@portabletext/editor 1.48.13 → 1.48.15

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.
Files changed (78) hide show
  1. package/lib/_chunks-cjs/editor-provider.cjs +682 -609
  2. package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
  3. package/lib/_chunks-es/editor-provider.js +683 -610
  4. package/lib/_chunks-es/editor-provider.js.map +1 -1
  5. package/lib/behaviors/index.cjs.map +1 -1
  6. package/lib/behaviors/index.d.cts +226 -2772
  7. package/lib/behaviors/index.d.ts +226 -2772
  8. package/lib/behaviors/index.js.map +1 -1
  9. package/lib/index.cjs +22 -6
  10. package/lib/index.cjs.map +1 -1
  11. package/lib/index.d.cts +227 -2780
  12. package/lib/index.d.ts +227 -2780
  13. package/lib/index.js +23 -7
  14. package/lib/index.js.map +1 -1
  15. package/lib/plugins/index.cjs +1 -7
  16. package/lib/plugins/index.cjs.map +1 -1
  17. package/lib/plugins/index.d.cts +226 -2785
  18. package/lib/plugins/index.d.ts +226 -2785
  19. package/lib/plugins/index.js +2 -8
  20. package/lib/plugins/index.js.map +1 -1
  21. package/lib/selectors/index.d.cts +225 -2771
  22. package/lib/selectors/index.d.ts +225 -2771
  23. package/lib/utils/index.d.cts +227 -2772
  24. package/lib/utils/index.d.ts +227 -2772
  25. package/package.json +1 -1
  26. package/src/behaviors/behavior.abstract.keyboard.ts +16 -0
  27. package/src/behaviors/{behavior.default.ts → behavior.abstract.ts} +3 -3
  28. package/src/behaviors/behavior.config.ts +7 -0
  29. package/src/behaviors/behavior.core.ts +6 -5
  30. package/src/behaviors/behavior.perform-event.ts +27 -51
  31. package/src/behaviors/behavior.types.action.ts +1 -11
  32. package/src/editor/PortableTextEditor.tsx +1 -1
  33. package/src/editor/components/Element.tsx +30 -4
  34. package/src/editor/create-editor.ts +17 -5
  35. package/src/editor/editor-machine.ts +23 -17
  36. package/src/editor/mutation-machine.ts +6 -6
  37. package/src/editor/plugins/create-with-event-listeners.ts +25 -25
  38. package/src/editor/plugins/createWithEditableAPI.ts +3 -3
  39. package/src/editor/plugins/createWithPatches.ts +13 -5
  40. package/src/editor/plugins/createWithPortableTextMarkModel.ts +5 -5
  41. package/src/editor/plugins/createWithUndoRedo.ts +8 -8
  42. package/src/editor/with-applying-behavior-operations.ts +18 -0
  43. package/src/editor/{with-applying-behavior-actions.ts → with-undo-step.ts} +1 -19
  44. package/src/index.ts +1 -1
  45. package/src/{behavior-actions/behavior.action.annotation.add.ts → operations/behavior.operation.annotation.add.ts} +7 -7
  46. package/src/{behavior-actions/behavior.action.annotation.remove.ts → operations/behavior.operation.annotation.remove.ts} +6 -6
  47. package/src/{behavior-actions/behavior.action.block.set.ts → operations/behavior.operation.block.set.ts} +14 -14
  48. package/src/{behavior-actions/behavior.action.block.unset.ts → operations/behavior.operation.block.unset.ts} +19 -17
  49. package/src/{behavior-actions/behavior.action.decorator.add.ts → operations/behavior.operation.decorator.add.ts} +10 -10
  50. package/src/operations/behavior.operation.delete.backward.ts +8 -0
  51. package/src/operations/behavior.operation.delete.block.ts +24 -0
  52. package/src/operations/behavior.operation.delete.forward.ts +8 -0
  53. package/src/{behavior-actions/behavior.action.delete.ts → operations/behavior.operation.delete.ts} +8 -8
  54. package/src/{behavior-actions/behavior.action.insert-inline-object.ts → operations/behavior.operation.insert-inline-object.ts} +11 -11
  55. package/src/{behavior-actions/behavior.action.insert-span.ts → operations/behavior.operation.insert-span.ts} +15 -15
  56. package/src/{behavior-actions/behavior.action.insert.block.ts → operations/behavior.operation.insert.block.ts} +8 -8
  57. package/src/operations/behavior.operation.insert.text.ts +17 -0
  58. package/src/operations/behavior.operation.move.backward.ts +12 -0
  59. package/src/operations/behavior.operation.move.block.ts +16 -0
  60. package/src/operations/behavior.operation.move.forward.ts +11 -0
  61. package/src/operations/behavior.operation.select.ts +15 -0
  62. package/src/operations/behavior.operations.ts +239 -0
  63. package/src/plugins/index.ts +0 -1
  64. package/src/priority/priority.core.ts +3 -0
  65. package/src/priority/priority.sort.test.ts +319 -0
  66. package/src/priority/priority.sort.ts +121 -0
  67. package/src/priority/priority.types.ts +24 -0
  68. package/src/behavior-actions/behavior.action.delete.backward.ts +0 -7
  69. package/src/behavior-actions/behavior.action.delete.block.ts +0 -24
  70. package/src/behavior-actions/behavior.action.delete.forward.ts +0 -7
  71. package/src/behavior-actions/behavior.action.insert.text.ts +0 -17
  72. package/src/behavior-actions/behavior.action.move.backward.ts +0 -12
  73. package/src/behavior-actions/behavior.action.move.block.ts +0 -16
  74. package/src/behavior-actions/behavior.action.move.forward.ts +0 -11
  75. package/src/behavior-actions/behavior.action.select.ts +0 -15
  76. package/src/behavior-actions/behavior.actions.ts +0 -219
  77. package/src/behaviors/behavior.default.raise-soft-break.ts +0 -14
  78. package/src/plugins/plugin.core.tsx +0 -9
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { c } from "react-compiler-runtime";
2
2
  import { useEffect, useContext, useRef, useState, useMemo, startTransition, useCallback, forwardRef, useImperativeHandle } from "react";
3
3
  import { useEffectEvent } from "use-effect-event";
4
- import { useEditor, getNodeBlock, getFirstBlock, getLastBlock, slateRangeToSelection, toSlateRange, debugWithName, EditorActorContext, fromSlateValue, KEY_TO_VALUE_ELEMENT, usePortableTextEditor, PortableTextEditor, isHotkey, moveRangeByOperation, isEqualToEmptyEditor, getEditorSnapshot } from "./_chunks-es/editor-provider.js";
4
+ import { useEditor, getNodeBlock, getFirstBlock, getLastBlock, slateRangeToSelection, toSlateRange, debugWithName, EditorActorContext, createEditorPriority, corePriority, fromSlateValue, KEY_TO_VALUE_ELEMENT, usePortableTextEditor, PortableTextEditor, isHotkey, moveRangeByOperation, isEqualToEmptyEditor, getEditorSnapshot } from "./_chunks-es/editor-provider.js";
5
5
  import { EditorProvider, defineSchema, defaultKeyGenerator, useEditorSelector, usePortableTextEditorSelection } from "./_chunks-es/editor-provider.js";
6
6
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
7
7
  import { useSelector, useActorRef } from "@xstate/react";
@@ -436,14 +436,22 @@ const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
436
436
  setDragPositionBlock(event_0.position.block);
437
437
  }
438
438
  }]]
439
- });
439
+ }), priority = createEditorPriority({
440
+ reference: {
441
+ priority: corePriority,
442
+ importance: "lower"
443
+ }
444
+ }), behaviorConfig = {
445
+ behavior,
446
+ priority
447
+ };
440
448
  return editorActor.send({
441
449
  type: "add behavior",
442
- behavior
450
+ behaviorConfig
443
451
  }), () => {
444
452
  editorActor.send({
445
453
  type: "remove behavior",
446
- behavior
454
+ behaviorConfig
447
455
  });
448
456
  };
449
457
  }, [editorActor, element._key]), useEffect(() => {
@@ -460,14 +468,22 @@ const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
460
468
  setDragPositionBlock(void 0);
461
469
  }
462
470
  }, forward(event_2)]]
463
- });
471
+ }), priority_0 = createEditorPriority({
472
+ reference: {
473
+ priority: corePriority,
474
+ importance: "lower"
475
+ }
476
+ }), behaviorConfig_0 = {
477
+ behavior: behavior_0,
478
+ priority: priority_0
479
+ };
464
480
  return editorActor.send({
465
481
  type: "add behavior",
466
- behavior: behavior_0
482
+ behaviorConfig: behaviorConfig_0
467
483
  }), () => {
468
484
  editorActor.send({
469
485
  type: "remove behavior",
470
- behavior: behavior_0
486
+ behaviorConfig: behaviorConfig_0
471
487
  });
472
488
  };
473
489
  }, [editorActor]);