vuewrite 0.0.4 → 0.0.5-a

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