@portabletext/editor 2.8.0 → 2.8.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/lib/_chunks-cjs/selector.is-selection-expanded.cjs +10 -4
- package/lib/_chunks-cjs/selector.is-selection-expanded.cjs.map +1 -1
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs +0 -1
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.slice-blocks.cjs +3 -6
- package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
- package/lib/_chunks-dts/behavior.types.action.d.cts +73 -73
- package/lib/_chunks-dts/behavior.types.action.d.ts +9 -9
- package/lib/_chunks-es/selector.is-selection-expanded.js +10 -4
- package/lib/_chunks-es/selector.is-selection-expanded.js.map +1 -1
- package/lib/_chunks-es/util.merge-text-blocks.js +0 -1
- package/lib/_chunks-es/util.merge-text-blocks.js.map +1 -1
- package/lib/_chunks-es/util.slice-blocks.js +3 -6
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
- package/lib/index.cjs +0 -10
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +0 -10
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.cts +3 -3
- package/lib/plugins/index.d.ts +3 -3
- package/lib/utils/index.d.ts +2 -2
- package/package.json +5 -5
- package/src/behaviors/behavior.abstract.split.ts +0 -1
- package/src/converters/converter.portable-text.ts +0 -1
- package/src/converters/converter.text-html.ts +0 -1
- package/src/converters/converter.text-plain.ts +0 -1
- package/src/editor/Editable.tsx +0 -1
- package/src/internal-utils/parse-blocks.test.ts +23 -23
- package/src/internal-utils/parse-blocks.ts +11 -23
- package/src/internal-utils/test-editor.tsx +15 -21
- package/src/operations/behavior.operation.annotation.add.ts +1 -1
- package/src/operations/behavior.operation.block.set.ts +1 -1
- package/src/operations/behavior.operation.block.unset.ts +2 -2
- package/src/operations/behavior.operation.insert.block.ts +1 -1
- package/src/plugins/plugin.internal.auto-close-brackets.test.tsx +25 -71
- package/src/plugins/plugin.markdown.test.tsx +12 -30
- package/src/selectors/selector.get-selected-value.test.ts +748 -0
- package/src/selectors/selector.get-selected-value.ts +28 -7
- package/src/selectors/selector.get-trimmed-selection.test.ts +0 -1
- package/src/utils/util.merge-text-blocks.ts +1 -1
- package/src/utils/util.slice-blocks.ts +3 -3
- package/src/utils/util.slice-blocks.test.ts +0 -499
|
@@ -3,12 +3,12 @@ import * as _sanity_types5 from "@sanity/types";
|
|
|
3
3
|
import { ArrayDefinition, ArraySchemaType, BlockDecoratorDefinition, BlockListDefinition, BlockStyleDefinition, ObjectSchemaType, Path, PortableTextBlock, PortableTextBlock as PortableTextBlock$1, PortableTextChild, PortableTextChild as PortableTextChild$1, PortableTextListBlock, PortableTextObject, PortableTextObject as PortableTextObject$1, PortableTextSpan, PortableTextSpan as PortableTextSpan$1, PortableTextTextBlock, PortableTextTextBlock as PortableTextTextBlock$1, TypedObject } from "@sanity/types";
|
|
4
4
|
import * as _portabletext_schema5 from "@portabletext/schema";
|
|
5
5
|
import { AnnotationDefinition, AnnotationSchemaType, BaseDefinition, BlockObjectDefinition, BlockObjectSchemaType, DecoratorDefinition, DecoratorSchemaType, FieldDefinition, InlineObjectDefinition, InlineObjectSchemaType, ListDefinition, ListSchemaType, Schema, SchemaDefinition, SchemaDefinition as SchemaDefinition$1, StyleDefinition, StyleSchemaType, defineSchema } from "@portabletext/schema";
|
|
6
|
-
import * as
|
|
6
|
+
import * as xstate241 from "xstate";
|
|
7
7
|
import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
|
|
8
8
|
import { BaseRange, Descendant, Operation } from "slate";
|
|
9
|
-
import * as
|
|
9
|
+
import * as react22 from "react";
|
|
10
10
|
import React$1, { BaseSyntheticEvent, ClipboardEvent, Component, FocusEvent, JSX, KeyboardEvent as KeyboardEvent$1, MutableRefObject, PropsWithChildren, ReactElement, RefObject, TextareaHTMLAttributes } from "react";
|
|
11
|
-
import * as
|
|
11
|
+
import * as xstate_guards14 from "xstate/guards";
|
|
12
12
|
import { Observable, Subject } from "rxjs";
|
|
13
13
|
import { DOMNode } from "slate-dom";
|
|
14
14
|
import { ReactEditor } from "slate-react";
|
|
@@ -215,7 +215,7 @@ declare class PortableTextEditor extends Component<PortableTextEditorProps<Inter
|
|
|
215
215
|
componentDidUpdate(prevProps: PortableTextEditorProps): void;
|
|
216
216
|
componentWillUnmount(): void;
|
|
217
217
|
setEditable: (editable: EditableAPI) => void;
|
|
218
|
-
render():
|
|
218
|
+
render(): react22.JSX.Element;
|
|
219
219
|
/**
|
|
220
220
|
* @deprecated
|
|
221
221
|
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
@@ -610,7 +610,7 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
|
|
|
610
610
|
* ```
|
|
611
611
|
* @group Components
|
|
612
612
|
*/
|
|
613
|
-
declare const PortableTextEditable:
|
|
613
|
+
declare const PortableTextEditable: react22.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react22.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
|
|
614
614
|
type DecoratedRange = BaseRange & {
|
|
615
615
|
rangeDecoration: RangeDecoration;
|
|
616
616
|
};
|
|
@@ -1176,7 +1176,7 @@ type EditorActor = ActorRefFrom<typeof editorMachine>;
|
|
|
1176
1176
|
/**
|
|
1177
1177
|
* @internal
|
|
1178
1178
|
*/
|
|
1179
|
-
declare const editorMachine:
|
|
1179
|
+
declare const editorMachine: xstate241.StateMachine<{
|
|
1180
1180
|
behaviors: Set<BehaviorConfig>;
|
|
1181
1181
|
behaviorsSorted: boolean;
|
|
1182
1182
|
converters: Set<Converter>;
|
|
@@ -1194,7 +1194,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1194
1194
|
};
|
|
1195
1195
|
dragGhost?: HTMLElement;
|
|
1196
1196
|
slateEditor?: PortableTextSlateEditor;
|
|
1197
|
-
},
|
|
1197
|
+
}, MutationEvent | InternalPatchEvent | PatchesEvent | {
|
|
1198
1198
|
type: "update readOnly";
|
|
1199
1199
|
readOnly: boolean;
|
|
1200
1200
|
} | {
|
|
@@ -1241,58 +1241,58 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1241
1241
|
type: "dragend";
|
|
1242
1242
|
} | {
|
|
1243
1243
|
type: "drop";
|
|
1244
|
-
}, {}, never,
|
|
1244
|
+
}, {}, never, xstate241.Values<{
|
|
1245
1245
|
"add behavior to context": {
|
|
1246
1246
|
type: "add behavior to context";
|
|
1247
|
-
params:
|
|
1247
|
+
params: xstate241.NonReducibleUnknown;
|
|
1248
1248
|
};
|
|
1249
1249
|
"remove behavior from context": {
|
|
1250
1250
|
type: "remove behavior from context";
|
|
1251
|
-
params:
|
|
1251
|
+
params: xstate241.NonReducibleUnknown;
|
|
1252
1252
|
};
|
|
1253
1253
|
"emit patch event": {
|
|
1254
1254
|
type: "emit patch event";
|
|
1255
|
-
params:
|
|
1255
|
+
params: xstate241.NonReducibleUnknown;
|
|
1256
1256
|
};
|
|
1257
1257
|
"emit mutation event": {
|
|
1258
1258
|
type: "emit mutation event";
|
|
1259
|
-
params:
|
|
1259
|
+
params: xstate241.NonReducibleUnknown;
|
|
1260
1260
|
};
|
|
1261
1261
|
"emit read only": {
|
|
1262
1262
|
type: "emit read only";
|
|
1263
|
-
params:
|
|
1263
|
+
params: xstate241.NonReducibleUnknown;
|
|
1264
1264
|
};
|
|
1265
1265
|
"emit editable": {
|
|
1266
1266
|
type: "emit editable";
|
|
1267
|
-
params:
|
|
1267
|
+
params: xstate241.NonReducibleUnknown;
|
|
1268
1268
|
};
|
|
1269
1269
|
"defer event": {
|
|
1270
1270
|
type: "defer event";
|
|
1271
|
-
params:
|
|
1271
|
+
params: xstate241.NonReducibleUnknown;
|
|
1272
1272
|
};
|
|
1273
1273
|
"emit pending events": {
|
|
1274
1274
|
type: "emit pending events";
|
|
1275
|
-
params:
|
|
1275
|
+
params: xstate241.NonReducibleUnknown;
|
|
1276
1276
|
};
|
|
1277
1277
|
"emit ready": {
|
|
1278
1278
|
type: "emit ready";
|
|
1279
|
-
params:
|
|
1279
|
+
params: xstate241.NonReducibleUnknown;
|
|
1280
1280
|
};
|
|
1281
1281
|
"clear pending events": {
|
|
1282
1282
|
type: "clear pending events";
|
|
1283
|
-
params:
|
|
1283
|
+
params: xstate241.NonReducibleUnknown;
|
|
1284
1284
|
};
|
|
1285
1285
|
"defer incoming patches": {
|
|
1286
1286
|
type: "defer incoming patches";
|
|
1287
|
-
params:
|
|
1287
|
+
params: xstate241.NonReducibleUnknown;
|
|
1288
1288
|
};
|
|
1289
1289
|
"emit pending incoming patches": {
|
|
1290
1290
|
type: "emit pending incoming patches";
|
|
1291
|
-
params:
|
|
1291
|
+
params: xstate241.NonReducibleUnknown;
|
|
1292
1292
|
};
|
|
1293
1293
|
"clear pending incoming patches": {
|
|
1294
1294
|
type: "clear pending incoming patches";
|
|
1295
|
-
params:
|
|
1295
|
+
params: xstate241.NonReducibleUnknown;
|
|
1296
1296
|
};
|
|
1297
1297
|
"handle blur": {
|
|
1298
1298
|
type: "handle blur";
|
|
@@ -1308,7 +1308,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1308
1308
|
};
|
|
1309
1309
|
"sort behaviors": {
|
|
1310
1310
|
type: "sort behaviors";
|
|
1311
|
-
params:
|
|
1311
|
+
params: xstate241.NonReducibleUnknown;
|
|
1312
1312
|
};
|
|
1313
1313
|
}>, {
|
|
1314
1314
|
type: "slate is busy";
|
|
@@ -1337,9 +1337,9 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1337
1337
|
readOnly?: boolean;
|
|
1338
1338
|
schema: EditorSchema;
|
|
1339
1339
|
initialValue?: Array<PortableTextBlock>;
|
|
1340
|
-
},
|
|
1340
|
+
}, xstate241.NonReducibleUnknown, {
|
|
1341
1341
|
type: "blurred";
|
|
1342
|
-
event:
|
|
1342
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
1343
1343
|
} | {
|
|
1344
1344
|
type: "done loading";
|
|
1345
1345
|
} | {
|
|
@@ -1351,14 +1351,14 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1351
1351
|
data: unknown;
|
|
1352
1352
|
} | {
|
|
1353
1353
|
type: "focused";
|
|
1354
|
-
event:
|
|
1354
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
1355
1355
|
} | {
|
|
1356
1356
|
type: "invalid value";
|
|
1357
1357
|
resolution: InvalidValueResolution | null;
|
|
1358
1358
|
value: Array<PortableTextBlock> | undefined;
|
|
1359
1359
|
} | {
|
|
1360
1360
|
type: "loading";
|
|
1361
|
-
} | {
|
|
1361
|
+
} | MutationEvent | {
|
|
1362
1362
|
type: "read only";
|
|
1363
1363
|
} | {
|
|
1364
1364
|
type: "ready";
|
|
@@ -1368,19 +1368,19 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1368
1368
|
} | {
|
|
1369
1369
|
type: "value changed";
|
|
1370
1370
|
value: Array<PortableTextBlock> | undefined;
|
|
1371
|
-
},
|
|
1371
|
+
} | InternalPatchEvent | PatchesEvent, xstate241.MetaObject, {
|
|
1372
1372
|
readonly id: "editor";
|
|
1373
1373
|
readonly context: ({
|
|
1374
1374
|
input
|
|
1375
1375
|
}: {
|
|
1376
1376
|
spawn: {
|
|
1377
|
-
<TSrc extends never>(logic: TSrc, ...[options]: never):
|
|
1378
|
-
<TLogic extends
|
|
1377
|
+
<TSrc extends never>(logic: TSrc, ...[options]: never): xstate241.ActorRefFromLogic<never>;
|
|
1378
|
+
<TLogic extends xstate241.AnyActorLogic>(src: TLogic, ...[options]: xstate241.ConditionalRequired<[options?: ({
|
|
1379
1379
|
id?: never;
|
|
1380
1380
|
systemId?: string;
|
|
1381
|
-
input?:
|
|
1381
|
+
input?: xstate241.InputFrom<TLogic> | undefined;
|
|
1382
1382
|
syncSnapshot?: boolean;
|
|
1383
|
-
} & { [K in
|
|
1383
|
+
} & { [K in xstate241.RequiredLogicInput<TLogic>]: unknown }) | undefined], xstate241.IsNotNever<xstate241.RequiredLogicInput<TLogic>>>): xstate241.ActorRefFromLogic<TLogic>;
|
|
1384
1384
|
};
|
|
1385
1385
|
input: {
|
|
1386
1386
|
converters?: Array<Converter>;
|
|
@@ -1391,7 +1391,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1391
1391
|
schema: EditorSchema;
|
|
1392
1392
|
initialValue?: Array<PortableTextBlock>;
|
|
1393
1393
|
};
|
|
1394
|
-
self:
|
|
1394
|
+
self: xstate241.ActorRef<xstate241.MachineSnapshot<{
|
|
1395
1395
|
behaviors: Set<BehaviorConfig>;
|
|
1396
1396
|
behaviorsSorted: boolean;
|
|
1397
1397
|
converters: Set<Converter>;
|
|
@@ -1409,7 +1409,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1409
1409
|
};
|
|
1410
1410
|
dragGhost?: HTMLElement;
|
|
1411
1411
|
slateEditor?: PortableTextSlateEditor;
|
|
1412
|
-
},
|
|
1412
|
+
}, MutationEvent | InternalPatchEvent | PatchesEvent | {
|
|
1413
1413
|
type: "update readOnly";
|
|
1414
1414
|
readOnly: boolean;
|
|
1415
1415
|
} | {
|
|
@@ -1456,7 +1456,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1456
1456
|
type: "dragend";
|
|
1457
1457
|
} | {
|
|
1458
1458
|
type: "drop";
|
|
1459
|
-
}, Record<string,
|
|
1459
|
+
}, Record<string, xstate241.AnyActorRef | undefined>, xstate241.StateValue, string, unknown, any, any>, MutationEvent | InternalPatchEvent | PatchesEvent | {
|
|
1460
1460
|
type: "update readOnly";
|
|
1461
1461
|
readOnly: boolean;
|
|
1462
1462
|
} | {
|
|
@@ -1503,10 +1503,10 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1503
1503
|
type: "dragend";
|
|
1504
1504
|
} | {
|
|
1505
1505
|
type: "drop";
|
|
1506
|
-
},
|
|
1506
|
+
}, xstate241.AnyEventObject>;
|
|
1507
1507
|
}) => {
|
|
1508
1508
|
behaviors: Set<{
|
|
1509
|
-
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.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.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" | "
|
|
1509
|
+
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.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.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.*" | "style.*" | "clipboard.*" | "drag.*" | "keyboard.*" | "mouse.*", true, {
|
|
1510
1510
|
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.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.previous block" | "select.next block" | "serialize" | "serialize.data" | "serialization.success" | "serialization.failure" | "style.add" | "style.remove" | "style.toggle", "annotation.add">;
|
|
1511
1511
|
annotation: {
|
|
1512
1512
|
name: string;
|
|
@@ -1798,7 +1798,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1798
1798
|
readonly actions: "remove behavior from context";
|
|
1799
1799
|
};
|
|
1800
1800
|
readonly 'update maxBlocks': {
|
|
1801
|
-
readonly actions:
|
|
1801
|
+
readonly actions: xstate241.ActionFunction<{
|
|
1802
1802
|
behaviors: Set<BehaviorConfig>;
|
|
1803
1803
|
behaviorsSorted: boolean;
|
|
1804
1804
|
converters: Set<Converter>;
|
|
@@ -1819,7 +1819,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1819
1819
|
}, {
|
|
1820
1820
|
type: "update maxBlocks";
|
|
1821
1821
|
maxBlocks: number | undefined;
|
|
1822
|
-
},
|
|
1822
|
+
}, MutationEvent | InternalPatchEvent | PatchesEvent | {
|
|
1823
1823
|
type: "update readOnly";
|
|
1824
1824
|
readOnly: boolean;
|
|
1825
1825
|
} | {
|
|
@@ -1869,7 +1869,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1869
1869
|
}, undefined, never, never, never, never, never>;
|
|
1870
1870
|
};
|
|
1871
1871
|
readonly 'update selection': {
|
|
1872
|
-
readonly actions: readonly [
|
|
1872
|
+
readonly actions: readonly [xstate241.ActionFunction<{
|
|
1873
1873
|
behaviors: Set<BehaviorConfig>;
|
|
1874
1874
|
behaviorsSorted: boolean;
|
|
1875
1875
|
converters: Set<Converter>;
|
|
@@ -1890,7 +1890,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1890
1890
|
}, {
|
|
1891
1891
|
type: "update selection";
|
|
1892
1892
|
selection: EditorSelection;
|
|
1893
|
-
},
|
|
1893
|
+
}, MutationEvent | InternalPatchEvent | PatchesEvent | {
|
|
1894
1894
|
type: "update readOnly";
|
|
1895
1895
|
readOnly: boolean;
|
|
1896
1896
|
} | {
|
|
@@ -1937,7 +1937,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1937
1937
|
type: "dragend";
|
|
1938
1938
|
} | {
|
|
1939
1939
|
type: "drop";
|
|
1940
|
-
}, undefined, never, never, never, never, never>,
|
|
1940
|
+
}, undefined, never, never, never, never, never>, xstate241.ActionFunction<{
|
|
1941
1941
|
behaviors: Set<BehaviorConfig>;
|
|
1942
1942
|
behaviorsSorted: boolean;
|
|
1943
1943
|
converters: Set<Converter>;
|
|
@@ -1958,7 +1958,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1958
1958
|
}, {
|
|
1959
1959
|
type: "update selection";
|
|
1960
1960
|
selection: EditorSelection;
|
|
1961
|
-
},
|
|
1961
|
+
}, MutationEvent | InternalPatchEvent | PatchesEvent | {
|
|
1962
1962
|
type: "update readOnly";
|
|
1963
1963
|
readOnly: boolean;
|
|
1964
1964
|
} | {
|
|
@@ -2005,9 +2005,9 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2005
2005
|
type: "dragend";
|
|
2006
2006
|
} | {
|
|
2007
2007
|
type: "drop";
|
|
2008
|
-
}, undefined, never, never, never, never,
|
|
2008
|
+
}, undefined, never, never, never, never, {
|
|
2009
2009
|
type: "blurred";
|
|
2010
|
-
event:
|
|
2010
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
2011
2011
|
} | {
|
|
2012
2012
|
type: "done loading";
|
|
2013
2013
|
} | {
|
|
@@ -2019,14 +2019,14 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2019
2019
|
data: unknown;
|
|
2020
2020
|
} | {
|
|
2021
2021
|
type: "focused";
|
|
2022
|
-
event:
|
|
2022
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
2023
2023
|
} | {
|
|
2024
2024
|
type: "invalid value";
|
|
2025
2025
|
resolution: InvalidValueResolution | null;
|
|
2026
2026
|
value: Array<PortableTextBlock> | undefined;
|
|
2027
2027
|
} | {
|
|
2028
2028
|
type: "loading";
|
|
2029
|
-
} | {
|
|
2029
|
+
} | MutationEvent | {
|
|
2030
2030
|
type: "read only";
|
|
2031
2031
|
} | {
|
|
2032
2032
|
type: "ready";
|
|
@@ -2036,10 +2036,10 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2036
2036
|
} | {
|
|
2037
2037
|
type: "value changed";
|
|
2038
2038
|
value: Array<PortableTextBlock> | undefined;
|
|
2039
|
-
}>];
|
|
2039
|
+
} | InternalPatchEvent | PatchesEvent>];
|
|
2040
2040
|
};
|
|
2041
2041
|
readonly 'set drag ghost': {
|
|
2042
|
-
readonly actions:
|
|
2042
|
+
readonly actions: xstate241.ActionFunction<{
|
|
2043
2043
|
behaviors: Set<BehaviorConfig>;
|
|
2044
2044
|
behaviorsSorted: boolean;
|
|
2045
2045
|
converters: Set<Converter>;
|
|
@@ -2060,7 +2060,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2060
2060
|
}, {
|
|
2061
2061
|
type: "set drag ghost";
|
|
2062
2062
|
ghost: HTMLElement;
|
|
2063
|
-
},
|
|
2063
|
+
}, MutationEvent | InternalPatchEvent | PatchesEvent | {
|
|
2064
2064
|
type: "update readOnly";
|
|
2065
2065
|
readOnly: boolean;
|
|
2066
2066
|
} | {
|
|
@@ -2122,7 +2122,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2122
2122
|
readonly actions: readonly ["sort behaviors", "handle behavior event"];
|
|
2123
2123
|
readonly guard: ({
|
|
2124
2124
|
event
|
|
2125
|
-
}:
|
|
2125
|
+
}: xstate_guards14.GuardArgs<{
|
|
2126
2126
|
behaviors: Set<BehaviorConfig>;
|
|
2127
2127
|
behaviorsSorted: boolean;
|
|
2128
2128
|
converters: Set<Converter>;
|
|
@@ -2159,7 +2159,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2159
2159
|
readonly target: "#editor.edit mode.read only.read only";
|
|
2160
2160
|
readonly guard: ({
|
|
2161
2161
|
context
|
|
2162
|
-
}:
|
|
2162
|
+
}: xstate_guards14.GuardArgs<{
|
|
2163
2163
|
behaviors: Set<BehaviorConfig>;
|
|
2164
2164
|
behaviorsSorted: boolean;
|
|
2165
2165
|
converters: Set<Converter>;
|
|
@@ -2192,7 +2192,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2192
2192
|
readonly 'update readOnly': {
|
|
2193
2193
|
readonly guard: ({
|
|
2194
2194
|
event
|
|
2195
|
-
}:
|
|
2195
|
+
}: xstate_guards14.GuardArgs<{
|
|
2196
2196
|
behaviors: Set<BehaviorConfig>;
|
|
2197
2197
|
behaviorsSorted: boolean;
|
|
2198
2198
|
converters: Set<Converter>;
|
|
@@ -2226,7 +2226,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2226
2226
|
readonly 'update readOnly': {
|
|
2227
2227
|
readonly guard: ({
|
|
2228
2228
|
event
|
|
2229
|
-
}:
|
|
2229
|
+
}: xstate_guards14.GuardArgs<{
|
|
2230
2230
|
behaviors: Set<BehaviorConfig>;
|
|
2231
2231
|
behaviorsSorted: boolean;
|
|
2232
2232
|
converters: Set<Converter>;
|
|
@@ -2259,7 +2259,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2259
2259
|
};
|
|
2260
2260
|
readonly focus: {
|
|
2261
2261
|
readonly target: ".focusing";
|
|
2262
|
-
readonly actions: readonly [
|
|
2262
|
+
readonly actions: readonly [xstate241.ActionFunction<{
|
|
2263
2263
|
behaviors: Set<BehaviorConfig>;
|
|
2264
2264
|
behaviorsSorted: boolean;
|
|
2265
2265
|
converters: Set<Converter>;
|
|
@@ -2280,7 +2280,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2280
2280
|
}, {
|
|
2281
2281
|
type: "focus";
|
|
2282
2282
|
editor: PortableTextSlateEditor;
|
|
2283
|
-
},
|
|
2283
|
+
}, MutationEvent | InternalPatchEvent | PatchesEvent | {
|
|
2284
2284
|
type: "update readOnly";
|
|
2285
2285
|
readOnly: boolean;
|
|
2286
2286
|
} | {
|
|
@@ -2337,7 +2337,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2337
2337
|
readonly exit: readonly [() => void];
|
|
2338
2338
|
readonly on: {
|
|
2339
2339
|
readonly dragstart: {
|
|
2340
|
-
readonly actions: readonly [
|
|
2340
|
+
readonly actions: readonly [xstate241.ActionFunction<{
|
|
2341
2341
|
behaviors: Set<BehaviorConfig>;
|
|
2342
2342
|
behaviorsSorted: boolean;
|
|
2343
2343
|
converters: Set<Converter>;
|
|
@@ -2359,7 +2359,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2359
2359
|
type: "dragstart";
|
|
2360
2360
|
ghost?: HTMLElement;
|
|
2361
2361
|
origin: Pick<EventPosition, "selection">;
|
|
2362
|
-
},
|
|
2362
|
+
}, MutationEvent | InternalPatchEvent | PatchesEvent | {
|
|
2363
2363
|
type: "update readOnly";
|
|
2364
2364
|
readOnly: boolean;
|
|
2365
2365
|
} | {
|
|
@@ -2440,7 +2440,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2440
2440
|
readonly entry: readonly [() => void];
|
|
2441
2441
|
readonly exit: readonly [() => void, ({
|
|
2442
2442
|
context
|
|
2443
|
-
}:
|
|
2443
|
+
}: xstate241.ActionArgs<{
|
|
2444
2444
|
behaviors: Set<BehaviorConfig>;
|
|
2445
2445
|
behaviorsSorted: boolean;
|
|
2446
2446
|
converters: Set<Converter>;
|
|
@@ -2458,7 +2458,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2458
2458
|
};
|
|
2459
2459
|
dragGhost?: HTMLElement;
|
|
2460
2460
|
slateEditor?: PortableTextSlateEditor;
|
|
2461
|
-
},
|
|
2461
|
+
}, MutationEvent | InternalPatchEvent | PatchesEvent | {
|
|
2462
2462
|
type: "update readOnly";
|
|
2463
2463
|
readOnly: boolean;
|
|
2464
2464
|
} | {
|
|
@@ -2505,7 +2505,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2505
2505
|
type: "dragend";
|
|
2506
2506
|
} | {
|
|
2507
2507
|
type: "drop";
|
|
2508
|
-
},
|
|
2508
|
+
}, MutationEvent | InternalPatchEvent | PatchesEvent | {
|
|
2509
2509
|
type: "update readOnly";
|
|
2510
2510
|
readOnly: boolean;
|
|
2511
2511
|
} | {
|
|
@@ -2552,7 +2552,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2552
2552
|
type: "dragend";
|
|
2553
2553
|
} | {
|
|
2554
2554
|
type: "drop";
|
|
2555
|
-
}>) => void,
|
|
2555
|
+
}>) => void, xstate241.ActionFunction<{
|
|
2556
2556
|
behaviors: Set<BehaviorConfig>;
|
|
2557
2557
|
behaviorsSorted: boolean;
|
|
2558
2558
|
converters: Set<Converter>;
|
|
@@ -2570,7 +2570,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2570
2570
|
};
|
|
2571
2571
|
dragGhost?: HTMLElement;
|
|
2572
2572
|
slateEditor?: PortableTextSlateEditor;
|
|
2573
|
-
},
|
|
2573
|
+
}, MutationEvent | InternalPatchEvent | PatchesEvent | {
|
|
2574
2574
|
type: "update readOnly";
|
|
2575
2575
|
readOnly: boolean;
|
|
2576
2576
|
} | {
|
|
@@ -2617,7 +2617,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2617
2617
|
type: "dragend";
|
|
2618
2618
|
} | {
|
|
2619
2619
|
type: "drop";
|
|
2620
|
-
},
|
|
2620
|
+
}, MutationEvent | InternalPatchEvent | PatchesEvent | {
|
|
2621
2621
|
type: "update readOnly";
|
|
2622
2622
|
readOnly: boolean;
|
|
2623
2623
|
} | {
|
|
@@ -2664,7 +2664,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2664
2664
|
type: "dragend";
|
|
2665
2665
|
} | {
|
|
2666
2666
|
type: "drop";
|
|
2667
|
-
}, undefined, never, never, never, never, never>,
|
|
2667
|
+
}, undefined, never, never, never, never, never>, xstate241.ActionFunction<{
|
|
2668
2668
|
behaviors: Set<BehaviorConfig>;
|
|
2669
2669
|
behaviorsSorted: boolean;
|
|
2670
2670
|
converters: Set<Converter>;
|
|
@@ -2682,7 +2682,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2682
2682
|
};
|
|
2683
2683
|
dragGhost?: HTMLElement;
|
|
2684
2684
|
slateEditor?: PortableTextSlateEditor;
|
|
2685
|
-
},
|
|
2685
|
+
}, MutationEvent | InternalPatchEvent | PatchesEvent | {
|
|
2686
2686
|
type: "update readOnly";
|
|
2687
2687
|
readOnly: boolean;
|
|
2688
2688
|
} | {
|
|
@@ -2729,7 +2729,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2729
2729
|
type: "dragend";
|
|
2730
2730
|
} | {
|
|
2731
2731
|
type: "drop";
|
|
2732
|
-
},
|
|
2732
|
+
}, MutationEvent | InternalPatchEvent | PatchesEvent | {
|
|
2733
2733
|
type: "update readOnly";
|
|
2734
2734
|
readOnly: boolean;
|
|
2735
2735
|
} | {
|
|
@@ -2823,7 +2823,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2823
2823
|
readonly exit: readonly [() => void];
|
|
2824
2824
|
readonly on: {
|
|
2825
2825
|
readonly patches: {
|
|
2826
|
-
readonly actions: readonly [
|
|
2826
|
+
readonly actions: readonly [xstate241.ActionFunction<{
|
|
2827
2827
|
behaviors: Set<BehaviorConfig>;
|
|
2828
2828
|
behaviorsSorted: boolean;
|
|
2829
2829
|
converters: Set<Converter>;
|
|
@@ -2841,7 +2841,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2841
2841
|
};
|
|
2842
2842
|
dragGhost?: HTMLElement;
|
|
2843
2843
|
slateEditor?: PortableTextSlateEditor;
|
|
2844
|
-
}, PatchesEvent,
|
|
2844
|
+
}, PatchesEvent, MutationEvent | InternalPatchEvent | PatchesEvent | {
|
|
2845
2845
|
type: "update readOnly";
|
|
2846
2846
|
readOnly: boolean;
|
|
2847
2847
|
} | {
|
|
@@ -2888,9 +2888,9 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2888
2888
|
type: "dragend";
|
|
2889
2889
|
} | {
|
|
2890
2890
|
type: "drop";
|
|
2891
|
-
}, undefined, never, never, never, never,
|
|
2891
|
+
}, undefined, never, never, never, never, {
|
|
2892
2892
|
type: "blurred";
|
|
2893
|
-
event:
|
|
2893
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
2894
2894
|
} | {
|
|
2895
2895
|
type: "done loading";
|
|
2896
2896
|
} | {
|
|
@@ -2902,14 +2902,14 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2902
2902
|
data: unknown;
|
|
2903
2903
|
} | {
|
|
2904
2904
|
type: "focused";
|
|
2905
|
-
event:
|
|
2905
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
2906
2906
|
} | {
|
|
2907
2907
|
type: "invalid value";
|
|
2908
2908
|
resolution: InvalidValueResolution | null;
|
|
2909
2909
|
value: Array<PortableTextBlock> | undefined;
|
|
2910
2910
|
} | {
|
|
2911
2911
|
type: "loading";
|
|
2912
|
-
} | {
|
|
2912
|
+
} | MutationEvent | {
|
|
2913
2913
|
type: "read only";
|
|
2914
2914
|
} | {
|
|
2915
2915
|
type: "ready";
|
|
@@ -2919,7 +2919,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2919
2919
|
} | {
|
|
2920
2920
|
type: "value changed";
|
|
2921
2921
|
value: Array<PortableTextBlock> | undefined;
|
|
2922
|
-
}>];
|
|
2922
|
+
} | InternalPatchEvent | PatchesEvent>];
|
|
2923
2923
|
};
|
|
2924
2924
|
readonly 'syncing value': {
|
|
2925
2925
|
readonly target: "syncing value";
|
|
@@ -6,7 +6,7 @@ import { AnnotationDefinition, AnnotationSchemaType, BaseDefinition, BlockObject
|
|
|
6
6
|
import * as xstate227 from "xstate";
|
|
7
7
|
import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
|
|
8
8
|
import { BaseRange, Descendant, Operation } from "slate";
|
|
9
|
-
import * as
|
|
9
|
+
import * as react22 from "react";
|
|
10
10
|
import React$1, { BaseSyntheticEvent, ClipboardEvent, Component, FocusEvent, JSX, KeyboardEvent as KeyboardEvent$1, MutableRefObject, PropsWithChildren, ReactElement, RefObject, TextareaHTMLAttributes } from "react";
|
|
11
11
|
import * as xstate_guards12 from "xstate/guards";
|
|
12
12
|
import { Observable, Subject } from "rxjs";
|
|
@@ -215,7 +215,7 @@ declare class PortableTextEditor extends Component<PortableTextEditorProps<Inter
|
|
|
215
215
|
componentDidUpdate(prevProps: PortableTextEditorProps): void;
|
|
216
216
|
componentWillUnmount(): void;
|
|
217
217
|
setEditable: (editable: EditableAPI) => void;
|
|
218
|
-
render():
|
|
218
|
+
render(): react22.JSX.Element;
|
|
219
219
|
/**
|
|
220
220
|
* @deprecated
|
|
221
221
|
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
@@ -610,7 +610,7 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
|
|
|
610
610
|
* ```
|
|
611
611
|
* @group Components
|
|
612
612
|
*/
|
|
613
|
-
declare const PortableTextEditable:
|
|
613
|
+
declare const PortableTextEditable: react22.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react22.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
|
|
614
614
|
type DecoratedRange = BaseRange & {
|
|
615
615
|
rangeDecoration: RangeDecoration;
|
|
616
616
|
};
|
|
@@ -1339,7 +1339,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1339
1339
|
initialValue?: Array<PortableTextBlock>;
|
|
1340
1340
|
}, xstate227.NonReducibleUnknown, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
1341
1341
|
type: "blurred";
|
|
1342
|
-
event:
|
|
1342
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
1343
1343
|
} | {
|
|
1344
1344
|
type: "done loading";
|
|
1345
1345
|
} | {
|
|
@@ -1351,7 +1351,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1351
1351
|
data: unknown;
|
|
1352
1352
|
} | {
|
|
1353
1353
|
type: "focused";
|
|
1354
|
-
event:
|
|
1354
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
1355
1355
|
} | {
|
|
1356
1356
|
type: "invalid value";
|
|
1357
1357
|
resolution: InvalidValueResolution | null;
|
|
@@ -2007,7 +2007,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2007
2007
|
type: "drop";
|
|
2008
2008
|
}, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
2009
2009
|
type: "blurred";
|
|
2010
|
-
event:
|
|
2010
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
2011
2011
|
} | {
|
|
2012
2012
|
type: "done loading";
|
|
2013
2013
|
} | {
|
|
@@ -2019,7 +2019,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2019
2019
|
data: unknown;
|
|
2020
2020
|
} | {
|
|
2021
2021
|
type: "focused";
|
|
2022
|
-
event:
|
|
2022
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
2023
2023
|
} | {
|
|
2024
2024
|
type: "invalid value";
|
|
2025
2025
|
resolution: InvalidValueResolution | null;
|
|
@@ -2890,7 +2890,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2890
2890
|
type: "drop";
|
|
2891
2891
|
}, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
2892
2892
|
type: "blurred";
|
|
2893
|
-
event:
|
|
2893
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
2894
2894
|
} | {
|
|
2895
2895
|
type: "done loading";
|
|
2896
2896
|
} | {
|
|
@@ -2902,7 +2902,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2902
2902
|
data: unknown;
|
|
2903
2903
|
} | {
|
|
2904
2904
|
type: "focused";
|
|
2905
|
-
event:
|
|
2905
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
2906
2906
|
} | {
|
|
2907
2907
|
type: "invalid value";
|
|
2908
2908
|
resolution: InvalidValueResolution | null;
|
|
@@ -65,11 +65,17 @@ const getFocusBlock = (snapshot) => {
|
|
|
65
65
|
const startBlockIndex = snapshot.blockIndexMap.get(startBlockKey), endBlockIndex = snapshot.blockIndexMap.get(endBlockKey);
|
|
66
66
|
if (startBlockIndex === void 0 || endBlockIndex === void 0)
|
|
67
67
|
return [];
|
|
68
|
-
const
|
|
69
|
-
return sliceBlocks({
|
|
68
|
+
const startBlock = snapshot.context.value.at(startBlockIndex), slicedStartBlock = startBlock ? sliceBlocks({
|
|
70
69
|
context: snapshot.context,
|
|
71
|
-
blocks:
|
|
72
|
-
});
|
|
70
|
+
blocks: [startBlock]
|
|
71
|
+
}).at(0) : void 0;
|
|
72
|
+
if (startBlockIndex === endBlockIndex)
|
|
73
|
+
return slicedStartBlock ? [slicedStartBlock] : [];
|
|
74
|
+
const endBlock = snapshot.context.value.at(endBlockIndex), slicedEndBlock = endBlock ? sliceBlocks({
|
|
75
|
+
context: snapshot.context,
|
|
76
|
+
blocks: [endBlock]
|
|
77
|
+
}).at(0) : void 0, middleBlocks = snapshot.context.value.slice(startBlockIndex + 1, endBlockIndex);
|
|
78
|
+
return [...slicedStartBlock ? [slicedStartBlock] : [], ...middleBlocks, ...slicedEndBlock ? [slicedEndBlock] : []];
|
|
73
79
|
}, getSelectionText = (snapshot) => getSelectedValue(snapshot).reduce((text, block) => isTextBlock(snapshot.context, block) ? text + block.children.reduce((text2, child) => isSpan(snapshot.context, child) ? text2 + child.text : text2, "") : text, ""), isSelectionCollapsed = (snapshot) => snapshot.context.selection ? JSON.stringify(snapshot.context.selection.anchor.path) === JSON.stringify(snapshot.context.selection.focus.path) && snapshot.context.selection?.anchor.offset === snapshot.context.selection?.focus.offset : !1, isSelectionExpanded = (snapshot) => !isSelectionCollapsed(snapshot);
|
|
74
80
|
export {
|
|
75
81
|
getFocusBlock,
|