vuewrite 0.0.5-a → 0.0.6

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.
@@ -43,8 +43,12 @@ export declare type Style = {
43
43
  export declare const TextEditor: __VLS_WithTemplateSlots<DefineComponent<__VLS_TypePropsToRuntimeProps<{
44
44
  decorator?: Decorator | undefined;
45
45
  single?: boolean | undefined;
46
- modelValue?: string | string[] | undefined;
47
- styles?: Style[] | Style[][] | undefined;
46
+ modelValue?: string | {
47
+ text: string;
48
+ styles?: Style[] | undefined;
49
+ type?: string | undefined;
50
+ }[] | undefined;
51
+ styles?: Style[] | undefined;
48
52
  autofocus?: boolean | undefined;
49
53
  autoselect?: boolean | undefined;
50
54
  }>, {
@@ -84,8 +88,12 @@ keydown: (...args: any[]) => void;
84
88
  }, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
85
89
  decorator?: Decorator | undefined;
86
90
  single?: boolean | undefined;
87
- modelValue?: string | string[] | undefined;
88
- styles?: Style[] | Style[][] | undefined;
91
+ modelValue?: string | {
92
+ text: string;
93
+ styles?: Style[] | undefined;
94
+ type?: string | undefined;
95
+ }[] | undefined;
96
+ styles?: Style[] | undefined;
89
97
  autofocus?: boolean | undefined;
90
98
  autoselect?: boolean | undefined;
91
99
  }>>> & {
package/dist/vuewrite.js CHANGED
@@ -566,7 +566,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
566
566
  }
567
567
  store.blocks.length = newValue.length;
568
568
  for (let i = 0; i < newValue.length; i++) {
569
- store.blocks[i].text = newValue[i];
569
+ store.blocks[i].text = newValue[i].text;
570
+ store.blocks[i].type = newValue[i].type;
571
+ store.blocks[i].text = newValue[i].text;
570
572
  }
571
573
  }
572
574
  }, { immediate: true });
@@ -577,20 +579,23 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
577
579
  for (let i = 0; i < store.blocks.length; i++) {
578
580
  if (newStyles.length <= i)
579
581
  break;
580
- const style = props.single ? newStyles : newStyles[i];
581
- store.blocks[i].styles = style;
582
+ store.blocks[i].styles = newStyles;
582
583
  }
583
584
  }, { immediate: true });
584
585
  watch(() => store.blocks, () => {
585
586
  if (props.single) {
586
587
  modelValue = store.blocks[0].text;
587
588
  styles = store.blocks[0].styles;
589
+ emit("update:styles", styles);
590
+ emit("update:modelValue", modelValue);
588
591
  } else {
589
- modelValue = store.blocks.map((item) => item.text);
590
- styles = store.blocks.map((item) => item.styles);
592
+ modelValue = store.blocks.map((item) => ({
593
+ type: item.type,
594
+ text: item.text,
595
+ styles: item.styles.length === 0 ? void 0 : item.styles
596
+ }));
597
+ emit("update:modelValue", modelValue);
591
598
  }
592
- emit("update:modelValue", modelValue);
593
- emit("update:styles", styles);
594
599
  }, { deep: true });
595
600
  const onKeyDown = (e) => {
596
601
  emit("keydown", e);
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.5-a",
5
+ "version": "0.0.6",
6
6
  "type": "module",
7
7
  "license": "MIT",
8
8
  "author": "den59k",