@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
@@ -1,5 +1,5 @@
1
- import { getBlockKeyFromSelectionPoint, isTextBlock, getChildKeyFromSelectionPoint, isSpan$1 as isSpan, isSpan as isSpan$1, getSelectionStartPoint as getSelectionStartPoint$1, getSelectionEndPoint, sliceBlocks } from "./util.slice-blocks.js";
2
1
  import { isKeySegment } from "@sanity/types";
2
+ import { getBlockKeyFromSelectionPoint, isTextBlock, isSpan$1 as isSpan, getSelectionStartPoint as getSelectionStartPoint$1, getSelectionEndPoint, sliceBlocks, isSpan as isSpan$1, getChildKeyFromSelectionPoint } from "./util.slice-blocks.js";
3
3
  const getFocusBlock = (snapshot) => {
4
4
  if (!snapshot.context.selection)
5
5
  return;
@@ -10,35 +10,16 @@ const getFocusBlock = (snapshot) => {
10
10
  _key: key
11
11
  }]
12
12
  } : void 0;
13
+ }, getSelectionStartPoint = (snapshot) => {
14
+ if (snapshot.context.selection)
15
+ return snapshot.context.selection.backward ? snapshot.context.selection.focus : snapshot.context.selection.anchor;
13
16
  }, getFocusTextBlock = (snapshot) => {
14
17
  const focusBlock = getFocusBlock(snapshot);
15
18
  return focusBlock && isTextBlock(snapshot.context, focusBlock.node) ? {
16
19
  node: focusBlock.node,
17
20
  path: focusBlock.path
18
21
  } : void 0;
19
- }, getFocusChild = (snapshot) => {
20
- if (!snapshot.context.selection)
21
- return;
22
- const focusBlock = getFocusTextBlock(snapshot);
23
- if (!focusBlock)
24
- return;
25
- const key = getChildKeyFromSelectionPoint(snapshot.context.selection.focus), node = key ? focusBlock.node.children.find((span) => span._key === key) : void 0;
26
- return node && key ? {
27
- node,
28
- path: [...focusBlock.path, "children", {
29
- _key: key
30
- }]
31
- } : void 0;
32
- }, getFocusSpan = (snapshot) => {
33
- const focusChild = getFocusChild(snapshot);
34
- return focusChild && isSpan(snapshot.context, focusChild.node) ? {
35
- node: focusChild.node,
36
- path: focusChild.path
37
- } : void 0;
38
- }, getSelectionStartPoint = (snapshot) => {
39
- if (snapshot.context.selection)
40
- return snapshot.context.selection.backward ? snapshot.context.selection.focus : snapshot.context.selection.anchor;
41
- }, 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, getPreviousInlineObject = (snapshot) => {
22
+ }, getPreviousInlineObject = (snapshot) => {
42
23
  const focusTextBlock = getFocusTextBlock(snapshot), selectionStartPoint = getSelectionStartPoint(snapshot), selectionStartPointChildKey = selectionStartPoint && isKeySegment(selectionStartPoint.path[2]) ? selectionStartPoint.path[2]._key : void 0;
43
24
  if (!focusTextBlock || !selectionStartPointChildKey)
44
25
  return;
@@ -46,7 +27,7 @@ const getFocusBlock = (snapshot) => {
46
27
  for (const child of focusTextBlock.node.children) {
47
28
  if (child._key === selectionStartPointChildKey)
48
29
  break;
49
- isSpan$1(snapshot.context, child) || (inlineObject = {
30
+ isSpan(snapshot.context, child) || (inlineObject = {
50
31
  node: child,
51
32
  path: [...focusTextBlock.path, "children", {
52
33
  _key: child._key
@@ -69,7 +50,26 @@ const getFocusBlock = (snapshot) => {
69
50
  context: snapshot.context,
70
51
  blocks: slicedValue
71
52
  });
72
- }, 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, ""), isSelectionExpanded = (snapshot) => !isSelectionCollapsed(snapshot);
53
+ }, getSelectionText = (snapshot) => getSelectedValue(snapshot).reduce((text, block) => isTextBlock(snapshot.context, block) ? text + block.children.reduce((text2, child) => isSpan$1(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), getFocusChild = (snapshot) => {
54
+ if (!snapshot.context.selection)
55
+ return;
56
+ const focusBlock = getFocusTextBlock(snapshot);
57
+ if (!focusBlock)
58
+ return;
59
+ const key = getChildKeyFromSelectionPoint(snapshot.context.selection.focus), node = key ? focusBlock.node.children.find((span) => span._key === key) : void 0;
60
+ return node && key ? {
61
+ node,
62
+ path: [...focusBlock.path, "children", {
63
+ _key: key
64
+ }]
65
+ } : void 0;
66
+ }, getFocusSpan = (snapshot) => {
67
+ const focusChild = getFocusChild(snapshot);
68
+ return focusChild && isSpan$1(snapshot.context, focusChild.node) ? {
69
+ node: focusChild.node,
70
+ path: focusChild.path
71
+ } : void 0;
72
+ };
73
73
  export {
74
74
  getFocusBlock,
75
75
  getFocusChild,
@@ -82,4 +82,4 @@ export {
82
82
  isSelectionCollapsed,
83
83
  isSelectionExpanded
84
84
  };
85
- //# sourceMappingURL=selector.is-selection-expanded.js.map
85
+ //# sourceMappingURL=selector.get-focus-span.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selector.get-focus-span.js","sources":["../../src/selectors/selector.get-focus-block.ts","../../src/selectors/selector.get-selection-start-point.ts","../../src/selectors/selector.get-focus-text-block.ts","../../src/selectors/selector.get-previous-inline-object.ts","../../src/selectors/selector.get-selected-value.ts","../../src/selectors/selector.get-selection-text.ts","../../src/selectors/selector.is-selection-collapsed.ts","../../src/selectors/selector.is-selection-expanded.ts","../../src/selectors/selector.get-focus-child.ts","../../src/selectors/selector.get-focus-span.ts"],"sourcesContent":["import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getBlockKeyFromSelectionPoint} from '../selection/selection-point'\nimport type {BlockPath} from '../types/paths'\n\n/**\n * @public\n */\nexport const getFocusBlock: EditorSelector<\n {node: PortableTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const key = getBlockKeyFromSelectionPoint(snapshot.context.selection.focus)\n const index = key ? snapshot.blockIndexMap.get(key) : undefined\n\n const node =\n index !== undefined ? snapshot.context.value.at(index) : undefined\n\n return node && key ? {node, path: [{_key: key}]} : undefined\n}\n","import type {EditorSelectionPoint} from '..'\nimport type {EditorSelector} from '../editor/editor-selector'\n\n/**\n * @public\n */\nexport const getSelectionStartPoint: EditorSelector<\n EditorSelectionPoint | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n return snapshot.context.selection.backward\n ? snapshot.context.selection.focus\n : snapshot.context.selection.anchor\n}\n","import type {PortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport type {BlockPath} from '../types/paths'\nimport {getFocusBlock} from './selector.get-focus-block'\n\n/**\n * @public\n */\nexport const getFocusTextBlock: EditorSelector<\n {node: PortableTextTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const focusBlock = getFocusBlock(snapshot)\n\n return focusBlock && isTextBlock(snapshot.context, focusBlock.node)\n ? {node: focusBlock.node, path: focusBlock.path}\n : undefined\n}\n","import {isKeySegment, type PortableTextObject} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {ChildPath} from '../types/paths'\nimport {isSpan} from '../utils'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\n\n/**\n * @public\n */\nexport const getPreviousInlineObject: EditorSelector<\n | {\n node: PortableTextObject\n path: ChildPath\n }\n | undefined\n> = (snapshot) => {\n const focusTextBlock = getFocusTextBlock(snapshot)\n const selectionStartPoint = getSelectionStartPoint(snapshot)\n const selectionStartPointChildKey =\n selectionStartPoint && isKeySegment(selectionStartPoint.path[2])\n ? selectionStartPoint.path[2]._key\n : undefined\n\n if (!focusTextBlock || !selectionStartPointChildKey) {\n return undefined\n }\n\n let inlineObject:\n | {\n node: PortableTextObject\n path: ChildPath\n }\n | undefined\n\n for (const child of focusTextBlock.node.children) {\n if (child._key === selectionStartPointChildKey) {\n break\n }\n\n if (!isSpan(snapshot.context, child)) {\n inlineObject = {\n node: child,\n path: [...focusTextBlock.path, 'children', {_key: child._key}],\n }\n }\n }\n\n return inlineObject\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getBlockKeyFromSelectionPoint} from '../selection/selection-point'\nimport {\n getSelectionEndPoint,\n getSelectionStartPoint,\n sliceBlocks,\n} from '../utils'\n\n/**\n * @public\n */\nexport const getSelectedValue: EditorSelector<Array<PortableTextBlock>> = (\n snapshot,\n) => {\n const selection = snapshot.context.selection\n\n if (!selection) {\n return []\n }\n\n const startPoint = getSelectionStartPoint(selection)\n const endPoint = getSelectionEndPoint(selection)\n const startBlockKey = getBlockKeyFromSelectionPoint(startPoint)\n const endBlockKey = getBlockKeyFromSelectionPoint(endPoint)\n\n if (!startBlockKey || !endBlockKey) {\n return []\n }\n\n const startBlockIndex = snapshot.blockIndexMap.get(startBlockKey)\n const endBlockIndex = snapshot.blockIndexMap.get(endBlockKey)\n\n if (startBlockIndex === undefined || endBlockIndex === undefined) {\n return []\n }\n\n const slicedValue = snapshot.context.value.slice(\n startBlockIndex,\n endBlockIndex + 1,\n )\n\n return sliceBlocks({\n context: snapshot.context,\n blocks: slicedValue,\n })\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {isSpan, isTextBlock} from '../internal-utils/parse-blocks'\nimport {getSelectedValue} from './selector.get-selected-value'\n\n/**\n * @public\n */\nexport const getSelectionText: EditorSelector<string> = (snapshot) => {\n const selectedValue = getSelectedValue(snapshot)\n\n return selectedValue.reduce((text, block) => {\n if (!isTextBlock(snapshot.context, block)) {\n return text\n }\n\n return (\n text +\n block.children.reduce((text, child) => {\n if (isSpan(snapshot.context, child)) {\n return text + child.text\n }\n\n return text\n }, '')\n )\n }, '')\n}\n","import type {EditorSelector} from '../editor/editor-selector'\n\n/**\n * @public\n */\nexport const isSelectionCollapsed: EditorSelector<boolean> = (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n return (\n JSON.stringify(snapshot.context.selection.anchor.path) ===\n JSON.stringify(snapshot.context.selection.focus.path) &&\n snapshot.context.selection?.anchor.offset ===\n snapshot.context.selection?.focus.offset\n )\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\n\n/**\n * @public\n */\nexport const isSelectionExpanded: EditorSelector<boolean> = (snapshot) => {\n return !isSelectionCollapsed(snapshot)\n}\n","import type {PortableTextObject, PortableTextSpan} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getChildKeyFromSelectionPoint} from '../selection/selection-point'\nimport type {ChildPath} from '../types/paths'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\n\n/**\n * @public\n */\nexport const getFocusChild: EditorSelector<\n | {\n node: PortableTextObject | PortableTextSpan\n path: ChildPath\n }\n | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const focusBlock = getFocusTextBlock(snapshot)\n\n if (!focusBlock) {\n return undefined\n }\n\n const key = getChildKeyFromSelectionPoint(snapshot.context.selection.focus)\n\n const node = key\n ? focusBlock.node.children.find((span) => span._key === key)\n : undefined\n\n return node && key\n ? {node, path: [...focusBlock.path, 'children', {_key: key}]}\n : undefined\n}\n","import type {PortableTextSpan} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isSpan} from '../internal-utils/parse-blocks'\nimport type {ChildPath} from '../types/paths'\nimport {getFocusChild} from './selector.get-focus-child'\n\n/**\n * @public\n */\nexport const getFocusSpan: EditorSelector<\n {node: PortableTextSpan; path: ChildPath} | undefined\n> = (snapshot) => {\n const focusChild = getFocusChild(snapshot)\n\n return focusChild && isSpan(snapshot.context, focusChild.node)\n ? {node: focusChild.node, path: focusChild.path}\n : undefined\n}\n"],"names":["getFocusBlock","snapshot","context","selection","key","getBlockKeyFromSelectionPoint","focus","index","blockIndexMap","get","undefined","node","value","at","path","_key","getSelectionStartPoint","backward","anchor","getFocusTextBlock","focusBlock","isTextBlock","getPreviousInlineObject","focusTextBlock","selectionStartPoint","selectionStartPointChildKey","isKeySegment","inlineObject","child","children","isSpan","getSelectedValue","startPoint","endPoint","getSelectionEndPoint","startBlockKey","endBlockKey","startBlockIndex","endBlockIndex","slicedValue","slice","sliceBlocks","blocks","getSelectionText","reduce","text","block","isSelectionCollapsed","JSON","stringify","offset","isSelectionExpanded","getFocusChild","getChildKeyFromSelectionPoint","find","span","getFocusSpan","focusChild"],"mappings":"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"}
@@ -1,5 +1,5 @@
1
1
  import { getSelectionStartPoint, getBlockStartPoint } from "./util.slice-blocks.js";
2
- import { getFocusBlock, getSelectionText } from "./selector.is-selection-expanded.js";
2
+ import { getFocusBlock, getSelectionText } from "./selector.get-focus-span.js";
3
3
  const getBlockTextBefore = (snapshot) => {
4
4
  if (!snapshot.context.selection)
5
5
  return "";
@@ -1,8 +1,152 @@
1
- import { getBlockKeyFromSelectionPoint, getSelectionStartPoint, getSelectionEndPoint as getSelectionEndPoint$1, getChildKeyFromSelectionPoint, isTextBlock, isSpan$1 as isSpan, isSpan as isSpan$1, spanSelectionPointToBlockOffset, getBlockStartPoint, blockOffsetToSpanSelectionPoint, isListBlock } from "./util.slice-blocks.js";
2
- import { getSelectionStartPoint as getSelectionStartPoint$1, getFocusSpan, isSelectionCollapsed, getFocusTextBlock, getPreviousInlineObject, getSelectionText, isSelectionExpanded, getFocusBlock, getFocusChild } from "./selector.is-selection-expanded.js";
3
- import { getBlockEndPoint, isEmptyTextBlock, isEqualSelectionPoints } from "./util.is-equal-selection-points.js";
1
+ import { getSelectionEndPoint as getSelectionEndPoint$1, isTextBlock, getChildKeyFromSelectionPoint, isSpan, getSelectionStartPoint, getBlockKeyFromSelectionPoint, isSpan$1, spanSelectionPointToBlockOffset, getBlockStartPoint, blockOffsetToSpanSelectionPoint, isListBlock } from "./util.slice-blocks.js";
2
+ import { isSelectionCollapsed, getBlockEndPoint, isEmptyTextBlock, isEqualSelectionPoints } from "./util.is-selection-collapsed.js";
3
+ import { getFocusBlock, getSelectionStartPoint as getSelectionStartPoint$1, getFocusTextBlock, getFocusSpan, isSelectionCollapsed as isSelectionCollapsed$1, getPreviousInlineObject, getSelectionText, isSelectionExpanded as isSelectionExpanded$1, getFocusChild } from "./selector.get-focus-span.js";
4
4
  import { isKeySegment, isPortableTextSpan } from "@sanity/types";
5
- const getSelectedBlocks = (snapshot) => {
5
+ function isSelectionExpanded(selection) {
6
+ return selection ? !isSelectionCollapsed(selection) : !1;
7
+ }
8
+ const getSelectionEndBlock = (snapshot) => {
9
+ const endPoint = getSelectionEndPoint$1(snapshot.context.selection);
10
+ if (endPoint)
11
+ return getFocusBlock({
12
+ ...snapshot,
13
+ context: {
14
+ ...snapshot.context,
15
+ selection: {
16
+ anchor: endPoint,
17
+ focus: endPoint
18
+ }
19
+ }
20
+ });
21
+ }, getSelectionEndPoint = (snapshot) => {
22
+ if (snapshot.context.selection)
23
+ return snapshot.context.selection.backward ? snapshot.context.selection.anchor : snapshot.context.selection.focus;
24
+ }, getNextSpan = (snapshot) => {
25
+ const selectionEndBlock = getSelectionEndBlock(snapshot), selectionEndPoint = getSelectionEndPoint(snapshot);
26
+ if (!selectionEndBlock || !selectionEndPoint || !isTextBlock(snapshot.context, selectionEndBlock.node))
27
+ return;
28
+ const selectionEndPointChildKey = getChildKeyFromSelectionPoint(selectionEndPoint);
29
+ let endPointChildFound = !1, nextSpan;
30
+ for (const child of selectionEndBlock.node.children) {
31
+ if (child._key === selectionEndPointChildKey) {
32
+ endPointChildFound = !0;
33
+ continue;
34
+ }
35
+ if (isSpan(snapshot.context, child) && endPointChildFound) {
36
+ nextSpan = {
37
+ node: child,
38
+ path: [...selectionEndBlock.path, "children", {
39
+ _key: child._key
40
+ }]
41
+ };
42
+ break;
43
+ }
44
+ }
45
+ return nextSpan;
46
+ }, getSelectionStartBlock = (snapshot) => {
47
+ const startPoint = getSelectionStartPoint(snapshot.context.selection);
48
+ if (startPoint)
49
+ return getFocusBlock({
50
+ ...snapshot,
51
+ context: {
52
+ ...snapshot.context,
53
+ selection: {
54
+ anchor: startPoint,
55
+ focus: startPoint
56
+ }
57
+ }
58
+ });
59
+ }, getPreviousSpan = (snapshot) => {
60
+ const selectionStartBlock = getSelectionStartBlock(snapshot), selectionStartPoint = getSelectionStartPoint$1(snapshot);
61
+ if (!selectionStartBlock || !selectionStartPoint || !isTextBlock(snapshot.context, selectionStartBlock.node))
62
+ return;
63
+ const selectionStartPointChildKey = getChildKeyFromSelectionPoint(selectionStartPoint);
64
+ let previousSpan;
65
+ for (const child of selectionStartBlock.node.children) {
66
+ if (child._key === selectionStartPointChildKey)
67
+ break;
68
+ isSpan(snapshot.context, child) && (previousSpan = {
69
+ node: child,
70
+ path: [...selectionStartBlock.path, "children", {
71
+ _key: child._key
72
+ }]
73
+ });
74
+ }
75
+ return previousSpan;
76
+ }, getMarkState = (snapshot) => {
77
+ if (!snapshot.context.selection)
78
+ return;
79
+ const focusTextBlock = getFocusTextBlock(snapshot), focusSpan = getFocusSpan(snapshot);
80
+ if (!focusTextBlock || !focusSpan)
81
+ return;
82
+ if (isSelectionExpanded(snapshot.context.selection)) {
83
+ const selectedSpans = getSelectedSpans(snapshot);
84
+ let index = 0, marks2 = [];
85
+ for (const span of selectedSpans) {
86
+ if (index === 0)
87
+ marks2 = span.node.marks ?? [];
88
+ else {
89
+ if (span.node.marks?.length === 0) {
90
+ marks2 = [];
91
+ continue;
92
+ }
93
+ marks2 = marks2.filter((mark) => (span.node.marks ?? []).some((spanMark) => spanMark === mark));
94
+ }
95
+ index++;
96
+ }
97
+ return {
98
+ state: "unchanged",
99
+ marks: marks2
100
+ };
101
+ }
102
+ const decorators = snapshot.context.schema.decorators.map((decorator) => decorator.name), marks = focusSpan.node.marks ?? [], marksWithoutAnnotations = marks.filter((mark) => decorators.includes(mark)), spanHasAnnotations = marks.length > marksWithoutAnnotations.length, spanIsEmpty = focusSpan.node.text.length === 0, atTheBeginningOfSpan = snapshot.context.selection.anchor.offset === 0, atTheEndOfSpan = snapshot.context.selection.anchor.offset === focusSpan.node.text.length, previousSpan = getPreviousSpan(snapshot), nextSpan = getNextSpan(snapshot), nextSpanAnnotations = nextSpan?.node?.marks?.filter((mark) => !decorators.includes(mark)) ?? [], spanAnnotations = marks.filter((mark) => !decorators.includes(mark)), previousSpanHasAnnotations = previousSpan ? previousSpan.node.marks?.some((mark) => !decorators.includes(mark)) : !1, previousSpanHasSameAnnotations = previousSpan ? previousSpan.node.marks?.filter((mark) => !decorators.includes(mark)).every((mark) => marks.includes(mark)) : !1, previousSpanHasSameAnnotation = previousSpan ? previousSpan.node.marks?.some((mark) => !decorators.includes(mark) && marks.includes(mark)) : !1, previousSpanHasSameMarks = previousSpan ? previousSpan.node.marks?.every((mark) => marks.includes(mark)) : !1, nextSpanSharesSomeAnnotations = spanAnnotations.some((mark) => nextSpanAnnotations?.includes(mark));
103
+ if (spanHasAnnotations && !spanIsEmpty) {
104
+ if (atTheBeginningOfSpan) {
105
+ if (previousSpanHasSameMarks)
106
+ return {
107
+ state: "changed",
108
+ marks: previousSpan?.node.marks ?? []
109
+ };
110
+ if (previousSpanHasSameAnnotations)
111
+ return {
112
+ state: "changed",
113
+ marks: previousSpan?.node.marks ?? []
114
+ };
115
+ if (previousSpanHasSameAnnotation)
116
+ return {
117
+ state: "unchanged",
118
+ marks: focusSpan.node.marks ?? []
119
+ };
120
+ if (!previousSpan)
121
+ return {
122
+ state: "changed",
123
+ marks: []
124
+ };
125
+ }
126
+ if (atTheEndOfSpan) {
127
+ if (nextSpan && nextSpanSharesSomeAnnotations && nextSpanAnnotations.length < spanAnnotations.length || !nextSpanSharesSomeAnnotations)
128
+ return {
129
+ state: "changed",
130
+ marks: nextSpan?.node.marks ?? []
131
+ };
132
+ if (!nextSpan)
133
+ return {
134
+ state: "changed",
135
+ marks: []
136
+ };
137
+ }
138
+ }
139
+ return atTheBeginningOfSpan && !spanIsEmpty && previousSpan ? previousSpanHasAnnotations ? {
140
+ state: "changed",
141
+ marks: []
142
+ } : {
143
+ state: "changed",
144
+ marks: (previousSpan?.node.marks ?? []).filter((mark) => decorators.includes(mark))
145
+ } : {
146
+ state: "unchanged",
147
+ marks: focusSpan.node.marks ?? []
148
+ };
149
+ }, getSelectedBlocks = (snapshot) => {
6
150
  if (!snapshot.context.selection)
7
151
  return [];
8
152
  const selectedBlocks = [], startPoint = getSelectionStartPoint(snapshot.context.selection), endPoint = getSelectionEndPoint$1(snapshot.context.selection), startKey = getBlockKeyFromSelectionPoint(startPoint), endKey = getBlockKeyFromSelectionPoint(endPoint);
@@ -40,114 +184,10 @@ const getSelectedBlocks = (snapshot) => {
40
184
  });
41
185
  }
42
186
  return selectedBlocks;
43
- }, getSelectionEndPoint = (snapshot) => {
44
- if (snapshot.context.selection)
45
- return snapshot.context.selection.backward ? snapshot.context.selection.anchor : snapshot.context.selection.focus;
46
- }, getSelectedSpans = (snapshot) => {
47
- if (!snapshot.context.selection)
48
- return [];
49
- const selectedSpans = [], startPoint = getSelectionStartPoint$1(snapshot), endPoint = getSelectionEndPoint(snapshot);
50
- if (!startPoint || !endPoint)
51
- return selectedSpans;
52
- const startBlockKey = getBlockKeyFromSelectionPoint(startPoint), endBlockKey = getBlockKeyFromSelectionPoint(endPoint), startSpanKey = getChildKeyFromSelectionPoint(startPoint), endSpanKey = getChildKeyFromSelectionPoint(endPoint);
53
- if (!startBlockKey || !endBlockKey)
54
- return selectedSpans;
55
- const startBlockIndex = snapshot.blockIndexMap.get(startBlockKey), endBlockIndex = snapshot.blockIndexMap.get(endBlockKey);
56
- if (startBlockIndex === void 0 || endBlockIndex === void 0)
57
- return selectedSpans;
58
- const slicedValue = snapshot.context.value.slice(startBlockIndex, endBlockIndex + 1);
59
- let startBlockFound = !1;
60
- for (const block of slicedValue)
61
- if (block._key === startBlockKey && (startBlockFound = !0), !!isTextBlock(snapshot.context, block)) {
62
- if (block._key === startBlockKey) {
63
- for (const child of block.children)
64
- if (isSpan(snapshot.context, child)) {
65
- if (startSpanKey && child._key === startSpanKey) {
66
- if (startPoint.offset < child.text.length && selectedSpans.push({
67
- node: child,
68
- path: [{
69
- _key: block._key
70
- }, "children", {
71
- _key: child._key
72
- }]
73
- }), startSpanKey === endSpanKey)
74
- break;
75
- continue;
76
- }
77
- if (endSpanKey && child._key === endSpanKey) {
78
- endPoint.offset > 0 && selectedSpans.push({
79
- node: child,
80
- path: [{
81
- _key: block._key
82
- }, "children", {
83
- _key: child._key
84
- }]
85
- });
86
- break;
87
- }
88
- selectedSpans.length > 0 && selectedSpans.push({
89
- node: child,
90
- path: [{
91
- _key: block._key
92
- }, "children", {
93
- _key: child._key
94
- }]
95
- });
96
- }
97
- if (startBlockKey === endBlockKey)
98
- break;
99
- continue;
100
- }
101
- if (block._key === endBlockKey) {
102
- for (const child of block.children)
103
- if (isSpan(snapshot.context, child)) {
104
- if (endSpanKey && child._key === endSpanKey) {
105
- endPoint.offset > 0 && selectedSpans.push({
106
- node: child,
107
- path: [{
108
- _key: block._key
109
- }, "children", {
110
- _key: child._key
111
- }]
112
- });
113
- break;
114
- }
115
- selectedSpans.push({
116
- node: child,
117
- path: [{
118
- _key: block._key
119
- }, "children", {
120
- _key: child._key
121
- }]
122
- });
123
- }
124
- break;
125
- }
126
- if (startBlockFound)
127
- for (const child of block.children)
128
- isSpan(snapshot.context, child) && selectedSpans.push({
129
- node: child,
130
- path: [{
131
- _key: block._key
132
- }, "children", {
133
- _key: child._key
134
- }]
135
- });
136
- }
137
- return selectedSpans;
138
187
  }, getActiveAnnotations = (snapshot) => {
139
188
  if (!snapshot.context.selection)
140
189
  return [];
141
- const selectedBlocks = getSelectedBlocks(snapshot), selectedSpans = getSelectedSpans(snapshot), focusSpan = getFocusSpan(snapshot);
142
- if (selectedSpans.length === 0 || !focusSpan)
143
- return [];
144
- if (selectedSpans.length === 1 && isSelectionCollapsed(snapshot)) {
145
- if (snapshot.context.selection.focus.offset === 0)
146
- return [];
147
- if (snapshot.context.selection.focus.offset === focusSpan.node.text.length)
148
- return [];
149
- }
150
- const activeAnnotations = snapshot.beta.activeAnnotations;
190
+ const selectedBlocks = getSelectedBlocks(snapshot), activeAnnotations = (getMarkState(snapshot)?.marks ?? []).filter((mark) => !snapshot.context.schema.decorators.map((decorator) => decorator.name).includes(mark));
151
191
  return selectedBlocks.flatMap((block) => isTextBlock(snapshot.context, block.node) ? block.node.markDefs ?? [] : []).filter((markDef) => activeAnnotations.includes(markDef._key));
152
192
  }, getActiveListItem = (snapshot) => {
153
193
  if (!snapshot.context.selection)
@@ -189,7 +229,7 @@ const getSelectedBlocks = (snapshot) => {
189
229
  }
190
230
  return inlineObject;
191
231
  }, getCaretWordSelection = (snapshot) => {
192
- if (!snapshot.context.selection || !isSelectionCollapsed(snapshot))
232
+ if (!snapshot.context.selection || !isSelectionCollapsed$1(snapshot))
193
233
  return null;
194
234
  const focusTextBlock = getFocusTextBlock(snapshot), selectionStartPoint = getSelectionStartPoint$1(snapshot), selectionStartOffset = selectionStartPoint ? spanSelectionPointToBlockOffset({
195
235
  context: snapshot.context,
@@ -251,7 +291,7 @@ const getSelectedBlocks = (snapshot) => {
251
291
  anchor: caretWordStartSelectionPoint,
252
292
  focus: caretWordEndSelectionPoint
253
293
  };
254
- return isSelectionExpanded({
294
+ return isSelectionExpanded$1({
255
295
  context: {
256
296
  ...snapshot.context,
257
297
  selection: caretWordSelection
@@ -291,19 +331,6 @@ const getSelectedBlocks = (snapshot) => {
291
331
  _key: node._key
292
332
  }]
293
333
  } : void 0;
294
- }, getSelectionEndBlock = (snapshot) => {
295
- const endPoint = getSelectionEndPoint$1(snapshot.context.selection);
296
- if (endPoint)
297
- return getFocusBlock({
298
- ...snapshot,
299
- context: {
300
- ...snapshot.context,
301
- selection: {
302
- anchor: endPoint,
303
- focus: endPoint
304
- }
305
- }
306
- });
307
334
  }, getNextBlock = (snapshot) => {
308
335
  const selectionEndBlock = getSelectionEndBlock(snapshot);
309
336
  if (!selectionEndBlock)
@@ -318,19 +345,6 @@ const getSelectedBlocks = (snapshot) => {
318
345
  _key: nextBlock._key
319
346
  }]
320
347
  } : void 0;
321
- }, getSelectionStartBlock = (snapshot) => {
322
- const startPoint = getSelectionStartPoint(snapshot.context.selection);
323
- if (startPoint)
324
- return getFocusBlock({
325
- ...snapshot,
326
- context: {
327
- ...snapshot.context,
328
- selection: {
329
- anchor: startPoint,
330
- focus: startPoint
331
- }
332
- }
333
- });
334
348
  }, getPreviousBlock = (snapshot) => {
335
349
  const selectionStartBlock = getSelectionStartBlock(snapshot);
336
350
  if (!selectionStartBlock)
@@ -345,6 +359,98 @@ const getSelectedBlocks = (snapshot) => {
345
359
  _key: previousBlock._key
346
360
  }]
347
361
  } : void 0;
362
+ }, getSelectedSpans = (snapshot) => {
363
+ if (!snapshot.context.selection)
364
+ return [];
365
+ const selectedSpans = [], startPoint = getSelectionStartPoint$1(snapshot), endPoint = getSelectionEndPoint(snapshot);
366
+ if (!startPoint || !endPoint)
367
+ return selectedSpans;
368
+ const startBlockKey = getBlockKeyFromSelectionPoint(startPoint), endBlockKey = getBlockKeyFromSelectionPoint(endPoint), startSpanKey = getChildKeyFromSelectionPoint(startPoint), endSpanKey = getChildKeyFromSelectionPoint(endPoint);
369
+ if (!startBlockKey || !endBlockKey)
370
+ return selectedSpans;
371
+ const startBlockIndex = snapshot.blockIndexMap.get(startBlockKey), endBlockIndex = snapshot.blockIndexMap.get(endBlockKey);
372
+ if (startBlockIndex === void 0 || endBlockIndex === void 0)
373
+ return selectedSpans;
374
+ const slicedValue = snapshot.context.value.slice(startBlockIndex, endBlockIndex + 1);
375
+ let startBlockFound = !1;
376
+ for (const block of slicedValue)
377
+ if (block._key === startBlockKey && (startBlockFound = !0), !!isTextBlock(snapshot.context, block)) {
378
+ if (block._key === startBlockKey) {
379
+ for (const child of block.children)
380
+ if (isSpan(snapshot.context, child)) {
381
+ if (startSpanKey && child._key === startSpanKey) {
382
+ if (startPoint.offset < child.text.length && selectedSpans.push({
383
+ node: child,
384
+ path: [{
385
+ _key: block._key
386
+ }, "children", {
387
+ _key: child._key
388
+ }]
389
+ }), startSpanKey === endSpanKey)
390
+ break;
391
+ continue;
392
+ }
393
+ if (endSpanKey && child._key === endSpanKey) {
394
+ endPoint.offset > 0 && selectedSpans.push({
395
+ node: child,
396
+ path: [{
397
+ _key: block._key
398
+ }, "children", {
399
+ _key: child._key
400
+ }]
401
+ });
402
+ break;
403
+ }
404
+ selectedSpans.length > 0 && selectedSpans.push({
405
+ node: child,
406
+ path: [{
407
+ _key: block._key
408
+ }, "children", {
409
+ _key: child._key
410
+ }]
411
+ });
412
+ }
413
+ if (startBlockKey === endBlockKey)
414
+ break;
415
+ continue;
416
+ }
417
+ if (block._key === endBlockKey) {
418
+ for (const child of block.children)
419
+ if (isSpan(snapshot.context, child)) {
420
+ if (endSpanKey && child._key === endSpanKey) {
421
+ endPoint.offset > 0 && selectedSpans.push({
422
+ node: child,
423
+ path: [{
424
+ _key: block._key
425
+ }, "children", {
426
+ _key: child._key
427
+ }]
428
+ });
429
+ break;
430
+ }
431
+ selectedSpans.push({
432
+ node: child,
433
+ path: [{
434
+ _key: block._key
435
+ }, "children", {
436
+ _key: child._key
437
+ }]
438
+ });
439
+ }
440
+ break;
441
+ }
442
+ if (startBlockFound)
443
+ for (const child of block.children)
444
+ isSpan(snapshot.context, child) && selectedSpans.push({
445
+ node: child,
446
+ path: [{
447
+ _key: block._key
448
+ }, "children", {
449
+ _key: child._key
450
+ }]
451
+ });
452
+ }
453
+ return selectedSpans;
348
454
  }, getSelectedTextBlocks = (snapshot) => {
349
455
  if (!snapshot.context.selection)
350
456
  return [];
@@ -454,7 +560,7 @@ const getSelectedBlocks = (snapshot) => {
454
560
  anchor: adjustedStartPoint ?? startPoint,
455
561
  focus: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint
456
562
  };
457
- if (isSelectionCollapsed({
563
+ if (isSelectionCollapsed$1({
458
564
  context: {
459
565
  ...snapshot.context,
460
566
  selection: trimmedSelection
@@ -472,16 +578,30 @@ const getSelectedBlocks = (snapshot) => {
472
578
  }
473
579
  return trimmedSelection;
474
580
  };
581
+ function getActiveAnnotationsMarks(snapshot) {
582
+ const schema = snapshot.context.schema;
583
+ return (getMarkState(snapshot)?.marks ?? []).filter((mark) => !schema.decorators.map((decorator) => decorator.name).includes(mark));
584
+ }
475
585
  function isActiveAnnotation(annotation) {
476
- return (snapshot) => getSelectedBlocks(snapshot).flatMap((block) => isTextBlock(snapshot.context, block.node) ? block.node.markDefs ?? [] : []).filter((markDef) => markDef._type === annotation && snapshot.beta.activeAnnotations.includes(markDef._key)).length > 0;
586
+ return (snapshot) => {
587
+ const selectionMarkDefs = getSelectedBlocks(snapshot).flatMap((block) => isTextBlock(snapshot.context, block.node) ? block.node.markDefs ?? [] : []), activeAnnotations = getActiveAnnotationsMarks(snapshot);
588
+ return selectionMarkDefs.filter((markDef) => markDef._type === annotation && activeAnnotations.includes(markDef._key)).length > 0;
589
+ };
590
+ }
591
+ function getActiveDecorators(snapshot) {
592
+ const schema = snapshot.context.schema, decoratorState = snapshot.decoratorState, markState = getMarkState(snapshot), decorators = schema.decorators.map((decorator) => decorator.name);
593
+ let activeDecorators = (markState?.marks ?? []).filter((mark) => decorators.includes(mark));
594
+ for (const decorator in decoratorState)
595
+ decoratorState[decorator] === !1 ? activeDecorators = activeDecorators.filter((activeDecorator) => activeDecorator !== decorator) : decoratorState[decorator] === !0 && (activeDecorators.includes(decorator) || activeDecorators.push(decorator));
596
+ return activeDecorators;
477
597
  }
478
598
  function isActiveDecorator(decorator) {
479
599
  return (snapshot) => {
480
- if (isSelectionExpanded(snapshot)) {
600
+ if (isSelectionExpanded$1(snapshot)) {
481
601
  const selectedSpans = getSelectedSpans(snapshot);
482
602
  return selectedSpans.length > 0 && selectedSpans.every((span) => span.node.marks?.includes(decorator));
483
603
  }
484
- return snapshot.beta.activeDecorators.includes(decorator);
604
+ return getActiveDecorators(snapshot).includes(decorator);
485
605
  };
486
606
  }
487
607
  function isActiveListItem(listItem) {
@@ -492,7 +612,7 @@ function isActiveStyle(style) {
492
612
  }
493
613
  function isAtTheEndOfBlock(block) {
494
614
  return (snapshot) => {
495
- if (!snapshot.context.selection || !isSelectionCollapsed(snapshot))
615
+ if (!snapshot.context.selection || !isSelectionCollapsed$1(snapshot))
496
616
  return !1;
497
617
  const blockEndPoint = getBlockEndPoint({
498
618
  context: snapshot.context,
@@ -503,7 +623,7 @@ function isAtTheEndOfBlock(block) {
503
623
  }
504
624
  function isAtTheStartOfBlock(block) {
505
625
  return (snapshot) => {
506
- if (!snapshot.context.selection || !isSelectionCollapsed(snapshot))
626
+ if (!snapshot.context.selection || !isSelectionCollapsed$1(snapshot))
507
627
  return !1;
508
628
  const blockStartPoint = getBlockStartPoint({
509
629
  context: snapshot.context,
@@ -640,6 +760,8 @@ const isSelectingEntireBlocks = (snapshot) => {
640
760
  };
641
761
  export {
642
762
  getActiveAnnotations,
763
+ getActiveAnnotationsMarks,
764
+ getActiveDecorators,
643
765
  getActiveListItem,
644
766
  getActiveStyle,
645
767
  getCaretWordSelection,
@@ -648,6 +770,7 @@ export {
648
770
  getFocusInlineObject,
649
771
  getFocusListBlock,
650
772
  getLastBlock,
773
+ getMarkState,
651
774
  getNextBlock,
652
775
  getNextInlineObject,
653
776
  getPreviousBlock,