From 43e740c88d1505be5acbb9b3d7bcea9c9cb080c3 Mon Sep 17 00:00:00 2001 From: Doug Reeder Date: Mon, 11 Oct 2021 20:40:38 -0400 Subject: [PATCH] docs: clarifies not setting editor values directly & plugin order (#4571) * Updates "Saving to a Database" example to distinguish actual content changes. * Update docs/walkthroughs/06-saving-to-a-database.md * Update docs/walkthroughs/06-saving-to-a-database.md * Update docs/walkthroughs/06-saving-to-a-database.md * Runs prettier * docs: clarifies not setting editor values directly & plugin order * Changes reccommended order of withReact & withHistory, to match current knowleged Co-authored-by: Dylan Schiemann --- docs/concepts/07-editor.md | 2 ++ docs/general/contributing.md | 6 ++++++ docs/libraries/slate-history.md | 6 ++++++ docs/libraries/slate-react.md | 6 ++++++ 4 files changed, 20 insertions(+) diff --git a/docs/concepts/07-editor.md b/docs/concepts/07-editor.md index 7b4392c56..8816958d1 100644 --- a/docs/concepts/07-editor.md +++ b/docs/concepts/07-editor.md @@ -33,10 +33,12 @@ It is slightly more complex than the others, because it contains all of the top- The `children` property contains the document tree of nodes that make up the editor's content. The `selection` property contains the user's current selection, if any. +Don't set it directly; use [Transforms.select](04-transforms#selection-transforms) The `operations` property contains all of the operations that have been applied since the last "change" was flushed. \(Since Slate batches operations up into ticks of the event loop.\) The `marks` property stores formatting to be applied when the editor inserts text. If `marks` is `null`, the formatting will be taken from the current selection. +Don't set it directly; use `Editor.addMark` and `Editor.removeMark`. ## Overriding Behaviors diff --git a/docs/general/contributing.md b/docs/general/contributing.md index d49ee9fb7..cb88e34a6 100644 --- a/docs/general/contributing.md +++ b/docs/general/contributing.md @@ -87,6 +87,12 @@ yarn lint This will catch TypeScript, Prettier, and Eslint errors. +```text +yarn fix +``` + +This will fix Prettier and Eslint errors. + ## Running integration tests To run integrations with [cypress](https://github.com/cypress-io/cypress), first run `yarn start` to run the examples website, then run `yarn cypress:open` in a separate session to open the cypress GUI. diff --git a/docs/libraries/slate-history.md b/docs/libraries/slate-history.md index aae3b5a8d..71edaedef 100644 --- a/docs/libraries/slate-history.md +++ b/docs/libraries/slate-history.md @@ -13,3 +13,9 @@ This sub-library tracks changes to the Slate value state over time, and enables ## `withHistory` The `withHistory` plugin keeps track of the operation history of a Slate editor as operations are applied to it, using undo and redo stacks. + +When used with `withReact`, `withHistory` should be applied inside. For example: + +```javascript +const editor = useMemo(() => withReact(withHistory(createEditor())), []) +``` diff --git a/docs/libraries/slate-react.md b/docs/libraries/slate-react.md index fe5c77468..e7c1daff6 100644 --- a/docs/libraries/slate-react.md +++ b/docs/libraries/slate-react.md @@ -180,6 +180,12 @@ React-specific plugins for Slate editors Adds React and DOM specific behaviors to the editor. +When used with `withHistory`, `withReact` should be applied outside. For example: + +```javascript +const editor = useMemo(() => withReact(withHistory(createEditor())), []) +``` + ## Utils Private convenience modules