ianstormtaylor / slate

A completely customizable framework for building rich text editors. (Currently in beta.)
http://slatejs.org
MIT License
29.9k stars 3.25k forks source link

Load different content #5710

Open tingjiangcao opened 2 months ago

tingjiangcao commented 2 months ago

I'm developing a note-taking software. Need to switch between different note files. And the method I have found so far is as follows:

Transforms.delete(editor, { at: { anchor: Editor.start(editor, []), focus: Editor.end(editor, []), }, }) Transforms.removeNodes(editor, {at: [0],}) Transforms.insertNodes(editor, noteObject) Transforms.select(editor, Editor.start(editor, []));

I'm wondering if there is a more simplified way that can be provided to accomplish this group. Because this is a more commonly used function.

I'm not sure if there's a method I'm not aware of

yf-yang commented 2 months ago

https://github.com/udecode/plate/blob/main/packages/slate-utils/src/transforms/replaceNode.ts