@portabletext/editor 2.8.3 → 2.8.4

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.
@@ -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 xstate241 from "xstate";
6
+ import * as xstate227 from "xstate";
7
7
  import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
8
8
  import { BaseRange, Descendant, Operation } from "slate";
9
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 xstate_guards14 from "xstate/guards";
11
+ import * as xstate_guards12 from "xstate/guards";
12
12
  import { Observable, Subject } from "rxjs";
13
13
  import { DOMNode } from "slate-dom";
14
14
  import { ReactEditor } from "slate-react";
@@ -1172,7 +1172,7 @@ type EditorActor = ActorRefFrom<typeof editorMachine>;
1172
1172
  /**
1173
1173
  * @internal
1174
1174
  */
1175
- declare const editorMachine: xstate241.StateMachine<{
1175
+ declare const editorMachine: xstate227.StateMachine<{
1176
1176
  behaviors: Set<BehaviorConfig>;
1177
1177
  behaviorsSorted: boolean;
1178
1178
  converters: Set<Converter>;
@@ -1190,7 +1190,7 @@ declare const editorMachine: xstate241.StateMachine<{
1190
1190
  };
1191
1191
  dragGhost?: HTMLElement;
1192
1192
  slateEditor?: PortableTextSlateEditor;
1193
- }, MutationEvent | InternalPatchEvent | PatchesEvent | {
1193
+ }, InternalPatchEvent | MutationEvent | PatchesEvent | {
1194
1194
  type: "update readOnly";
1195
1195
  readOnly: boolean;
1196
1196
  } | {
@@ -1237,58 +1237,58 @@ declare const editorMachine: xstate241.StateMachine<{
1237
1237
  type: "dragend";
1238
1238
  } | {
1239
1239
  type: "drop";
1240
- }, {}, never, xstate241.Values<{
1240
+ }, {}, never, xstate227.Values<{
1241
1241
  "add behavior to context": {
1242
1242
  type: "add behavior to context";
1243
- params: xstate241.NonReducibleUnknown;
1243
+ params: xstate227.NonReducibleUnknown;
1244
1244
  };
1245
1245
  "remove behavior from context": {
1246
1246
  type: "remove behavior from context";
1247
- params: xstate241.NonReducibleUnknown;
1247
+ params: xstate227.NonReducibleUnknown;
1248
1248
  };
1249
1249
  "emit patch event": {
1250
1250
  type: "emit patch event";
1251
- params: xstate241.NonReducibleUnknown;
1251
+ params: xstate227.NonReducibleUnknown;
1252
1252
  };
1253
1253
  "emit mutation event": {
1254
1254
  type: "emit mutation event";
1255
- params: xstate241.NonReducibleUnknown;
1255
+ params: xstate227.NonReducibleUnknown;
1256
1256
  };
1257
1257
  "emit read only": {
1258
1258
  type: "emit read only";
1259
- params: xstate241.NonReducibleUnknown;
1259
+ params: xstate227.NonReducibleUnknown;
1260
1260
  };
1261
1261
  "emit editable": {
1262
1262
  type: "emit editable";
1263
- params: xstate241.NonReducibleUnknown;
1263
+ params: xstate227.NonReducibleUnknown;
1264
1264
  };
1265
1265
  "defer event": {
1266
1266
  type: "defer event";
1267
- params: xstate241.NonReducibleUnknown;
1267
+ params: xstate227.NonReducibleUnknown;
1268
1268
  };
1269
1269
  "emit pending events": {
1270
1270
  type: "emit pending events";
1271
- params: xstate241.NonReducibleUnknown;
1271
+ params: xstate227.NonReducibleUnknown;
1272
1272
  };
1273
1273
  "emit ready": {
1274
1274
  type: "emit ready";
1275
- params: xstate241.NonReducibleUnknown;
1275
+ params: xstate227.NonReducibleUnknown;
1276
1276
  };
1277
1277
  "clear pending events": {
1278
1278
  type: "clear pending events";
1279
- params: xstate241.NonReducibleUnknown;
1279
+ params: xstate227.NonReducibleUnknown;
1280
1280
  };
1281
1281
  "defer incoming patches": {
1282
1282
  type: "defer incoming patches";
1283
- params: xstate241.NonReducibleUnknown;
1283
+ params: xstate227.NonReducibleUnknown;
1284
1284
  };
1285
1285
  "emit pending incoming patches": {
1286
1286
  type: "emit pending incoming patches";
1287
- params: xstate241.NonReducibleUnknown;
1287
+ params: xstate227.NonReducibleUnknown;
1288
1288
  };
1289
1289
  "clear pending incoming patches": {
1290
1290
  type: "clear pending incoming patches";
1291
- params: xstate241.NonReducibleUnknown;
1291
+ params: xstate227.NonReducibleUnknown;
1292
1292
  };
1293
1293
  "handle blur": {
1294
1294
  type: "handle blur";
@@ -1304,7 +1304,7 @@ declare const editorMachine: xstate241.StateMachine<{
1304
1304
  };
1305
1305
  "sort behaviors": {
1306
1306
  type: "sort behaviors";
1307
- params: xstate241.NonReducibleUnknown;
1307
+ params: xstate227.NonReducibleUnknown;
1308
1308
  };
1309
1309
  }>, {
1310
1310
  type: "slate is busy";
@@ -1333,7 +1333,7 @@ declare const editorMachine: xstate241.StateMachine<{
1333
1333
  readOnly?: boolean;
1334
1334
  schema: EditorSchema;
1335
1335
  initialValue?: Array<PortableTextBlock>;
1336
- }, xstate241.NonReducibleUnknown, {
1336
+ }, xstate227.NonReducibleUnknown, InternalPatchEvent | MutationEvent | PatchesEvent | {
1337
1337
  type: "blurred";
1338
1338
  event: react22.FocusEvent<HTMLDivElement, Element>;
1339
1339
  } | {
@@ -1354,7 +1354,7 @@ declare const editorMachine: xstate241.StateMachine<{
1354
1354
  value: Array<PortableTextBlock> | undefined;
1355
1355
  } | {
1356
1356
  type: "loading";
1357
- } | MutationEvent | {
1357
+ } | {
1358
1358
  type: "read only";
1359
1359
  } | {
1360
1360
  type: "ready";
@@ -1364,19 +1364,19 @@ declare const editorMachine: xstate241.StateMachine<{
1364
1364
  } | {
1365
1365
  type: "value changed";
1366
1366
  value: Array<PortableTextBlock> | undefined;
1367
- } | InternalPatchEvent | PatchesEvent, xstate241.MetaObject, {
1367
+ }, xstate227.MetaObject, {
1368
1368
  readonly id: "editor";
1369
1369
  readonly context: ({
1370
1370
  input
1371
1371
  }: {
1372
1372
  spawn: {
1373
- <TSrc extends never>(logic: TSrc, ...[options]: never): xstate241.ActorRefFromLogic<never>;
1374
- <TLogic extends xstate241.AnyActorLogic>(src: TLogic, ...[options]: xstate241.ConditionalRequired<[options?: ({
1373
+ <TSrc extends never>(logic: TSrc, ...[options]: never): xstate227.ActorRefFromLogic<never>;
1374
+ <TLogic extends xstate227.AnyActorLogic>(src: TLogic, ...[options]: xstate227.ConditionalRequired<[options?: ({
1375
1375
  id?: never;
1376
1376
  systemId?: string;
1377
- input?: xstate241.InputFrom<TLogic> | undefined;
1377
+ input?: xstate227.InputFrom<TLogic> | undefined;
1378
1378
  syncSnapshot?: boolean;
1379
- } & { [K in xstate241.RequiredLogicInput<TLogic>]: unknown }) | undefined], xstate241.IsNotNever<xstate241.RequiredLogicInput<TLogic>>>): xstate241.ActorRefFromLogic<TLogic>;
1379
+ } & { [K in xstate227.RequiredLogicInput<TLogic>]: unknown }) | undefined], xstate227.IsNotNever<xstate227.RequiredLogicInput<TLogic>>>): xstate227.ActorRefFromLogic<TLogic>;
1380
1380
  };
1381
1381
  input: {
1382
1382
  converters?: Array<Converter>;
@@ -1387,7 +1387,7 @@ declare const editorMachine: xstate241.StateMachine<{
1387
1387
  schema: EditorSchema;
1388
1388
  initialValue?: Array<PortableTextBlock>;
1389
1389
  };
1390
- self: xstate241.ActorRef<xstate241.MachineSnapshot<{
1390
+ self: xstate227.ActorRef<xstate227.MachineSnapshot<{
1391
1391
  behaviors: Set<BehaviorConfig>;
1392
1392
  behaviorsSorted: boolean;
1393
1393
  converters: Set<Converter>;
@@ -1405,7 +1405,7 @@ declare const editorMachine: xstate241.StateMachine<{
1405
1405
  };
1406
1406
  dragGhost?: HTMLElement;
1407
1407
  slateEditor?: PortableTextSlateEditor;
1408
- }, MutationEvent | InternalPatchEvent | PatchesEvent | {
1408
+ }, InternalPatchEvent | MutationEvent | PatchesEvent | {
1409
1409
  type: "update readOnly";
1410
1410
  readOnly: boolean;
1411
1411
  } | {
@@ -1452,7 +1452,7 @@ declare const editorMachine: xstate241.StateMachine<{
1452
1452
  type: "dragend";
1453
1453
  } | {
1454
1454
  type: "drop";
1455
- }, Record<string, xstate241.AnyActorRef | undefined>, xstate241.StateValue, string, unknown, any, any>, MutationEvent | InternalPatchEvent | PatchesEvent | {
1455
+ }, Record<string, xstate227.AnyActorRef | undefined>, xstate227.StateValue, string, unknown, any, any>, InternalPatchEvent | MutationEvent | PatchesEvent | {
1456
1456
  type: "update readOnly";
1457
1457
  readOnly: boolean;
1458
1458
  } | {
@@ -1499,10 +1499,10 @@ declare const editorMachine: xstate241.StateMachine<{
1499
1499
  type: "dragend";
1500
1500
  } | {
1501
1501
  type: "drop";
1502
- }, xstate241.AnyEventObject>;
1502
+ }, xstate227.AnyEventObject>;
1503
1503
  }) => {
1504
1504
  behaviors: Set<{
1505
- 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.*" | "style.*" | "delete.*" | "select.*" | "deserialize.*" | "serialize.*" | "annotation.*" | "block.*" | "child.*" | "decorator.*" | "insert.*" | "move.*" | "deserialization.*" | "list item.*" | "serialization.*" | "clipboard.*" | "drag.*" | "keyboard.*" | "mouse.*", true, {
1505
+ 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" | "style.*" | "history.*" | "split.*" | "delete.*" | "select.*" | "deserialize.*" | "serialize.*" | "annotation.*" | "block.*" | "child.*" | "decorator.*" | "insert.*" | "move.*" | "deserialization.*" | "list item.*" | "serialization.*" | "clipboard.*" | "drag.*" | "keyboard.*" | "mouse.*", true, {
1506
1506
  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">;
1507
1507
  annotation: {
1508
1508
  name: string;
@@ -1794,7 +1794,7 @@ declare const editorMachine: xstate241.StateMachine<{
1794
1794
  readonly actions: "remove behavior from context";
1795
1795
  };
1796
1796
  readonly 'update maxBlocks': {
1797
- readonly actions: xstate241.ActionFunction<{
1797
+ readonly actions: xstate227.ActionFunction<{
1798
1798
  behaviors: Set<BehaviorConfig>;
1799
1799
  behaviorsSorted: boolean;
1800
1800
  converters: Set<Converter>;
@@ -1815,7 +1815,7 @@ declare const editorMachine: xstate241.StateMachine<{
1815
1815
  }, {
1816
1816
  type: "update maxBlocks";
1817
1817
  maxBlocks: number | undefined;
1818
- }, MutationEvent | InternalPatchEvent | PatchesEvent | {
1818
+ }, InternalPatchEvent | MutationEvent | PatchesEvent | {
1819
1819
  type: "update readOnly";
1820
1820
  readOnly: boolean;
1821
1821
  } | {
@@ -1865,7 +1865,7 @@ declare const editorMachine: xstate241.StateMachine<{
1865
1865
  }, undefined, never, never, never, never, never>;
1866
1866
  };
1867
1867
  readonly 'update selection': {
1868
- readonly actions: readonly [xstate241.ActionFunction<{
1868
+ readonly actions: readonly [xstate227.ActionFunction<{
1869
1869
  behaviors: Set<BehaviorConfig>;
1870
1870
  behaviorsSorted: boolean;
1871
1871
  converters: Set<Converter>;
@@ -1886,7 +1886,7 @@ declare const editorMachine: xstate241.StateMachine<{
1886
1886
  }, {
1887
1887
  type: "update selection";
1888
1888
  selection: EditorSelection;
1889
- }, MutationEvent | InternalPatchEvent | PatchesEvent | {
1889
+ }, InternalPatchEvent | MutationEvent | PatchesEvent | {
1890
1890
  type: "update readOnly";
1891
1891
  readOnly: boolean;
1892
1892
  } | {
@@ -1933,7 +1933,7 @@ declare const editorMachine: xstate241.StateMachine<{
1933
1933
  type: "dragend";
1934
1934
  } | {
1935
1935
  type: "drop";
1936
- }, undefined, never, never, never, never, never>, xstate241.ActionFunction<{
1936
+ }, undefined, never, never, never, never, never>, xstate227.ActionFunction<{
1937
1937
  behaviors: Set<BehaviorConfig>;
1938
1938
  behaviorsSorted: boolean;
1939
1939
  converters: Set<Converter>;
@@ -1954,7 +1954,7 @@ declare const editorMachine: xstate241.StateMachine<{
1954
1954
  }, {
1955
1955
  type: "update selection";
1956
1956
  selection: EditorSelection;
1957
- }, MutationEvent | InternalPatchEvent | PatchesEvent | {
1957
+ }, InternalPatchEvent | MutationEvent | PatchesEvent | {
1958
1958
  type: "update readOnly";
1959
1959
  readOnly: boolean;
1960
1960
  } | {
@@ -2001,7 +2001,7 @@ declare const editorMachine: xstate241.StateMachine<{
2001
2001
  type: "dragend";
2002
2002
  } | {
2003
2003
  type: "drop";
2004
- }, undefined, never, never, never, never, {
2004
+ }, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
2005
2005
  type: "blurred";
2006
2006
  event: react22.FocusEvent<HTMLDivElement, Element>;
2007
2007
  } | {
@@ -2022,7 +2022,7 @@ declare const editorMachine: xstate241.StateMachine<{
2022
2022
  value: Array<PortableTextBlock> | undefined;
2023
2023
  } | {
2024
2024
  type: "loading";
2025
- } | MutationEvent | {
2025
+ } | {
2026
2026
  type: "read only";
2027
2027
  } | {
2028
2028
  type: "ready";
@@ -2032,10 +2032,10 @@ declare const editorMachine: xstate241.StateMachine<{
2032
2032
  } | {
2033
2033
  type: "value changed";
2034
2034
  value: Array<PortableTextBlock> | undefined;
2035
- } | InternalPatchEvent | PatchesEvent>];
2035
+ }>];
2036
2036
  };
2037
2037
  readonly 'set drag ghost': {
2038
- readonly actions: xstate241.ActionFunction<{
2038
+ readonly actions: xstate227.ActionFunction<{
2039
2039
  behaviors: Set<BehaviorConfig>;
2040
2040
  behaviorsSorted: boolean;
2041
2041
  converters: Set<Converter>;
@@ -2056,7 +2056,7 @@ declare const editorMachine: xstate241.StateMachine<{
2056
2056
  }, {
2057
2057
  type: "set drag ghost";
2058
2058
  ghost: HTMLElement;
2059
- }, MutationEvent | InternalPatchEvent | PatchesEvent | {
2059
+ }, InternalPatchEvent | MutationEvent | PatchesEvent | {
2060
2060
  type: "update readOnly";
2061
2061
  readOnly: boolean;
2062
2062
  } | {
@@ -2118,7 +2118,7 @@ declare const editorMachine: xstate241.StateMachine<{
2118
2118
  readonly actions: readonly ["sort behaviors", "handle behavior event"];
2119
2119
  readonly guard: ({
2120
2120
  event
2121
- }: xstate_guards14.GuardArgs<{
2121
+ }: xstate_guards12.GuardArgs<{
2122
2122
  behaviors: Set<BehaviorConfig>;
2123
2123
  behaviorsSorted: boolean;
2124
2124
  converters: Set<Converter>;
@@ -2155,7 +2155,7 @@ declare const editorMachine: xstate241.StateMachine<{
2155
2155
  readonly target: "#editor.edit mode.read only.read only";
2156
2156
  readonly guard: ({
2157
2157
  context
2158
- }: xstate_guards14.GuardArgs<{
2158
+ }: xstate_guards12.GuardArgs<{
2159
2159
  behaviors: Set<BehaviorConfig>;
2160
2160
  behaviorsSorted: boolean;
2161
2161
  converters: Set<Converter>;
@@ -2188,7 +2188,7 @@ declare const editorMachine: xstate241.StateMachine<{
2188
2188
  readonly 'update readOnly': {
2189
2189
  readonly guard: ({
2190
2190
  event
2191
- }: xstate_guards14.GuardArgs<{
2191
+ }: xstate_guards12.GuardArgs<{
2192
2192
  behaviors: Set<BehaviorConfig>;
2193
2193
  behaviorsSorted: boolean;
2194
2194
  converters: Set<Converter>;
@@ -2222,7 +2222,7 @@ declare const editorMachine: xstate241.StateMachine<{
2222
2222
  readonly 'update readOnly': {
2223
2223
  readonly guard: ({
2224
2224
  event
2225
- }: xstate_guards14.GuardArgs<{
2225
+ }: xstate_guards12.GuardArgs<{
2226
2226
  behaviors: Set<BehaviorConfig>;
2227
2227
  behaviorsSorted: boolean;
2228
2228
  converters: Set<Converter>;
@@ -2255,7 +2255,7 @@ declare const editorMachine: xstate241.StateMachine<{
2255
2255
  };
2256
2256
  readonly focus: {
2257
2257
  readonly target: ".focusing";
2258
- readonly actions: readonly [xstate241.ActionFunction<{
2258
+ readonly actions: readonly [xstate227.ActionFunction<{
2259
2259
  behaviors: Set<BehaviorConfig>;
2260
2260
  behaviorsSorted: boolean;
2261
2261
  converters: Set<Converter>;
@@ -2276,7 +2276,7 @@ declare const editorMachine: xstate241.StateMachine<{
2276
2276
  }, {
2277
2277
  type: "focus";
2278
2278
  editor: PortableTextSlateEditor;
2279
- }, MutationEvent | InternalPatchEvent | PatchesEvent | {
2279
+ }, InternalPatchEvent | MutationEvent | PatchesEvent | {
2280
2280
  type: "update readOnly";
2281
2281
  readOnly: boolean;
2282
2282
  } | {
@@ -2333,7 +2333,7 @@ declare const editorMachine: xstate241.StateMachine<{
2333
2333
  readonly exit: readonly [() => void];
2334
2334
  readonly on: {
2335
2335
  readonly dragstart: {
2336
- readonly actions: readonly [xstate241.ActionFunction<{
2336
+ readonly actions: readonly [xstate227.ActionFunction<{
2337
2337
  behaviors: Set<BehaviorConfig>;
2338
2338
  behaviorsSorted: boolean;
2339
2339
  converters: Set<Converter>;
@@ -2355,7 +2355,7 @@ declare const editorMachine: xstate241.StateMachine<{
2355
2355
  type: "dragstart";
2356
2356
  ghost?: HTMLElement;
2357
2357
  origin: Pick<EventPosition, "selection">;
2358
- }, MutationEvent | InternalPatchEvent | PatchesEvent | {
2358
+ }, InternalPatchEvent | MutationEvent | PatchesEvent | {
2359
2359
  type: "update readOnly";
2360
2360
  readOnly: boolean;
2361
2361
  } | {
@@ -2436,7 +2436,7 @@ declare const editorMachine: xstate241.StateMachine<{
2436
2436
  readonly entry: readonly [() => void];
2437
2437
  readonly exit: readonly [() => void, ({
2438
2438
  context
2439
- }: xstate241.ActionArgs<{
2439
+ }: xstate227.ActionArgs<{
2440
2440
  behaviors: Set<BehaviorConfig>;
2441
2441
  behaviorsSorted: boolean;
2442
2442
  converters: Set<Converter>;
@@ -2454,7 +2454,7 @@ declare const editorMachine: xstate241.StateMachine<{
2454
2454
  };
2455
2455
  dragGhost?: HTMLElement;
2456
2456
  slateEditor?: PortableTextSlateEditor;
2457
- }, MutationEvent | InternalPatchEvent | PatchesEvent | {
2457
+ }, InternalPatchEvent | MutationEvent | PatchesEvent | {
2458
2458
  type: "update readOnly";
2459
2459
  readOnly: boolean;
2460
2460
  } | {
@@ -2501,7 +2501,7 @@ declare const editorMachine: xstate241.StateMachine<{
2501
2501
  type: "dragend";
2502
2502
  } | {
2503
2503
  type: "drop";
2504
- }, MutationEvent | InternalPatchEvent | PatchesEvent | {
2504
+ }, InternalPatchEvent | MutationEvent | PatchesEvent | {
2505
2505
  type: "update readOnly";
2506
2506
  readOnly: boolean;
2507
2507
  } | {
@@ -2548,7 +2548,7 @@ declare const editorMachine: xstate241.StateMachine<{
2548
2548
  type: "dragend";
2549
2549
  } | {
2550
2550
  type: "drop";
2551
- }>) => void, xstate241.ActionFunction<{
2551
+ }>) => void, xstate227.ActionFunction<{
2552
2552
  behaviors: Set<BehaviorConfig>;
2553
2553
  behaviorsSorted: boolean;
2554
2554
  converters: Set<Converter>;
@@ -2566,7 +2566,7 @@ declare const editorMachine: xstate241.StateMachine<{
2566
2566
  };
2567
2567
  dragGhost?: HTMLElement;
2568
2568
  slateEditor?: PortableTextSlateEditor;
2569
- }, MutationEvent | InternalPatchEvent | PatchesEvent | {
2569
+ }, InternalPatchEvent | MutationEvent | PatchesEvent | {
2570
2570
  type: "update readOnly";
2571
2571
  readOnly: boolean;
2572
2572
  } | {
@@ -2613,7 +2613,7 @@ declare const editorMachine: xstate241.StateMachine<{
2613
2613
  type: "dragend";
2614
2614
  } | {
2615
2615
  type: "drop";
2616
- }, MutationEvent | InternalPatchEvent | PatchesEvent | {
2616
+ }, InternalPatchEvent | MutationEvent | PatchesEvent | {
2617
2617
  type: "update readOnly";
2618
2618
  readOnly: boolean;
2619
2619
  } | {
@@ -2660,7 +2660,7 @@ declare const editorMachine: xstate241.StateMachine<{
2660
2660
  type: "dragend";
2661
2661
  } | {
2662
2662
  type: "drop";
2663
- }, undefined, never, never, never, never, never>, xstate241.ActionFunction<{
2663
+ }, undefined, never, never, never, never, never>, xstate227.ActionFunction<{
2664
2664
  behaviors: Set<BehaviorConfig>;
2665
2665
  behaviorsSorted: boolean;
2666
2666
  converters: Set<Converter>;
@@ -2678,7 +2678,7 @@ declare const editorMachine: xstate241.StateMachine<{
2678
2678
  };
2679
2679
  dragGhost?: HTMLElement;
2680
2680
  slateEditor?: PortableTextSlateEditor;
2681
- }, MutationEvent | InternalPatchEvent | PatchesEvent | {
2681
+ }, InternalPatchEvent | MutationEvent | PatchesEvent | {
2682
2682
  type: "update readOnly";
2683
2683
  readOnly: boolean;
2684
2684
  } | {
@@ -2725,7 +2725,7 @@ declare const editorMachine: xstate241.StateMachine<{
2725
2725
  type: "dragend";
2726
2726
  } | {
2727
2727
  type: "drop";
2728
- }, MutationEvent | InternalPatchEvent | PatchesEvent | {
2728
+ }, InternalPatchEvent | MutationEvent | PatchesEvent | {
2729
2729
  type: "update readOnly";
2730
2730
  readOnly: boolean;
2731
2731
  } | {
@@ -2819,7 +2819,7 @@ declare const editorMachine: xstate241.StateMachine<{
2819
2819
  readonly exit: readonly [() => void];
2820
2820
  readonly on: {
2821
2821
  readonly patches: {
2822
- readonly actions: readonly [xstate241.ActionFunction<{
2822
+ readonly actions: readonly [xstate227.ActionFunction<{
2823
2823
  behaviors: Set<BehaviorConfig>;
2824
2824
  behaviorsSorted: boolean;
2825
2825
  converters: Set<Converter>;
@@ -2837,7 +2837,7 @@ declare const editorMachine: xstate241.StateMachine<{
2837
2837
  };
2838
2838
  dragGhost?: HTMLElement;
2839
2839
  slateEditor?: PortableTextSlateEditor;
2840
- }, PatchesEvent, MutationEvent | InternalPatchEvent | PatchesEvent | {
2840
+ }, PatchesEvent, InternalPatchEvent | MutationEvent | PatchesEvent | {
2841
2841
  type: "update readOnly";
2842
2842
  readOnly: boolean;
2843
2843
  } | {
@@ -2884,7 +2884,7 @@ declare const editorMachine: xstate241.StateMachine<{
2884
2884
  type: "dragend";
2885
2885
  } | {
2886
2886
  type: "drop";
2887
- }, undefined, never, never, never, never, {
2887
+ }, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
2888
2888
  type: "blurred";
2889
2889
  event: react22.FocusEvent<HTMLDivElement, Element>;
2890
2890
  } | {
@@ -2905,7 +2905,7 @@ declare const editorMachine: xstate241.StateMachine<{
2905
2905
  value: Array<PortableTextBlock> | undefined;
2906
2906
  } | {
2907
2907
  type: "loading";
2908
- } | MutationEvent | {
2908
+ } | {
2909
2909
  type: "read only";
2910
2910
  } | {
2911
2911
  type: "ready";
@@ -2915,7 +2915,7 @@ declare const editorMachine: xstate241.StateMachine<{
2915
2915
  } | {
2916
2916
  type: "value changed";
2917
2917
  value: Array<PortableTextBlock> | undefined;
2918
- } | InternalPatchEvent | PatchesEvent>];
2918
+ }>];
2919
2919
  };
2920
2920
  readonly 'syncing value': {
2921
2921
  readonly target: "syncing value";
@@ -3621,7 +3621,7 @@ type BehaviorAction = {
3621
3621
  * })
3622
3622
  * ```
3623
3623
  */
3624
- send: (event: SyntheticBehaviorEvent | CustomBehaviorEvent) => void;
3624
+ send: (event: ExternalBehaviorEvent) => void;
3625
3625
  }) => void;
3626
3626
  };
3627
3627
  /**
@@ -1,7 +1,7 @@
1
1
  import { Patch, Patch as Patch$1 } from "@portabletext/patches";
2
2
  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
- import * as _portabletext_schema5 from "@portabletext/schema";
4
+ import * as _portabletext_schema6 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
6
  import * as xstate227 from "xstate";
7
7
  import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
@@ -1780,7 +1780,7 @@ declare const editorMachine: xstate227.StateMachine<{
1780
1780
  keyGenerator: () => string;
1781
1781
  pendingEvents: never[];
1782
1782
  pendingIncomingPatchesEvents: never[];
1783
- schema: _portabletext_schema5.Schema;
1783
+ schema: _portabletext_schema6.Schema;
1784
1784
  selection: null;
1785
1785
  initialReadOnly: boolean;
1786
1786
  maxBlocks: number | undefined;
@@ -3621,7 +3621,7 @@ type BehaviorAction = {
3621
3621
  * })
3622
3622
  * ```
3623
3623
  */
3624
- send: (event: SyntheticBehaviorEvent | CustomBehaviorEvent) => void;
3624
+ send: (event: ExternalBehaviorEvent) => void;
3625
3625
  }) => void;
3626
3626
  };
3627
3627
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/behaviors/behavior.types.action.ts","../../src/behaviors/behavior.types.behavior.ts"],"sourcesContent":["import type {EditorDom} from '../editor/editor-dom'\nimport type {EditorSnapshot} from '../editor/editor-snapshot'\nimport type {PickFromUnion} from '../type-utils'\nimport type {\n CustomBehaviorEvent,\n NativeBehaviorEvent,\n SyntheticBehaviorEvent,\n} from './behavior.types.event'\n\n/**\n * @beta\n */\nexport type BehaviorAction =\n | {\n type: 'execute'\n event: SyntheticBehaviorEvent\n }\n | {\n type: 'forward'\n event: NativeBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent\n }\n | {\n type: 'raise'\n event: SyntheticBehaviorEvent | CustomBehaviorEvent\n }\n | {\n type: 'effect'\n effect: (payload: {\n /**\n * Send a Behavior Event back into the Editor.\n *\n * @example\n * ```ts\n * defineBehavior({\n * on: '...',\n * actions: [\n * () => [\n * effect(({send}) => {\n * doSomethingAsync()\n * .then(() => {\n * send({\n * type: '...',\n * })\n * })\n * })\n * ],\n * ],\n * })\n * ```\n */\n send: (event: SyntheticBehaviorEvent | CustomBehaviorEvent) => void\n }) => void\n }\n\n/**\n * @beta\n */\nexport function execute(\n event: SyntheticBehaviorEvent,\n): PickFromUnion<BehaviorAction, 'type', 'execute'> {\n return {type: 'execute', event}\n}\n\n/**\n * @beta\n */\nexport function forward(\n event: NativeBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent,\n): PickFromUnion<BehaviorAction, 'type', 'forward'> {\n return {type: 'forward', event}\n}\n\n/**\n * @beta\n */\nexport function raise(\n event: SyntheticBehaviorEvent | CustomBehaviorEvent,\n): PickFromUnion<BehaviorAction, 'type', 'raise'> {\n return {type: 'raise', event}\n}\n\n/**\n * @beta\n */\nexport function effect(\n effect: PickFromUnion<BehaviorAction, 'type', 'effect'>['effect'],\n): PickFromUnion<BehaviorAction, 'type', 'effect'> {\n return {type: 'effect', effect}\n}\n\n/**\n * @beta\n */\nexport type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (\n payload: {\n snapshot: EditorSnapshot\n event: TBehaviorEvent\n dom: EditorDom\n },\n guardResponse: TGuardResponse,\n) => Array<BehaviorAction>\n","import type {BehaviorActionSet} from './behavior.types.action'\nimport type {\n BehaviorEvent,\n BehaviorEventTypeNamespace,\n CustomBehaviorEvent,\n ResolveBehaviorEvent,\n} from './behavior.types.event'\nimport type {BehaviorGuard} from './behavior.types.guard'\n\n/**\n * @beta\n */\nexport type Behavior<\n TBehaviorEventType extends\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'] =\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'],\n TGuardResponse = true,\n TBehaviorEvent extends\n ResolveBehaviorEvent<TBehaviorEventType> = ResolveBehaviorEvent<TBehaviorEventType>,\n> = {\n /**\n * Editor Event that triggers this Behavior.\n */\n on: TBehaviorEventType\n /**\n * Predicate function that determines if the Behavior should be executed.\n * Returning a non-nullable value from the guard will pass the value to the\n * actions and execute them.\n */\n guard?: BehaviorGuard<TBehaviorEvent, TGuardResponse>\n /**\n * Array of Behavior Action sets.\n * Each set represents a step in the history stack.\n */\n actions: Array<BehaviorActionSet<TBehaviorEvent, TGuardResponse>>\n}\n\n/**\n * @beta\n *\n * @example\n *\n * ```tsx\n * const noLowerCaseA = defineBehavior({\n * on: 'insert.text',\n * guard: ({event, snapshot}) => event.text === 'a',\n * actions: [({event, snapshot}) => [{type: 'insert.text', text: 'A'}]],\n * })\n * ```\n *\n */\nexport function defineBehavior<\n TPayload extends Record<string, unknown>,\n TBehaviorEventType extends\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'] = CustomBehaviorEvent['type'],\n TGuardResponse = true,\n>(\n behavior: Behavior<\n TBehaviorEventType,\n TGuardResponse,\n ResolveBehaviorEvent<TBehaviorEventType, TPayload>\n >,\n): Behavior\nexport function defineBehavior<\n TPayload extends never = never,\n TBehaviorEventType extends\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'] = BehaviorEvent['type'],\n TGuardResponse = true,\n TBehaviorEvent extends ResolveBehaviorEvent<\n TBehaviorEventType,\n TPayload\n > = ResolveBehaviorEvent<TBehaviorEventType, TPayload>,\n>(\n behavior: Behavior<TBehaviorEventType, TGuardResponse, TBehaviorEvent>,\n): Behavior {\n return behavior as unknown as Behavior\n}\n"],"names":["execute","event","type","forward","raise","effect","defineBehavior","behavior"],"mappings":";;AAyDO,SAASA,QACdC,OACkD;AAClD,SAAO;AAAA,IAACC,MAAM;AAAA,IAAWD;AAAAA,EAAAA;AAC3B;AAKO,SAASE,QACdF,OACkD;AAClD,SAAO;AAAA,IAACC,MAAM;AAAA,IAAWD;AAAAA,EAAAA;AAC3B;AAKO,SAASG,MACdH,OACgD;AAChD,SAAO;AAAA,IAACC,MAAM;AAAA,IAASD;AAAAA,EAAAA;AACzB;AAKO,SAASI,OACdA,SACiD;AACjD,SAAO;AAAA,IAACH,MAAM;AAAA,IAAUG,QAAAA;AAAAA,EAAAA;AAC1B;ACnBO,SAASC,eAYdC,UACU;AACV,SAAOA;AACT;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/behaviors/behavior.types.action.ts","../../src/behaviors/behavior.types.behavior.ts"],"sourcesContent":["import type {EditorDom} from '../editor/editor-dom'\nimport type {EditorSnapshot} from '../editor/editor-snapshot'\nimport type {PickFromUnion} from '../type-utils'\nimport type {\n CustomBehaviorEvent,\n ExternalBehaviorEvent,\n NativeBehaviorEvent,\n SyntheticBehaviorEvent,\n} from './behavior.types.event'\n\n/**\n * @beta\n */\nexport type BehaviorAction =\n | {\n type: 'execute'\n event: SyntheticBehaviorEvent\n }\n | {\n type: 'forward'\n event: NativeBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent\n }\n | {\n type: 'raise'\n event: SyntheticBehaviorEvent | CustomBehaviorEvent\n }\n | {\n type: 'effect'\n effect: (payload: {\n /**\n * Send a Behavior Event back into the Editor.\n *\n * @example\n * ```ts\n * defineBehavior({\n * on: '...',\n * actions: [\n * () => [\n * effect(({send}) => {\n * doSomethingAsync()\n * .then(() => {\n * send({\n * type: '...',\n * })\n * })\n * })\n * ],\n * ],\n * })\n * ```\n */\n send: (event: ExternalBehaviorEvent) => void\n }) => void\n }\n\n/**\n * @beta\n */\nexport function execute(\n event: SyntheticBehaviorEvent,\n): PickFromUnion<BehaviorAction, 'type', 'execute'> {\n return {type: 'execute', event}\n}\n\n/**\n * @beta\n */\nexport function forward(\n event: NativeBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent,\n): PickFromUnion<BehaviorAction, 'type', 'forward'> {\n return {type: 'forward', event}\n}\n\n/**\n * @beta\n */\nexport function raise(\n event: SyntheticBehaviorEvent | CustomBehaviorEvent,\n): PickFromUnion<BehaviorAction, 'type', 'raise'> {\n return {type: 'raise', event}\n}\n\n/**\n * @beta\n */\nexport function effect(\n effect: PickFromUnion<BehaviorAction, 'type', 'effect'>['effect'],\n): PickFromUnion<BehaviorAction, 'type', 'effect'> {\n return {type: 'effect', effect}\n}\n\n/**\n * @beta\n */\nexport type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (\n payload: {\n snapshot: EditorSnapshot\n event: TBehaviorEvent\n dom: EditorDom\n },\n guardResponse: TGuardResponse,\n) => Array<BehaviorAction>\n","import type {BehaviorActionSet} from './behavior.types.action'\nimport type {\n BehaviorEvent,\n BehaviorEventTypeNamespace,\n CustomBehaviorEvent,\n ResolveBehaviorEvent,\n} from './behavior.types.event'\nimport type {BehaviorGuard} from './behavior.types.guard'\n\n/**\n * @beta\n */\nexport type Behavior<\n TBehaviorEventType extends\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'] =\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'],\n TGuardResponse = true,\n TBehaviorEvent extends\n ResolveBehaviorEvent<TBehaviorEventType> = ResolveBehaviorEvent<TBehaviorEventType>,\n> = {\n /**\n * Editor Event that triggers this Behavior.\n */\n on: TBehaviorEventType\n /**\n * Predicate function that determines if the Behavior should be executed.\n * Returning a non-nullable value from the guard will pass the value to the\n * actions and execute them.\n */\n guard?: BehaviorGuard<TBehaviorEvent, TGuardResponse>\n /**\n * Array of Behavior Action sets.\n * Each set represents a step in the history stack.\n */\n actions: Array<BehaviorActionSet<TBehaviorEvent, TGuardResponse>>\n}\n\n/**\n * @beta\n *\n * @example\n *\n * ```tsx\n * const noLowerCaseA = defineBehavior({\n * on: 'insert.text',\n * guard: ({event, snapshot}) => event.text === 'a',\n * actions: [({event, snapshot}) => [{type: 'insert.text', text: 'A'}]],\n * })\n * ```\n *\n */\nexport function defineBehavior<\n TPayload extends Record<string, unknown>,\n TBehaviorEventType extends\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'] = CustomBehaviorEvent['type'],\n TGuardResponse = true,\n>(\n behavior: Behavior<\n TBehaviorEventType,\n TGuardResponse,\n ResolveBehaviorEvent<TBehaviorEventType, TPayload>\n >,\n): Behavior\nexport function defineBehavior<\n TPayload extends never = never,\n TBehaviorEventType extends\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'] = BehaviorEvent['type'],\n TGuardResponse = true,\n TBehaviorEvent extends ResolveBehaviorEvent<\n TBehaviorEventType,\n TPayload\n > = ResolveBehaviorEvent<TBehaviorEventType, TPayload>,\n>(\n behavior: Behavior<TBehaviorEventType, TGuardResponse, TBehaviorEvent>,\n): Behavior {\n return behavior as unknown as Behavior\n}\n"],"names":["execute","event","type","forward","raise","effect","defineBehavior","behavior"],"mappings":";;AA0DO,SAASA,QACdC,OACkD;AAClD,SAAO;AAAA,IAACC,MAAM;AAAA,IAAWD;AAAAA,EAAAA;AAC3B;AAKO,SAASE,QACdF,OACkD;AAClD,SAAO;AAAA,IAACC,MAAM;AAAA,IAAWD;AAAAA,EAAAA;AAC3B;AAKO,SAASG,MACdH,OACgD;AAChD,SAAO;AAAA,IAACC,MAAM;AAAA,IAASD;AAAAA,EAAAA;AACzB;AAKO,SAASI,OACdA,SACiD;AACjD,SAAO;AAAA,IAACH,MAAM;AAAA,IAAUG,QAAAA;AAAAA,EAAAA;AAC1B;ACpBO,SAASC,eAYdC,UACU;AACV,SAAOA;AACT;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/behaviors/behavior.types.action.ts","../../src/behaviors/behavior.types.behavior.ts"],"sourcesContent":["import type {EditorDom} from '../editor/editor-dom'\nimport type {EditorSnapshot} from '../editor/editor-snapshot'\nimport type {PickFromUnion} from '../type-utils'\nimport type {\n CustomBehaviorEvent,\n NativeBehaviorEvent,\n SyntheticBehaviorEvent,\n} from './behavior.types.event'\n\n/**\n * @beta\n */\nexport type BehaviorAction =\n | {\n type: 'execute'\n event: SyntheticBehaviorEvent\n }\n | {\n type: 'forward'\n event: NativeBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent\n }\n | {\n type: 'raise'\n event: SyntheticBehaviorEvent | CustomBehaviorEvent\n }\n | {\n type: 'effect'\n effect: (payload: {\n /**\n * Send a Behavior Event back into the Editor.\n *\n * @example\n * ```ts\n * defineBehavior({\n * on: '...',\n * actions: [\n * () => [\n * effect(({send}) => {\n * doSomethingAsync()\n * .then(() => {\n * send({\n * type: '...',\n * })\n * })\n * })\n * ],\n * ],\n * })\n * ```\n */\n send: (event: SyntheticBehaviorEvent | CustomBehaviorEvent) => void\n }) => void\n }\n\n/**\n * @beta\n */\nexport function execute(\n event: SyntheticBehaviorEvent,\n): PickFromUnion<BehaviorAction, 'type', 'execute'> {\n return {type: 'execute', event}\n}\n\n/**\n * @beta\n */\nexport function forward(\n event: NativeBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent,\n): PickFromUnion<BehaviorAction, 'type', 'forward'> {\n return {type: 'forward', event}\n}\n\n/**\n * @beta\n */\nexport function raise(\n event: SyntheticBehaviorEvent | CustomBehaviorEvent,\n): PickFromUnion<BehaviorAction, 'type', 'raise'> {\n return {type: 'raise', event}\n}\n\n/**\n * @beta\n */\nexport function effect(\n effect: PickFromUnion<BehaviorAction, 'type', 'effect'>['effect'],\n): PickFromUnion<BehaviorAction, 'type', 'effect'> {\n return {type: 'effect', effect}\n}\n\n/**\n * @beta\n */\nexport type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (\n payload: {\n snapshot: EditorSnapshot\n event: TBehaviorEvent\n dom: EditorDom\n },\n guardResponse: TGuardResponse,\n) => Array<BehaviorAction>\n","import type {BehaviorActionSet} from './behavior.types.action'\nimport type {\n BehaviorEvent,\n BehaviorEventTypeNamespace,\n CustomBehaviorEvent,\n ResolveBehaviorEvent,\n} from './behavior.types.event'\nimport type {BehaviorGuard} from './behavior.types.guard'\n\n/**\n * @beta\n */\nexport type Behavior<\n TBehaviorEventType extends\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'] =\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'],\n TGuardResponse = true,\n TBehaviorEvent extends\n ResolveBehaviorEvent<TBehaviorEventType> = ResolveBehaviorEvent<TBehaviorEventType>,\n> = {\n /**\n * Editor Event that triggers this Behavior.\n */\n on: TBehaviorEventType\n /**\n * Predicate function that determines if the Behavior should be executed.\n * Returning a non-nullable value from the guard will pass the value to the\n * actions and execute them.\n */\n guard?: BehaviorGuard<TBehaviorEvent, TGuardResponse>\n /**\n * Array of Behavior Action sets.\n * Each set represents a step in the history stack.\n */\n actions: Array<BehaviorActionSet<TBehaviorEvent, TGuardResponse>>\n}\n\n/**\n * @beta\n *\n * @example\n *\n * ```tsx\n * const noLowerCaseA = defineBehavior({\n * on: 'insert.text',\n * guard: ({event, snapshot}) => event.text === 'a',\n * actions: [({event, snapshot}) => [{type: 'insert.text', text: 'A'}]],\n * })\n * ```\n *\n */\nexport function defineBehavior<\n TPayload extends Record<string, unknown>,\n TBehaviorEventType extends\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'] = CustomBehaviorEvent['type'],\n TGuardResponse = true,\n>(\n behavior: Behavior<\n TBehaviorEventType,\n TGuardResponse,\n ResolveBehaviorEvent<TBehaviorEventType, TPayload>\n >,\n): Behavior\nexport function defineBehavior<\n TPayload extends never = never,\n TBehaviorEventType extends\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'] = BehaviorEvent['type'],\n TGuardResponse = true,\n TBehaviorEvent extends ResolveBehaviorEvent<\n TBehaviorEventType,\n TPayload\n > = ResolveBehaviorEvent<TBehaviorEventType, TPayload>,\n>(\n behavior: Behavior<TBehaviorEventType, TGuardResponse, TBehaviorEvent>,\n): Behavior {\n return behavior as unknown as Behavior\n}\n"],"names":["execute","event","type","forward","raise","effect","defineBehavior","behavior"],"mappings":"AAyDO,SAASA,QACdC,OACkD;AAClD,SAAO;AAAA,IAACC,MAAM;AAAA,IAAWD;AAAAA,EAAAA;AAC3B;AAKO,SAASE,QACdF,OACkD;AAClD,SAAO;AAAA,IAACC,MAAM;AAAA,IAAWD;AAAAA,EAAAA;AAC3B;AAKO,SAASG,MACdH,OACgD;AAChD,SAAO;AAAA,IAACC,MAAM;AAAA,IAASD;AAAAA,EAAAA;AACzB;AAKO,SAASI,OACdA,SACiD;AACjD,SAAO;AAAA,IAACH,MAAM;AAAA,IAAUG,QAAAA;AAAAA,EAAAA;AAC1B;ACnBO,SAASC,eAYdC,UACU;AACV,SAAOA;AACT;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/behaviors/behavior.types.action.ts","../../src/behaviors/behavior.types.behavior.ts"],"sourcesContent":["import type {EditorDom} from '../editor/editor-dom'\nimport type {EditorSnapshot} from '../editor/editor-snapshot'\nimport type {PickFromUnion} from '../type-utils'\nimport type {\n CustomBehaviorEvent,\n ExternalBehaviorEvent,\n NativeBehaviorEvent,\n SyntheticBehaviorEvent,\n} from './behavior.types.event'\n\n/**\n * @beta\n */\nexport type BehaviorAction =\n | {\n type: 'execute'\n event: SyntheticBehaviorEvent\n }\n | {\n type: 'forward'\n event: NativeBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent\n }\n | {\n type: 'raise'\n event: SyntheticBehaviorEvent | CustomBehaviorEvent\n }\n | {\n type: 'effect'\n effect: (payload: {\n /**\n * Send a Behavior Event back into the Editor.\n *\n * @example\n * ```ts\n * defineBehavior({\n * on: '...',\n * actions: [\n * () => [\n * effect(({send}) => {\n * doSomethingAsync()\n * .then(() => {\n * send({\n * type: '...',\n * })\n * })\n * })\n * ],\n * ],\n * })\n * ```\n */\n send: (event: ExternalBehaviorEvent) => void\n }) => void\n }\n\n/**\n * @beta\n */\nexport function execute(\n event: SyntheticBehaviorEvent,\n): PickFromUnion<BehaviorAction, 'type', 'execute'> {\n return {type: 'execute', event}\n}\n\n/**\n * @beta\n */\nexport function forward(\n event: NativeBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent,\n): PickFromUnion<BehaviorAction, 'type', 'forward'> {\n return {type: 'forward', event}\n}\n\n/**\n * @beta\n */\nexport function raise(\n event: SyntheticBehaviorEvent | CustomBehaviorEvent,\n): PickFromUnion<BehaviorAction, 'type', 'raise'> {\n return {type: 'raise', event}\n}\n\n/**\n * @beta\n */\nexport function effect(\n effect: PickFromUnion<BehaviorAction, 'type', 'effect'>['effect'],\n): PickFromUnion<BehaviorAction, 'type', 'effect'> {\n return {type: 'effect', effect}\n}\n\n/**\n * @beta\n */\nexport type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (\n payload: {\n snapshot: EditorSnapshot\n event: TBehaviorEvent\n dom: EditorDom\n },\n guardResponse: TGuardResponse,\n) => Array<BehaviorAction>\n","import type {BehaviorActionSet} from './behavior.types.action'\nimport type {\n BehaviorEvent,\n BehaviorEventTypeNamespace,\n CustomBehaviorEvent,\n ResolveBehaviorEvent,\n} from './behavior.types.event'\nimport type {BehaviorGuard} from './behavior.types.guard'\n\n/**\n * @beta\n */\nexport type Behavior<\n TBehaviorEventType extends\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'] =\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'],\n TGuardResponse = true,\n TBehaviorEvent extends\n ResolveBehaviorEvent<TBehaviorEventType> = ResolveBehaviorEvent<TBehaviorEventType>,\n> = {\n /**\n * Editor Event that triggers this Behavior.\n */\n on: TBehaviorEventType\n /**\n * Predicate function that determines if the Behavior should be executed.\n * Returning a non-nullable value from the guard will pass the value to the\n * actions and execute them.\n */\n guard?: BehaviorGuard<TBehaviorEvent, TGuardResponse>\n /**\n * Array of Behavior Action sets.\n * Each set represents a step in the history stack.\n */\n actions: Array<BehaviorActionSet<TBehaviorEvent, TGuardResponse>>\n}\n\n/**\n * @beta\n *\n * @example\n *\n * ```tsx\n * const noLowerCaseA = defineBehavior({\n * on: 'insert.text',\n * guard: ({event, snapshot}) => event.text === 'a',\n * actions: [({event, snapshot}) => [{type: 'insert.text', text: 'A'}]],\n * })\n * ```\n *\n */\nexport function defineBehavior<\n TPayload extends Record<string, unknown>,\n TBehaviorEventType extends\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'] = CustomBehaviorEvent['type'],\n TGuardResponse = true,\n>(\n behavior: Behavior<\n TBehaviorEventType,\n TGuardResponse,\n ResolveBehaviorEvent<TBehaviorEventType, TPayload>\n >,\n): Behavior\nexport function defineBehavior<\n TPayload extends never = never,\n TBehaviorEventType extends\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'] = BehaviorEvent['type'],\n TGuardResponse = true,\n TBehaviorEvent extends ResolveBehaviorEvent<\n TBehaviorEventType,\n TPayload\n > = ResolveBehaviorEvent<TBehaviorEventType, TPayload>,\n>(\n behavior: Behavior<TBehaviorEventType, TGuardResponse, TBehaviorEvent>,\n): Behavior {\n return behavior as unknown as Behavior\n}\n"],"names":["execute","event","type","forward","raise","effect","defineBehavior","behavior"],"mappings":"AA0DO,SAASA,QACdC,OACkD;AAClD,SAAO;AAAA,IAACC,MAAM;AAAA,IAAWD;AAAAA,EAAAA;AAC3B;AAKO,SAASE,QACdF,OACkD;AAClD,SAAO;AAAA,IAACC,MAAM;AAAA,IAAWD;AAAAA,EAAAA;AAC3B;AAKO,SAASG,MACdH,OACgD;AAChD,SAAO;AAAA,IAACC,MAAM;AAAA,IAASD;AAAAA,EAAAA;AACzB;AAKO,SAASI,OACdA,SACiD;AACjD,SAAO;AAAA,IAACH,MAAM;AAAA,IAAUG,QAAAA;AAAAA,EAAAA;AAC1B;ACpBO,SAASC,eAYdC,UACU;AACV,SAAOA;AACT;"}