slate-vue3 0.2.1 → 0.2.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/index.js +33 -31
- package/dist/slate-vue/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineComponent, provide, ref, computed, onMounted, onUnmounted, renderSlot, inject, h, watch, renderList, Fragment, useAttrs, reactive } from "vue";
|
|
2
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 { t } from "./batch-dirty-paths-X-eP3GRL.js";
|
|
3
4
|
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-BwRBmDaN.js";
|
|
4
5
|
const SLATE_USE_EDITOR = Symbol("SLATE_USE_EDITOR");
|
|
5
6
|
const SLATE_USE_DECORATE = Symbol("SLATE_USE_DECORATE");
|
|
@@ -363,47 +364,47 @@ const ChildrenFC = (element, editor) => renderList(element.children, (child, i)
|
|
|
363
364
|
NODE_TO_PARENT.set(child, element);
|
|
364
365
|
return Element.isElement(child) ? h(ElementComp, { element: child, key: key.id }) : h(TextComp, { text: child, element, key: key.id });
|
|
365
366
|
});
|
|
366
|
-
const
|
|
367
|
-
if (
|
|
368
|
-
const o2 = getComputedStyle(
|
|
369
|
-
return e$1(o2.overflowY, n2) || e$1(o2.overflowX, n2) || ((
|
|
370
|
-
const e2 = ((
|
|
371
|
-
if (!
|
|
367
|
+
const t2 = (t3) => "object" == typeof t3 && null != t3 && 1 === t3.nodeType, e$1 = (t3, e2) => (!e2 || "hidden" !== t3) && ("visible" !== t3 && "clip" !== t3), n = (t3, n2) => {
|
|
368
|
+
if (t3.clientHeight < t3.scrollHeight || t3.clientWidth < t3.scrollWidth) {
|
|
369
|
+
const o2 = getComputedStyle(t3, null);
|
|
370
|
+
return e$1(o2.overflowY, n2) || e$1(o2.overflowX, n2) || ((t4) => {
|
|
371
|
+
const e2 = ((t5) => {
|
|
372
|
+
if (!t5.ownerDocument || !t5.ownerDocument.defaultView) return null;
|
|
372
373
|
try {
|
|
373
|
-
return
|
|
374
|
-
} catch (
|
|
374
|
+
return t5.ownerDocument.defaultView.frameElement;
|
|
375
|
+
} catch (t6) {
|
|
375
376
|
return null;
|
|
376
377
|
}
|
|
377
|
-
})(
|
|
378
|
-
return !!e2 && (e2.clientHeight <
|
|
379
|
-
})(
|
|
378
|
+
})(t4);
|
|
379
|
+
return !!e2 && (e2.clientHeight < t4.scrollHeight || e2.clientWidth < t4.scrollWidth);
|
|
380
|
+
})(t3);
|
|
380
381
|
}
|
|
381
382
|
return false;
|
|
382
|
-
}, o$1 = (
|
|
383
|
-
const e2 =
|
|
384
|
-
return null == e2 ?
|
|
383
|
+
}, o$1 = (t3, e2, n2, o2, l2, r2, i, s) => r2 < t3 && i > e2 || r2 > t3 && i < e2 ? 0 : r2 <= t3 && s <= n2 || i >= e2 && s >= n2 ? r2 - t3 - o2 : i > e2 && s < n2 || r2 < t3 && s > n2 ? i - e2 + l2 : 0, l = (t3) => {
|
|
384
|
+
const e2 = t3.parentElement;
|
|
385
|
+
return null == e2 ? t3.getRootNode().host || null : e2;
|
|
385
386
|
}, r = (e2, r2) => {
|
|
386
387
|
var i, s, d, h2;
|
|
387
388
|
if ("undefined" == typeof document) return [];
|
|
388
|
-
const { scrollMode: c, block: f, inline: u, boundary: a, skipOverflowHiddenElements: g } = r2, p = "function" == typeof a ? a : (
|
|
389
|
-
if (!
|
|
389
|
+
const { scrollMode: c, block: f, inline: u, boundary: a, skipOverflowHiddenElements: g } = r2, p = "function" == typeof a ? a : (t3) => t3 !== a;
|
|
390
|
+
if (!t2(e2)) throw new TypeError("Invalid target");
|
|
390
391
|
const m = document.scrollingElement || document.documentElement, w = [];
|
|
391
392
|
let W = e2;
|
|
392
|
-
for (;
|
|
393
|
+
for (; t2(W) && p(W); ) {
|
|
393
394
|
if (W = l(W), W === m) {
|
|
394
395
|
w.push(W);
|
|
395
396
|
break;
|
|
396
397
|
}
|
|
397
398
|
null != W && W === document.body && n(W) && !n(document.documentElement) || null != W && n(W, g) && w.push(W);
|
|
398
399
|
}
|
|
399
|
-
const b = null != (s = null == (i = window.visualViewport) ? void 0 : i.width) ? s : innerWidth, H = null != (h2 = null == (d = window.visualViewport) ? void 0 : d.height) ? h2 : innerHeight, { scrollX: y, scrollY: M } = window, { height: v, width: E, top: x, right: C, bottom: I, left: R } = e2.getBoundingClientRect(), { top: T, right: B, bottom: F, left: V } = ((
|
|
400
|
-
const e3 = window.getComputedStyle(
|
|
400
|
+
const b = null != (s = null == (i = window.visualViewport) ? void 0 : i.width) ? s : innerWidth, H = null != (h2 = null == (d = window.visualViewport) ? void 0 : d.height) ? h2 : innerHeight, { scrollX: y, scrollY: M } = window, { height: v, width: E, top: x, right: C, bottom: I, left: R } = e2.getBoundingClientRect(), { top: T, right: B, bottom: F, left: V } = ((t3) => {
|
|
401
|
+
const e3 = window.getComputedStyle(t3);
|
|
401
402
|
return { top: parseFloat(e3.scrollMarginTop) || 0, right: parseFloat(e3.scrollMarginRight) || 0, bottom: parseFloat(e3.scrollMarginBottom) || 0, left: parseFloat(e3.scrollMarginLeft) || 0 };
|
|
402
403
|
})(e2);
|
|
403
404
|
let k = "start" === f || "nearest" === f ? x - T : "end" === f ? I + F : x + v / 2 - T + F, D = "center" === u ? R + E / 2 - V + B : "end" === u ? C + B : R - V;
|
|
404
405
|
const L = [];
|
|
405
|
-
for (let
|
|
406
|
-
const e3 = w[
|
|
406
|
+
for (let t3 = 0; t3 < w.length; t3++) {
|
|
407
|
+
const e3 = w[t3], { height: n2, width: l2, top: r3, right: i2, bottom: s2, left: d2 } = e3.getBoundingClientRect();
|
|
407
408
|
if ("if-needed" === c && x >= 0 && R >= 0 && I <= H && C <= b && x >= r3 && I <= s2 && R >= d2 && C <= i2) return L;
|
|
408
409
|
const h3 = getComputedStyle(e3), a2 = parseInt(h3.borderLeftWidth, 10), g2 = parseInt(h3.borderTopWidth, 10), p2 = parseInt(h3.borderRightWidth, 10), W2 = parseInt(h3.borderBottomWidth, 10);
|
|
409
410
|
let T2 = 0, B2 = 0;
|
|
@@ -411,32 +412,32 @@ const t = (t2) => "object" == typeof t2 && null != t2 && 1 === t2.nodeType, e$1
|
|
|
411
412
|
if (m === e3) T2 = "start" === f ? k : "end" === f ? k - H : "nearest" === f ? o$1(M, M + H, H, g2, W2, M + k, M + k + v, v) : k - H / 2, B2 = "start" === u ? D : "center" === u ? D - b / 2 : "end" === u ? D - b : o$1(y, y + b, b, a2, p2, y + D, y + D + E, E), T2 = Math.max(0, T2 + M), B2 = Math.max(0, B2 + y);
|
|
412
413
|
else {
|
|
413
414
|
T2 = "start" === f ? k - r3 - g2 : "end" === f ? k - s2 + W2 + V2 : "nearest" === f ? o$1(r3, s2, n2, g2, W2 + V2, k, k + v, v) : k - (r3 + n2 / 2) + V2 / 2, B2 = "start" === u ? D - d2 - a2 : "center" === u ? D - (d2 + l2 / 2) + F2 / 2 : "end" === u ? D - i2 + p2 + F2 : o$1(d2, i2, l2, a2, p2 + F2, D, D + E, E);
|
|
414
|
-
const { scrollLeft:
|
|
415
|
-
T2 = 0 === X ? 0 : Math.max(0, Math.min(h4 + T2 / X, e3.scrollHeight - n2 / X + V2)), B2 = 0 === S ? 0 : Math.max(0, Math.min(
|
|
415
|
+
const { scrollLeft: t4, scrollTop: h4 } = e3;
|
|
416
|
+
T2 = 0 === X ? 0 : Math.max(0, Math.min(h4 + T2 / X, e3.scrollHeight - n2 / X + V2)), B2 = 0 === S ? 0 : Math.max(0, Math.min(t4 + B2 / S, e3.scrollWidth - l2 / S + F2)), k += h4 - T2, D += t4 - B2;
|
|
416
417
|
}
|
|
417
418
|
L.push({ el: e3, top: T2, left: B2 });
|
|
418
419
|
}
|
|
419
420
|
return L;
|
|
420
421
|
};
|
|
421
|
-
const o = (
|
|
422
|
+
const o = (t3) => false === t3 ? { block: "end", inline: "nearest" } : ((t4) => t4 === Object(t4) && 0 !== Object.keys(t4).length)(t3) ? t3 : { block: "start", inline: "nearest" };
|
|
422
423
|
function e(e2, r$1) {
|
|
423
|
-
if (!e2.isConnected || !((
|
|
424
|
-
let o2 =
|
|
424
|
+
if (!e2.isConnected || !((t3) => {
|
|
425
|
+
let o2 = t3;
|
|
425
426
|
for (; o2 && o2.parentNode; ) {
|
|
426
427
|
if (o2.parentNode === document) return true;
|
|
427
428
|
o2 = o2.parentNode instanceof ShadowRoot ? o2.parentNode.host : o2.parentNode;
|
|
428
429
|
}
|
|
429
430
|
return false;
|
|
430
431
|
})(e2)) return;
|
|
431
|
-
const n2 = ((
|
|
432
|
-
const o2 = window.getComputedStyle(
|
|
432
|
+
const n2 = ((t3) => {
|
|
433
|
+
const o2 = window.getComputedStyle(t3);
|
|
433
434
|
return { top: parseFloat(o2.scrollMarginTop) || 0, right: parseFloat(o2.scrollMarginRight) || 0, bottom: parseFloat(o2.scrollMarginBottom) || 0, left: parseFloat(o2.scrollMarginLeft) || 0 };
|
|
434
435
|
})(e2);
|
|
435
|
-
if (((
|
|
436
|
+
if (((t3) => "object" == typeof t3 && "function" == typeof t3.behavior)(r$1)) return r$1.behavior(r(e2, r$1));
|
|
436
437
|
const l2 = "boolean" == typeof r$1 || null == r$1 ? void 0 : r$1.behavior;
|
|
437
438
|
for (const { el: a, top: i, left: s } of r(e2, o(r$1))) {
|
|
438
|
-
const
|
|
439
|
-
a.scroll({ top:
|
|
439
|
+
const t3 = i - n2.top + n2.bottom, o2 = s - n2.left + n2.right;
|
|
440
|
+
a.scroll({ top: t3, left: o2, behavior: l2 });
|
|
440
441
|
}
|
|
441
442
|
}
|
|
442
443
|
const isEventHandled = (event, handler) => {
|
|
@@ -1773,6 +1774,7 @@ export {
|
|
|
1773
1774
|
Slate,
|
|
1774
1775
|
defaultRenderLeaf,
|
|
1775
1776
|
defaultRenderPlaceHolder,
|
|
1777
|
+
t as toRawWeakMap,
|
|
1776
1778
|
useComposing,
|
|
1777
1779
|
useEditor,
|
|
1778
1780
|
useFocused,
|
|
@@ -10,3 +10,4 @@ export { useSelected } from './hooks/use-selected';
|
|
|
10
10
|
export { useEditor } from './hooks/use-editor';
|
|
11
11
|
export { useSelection } from './hooks/use-selection';
|
|
12
12
|
export { useInheritRef } from './hooks/use-inherit-ref';
|
|
13
|
+
export { toRawWeakMap } from '../share-tools/index.ts';
|