slate-vue3 0.7.3 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{batch-dirty-paths-DTifjYae.js → batch-dirty-paths-BGS8X5pd.js} +30 -1
- package/dist/core.js +4 -3
- package/dist/{create-editor-BQTV3YKB.js → create-editor-ZZEkf55h.js} +3 -2
- package/dist/dom.js +3 -3
- package/dist/history.js +1 -1
- package/dist/{hotkeys-BF9U1Pfk.js → hotkeys-BU4HmwiB.js} +1 -1
- package/dist/hyperscript.js +2 -2
- package/dist/index.js +5 -5
- package/dist/{location-V9fJlEiJ.js → location-D4Ys3xEt.js} +1 -1
- package/dist/share-tools/index.d.ts +17 -0
- package/dist/slate/editor/is-editor.d.ts +2 -0
- package/dist/slate-vue/components/children.d.ts +1 -1
- package/dist/slate-vue/components/utils.d.ts +1 -1
- package/dist/slate-vue/hooks/use-editor.d.ts +8 -2
- package/dist/{use-focused-DcDZV3X4.js → use-focused-BypegJ1d.js} +54 -30
- package/dist/yjs.js +4 -4
- package/package.json +1 -1
|
@@ -33,6 +33,31 @@ class toRawWeakMap extends WeakMap {
|
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
class toRawWeakSet extends WeakSet {
|
|
37
|
+
constructor() {
|
|
38
|
+
super();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Removes the specified element from the toRawWeakSet.
|
|
42
|
+
* @returns true if the element was successfully removed, or false if it was not present.
|
|
43
|
+
*/
|
|
44
|
+
delete(value) {
|
|
45
|
+
return super.delete(isProxy(value) ? toRaw(value) : value);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @returns a boolean indicating whether an element with the specified value exists or not.
|
|
49
|
+
*/
|
|
50
|
+
has(value) {
|
|
51
|
+
return super.has(isProxy(value) ? toRaw(value) : value);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Adds a new element with a specified value.
|
|
55
|
+
* @param value Must be an object or symbol.
|
|
56
|
+
*/
|
|
57
|
+
add(value) {
|
|
58
|
+
return super.add(isProxy(value) ? toRaw(value) : value);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
36
61
|
const DIRTY_PATHS = new toRawWeakMap();
|
|
37
62
|
const DIRTY_PATH_KEYS = new toRawWeakMap();
|
|
38
63
|
const FLUSHING = new toRawWeakMap();
|
|
@@ -1802,8 +1827,11 @@ const Operation = {
|
|
|
1802
1827
|
}
|
|
1803
1828
|
}
|
|
1804
1829
|
};
|
|
1805
|
-
new
|
|
1830
|
+
const IS_EDITOR_SET = new toRawWeakSet();
|
|
1806
1831
|
const isEditor = (value, { deep = false } = {}) => {
|
|
1832
|
+
if (IS_EDITOR_SET.has(value)) {
|
|
1833
|
+
return true;
|
|
1834
|
+
}
|
|
1807
1835
|
if (!isObject$1(value)) {
|
|
1808
1836
|
return false;
|
|
1809
1837
|
}
|
|
@@ -2256,6 +2284,7 @@ export {
|
|
|
2256
2284
|
DIRTY_PATHS as D,
|
|
2257
2285
|
Editor as E,
|
|
2258
2286
|
FLUSHING as F,
|
|
2287
|
+
IS_EDITOR_SET as I,
|
|
2259
2288
|
Node as N,
|
|
2260
2289
|
Operation as O,
|
|
2261
2290
|
Path as P,
|
package/dist/core.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { a6, a7, a8, d, e, f, a, h, aj, c, i, j, k, ap, ak, l, m, o, p, q, g, b, r, t, u, v, w, x, aq, y, a9, z, A, B, C, D, E, F, G, H, I, J, aa, K, ab, al, ac, L, M, N, O, n, P, S, Q, R, V, T, U, W, X, _, Y, Z, $, ad, am, ae, a0, an, ao, a5, s, af, a1, a2, a3, ag, ah, a4, ai } from "./create-editor-
|
|
2
|
-
import { E as E2, a as a10, N as N2, O as O2, P as P2, b as b2, R as R2, S as S2, T as T2, c as c2, i as i2, d as d2 } from "./batch-dirty-paths-
|
|
3
|
-
import { L as L2, S as S3 } from "./location-
|
|
1
|
+
import { a6, a7, a8, d, e, f, a, h, aj, c, i, j, k, ap, ak, l, m, o, p, q, g, b, r, t, u, v, w, x, aq, y, a9, z, A, B, C, D, E, F, G, H, I, J, aa, K, ab, al, ac, L, M, N, O, n, P, S, Q, R, V, T, U, W, X, _, Y, Z, $, ad, am, ae, a0, an, ao, a5, s, af, a1, a2, a3, ag, ah, a4, ai } from "./create-editor-ZZEkf55h.js";
|
|
2
|
+
import { E as E2, a as a10, I as I2, N as N2, O as O2, P as P2, b as b2, R as R2, S as S2, T as T2, c as c2, i as i2, d as d2 } from "./batch-dirty-paths-BGS8X5pd.js";
|
|
3
|
+
import { L as L2, S as S3 } from "./location-D4Ys3xEt.js";
|
|
4
4
|
export {
|
|
5
5
|
E2 as Editor,
|
|
6
6
|
a10 as Element,
|
|
7
|
+
I2 as IS_EDITOR_SET,
|
|
7
8
|
L2 as Location,
|
|
8
9
|
N2 as Node,
|
|
9
10
|
O2 as Operation,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as Path, b as Point, R as Range, E as Editor, D as DIRTY_PATHS, e as DIRTY_PATH_KEYS, f as isBatchingDirtyPaths, c as Transforms, F as FLUSHING, T as Text, N as Node, a as Element, g as NORMALIZING, h as PATH_REFS, j as POINT_REFS, k as RANGE_REFS, l as cloneDeep, m as getDefaultInsertLocation, S as Scrubber, n as batchDirtyPaths } from "./batch-dirty-paths-
|
|
1
|
+
import { P as Path, b as Point, R as Range, E as Editor, D as DIRTY_PATHS, e as DIRTY_PATH_KEYS, f as isBatchingDirtyPaths, c as Transforms, F as FLUSHING, T as Text, N as Node, a as Element, g as NORMALIZING, h as PATH_REFS, j as POINT_REFS, k as RANGE_REFS, l as cloneDeep, m as getDefaultInsertLocation, S as Scrubber, n as batchDirtyPaths, I as IS_EDITOR_SET } from "./batch-dirty-paths-BGS8X5pd.js";
|
|
2
2
|
import { reactive } from "vue";
|
|
3
|
-
import { S as Span } from "./location-
|
|
3
|
+
import { S as Span } from "./location-D4Ys3xEt.js";
|
|
4
4
|
const PathRef = {
|
|
5
5
|
transform(ref, op) {
|
|
6
6
|
const { current, affinity } = ref;
|
|
@@ -2494,6 +2494,7 @@ const createEditor = () => {
|
|
|
2494
2494
|
wrapNodes: (...args) => wrapNodes(editor, ...args),
|
|
2495
2495
|
shouldMergeNodesRemovePrevNode: (...args) => shouldMergeNodesRemovePrevNode(editor, ...args)
|
|
2496
2496
|
});
|
|
2497
|
+
IS_EDITOR_SET.add(editor);
|
|
2497
2498
|
return editor;
|
|
2498
2499
|
};
|
|
2499
2500
|
export {
|
package/dist/dom.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DOMEditor, E as EDITOR_TO_KEY_TO_ELEMENT, a as EDITOR_TO_USER_MARKS, g as getChunkTreeForNode, b as EDITOR_TO_USER_SELECTION, N as NODE_TO_KEY, i as isDOMText, c as getPlainText, d as getSlateFragmentAttribute, e as EDITOR_TO_ON_CHANGE } from "./hotkeys-
|
|
2
|
-
import { C, J, L, M, H, F, I, v, O, w, x, P, y, Q, A, z, B, G, K, R, S, T, U, f, h, j, k, l, m, o, p, q, r, s, t, u, n } from "./hotkeys-
|
|
3
|
-
import { E as Editor, R as Range, a as Element, c as Transforms, N as Node, P as Path } from "./batch-dirty-paths-
|
|
1
|
+
import { D as DOMEditor, E as EDITOR_TO_KEY_TO_ELEMENT, a as EDITOR_TO_USER_MARKS, g as getChunkTreeForNode, b as EDITOR_TO_USER_SELECTION, N as NODE_TO_KEY, i as isDOMText, c as getPlainText, d as getSlateFragmentAttribute, e as EDITOR_TO_ON_CHANGE } from "./hotkeys-BU4HmwiB.js";
|
|
2
|
+
import { C, J, L, M, H, F, I, v, O, w, x, P, y, Q, A, z, B, G, K, R, S, T, U, f, h, j, k, l, m, o, p, q, r, s, t, u, n } from "./hotkeys-BU4HmwiB.js";
|
|
3
|
+
import { E as Editor, R as Range, a as Element, c as Transforms, N as Node, P as Path } from "./batch-dirty-paths-BGS8X5pd.js";
|
|
4
4
|
import "vue";
|
|
5
5
|
const doRectsIntersect = (rect, compareRect) => {
|
|
6
6
|
const middle = (compareRect.top + compareRect.bottom) / 2;
|
package/dist/history.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as isObject, O as Operation, t as toRawWeakMap, E as Editor, c as Transforms, P as Path } from "./batch-dirty-paths-
|
|
1
|
+
import { d as isObject, O as Operation, t as toRawWeakMap, E as Editor, c as Transforms, P as Path } from "./batch-dirty-paths-BGS8X5pd.js";
|
|
2
2
|
import "vue";
|
|
3
3
|
const History = {
|
|
4
4
|
/**
|
|
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
var _a, _b;
|
|
5
|
-
import { t as toRawWeakMap, R as Range, E as Editor, S as Scrubber, a as Element, c as Transforms, P as Path } from "./batch-dirty-paths-
|
|
5
|
+
import { t as toRawWeakMap, R as Range, E as Editor, S as Scrubber, a as Element, c as Transforms, P as Path } from "./batch-dirty-paths-BGS8X5pd.js";
|
|
6
6
|
import { toRaw, reactive } from "vue";
|
|
7
7
|
const getDefaultView = (value) => {
|
|
8
8
|
return value && value.ownerDocument && value.ownerDocument.defaultView || null;
|
package/dist/hyperscript.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { t as toRawWeakMap, R as Range, N as Node, T as Text, a as Element, d as isObject } from "./batch-dirty-paths-
|
|
5
|
-
import { c as createEditor$1 } from "./create-editor-
|
|
4
|
+
import { t as toRawWeakMap, R as Range, N as Node, T as Text, a as Element, d as isObject } from "./batch-dirty-paths-BGS8X5pd.js";
|
|
5
|
+
import { c as createEditor$1 } from "./create-editor-ZZEkf55h.js";
|
|
6
6
|
import "vue";
|
|
7
7
|
const ANCHOR = new toRawWeakMap();
|
|
8
8
|
const FOCUS = new toRawWeakMap();
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { S as SLATE_USE_ELEMENT, u as useEditor, a as SLATE_USE_SELECTION } from "./use-focused-
|
|
2
|
-
import { g, D, c, e, f, d, E, b, h, i, j } from "./use-focused-
|
|
3
|
-
import { E as Editor, R as Range } from "./batch-dirty-paths-
|
|
4
|
-
import { t } from "./batch-dirty-paths-
|
|
1
|
+
import { S as SLATE_USE_ELEMENT, u as useEditor, a as SLATE_USE_SELECTION } from "./use-focused-BypegJ1d.js";
|
|
2
|
+
import { g, D, c, e, f, d, E, b, h, i, j } from "./use-focused-BypegJ1d.js";
|
|
3
|
+
import { E as Editor, R as Range } from "./batch-dirty-paths-BGS8X5pd.js";
|
|
4
|
+
import { t } from "./batch-dirty-paths-BGS8X5pd.js";
|
|
5
5
|
import { inject, computed } from "vue";
|
|
6
|
-
import { D as DOMEditor } from "./hotkeys-
|
|
6
|
+
import { D as DOMEditor } from "./hotkeys-BU4HmwiB.js";
|
|
7
7
|
const useElement = () => {
|
|
8
8
|
const element = inject(SLATE_USE_ELEMENT);
|
|
9
9
|
if (element === void 0) {
|
|
@@ -19,3 +19,20 @@ export declare class toRawWeakMap<K extends WeakKey, V> extends WeakMap {
|
|
|
19
19
|
*/
|
|
20
20
|
set(key: K, value: V): this;
|
|
21
21
|
}
|
|
22
|
+
export declare class toRawWeakSet<T extends WeakKey> extends WeakSet<T> {
|
|
23
|
+
constructor();
|
|
24
|
+
/**
|
|
25
|
+
* Removes the specified element from the toRawWeakSet.
|
|
26
|
+
* @returns true if the element was successfully removed, or false if it was not present.
|
|
27
|
+
*/
|
|
28
|
+
delete(value: T): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* @returns a boolean indicating whether an element with the specified value exists or not.
|
|
31
|
+
*/
|
|
32
|
+
has(value: T): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Adds a new element with a specified value.
|
|
35
|
+
* @param value Must be an object or symbol.
|
|
36
|
+
*/
|
|
37
|
+
add(value: T): this;
|
|
38
|
+
}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { EditorInterface } from '../interfaces/editor';
|
|
2
|
+
import { toRawWeakSet as WeakSet } from '../../share-tools/index.ts';
|
|
3
|
+
export declare const IS_EDITOR_SET: WeakSet<import('../interfaces/editor').BaseEditor>;
|
|
2
4
|
export declare const isEditor: EditorInterface['isEditor'];
|
|
@@ -7,6 +7,6 @@ export declare const ChildrenComp: import('vue').DefineComponent<{
|
|
|
7
7
|
element: Ancestor;
|
|
8
8
|
}, () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
9
9
|
[key: string]: any;
|
|
10
|
-
}> | import('vue').VNodeChild[], {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{
|
|
10
|
+
}> | import('vue').VNodeChild[] | undefined, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{
|
|
11
11
|
element: Ancestor;
|
|
12
12
|
}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -27,7 +27,7 @@ export declare const DEFAULT_LEAF_RENDER: ({ attributes, children, }: RenderLeaf
|
|
|
27
27
|
export declare const DEFAULT_TEXT_RENDER: ({ attributes, children, }: RenderTextProps) => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
28
28
|
[key: string]: any;
|
|
29
29
|
}>;
|
|
30
|
-
export declare const DEFAULT_CHUNK_RENDER: ({ children
|
|
30
|
+
export declare const DEFAULT_CHUNK_RENDER: ({ children }: RenderChunkProps) => any;
|
|
31
31
|
export declare const DEFAULT_PLACEHOLDER_RENDER: ({ attributes, children, }: RenderPlaceholderProps) => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
32
32
|
[key: string]: any;
|
|
33
33
|
}>;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import { Reactive } from 'vue';
|
|
1
2
|
import { DOMEditor } from '../../slate-dom/index.ts';
|
|
2
3
|
/**
|
|
3
|
-
* Get the current editor object from the
|
|
4
|
+
* Get the current editor reactive object from the context.
|
|
4
5
|
*/
|
|
5
|
-
export declare const useEditor: () => DOMEditor
|
|
6
|
+
export declare const useEditor: () => Reactive<DOMEditor>;
|
|
7
|
+
/**
|
|
8
|
+
* Get the current editor raw object from the context
|
|
9
|
+
* it won't trigger rerender when children and selection change
|
|
10
|
+
*/
|
|
11
|
+
export declare const useEditorStatic: () => DOMEditor;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { h, defineComponent, provide, ref, computed, onMounted, onUnmounted, renderSlot, inject, watch, renderList, onUpdated, useAttrs, reactive
|
|
2
|
-
import { R as Range, N as Node, S as Scrubber, T as Text, P as Path, E as Editor, a as Element, c as Transforms } from "./batch-dirty-paths-
|
|
3
|
-
import { I as IS_ANDROID, q as isDOMNode, D as DOMEditor, R as MARK_PLACEHOLDER_SYMBOL, e as EDITOR_TO_ON_CHANGE, w as IS_FIREFOX, z as IS_WEBKIT, E as EDITOR_TO_KEY_TO_ELEMENT, M as ELEMENT_TO_NODE, S as NODE_TO_ELEMENT, T as NODE_TO_INDEX, U as NODE_TO_PARENT, g as getChunkTreeForNode, f as applyStringDiff, r as isDOMSelection, n as normalizeStringDiff, Q as IS_READ_ONLY, j as getDefaultView, L as EDITOR_TO_WINDOW, J as EDITOR_TO_ELEMENT, H as HAS_BEFORE_INPUT_SUPPORT, C as CAN_USE_DOM, h as getActiveElement, k as getSelection, P as IS_FOCUSED, s as isPlainTextOnlyPaste, O as IS_COMPOSING, F as Hotkeys, v as IS_CHROME, x as IS_FIREFOX_LEGACY, y as IS_IOS, B as IS_WECHATBROWSER, A as IS_UC_MOBILE, a as EDITOR_TO_USER_MARKS, p as isDOMElement, b as EDITOR_TO_USER_SELECTION } from "./hotkeys-
|
|
1
|
+
import { h, defineComponent, provide, ref, computed, onMounted, onUnmounted, renderSlot, inject, watch, renderList, onUpdated, toRaw, useAttrs, reactive } from "vue";
|
|
2
|
+
import { R as Range, N as Node, S as Scrubber, T as Text, P as Path, E as Editor, a as Element, c as Transforms } from "./batch-dirty-paths-BGS8X5pd.js";
|
|
3
|
+
import { I as IS_ANDROID, q as isDOMNode, D as DOMEditor, R as MARK_PLACEHOLDER_SYMBOL, e as EDITOR_TO_ON_CHANGE, w as IS_FIREFOX, z as IS_WEBKIT, E as EDITOR_TO_KEY_TO_ELEMENT, M as ELEMENT_TO_NODE, S as NODE_TO_ELEMENT, T as NODE_TO_INDEX, U as NODE_TO_PARENT, g as getChunkTreeForNode, f as applyStringDiff, r as isDOMSelection, n as normalizeStringDiff, Q as IS_READ_ONLY, j as getDefaultView, L as EDITOR_TO_WINDOW, J as EDITOR_TO_ELEMENT, H as HAS_BEFORE_INPUT_SUPPORT, C as CAN_USE_DOM, h as getActiveElement, k as getSelection, P as IS_FOCUSED, s as isPlainTextOnlyPaste, O as IS_COMPOSING, F as Hotkeys, v as IS_CHROME, x as IS_FIREFOX_LEGACY, y as IS_IOS, B as IS_WECHATBROWSER, A as IS_UC_MOBILE, a as EDITOR_TO_USER_MARKS, p as isDOMElement, b as EDITOR_TO_USER_SELECTION } from "./hotkeys-BU4HmwiB.js";
|
|
4
4
|
const SLATE_USE_EDITOR = Symbol("SLATE_USE_EDITOR");
|
|
5
5
|
const SLATE_USE_ELEMENT = Symbol("SLATE_USE_ELEMENT");
|
|
6
6
|
const SLATE_USE_FOCUSED = Symbol("SLATE_USE_FOCUSED");
|
|
@@ -129,6 +129,15 @@ const handleNativeHistoryEvents = (editor, event) => {
|
|
|
129
129
|
const DEFAULT_SCROLL_INTO_VIEW = (editor, domRange) => {
|
|
130
130
|
if (domRange.getBoundingClientRect && (!editor.selection || editor.selection && Range.isCollapsed(editor.selection))) {
|
|
131
131
|
const leafEl = domRange.startContainer.parentElement;
|
|
132
|
+
const domRect = domRange.getBoundingClientRect();
|
|
133
|
+
const isZeroDimensionRect = domRect.width === 0 && domRect.height === 0 && domRect.x === 0 && domRect.y === 0;
|
|
134
|
+
if (isZeroDimensionRect) {
|
|
135
|
+
const leafRect = leafEl.getBoundingClientRect();
|
|
136
|
+
const leafHasDimensions = leafRect.width > 0 || leafRect.height > 0;
|
|
137
|
+
if (leafHasDimensions) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
132
141
|
leafEl.getBoundingClientRect = domRange.getBoundingClientRect.bind(domRange);
|
|
133
142
|
e(leafEl, {
|
|
134
143
|
scrollMode: "if-needed"
|
|
@@ -162,9 +171,7 @@ const DEFAULT_TEXT_RENDER = ({
|
|
|
162
171
|
attributes,
|
|
163
172
|
children
|
|
164
173
|
}) => h("span", attributes, children);
|
|
165
|
-
const DEFAULT_CHUNK_RENDER = ({
|
|
166
|
-
children
|
|
167
|
-
}) => children;
|
|
174
|
+
const DEFAULT_CHUNK_RENDER = ({ children }) => children;
|
|
168
175
|
const DEFAULT_PLACEHOLDER_RENDER = ({
|
|
169
176
|
attributes,
|
|
170
177
|
children
|
|
@@ -547,9 +554,19 @@ const TextComp = defineComponent({
|
|
|
547
554
|
}
|
|
548
555
|
});
|
|
549
556
|
const isLastText = computed(() => {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
557
|
+
if (Editor.isVoid(editor, element)) {
|
|
558
|
+
return false;
|
|
559
|
+
}
|
|
560
|
+
if (!Element.isElement(element)) {
|
|
561
|
+
return false;
|
|
562
|
+
}
|
|
563
|
+
if (editor.isInline(element)) {
|
|
564
|
+
return false;
|
|
565
|
+
}
|
|
566
|
+
if (!Editor.hasInlines(editor, element)) {
|
|
567
|
+
return false;
|
|
568
|
+
}
|
|
569
|
+
return NODE_TO_INDEX.get(text) === element.children.length - 1;
|
|
553
570
|
});
|
|
554
571
|
const renderLeaf = useRenderLeaf();
|
|
555
572
|
const renderText = useRenderText();
|
|
@@ -678,6 +695,7 @@ const ElementComp = defineComponent({
|
|
|
678
695
|
}
|
|
679
696
|
});
|
|
680
697
|
const ChunkComp = defineComponent({
|
|
698
|
+
name: "slate-chunk",
|
|
681
699
|
props: ["ancestor"],
|
|
682
700
|
setup(props) {
|
|
683
701
|
const ancestor = props.ancestor;
|
|
@@ -699,14 +717,32 @@ const ChunkComp = defineComponent({
|
|
|
699
717
|
}
|
|
700
718
|
});
|
|
701
719
|
const ChildrenComp = defineComponent({
|
|
720
|
+
name: "slate-children",
|
|
702
721
|
props: ["element"],
|
|
703
722
|
setup(props) {
|
|
704
|
-
const element = props.element;
|
|
705
723
|
const editor = useEditor();
|
|
706
|
-
const
|
|
707
|
-
|
|
708
|
-
|
|
724
|
+
const element = props.element;
|
|
725
|
+
const _vector = toRaw(element);
|
|
726
|
+
const isBlock = !Editor.isEditor(element) && Element.isElement(element) && !editor.isInline(element);
|
|
727
|
+
const renderElementOrText = () => renderList(element.children, (n2, i) => {
|
|
728
|
+
NODE_TO_INDEX.set(n2, i);
|
|
729
|
+
NODE_TO_PARENT.set(n2, _vector);
|
|
730
|
+
const key = DOMEditor.findKey(editor, n2);
|
|
731
|
+
return Text.isText(n2) ? h(TextComp, {
|
|
732
|
+
text: n2,
|
|
733
|
+
element,
|
|
734
|
+
key: key.id
|
|
735
|
+
}) : h(ElementComp, {
|
|
736
|
+
element: n2,
|
|
737
|
+
key: key.id
|
|
738
|
+
});
|
|
709
739
|
});
|
|
740
|
+
if (isBlock) {
|
|
741
|
+
return renderElementOrText;
|
|
742
|
+
}
|
|
743
|
+
const chunkSize = computed(
|
|
744
|
+
() => Editor.hasInlines(editor, element) ? null : editor.getChunkSize(element)
|
|
745
|
+
);
|
|
710
746
|
const chunkTree = computed(() => {
|
|
711
747
|
if (!chunkSize.value) {
|
|
712
748
|
return null;
|
|
@@ -716,11 +752,11 @@ const ChildrenComp = defineComponent({
|
|
|
716
752
|
chunkSize: chunkSize.value,
|
|
717
753
|
onInsert: (n2, i) => {
|
|
718
754
|
NODE_TO_INDEX.set(n2, i);
|
|
719
|
-
NODE_TO_PARENT.set(n2,
|
|
755
|
+
NODE_TO_PARENT.set(n2, _vector);
|
|
720
756
|
},
|
|
721
757
|
onUpdate: (n2, i) => {
|
|
722
758
|
NODE_TO_INDEX.set(n2, i);
|
|
723
|
-
NODE_TO_PARENT.set(n2,
|
|
759
|
+
NODE_TO_PARENT.set(n2, _vector);
|
|
724
760
|
},
|
|
725
761
|
onIndexChange: (n2, i) => {
|
|
726
762
|
NODE_TO_INDEX.set(n2, i);
|
|
@@ -728,23 +764,11 @@ const ChildrenComp = defineComponent({
|
|
|
728
764
|
}
|
|
729
765
|
});
|
|
730
766
|
});
|
|
731
|
-
provide(SLATE_INNER_STATIC_CHUNK, chunkTree.value);
|
|
767
|
+
provide(SLATE_INNER_STATIC_CHUNK, chunkTree.value || null);
|
|
732
768
|
return () => {
|
|
733
769
|
if (chunkSize.value === null) {
|
|
734
|
-
return
|
|
735
|
-
|
|
736
|
-
NODE_TO_PARENT.set(n2, element);
|
|
737
|
-
const key = DOMEditor.findKey(editor, n2);
|
|
738
|
-
return Text.isText(n2) ? h(TextComp, {
|
|
739
|
-
text: n2,
|
|
740
|
-
element,
|
|
741
|
-
key: key.id
|
|
742
|
-
}) : h(ElementComp, {
|
|
743
|
-
element: n2,
|
|
744
|
-
key: key.id
|
|
745
|
-
});
|
|
746
|
-
});
|
|
747
|
-
} else {
|
|
770
|
+
return renderElementOrText();
|
|
771
|
+
} else if (chunkTree) {
|
|
748
772
|
return h(ChunkComp, {
|
|
749
773
|
ancestor: chunkTree.value
|
|
750
774
|
});
|
package/dist/yjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { d as isObject, T as Text, N as Node, P as Path, E as Editor, t as toRawWeakMap, c as Transforms, R as Range } from "./batch-dirty-paths-
|
|
1
|
+
import { d as isObject, T as Text, N as Node, P as Path, E as Editor, t as toRawWeakMap, c as Transforms, R as Range } from "./batch-dirty-paths-BGS8X5pd.js";
|
|
2
2
|
import { toRaw, ref, onMounted, onUnmounted, watch, onUpdated, computed } from "vue";
|
|
3
3
|
import { XmlText, YTextEvent, createRelativePositionFromTypeIndex, createAbsolutePositionFromRelativePosition, createRelativePositionFromJSON, decodeRelativePosition, encodeRelativePosition, UndoManager, compareRelativePositions } from "yjs";
|
|
4
|
-
import { L as Location } from "./location-
|
|
5
|
-
import { u as useEditor, i as useFocused } from "./use-focused-
|
|
6
|
-
import { D as DOMEditor } from "./hotkeys-
|
|
4
|
+
import { L as Location } from "./location-D4Ys3xEt.js";
|
|
5
|
+
import { u as useEditor, i as useFocused } from "./use-focused-BypegJ1d.js";
|
|
6
|
+
import { D as DOMEditor } from "./hotkeys-BU4HmwiB.js";
|
|
7
7
|
function deepEquals(node, another) {
|
|
8
8
|
for (const key in node) {
|
|
9
9
|
const a = node[key];
|