Bootstrap/TinyMCE

7 posts by 3 authors in: Forums > CMS Builder
Last Post: April 16   (RSS)

By glennp - March 22

Hello,

I was wondering if there is any info about integrating Bootstrap features grid with TinyMCE.

Thanks!

Glenn

By Dave - March 22

Hi Glenn, 

I haven't worked with anything like that but I see some tinymce plugins on Google: 

You'd have to experiment and see what's possible.  Looks interesting, though!

Dave Edis - Senior Developer
interactivetools.com

By glennp - March 22

Hi Dave,

Thanks for the reply!

Am I correct that the current version of CMSB uses TinyMCE 4? If so, I think I'd need to upgrade that first.

Glenn

By kitsguru - March 23

I use bootstrap 5.3+ with TinyMCE by using a wysiwyg_custom.php. I have used bootstrap from 3 to 5 over the years upgrading as needed.

Here is a snippet from that you can modify as required. I build a separate editor.css file from bootstrap that only has the classes I want to use in the editor.

      // add file modified time on end of url so updated files won't be cached by the browser
      // reference: https://www.tinymce.com/docs/configure/content-appearance/#content_css

      content_css: "$wysiwygCssUrl, /css/editor.min.css",

      content_css_cors: true,

      importcss_groups: [
        {title: 'Fonts Classes', filter: /\.h\d+|\.fs|\.display-|\.fw/}, // regex
        {title: 'Text Classes', filter: /\.lead|\.small|\.mark|\.text-|\.lh/}, // regex
        {title: 'Background Color', filter: /\.bg-/}, // regex
        {title: 'Buttons', filter: /\.btn/}, // regex
        {title: 'Cards', filter: /\.card/}, // regex
        {title: 'Columns', filter: /\.col|\.row|\.offset/}, // regex
        {title: 'Lists', filter: /\.list/}, // regex
        {title: 'Spacing', filter: /\.gap|\.g-|\.gx-|\.gy-|\.m-|\.mx-|\.my-|\.ms-|\.me-|\.mt-|\.mb-|\.p-|\.px-|\.py-|\.py-|\.ps-|\.pe-|\.pt-|\.pb-/}, // regex
        {title: 'Tables', filter: /\.table/}, // .class
        {title: 'Special Classes', filter: /\.dropcap|\.island|\.blockquote/},
        {title: 'Remaining classes', filter: /\./}, // .class
        {title: 'Other styles'}, // The rest
      ],

      importcss_append: true,
      importcss_merge_classes: true,
      importcss_exclusive: true,

// bootstrap template for a simple card
      templates: [
        {title: 'Simple Card', description: 'Simple Card template', content: '<div class="card"> \
        <div class="card-body"> <img src="..." class="card-img-top" alt="no image specified"> \
        <h5 class="card-title">Card title</h5> \
        <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card content.</p> \
        <a href="#" class="btn btn-primary">Go somewhere</a> \
        </div> \
        </div>'},

// bootstrap template for a 2 card
        {title: '2 Cards', description: '2 Card template side by side', content: '<div class="row"> \
        <div class="col-sm-6"> \
          <div class="card"> \
            <div class="card-body"> \
              <h5 class="card-title">Special title treatment</h5> \
              <p class="card-text">With supporting text below as a natural lead-in to additional content.</p> \
              <a href="#" class="btn btn-primary">Go somewhere</a> \
              </div> \
            </div> \
          </div> \
          <div class="col-sm-6"> \
            <div class="card"> \
              <div class="card-body"> \
                <h5 class="card-title">Special title treatment</h5> \
                <p class="card-text">With supporting text below as a natural lead-in to additional content.</p> \
                <a href="#" class="btn btn-primary">Go somewhere</a> \
              </div> \
            </div> \
          </div> \
        </div>'},
],
Jeff Shields

By glennp - April 16

Thanks, Jeff!

I think I'm missing something because I'm not getting the card template to appear. I've gotten a previous post of yours (https://www.interactivetools.com/forum/forum-posts.php?postNum=2240125#post2240125) to work.

The site I'm working on uses Bootstrap 4. Is there any chance you have complete working files with your example?

Glenn

By glennp - April 16

Thank you for your help, Jeff.

Glenn