question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature request] Allow TinyMCE to fill parent container - 100% height

See original GitHub issue

Do you want to request a feature or report a bug? feature What is the current behavior? currently we can specify height of TinyMCE as number, but there isn’t any easy way to set height to 100% **If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via fiddle.tinymce.com or similar.

What is the expected behavior? I’d like to be able to specify that TinyMCE should fill it’s parent container. If it is inside div then it should fill div, if inside body then entire body. Which versions of TinyMCE, and which browser / OS are affected by this issue? Did this work in previous versions of TinyMCE? 4.5.5 Chrome 57 Win10x64

There are many questions related to this issue, for example https://community.tinymce.com/communityQuestion?id=90661000000MrXkAAK http://stackoverflow.com/questions/9588025/change-tinymce-editors-height-dynamically http://stackoverflow.com/questions/19861838/tinymce-4-and-100-height-within-containing-element#

and some partly solutions: https://gist.github.com/xypaul/efae27e0d0093d0746c3

but they aren’t working perfectly, In my case my custom sidebar isn’t displayed correctly.

It would be awesome if You guys could allow this behavior, simply by adding an extra option (fill_container, default false) for it or allow us to specify height as percentage value.

When using resize we can resize editor, so maybe same code can be used, but instead of user selected height it can use height of parent container?

When looking at content using Chrome Developer tools we can see that the when resizing editor only this that is changing is height of iframe with classes mce-edit-area mce-container mce-panel mce-stack-layout-item mce-first. Maybe this can be calculated on init and on page resize?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:1
  • Comments:42 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
Misiucommented, Mar 22, 2017

I’ve created plugin for this:

tinymce.PluginManager.add('autoheight', function(editor) {

  var editor_container;
  var bars_height = 0;

  function resizeEditor(e) {
    if (typeof(editor_container) === 'undefined') return;

    try {
      var element_height = parseInt(window.getComputedStyle(editor_container).height);
      /*calculate bar height only once*/
      if (bars_height === 0) {
        var toolbars = editor_container.querySelectorAll('.mce-toolbar, .mce-statusbar, .mce-menubar');
        /*IE11 FIX*/
        var toolbarsLength = toolbars.length;
        for (var i = 0; i < toolbarsLength; i++) {
          var toolbar = toolbars[i];
          /*skip sidebar*/
          if (!toolbar.classList.contains('mce-sidebar-toolbar')) {
            var bar_height = parseInt(window.getComputedStyle(toolbar).height);
            bars_height += bar_height;
          }
        }
      }
      /*the extra 8 is for margin added between the toolbars*/
      new_height = element_height - bars_height - 8;
      editor.theme.resizeTo('100%', new_height);
    } catch (err) {
      console.log(err);
    }
  }
  editor.on('ResizeWindow', resizeEditor);
  editor.on("init", function() {
    try {
      editor_container = editor.getContainer().parentNode;
    } catch (e) {
    }
    setTimeout(function() {
      resizeEditor();
    }, 0);
  });
});

Demo is available here: https://codepen.io/Misiu/pen/EWEVPo

I’ll create repository for this if this can’t be added to core.

1reaction
Misiucommented, Mar 2, 2020

@spocke any updates? 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

TinyMCE 4 and 100% Height Within Containing Element
Now, I am looking for a pure CSS (no calc() function) solution to make the entire editor fill its container and be fluidly...
Read more >
height - TinyMCE
This height can be very useful to specify if the editor is used in hidden tabs or if the editor area should be...
Read more >
Safari Technology Preview Release Notes - Apple Developer
Allowed Wasm import from a JS Worker module behind the feature flag ... show each item's CSS order and/or DOM index in the...
Read more >
WordPress TinyMCE Editor Tips | How to Add Custom Buttons ...
Declaring a new TinyMCE button. Let's start with the basics – in order to make our buttons appear in the editor, we have...
Read more >
Moodle in English: TinyMCE 6 - prototype available
Feature request : track changes for assignments · Moodle LMS research ... x.x dev site allows me to use both the current TinyMCE...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found