@portabletext/editor 2.18.1 → 2.19.1
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 +7 -0
- package/lib/_chunks-dts/index.d.ts +57 -55
- package/lib/index.js +68 -0
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- package/src/behaviors/behavior.abstract.keyboard.ts +15 -0
- package/src/behaviors/behavior.types.event.ts +1 -0
- package/src/keyboard-shortcuts/default-keyboard-shortcuts.ts +42 -0
- package/src/operations/behavior.operation.annotation.add.ts +1 -0
- package/src/operations/behavior.operation.delete.ts +18 -0
- package/src/test/gherkin-parameter-types.ts +5 -0
- package/src/test/vitest/step-definitions.tsx +17 -0
package/README.md
CHANGED
|
@@ -435,6 +435,13 @@ This monorepo also contains additional libraries that can be used with the Porta
|
|
|
435
435
|
- 💻 [./packages/keyboard-shortcuts](./packages/keyboard-shortcuts/)
|
|
436
436
|
- 📦 [@portabletext/keyboard-shortcuts](https://www.npmjs.com/package/@portabletext/keyboard-shortcuts)
|
|
437
437
|
|
|
438
|
+
### `@portabletext/test`
|
|
439
|
+
|
|
440
|
+
> Testing utilities for the Portable Text Editor
|
|
441
|
+
|
|
442
|
+
- 💻 [./packages/test](./packages/test/)
|
|
443
|
+
- 📦 [@portabletext/test](https://www.npmjs.com/package/@portabletext/test)
|
|
444
|
+
|
|
438
445
|
### `@portabletext/toolbar`
|
|
439
446
|
|
|
440
447
|
> Powered by [Behaviors](https://www.portabletext.org/concepts/behavior/) and [State Machines](https://stately.ai/docs/xstate), `@portabletext/toolbar` is a collection of robust React hooks for building toolbars and related UI components
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import * as _sanity_types5 from "@sanity/types";
|
|
2
2
|
import { ArrayDefinition, ArraySchemaType, BlockDecoratorDefinition, BlockListDefinition, BlockStyleDefinition, ObjectSchemaType, Path, PortableTextBlock, PortableTextBlock as PortableTextBlock$1, PortableTextChild, PortableTextChild as PortableTextChild$1, PortableTextListBlock, PortableTextObject, PortableTextObject as PortableTextObject$2, PortableTextSpan, PortableTextSpan as PortableTextSpan$2, PortableTextTextBlock, PortableTextTextBlock as PortableTextTextBlock$2, TypedObject } from "@sanity/types";
|
|
3
3
|
import { BaseRange, Descendant, Operation } from "slate";
|
|
4
|
-
import * as
|
|
4
|
+
import * as xstate229 from "xstate";
|
|
5
5
|
import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
|
|
6
|
-
import * as
|
|
6
|
+
import * as react20 from "react";
|
|
7
7
|
import React$1, { BaseSyntheticEvent, ClipboardEvent, Component, FocusEvent, JSX, KeyboardEvent as KeyboardEvent$1, MutableRefObject, PropsWithChildren, ReactElement, RefObject, TextareaHTMLAttributes } from "react";
|
|
8
8
|
import { Patch, Patch as Patch$1 } from "@portabletext/patches";
|
|
9
|
-
import * as
|
|
9
|
+
import * as _portabletext_schema5 from "@portabletext/schema";
|
|
10
10
|
import { AnnotationDefinition, AnnotationSchemaType, BaseDefinition, BlockObjectDefinition, BlockObjectSchemaType, DecoratorDefinition, DecoratorSchemaType, FieldDefinition, InlineObjectDefinition, InlineObjectSchemaType, ListDefinition, ListSchemaType, PortableTextObject as PortableTextObject$1, PortableTextSpan as PortableTextSpan$1, PortableTextTextBlock as PortableTextTextBlock$1, Schema, SchemaDefinition, SchemaDefinition as SchemaDefinition$1, StyleDefinition, StyleSchemaType, defineSchema } from "@portabletext/schema";
|
|
11
11
|
import { Observable, Subject } from "rxjs";
|
|
12
12
|
import { DOMNode } from "slate-dom";
|
|
13
13
|
import { ReactEditor } from "slate-react";
|
|
14
|
-
import * as
|
|
14
|
+
import * as xstate_guards12 from "xstate/guards";
|
|
15
15
|
type MIMEType = `${string}/${string}`;
|
|
16
16
|
/**
|
|
17
17
|
* @internal
|
|
@@ -219,7 +219,7 @@ declare class PortableTextEditor extends Component<PortableTextEditorProps<Inter
|
|
|
219
219
|
componentDidUpdate(prevProps: PortableTextEditorProps): void;
|
|
220
220
|
componentWillUnmount(): void;
|
|
221
221
|
setEditable: (editable: EditableAPI) => void;
|
|
222
|
-
render():
|
|
222
|
+
render(): react20.JSX.Element;
|
|
223
223
|
/**
|
|
224
224
|
* @deprecated
|
|
225
225
|
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
@@ -614,7 +614,7 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
|
|
|
614
614
|
* ```
|
|
615
615
|
* @group Components
|
|
616
616
|
*/
|
|
617
|
-
declare const PortableTextEditable:
|
|
617
|
+
declare const PortableTextEditable: react20.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react20.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
|
|
618
618
|
type DecoratedRange = BaseRange & {
|
|
619
619
|
rangeDecoration: RangeDecoration;
|
|
620
620
|
};
|
|
@@ -1360,7 +1360,7 @@ type EditorActor = ActorRefFrom<typeof editorMachine>;
|
|
|
1360
1360
|
/**
|
|
1361
1361
|
* @internal
|
|
1362
1362
|
*/
|
|
1363
|
-
declare const editorMachine:
|
|
1363
|
+
declare const editorMachine: xstate229.StateMachine<{
|
|
1364
1364
|
behaviors: Set<BehaviorConfig>;
|
|
1365
1365
|
behaviorsSorted: boolean;
|
|
1366
1366
|
converters: Set<Converter>;
|
|
@@ -1424,62 +1424,62 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
1424
1424
|
} | {
|
|
1425
1425
|
type: "add slate editor";
|
|
1426
1426
|
editor: PortableTextSlateEditor;
|
|
1427
|
-
}, {}, never,
|
|
1427
|
+
}, {}, never, xstate229.Values<{
|
|
1428
1428
|
"add behavior to context": {
|
|
1429
1429
|
type: "add behavior to context";
|
|
1430
|
-
params:
|
|
1430
|
+
params: xstate229.NonReducibleUnknown;
|
|
1431
1431
|
};
|
|
1432
1432
|
"remove behavior from context": {
|
|
1433
1433
|
type: "remove behavior from context";
|
|
1434
|
-
params:
|
|
1434
|
+
params: xstate229.NonReducibleUnknown;
|
|
1435
1435
|
};
|
|
1436
1436
|
"add slate editor to context": {
|
|
1437
1437
|
type: "add slate editor to context";
|
|
1438
|
-
params:
|
|
1438
|
+
params: xstate229.NonReducibleUnknown;
|
|
1439
1439
|
};
|
|
1440
1440
|
"emit patch event": {
|
|
1441
1441
|
type: "emit patch event";
|
|
1442
|
-
params:
|
|
1442
|
+
params: xstate229.NonReducibleUnknown;
|
|
1443
1443
|
};
|
|
1444
1444
|
"emit mutation event": {
|
|
1445
1445
|
type: "emit mutation event";
|
|
1446
|
-
params:
|
|
1446
|
+
params: xstate229.NonReducibleUnknown;
|
|
1447
1447
|
};
|
|
1448
1448
|
"emit read only": {
|
|
1449
1449
|
type: "emit read only";
|
|
1450
|
-
params:
|
|
1450
|
+
params: xstate229.NonReducibleUnknown;
|
|
1451
1451
|
};
|
|
1452
1452
|
"emit editable": {
|
|
1453
1453
|
type: "emit editable";
|
|
1454
|
-
params:
|
|
1454
|
+
params: xstate229.NonReducibleUnknown;
|
|
1455
1455
|
};
|
|
1456
1456
|
"defer event": {
|
|
1457
1457
|
type: "defer event";
|
|
1458
|
-
params:
|
|
1458
|
+
params: xstate229.NonReducibleUnknown;
|
|
1459
1459
|
};
|
|
1460
1460
|
"emit pending events": {
|
|
1461
1461
|
type: "emit pending events";
|
|
1462
|
-
params:
|
|
1462
|
+
params: xstate229.NonReducibleUnknown;
|
|
1463
1463
|
};
|
|
1464
1464
|
"emit ready": {
|
|
1465
1465
|
type: "emit ready";
|
|
1466
|
-
params:
|
|
1466
|
+
params: xstate229.NonReducibleUnknown;
|
|
1467
1467
|
};
|
|
1468
1468
|
"clear pending events": {
|
|
1469
1469
|
type: "clear pending events";
|
|
1470
|
-
params:
|
|
1470
|
+
params: xstate229.NonReducibleUnknown;
|
|
1471
1471
|
};
|
|
1472
1472
|
"defer incoming patches": {
|
|
1473
1473
|
type: "defer incoming patches";
|
|
1474
|
-
params:
|
|
1474
|
+
params: xstate229.NonReducibleUnknown;
|
|
1475
1475
|
};
|
|
1476
1476
|
"emit pending incoming patches": {
|
|
1477
1477
|
type: "emit pending incoming patches";
|
|
1478
|
-
params:
|
|
1478
|
+
params: xstate229.NonReducibleUnknown;
|
|
1479
1479
|
};
|
|
1480
1480
|
"clear pending incoming patches": {
|
|
1481
1481
|
type: "clear pending incoming patches";
|
|
1482
|
-
params:
|
|
1482
|
+
params: xstate229.NonReducibleUnknown;
|
|
1483
1483
|
};
|
|
1484
1484
|
"handle blur": {
|
|
1485
1485
|
type: "handle blur";
|
|
@@ -1495,9 +1495,9 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
1495
1495
|
};
|
|
1496
1496
|
"sort behaviors": {
|
|
1497
1497
|
type: "sort behaviors";
|
|
1498
|
-
params:
|
|
1498
|
+
params: xstate229.NonReducibleUnknown;
|
|
1499
1499
|
};
|
|
1500
|
-
}>,
|
|
1500
|
+
}>, xstate229.Values<{
|
|
1501
1501
|
"slate is busy": {
|
|
1502
1502
|
type: "slate is busy";
|
|
1503
1503
|
params: unknown;
|
|
@@ -1530,9 +1530,9 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
1530
1530
|
readOnly?: boolean;
|
|
1531
1531
|
schema: EditorSchema;
|
|
1532
1532
|
initialValue?: Array<PortableTextBlock>;
|
|
1533
|
-
},
|
|
1533
|
+
}, xstate229.NonReducibleUnknown, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
1534
1534
|
type: "blurred";
|
|
1535
|
-
event:
|
|
1535
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
1536
1536
|
} | {
|
|
1537
1537
|
type: "done loading";
|
|
1538
1538
|
} | {
|
|
@@ -1544,7 +1544,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
1544
1544
|
data: unknown;
|
|
1545
1545
|
} | {
|
|
1546
1546
|
type: "focused";
|
|
1547
|
-
event:
|
|
1547
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
1548
1548
|
} | {
|
|
1549
1549
|
type: "invalid value";
|
|
1550
1550
|
resolution: InvalidValueResolution | null;
|
|
@@ -1561,19 +1561,19 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
1561
1561
|
} | {
|
|
1562
1562
|
type: "value changed";
|
|
1563
1563
|
value: Array<PortableTextBlock> | undefined;
|
|
1564
|
-
},
|
|
1564
|
+
}, xstate229.MetaObject, {
|
|
1565
1565
|
readonly id: "editor";
|
|
1566
1566
|
readonly context: ({
|
|
1567
1567
|
input
|
|
1568
1568
|
}: {
|
|
1569
1569
|
spawn: {
|
|
1570
|
-
<TSrc extends never>(logic: TSrc, ...[options]: never):
|
|
1571
|
-
<TLogic extends
|
|
1570
|
+
<TSrc extends never>(logic: TSrc, ...[options]: never): xstate229.ActorRefFromLogic<never>;
|
|
1571
|
+
<TLogic extends xstate229.AnyActorLogic>(src: TLogic, ...[options]: xstate229.ConditionalRequired<[options?: ({
|
|
1572
1572
|
id?: never;
|
|
1573
1573
|
systemId?: string;
|
|
1574
|
-
input?:
|
|
1574
|
+
input?: xstate229.InputFrom<TLogic> | undefined;
|
|
1575
1575
|
syncSnapshot?: boolean;
|
|
1576
|
-
} & { [K in
|
|
1576
|
+
} & { [K in xstate229.RequiredLogicInput<TLogic>]: unknown }) | undefined], xstate229.IsNotNever<xstate229.RequiredLogicInput<TLogic>>>): xstate229.ActorRefFromLogic<TLogic>;
|
|
1577
1577
|
};
|
|
1578
1578
|
input: {
|
|
1579
1579
|
converters?: Array<Converter>;
|
|
@@ -1584,7 +1584,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
1584
1584
|
schema: EditorSchema;
|
|
1585
1585
|
initialValue?: Array<PortableTextBlock>;
|
|
1586
1586
|
};
|
|
1587
|
-
self:
|
|
1587
|
+
self: xstate229.ActorRef<xstate229.MachineSnapshot<{
|
|
1588
1588
|
behaviors: Set<BehaviorConfig>;
|
|
1589
1589
|
behaviorsSorted: boolean;
|
|
1590
1590
|
converters: Set<Converter>;
|
|
@@ -1648,7 +1648,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
1648
1648
|
} | {
|
|
1649
1649
|
type: "add slate editor";
|
|
1650
1650
|
editor: PortableTextSlateEditor;
|
|
1651
|
-
}, Record<string,
|
|
1651
|
+
}, Record<string, xstate229.AnyActorRef | undefined>, xstate229.StateValue, string, unknown, any, any>, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
1652
1652
|
type: "update readOnly";
|
|
1653
1653
|
readOnly: boolean;
|
|
1654
1654
|
} | {
|
|
@@ -1694,13 +1694,14 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
1694
1694
|
} | {
|
|
1695
1695
|
type: "add slate editor";
|
|
1696
1696
|
editor: PortableTextSlateEditor;
|
|
1697
|
-
},
|
|
1697
|
+
}, xstate229.AnyEventObject>;
|
|
1698
1698
|
}) => {
|
|
1699
1699
|
behaviors: Set<{
|
|
1700
|
-
behavior: Behavior<"*" | "split" | `custom.${string}` | "annotation.add" | "annotation.remove" | "block.set" | "block.unset" | "child.set" | "child.unset" | "decorator.add" | "decorator.remove" | "delete" | "history.redo" | "history.undo" | "insert.block" | "insert.child" | "insert.text" | "move.backward" | "move.block" | "move.forward" | "select" | "annotation.set" | "annotation.toggle" | "decorator.toggle" | "delete.backward" | "delete.block" | "delete.child" | "delete.forward" | "delete.text" | "deserialize" | "deserialize.data" | "deserialization.success" | "deserialization.failure" | "insert.blocks" | "insert.break" | "insert.inline object" | "insert.soft break" | "insert.span" | "list item.add" | "list item.remove" | "list item.toggle" | "move.block down" | "move.block up" | "select.block" | "select.previous block" | "select.next block" | "serialize" | "serialize.data" | "serialization.success" | "serialization.failure" | "style.add" | "style.remove" | "style.toggle" | "clipboard.copy" | "clipboard.cut" | "clipboard.paste" | "drag.dragstart" | "drag.drag" | "drag.dragend" | "drag.dragenter" | "drag.dragover" | "drag.dragleave" | "drag.drop" | "input.*" | "keyboard.keydown" | "keyboard.keyup" | "mouse.click" | "history.*" | "split.*" | "delete.*" | "select.*" | "deserialize.*" | "serialize.*" | "annotation.*" | "block.*" | "child.*" | "decorator.*" | "insert.*" | "move.*" | "deserialization.*" | "list item.*" | "serialization.*" | "
|
|
1700
|
+
behavior: Behavior<"*" | "split" | `custom.${string}` | "annotation.add" | "annotation.remove" | "block.set" | "block.unset" | "child.set" | "child.unset" | "decorator.add" | "decorator.remove" | "delete" | "history.redo" | "history.undo" | "insert.block" | "insert.child" | "insert.text" | "move.backward" | "move.block" | "move.forward" | "select" | "annotation.set" | "annotation.toggle" | "decorator.toggle" | "delete.backward" | "delete.block" | "delete.child" | "delete.forward" | "delete.text" | "deserialize" | "deserialize.data" | "deserialization.success" | "deserialization.failure" | "insert.blocks" | "insert.break" | "insert.inline object" | "insert.soft break" | "insert.span" | "list item.add" | "list item.remove" | "list item.toggle" | "move.block down" | "move.block up" | "select.block" | "select.previous block" | "select.next block" | "serialize" | "serialize.data" | "serialization.success" | "serialization.failure" | "style.add" | "style.remove" | "style.toggle" | "clipboard.copy" | "clipboard.cut" | "clipboard.paste" | "drag.dragstart" | "drag.drag" | "drag.dragend" | "drag.dragenter" | "drag.dragover" | "drag.dragleave" | "drag.drop" | "input.*" | "keyboard.keydown" | "keyboard.keyup" | "mouse.click" | "style.*" | "history.*" | "split.*" | "delete.*" | "select.*" | "deserialize.*" | "serialize.*" | "annotation.*" | "block.*" | "child.*" | "decorator.*" | "insert.*" | "move.*" | "deserialization.*" | "list item.*" | "serialization.*" | "clipboard.*" | "drag.*" | "keyboard.*" | "mouse.*", true, {
|
|
1701
1701
|
type: StrictExtract<"split" | "annotation.add" | "annotation.remove" | "block.set" | "block.unset" | "child.set" | "child.unset" | "decorator.add" | "decorator.remove" | "delete" | "history.redo" | "history.undo" | "insert.block" | "insert.child" | "insert.text" | "move.backward" | "move.block" | "move.forward" | "select" | "annotation.set" | "annotation.toggle" | "decorator.toggle" | "delete.backward" | "delete.block" | "delete.child" | "delete.forward" | "delete.text" | "deserialize" | "deserialize.data" | "deserialization.success" | "deserialization.failure" | "insert.blocks" | "insert.break" | "insert.inline object" | "insert.soft break" | "insert.span" | "list item.add" | "list item.remove" | "list item.toggle" | "move.block down" | "move.block up" | "select.block" | "select.previous block" | "select.next block" | "serialize" | "serialize.data" | "serialization.success" | "serialization.failure" | "style.add" | "style.remove" | "style.toggle", "annotation.add">;
|
|
1702
1702
|
annotation: {
|
|
1703
1703
|
name: string;
|
|
1704
|
+
_key?: string;
|
|
1704
1705
|
value: {
|
|
1705
1706
|
[prop: string]: unknown;
|
|
1706
1707
|
};
|
|
@@ -1982,7 +1983,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
1982
1983
|
keyGenerator: () => string;
|
|
1983
1984
|
pendingEvents: never[];
|
|
1984
1985
|
pendingIncomingPatchesEvents: never[];
|
|
1985
|
-
schema:
|
|
1986
|
+
schema: _portabletext_schema5.Schema;
|
|
1986
1987
|
selection: null;
|
|
1987
1988
|
initialReadOnly: boolean;
|
|
1988
1989
|
maxBlocks: number | undefined;
|
|
@@ -1996,7 +1997,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
1996
1997
|
readonly actions: "remove behavior from context";
|
|
1997
1998
|
};
|
|
1998
1999
|
readonly 'update maxBlocks': {
|
|
1999
|
-
readonly actions:
|
|
2000
|
+
readonly actions: xstate229.ActionFunction<{
|
|
2000
2001
|
behaviors: Set<BehaviorConfig>;
|
|
2001
2002
|
behaviorsSorted: boolean;
|
|
2002
2003
|
converters: Set<Converter>;
|
|
@@ -2069,7 +2070,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
2069
2070
|
readonly actions: "add slate editor to context";
|
|
2070
2071
|
};
|
|
2071
2072
|
readonly 'update selection': {
|
|
2072
|
-
readonly actions: readonly [
|
|
2073
|
+
readonly actions: readonly [xstate229.ActionFunction<{
|
|
2073
2074
|
behaviors: Set<BehaviorConfig>;
|
|
2074
2075
|
behaviorsSorted: boolean;
|
|
2075
2076
|
converters: Set<Converter>;
|
|
@@ -2136,7 +2137,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
2136
2137
|
} | {
|
|
2137
2138
|
type: "add slate editor";
|
|
2138
2139
|
editor: PortableTextSlateEditor;
|
|
2139
|
-
}, undefined, never, never, never, never, never>,
|
|
2140
|
+
}, undefined, never, never, never, never, never>, xstate229.ActionFunction<{
|
|
2140
2141
|
behaviors: Set<BehaviorConfig>;
|
|
2141
2142
|
behaviorsSorted: boolean;
|
|
2142
2143
|
converters: Set<Converter>;
|
|
@@ -2205,7 +2206,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
2205
2206
|
editor: PortableTextSlateEditor;
|
|
2206
2207
|
}, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
2207
2208
|
type: "blurred";
|
|
2208
|
-
event:
|
|
2209
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
2209
2210
|
} | {
|
|
2210
2211
|
type: "done loading";
|
|
2211
2212
|
} | {
|
|
@@ -2217,7 +2218,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
2217
2218
|
data: unknown;
|
|
2218
2219
|
} | {
|
|
2219
2220
|
type: "focused";
|
|
2220
|
-
event:
|
|
2221
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
2221
2222
|
} | {
|
|
2222
2223
|
type: "invalid value";
|
|
2223
2224
|
resolution: InvalidValueResolution | null;
|
|
@@ -2237,7 +2238,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
2237
2238
|
}>];
|
|
2238
2239
|
};
|
|
2239
2240
|
readonly 'set drag ghost': {
|
|
2240
|
-
readonly actions:
|
|
2241
|
+
readonly actions: xstate229.ActionFunction<{
|
|
2241
2242
|
behaviors: Set<BehaviorConfig>;
|
|
2242
2243
|
behaviorsSorted: boolean;
|
|
2243
2244
|
converters: Set<Converter>;
|
|
@@ -2319,7 +2320,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
2319
2320
|
readonly actions: readonly ["sort behaviors", "handle behavior event"];
|
|
2320
2321
|
readonly guard: ({
|
|
2321
2322
|
event
|
|
2322
|
-
}:
|
|
2323
|
+
}: xstate_guards12.GuardArgs<{
|
|
2323
2324
|
behaviors: Set<BehaviorConfig>;
|
|
2324
2325
|
behaviorsSorted: boolean;
|
|
2325
2326
|
converters: Set<Converter>;
|
|
@@ -2356,7 +2357,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
2356
2357
|
readonly target: "#editor.edit mode.read only.read only";
|
|
2357
2358
|
readonly guard: ({
|
|
2358
2359
|
context
|
|
2359
|
-
}:
|
|
2360
|
+
}: xstate_guards12.GuardArgs<{
|
|
2360
2361
|
behaviors: Set<BehaviorConfig>;
|
|
2361
2362
|
behaviorsSorted: boolean;
|
|
2362
2363
|
converters: Set<Converter>;
|
|
@@ -2389,7 +2390,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
2389
2390
|
readonly 'update readOnly': {
|
|
2390
2391
|
readonly guard: ({
|
|
2391
2392
|
event
|
|
2392
|
-
}:
|
|
2393
|
+
}: xstate_guards12.GuardArgs<{
|
|
2393
2394
|
behaviors: Set<BehaviorConfig>;
|
|
2394
2395
|
behaviorsSorted: boolean;
|
|
2395
2396
|
converters: Set<Converter>;
|
|
@@ -2423,7 +2424,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
2423
2424
|
readonly 'update readOnly': {
|
|
2424
2425
|
readonly guard: ({
|
|
2425
2426
|
event
|
|
2426
|
-
}:
|
|
2427
|
+
}: xstate_guards12.GuardArgs<{
|
|
2427
2428
|
behaviors: Set<BehaviorConfig>;
|
|
2428
2429
|
behaviorsSorted: boolean;
|
|
2429
2430
|
converters: Set<Converter>;
|
|
@@ -2456,7 +2457,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
2456
2457
|
};
|
|
2457
2458
|
readonly focus: {
|
|
2458
2459
|
readonly target: ".focusing";
|
|
2459
|
-
readonly actions: readonly [
|
|
2460
|
+
readonly actions: readonly [xstate229.ActionFunction<{
|
|
2460
2461
|
behaviors: Set<BehaviorConfig>;
|
|
2461
2462
|
behaviorsSorted: boolean;
|
|
2462
2463
|
converters: Set<Converter>;
|
|
@@ -2533,7 +2534,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
2533
2534
|
readonly exit: readonly [() => void];
|
|
2534
2535
|
readonly on: {
|
|
2535
2536
|
readonly dragstart: {
|
|
2536
|
-
readonly actions: readonly [
|
|
2537
|
+
readonly actions: readonly [xstate229.ActionFunction<{
|
|
2537
2538
|
behaviors: Set<BehaviorConfig>;
|
|
2538
2539
|
behaviorsSorted: boolean;
|
|
2539
2540
|
converters: Set<Converter>;
|
|
@@ -2635,7 +2636,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
2635
2636
|
readonly entry: readonly [() => void];
|
|
2636
2637
|
readonly exit: readonly [() => void, ({
|
|
2637
2638
|
context
|
|
2638
|
-
}:
|
|
2639
|
+
}: xstate229.ActionArgs<{
|
|
2639
2640
|
behaviors: Set<BehaviorConfig>;
|
|
2640
2641
|
behaviorsSorted: boolean;
|
|
2641
2642
|
converters: Set<Converter>;
|
|
@@ -2745,7 +2746,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
2745
2746
|
} | {
|
|
2746
2747
|
type: "add slate editor";
|
|
2747
2748
|
editor: PortableTextSlateEditor;
|
|
2748
|
-
}>) => void,
|
|
2749
|
+
}>) => void, xstate229.ActionFunction<{
|
|
2749
2750
|
behaviors: Set<BehaviorConfig>;
|
|
2750
2751
|
behaviorsSorted: boolean;
|
|
2751
2752
|
converters: Set<Converter>;
|
|
@@ -2855,7 +2856,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
2855
2856
|
} | {
|
|
2856
2857
|
type: "add slate editor";
|
|
2857
2858
|
editor: PortableTextSlateEditor;
|
|
2858
|
-
}, undefined, never, never, never, never, never>,
|
|
2859
|
+
}, undefined, never, never, never, never, never>, xstate229.ActionFunction<{
|
|
2859
2860
|
behaviors: Set<BehaviorConfig>;
|
|
2860
2861
|
behaviorsSorted: boolean;
|
|
2861
2862
|
converters: Set<Converter>;
|
|
@@ -3012,7 +3013,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
3012
3013
|
readonly exit: readonly [() => void];
|
|
3013
3014
|
readonly on: {
|
|
3014
3015
|
readonly patches: {
|
|
3015
|
-
readonly actions: readonly [
|
|
3016
|
+
readonly actions: readonly [xstate229.ActionFunction<{
|
|
3016
3017
|
behaviors: Set<BehaviorConfig>;
|
|
3017
3018
|
behaviorsSorted: boolean;
|
|
3018
3019
|
converters: Set<Converter>;
|
|
@@ -3078,7 +3079,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
3078
3079
|
editor: PortableTextSlateEditor;
|
|
3079
3080
|
}, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
3080
3081
|
type: "blurred";
|
|
3081
|
-
event:
|
|
3082
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
3082
3083
|
} | {
|
|
3083
3084
|
type: "done loading";
|
|
3084
3085
|
} | {
|
|
@@ -3090,7 +3091,7 @@ declare const editorMachine: xstate243.StateMachine<{
|
|
|
3090
3091
|
data: unknown;
|
|
3091
3092
|
} | {
|
|
3092
3093
|
type: "focused";
|
|
3093
|
-
event:
|
|
3094
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
3094
3095
|
} | {
|
|
3095
3096
|
type: "invalid value";
|
|
3096
3097
|
resolution: InvalidValueResolution | null;
|
|
@@ -3222,6 +3223,7 @@ type SyntheticBehaviorEvent = {
|
|
|
3222
3223
|
type: StrictExtract<SyntheticBehaviorEventType, 'annotation.add'>;
|
|
3223
3224
|
annotation: {
|
|
3224
3225
|
name: string;
|
|
3226
|
+
_key?: string;
|
|
3225
3227
|
value: {
|
|
3226
3228
|
[prop: string]: unknown;
|
|
3227
3229
|
};
|
package/lib/index.js
CHANGED
|
@@ -4135,6 +4135,7 @@ const addAnnotationOperationImplementation = ({
|
|
|
4135
4135
|
const parsedAnnotation = parseAnnotation({
|
|
4136
4136
|
annotation: {
|
|
4137
4137
|
_type: operation.annotation.name,
|
|
4138
|
+
_key: operation.annotation._key,
|
|
4138
4139
|
...operation.annotation.value
|
|
4139
4140
|
},
|
|
4140
4141
|
context,
|
|
@@ -4673,6 +4674,19 @@ const addAnnotationOperationImplementation = ({
|
|
|
4673
4674
|
}
|
|
4674
4675
|
}
|
|
4675
4676
|
}
|
|
4677
|
+
if (operation.unit === "word") {
|
|
4678
|
+
const range = at ?? operation.editor.selection ?? void 0;
|
|
4679
|
+
if (!range)
|
|
4680
|
+
throw new Error("Unable to delete word without a selection");
|
|
4681
|
+
if (Range.isCollapsed(range)) {
|
|
4682
|
+
deleteText(operation.editor, {
|
|
4683
|
+
at: range,
|
|
4684
|
+
unit: "word",
|
|
4685
|
+
reverse: operation.direction === "backward"
|
|
4686
|
+
});
|
|
4687
|
+
return;
|
|
4688
|
+
}
|
|
4689
|
+
}
|
|
4676
4690
|
const hanging = reverse ? endPoint ? isTextBlock(context, endBlock) ? endPoint.offset === 0 : !0 : !1 : startPoint ? isTextBlock(context, startBlock) ? startPoint.offset === 0 : !0 : !1;
|
|
4677
4691
|
at ? deleteText(operation.editor, {
|
|
4678
4692
|
at,
|
|
@@ -7046,6 +7060,40 @@ const addAnnotationOnCollapsedSelection = defineBehavior({
|
|
|
7046
7060
|
shift: !1
|
|
7047
7061
|
}]
|
|
7048
7062
|
}),
|
|
7063
|
+
deleteWord: {
|
|
7064
|
+
backward: createKeyboardShortcut({
|
|
7065
|
+
default: [{
|
|
7066
|
+
key: "Backspace",
|
|
7067
|
+
alt: !1,
|
|
7068
|
+
ctrl: !0,
|
|
7069
|
+
meta: !1
|
|
7070
|
+
// shift is optional
|
|
7071
|
+
}],
|
|
7072
|
+
apple: [{
|
|
7073
|
+
key: "Backspace",
|
|
7074
|
+
alt: !0,
|
|
7075
|
+
ctrl: !1,
|
|
7076
|
+
meta: !1
|
|
7077
|
+
// shift is optional
|
|
7078
|
+
}]
|
|
7079
|
+
}),
|
|
7080
|
+
forward: createKeyboardShortcut({
|
|
7081
|
+
default: [{
|
|
7082
|
+
key: "Delete",
|
|
7083
|
+
alt: !1,
|
|
7084
|
+
ctrl: !0,
|
|
7085
|
+
meta: !1
|
|
7086
|
+
// shift is optional
|
|
7087
|
+
}],
|
|
7088
|
+
apple: [{
|
|
7089
|
+
key: "Delete",
|
|
7090
|
+
alt: !0,
|
|
7091
|
+
ctrl: !1,
|
|
7092
|
+
meta: !1
|
|
7093
|
+
// shift is optional
|
|
7094
|
+
}]
|
|
7095
|
+
})
|
|
7096
|
+
},
|
|
7049
7097
|
history: {
|
|
7050
7098
|
undo,
|
|
7051
7099
|
redo
|
|
@@ -9178,6 +9226,26 @@ const abstractAnnotationBehaviors = [defineBehavior({
|
|
|
9178
9226
|
unit: "character"
|
|
9179
9227
|
})]]
|
|
9180
9228
|
}),
|
|
9229
|
+
defineBehavior({
|
|
9230
|
+
on: "keyboard.keydown",
|
|
9231
|
+
guard: ({
|
|
9232
|
+
event
|
|
9233
|
+
}) => defaultKeyboardShortcuts.deleteWord.backward.guard(event.originEvent),
|
|
9234
|
+
actions: [() => [raise({
|
|
9235
|
+
type: "delete.backward",
|
|
9236
|
+
unit: "word"
|
|
9237
|
+
})]]
|
|
9238
|
+
}),
|
|
9239
|
+
defineBehavior({
|
|
9240
|
+
on: "keyboard.keydown",
|
|
9241
|
+
guard: ({
|
|
9242
|
+
event
|
|
9243
|
+
}) => defaultKeyboardShortcuts.deleteWord.forward.guard(event.originEvent),
|
|
9244
|
+
actions: [() => [raise({
|
|
9245
|
+
type: "delete.forward",
|
|
9246
|
+
unit: "word"
|
|
9247
|
+
})]]
|
|
9248
|
+
}),
|
|
9181
9249
|
/**
|
|
9182
9250
|
* Allow raising an `insert.break` event when pressing Enter on an inline
|
|
9183
9251
|
* object.
|