Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Apply styles for WYSIWYG content #64

Merged
merged 2 commits into from
Apr 25, 2024
Merged

Conversation

dtrucs
Copy link
Contributor

@dtrucs dtrucs commented Apr 19, 2024

ref #62
I'm keeping this PR as a draft until the ARG has updated its tinyMCE configuration.

I used tinyMCE version 5 (https://cdn.tiny.cloud/1/qagffr3pkuv17a8on1afax661irst1hbr4e6tbv888sz91jc/tinymce/5/tinymce.min.js)
And below is the tinyMCE configuration corresponding to this development:

tinymce.init({
  selector: 'textarea',
  height: 800,
  plugins: [
    'autolink lists link image',
    'media mediaembed',
    'media table paste imagetools wordcount image_caption',
    'visualblocks'
  ],
  menubar: false,
  image_caption: true,
  toolbar: 'undo redo | styleselect | blockquote | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist | link image media | visualblocks',
  formats: {
    information: { 
      block: 'div', classes: 'information'
    }
  },
  style_formats: [
    { title: 'Headings', items: [
      {title: 'Headings 2', format: 'h2'},
      {title: 'Headings 3', format: 'h3'},
      {title: 'Headings 4', format: 'h4'},
      {title: 'Headings 5', format: 'h5'},
      {title: 'Headings 6', format: 'h6'}
    ]},
    {title: 'Inline', items: [
      {title: 'Bold', format: 'bold'},
      {title: 'Italic', format: 'italic'},
      {title: 'Underline', format: 'underline'},
      {title: 'Strikethrough', format: 'strikethrough'},
    ]},
    {title: 'Blocks', items: [
      {title: 'Paragraph', format: 'p'},
      {title: 'Blockquote', format: 'blockquote'},
      {title: 'Information', format: 'information'},
    ]},
    {title: 'Alignment', items: [
      {title: 'Left', format: 'alignleft'},
      {title: 'Center', format: 'aligncenter'},
      {title: 'Right', format: 'alignright'},
      {title: 'Justify', format: 'alignjustify'}
    ]}
  ],
  forced_root_block : false,
  default_font_stack: [ '-apple-system', 'Helvetica', 'Arial', 'sans-serif' ],
  content_style: `
  h1,h2,h3 {
    clear:both;
  }
  .align-left {
    float: left;
    margin-right: 1rem;
    margin-bottom: 1rem;
  }
  .align-right {
    float: right;
    margin-left: 1rem;
    margin-bottom: 1rem;
  }
  .information {
     clear: both;
     padding: 1rem;
     background: lightgray;
  }
`
});

@dtrucs dtrucs force-pushed the Apply-style-for-WYSIWYG-content branch from a536571 to 56a62ed Compare April 19, 2024 14:56
@dtrucs
Copy link
Contributor Author

dtrucs commented Apr 23, 2024

Compatibility with TinyMCE4 (the only change is the removal of the image_caption plugin, which doesn't yet exist in this version)

tinymce.init({
  selector: 'textarea',
  height: 800,
  plugins: [
    'autolink lists link image',
    'media mediaembed',
    'media table paste imagetools wordcount',
    'visualblocks'
  ],
  menubar: false,
  image_caption: true,
  toolbar: 'undo redo | styleselect | blockquote | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist | link image media | visualblocks',
  formats: {
    informationFormat: { 
      block: 'div', classes: 'information'
    }
  },
  style_formats: [
    { title: 'Headings', items: [
      {title: 'Headings 2', format: 'h2'},
      {title: 'Headings 3', format: 'h3'},
      {title: 'Headings 4', format: 'h4'},
      {title: 'Headings 5', format: 'h5'},
      {title: 'Headings 6', format: 'h6'}
    ]},
    {title: 'Inline', items: [
      {title: 'Bold', format: 'bold'},
      {title: 'Italic', format: 'italic'},
      {title: 'Underline', format: 'underline'},
      {title: 'Strikethrough', format: 'strikethrough'},
    ]},
    {title: 'Blocks', items: [
      {title: 'Paragraph', format: 'p'},
      {title: 'Blockquote', format: 'blockquote'},
      {title: 'Information', format: 'informationFormat'},
    ]},
    {title: 'Alignment', items: [
      {title: 'Left', format: 'alignleft'},
      {title: 'Center', format: 'aligncenter'},
      {title: 'Right', format: 'alignright'},
      {title: 'Justify', format: 'alignjustify'}
    ]}
  ],
  forced_root_block : false,
  default_font_stack: [ '-apple-system', 'Helvetica', 'Arial', 'sans-serif' ],
  content_style: `
  h1,h2,h3 {
    clear:both;
  }
  .align-left {
    float: left;
    margin-right: 1rem;
    margin-bottom: 1rem;
  }
  .align-right {
    float: right;
    margin-left: 1rem;
    margin-bottom: 1rem;
  }
  .information {
     clear: both;
     padding: 1rem;
     background: lightgray;
  }
  
`
});

@dtrucs dtrucs force-pushed the Apply-style-for-WYSIWYG-content branch from ddb858f to 4efd006 Compare April 23, 2024 13:22
babastienne added a commit to Georiviere/Georiviere-admin that referenced this pull request Apr 23, 2024
babastienne added a commit to Georiviere/Georiviere-admin that referenced this pull request Apr 23, 2024
submarcos pushed a commit to Georiviere/Georiviere-admin that referenced this pull request Apr 24, 2024
…contents (#249)

* ✨ [Improve] Configuration of TinyMCE to support additional style and contents

Refs: Georiviere/Georiviere-public#64

* Update georiviere/flatpages/static/js/tinymce.js

* Update georiviere/flatpages/static/js/tinymce.js
@dtrucs dtrucs changed the title Draft: Apply styles for WYSIWYG content Apply styles for WYSIWYG content Apr 24, 2024
@dtrucs dtrucs requested a review from Bo-Duke April 24, 2024 14:57
@dtrucs dtrucs merged commit a942769 into main Apr 25, 2024
2 checks passed
@dtrucs dtrucs deleted the Apply-style-for-WYSIWYG-content branch April 25, 2024 08:26
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants