-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Shadow DOM v1 #2021
Comments
@jhchen Shadow DOM is becoming reality and many frameworks are taking advantage of it. I think it would be a great feature for 2.0 version of the modern Quill editor. Do you think version 2.0 will support it? |
Any news on this? |
bump. PLEASE add shadow dom support. this editor is so nice. |
Any news on this? |
Hello, I'm revisiting quill after about 4 months after not being able to use it due to this issue. Is it actively being worked on or is it simply not realistic... |
We've now reached 88.66% global browser support for Shadow DOM (V1). We can ignore IE or Edge at this point, since libs like Lit are poly-filling and use Light DOM. Any updates or plans to implement support for 2019? |
This would be really helpful! I love quill but we can't really use it today in our Polymer/LitElement application... :( |
@ronnyroeller Try this fork https://github.com/web-padawan/quill/tree/shadow |
Interesting, @web-padawan - any chance this can get merged back into master? Maybe now when Edge is also Chromium based it will get accepted. |
I have quill working in shadowdom almost perfectly without any changes to quill itself, however I have an issue in Firefox where the cursor will not display in the quill editor, but does know my cursors position. |
how? do you have demo? |
@aanavaneeth Demo of quill almost working in shadow Dom or the tabbing thing? I'm not sure why the tabbing thing happens the way it does and am currently trying to fix that. Only happens in Firefox. Regardless this weekend I can make a simple example repo and link it here. The hill I am dying on is this Firefox issue though. |
Demo of working in shadow DOM. Frankly, for now I am ok if it doesn't work perfectly in FF but hoping for it i n near future. |
I'm using the following polyfill workaround if it helps anyone, it is not perfect, but makes the editor fairly usable in Firefox. It also has a small memory leak because of the event listener in the end that is not cleaned up if the quill instance is thrown away. It is a mix of the shadow-selection-polyfill npm package and a script from stackoverflow (link in code comment): import { getRange } from 'shadow-selection-polyfill';
// Shadow DOM fix based on https://stackoverflow.com/questions/67914657/quill-editor-inside-shadow-dom/67944380#67944380
export function quillSelectionFix(quill) {
const normalizeNative = (nativeRange) => {
// document.getSelection model has properties startContainer and endContainer
// shadow.getSelection model has baseNode and focusNode
// Unify formats to always look like document.getSelection
if (nativeRange) {
const range = nativeRange;
if (range.baseNode) {
range.startContainer = nativeRange.baseNode;
range.endContainer = nativeRange.focusNode;
range.startOffset = nativeRange.baseOffset;
range.endOffset = nativeRange.focusOffset;
if (range.endOffset < range.startOffset) {
range.startContainer = nativeRange.focusNode;
range.endContainer = nativeRange.baseNode;
range.startOffset = nativeRange.focusOffset;
range.endOffset = nativeRange.baseOffset;
}
}
if (range.startContainer) {
return {
start: { node: range.startContainer, offset: range.startOffset },
end: { node: range.endContainer, offset: range.endOffset },
native: range
};
}
}
return null
};
// Hack Quill and replace document.getSelection with shadow.getSelection
// eslint-disable-next-line no-param-reassign
quill.selection.getNativeRange = () => {
const dom = quill.root.getRootNode();
// const selection = dom.getSelection instanceof Function ? dom.getSelection() : document.getSelection();
const selection = getRange(dom);
const range = normalizeNative(selection);
return range;
};
// Subscribe to selection change separately,
// because emitter in Quill doesn't catch this event in Shadow DOM
document.addEventListener("selectionchange", () => {
// Update selection and some other properties
quill.selection.update();
});
} |
@tirithen with this approach, there is a problem of copy/pasting in chrome |
In case anyone is still trying to solve this, here's what I have (seems to work ok in Chromium, Gecko, Webkit browsers, including copy/paste, selection, keyboard shortcuts, etc. Note: for Safari it requires > Safari 17 which has the new Selection API All issues seemed to boil down to three problems:
Here's a codepen example: https://codepen.io/John-Hefferman/pen/yLZygKo?editors=1000
|
Any news on this issue? |
@luin Now that Quill 2.0 has released, are we interested in a PR for this based on @jhefferman-sfdc's snippet above? I can submit one if so. I've tested their changes on v2 within a shadow root and its working very well, so it shows promise. |
Quill 2.0.0 has same bugs with Web components: EasyWebApp/quill-cell@8bf3c6d Reproduce
|
Please note that the code snippet above isn't really the only thing that should be applied. This part also need an update: See also #1805 where shadow DOM support was originally prototyped for some other places where |
Hello,
#1472 can we get this issue reopened or at least have a new one on the subject?
The stable spec is over a year old, chrome, safari and other webkit based browsers have full support, firefox nightly ships Shadow Dom behind a flag already and stable will probably land with support at the end of march.
The text was updated successfully, but these errors were encountered: