vuewrite 0.0.10 → 0.0.12

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/README.md CHANGED
@@ -25,7 +25,7 @@ You can watch the demo [here](https://vuewrite.easix.ru)
25
25
  import { TextEditor, TextEditorRef } from 'vuewrite'
26
26
 
27
27
  const textEditorRef = shallowRef<TextEditorRef>()
28
- const modelValue = ref("")
28
+ const modelValue = shallowRef("")
29
29
 
30
30
  const onKeyDown = (e: KeyboardEvent) => {
31
31
  if (!textEditorRef.value) return
package/dist/vuewrite.js CHANGED
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- import { getCurrentScope, onScopeDispose, unref, watch, nextTick, reactive, computed, ref, defineComponent, getCurrentInstance, openBlock, createBlock, resolveDynamicComponent, createElementBlock, normalizeProps, mergeProps, h, useSlots, onMounted, Fragment, renderList, renderSlot, createCommentVNode } from "vue";
7
+ import { getCurrentScope, onScopeDispose, unref, watch, nextTick, reactive, computed, ref, defineComponent, getCurrentInstance, openBlock, createBlock, resolveDynamicComponent, createElementBlock, normalizeProps, mergeProps, h, useSlots, isProxy, toRaw, onMounted, Fragment, renderList, renderSlot, createCommentVNode } from "vue";
8
8
  function tryOnScopeDispose(fn) {
9
9
  if (getCurrentScope()) {
10
10
  onScopeDispose(fn);
@@ -348,6 +348,12 @@ class TextEditorStore {
348
348
  }
349
349
  }
350
350
  addNewLine() {
351
+ if (this.isCollapsed && this.selection.anchor.offset === 0) {
352
+ const index2 = this.blocks.findIndex((item) => item.id === this.selection.anchor.blockId);
353
+ const block2 = { id: uid(), text: "", styles: [] };
354
+ this.blocks.splice(index2, 0, block2);
355
+ return;
356
+ }
351
357
  this.deleteSelected();
352
358
  if (!this.currentBlock)
353
359
  return;
@@ -538,7 +544,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
538
544
  const emit = __emit;
539
545
  const slot = computed(() => {
540
546
  if (!props.block.type)
541
- return null;
547
+ return props.slots["default"] ?? null;
542
548
  return props.slots[props.block.type] ?? null;
543
549
  });
544
550
  const blockProps = {
@@ -694,6 +700,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
694
700
  const store = new TextEditorStore();
695
701
  let modelValue = "";
696
702
  watch(() => props.modelValue, (newValue) => {
703
+ if (isProxy(newValue) && toRaw(newValue) === modelValue)
704
+ return;
697
705
  if (newValue === void 0 || newValue === null || newValue === modelValue)
698
706
  return;
699
707
  if (!Array.isArray(newValue)) {
@@ -707,7 +715,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
707
715
  for (let i = 0; i < newValue.length; i++) {
708
716
  store.blocks[i].text = newValue[i].text;
709
717
  store.blocks[i].type = newValue[i].type;
710
- store.blocks[i].text = newValue[i].text;
718
+ store.blocks[i].styles = newValue[i].styles ?? [];
711
719
  }
712
720
  }
713
721
  }, { immediate: true });
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.10",
5
+ "version": "0.0.12",
6
6
  "type": "module",
7
7
  "license": "MIT",
8
8
  "author": "den59k",