vuewrite 0.0.11 → 0.0.13
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 +1 -1
- package/dist/vuewrite.d.ts +3 -1
- package/dist/vuewrite.js +9 -3
- package/package.json +1 -1
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 =
|
|
28
|
+
const modelValue = shallowRef("")
|
|
29
29
|
|
|
30
30
|
const onKeyDown = (e: KeyboardEvent) => {
|
|
31
31
|
if (!textEditorRef.value) return
|
package/dist/vuewrite.d.ts
CHANGED
|
@@ -43,7 +43,9 @@ export declare type Block = {
|
|
|
43
43
|
editable?: boolean;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
export declare type Decorator = (style: Style) => HTMLAttributes
|
|
46
|
+
export declare type Decorator = (style: Style) => HTMLAttributes & {
|
|
47
|
+
tag?: string;
|
|
48
|
+
} | undefined;
|
|
47
49
|
|
|
48
50
|
declare type HistoryAction = {
|
|
49
51
|
type: "insertText" | "setText";
|
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);
|
|
@@ -553,12 +553,13 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
553
553
|
const renderBlockPart = (text, styles) => {
|
|
554
554
|
if (!props.decorator)
|
|
555
555
|
return text;
|
|
556
|
+
let elementTag = "span";
|
|
556
557
|
const attrs = {};
|
|
557
558
|
for (let style of styles) {
|
|
558
559
|
const partProps = props.decorator(style);
|
|
559
560
|
if (!partProps)
|
|
560
561
|
continue;
|
|
561
|
-
const { class: _class, style: _style, ...otherProps } = partProps;
|
|
562
|
+
const { class: _class, style: _style, tag, ...otherProps } = partProps;
|
|
562
563
|
Object.assign(attrs, otherProps);
|
|
563
564
|
if (_class) {
|
|
564
565
|
attrs.class = attrs.class ? attrs.class + " " + _class : _class;
|
|
@@ -566,10 +567,13 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
566
567
|
if (_style) {
|
|
567
568
|
attrs.style = attrs.style ? attrs.style + " " + _style : _style;
|
|
568
569
|
}
|
|
570
|
+
if (tag) {
|
|
571
|
+
elementTag = tag;
|
|
572
|
+
}
|
|
569
573
|
}
|
|
570
574
|
if (Object.keys(attrs).length === 0)
|
|
571
575
|
return text;
|
|
572
|
-
return h(
|
|
576
|
+
return h(elementTag, attrs, text);
|
|
573
577
|
};
|
|
574
578
|
const instance = getCurrentInstance();
|
|
575
579
|
const getRef = () => {
|
|
@@ -700,6 +704,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
700
704
|
const store = new TextEditorStore();
|
|
701
705
|
let modelValue = "";
|
|
702
706
|
watch(() => props.modelValue, (newValue) => {
|
|
707
|
+
if (isProxy(newValue) && toRaw(newValue) === modelValue)
|
|
708
|
+
return;
|
|
703
709
|
if (newValue === void 0 || newValue === null || newValue === modelValue)
|
|
704
710
|
return;
|
|
705
711
|
if (!Array.isArray(newValue)) {
|