GetmeUK / ContentTools

A JS library for building WYSIWYG editors for HTML content.
http://getcontenttools.com
MIT License
3.95k stars 395 forks source link

Mount ct-app to specific element? #373

Closed patrikengborg closed 7 years ago

patrikengborg commented 7 years ago

Hi,

Is there any way to mount (or remount) the ct-app to a specific element instead of the body?

I'm trying to avoid some tricky z-index issues and this would be the easiest way to get around it.

Thanks!

patrikengborg commented 7 years ago

Just tried to remount it manually. Obviously not the prettiest solution, but it seems to work fine. Could it come with any drawbacks?

document.querySelector('#target').appendChild(document.querySelector('.ct-app'))

anthonyjb commented 7 years ago

Hi @patrikengborg so I can't see any issue with this how it's probably advisable to override the mount function instead, so in JS:

var editorCls = ContentTools.EditorApp.getCls();
editorCls.prototype.mount = function () {
        this._domElement = editorCls.createDiv(['ct-app']);
        document.querySelector('#target').appendChild(this._domElement, null);
        this._addDOMEventListeners();

}
patrikengborg commented 7 years ago

You're a star, thanks! Will post questions to Stackoverflow from now on, didn't see the guidelines until after this. Sorry!