Open sotaan opened 6 years ago
im having the same problem
+1
+1
+1
样式改变没响应,大神们,有解决的没?
Anyone ever solve this issue?
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: {}
}
});
Great! I saw your message just ago. Good luck!
You can use a mutation observer with a debounced callback to obtain any change which occurred to the HTML in the editor. The only possible downside is that it could trigger on something like the resize grabbers and alignment overlay appearing. Also make sure to disconnect the observer to prevent possible memory leaks.
const editor = new Quill(...)
const mutationObserver = new MutationObserver(debounce(() => {
console.log(editor.root.innerHTML)
}, 200))
mutationObserver.observe(editor.root, {
attributes: true,
characterData: true,
childList: true,
subtree: true,
})
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 Quilleditor-change
event).Demo
editor-change
triggerededitor-change
😭