slate-vue3 0.1.1 → 0.1.2
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-BNjNom-v.js → batch-dirty-paths-X-eP3GRL.js} +7 -7
- package/dist/core.js +3 -3
- package/dist/{create-editor-D-lN_Ejd.js → create-editor-BFFWnObb.js} +2 -2
- package/dist/dom.js +3 -3
- package/dist/history.js +1 -1
- package/dist/{hotkeys-B_EjNsx-.js → hotkeys-u-dgagSM.js} +1 -1
- package/dist/hyperscript.js +2 -2
- package/dist/index.js +2 -2
- package/dist/{location-j9dF8XY5.js → location-CeJ1rJSq.js} +1 -1
- package/dist/slate-yjs/plugins/withYjs.d.ts +2 -13
- package/dist/yjs.js +8 -55
- package/package.json +1 -1
|
@@ -2369,14 +2369,14 @@ export {
|
|
|
2369
2369
|
Point as b,
|
|
2370
2370
|
Transforms as c,
|
|
2371
2371
|
isPlainObject as d,
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2372
|
+
DIRTY_PATH_KEYS as e,
|
|
2373
|
+
isBatchingDirtyPaths as f,
|
|
2374
|
+
NORMALIZING as g,
|
|
2375
|
+
PATH_REFS as h,
|
|
2376
2376
|
isEditor as i,
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2377
|
+
POINT_REFS as j,
|
|
2378
|
+
RANGE_REFS as k,
|
|
2379
|
+
cloneDeep as l,
|
|
2380
2380
|
getDefaultInsertLocation as m,
|
|
2381
2381
|
batchDirtyPaths as n,
|
|
2382
2382
|
toRawWeakMap as t
|
package/dist/core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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 } 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-BFFWnObb.js";
|
|
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 } from "./batch-dirty-paths-X-eP3GRL.js";
|
|
3
|
+
import { L as L2, S as S3 } from "./location-CeJ1rJSq.js";
|
|
4
4
|
export {
|
|
5
5
|
E2 as Editor,
|
|
6
6
|
a10 as Element,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as Path, b as Point, R as Range, E as Editor, D as 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 } from "./batch-dirty-paths-X-eP3GRL.js";
|
|
2
2
|
import { reactive } from "vue";
|
|
3
|
-
import { S as Span } from "./location-
|
|
3
|
+
import { S as Span } from "./location-CeJ1rJSq.js";
|
|
4
4
|
const PathRef = {
|
|
5
5
|
transform(ref, op) {
|
|
6
6
|
const { current, affinity } = ref;
|
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, b as EDITOR_TO_USER_SELECTION, N as NODE_TO_KEY, i as isDOMText, g as getPlainText, c as getSlateFragmentAttribute, d as EDITOR_TO_ON_CHANGE } from "./hotkeys-
|
|
2
|
-
import { C, F, G, J, H, B, I, u, L, v, w, M, x, O, z, y, A, K, P, Q, R, S, e, f, h, j, k, l, m, o, p, q, r, s, t, n } from "./hotkeys-
|
|
3
|
-
import { E as Editor, R as Range, a as Element, c as Transforms, P as Path, N as Node } from "./batch-dirty-paths-
|
|
1
|
+
import { D as DOMEditor, E as EDITOR_TO_KEY_TO_ELEMENT, a as EDITOR_TO_USER_MARKS, b as EDITOR_TO_USER_SELECTION, N as NODE_TO_KEY, i as isDOMText, g as getPlainText, c as getSlateFragmentAttribute, d as EDITOR_TO_ON_CHANGE } from "./hotkeys-u-dgagSM.js";
|
|
2
|
+
import { C, F, G, J, H, B, I, u, L, v, w, M, x, O, z, y, A, K, P, Q, R, S, e, f, h, j, k, l, m, o, p, q, r, s, t, n } from "./hotkeys-u-dgagSM.js";
|
|
3
|
+
import { E as Editor, R as Range, a as Element, c as Transforms, P as Path, N as Node } from "./batch-dirty-paths-X-eP3GRL.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 isPlainObject, O as Operation, t as toRawWeakMap, E as Editor, c as Transforms, P as Path } from "./batch-dirty-paths-
|
|
1
|
+
import { d as isPlainObject, O as Operation, t as toRawWeakMap, E as Editor, c as Transforms, P as Path } from "./batch-dirty-paths-X-eP3GRL.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, c as Transforms, a as Element, E as Editor, S as Scrubber, R as Range } from "./batch-dirty-paths-
|
|
5
|
+
import { t as toRawWeakMap, c as Transforms, a as Element, E as Editor, S as Scrubber, R as Range } from "./batch-dirty-paths-X-eP3GRL.js";
|
|
6
6
|
import "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, T as Text, R as Range, N as Node, a as Element, d as isPlainObject } from "./batch-dirty-paths-
|
|
5
|
-
import { c as createEditor$1 } from "./create-editor-
|
|
4
|
+
import { t as toRawWeakMap, T as Text, R as Range, N as Node, a as Element, d as isPlainObject } from "./batch-dirty-paths-X-eP3GRL.js";
|
|
5
|
+
import { c as createEditor$1 } from "./create-editor-BFFWnObb.js";
|
|
6
6
|
import "vue";
|
|
7
7
|
const ANCHOR = new toRawWeakMap();
|
|
8
8
|
const FOCUS = new toRawWeakMap();
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, provide, ref, computed, onMounted, onUnmounted, renderSlot, inject, h, watch, renderList, Fragment, useAttrs, reactive } from "vue";
|
|
2
|
-
import { N as Node, S as Scrubber, P as Path, E as Editor, R as Range, T as Text, a as Element, c as Transforms } from "./batch-dirty-paths-
|
|
3
|
-
import { D as DOMEditor, d as EDITOR_TO_ON_CHANGE, P as MARK_PLACEHOLDER_SYMBOL, I as IS_ANDROID, x as IS_IOS, E as EDITOR_TO_KEY_TO_ELEMENT, J as ELEMENT_TO_NODE, Q as NODE_TO_ELEMENT, R as NODE_TO_INDEX, S as NODE_TO_PARENT, p as isDOMNode, y as IS_WEBKIT, e as applyStringDiff, q as isDOMSelection, n as normalizeStringDiff, O as IS_READ_ONLY, h as getDefaultView, G as EDITOR_TO_WINDOW, F as EDITOR_TO_ELEMENT, H as HAS_BEFORE_INPUT_SUPPORT, C as CAN_USE_DOM, f as getActiveElement, j as getSelection, M as IS_FOCUSED, b as EDITOR_TO_USER_SELECTION, L as IS_COMPOSING, o as isDOMElement, w as IS_FIREFOX_LEGACY, A as IS_WECHATBROWSER, z as IS_UC_MOBILE, a as EDITOR_TO_USER_MARKS, v as IS_FIREFOX, B as Hotkeys, u as IS_CHROME, r as isPlainTextOnlyPaste } from "./hotkeys-
|
|
2
|
+
import { N as Node, S as Scrubber, P as Path, E as Editor, R as Range, T as Text, a as Element, c as Transforms } from "./batch-dirty-paths-X-eP3GRL.js";
|
|
3
|
+
import { D as DOMEditor, d as EDITOR_TO_ON_CHANGE, P as MARK_PLACEHOLDER_SYMBOL, I as IS_ANDROID, x as IS_IOS, E as EDITOR_TO_KEY_TO_ELEMENT, J as ELEMENT_TO_NODE, Q as NODE_TO_ELEMENT, R as NODE_TO_INDEX, S as NODE_TO_PARENT, p as isDOMNode, y as IS_WEBKIT, e as applyStringDiff, q as isDOMSelection, n as normalizeStringDiff, O as IS_READ_ONLY, h as getDefaultView, G as EDITOR_TO_WINDOW, F as EDITOR_TO_ELEMENT, H as HAS_BEFORE_INPUT_SUPPORT, C as CAN_USE_DOM, f as getActiveElement, j as getSelection, M as IS_FOCUSED, b as EDITOR_TO_USER_SELECTION, L as IS_COMPOSING, o as isDOMElement, w as IS_FIREFOX_LEGACY, A as IS_WECHATBROWSER, z as IS_UC_MOBILE, a as EDITOR_TO_USER_MARKS, v as IS_FIREFOX, B as Hotkeys, u as IS_CHROME, r as isPlainTextOnlyPaste } from "./hotkeys-u-dgagSM.js";
|
|
4
4
|
const SLATE_USE_EDITOR = Symbol("SLATE_USE_EDITOR");
|
|
5
5
|
const SLATE_USE_DECORATE = Symbol("SLATE_USE_DECORATE");
|
|
6
6
|
const SLATE_USE_SELECTED = Symbol("SLATE_USE_SELECTED");
|
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
import { BaseEditor,
|
|
2
|
-
import * as Y from
|
|
3
|
-
type LocalChange = {
|
|
4
|
-
op: Operation;
|
|
5
|
-
doc: Descendant[];
|
|
6
|
-
origin: unknown;
|
|
7
|
-
};
|
|
1
|
+
import { BaseEditor, Editor, Point } from '../../slate/index.ts';
|
|
2
|
+
import * as Y from "yjs";
|
|
8
3
|
export type YjsEditor = BaseEditor & {
|
|
9
4
|
sharedRoot: Y.XmlText;
|
|
10
5
|
localOrigin: unknown;
|
|
11
6
|
positionStorageOrigin: unknown;
|
|
12
7
|
applyRemoteEvents: (events: Y.YEvent<Y.XmlText>[], origin: unknown) => void;
|
|
13
|
-
storeLocalChange: (op: Operation) => void;
|
|
14
|
-
flushLocalChanges: () => void;
|
|
15
8
|
isLocalOrigin: (origin: unknown) => boolean;
|
|
16
9
|
connect: () => void;
|
|
17
10
|
disconnect: () => void;
|
|
18
11
|
};
|
|
19
12
|
export declare const YjsEditor: {
|
|
20
13
|
isYjsEditor(value: unknown): value is YjsEditor;
|
|
21
|
-
localChanges(editor: YjsEditor): LocalChange[];
|
|
22
14
|
applyRemoteEvents(editor: YjsEditor, events: Y.YEvent<Y.XmlText>[], origin: unknown): void;
|
|
23
|
-
storeLocalChange(editor: YjsEditor, op: Operation): void;
|
|
24
|
-
flushLocalChanges(editor: YjsEditor): void;
|
|
25
15
|
connected(editor: YjsEditor): boolean;
|
|
26
16
|
connect(editor: YjsEditor): void;
|
|
27
17
|
disconnect(editor: YjsEditor): void;
|
|
@@ -39,4 +29,3 @@ export type WithYjsOptions = {
|
|
|
39
29
|
positionStorageOrigin?: unknown;
|
|
40
30
|
};
|
|
41
31
|
export declare function withYjs<T extends Editor>(editor: T, sharedRoot: Y.XmlText, { localOrigin, positionStorageOrigin, autoConnect, }?: WithYjsOptions): T & YjsEditor;
|
|
42
|
-
export {};
|
package/dist/yjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { d as isPlainObject, T as Text, N as Node, P as Path, E as Editor, t as toRawWeakMap,
|
|
1
|
+
import { d as isPlainObject, T as Text, N as Node, P as Path, E as Editor, t as toRawWeakMap, c as Transforms } from "./batch-dirty-paths-X-eP3GRL.js";
|
|
2
2
|
import { toRaw } from "vue";
|
|
3
3
|
import * as Y from "yjs";
|
|
4
|
-
import { L as Location } from "./location-
|
|
4
|
+
import { L as Location } from "./location-CeJ1rJSq.js";
|
|
5
5
|
function deepEquals(node, another) {
|
|
6
6
|
for (const key in node) {
|
|
7
7
|
const a = node[key];
|
|
@@ -926,24 +926,14 @@ function applySlateOp(sharedRoot, slateRoot, op) {
|
|
|
926
926
|
const DEFAULT_LOCAL_ORIGIN = Symbol("slate-yjs-operation");
|
|
927
927
|
const DEFAULT_POSITION_STORAGE_ORIGIN = Symbol("slate-yjs-position-storage");
|
|
928
928
|
const ORIGIN = new toRawWeakMap();
|
|
929
|
-
const LOCAL_CHANGES = new toRawWeakMap();
|
|
930
929
|
const CONNECTED = /* @__PURE__ */ new WeakSet();
|
|
931
930
|
const YjsEditor = {
|
|
932
931
|
isYjsEditor(value) {
|
|
933
|
-
return Editor.isEditor(value) && value.sharedRoot instanceof Y.XmlText && "localOrigin" in value && "positionStorageOrigin" in value && typeof value.applyRemoteEvents === "function" && typeof value.
|
|
934
|
-
},
|
|
935
|
-
localChanges(editor) {
|
|
936
|
-
return LOCAL_CHANGES.get(editor) ?? [];
|
|
932
|
+
return Editor.isEditor(value) && value.sharedRoot instanceof Y.XmlText && "localOrigin" in value && "positionStorageOrigin" in value && typeof value.applyRemoteEvents === "function" && typeof value.isLocalOrigin === "function" && typeof value.connect === "function" && typeof value.disconnect === "function";
|
|
937
933
|
},
|
|
938
934
|
applyRemoteEvents(editor, events, origin) {
|
|
939
935
|
editor.applyRemoteEvents(events, origin);
|
|
940
936
|
},
|
|
941
|
-
storeLocalChange(editor, op) {
|
|
942
|
-
editor.storeLocalChange(op);
|
|
943
|
-
},
|
|
944
|
-
flushLocalChanges(editor) {
|
|
945
|
-
editor.flushLocalChanges();
|
|
946
|
-
},
|
|
947
937
|
connected(editor) {
|
|
948
938
|
return CONNECTED.has(editor);
|
|
949
939
|
},
|
|
@@ -1002,7 +992,6 @@ function withYjs(editor, sharedRoot, {
|
|
|
1002
992
|
e.localOrigin = localOrigin ?? DEFAULT_LOCAL_ORIGIN;
|
|
1003
993
|
e.positionStorageOrigin = positionStorageOrigin ?? DEFAULT_POSITION_STORAGE_ORIGIN;
|
|
1004
994
|
e.applyRemoteEvents = (events, origin) => {
|
|
1005
|
-
YjsEditor.flushLocalChanges(e);
|
|
1006
995
|
Editor.withoutNormalizing(e, () => {
|
|
1007
996
|
YjsEditor.withOrigin(e, origin, () => {
|
|
1008
997
|
applyYjsEvents(e.sharedRoot, e, events);
|
|
@@ -1040,54 +1029,20 @@ function withYjs(editor, sharedRoot, {
|
|
|
1040
1029
|
if (autoConnectTimeoutId) {
|
|
1041
1030
|
clearTimeout(autoConnectTimeoutId);
|
|
1042
1031
|
}
|
|
1043
|
-
YjsEditor.flushLocalChanges(e);
|
|
1044
1032
|
e.sharedRoot.unobserveDeep(handleYEvents);
|
|
1045
1033
|
CONNECTED.delete(e);
|
|
1046
1034
|
};
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
// fixme
|
|
1051
|
-
// 这里的调度顺序有问题
|
|
1052
|
-
// flushLocalChanges 时,由于 slate-vue3 没有使用 immer 锁定,children 已随着更新
|
|
1053
|
-
// 需要使用深拷贝切断指针,有性能问题
|
|
1054
|
-
// 后续需要使用浅拷贝,只切断部分指针
|
|
1055
|
-
{ op, doc: cloneDeep$1(editor.children), origin: YjsEditor.origin(e) }
|
|
1056
|
-
]);
|
|
1057
|
-
};
|
|
1058
|
-
e.flushLocalChanges = () => {
|
|
1059
|
-
assertDocumentAttachment(e.sharedRoot);
|
|
1060
|
-
const localChanges = YjsEditor.localChanges(e);
|
|
1061
|
-
LOCAL_CHANGES.delete(e);
|
|
1062
|
-
const txGroups = [];
|
|
1063
|
-
localChanges.forEach((change) => {
|
|
1064
|
-
const currentGroup = txGroups[txGroups.length - 1];
|
|
1065
|
-
if ((currentGroup == null ? void 0 : currentGroup.origin) === change.origin) {
|
|
1066
|
-
return txGroups.push(change);
|
|
1067
|
-
}
|
|
1068
|
-
txGroups.push(change);
|
|
1069
|
-
});
|
|
1070
|
-
txGroups.forEach((txGroup) => {
|
|
1035
|
+
const { apply } = e;
|
|
1036
|
+
e.apply = (op) => {
|
|
1037
|
+
if (YjsEditor.connected(e) && YjsEditor.isLocal(e)) {
|
|
1071
1038
|
assertDocumentAttachment(e.sharedRoot);
|
|
1072
1039
|
e.sharedRoot.doc.transact(() => {
|
|
1073
1040
|
assertDocumentAttachment(e.sharedRoot);
|
|
1074
|
-
applySlateOp(e.sharedRoot,
|
|
1075
|
-
},
|
|
1076
|
-
});
|
|
1077
|
-
};
|
|
1078
|
-
const { apply, onChange } = e;
|
|
1079
|
-
e.apply = (op) => {
|
|
1080
|
-
if (YjsEditor.connected(e) && YjsEditor.isLocal(e)) {
|
|
1081
|
-
YjsEditor.storeLocalChange(e, op);
|
|
1041
|
+
applySlateOp(e.sharedRoot, editor, op);
|
|
1042
|
+
}, YjsEditor.origin(e));
|
|
1082
1043
|
}
|
|
1083
1044
|
apply(op);
|
|
1084
1045
|
};
|
|
1085
|
-
e.onChange = () => {
|
|
1086
|
-
if (YjsEditor.connected(e)) {
|
|
1087
|
-
YjsEditor.flushLocalChanges(e);
|
|
1088
|
-
}
|
|
1089
|
-
onChange();
|
|
1090
|
-
};
|
|
1091
1046
|
return e;
|
|
1092
1047
|
}
|
|
1093
1048
|
const LAST_SELECTION = /* @__PURE__ */ new WeakMap();
|
|
@@ -1175,13 +1130,11 @@ function withYHistory(editor, {
|
|
|
1175
1130
|
};
|
|
1176
1131
|
e.undo = () => {
|
|
1177
1132
|
if (YjsEditor.connected(e)) {
|
|
1178
|
-
YjsEditor.flushLocalChanges(e);
|
|
1179
1133
|
e.undoManager.undo();
|
|
1180
1134
|
}
|
|
1181
1135
|
};
|
|
1182
1136
|
e.redo = () => {
|
|
1183
1137
|
if (YjsEditor.connected(e)) {
|
|
1184
|
-
YjsEditor.flushLocalChanges(e);
|
|
1185
1138
|
e.undoManager.redo();
|
|
1186
1139
|
}
|
|
1187
1140
|
};
|