Catching blot clicks (on selection-change) in readonly editor?
See original GitHub issueI’ve got a Blot where I catch clicks using on('selection-change')
and offer to change that blot with a menu. I’d now like to make the editor readonly, apart from changes made by the clicks on those blots. But if it’s readonly, on('selection-change')
is never hit, since source === "user"
.
You can “reproduce” this by doing quill.disable()
on quilljs.com and trying to edit a link, which also seems to use on('selection-change')
.
Is there a way to have a “readonly-light”, where users can’t modify text by typing, but they can by clicking on blots? I see there is this function
https://github.com/quilljs/quill/blob/131db2b98d1fcabf8586ecd1b493345ea2bb1002/core/quill.js#L431
which never emits anything if the editor is disabled and source is user, so I’m guessing there’s nothing implemented to do what I want using selection-change. But maybe there’s a different way I could get what I want?
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
If your goal is to find the blot would something like this work:
I was unsure if just the
blot
element would have enough info to safely remove/unwrap the blot, or change the text contents in it, but after looking through https://github.com/quilljs/parchment/#blots I see I can useQuill.find(node).offset(quill.scroll)
to get the the beginning/offset, andQuill.find(node).length())
to get the length, so I believe that gives me all the information I need 😃Thanks! I’ll close this then; using a normal DOM click event seems like a better solution than a “partial readonly” state.