mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-31 10:51:44 +02:00
Expose transforms (#836)
* refactor to extract applyOperation util * change handlers to receive transform instead of state * change onChange to receive a transform, update rich-text example * fix stack iterationg, convert check-list example * convert code-highlighting, embeds, emojis examples * change operations to use full paths, not indexes * switch split and join to be recursive * fix linter * fix onChange calls * make all operations invertable, add src/operations/* logic * rename "join" to "merge" * remove .length property of nodes * fix node.getFragmentAtRange logic * convert remaining examples, fix existing changes * fix .apply() calls and tests * change setSave and setIsNative transforms * fix insert_text operations to include marks always * cleanup and fixes * fix node inheritance * fix core onCut handler * skip constructor in node inheritance * cleanup * change updateDescendant to updateNode * add and update docs * eliminate need for .apply(), change history to mutable * add missing file * add deprecation support to Transform objects * rename "transform" to "change" * update benchmark * add deprecation util to logger * update transform isNative attr * fix remaining warn use * simplify history checkpointing logic * fix tests * revert history to being immutable * fix history * fix normalize * fix syntax error from merge
This commit is contained in:
@@ -15,10 +15,10 @@ Instead, the new state is propagated to the Slate editor's parent component, who
|
||||
_To learn more, check out the [`<Editor>` component reference](../reference/components/editor.md)._
|
||||
|
||||
|
||||
### Transforms
|
||||
### Changes
|
||||
|
||||
All of the changes in Slate are applied via [`Transforms`](../reference/models/transform.md). This makes it possible to enforce some of the constraints that Slate needs to enforce, like requiring that [all leaf nodes be text nodes](./the-document-model.md#leaf-text-nodes). This also makes it possible to implement collaborative editing, where information about changes must be serialized and sent over the network to other editors.
|
||||
All of the changes in Slate are applied via [`Changes`](../reference/models/change.md). This makes it possible to enforce some of the constraints that Slate needs to enforce, like requiring that [all leaf nodes be text nodes](./the-document-model.md#leaf-text-nodes). This also makes it possible to implement collaborative editing, where information about changes must be serialized and sent over the network to other editors.
|
||||
|
||||
You should never update the `selection` or `document` of an editor other than by using the [`transform()`](../reference/models/state.md#transform) method of a `State`.
|
||||
You should never update the `selection` or `document` of an editor other than by using the [`change()`](../reference/models/state.md#change) method of a `State`.
|
||||
|
||||
_To learn more, check out the [`Transform` model reference](../reference/models/transform.md)._
|
||||
_To learn more, check out the [`Change` model reference](../reference/models/change.md)._
|
||||
|
@@ -1,7 +1,7 @@
|
||||
|
||||
# The Selection Model
|
||||
|
||||
Slate keeps track of the user's selection in the editor in an immutable data store called a [`Selection`](../reference/models/selection.md). By doing this, it lets Slate manipulate the selection with transforms, but still update it in the DOM on `render`.
|
||||
Slate keeps track of the user's selection in the editor in an immutable data store called a [`Selection`](../reference/models/selection.md). By doing this, it lets Slate manipulate the selection with changes, but still update it in the DOM on `render`.
|
||||
|
||||
|
||||
### Always References Text
|
||||
@@ -17,7 +17,7 @@ This makes selections easier to reason about, while still giving us the benefits
|
||||
|
||||
When a selection is used to compute a set of [`Block`](../reference/models/block.md) nodes, by convention those nodes are always the leaf-most `Block` nodes (ie. the lowest `Block` nodes in the tree at their location). This is important, because the nested document model allows for nested `Block` nodes.
|
||||
|
||||
This convention makes it much simpler to implement selection and transformation logic, since the user's actions are very often supposed to effect the leaf blocks.
|
||||
This convention makes it much simpler to implement selection and changeation logic, since the user's actions are very often supposed to effect the leaf blocks.
|
||||
|
||||
|
||||
### Trunk Inlines
|
||||
|
Reference in New Issue
Block a user