Repository navigation
Conversation
|
This is one big patch but it's nice to see that shadow dom support seems closer. Earlier attempts that I've made failed due to limitations in Chrome the only browser implementing it at the time. The show stopper then was focus it was impossible to sub focus items properly within a shadow root. There is a reason why we use ID:s on everything. Legacy browser support requires us to not have or at least limit the number of references from JS to DOM to avoid memory leaks on older IE versions. One small reference could cause the whole document to linger in ram on each reload. However we could probably abstract that away better. Also we really need caretRangeFromPoint in fact in the next 4.3 version we use it a lot more so that is a show stopper if it's buggy. So I guess we could do this in steps small iterations. Also the getContatinerElm is a left over from the last attempt I made towards shadow dom: I in that version tried to render everything within the shadow root to make it self contained. |
|
Can you clarify what IE versions are officially supported? It seems like IE8+, but I saw some hacks for 6-7 in code. Anyway, some abstraction would be really helpful here. Chromium is evergreen browser, just help pushing developers in mentioned Chromium issue and in few months after implementation we can use it rather safely. It is not buggy, it is just not available inside Shadow DOM at all, this is the main problem. I've tried to move everything under Shadow DOM initially as well, but then decided to leave modals and tooltips where they are to simplify changes (also this is my first time touching internals of TinyMCE). In fact in my own custom elements I put tooltips and modals under |
|
As first steps abstracting elements selection and event targeting fixes might be upstreamed since they'll not hurt anything. |
|
I think the e.path/e.deepPath should be added to EventUtils.js logic so all events everywhere gets patched. |
|
We support IE 8 we used to support IE 7 as well. |
|
So now IE7 is gone, right? |
4057298 to
c16c6c0
Compare
|
Good news on working under polyfill. No updates about those 2 failing tests. All other things as far as I've tested work fine, its just a matter of proper CSS pre-processing. Ideally, it should be cooked as Web Component (Polymer element) and stylesheet files should be explicitly included to be properly shimmed (I'll prepare such element soon). Alternatively to use CSS that we obtain from using script I've mentioned before under polyfill we can to patch I've thought to hack What are your thoughts about upstreaming changes from this PR? |
|
Rebased against master |
abc4240 to
3380ead
Compare
3380ead to
119bba4
Compare
|
Rebased against master and included updated changes from #2459 <cs-editor>
<textarea></textarea>
</cs-editor>
<cs-editor-simple>
<textarea></textarea>
</cs-editor-simple>
<cs-editor-inline>
<div></div>
</cs-editor-inline>
<cs-editor-simple-inline>
<div></div>
</cs-editor-simple-inline>And it doesn't matter whether it is located under Shadow DOM at any depth or just in main document tree - it works everywhere. Elements are opinionated and intended to be used withing CleverStyle CMS, but it is possible to create general purpose elements as well. Just wanted to post working example of, probably, first build of fully functional (I hope so, no problems so far) feature-reach WYSIWYG editor working under Shadow DOM ever, as reference point. |
119bba4 to
5d73cb6
Compare
|
Good news, I found the reason of that 2 failed tests and now they are all green! |
|
Will have to schedule some time to bring this into the core. Since if we add it we need to A) Maintain it for ever. B) Add a bunch of unit tests. We want to improve integrations with web components, react and angular so it's in the backlog. |
5d73cb6 to
1e2e9b4
Compare
|
Just rebased against master once again, fixed one bug appeared after rebase - there was infinite loop when closing modal popups because of recursive |
1e2e9b4 to
0586ff3
Compare
…the same specificity, but might be useful in certain scenarios
0586ff3 to
bff624a
Compare
For this we keep forwarding target element property everywhere to know about Shadow Root when we make searching for element by its ID. Also in jQuery version `settings.target` is filled automatically, otherwise afterwards it will not be possible to find element under Shadow DOM. `window.getSelection()` is changed to element's shadow root like `shadowRoot.getSelection()` in inline mode. Active element detection is fixed, since active element under Shadow DOM should be defined on closest Shadow Root. Target correction on focus in/out events. Fix for drag'n'drop in inline mode under Shadow DOM (limited to insertion at the beginning or at the end). Fix for `element.ownerDocument` might be wrapped by polyfill and thus not be the same as `document`. Fix for using `document.activeElement` being not-wrapped under polyfill, while it needs to be before usage. Fix for tests to provide `settings.target` for `getEl()` call.
bff624a to
7119b02
Compare
|
The TinyMCE source code has been converted to TypeScript which makes this PR impossible to merge, so I am closing it. Please open up a new PR written in TypeScript if you want us to take a look at it again. |
|
Man, this is rude! I was working on multiple things from trivial to complex like this one, rebased them multiple times against moving target and now you're just closing it? |
|
It wasn't closed to be rude, just to get a clean slate with the PRs now that the whole project is written in TypeScript. |
|
I have been watching this PR for long time and now it got closed 😥 . I'm using tinymce in a Chrome extension which inserts an editor in a website and I need to use it in a ShadowDOM for encapsulation. I'm using nazar-pc/tinymce fork for now but that's more than two years old. Chrome and Safari support ShadowDOM natively and Firefox is going to ship with it somewhere in 2018. |
|
@rkbhochalya, I will try to rebase this soon and will try to submit another PR when ready. I was rebasing this PR alongside with other tweaks for CleverStyle Framework till March last year (https://github.com/nazar-pc/CleverStyle-Framework/tree/master/modules/TinyMCE/assets/js), but apparently didn't publish rebased branches to my fork, sorry about that.
This was said more than 2 years ago and it would really help, but it doesn't seem to be moving in that direction at all. I hope smaller PRs like #2928, #2913 and #4163 will be merged without issues very soon, since at least we have some answers from TinyMCE team now. |
|
Any update on this? I am trying to get tinymce to work in Polymer 2... |
|
Not yet, I'm working on stuff like this in my spare time and since not actively using TinyMCE right now, can't promise any dates besides that I'll make it work with Polymer 2/3 one day in future. |
|
Okay no worries! Thank you :) |
|
Hey nazar-pc, I am the product manager for TinyMCE, and I just want to say I appreciate the work you have done keeping this alive. I know things haven't been moving very fast in this direction from our point of view, we really need it supported in all major browsers before we commit to it fully, as Spocke says, once we enable the support for Shadow DOM, we are stuck supporting it. I hope you understand. I highly suggest making a new PR, summarize what issues remain etc and we can try work from there. |
* commit 'f09d9da389e4f30ae619315b9f145036f539be79': TINY-1581: domquery should return empty string if elm.ownerDocument.defaultView is falsy
|
Great work, @nazar-pc! |
The first attempt to bring TinyMCE under Shadow DOM and make it working there.
To be honest I'm not expecting this to be merged, but I want to show main issues in current architecture and demonstrate that this is indeed possible.
Related feature was requested here, this is just first essential step (and is more generic): http://www.tinymce.com/forum/viewtopic.php?pid=117628
What works
TinyMCE under native Shadow DOM (including inline mode) - selection, cut/paste, all buttons, dropdowns, modals, etc.
I've tested most of plugins, to be specific:
This patch includes only JS part, CSS can be easily converted to such that penetrates Shadow Root and thus will work using this script (ideally, we'll need to wrap everything into custom element to avoid using deprecated
/deep/, but it works for now and will work for quite long time until we'll implement it properly).What doesn't work
TinyMCE under Shadow DOM polyfill from WebComponents.js.
This is in progress, I'm planning to implement this as well, but changes in Shadow DOM polyfill will be necessary, so this will take some more time, hopefully not too much, PR will be updated.
Also 2 tests fail, don't know yet why exactly, but they don't seem to be critical indeed (help is welcomed).
Partially working features
caretRangeFromPoint()method is present only ondocument, but not onshadowRoot(mailing list, relevant Chromium issue, vote, please) and usingdocument.caretRangeFromPoint()gives us just Shadow Root's host element.Because of this we can't find exact position where content was dropped.
However,
shadowRoot.elementFromPoint()method is present and is used as last resort to drop contents to the beginning or the end of string, this was the best alternative I was able to get working and it is not that bad actually.BC breaks
Current design involves very, VERY bad, horrible idea to reference everything by ID.
Since some elements are under Shadow DOM we need to know where Shadow Root is, for this purpose
targetproperty should be passed in settings withtextarea(or target element in inline mode), which involves trivial changes for many of TinyMCE's internals and some plugins/themes.I had some idea about repository of elements like key-value storage
id:dom_node_referenceto make smaller changes to existing structure from one side and avoid problems with determining current document/shadow root to search for ID in from another side.Implementation
First 3 commits might be actually separated since they are generic and will not break anything in existing code, the last is heavy with actually implementing all essential things. Please, refer to commit messages for details (tricky parts in code also commented).
What is next?
I expect feedback from core developers and those who are interested about how TinyMCE's core might be adjusted to make this patch less invasive and avoid breaking plugins/themes (
settings.targetis required now).Also any other feedback about implementation and/or help with fixing those 2 tests and/or anything else - I'm open for discussion.