@portabletext/editor 1.55.13 → 1.55.14

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 (74) hide show
  1. package/lib/_chunks-cjs/{selector.is-selection-expanded.cjs → selector.get-focus-span.cjs} +27 -27
  2. package/lib/_chunks-cjs/selector.get-focus-span.cjs.map +1 -0
  3. package/lib/_chunks-cjs/selector.get-text-before.cjs +3 -3
  4. package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
  5. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +291 -168
  6. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
  7. package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs +1 -1
  8. package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs.map +1 -1
  9. package/lib/_chunks-cjs/{util.is-equal-selection-points.cjs → util.is-selection-collapsed.cjs} +7 -3
  10. package/lib/_chunks-cjs/util.is-selection-collapsed.cjs.map +1 -0
  11. package/lib/_chunks-cjs/util.slice-blocks.cjs +2 -2
  12. package/lib/_chunks-cjs/util.slice-text-block.cjs +2 -6
  13. package/lib/_chunks-cjs/util.slice-text-block.cjs.map +1 -1
  14. package/lib/_chunks-es/{selector.is-selection-expanded.js → selector.get-focus-span.js} +27 -27
  15. package/lib/_chunks-es/selector.get-focus-span.js.map +1 -0
  16. package/lib/_chunks-es/selector.get-text-before.js +1 -1
  17. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +266 -143
  18. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
  19. package/lib/_chunks-es/util.child-selection-point-to-block-offset.js +1 -1
  20. package/lib/_chunks-es/{util.is-equal-selection-points.js → util.is-selection-collapsed.js} +7 -3
  21. package/lib/_chunks-es/util.is-selection-collapsed.js.map +1 -0
  22. package/lib/_chunks-es/util.slice-blocks.js +2 -2
  23. package/lib/_chunks-es/util.slice-text-block.js +1 -5
  24. package/lib/_chunks-es/util.slice-text-block.js.map +1 -1
  25. package/lib/behaviors/index.d.cts +3 -6
  26. package/lib/behaviors/index.d.ts +3 -6
  27. package/lib/index.cjs +110 -239
  28. package/lib/index.cjs.map +1 -1
  29. package/lib/index.d.cts +11 -20
  30. package/lib/index.d.ts +11 -20
  31. package/lib/index.js +49 -178
  32. package/lib/index.js.map +1 -1
  33. package/lib/plugins/index.cjs +16 -16
  34. package/lib/plugins/index.cjs.map +1 -1
  35. package/lib/plugins/index.d.cts +3 -6
  36. package/lib/plugins/index.d.ts +3 -6
  37. package/lib/plugins/index.js +1 -1
  38. package/lib/selectors/index.cjs +14 -14
  39. package/lib/selectors/index.cjs.map +1 -1
  40. package/lib/selectors/index.d.cts +3 -6
  41. package/lib/selectors/index.d.ts +3 -6
  42. package/lib/selectors/index.js +2 -2
  43. package/lib/utils/index.cjs +9 -9
  44. package/lib/utils/index.cjs.map +1 -1
  45. package/lib/utils/index.d.cts +3 -6
  46. package/lib/utils/index.d.ts +3 -6
  47. package/lib/utils/index.js +5 -5
  48. package/package.json +3 -3
  49. package/src/behaviors/behavior.abstract.ts +2 -1
  50. package/src/editor/create-slate-editor.tsx +0 -1
  51. package/src/editor/editor-selector.ts +1 -13
  52. package/src/editor/editor-snapshot.ts +4 -19
  53. package/src/editor/plugins/createWithEditableAPI.ts +9 -5
  54. package/src/editor/plugins/createWithPortableTextMarkModel.ts +13 -4
  55. package/src/editor/plugins/with-plugins.ts +4 -8
  56. package/src/internal-utils/create-test-snapshot.ts +2 -5
  57. package/src/operations/behavior.operation.decorator.add.ts +1 -4
  58. package/src/operations/behavior.operation.insert.text.ts +34 -20
  59. package/src/selectors/selector.get-active-annotation-marks.ts +12 -0
  60. package/src/selectors/selector.get-active-annotations.ts +8 -20
  61. package/src/{editor/get-active-decorators.ts → selectors/selector.get-active-decorators.ts} +6 -11
  62. package/src/{internal-utils/mark-state.ts → selectors/selector.get-mark-state.ts} +41 -67
  63. package/src/selectors/selector.get-next-span.ts +56 -0
  64. package/src/selectors/selector.get-previous-span.ts +53 -0
  65. package/src/selectors/selector.is-active-annotation.ts +3 -1
  66. package/src/selectors/selector.is-active-decorator.ts +4 -1
  67. package/src/types/editor.ts +0 -2
  68. package/src/utils/util.is-selection-expanded.ts +13 -0
  69. package/lib/_chunks-cjs/selector.is-selection-expanded.cjs.map +0 -1
  70. package/lib/_chunks-cjs/util.is-equal-selection-points.cjs.map +0 -1
  71. package/lib/_chunks-es/selector.is-selection-expanded.js.map +0 -1
  72. package/lib/_chunks-es/util.is-equal-selection-points.js.map +0 -1
  73. package/src/editor/get-active-annotations.ts +0 -15
  74. package/src/editor/plugins/slate-plugin.update-mark-state.ts +0 -21
package/lib/index.d.cts CHANGED
@@ -1215,10 +1215,10 @@ declare const editorMachine: StateMachine<
1215
1215
  'edit mode':
1216
1216
  | {
1217
1217
  editable:
1218
- | 'dragging internally'
1219
1218
  | 'idle'
1219
+ | 'dragging internally'
1220
1220
  | {
1221
- focusing: 'checking if busy' | 'busy'
1221
+ focusing: 'busy' | 'checking if busy'
1222
1222
  }
1223
1223
  }
1224
1224
  | {
@@ -1228,11 +1228,11 @@ declare const editorMachine: StateMachine<
1228
1228
  | 'setting up'
1229
1229
  | {
1230
1230
  'set up': {
1231
- 'value sync': 'syncing value' | 'idle'
1231
+ 'value sync': 'idle' | 'syncing value'
1232
1232
  'writing':
1233
1233
  | 'dirty'
1234
1234
  | {
1235
- pristine: 'normalizing' | 'idle'
1235
+ pristine: 'idle' | 'normalizing'
1236
1236
  }
1237
1237
  }
1238
1238
  }
@@ -1557,6 +1557,7 @@ declare const editorMachine: StateMachine<
1557
1557
  | 'keyboard.keyup'
1558
1558
  | 'mouse.click'
1559
1559
  | '*'
1560
+ | `custom.${string}`
1560
1561
  | 'deserialize.*'
1561
1562
  | 'serialize.*'
1562
1563
  | 'split.*'
@@ -1564,20 +1565,19 @@ declare const editorMachine: StateMachine<
1564
1565
  | 'select.*'
1565
1566
  | 'style.*'
1566
1567
  | 'block.*'
1568
+ | 'history.*'
1569
+ | 'insert.*'
1567
1570
  | 'annotation.*'
1568
1571
  | 'decorator.*'
1569
1572
  | 'child.*'
1570
1573
  | 'deserialization.*'
1571
- | 'insert.*'
1572
1574
  | 'list item.*'
1573
1575
  | 'move.*'
1574
1576
  | 'serialization.*'
1575
- | 'history.*'
1576
1577
  | 'clipboard.*'
1577
1578
  | 'drag.*'
1578
1579
  | 'keyboard.*'
1579
- | 'mouse.*'
1580
- | `custom.${string}`,
1580
+ | 'mouse.*',
1581
1581
  true,
1582
1582
  | {
1583
1583
  type: StrictExtract_2<
@@ -6156,15 +6156,12 @@ export declare type EditorSelector<TSelected> = (
6156
6156
  */
6157
6157
  export declare type EditorSnapshot = {
6158
6158
  context: EditorContext
6159
+ blockIndexMap: Map<string, number>
6159
6160
  /**
6160
6161
  * @beta
6161
- * Do not rely on this externally
6162
+ * Subject to change
6162
6163
  */
6163
- beta: {
6164
- activeAnnotations: Array<string>
6165
- activeDecorators: Array<string>
6166
- }
6167
- blockIndexMap: Map<string, number>
6164
+ decoratorState: Record<string, boolean | undefined>
6168
6165
  }
6169
6166
 
6170
6167
  /**
@@ -6417,11 +6414,6 @@ export declare type LoadingChange = {
6417
6414
  isLoading: boolean
6418
6415
  }
6419
6416
 
6420
- declare type MarkState = {
6421
- state: 'changed' | 'unchanged'
6422
- marks: Array<string>
6423
- }
6424
-
6425
6417
  declare type MIMEType = `${string}/${string}`
6426
6418
 
6427
6419
  declare type MouseBehaviorEvent = {
@@ -7178,7 +7170,6 @@ declare interface PortableTextSlateEditor extends ReactEditor {
7178
7170
  value: Array<PortableTextBlock>
7179
7171
  decoratedRanges: Array<DecoratedRange>
7180
7172
  decoratorState: Record<string, boolean | undefined>
7181
- markState: MarkState | undefined
7182
7173
  blockIndexMap: Map<string, number>
7183
7174
  listIndexMap: Map<string, number>
7184
7175
  /**
package/lib/index.d.ts CHANGED
@@ -1215,10 +1215,10 @@ declare const editorMachine: StateMachine<
1215
1215
  'edit mode':
1216
1216
  | {
1217
1217
  editable:
1218
- | 'dragging internally'
1219
1218
  | 'idle'
1219
+ | 'dragging internally'
1220
1220
  | {
1221
- focusing: 'checking if busy' | 'busy'
1221
+ focusing: 'busy' | 'checking if busy'
1222
1222
  }
1223
1223
  }
1224
1224
  | {
@@ -1228,11 +1228,11 @@ declare const editorMachine: StateMachine<
1228
1228
  | 'setting up'
1229
1229
  | {
1230
1230
  'set up': {
1231
- 'value sync': 'syncing value' | 'idle'
1231
+ 'value sync': 'idle' | 'syncing value'
1232
1232
  'writing':
1233
1233
  | 'dirty'
1234
1234
  | {
1235
- pristine: 'normalizing' | 'idle'
1235
+ pristine: 'idle' | 'normalizing'
1236
1236
  }
1237
1237
  }
1238
1238
  }
@@ -1557,6 +1557,7 @@ declare const editorMachine: StateMachine<
1557
1557
  | 'keyboard.keyup'
1558
1558
  | 'mouse.click'
1559
1559
  | '*'
1560
+ | `custom.${string}`
1560
1561
  | 'deserialize.*'
1561
1562
  | 'serialize.*'
1562
1563
  | 'split.*'
@@ -1564,20 +1565,19 @@ declare const editorMachine: StateMachine<
1564
1565
  | 'select.*'
1565
1566
  | 'style.*'
1566
1567
  | 'block.*'
1568
+ | 'history.*'
1569
+ | 'insert.*'
1567
1570
  | 'annotation.*'
1568
1571
  | 'decorator.*'
1569
1572
  | 'child.*'
1570
1573
  | 'deserialization.*'
1571
- | 'insert.*'
1572
1574
  | 'list item.*'
1573
1575
  | 'move.*'
1574
1576
  | 'serialization.*'
1575
- | 'history.*'
1576
1577
  | 'clipboard.*'
1577
1578
  | 'drag.*'
1578
1579
  | 'keyboard.*'
1579
- | 'mouse.*'
1580
- | `custom.${string}`,
1580
+ | 'mouse.*',
1581
1581
  true,
1582
1582
  | {
1583
1583
  type: StrictExtract_2<
@@ -6156,15 +6156,12 @@ export declare type EditorSelector<TSelected> = (
6156
6156
  */
6157
6157
  export declare type EditorSnapshot = {
6158
6158
  context: EditorContext
6159
+ blockIndexMap: Map<string, number>
6159
6160
  /**
6160
6161
  * @beta
6161
- * Do not rely on this externally
6162
+ * Subject to change
6162
6163
  */
6163
- beta: {
6164
- activeAnnotations: Array<string>
6165
- activeDecorators: Array<string>
6166
- }
6167
- blockIndexMap: Map<string, number>
6164
+ decoratorState: Record<string, boolean | undefined>
6168
6165
  }
6169
6166
 
6170
6167
  /**
@@ -6417,11 +6414,6 @@ export declare type LoadingChange = {
6417
6414
  isLoading: boolean
6418
6415
  }
6419
6416
 
6420
- declare type MarkState = {
6421
- state: 'changed' | 'unchanged'
6422
- marks: Array<string>
6423
- }
6424
-
6425
6417
  declare type MIMEType = `${string}/${string}`
6426
6418
 
6427
6419
  declare type MouseBehaviorEvent = {
@@ -7178,7 +7170,6 @@ declare interface PortableTextSlateEditor extends ReactEditor {
7178
7170
  value: Array<PortableTextBlock>
7179
7171
  decoratedRanges: Array<DecoratedRange>
7180
7172
  decoratorState: Record<string, boolean | undefined>
7181
- markState: MarkState | undefined
7182
7173
  blockIndexMap: Map<string, number>
7183
7174
  listIndexMap: Map<string, number>
7184
7175
  /**
package/lib/index.js CHANGED
@@ -9,12 +9,11 @@ import { Element as Element$1, Text, Range, Editor, Node, Point, Transforms, Pat
9
9
  import { useSelected, useSlateSelector, useSlateStatic, withReact, ReactEditor, Slate, useSlate, Editable } from "slate-react";
10
10
  import debug$f from "debug";
11
11
  import { DOMEditor, isDOMNode } from "slate-dom";
12
- import { getBlockStartPoint, getBlockKeyFromSelectionPoint, getChildKeyFromSelectionPoint, isTextBlock, parseBlock, parseAnnotation, blockOffsetToSpanSelectionPoint, parseInlineObject, isKeyedSegment, isSpan$1 as isSpan, isListBlock, isTypedObject, getSelectionStartPoint, getSelectionEndPoint, getTextBlockText, parseBlocks } from "./_chunks-es/util.slice-blocks.js";
13
- import { getBlockEndPoint, isEmptyTextBlock, isEqualSelectionPoints } from "./_chunks-es/util.is-equal-selection-points.js";
14
- import { isSelectionCollapsed, selectionPointToBlockOffset, sliceTextBlock } from "./_chunks-es/util.slice-text-block.js";
12
+ import { getBlockStartPoint, getBlockKeyFromSelectionPoint, getChildKeyFromSelectionPoint, isTextBlock, parseBlock, parseAnnotation, blockOffsetToSpanSelectionPoint, parseInlineObject, isKeyedSegment, isSpan, isListBlock, isTypedObject, getSelectionStartPoint, getSelectionEndPoint, getTextBlockText, parseBlocks } from "./_chunks-es/util.slice-blocks.js";
13
+ import { getBlockEndPoint, isSelectionCollapsed, isEmptyTextBlock, isEqualSelectionPoints } from "./_chunks-es/util.is-selection-collapsed.js";
15
14
  import isEqual from "lodash/isEqual.js";
16
- import { isSelectionCollapsed as isSelectionCollapsed$1, getFocusTextBlock, getFocusSpan as getFocusSpan$1, isSelectionExpanded, getFocusBlock as getFocusBlock$1, getSelectedValue, getFocusChild as getFocusChild$1 } from "./_chunks-es/selector.is-selection-expanded.js";
17
- import { getFocusInlineObject, getSelectedBlocks, getSelectionStartBlock as getSelectionStartBlock$1, getSelectionEndBlock as getSelectionEndBlock$1, isOverlappingSelection, isSelectingEntireBlocks, getTrimmedSelection, getSelectedSpans, getCaretWordSelection, getFocusBlockObject, getPreviousBlock, getNextBlock, isAtTheEndOfBlock, isAtTheStartOfBlock, getFirstBlock as getFirstBlock$1, getLastBlock as getLastBlock$1, getFocusListBlock, isActiveAnnotation, isActiveDecorator, getSelectedTextBlocks, isActiveListItem, isActiveStyle, getActiveAnnotations as getActiveAnnotations$1 } from "./_chunks-es/selector.is-selecting-entire-blocks.js";
15
+ import { getFocusInlineObject, getSelectedBlocks, getSelectionStartBlock as getSelectionStartBlock$1, getSelectionEndBlock as getSelectionEndBlock$1, isOverlappingSelection, isSelectingEntireBlocks, getMarkState, getActiveDecorators, getActiveAnnotationsMarks, getTrimmedSelection, getCaretWordSelection, getFocusBlockObject, getPreviousBlock, getNextBlock, isAtTheEndOfBlock, isAtTheStartOfBlock, getFirstBlock as getFirstBlock$1, getLastBlock as getLastBlock$1, getFocusListBlock, isActiveAnnotation, isActiveDecorator, getSelectedTextBlocks, isActiveListItem, isActiveStyle, getActiveAnnotations } from "./_chunks-es/selector.is-selecting-entire-blocks.js";
16
+ import { isSelectionCollapsed as isSelectionCollapsed$1, getFocusTextBlock, getFocusSpan as getFocusSpan$1, isSelectionExpanded, getFocusBlock as getFocusBlock$1, getSelectedValue, getFocusChild as getFocusChild$1 } from "./_chunks-es/selector.get-focus-span.js";
18
17
  import getRandomValues from "get-random-values-esm";
19
18
  import { defineBehavior, forward, raise, effect } from "./behaviors/index.js";
20
19
  import uniq from "lodash/uniq.js";
@@ -27,6 +26,7 @@ import flatten from "lodash/flatten.js";
27
26
  import omit from "lodash/omit.js";
28
27
  import { applyAll, unset, insert, set, setIfMissing, diffMatchPatch as diffMatchPatch$1 } from "@portabletext/patches";
29
28
  import { blockOffsetsToSelection } from "./_chunks-es/util.child-selection-point-to-block-offset.js";
29
+ import { selectionPointToBlockOffset, sliceTextBlock } from "./_chunks-es/util.slice-text-block.js";
30
30
  import get from "lodash/get.js";
31
31
  import isUndefined from "lodash/isUndefined.js";
32
32
  import omitBy from "lodash/omitBy.js";
@@ -1372,43 +1372,34 @@ function createPlaceholderBlock(context) {
1372
1372
  }]
1373
1373
  };
1374
1374
  }
1375
- function getActiveAnnotations({
1376
- markState,
1377
- schema
1378
- }) {
1379
- return (markState?.marks ?? []).filter((mark) => !schema.decorators.map((decorator) => decorator.name).includes(mark));
1380
- }
1381
- function getActiveDecorators({
1382
- decoratorState,
1383
- markState,
1384
- schema
1385
- }) {
1386
- const decorators = schema.decorators.map((decorator) => decorator.name);
1387
- let activeDecorators = (markState?.marks ?? []).filter((mark) => decorators.includes(mark));
1388
- for (const decorator in decoratorState)
1389
- decoratorState[decorator] === !1 ? activeDecorators = activeDecorators.filter((activeDecorator) => activeDecorator !== decorator) : decoratorState[decorator] === !0 && (activeDecorators.includes(decorator) || activeDecorators.push(decorator));
1390
- return activeDecorators;
1391
- }
1392
1375
  const insertTextOperationImplementation = ({
1393
1376
  context,
1394
1377
  operation
1395
1378
  }) => {
1396
- const activeDecorators = getActiveDecorators({
1397
- decoratorState: operation.editor.decoratorState,
1398
- markState: operation.editor.markState,
1399
- schema: context.schema
1400
- }), activeAnnotations = getActiveAnnotations({
1401
- markState: operation.editor.markState,
1402
- schema: context.schema
1403
- }), [focusSpan] = getFocusSpan({
1379
+ const snapshot = {
1380
+ blockIndexMap: operation.editor.blockIndexMap,
1381
+ context: {
1382
+ value: operation.editor.value,
1383
+ selection: operation.editor.selection ? slateRangeToSelection({
1384
+ schema: context.schema,
1385
+ editor: operation.editor,
1386
+ range: operation.editor.selection
1387
+ }) : null,
1388
+ schema: context.schema,
1389
+ keyGenerator: context.keyGenerator,
1390
+ converters: [],
1391
+ readOnly: !1
1392
+ },
1393
+ decoratorState: operation.editor.decoratorState
1394
+ }, markState = getMarkState(snapshot), activeDecorators = getActiveDecorators(snapshot), activeAnnotations = getActiveAnnotationsMarks(snapshot), [focusSpan] = getFocusSpan({
1404
1395
  editor: operation.editor
1405
1396
  });
1406
1397
  if (!focusSpan) {
1407
1398
  Transforms.insertText(operation.editor, operation.text);
1408
1399
  return;
1409
1400
  }
1410
- if (operation.editor.markState && operation.editor.markState.state === "unchanged") {
1411
- const markStateDecorators = (operation.editor.markState.marks ?? []).filter((mark) => context.schema.decorators.map((decorator) => decorator.name).includes(mark));
1401
+ if (markState && markState.state === "unchanged") {
1402
+ const markStateDecorators = (markState.marks ?? []).filter((mark) => context.schema.decorators.map((decorator) => decorator.name).includes(mark));
1412
1403
  if (markStateDecorators.length === activeDecorators.length && markStateDecorators.every((mark) => activeDecorators.includes(mark))) {
1413
1404
  Transforms.insertText(operation.editor, operation.text);
1414
1405
  return;
@@ -1522,17 +1513,7 @@ function getEditorSnapshot({
1522
1513
  selection: editorActorSnapshot.context.selection,
1523
1514
  value: slateEditorInstance.value
1524
1515
  },
1525
- beta: {
1526
- activeAnnotations: getActiveAnnotations({
1527
- markState: slateEditorInstance.markState,
1528
- schema: editorActorSnapshot.context.schema
1529
- }),
1530
- activeDecorators: getActiveDecorators({
1531
- decoratorState: slateEditorInstance.decoratorState,
1532
- markState: slateEditorInstance.markState,
1533
- schema: editorActorSnapshot.context.schema
1534
- })
1535
- }
1516
+ decoratorState: slateEditorInstance.decoratorState
1536
1517
  };
1537
1518
  }
1538
1519
  const debug$e = debugWithName("plugin:withPortableTextMarkModel");
@@ -1747,11 +1728,15 @@ function createWithPortableTextMarkModel(editorActor) {
1747
1728
  }
1748
1729
  }
1749
1730
  if (op.type === "insert_text") {
1750
- if (!editor.markState) {
1731
+ const snapshot = getEditorSnapshot({
1732
+ editorActorSnapshot: editorActor.getSnapshot(),
1733
+ slateEditorInstance: editor
1734
+ }), markState = getMarkState(snapshot);
1735
+ if (!markState) {
1751
1736
  apply2(op);
1752
1737
  return;
1753
1738
  }
1754
- if (editor.markState.state === "unchanged") {
1739
+ if (markState.state === "unchanged") {
1755
1740
  apply2(op);
1756
1741
  return;
1757
1742
  }
@@ -1759,7 +1744,7 @@ function createWithPortableTextMarkModel(editorActor) {
1759
1744
  _type: "span",
1760
1745
  _key: editorActor.getSnapshot().context.keyGenerator(),
1761
1746
  text: op.text,
1762
- marks: editor.markState.marks
1747
+ marks: markState.marks
1763
1748
  });
1764
1749
  return;
1765
1750
  }
@@ -1796,7 +1781,7 @@ function createWithPortableTextMarkModel(editorActor) {
1796
1781
  });
1797
1782
  Editor.withoutNormalizing(editor, () => {
1798
1783
  apply2(op), Transforms.setNodes(editor, {
1799
- marks: snapshot.beta.activeDecorators
1784
+ marks: getActiveDecorators(snapshot)
1800
1785
  }, {
1801
1786
  at: op.path
1802
1787
  });
@@ -3215,10 +3200,6 @@ const addAnnotationOperationImplementation = ({
3215
3200
  backward: editorSelection?.backward
3216
3201
  }), trimmedSelection = getTrimmedSelection({
3217
3202
  blockIndexMap: editor.blockIndexMap,
3218
- beta: {
3219
- activeAnnotations: [],
3220
- activeDecorators: []
3221
- },
3222
3203
  context: {
3223
3204
  converters: [],
3224
3205
  keyGenerator: context.keyGenerator,
@@ -3226,7 +3207,8 @@ const addAnnotationOperationImplementation = ({
3226
3207
  schema: context.schema,
3227
3208
  selection: newSelection,
3228
3209
  value: newValue
3229
- }
3210
+ },
3211
+ decoratorState: editor.decoratorState
3230
3212
  });
3231
3213
  if (!trimmedSelection)
3232
3214
  throw new Error("Unable to find trimmed selection");
@@ -4829,110 +4811,6 @@ function createWithUtils({
4829
4811
  })[0], editor;
4830
4812
  };
4831
4813
  }
4832
- function getMarkState({
4833
- schema,
4834
- editor
4835
- }) {
4836
- if (!editor.selection)
4837
- return;
4838
- const [block, blockPath] = getFocusBlock({
4839
- editor
4840
- }), [span, spanPath] = getFocusSpan({
4841
- editor
4842
- });
4843
- if (!block || !editor.isTextBlock(block) || !span)
4844
- return;
4845
- if (Range.isExpanded(editor.selection)) {
4846
- const selection = editor.selection ? slateRangeToSelection({
4847
- schema,
4848
- editor,
4849
- range: editor.selection
4850
- }) : null, selectedSpans = getSelectedSpans({
4851
- blockIndexMap: editor.blockIndexMap,
4852
- context: {
4853
- value: editor.value,
4854
- selection,
4855
- schema,
4856
- converters: [],
4857
- keyGenerator: () => "",
4858
- readOnly: !1
4859
- }
4860
- });
4861
- let index = 0, marks2 = [];
4862
- for (const span2 of selectedSpans)
4863
- index === 0 ? marks2 = span2.node.marks ?? [] : (span2.node.marks?.length === 0 || (span2.node.marks ?? [])?.some((mark) => !marks2.includes(mark))) && (marks2 = []), index++;
4864
- return {
4865
- state: "unchanged",
4866
- marks: marks2
4867
- };
4868
- }
4869
- const decorators = schema.decorators.map((decorator) => decorator.name), marks = span.marks ?? [], marksWithoutAnnotations = marks.filter((mark) => decorators.includes(mark)), spanHasAnnotations = marks.length > marksWithoutAnnotations.length, spanIsEmpty = span.text.length === 0, atTheBeginningOfSpan = editor.selection.anchor.offset === 0, atTheEndOfSpan = editor.selection.anchor.offset === span.text.length, previousSpan = getPreviousSpan({
4870
- editor,
4871
- blockPath,
4872
- spanPath
4873
- }), nextSpan = getNextSpan({
4874
- editor,
4875
- blockPath,
4876
- spanPath
4877
- }), nextSpanAnnotations = nextSpan?.marks?.filter((mark) => !decorators.includes(mark)) ?? [], spanAnnotations = marks.filter((mark) => !decorators.includes(mark)), previousSpanHasAnnotations = previousSpan ? previousSpan.marks?.some((mark) => !decorators.includes(mark)) : !1, previousSpanHasSameAnnotations = previousSpan ? previousSpan.marks?.filter((mark) => !decorators.includes(mark)).every((mark) => marks.includes(mark)) : !1, previousSpanHasSameAnnotation = previousSpan ? previousSpan.marks?.some((mark) => !decorators.includes(mark) && marks.includes(mark)) : !1, previousSpanHasSameMarks = previousSpan ? previousSpan.marks?.every((mark) => marks.includes(mark)) : !1, nextSpanSharesSomeAnnotations = spanAnnotations.some((mark) => nextSpanAnnotations?.includes(mark));
4878
- if (spanHasAnnotations && !spanIsEmpty) {
4879
- if (atTheBeginningOfSpan) {
4880
- if (previousSpanHasSameMarks)
4881
- return {
4882
- state: "changed",
4883
- marks: previousSpan?.marks ?? []
4884
- };
4885
- if (previousSpanHasSameAnnotations)
4886
- return {
4887
- state: "changed",
4888
- marks: previousSpan?.marks ?? []
4889
- };
4890
- if (previousSpanHasSameAnnotation)
4891
- return {
4892
- state: "unchanged",
4893
- marks: span.marks ?? []
4894
- };
4895
- if (!previousSpan)
4896
- return {
4897
- state: "changed",
4898
- marks: []
4899
- };
4900
- }
4901
- if (atTheEndOfSpan) {
4902
- if (nextSpan && nextSpanSharesSomeAnnotations && nextSpanAnnotations.length < spanAnnotations.length || !nextSpanSharesSomeAnnotations)
4903
- return {
4904
- state: "changed",
4905
- marks: nextSpan?.marks ?? []
4906
- };
4907
- if (!nextSpan)
4908
- return {
4909
- state: "changed",
4910
- marks: []
4911
- };
4912
- }
4913
- }
4914
- return atTheBeginningOfSpan && !spanIsEmpty && previousSpan ? previousSpanHasAnnotations ? {
4915
- state: "changed",
4916
- marks: []
4917
- } : {
4918
- state: "changed",
4919
- marks: (previousSpan?.marks ?? []).filter((mark) => decorators.includes(mark))
4920
- } : {
4921
- state: "unchanged",
4922
- marks: span.marks ?? []
4923
- };
4924
- }
4925
- function pluginUpdateMarkState(context, editor) {
4926
- const {
4927
- apply: apply2
4928
- } = editor;
4929
- return editor.apply = (operation) => {
4930
- apply2(operation), editor.markState = getMarkState({
4931
- editor,
4932
- schema: context.schema
4933
- });
4934
- }, editor;
4935
- }
4936
4814
  function pluginUpdateSelection({
4937
4815
  editor,
4938
4816
  editorActor
@@ -5276,10 +5154,10 @@ const withPlugins = (editor, options) => {
5276
5154
  }), withPortableTextMarkModel = createWithPortableTextMarkModel(editorActor), withPlaceholderBlock = createWithPlaceholderBlock(editorActor), withUtils = createWithUtils({
5277
5155
  editorActor
5278
5156
  });
5279
- return createWithEventListeners(editorActor)(withSchemaTypes(withObjectKeys(withPortableTextMarkModel(withPlaceholderBlock(withUtils(withMaxBlocks(withUndoRedo(withPatches(pluginUpdateValue(editorActor.getSnapshot().context, pluginUpdateMarkState(editorActor.getSnapshot().context, pluginUpdateSelection({
5157
+ return createWithEventListeners(editorActor)(withSchemaTypes(withObjectKeys(withPortableTextMarkModel(withPlaceholderBlock(withUtils(withMaxBlocks(withUndoRedo(withPatches(pluginUpdateValue(editorActor.getSnapshot().context, pluginUpdateSelection({
5280
5158
  editorActor,
5281
5159
  editor: e
5282
- }))))))))))));
5160
+ })))))))))));
5283
5161
  }, debug$9 = debugWithName("setup");
5284
5162
  function createSlateEditor(config) {
5285
5163
  debug$9("Creating new Slate editor instance");
@@ -5288,7 +5166,7 @@ function createSlateEditor(config) {
5288
5166
  relayActor: config.relayActor,
5289
5167
  subscriptions: config.subscriptions
5290
5168
  });
5291
- KEY_TO_VALUE_ELEMENT.set(instance, {}), KEY_TO_SLATE_ELEMENT.set(instance, {}), instance.decoratedRanges = [], instance.decoratorState = {}, instance.markState = void 0;
5169
+ KEY_TO_VALUE_ELEMENT.set(instance, {}), KEY_TO_SLATE_ELEMENT.set(instance, {}), instance.decoratedRanges = [], instance.decoratorState = {};
5292
5170
  const placeholderBlock = createPlaceholderBlock(config.editorActor.getSnapshot().context);
5293
5171
  instance.value = [placeholderBlock], instance.blockIndexMap = /* @__PURE__ */ new Map(), instance.listIndexMap = /* @__PURE__ */ new Map(), buildIndexMaps({
5294
5172
  schema: config.editorActor.getSnapshot().context.schema,
@@ -7278,9 +7156,9 @@ const coreDndBehaviors = [
7278
7156
  event
7279
7157
  }) => {
7280
7158
  if (getFocusTextBlock(snapshot) && event.mimeType === "text/plain" && event.originEvent.type === "clipboard.paste") {
7281
- const activeDecorators = snapshot.beta.activeDecorators;
7159
+ const activeDecorators = getActiveDecorators(snapshot);
7282
7160
  return {
7283
- activeAnnotations: getActiveAnnotations$1(snapshot),
7161
+ activeAnnotations: getActiveAnnotations(snapshot),
7284
7162
  activeDecorators,
7285
7163
  textRuns: event.data.flatMap((block) => isTextBlock(snapshot.context, block) ? [getTextBlockText(block)] : [])
7286
7164
  };
@@ -7654,17 +7532,7 @@ function createEditorSnapshot({
7654
7532
  return {
7655
7533
  blockIndexMap: editor.blockIndexMap,
7656
7534
  context,
7657
- beta: {
7658
- activeAnnotations: getActiveAnnotations({
7659
- markState: editor.markState,
7660
- schema
7661
- }),
7662
- activeDecorators: getActiveDecorators({
7663
- decoratorState: editor.decoratorState,
7664
- markState: editor.markState,
7665
- schema
7666
- })
7667
- }
7535
+ decoratorState: editor.decoratorState
7668
7536
  };
7669
7537
  }
7670
7538
  const debug$7 = debugWithName("editor machine"), editorMachine = setup({
@@ -8630,16 +8498,19 @@ function createEditableAPI(editor, editorActor) {
8630
8498
  editor
8631
8499
  });
8632
8500
  },
8633
- isMarkActive: (mark) => getEditorSnapshot({
8634
- editorActorSnapshot: editorActor.getSnapshot(),
8635
- slateEditorInstance: editor
8636
- }).beta.activeDecorators.includes(mark),
8637
- marks: () => {
8501
+ isMarkActive: (mark) => {
8638
8502
  const snapshot = getEditorSnapshot({
8639
8503
  editorActorSnapshot: editorActor.getSnapshot(),
8640
8504
  slateEditorInstance: editor
8641
8505
  });
8642
- return [...snapshot.beta.activeAnnotations, ...snapshot.beta.activeDecorators];
8506
+ return getActiveDecorators(snapshot).includes(mark);
8507
+ },
8508
+ marks: () => {
8509
+ const snapshot = getEditorSnapshot({
8510
+ editorActorSnapshot: editorActor.getSnapshot(),
8511
+ slateEditorInstance: editor
8512
+ }), activeAnnotations = getActiveAnnotationsMarks(snapshot), activeDecorators = getActiveDecorators(snapshot);
8513
+ return [...activeAnnotations, ...activeDecorators];
8643
8514
  },
8644
8515
  undo: () => {
8645
8516
  editorActor.send({