slate-vue3 0.11.0 → 0.11.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
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { u as useElementIf, a as useEditor, S as SLATE_USE_SELECTION } from "./use-focused-
|
|
2
|
-
import { n, p, k, l, o, D, m, E, b, j, h, g, i, c, f, d, e } from "./use-focused-
|
|
1
|
+
import { u as useElementIf, a as useEditor, S as SLATE_USE_SELECTION } from "./use-focused-c2_pK4Hd.js";
|
|
2
|
+
import { n, p, k, l, o, D, m, E, b, j, h, g, i, c, f, d, e } from "./use-focused-c2_pK4Hd.js";
|
|
3
3
|
import { E as Editor, R as Range } from "./index-CeEqNjuc.js";
|
|
4
4
|
import { computed, inject } from "vue";
|
|
5
5
|
import { D as DOMEditor } from "./hotkeys-FU5gHPpY.js";
|
|
@@ -13,7 +13,7 @@ export declare const provideMarkPlaceholder: (markPlaceholder: MarkPlaceholder)
|
|
|
13
13
|
export declare const useMarkPlaceholder: () => MarkPlaceholder;
|
|
14
14
|
export declare const SLATE_INNER_PLACEHOLDER_SHOW: unique symbol;
|
|
15
15
|
export declare const providePlaceholderShow: (show: ComputedRef<boolean>) => void;
|
|
16
|
-
export declare const usePlaceholderShow: () =>
|
|
16
|
+
export declare const usePlaceholderShow: () => () => boolean;
|
|
17
17
|
export declare const SLATE_INNER_PLACEHOLDER_RESIZE: unique symbol;
|
|
18
18
|
export declare const providePlaceholderResize: (fn: (height?: number) => void) => void;
|
|
19
19
|
export declare const usePlaceholderResize: () => (height?: number) => void;
|
|
@@ -318,7 +318,7 @@ const SLATE_INNER_PLACEHOLDER_SHOW = Symbol(
|
|
|
318
318
|
"SLATE_INNER_PLACEHOLDER_SHOW"
|
|
319
319
|
);
|
|
320
320
|
const providePlaceholderShow = (show) => {
|
|
321
|
-
provide(SLATE_INNER_PLACEHOLDER_SHOW, show);
|
|
321
|
+
provide(SLATE_INNER_PLACEHOLDER_SHOW, () => show.value);
|
|
322
322
|
};
|
|
323
323
|
const usePlaceholderShow = () => {
|
|
324
324
|
const PLACEHOLDER_SHOW_INJECT = inject(
|
|
@@ -563,60 +563,52 @@ const StringComp = defineComponent({
|
|
|
563
563
|
const isLastEmptyBlock = injectIsLastEmptyBlock();
|
|
564
564
|
return () => {
|
|
565
565
|
if (editor.isVoid(element.value)) {
|
|
566
|
-
return
|
|
566
|
+
return ZeroWidthString({
|
|
567
567
|
length: Node.string(element.value).length
|
|
568
568
|
});
|
|
569
569
|
}
|
|
570
570
|
if (props.leaf.text === "" && element.value.children.at(-1) === props.text && isLastEmptyBlock.value) {
|
|
571
|
-
return
|
|
571
|
+
return ZeroWidthString({
|
|
572
572
|
isLineBreak: true,
|
|
573
573
|
isMarkPlaceholder: props.leaf[MARK_PLACEHOLDER_SYMBOL] === true
|
|
574
574
|
});
|
|
575
575
|
}
|
|
576
576
|
if (props.leaf.text === "") {
|
|
577
|
-
return
|
|
577
|
+
return ZeroWidthString({
|
|
578
578
|
isMarkPlaceholder: props.leaf[MARK_PLACEHOLDER_SYMBOL] === true
|
|
579
579
|
});
|
|
580
580
|
}
|
|
581
581
|
if (props.isLast && props.leaf.text.endsWith("\n")) {
|
|
582
|
-
return
|
|
582
|
+
return TextString({
|
|
583
583
|
isTrailing: true,
|
|
584
584
|
text: props.leaf.text
|
|
585
585
|
});
|
|
586
586
|
}
|
|
587
|
-
return
|
|
587
|
+
return TextString({ text: props.leaf.text });
|
|
588
588
|
};
|
|
589
589
|
}
|
|
590
590
|
});
|
|
591
|
-
const TextString =
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
"
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
},
|
|
613
|
-
[
|
|
614
|
-
!IS_ANDROID || !props.isLineBreak ? "\uFEFF" : null,
|
|
615
|
-
props.isLineBreak ? h("br") : null
|
|
616
|
-
]
|
|
617
|
-
);
|
|
618
|
-
}
|
|
619
|
-
});
|
|
591
|
+
const TextString = (props) => {
|
|
592
|
+
return h(
|
|
593
|
+
"span",
|
|
594
|
+
{ "data-slate-string": true },
|
|
595
|
+
`${props.text ?? ""}${props.isTrailing ? "\n" : ""}`
|
|
596
|
+
);
|
|
597
|
+
};
|
|
598
|
+
const ZeroWidthString = (props) => {
|
|
599
|
+
return h(
|
|
600
|
+
"span",
|
|
601
|
+
{
|
|
602
|
+
"data-slate-zero-width": props.isLineBreak ? "n" : "z",
|
|
603
|
+
"data-slate-length": props.length,
|
|
604
|
+
"data-slate-mark-placeholder": props.isMarkPlaceholder ? true : void 0
|
|
605
|
+
},
|
|
606
|
+
[
|
|
607
|
+
!IS_ANDROID || !props.isLineBreak ? "\uFEFF" : null,
|
|
608
|
+
props.isLineBreak ? h("br") : null
|
|
609
|
+
]
|
|
610
|
+
);
|
|
611
|
+
};
|
|
620
612
|
const style = {
|
|
621
613
|
position: "absolute",
|
|
622
614
|
top: 0,
|
|
@@ -662,54 +654,29 @@ const PlaceholderComp = defineComponent({
|
|
|
662
654
|
}
|
|
663
655
|
});
|
|
664
656
|
const LeafComp = defineComponent({
|
|
665
|
-
name: "slate-
|
|
657
|
+
name: "slate-leaf",
|
|
666
658
|
props: ["text", "leaf", "isLast", "leafPosition"],
|
|
667
659
|
setup(props) {
|
|
668
|
-
const text = props
|
|
669
|
-
const leaf = props.leaf;
|
|
670
|
-
const isLast = props.isLast;
|
|
671
|
-
const leafPosition = props.leafPosition;
|
|
672
|
-
const editor = useEditor();
|
|
673
|
-
const textRef = ref();
|
|
674
|
-
onMounted(() => {
|
|
675
|
-
const key = DOMEditor.findKey(editor, text);
|
|
676
|
-
if (textRef.value) {
|
|
677
|
-
const KEY_TO_ELEMENT = EDITOR_TO_KEY_TO_ELEMENT.get(editor);
|
|
678
|
-
KEY_TO_ELEMENT?.set(key, textRef.value);
|
|
679
|
-
ELEMENT_TO_NODE.set(textRef.value, text);
|
|
680
|
-
NODE_TO_ELEMENT.set(text, textRef.value);
|
|
681
|
-
}
|
|
682
|
-
});
|
|
683
|
-
onUnmounted(() => {
|
|
684
|
-
NODE_TO_ELEMENT.delete(text);
|
|
685
|
-
if (textRef.value) {
|
|
686
|
-
ELEMENT_TO_NODE.delete(textRef.value);
|
|
687
|
-
}
|
|
688
|
-
});
|
|
660
|
+
const { text, leaf, isLast, leafPosition } = props;
|
|
689
661
|
const renderLeaf = useRenderLeaf();
|
|
690
662
|
const showPlaceholder = usePlaceholderShow();
|
|
691
|
-
|
|
692
|
-
|
|
663
|
+
return () => renderLeaf({
|
|
664
|
+
text,
|
|
665
|
+
leaf,
|
|
666
|
+
leafPosition,
|
|
667
|
+
attributes: { "data-slate-leaf": true },
|
|
668
|
+
children: showPlaceholder() ? [
|
|
693
669
|
h(StringComp, {
|
|
694
670
|
text,
|
|
695
671
|
leaf,
|
|
696
|
-
isLast: true
|
|
697
|
-
key: DOMEditor.findKey(editor, leaf).id
|
|
672
|
+
isLast: true
|
|
698
673
|
}),
|
|
699
674
|
h(PlaceholderComp)
|
|
700
675
|
] : h(StringComp, {
|
|
701
676
|
text,
|
|
702
677
|
leaf,
|
|
703
|
-
isLast
|
|
704
|
-
|
|
705
|
-
});
|
|
706
|
-
});
|
|
707
|
-
return () => renderLeaf({
|
|
708
|
-
text,
|
|
709
|
-
leaf,
|
|
710
|
-
leafPosition,
|
|
711
|
-
attributes: { "data-slate-leaf": true },
|
|
712
|
-
children: children.value
|
|
678
|
+
isLast
|
|
679
|
+
})
|
|
713
680
|
});
|
|
714
681
|
}
|
|
715
682
|
});
|
|
@@ -740,10 +707,10 @@ const TextComp = defineComponent({
|
|
|
740
707
|
return Text.decorations(text, filterDs.length ? filterDs : []);
|
|
741
708
|
});
|
|
742
709
|
onMounted(() => {
|
|
743
|
-
const
|
|
710
|
+
const key2 = DOMEditor.findKey(editor, text);
|
|
744
711
|
if (textRef.value) {
|
|
745
712
|
const KEY_TO_ELEMENT = EDITOR_TO_KEY_TO_ELEMENT.get(editor);
|
|
746
|
-
KEY_TO_ELEMENT?.set(
|
|
713
|
+
KEY_TO_ELEMENT?.set(key2, textRef.value);
|
|
747
714
|
ELEMENT_TO_NODE.set(textRef.value, text);
|
|
748
715
|
NODE_TO_ELEMENT.set(text, textRef.value);
|
|
749
716
|
}
|
|
@@ -755,6 +722,7 @@ const TextComp = defineComponent({
|
|
|
755
722
|
}
|
|
756
723
|
});
|
|
757
724
|
const renderText = useRenderText();
|
|
725
|
+
let key = 0;
|
|
758
726
|
const children = computed(
|
|
759
727
|
() => renderList(
|
|
760
728
|
leaves.value,
|
|
@@ -763,7 +731,7 @@ const TextComp = defineComponent({
|
|
|
763
731
|
leaf: leaf.leaf,
|
|
764
732
|
isLast: props.isLast && i === leaves.value.length - 1,
|
|
765
733
|
leafPosition: leaf.position,
|
|
766
|
-
key:
|
|
734
|
+
key: key++
|
|
767
735
|
})
|
|
768
736
|
)
|
|
769
737
|
);
|
|
@@ -836,7 +804,7 @@ const ElementComp = defineComponent({
|
|
|
836
804
|
}
|
|
837
805
|
if (Editor.isVoid(editor, element)) {
|
|
838
806
|
attr["data-slate-void"] = true;
|
|
839
|
-
if (!readOnly && isInline.value) {
|
|
807
|
+
if (!readOnly.value && isInline.value) {
|
|
840
808
|
attr.contenteditable = false;
|
|
841
809
|
}
|
|
842
810
|
}
|
package/dist/yjs.js
CHANGED
|
@@ -2,7 +2,7 @@ import { d as isObject, T as Text, N as Node, P as Path, E as Editor, c as Trans
|
|
|
2
2
|
import { ref, onMounted, onUnmounted, watch, onUpdated, computed } from "vue";
|
|
3
3
|
import { XmlText, YTextEvent, createRelativePositionFromTypeIndex, createAbsolutePositionFromRelativePosition, createRelativePositionFromJSON, decodeRelativePosition, encodeRelativePosition, UndoManager, compareRelativePositions } from "yjs";
|
|
4
4
|
import { L as Location } from "./location-TwW6GZ1v.js";
|
|
5
|
-
import { a as useEditor, d as useFocused } from "./use-focused-
|
|
5
|
+
import { a as useEditor, d as useFocused } from "./use-focused-c2_pK4Hd.js";
|
|
6
6
|
import { D as DOMEditor } from "./hotkeys-FU5gHPpY.js";
|
|
7
7
|
function deepEquals(node, another) {
|
|
8
8
|
for (const key in node) {
|