memos icon indicating copy to clipboard operation
memos copied to clipboard

redo/undo

Open ChasLui opened this issue 2 years ago • 1 comments

Is your feature request related to a problem?

no

Describe the solution you'd like

The editor currently uses the browser textarea comes with redo/undo, but in the call insertText can not generate the browser default undoStack, to solve this problem there are several options.

  1. use document.execCommand to replace the current editorRef.current.value assignment, but this api is no longer recommended.

  2. generate a snapshot of editorRef.current.value and use the snapshot stack to replace the current value when redo/undo. 3.

  3. abstract command and transaction, when modifying content to generate a transaction, including content changes and cursor changes, which is the design of modern rich text editors.

If no one has implemented it I can pr a draft

Additional context

No response

ChasLui avatar Dec 20 '22 16:12 ChasLui

@ChasLui The option2 LGTM. Please have a try.

boojack avatar Dec 21 '22 10:12 boojack