slab / quill

Quill is a modern WYSIWYG editor built for compatibility and extensibility
https://quilljs.com
BSD 3-Clause "New" or "Revised" License
43.75k stars 3.4k forks source link

Bug: Event editor-change not fired when user change active format #2969

Closed m-malczyk closed 7 months ago

m-malczyk commented 4 years ago

I want to get notified when user change active format (but without formatting any text in editor) via key shortcut

Steps for Reproduction

  1. https://codepen.io/mmalczyk/pen/MWwVgPE?editors=1111
  2. important Select some text and press ctrl+B
  3. Both text-change and editor-change are emited (check console) - this is fine.
  4. Place cursor anywhere in editor, but without selecting any letters, press ctrl + B
  5. BUG: No events emitted when user press predefined shortcut.

What I'm trying to do I'm creating a custom toolbar (something like in 'Cloning Medium with Parchment') whiten in angular-material, and I want to toggle: bold, italic, underscore buttons when user press keyboard shortcuts. Exactly how the native quill toolbar is working. I have no event to listen for format change even the getFormat method return correct format when manually invoke that method.

What I tried so far: had the idea to add key bindings for 'B', 'I', 'U' but this are default quill bindings and according to documentation:

Note: Since Quill’s default handlers are added at initialization, the only way to prevent them is to add yours in the configuration.

I had to create them in quill initialization, in my case in QuillModule.forRoot (ngx-quill) method. It not suit me because I have multiple editors on single page.

Expected behavior: It would be nice to have a event like: format-change or current-formatting-change that will be emitted when user change formatting at the cursor

Actual behavior: there is no event for that in Emitter.events = { EDITOR_CHANGE: 'editor-change', SCROLL_BEFORE_UPDATE: 'scroll-before-update', SCROLL_OPTIMIZE: 'scroll-optimize', SCROLL_UPDATE: 'scroll-update', SELECTION_CHANGE: 'selection-change', TEXT_CHANGE: 'text-change' };

Platforms: tested on chrome 80.0.3987.132

Version: https://cdn.quilljs.com/1.3.7/quill.core.js

sudofox commented 3 years ago

Trying to do the same thing here. It seems like such an essential thing that I'm not sure why it's not front-and-center in the docs.

Oddly, I'm not even getting the editor-change event on my editor.

quill-bot commented 7 months ago

Quill 2.0 has been released (announcement post) with many changes and fixes. If this is still an issue please create a new issue after reviewing our updated Contributing guide :pray: