slate-vue3 0.13.6 → 0.13.8

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 (211) hide show
  1. package/dist/hyperscript.js +122 -37
  2. package/dist/{packages/slate-hyperscript → slate-hyperscript}/creators.d.ts +7 -1
  3. package/dist/{packages/slate-hyperscript → slate-hyperscript}/hyperscript.d.ts +3 -2
  4. package/dist/{packages/slate-hyperscript → slate-hyperscript}/index.d.ts +4 -2
  5. package/dist/slate-hyperscript/refs.d.ts +19 -0
  6. package/dist/slate-hyperscript/tokens.d.ts +54 -0
  7. package/package.json +2 -2
  8. package/dist/packages/slate-hyperscript/tokens.d.ts +0 -44
  9. package/dist/playwright.config.d.ts +0 -9
  10. /package/dist/{packages/share-tools → share-tools}/index.d.ts +0 -0
  11. /package/dist/{packages/slate → slate}/core/apply.d.ts +0 -0
  12. /package/dist/{packages/slate → slate}/core/batch-dirty-paths.d.ts +0 -0
  13. /package/dist/{packages/slate → slate}/core/get-dirty-paths.d.ts +0 -0
  14. /package/dist/{packages/slate → slate}/core/get-fragment.d.ts +0 -0
  15. /package/dist/{packages/slate → slate}/core/index.d.ts +0 -0
  16. /package/dist/{packages/slate → slate}/core/normalize-node.d.ts +0 -0
  17. /package/dist/{packages/slate → slate}/core/should-normalize.d.ts +0 -0
  18. /package/dist/{packages/slate → slate}/core/update-dirty-paths.d.ts +0 -0
  19. /package/dist/{packages/slate → slate}/create-editor.d.ts +0 -0
  20. /package/dist/{packages/slate → slate}/editor/above.d.ts +0 -0
  21. /package/dist/{packages/slate → slate}/editor/add-mark.d.ts +0 -0
  22. /package/dist/{packages/slate → slate}/editor/after.d.ts +0 -0
  23. /package/dist/{packages/slate → slate}/editor/before.d.ts +0 -0
  24. /package/dist/{packages/slate → slate}/editor/delete-backward.d.ts +0 -0
  25. /package/dist/{packages/slate → slate}/editor/delete-forward.d.ts +0 -0
  26. /package/dist/{packages/slate → slate}/editor/delete-fragment.d.ts +0 -0
  27. /package/dist/{packages/slate → slate}/editor/edges.d.ts +0 -0
  28. /package/dist/{packages/slate → slate}/editor/element-read-only.d.ts +0 -0
  29. /package/dist/{packages/slate → slate}/editor/end.d.ts +0 -0
  30. /package/dist/{packages/slate → slate}/editor/first.d.ts +0 -0
  31. /package/dist/{packages/slate → slate}/editor/fragment.d.ts +0 -0
  32. /package/dist/{packages/slate → slate}/editor/get-void.d.ts +0 -0
  33. /package/dist/{packages/slate → slate}/editor/has-blocks.d.ts +0 -0
  34. /package/dist/{packages/slate → slate}/editor/has-inlines.d.ts +0 -0
  35. /package/dist/{packages/slate → slate}/editor/has-path.d.ts +0 -0
  36. /package/dist/{packages/slate → slate}/editor/has-texts.d.ts +0 -0
  37. /package/dist/{packages/slate → slate}/editor/index.d.ts +0 -0
  38. /package/dist/{packages/slate → slate}/editor/insert-break.d.ts +0 -0
  39. /package/dist/{packages/slate → slate}/editor/insert-node.d.ts +0 -0
  40. /package/dist/{packages/slate → slate}/editor/insert-soft-break.d.ts +0 -0
  41. /package/dist/{packages/slate → slate}/editor/insert-text.d.ts +0 -0
  42. /package/dist/{packages/slate → slate}/editor/is-block.d.ts +0 -0
  43. /package/dist/{packages/slate → slate}/editor/is-edge.d.ts +0 -0
  44. /package/dist/{packages/slate → slate}/editor/is-editor.d.ts +0 -0
  45. /package/dist/{packages/slate → slate}/editor/is-empty.d.ts +0 -0
  46. /package/dist/{packages/slate → slate}/editor/is-end.d.ts +0 -0
  47. /package/dist/{packages/slate → slate}/editor/is-normalizing.d.ts +0 -0
  48. /package/dist/{packages/slate → slate}/editor/is-start.d.ts +0 -0
  49. /package/dist/{packages/slate → slate}/editor/last.d.ts +0 -0
  50. /package/dist/{packages/slate → slate}/editor/leaf.d.ts +0 -0
  51. /package/dist/{packages/slate → slate}/editor/levels.d.ts +0 -0
  52. /package/dist/{packages/slate → slate}/editor/marks.d.ts +0 -0
  53. /package/dist/{packages/slate → slate}/editor/next.d.ts +0 -0
  54. /package/dist/{packages/slate → slate}/editor/node.d.ts +0 -0
  55. /package/dist/{packages/slate → slate}/editor/nodes.d.ts +0 -0
  56. /package/dist/{packages/slate → slate}/editor/normalize.d.ts +0 -0
  57. /package/dist/{packages/slate → slate}/editor/parent.d.ts +0 -0
  58. /package/dist/{packages/slate → slate}/editor/path-ref.d.ts +0 -0
  59. /package/dist/{packages/slate → slate}/editor/path-refs.d.ts +0 -0
  60. /package/dist/{packages/slate → slate}/editor/path.d.ts +0 -0
  61. /package/dist/{packages/slate → slate}/editor/point-ref.d.ts +0 -0
  62. /package/dist/{packages/slate → slate}/editor/point-refs.d.ts +0 -0
  63. /package/dist/{packages/slate → slate}/editor/point.d.ts +0 -0
  64. /package/dist/{packages/slate → slate}/editor/positions.d.ts +0 -0
  65. /package/dist/{packages/slate → slate}/editor/previous.d.ts +0 -0
  66. /package/dist/{packages/slate → slate}/editor/range-ref.d.ts +0 -0
  67. /package/dist/{packages/slate → slate}/editor/range-refs.d.ts +0 -0
  68. /package/dist/{packages/slate → slate}/editor/range.d.ts +0 -0
  69. /package/dist/{packages/slate → slate}/editor/remove-mark.d.ts +0 -0
  70. /package/dist/{packages/slate → slate}/editor/set-normalizing.d.ts +0 -0
  71. /package/dist/{packages/slate → slate}/editor/should-merge-nodes-remove-prev-node.d.ts +0 -0
  72. /package/dist/{packages/slate → slate}/editor/start.d.ts +0 -0
  73. /package/dist/{packages/slate → slate}/editor/string.d.ts +0 -0
  74. /package/dist/{packages/slate → slate}/editor/unhang-range.d.ts +0 -0
  75. /package/dist/{packages/slate → slate}/editor/without-normalizing.d.ts +0 -0
  76. /package/dist/{packages/slate → slate}/index.d.ts +0 -0
  77. /package/dist/{packages/slate → slate}/interfaces/editor.d.ts +0 -0
  78. /package/dist/{packages/slate → slate}/interfaces/element.d.ts +0 -0
  79. /package/dist/{packages/slate → slate}/interfaces/index.d.ts +0 -0
  80. /package/dist/{packages/slate → slate}/interfaces/location.d.ts +0 -0
  81. /package/dist/{packages/slate → slate}/interfaces/node.d.ts +0 -0
  82. /package/dist/{packages/slate → slate}/interfaces/operation.d.ts +0 -0
  83. /package/dist/{packages/slate → slate}/interfaces/path-ref.d.ts +0 -0
  84. /package/dist/{packages/slate → slate}/interfaces/path.d.ts +0 -0
  85. /package/dist/{packages/slate → slate}/interfaces/point-ref.d.ts +0 -0
  86. /package/dist/{packages/slate → slate}/interfaces/point.d.ts +0 -0
  87. /package/dist/{packages/slate → slate}/interfaces/range-ref.d.ts +0 -0
  88. /package/dist/{packages/slate → slate}/interfaces/range.d.ts +0 -0
  89. /package/dist/{packages/slate → slate}/interfaces/scrubber.d.ts +0 -0
  90. /package/dist/{packages/slate → slate}/interfaces/text.d.ts +0 -0
  91. /package/dist/{packages/slate → slate}/interfaces/transforms/general.d.ts +0 -0
  92. /package/dist/{packages/slate → slate}/interfaces/transforms/index.d.ts +0 -0
  93. /package/dist/{packages/slate → slate}/interfaces/transforms/node.d.ts +0 -0
  94. /package/dist/{packages/slate → slate}/interfaces/transforms/selection.d.ts +0 -0
  95. /package/dist/{packages/slate → slate}/interfaces/transforms/text.d.ts +0 -0
  96. /package/dist/{packages/slate → slate}/transforms-node/index.d.ts +0 -0
  97. /package/dist/{packages/slate → slate}/transforms-node/insert-nodes.d.ts +0 -0
  98. /package/dist/{packages/slate → slate}/transforms-node/lift-nodes.d.ts +0 -0
  99. /package/dist/{packages/slate → slate}/transforms-node/merge-nodes.d.ts +0 -0
  100. /package/dist/{packages/slate → slate}/transforms-node/move-nodes.d.ts +0 -0
  101. /package/dist/{packages/slate → slate}/transforms-node/remove-nodes.d.ts +0 -0
  102. /package/dist/{packages/slate → slate}/transforms-node/set-nodes.d.ts +0 -0
  103. /package/dist/{packages/slate → slate}/transforms-node/split-nodes.d.ts +0 -0
  104. /package/dist/{packages/slate → slate}/transforms-node/unset-nodes.d.ts +0 -0
  105. /package/dist/{packages/slate → slate}/transforms-node/unwrap-nodes.d.ts +0 -0
  106. /package/dist/{packages/slate → slate}/transforms-node/wrap-nodes.d.ts +0 -0
  107. /package/dist/{packages/slate → slate}/transforms-selection/collapse.d.ts +0 -0
  108. /package/dist/{packages/slate → slate}/transforms-selection/deselect.d.ts +0 -0
  109. /package/dist/{packages/slate → slate}/transforms-selection/index.d.ts +0 -0
  110. /package/dist/{packages/slate → slate}/transforms-selection/move.d.ts +0 -0
  111. /package/dist/{packages/slate → slate}/transforms-selection/select.d.ts +0 -0
  112. /package/dist/{packages/slate → slate}/transforms-selection/set-point.d.ts +0 -0
  113. /package/dist/{packages/slate → slate}/transforms-selection/set-selection.d.ts +0 -0
  114. /package/dist/{packages/slate → slate}/transforms-text/delete-text.d.ts +0 -0
  115. /package/dist/{packages/slate → slate}/transforms-text/index.d.ts +0 -0
  116. /package/dist/{packages/slate → slate}/transforms-text/insert-fragment.d.ts +0 -0
  117. /package/dist/{packages/slate → slate}/types/custom-types.d.ts +0 -0
  118. /package/dist/{packages/slate → slate}/types/index.d.ts +0 -0
  119. /package/dist/{packages/slate → slate}/types/types.d.ts +0 -0
  120. /package/dist/{packages/slate → slate}/utils/deep-equal.d.ts +0 -0
  121. /package/dist/{packages/slate → slate}/utils/get-default-insert-location.d.ts +0 -0
  122. /package/dist/{packages/slate → slate}/utils/index.d.ts +0 -0
  123. /package/dist/{packages/slate → slate}/utils/is-object.d.ts +0 -0
  124. /package/dist/{packages/slate → slate}/utils/match-path.d.ts +0 -0
  125. /package/dist/{packages/slate → slate}/utils/string.d.ts +0 -0
  126. /package/dist/{packages/slate → slate}/utils/types.d.ts +0 -0
  127. /package/dist/{packages/slate → slate}/utils/weak-maps.d.ts +0 -0
  128. /package/dist/{packages/slate-dom → slate-dom}/chunking/children-helper.d.ts +0 -0
  129. /package/dist/{packages/slate-dom → slate-dom}/chunking/chunk-tree-helper.d.ts +0 -0
  130. /package/dist/{packages/slate-dom → slate-dom}/chunking/get-chunk-tree-for-node.d.ts +0 -0
  131. /package/dist/{packages/slate-dom → slate-dom}/chunking/index.d.ts +0 -0
  132. /package/dist/{packages/slate-dom → slate-dom}/chunking/reconcile-children.d.ts +0 -0
  133. /package/dist/{packages/slate-dom → slate-dom}/chunking/types.d.ts +0 -0
  134. /package/dist/{packages/slate-dom → slate-dom}/custom-types.d.ts +0 -0
  135. /package/dist/{packages/slate-dom → slate-dom}/index.d.ts +0 -0
  136. /package/dist/{packages/slate-dom → slate-dom}/plugin/dom-editor.d.ts +0 -0
  137. /package/dist/{packages/slate-dom → slate-dom}/plugin/with-dom.d.ts +0 -0
  138. /package/dist/{packages/slate-dom → slate-dom}/utils/diff-text.d.ts +0 -0
  139. /package/dist/{packages/slate-dom → slate-dom}/utils/dom.d.ts +0 -0
  140. /package/dist/{packages/slate-dom → slate-dom}/utils/environment.d.ts +0 -0
  141. /package/dist/{packages/slate-dom → slate-dom}/utils/hotkeys.d.ts +0 -0
  142. /package/dist/{packages/slate-dom → slate-dom}/utils/key.d.ts +0 -0
  143. /package/dist/{packages/slate-dom → slate-dom}/utils/lines.d.ts +0 -0
  144. /package/dist/{packages/slate-dom → slate-dom}/utils/range-list.d.ts +0 -0
  145. /package/dist/{packages/slate-dom → slate-dom}/utils/types.d.ts +0 -0
  146. /package/dist/{packages/slate-dom → slate-dom}/utils/weak-maps.d.ts +0 -0
  147. /package/dist/{packages/slate-history → slate-history}/history-editor.d.ts +0 -0
  148. /package/dist/{packages/slate-history → slate-history}/history.d.ts +0 -0
  149. /package/dist/{packages/slate-history → slate-history}/index.d.ts +0 -0
  150. /package/dist/{packages/slate-history → slate-history}/with-history.d.ts +0 -0
  151. /package/dist/{packages/slate-vue → slate-vue}/components/children.d.ts +0 -0
  152. /package/dist/{packages/slate-vue → slate-vue}/components/chunk.d.ts +0 -0
  153. /package/dist/{packages/slate-vue → slate-vue}/components/editable.d.ts +0 -0
  154. /package/dist/{packages/slate-vue → slate-vue}/components/element.d.ts +0 -0
  155. /package/dist/{packages/slate-vue → slate-vue}/components/leaf.d.ts +0 -0
  156. /package/dist/{packages/slate-vue → slate-vue}/components/placeholder.d.ts +0 -0
  157. /package/dist/{packages/slate-vue → slate-vue}/components/slate.d.ts +0 -0
  158. /package/dist/{packages/slate-vue → slate-vue}/components/string.d.ts +0 -0
  159. /package/dist/{packages/slate-vue → slate-vue}/components/text.d.ts +0 -0
  160. /package/dist/{packages/slate-vue → slate-vue}/components/utils.d.ts +0 -0
  161. /package/dist/{packages/slate-vue → slate-vue}/hooks/use-android-manager.d.ts +0 -0
  162. /package/dist/{packages/slate-vue → slate-vue}/hooks/use-composing.d.ts +0 -0
  163. /package/dist/{packages/slate-vue → slate-vue}/hooks/use-editor.d.ts +0 -0
  164. /package/dist/{packages/slate-vue → slate-vue}/hooks/use-element.d.ts +0 -0
  165. /package/dist/{packages/slate-vue → slate-vue}/hooks/use-focused.d.ts +0 -0
  166. /package/dist/{packages/slate-vue → slate-vue}/hooks/use-inherit-ref.d.ts +0 -0
  167. /package/dist/{packages/slate-vue → slate-vue}/hooks/use-read-only.d.ts +0 -0
  168. /package/dist/{packages/slate-vue → slate-vue}/hooks/use-selected.d.ts +0 -0
  169. /package/dist/{packages/slate-vue → slate-vue}/hooks/use-selection.d.ts +0 -0
  170. /package/dist/{packages/slate-vue → slate-vue}/index.d.ts +0 -0
  171. /package/dist/{packages/slate-vue → slate-vue}/render/chunk.d.ts +0 -0
  172. /package/dist/{packages/slate-vue → slate-vue}/render/decorate.d.ts +0 -0
  173. /package/dist/{packages/slate-vue → slate-vue}/render/fn.d.ts +0 -0
  174. /package/dist/{packages/slate-vue → slate-vue}/render/last.d.ts +0 -0
  175. /package/dist/{packages/slate-vue → slate-vue}/render/placeholder.d.ts +0 -0
  176. /package/dist/{packages/slate-vue → slate-vue}/render/version.d.ts +0 -0
  177. /package/dist/{packages/slate-vue → slate-vue}/utils/constants.d.ts +0 -0
  178. /package/dist/{packages/slate-vue → slate-vue}/utils/interface.d.ts +0 -0
  179. /package/dist/{packages/slate-yjs → slate-yjs}/applyToSlate/index.d.ts +0 -0
  180. /package/dist/{packages/slate-yjs → slate-yjs}/applyToSlate/textEvent.d.ts +0 -0
  181. /package/dist/{packages/slate-yjs → slate-yjs}/applyToYjs/index.d.ts +0 -0
  182. /package/dist/{packages/slate-yjs → slate-yjs}/applyToYjs/node/index.d.ts +0 -0
  183. /package/dist/{packages/slate-yjs → slate-yjs}/applyToYjs/node/insertNode.d.ts +0 -0
  184. /package/dist/{packages/slate-yjs → slate-yjs}/applyToYjs/node/mergeNode.d.ts +0 -0
  185. /package/dist/{packages/slate-yjs → slate-yjs}/applyToYjs/node/moveNode.d.ts +0 -0
  186. /package/dist/{packages/slate-yjs → slate-yjs}/applyToYjs/node/removeNode.d.ts +0 -0
  187. /package/dist/{packages/slate-yjs → slate-yjs}/applyToYjs/node/setNode.d.ts +0 -0
  188. /package/dist/{packages/slate-yjs → slate-yjs}/applyToYjs/node/splitNode.d.ts +0 -0
  189. /package/dist/{packages/slate-yjs → slate-yjs}/applyToYjs/text/index.d.ts +0 -0
  190. /package/dist/{packages/slate-yjs → slate-yjs}/applyToYjs/text/insertText.d.ts +0 -0
  191. /package/dist/{packages/slate-yjs → slate-yjs}/applyToYjs/text/removeText.d.ts +0 -0
  192. /package/dist/{packages/slate-yjs → slate-yjs}/applyToYjs/types.d.ts +0 -0
  193. /package/dist/{packages/slate-yjs → slate-yjs}/hooks/useDecorateRemoteCursors.d.ts +0 -0
  194. /package/dist/{packages/slate-yjs → slate-yjs}/hooks/useRemoteCursorOverlayPositions.d.ts +0 -0
  195. /package/dist/{packages/slate-yjs → slate-yjs}/hooks/useRemoteCursorStates.d.ts +0 -0
  196. /package/dist/{packages/slate-yjs → slate-yjs}/hooks/useUnsetCursorPositionOnBlur.d.ts +0 -0
  197. /package/dist/{packages/slate-yjs → slate-yjs}/hooks/utils.d.ts +0 -0
  198. /package/dist/{packages/slate-yjs → slate-yjs}/index.d.ts +0 -0
  199. /package/dist/{packages/slate-yjs → slate-yjs}/model/types.d.ts +0 -0
  200. /package/dist/{packages/slate-yjs → slate-yjs}/plugins/index.d.ts +0 -0
  201. /package/dist/{packages/slate-yjs → slate-yjs}/plugins/withCursors.d.ts +0 -0
  202. /package/dist/{packages/slate-yjs → slate-yjs}/plugins/withYHistory.d.ts +0 -0
  203. /package/dist/{packages/slate-yjs → slate-yjs}/plugins/withYjs.d.ts +0 -0
  204. /package/dist/{packages/slate-yjs → slate-yjs}/utils/clone.d.ts +0 -0
  205. /package/dist/{packages/slate-yjs → slate-yjs}/utils/convert.d.ts +0 -0
  206. /package/dist/{packages/slate-yjs → slate-yjs}/utils/delta.d.ts +0 -0
  207. /package/dist/{packages/slate-yjs → slate-yjs}/utils/location.d.ts +0 -0
  208. /package/dist/{packages/slate-yjs → slate-yjs}/utils/object.d.ts +0 -0
  209. /package/dist/{packages/slate-yjs → slate-yjs}/utils/position.d.ts +0 -0
  210. /package/dist/{packages/slate-yjs → slate-yjs}/utils/slate.d.ts +0 -0
  211. /package/dist/{packages/slate-yjs → slate-yjs}/utils/yjs.d.ts +0 -0
@@ -2,48 +2,88 @@ import { R as Range, N as Node, T as Text, a as Element, e as isObject } from ".
2
2
  import { h as createEditor$1 } from "./create-editor-D66_fXbO.js";
3
3
  import "vue";
4
4
  import { t as toRawWeakMap } from "./index-Ban80MbP.js";
5
- const ANCHOR = new toRawWeakMap();
6
- const FOCUS = new toRawWeakMap();
5
+ const ANCHORS = new toRawWeakMap();
6
+ const FOCI = new toRawWeakMap();
7
+ const POINTS = new toRawWeakMap();
7
8
  class Token {
8
- }
9
- class AnchorToken extends Token {
10
9
  offset;
11
10
  path;
11
+ ref;
12
12
  constructor(props = {}) {
13
- super();
14
- const { offset, path } = props;
13
+ const { offset, path, ref } = props;
15
14
  this.offset = offset;
16
15
  this.path = path;
16
+ if (ref) {
17
+ if (path != null) {
18
+ throw new Error(
19
+ "The ref prop of a token cannot be used with the path prop."
20
+ );
21
+ }
22
+ this.ref = ref;
23
+ }
17
24
  }
18
25
  }
26
+ class AnchorToken extends Token {
27
+ }
19
28
  class FocusToken extends Token {
20
- offset;
21
- path;
22
- constructor(props = {}) {
23
- super();
24
- const { offset, path } = props;
25
- this.offset = offset;
26
- this.path = path;
29
+ }
30
+ class PointToken extends Token {
31
+ }
32
+ function addAnchorToken(text, token) {
33
+ const offset = text.text.length;
34
+ let anchors = ANCHORS.get(text);
35
+ if (!anchors) {
36
+ anchors = /* @__PURE__ */ new Set();
37
+ ANCHORS.set(text, anchors);
27
38
  }
39
+ anchors.add([offset, token]);
40
+ }
41
+ function getAnchors(text) {
42
+ const anchors = ANCHORS.get(text);
43
+ if (!anchors) return [];
44
+ return Array.from(
45
+ anchors.values(),
46
+ ([offset, token]) => new AnchorToken({ ...token, offset })
47
+ );
28
48
  }
29
- const addAnchorToken = (text, token) => {
49
+ function addFocusToken(text, token) {
30
50
  const offset = text.text.length;
31
- ANCHOR.set(text, [offset, token]);
32
- };
33
- const getAnchorOffset = (text) => {
34
- return ANCHOR.get(text);
35
- };
36
- const addFocusToken = (text, token) => {
51
+ let foci = FOCI.get(text);
52
+ if (!foci) {
53
+ foci = /* @__PURE__ */ new Set();
54
+ FOCI.set(text, foci);
55
+ }
56
+ foci.add([offset, token]);
57
+ }
58
+ function getFoci(text) {
59
+ const foci = FOCI.get(text);
60
+ if (!foci) return [];
61
+ return Array.from(
62
+ foci.values(),
63
+ ([offset, token]) => new FocusToken({ ...token, offset })
64
+ );
65
+ }
66
+ function addPointToken(text, token) {
37
67
  const offset = text.text.length;
38
- FOCUS.set(text, [offset, token]);
39
- };
40
- const getFocusOffset = (text) => {
41
- return FOCUS.get(text);
42
- };
68
+ let points = POINTS.get(text);
69
+ if (!points) {
70
+ points = /* @__PURE__ */ new Set();
71
+ POINTS.set(text, points);
72
+ }
73
+ points.add([offset, token]);
74
+ }
75
+ function getPoints(text) {
76
+ const points = POINTS.get(text);
77
+ if (!points) return [];
78
+ return Array.from(
79
+ points.values(),
80
+ ([offset, token]) => new PointToken({ ...token, offset })
81
+ );
82
+ }
43
83
  const STRINGS = /* @__PURE__ */ new WeakSet();
44
- const resolveDescendants = (children) => {
84
+ function resolveDescendants(children) {
45
85
  const nodes = [];
46
- const addChild = (child) => {
86
+ function addChild(child) {
47
87
  if (child == null) {
48
88
  return;
49
89
  }
@@ -72,16 +112,18 @@ const resolveDescendants = (children) => {
72
112
  addAnchorToken(n, child);
73
113
  } else if (child instanceof FocusToken) {
74
114
  addFocusToken(n, child);
115
+ } else if (child instanceof PointToken) {
116
+ addPointToken(n, child);
75
117
  }
76
118
  } else {
77
119
  throw new Error(`Unexpected hyperscript child object: ${child}`);
78
120
  }
79
- };
121
+ }
80
122
  for (const child of children.flat(Infinity)) {
81
123
  addChild(child);
82
124
  }
83
125
  return nodes;
84
- };
126
+ }
85
127
  function createAnchor(tagName, attributes, children) {
86
128
  return new AnchorToken(attributes);
87
129
  }
@@ -97,6 +139,9 @@ function createFocus(tagName, attributes, children) {
97
139
  function createFragment(tagName, attributes, children) {
98
140
  return resolveDescendants(children);
99
141
  }
142
+ function createPoint(tagName, attributes, children) {
143
+ return new PointToken(attributes);
144
+ }
100
145
  function createSelection(tagName, attributes, children) {
101
146
  const anchor = children.find(
102
147
  (c) => c instanceof AnchorToken
@@ -161,15 +206,21 @@ const createEditor = (makeEditor) => (tagName, attributes, children) => {
161
206
  Object.assign(editor, attributes);
162
207
  editor.children = descendants;
163
208
  for (const [node, path] of Node.texts(editor)) {
164
- const anchor = getAnchorOffset(node);
165
- const focus = getFocusOffset(node);
166
- if (anchor != null) {
167
- const [offset] = anchor;
168
- selection.anchor = { path, offset };
209
+ for (const { ref = selection, offset } of getAnchors(node)) {
210
+ if (offset != null) {
211
+ ref.anchor = { path, offset };
212
+ }
213
+ }
214
+ for (const { ref = selection, offset } of getFoci(node)) {
215
+ if (offset != null) {
216
+ ref.focus = { path, offset };
217
+ }
169
218
  }
170
- if (focus != null) {
171
- const [offset] = focus;
172
- selection.focus = { path, offset };
219
+ for (const { ref, offset } of getPoints(node)) {
220
+ if (ref) {
221
+ ref.offset = offset;
222
+ ref.path = path;
223
+ }
173
224
  }
174
225
  }
175
226
  if (selection.anchor && !selection.focus) {
@@ -196,6 +247,7 @@ const DEFAULT_CREATORS = {
196
247
  element: createElement,
197
248
  focus: createFocus,
198
249
  fragment: createFragment,
250
+ point: createPoint,
199
251
  selection: createSelection,
200
252
  text: createText
201
253
  };
@@ -244,8 +296,41 @@ const normalizeElements = (elements) => {
244
296
  }
245
297
  return creators;
246
298
  };
299
+ class HyperscriptPointRef {
300
+ path;
301
+ offset;
302
+ point() {
303
+ const { path, offset } = this;
304
+ if (path == null || offset == null) {
305
+ throw new Error(
306
+ "A HyperscriptPointRef must be passed as the ref prop of a <point /> tag that is used inside an <editor>."
307
+ );
308
+ }
309
+ return { path, offset };
310
+ }
311
+ }
312
+ class HyperscriptRangeRef {
313
+ anchor;
314
+ focus;
315
+ range() {
316
+ const { anchor, focus } = this;
317
+ if (anchor == null) {
318
+ throw new Error(
319
+ "A HyperscriptRangeRef must be passed as the ref prop of an <anchor /> tag that is used inside an <editor>."
320
+ );
321
+ }
322
+ if (focus == null) {
323
+ throw new Error(
324
+ "A HyperscriptRangeRef must be passed as the ref prop of a <focus /> tag that is used inside an <editor>."
325
+ );
326
+ }
327
+ return { anchor, focus };
328
+ }
329
+ }
247
330
  const jsx = createHyperscript();
248
331
  export {
332
+ HyperscriptPointRef,
333
+ HyperscriptRangeRef,
249
334
  createEditor,
250
335
  createHyperscript,
251
336
  createText,
@@ -1,5 +1,5 @@
1
1
  import { Element, Descendant, Range, Text, Editor } from '../slate/index.ts';
2
- import { AnchorToken, FocusToken, Token } from './tokens';
2
+ import { AnchorToken, FocusToken, PointToken, Token } from './tokens';
3
3
  /**
4
4
  * Create an anchor token.
5
5
  */
@@ -30,6 +30,12 @@ export declare function createFocus(tagName: string, attributes: {
30
30
  export declare function createFragment(tagName: string, attributes: {
31
31
  [key: string]: any;
32
32
  }, children: any[]): Descendant[];
33
+ /**
34
+ * Create a point token.
35
+ */
36
+ export declare function createPoint(tagName: string, attributes: {
37
+ [key: string]: any;
38
+ }, children: any[]): PointToken;
33
39
  /**
34
40
  * Create a `Selection` object.
35
41
  */
@@ -1,4 +1,4 @@
1
- import { createAnchor, createCursor, createElement, createFocus, createFragment, createSelection, createText } from './creators';
1
+ import { createAnchor, createCursor, createElement, createFocus, createPoint, createFragment, createSelection, createText } from './creators';
2
2
  /**
3
3
  * `HyperscriptCreators` are dictionaries of `HyperscriptCreator` functions
4
4
  * keyed by tag name.
@@ -18,7 +18,7 @@ type HyperscriptShorthands = Record<string, Record<string, any>>;
18
18
  declare const createHyperscript: (options?: {
19
19
  creators?: HyperscriptCreators;
20
20
  elements?: HyperscriptShorthands;
21
- }) => <S extends "anchor" | "focus" | "text" | "selection" | "fragment" | "element" | "editor" | "cursor">(tagName: S, attributes?: object, ...children: any[]) => ReturnType<{
21
+ }) => <S extends "anchor" | "focus" | "text" | "point" | "selection" | "fragment" | "element" | "editor" | "cursor">(tagName: S, attributes?: object, ...children: any[]) => ReturnType<{
22
22
  anchor: typeof createAnchor;
23
23
  cursor: typeof createCursor;
24
24
  editor: (tagName: string, attributes: {
@@ -27,6 +27,7 @@ declare const createHyperscript: (options?: {
27
27
  element: typeof createElement;
28
28
  focus: typeof createFocus;
29
29
  fragment: typeof createFragment;
30
+ point: typeof createPoint;
30
31
  selection: typeof createSelection;
31
32
  text: typeof createText;
32
33
  }[S]>;
@@ -1,9 +1,10 @@
1
1
  import { createHyperscript, HyperscriptCreators, HyperscriptShorthands } from './hyperscript';
2
2
  import { createEditor, createText } from './creators';
3
+ import { HyperscriptPointRef, HyperscriptRangeRef } from './refs';
3
4
  /**
4
5
  * The default hyperscript factory that ships with Slate, without custom tags.
5
6
  */
6
- declare const jsx: <S extends "anchor" | "focus" | "text" | "selection" | "fragment" | "element" | "editor" | "cursor">(tagName: S, attributes?: object, ...children: any[]) => ReturnType<{
7
+ declare const jsx: <S extends "anchor" | "focus" | "text" | "point" | "selection" | "fragment" | "element" | "editor" | "cursor">(tagName: S, attributes?: object, ...children: any[]) => ReturnType<{
7
8
  anchor: typeof import('./creators').createAnchor;
8
9
  cursor: typeof import('./creators').createCursor;
9
10
  editor: (tagName: string, attributes: {
@@ -12,7 +13,8 @@ declare const jsx: <S extends "anchor" | "focus" | "text" | "selection" | "fragm
12
13
  element: typeof import('./creators').createElement;
13
14
  focus: typeof import('./creators').createFocus;
14
15
  fragment: typeof import('./creators').createFragment;
16
+ point: typeof import('./creators').createPoint;
15
17
  selection: typeof import('./creators').createSelection;
16
18
  text: typeof createText;
17
19
  }[S]>;
18
- export { jsx, createHyperscript, createEditor, createText, HyperscriptCreators, HyperscriptShorthands, };
20
+ export { jsx, createHyperscript, createEditor, createText, HyperscriptCreators, HyperscriptPointRef, HyperscriptRangeRef, HyperscriptShorthands, };
@@ -0,0 +1,19 @@
1
+ import { Path, Point, Range } from '../slate/index.ts';
2
+ /**
3
+ * Hyperscript point refs can be used to construct arbitrary points using the
4
+ * ref prop of a <point /> tag.
5
+ */
6
+ export declare class HyperscriptPointRef {
7
+ path?: Path;
8
+ offset?: number;
9
+ point(): Point;
10
+ }
11
+ /**
12
+ * Hyperscript range refs can be used to construct arbitrary range using the ref
13
+ * props of <anchor /> and <focus /> tags.
14
+ */
15
+ export declare class HyperscriptRangeRef {
16
+ anchor?: Point;
17
+ focus?: Point;
18
+ range(): Range;
19
+ }
@@ -0,0 +1,54 @@
1
+ import { Path, Text } from '../slate/index.ts';
2
+ import { HyperscriptPointRef, HyperscriptRangeRef } from './refs';
3
+ /**
4
+ * All tokens inherit from a single constructor for `instanceof` checking.
5
+ */
6
+ export declare class Token<Ref = unknown> {
7
+ offset?: number;
8
+ path?: Path;
9
+ ref?: Ref;
10
+ constructor(props?: {
11
+ offset?: number;
12
+ path?: Path;
13
+ ref?: Ref;
14
+ });
15
+ }
16
+ /**
17
+ * Anchor tokens represent the selection's anchor point.
18
+ */
19
+ export declare class AnchorToken extends Token<HyperscriptRangeRef> {
20
+ }
21
+ /**
22
+ * Focus tokens represent the selection's focus point.
23
+ */
24
+ export declare class FocusToken extends Token<HyperscriptRangeRef> {
25
+ }
26
+ /**
27
+ * A weak map to hold point tokens.
28
+ */
29
+ export declare class PointToken extends Token<HyperscriptPointRef> {
30
+ }
31
+ /**
32
+ * Add an anchor token to the end of a text node.
33
+ */
34
+ export declare function addAnchorToken(text: Text, token: AnchorToken): void;
35
+ /**
36
+ * Get the associated anchor tokens for a text node.
37
+ */
38
+ export declare function getAnchors(text: Text): AnchorToken[];
39
+ /**
40
+ * Add a focus token to the end of a text node.
41
+ */
42
+ export declare function addFocusToken(text: Text, token: FocusToken): void;
43
+ /**
44
+ * Get the associated focus tokens for a text node.
45
+ */
46
+ export declare function getFoci(text: Text): FocusToken[];
47
+ /**
48
+ * Add a point token to the end of a text node.
49
+ */
50
+ export declare function addPointToken(text: Text, token: PointToken): void;
51
+ /**
52
+ * Get the associated point tokens for a text node.
53
+ */
54
+ export declare function getPoints(text: Text): PointToken[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slate-vue3",
3
- "version": "0.13.6",
3
+ "version": "0.13.8",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -82,7 +82,7 @@
82
82
  "@faker-js/faker": "^10.4.0",
83
83
  "@liveblocks/client": "^3.18.2",
84
84
  "@liveblocks/yjs": "^3.18.2",
85
- "@playwright/test": "^1.59.1",
85
+ "@playwright/test": "^1.60.0",
86
86
  "@testing-library/vue": "^8.1.0",
87
87
  "@types/is-hotkey": "^0.1.10",
88
88
  "@types/is-url": "^1.2.32",
@@ -1,44 +0,0 @@
1
- import { Path, Text } from '../slate/index.ts';
2
- /**
3
- * All tokens inherit from a single constructor for `instanceof` checking.
4
- */
5
- export declare class Token {
6
- }
7
- /**
8
- * Anchor tokens represent the selection's anchor point.
9
- */
10
- export declare class AnchorToken extends Token {
11
- offset?: number;
12
- path?: Path;
13
- constructor(props?: {
14
- offset?: number;
15
- path?: Path;
16
- });
17
- }
18
- /**
19
- * Focus tokens represent the selection's focus point.
20
- */
21
- export declare class FocusToken extends Token {
22
- offset?: number;
23
- path?: Path;
24
- constructor(props?: {
25
- offset?: number;
26
- path?: Path;
27
- });
28
- }
29
- /**
30
- * Add an anchor token to the end of a text node.
31
- */
32
- export declare const addAnchorToken: (text: Text, token: AnchorToken) => void;
33
- /**
34
- * Get the offset if a text node has an associated anchor token.
35
- */
36
- export declare const getAnchorOffset: (text: Text) => [number, AnchorToken] | undefined;
37
- /**
38
- * Add a focus token to the end of a text node.
39
- */
40
- export declare const addFocusToken: (text: Text, token: FocusToken) => void;
41
- /**
42
- * Get the offset if a text node has an associated focus token.
43
- */
44
- export declare const getFocusOffset: (text: Text) => [number, FocusToken] | undefined;
@@ -1,9 +0,0 @@
1
- /**
2
- * Read environment variables from file.
3
- * https://github.com/motdotla/dotenv
4
- */
5
- /**
6
- * See https://playwright.dev/docs/test-configuration.
7
- */
8
- declare const _default: import('@playwright/test').PlaywrightTestConfig<{}, {}>;
9
- export default _default;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes