@portabletext/editor 1.11.1 → 1.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/lib/index.esm.js +1 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +1 -1
- package/lib/index.mjs.map +1 -1
- package/package.json +10 -10
- package/src/editor/behavior/behavior.action.insert-break.ts +3 -3
- package/src/editor/behavior/behavior.action.insert-span.ts +2 -2
- package/src/editor/behavior/behavior.actions.ts +4 -4
- package/src/editor/editor-machine.ts +5 -2
- package/src/editor/plugins/createWithEditableAPI.ts +5 -5
- package/src/editor/plugins/createWithPortableTextMarkModel.ts +4 -4
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ In order to provide a robust and consistent end-user experience, the editor is b
|
|
|
21
21
|
> [!WARNING]
|
|
22
22
|
> The `@portabletext/editor` is currently on the path to deprecate legacy APIs and introduce new ones. The end goals are to make the editor easier to use outside of `Sanity` (and without `@sanity/*` libraries) as well as providing a brand new API to configure the behavior of the editor.
|
|
23
23
|
>
|
|
24
|
-
> This means that the `defineSchema` and `
|
|
24
|
+
> This means that the `defineSchema` and `EditorProvider` APIs showcased here are still experimental APIs tagged with `@alpha` and cannot be considered stable yet. At the same time, the examples below showcase usages of legacy static methods on the `PortableTextEditor` (for example, `PortableTextEditor.isMarkActive(...)` and `PortableTextEditor.toggleMark(...)`) that will soon be discouraged and deprecrated.
|
|
25
25
|
|
|
26
26
|
Check [/examples/basic/src/App.tsx](/examples/basic/src/App.tsx) for a basic example of how to set up the edior. Most of the source code from this example app can also be found in the instructions below.
|
|
27
27
|
|
|
@@ -369,3 +369,12 @@ function Toolbar() {
|
|
|
369
369
|
)
|
|
370
370
|
}
|
|
371
371
|
```
|
|
372
|
+
|
|
373
|
+
## Behavior API (Coming Soon)
|
|
374
|
+
|
|
375
|
+
The Behavior API is a new way of interfacing with the Portable Text Editor. It allows you to think of and treat the editor as a state machine by:
|
|
376
|
+
|
|
377
|
+
1. Declaratively hooking into editor **events** and defining new behaviors using `defineBehavior`. (A "Behavior" (1) listens for an **event**, (2) uses a **guard** to determine whether it should run and (3) raises a set of **actions** to be performed on the editor.)
|
|
378
|
+
2. Imperatively trigger **events** using `editor.send(…)` which in turn can trigger behaviors defined using `defineBehavior`.
|
|
379
|
+
3. Deriving editor **state** using **pure functions**.
|
|
380
|
+
4. Subscribe to **emitted** editor **events** using `editor.on(…)`.
|
package/lib/index.esm.js
CHANGED
|
@@ -5744,7 +5744,7 @@ const editorMachine = setup({
|
|
|
5744
5744
|
event: event.behaviorEvent
|
|
5745
5745
|
}, shouldRun));
|
|
5746
5746
|
for (const actionIntends of actionIntendSets)
|
|
5747
|
-
behaviorOverwritten = actionIntends.length > 0 && actionIntends.some((actionIntend) => actionIntend.type !== "effect"), enqueue.raise({
|
|
5747
|
+
behaviorOverwritten = behaviorOverwritten || actionIntends.length > 0 && actionIntends.some((actionIntend) => actionIntend.type !== "effect"), enqueue.raise({
|
|
5748
5748
|
type: "behavior action intends",
|
|
5749
5749
|
editor: event.editor,
|
|
5750
5750
|
actionIntends
|