question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trigger 'editor-change' when user changes image alignment

See original GitHub issue

Description

I scratched my head for hours to verify this before even posting. I founded out that when a user interacts with the alignment Toolbar, there is no ‘editor-change’ event being triggered. I can be a problem when a user change alignment as final action since it will not be registered by my Vue component (I rely on a change event bound to Quill editor-change event).

Demo

  1. open this plunkr
  2. open dev console
  3. try resizing an image: editor-change triggered
  4. try changing alignment: no editor-change 😭

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:8
  • Comments:10

github_iconTop GitHub Comments

5reactions
benwindingcommented, Oct 29, 2019

Okay, we solved this issue by adding the code from this comment: https://github.com/kensnyder/quill-image-resize-module/issues/10#issuecomment-317747389

var BaseImageFormat = Quill.import('formats/image');
const ImageFormatAttributesList = [
    'alt',
    'height',
    'width',
    'style'
];

class ImageFormat extends BaseImageFormat {
  static formats(domNode) {
    return ImageFormatAttributesList.reduce(function(formats, attribute) {
      if (domNode.hasAttribute(attribute)) {
        formats[attribute] = domNode.getAttribute(attribute);
      }
      return formats;
    }, {});
  }
  format(name, value) {
    if (ImageFormatAttributesList.indexOf(name) > -1) {
      if (value) {
        this.domNode.setAttribute(name, value);
      } else {
        this.domNode.removeAttribute(name);
      }
    } else {
      super.format(name, value);
    }
  }
}

Quill.register(ImageFormat, true);
                
                
var quill = new Quill('#editor', {
    theme: 'snow',
    modules: {
        imageResize: {}
    }
});

3reactions
jsieberncommented, May 8, 2018

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trigger 'editor-change' when user changes image alignment
I founded out that when a user interacts with the alignment Toolbar, there is no 'editor-change' event being triggered. I can be a...
Read more >
How can a change on the select tag trigger changing the src of ...
Is it possible to put an image that changes based on your selected option in a select tag? I need to change the...
Read more >
Events Available for TinyMCE | Docs
The following examples illustrate how to use supported native events, editor core events, and plugin events with TinyMCE.
Read more >
API - Quill Rich Text Editor
Formats text in the editor, returning a Delta representing the change. For line level formats, such as text alignment, target the newline character...
Read more >
CodeMirror 5 User Manual
Fired whenever a change occurs to the document. changeObj has a similar type as the object passed to the editor's "change" event. "beforeChange"...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found