-
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
Nested properties get ignored. #1333
Comments
After investigating I have found that the clipboard module is building up the document in a depth first order. This causes parent attributes to always overwrite child attributes. One way to fix this is by adding an option for 'retain' Deltas to be soft - i.e. to preserve existing attribute values if they exist. I have pull requests on the quill-delta and quilljs projects that implement this:
|
I think for the Clipboard's purposes it should always favor the lower tree nodes since that how CSS rules are prioritized so a config is not necessary. I don't think modifying the Delta API is the best approach and others should be explored first as the cost of this approach is supporting that API forever and all the interactions with other APIs. |
Yes, for clipboard (as currently written) use case you always want to prioritize the existing values, but for the interactive case you always want to prioritize the new values. Modifying the delta API should certainly be considered carefully. The clipboard traverse and match* functions could be rewritten to work top down with the existing delta API, but this will require some extra bookkeeping outside of the Deltas. |
The Delta API is very simple with only insert, retain, and delete operations, but powerful enough to build a full text editor on top of. My proposed "soft" retain, while it would be useful in certain document creation situations, is not likely to be useful for general document editing. If the Delta API is to be expanded is should probably be in a way that is much more generally applicable than my 'soft' retain proposal. One possible addition that would work for both document editing and creation cases is to allow passing in a function to control how attributes are merged on retain operations. This could be an optional argument to retain operations, or it could be a new operation type. Doing it that way would allow a simple way to add editor features like 'make selected text 20% larger' as well as allow for a simple way to perform 'soft' retains for document creation workflows. it could be used something like this:
If it is a requirement that Deltas are able to be persisted, then one could add an indirection through a registry without too much extra effort. |
I think I would favor just fixing this specific bug in the Clipboard (which is used for initialization). |
I can still reproduce the issue From test case - If I add this to editor(innerHTML) and get the delta (quill.getContents()), I get - In the clipboard - select the string + cut + undo and the text becomes red |
It's working for me. @dsathyan You are following the steps for reproduction precisely? It sounds like you are doing something else from the mention of innerHTML |
My bad, it does work And innerHTML unleashes a different beast and not related to clipboard |
When initializing a quill view with existing content nested properties get overridden by the outermost definition
Steps for Reproduction
<span style="color: #000;">black <span style="color: #F00;">red</span> black</span>
Expected behavior:
The word red should be colored red.
Actual behavior:
All the words are black
Platforms:
safari 10.0.3
OS X Yosemite 10.10.5
Version:
1.2.0
The text was updated successfully, but these errors were encountered: