0

Use selection.addRange(range) for insert html near default text, but this action doesn't save into history of input, and when i use ctrl+z, undo previous action, not change(insertNode) I need, that when I use ctrl+z, action undo detach my html, which i insert before i'l do this like that:

let node = target_fragment.appendChild(target.firstChild);
                range.insertNode(target_fragment);
                range = range.cloneRange();
                range.setStartAfter(node);
                range.collapse(true);
                selection.removeAllRanges();
                selection.addRange(range);
Roman
  • 1
  • p.s. if you use historyUndo when add tag after question, you destroy previous tag, stackoverflow has same problem – Roman Sep 20 '20 at 11:05
  • it works normaly, then use execCommand('insertHtml') with range.setStart/setEnd, but needs be carefully with listner, and capture unwanted events – Roman Sep 23 '20 at 05:23

0 Answers0