Undo / Redo does not work properly for EmbedBlot.
See original GitHub issuePlease describe the a concise description and fill out the details below. It will help others efficiently understand your request and get to an answer instead of repeated back and forth. Providing a minimal, complete and verifiable example will further increase your chances that someone can help.
Steps for Reproduction
- Added a new EmbedBlot and defined
value
functions. - After I add a new EmbedBlot on the Quill component, I try
CTRL+Z
forundo
.
- When there is no appended texts,
undo
just removes that Custom Blot perfect. But if I tryredo
, then it just adds a simpletext
(fromvalue()
function) and does not add CustomBlot back. - When there is appended texts, its behavior is really messy. I am gonna attach the video below for that.
class MathInputCmp extends Embed {
state = {
mathField: null
};
static create(val) {
const node = super.create();
node.innerHTML = '<span class="input__math__field"></span>';
node.setAttribute('data-latex', val);
node.setAttribute('contenteditable', false);
return node;
}
static value(domNode) {
return domNode.getAttribute('data-latex');
}
static formats(domNode) {
const MQ = window.MathQuill.getInterface(2);
const mathField = MQ.StaticMath(domNode.firstChild);
return {
"data-latex": mathField.latex()
};
}
constructor(domNode, value) {
super(domNode, value);
const MQ = window.MathQuill.getInterface(2);
const mathField = MQ.StaticMath(domNode.firstChild);
mathField.latex(value);
domNode.setAttribute('data-latex', value);
this.state = {
mathField
};
}
value() {
return this.state.mathField.latex();
}
format(name, value) {
if (name === 'data-latex') {
if (value) {
this.domNode.setAttribute('data-latex', value);
} else {
this.domNode.removeAttribute('data-latex');
}
} else {
super.format(name, value);
}
}
}
MathInputCmp.blotName = "MathInput";
MathInputCmp.tagName = "span";
MathInputCmp.className = "input__math";
Quill.register(MathInputCmp, true);
Expected behavior:
- undo should remove CustomBlot completely.
- redo should restore CustomBlot again.
Actual behavior:
- undo does not remove CustomBlot sometimes.
- redo is not adding CustomBlot back never.
Platforms:
Google Chrome 72.0
Using this on react
react-quill
: 1.3.3
quilljs
: 1.2.6
Version:
quilljs
: 1.2.6
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:8
Top Results From Across the Web
How to create undo/redo buttons in Quill JS (react-quill)?
Here's how to make undo/redo work for react-quill: ... In the editor, the undo/redo buttons don't have the icons yet; I haven't figured...
Read more >Getting to know QuillJS - Part 1 (Parchment, Blots, and Lifecycle)
Blots are not necesarilly always constructed with their create function. ... and Parchment.create(blotName) will work correctly.
Read more >Why is undo/redo not working! - Blender Stack Exchange
Pressing Shift + Alt when? As far as I am aware there is no way to disable undo/redo.
Read more >Quill - Pasting Custom Embed Sometimes Return Boolean Instead ...
After I add a new EmbedBlot on the Quill component I try CTRL+Z for undo. When there is no appended texts undo just...
Read more >Test Tables - JS Bin - Collaborative JavaScript Debugging
scrollIntoView(); this.stack[dest].push(delta); } }, { key: 'clear', value: function clear() { this.stack = { undo: [], redo: [] }; } } ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Similar problem. For me though,
undo
restores the custom blot with the wordtrue
, no matter what was in there before.I am on
2.0.0-dev.3
.I also encounter this problem. We need get a complete delta information when excute ‘undo’ operation. Or whole node is also accepted.