vuewrite 0.0.5-a → 0.0.5
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/vuewrite.d.ts +0 -2
- package/dist/vuewrite.js +9 -14
- package/package.json +1 -1
package/dist/vuewrite.d.ts
CHANGED
|
@@ -46,7 +46,6 @@ single?: boolean | undefined;
|
|
|
46
46
|
modelValue?: string | string[] | undefined;
|
|
47
47
|
styles?: Style[] | Style[][] | undefined;
|
|
48
48
|
autofocus?: boolean | undefined;
|
|
49
|
-
autoselect?: boolean | undefined;
|
|
50
49
|
}>, {
|
|
51
50
|
currentStyles: ComputedRef<Map<string, Style>>;
|
|
52
51
|
currentBlock: ComputedRef< {
|
|
@@ -87,7 +86,6 @@ single?: boolean | undefined;
|
|
|
87
86
|
modelValue?: string | string[] | undefined;
|
|
88
87
|
styles?: Style[] | Style[][] | undefined;
|
|
89
88
|
autofocus?: boolean | undefined;
|
|
90
|
-
autoselect?: boolean | undefined;
|
|
91
89
|
}>>> & {
|
|
92
90
|
onKeydown?: ((...args: any[]) => any) | undefined;
|
|
93
91
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
package/dist/vuewrite.js
CHANGED
|
@@ -415,7 +415,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
415
415
|
return props.slots[props.block.type] ?? null;
|
|
416
416
|
});
|
|
417
417
|
const blockProps = {
|
|
418
|
-
"data-
|
|
418
|
+
"data-block-id": props.block.id
|
|
419
419
|
};
|
|
420
420
|
const renderBlockPart = (text, styles) => {
|
|
421
421
|
if (!props.decorator)
|
|
@@ -543,8 +543,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
543
543
|
single: { type: Boolean },
|
|
544
544
|
modelValue: {},
|
|
545
545
|
styles: {},
|
|
546
|
-
autofocus: { type: Boolean }
|
|
547
|
-
autoselect: { type: Boolean }
|
|
546
|
+
autofocus: { type: Boolean }
|
|
548
547
|
},
|
|
549
548
|
emits: ["keydown", "update:modelValue", "update:styles"],
|
|
550
549
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
@@ -618,15 +617,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
618
617
|
let cachedSelection = {};
|
|
619
618
|
useEventListener(document, "selectionchange", () => {
|
|
620
619
|
const sel = window.getSelection();
|
|
621
|
-
const anchor = findParent(sel.anchorNode, (el) => el.hasAttribute("data-
|
|
620
|
+
const anchor = findParent(sel.anchorNode, (el) => el.hasAttribute("data-block-id"));
|
|
622
621
|
if (anchor) {
|
|
623
622
|
const offset = anchor === sel.anchorNode ? 0 : calcOffsetToNode(anchor, sel.anchorNode) + sel.anchorOffset;
|
|
624
|
-
store.selection.anchor = { blockId: anchor.getAttribute("data-
|
|
623
|
+
store.selection.anchor = { blockId: anchor.getAttribute("data-block-id"), offset };
|
|
625
624
|
}
|
|
626
|
-
const focus = findParent(sel.focusNode, (el) => el.hasAttribute("data-
|
|
625
|
+
const focus = findParent(sel.focusNode, (el) => el.hasAttribute("data-block-id"));
|
|
627
626
|
if (focus) {
|
|
628
627
|
const offset = anchor === sel.focusNode ? 0 : calcOffsetToNode(focus, sel.focusNode) + sel.focusOffset;
|
|
629
|
-
store.selection.focus = { blockId: focus.getAttribute("data-
|
|
628
|
+
store.selection.focus = { blockId: focus.getAttribute("data-block-id"), offset };
|
|
630
629
|
}
|
|
631
630
|
if (store.isFocused.value !== !!focus || !!anchor) {
|
|
632
631
|
store.isFocused.value = !!focus || !!anchor;
|
|
@@ -656,10 +655,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
656
655
|
let anchor = null;
|
|
657
656
|
let focus = null;
|
|
658
657
|
for (let item of textEditorRef.value.children) {
|
|
659
|
-
if (item.getAttribute("data-
|
|
658
|
+
if (item.getAttribute("data-block-id") === store.selection.anchor.blockId) {
|
|
660
659
|
anchor = item;
|
|
661
660
|
}
|
|
662
|
-
if (item.getAttribute("data-
|
|
661
|
+
if (item.getAttribute("data-block-id") === store.selection.focus.blockId) {
|
|
663
662
|
focus = item;
|
|
664
663
|
}
|
|
665
664
|
}
|
|
@@ -673,15 +672,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
673
672
|
};
|
|
674
673
|
watch(() => store.selection, applySelection, { deep: true, flush: "post" });
|
|
675
674
|
onMounted(() => {
|
|
676
|
-
var _a
|
|
675
|
+
var _a;
|
|
677
676
|
if (props.autofocus) {
|
|
678
677
|
(_a = textEditorRef.value) == null ? void 0 : _a.focus();
|
|
679
678
|
applySelection();
|
|
680
679
|
}
|
|
681
|
-
if (props.autoselect) {
|
|
682
|
-
(_b = textEditorRef.value) == null ? void 0 : _b.focus();
|
|
683
|
-
store.selectAll();
|
|
684
|
-
}
|
|
685
680
|
});
|
|
686
681
|
const onCopy = (e) => {
|
|
687
682
|
e.preventDefault();
|