vuewrite 0.0.9 → 0.0.10
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 +31 -0
- package/dist/vuewrite.js +46 -11
- package/package.json +1 -1
package/dist/vuewrite.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ import { Ref } from 'vue';
|
|
|
9
9
|
|
|
10
10
|
declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
11
11
|
|
|
12
|
+
declare type __VLS_NonUndefinedable_2<T> = T extends undefined ? never : T;
|
|
13
|
+
|
|
12
14
|
declare type __VLS_TypePropsToRuntimeProps<T> = {
|
|
13
15
|
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
14
16
|
type: PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
@@ -18,6 +20,15 @@ declare type __VLS_TypePropsToRuntimeProps<T> = {
|
|
|
18
20
|
};
|
|
19
21
|
};
|
|
20
22
|
|
|
23
|
+
declare type __VLS_TypePropsToRuntimeProps_2<T> = {
|
|
24
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
25
|
+
type: PropType<__VLS_NonUndefinedable_2<T[K]>>;
|
|
26
|
+
} : {
|
|
27
|
+
type: PropType<T[K]>;
|
|
28
|
+
required: true;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
21
32
|
declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
22
33
|
new (): {
|
|
23
34
|
$slots: S;
|
|
@@ -229,6 +240,26 @@ declare class TextEditorStore {
|
|
|
229
240
|
selectAll(): void;
|
|
230
241
|
}
|
|
231
242
|
|
|
243
|
+
export declare const TextEditorView: DefineComponent<__VLS_TypePropsToRuntimeProps_2<{
|
|
244
|
+
modelValue: {
|
|
245
|
+
text: string;
|
|
246
|
+
styles?: Style[];
|
|
247
|
+
type?: string;
|
|
248
|
+
}[] | string;
|
|
249
|
+
decorator?: Decorator | undefined;
|
|
250
|
+
parser?: TextParser | undefined;
|
|
251
|
+
styles?: Style[] | undefined;
|
|
252
|
+
}>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_2<{
|
|
253
|
+
modelValue: {
|
|
254
|
+
text: string;
|
|
255
|
+
styles?: Style[];
|
|
256
|
+
type?: string;
|
|
257
|
+
}[] | string;
|
|
258
|
+
decorator?: Decorator | undefined;
|
|
259
|
+
parser?: TextParser | undefined;
|
|
260
|
+
styles?: Style[] | undefined;
|
|
261
|
+
}>>>, {}, {}>;
|
|
262
|
+
|
|
232
263
|
declare type TextParser = (text: string) => Style[];
|
|
233
264
|
|
|
234
265
|
export { }
|
package/dist/vuewrite.js
CHANGED
|
@@ -291,16 +291,16 @@ class TextEditorStore {
|
|
|
291
291
|
const blockIndex = this.blocks.findIndex((item) => item.id === this.selection.anchor.blockId);
|
|
292
292
|
if (blockIndex < 1)
|
|
293
293
|
return;
|
|
294
|
+
this.selection.anchor.blockId = this.blocks[blockIndex - 1].id;
|
|
295
|
+
this.selection.focus.blockId = this.blocks[blockIndex - 1].id;
|
|
296
|
+
this.selection.anchor.offset = this.blocks[blockIndex - 1].text.length;
|
|
297
|
+
this.selection.focus.offset = this.blocks[blockIndex - 1].text.length;
|
|
294
298
|
if (this.blocks[blockIndex - 1].editable === false) {
|
|
295
299
|
this.blocks.splice(blockIndex - 1, 1);
|
|
296
300
|
} else {
|
|
297
301
|
this.concatBlocks(this.blocks[blockIndex - 1], this.blocks[blockIndex]);
|
|
298
302
|
this.blocks.splice(blockIndex, 1);
|
|
299
303
|
}
|
|
300
|
-
this.selection.anchor.blockId = this.blocks[blockIndex - 1].id;
|
|
301
|
-
this.selection.focus.blockId = this.blocks[blockIndex - 1].id;
|
|
302
|
-
this.selection.anchor.offset = this.blocks[blockIndex - 1].text.length;
|
|
303
|
-
this.selection.focus.offset = this.blocks[blockIndex - 1].text.length;
|
|
304
304
|
this.history.push("setText");
|
|
305
305
|
}
|
|
306
306
|
onInput(_e) {
|
|
@@ -524,7 +524,7 @@ class TextEditorStore {
|
|
|
524
524
|
}
|
|
525
525
|
let uidCounter = 0;
|
|
526
526
|
const uid = () => (uidCounter++).toString();
|
|
527
|
-
const _sfc_main$
|
|
527
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
528
528
|
__name: "TextEditorBlock",
|
|
529
529
|
props: {
|
|
530
530
|
block: {},
|
|
@@ -625,9 +625,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
625
625
|
text = text + "\n";
|
|
626
626
|
}
|
|
627
627
|
const markers = [];
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
628
|
+
if (block.styles) {
|
|
629
|
+
for (let style of block.styles) {
|
|
630
|
+
markers.push([style.start, style]);
|
|
631
|
+
markers.push([style.end, style]);
|
|
632
|
+
}
|
|
631
633
|
}
|
|
632
634
|
if (props.parser) {
|
|
633
635
|
for (let style of props.parser(text)) {
|
|
@@ -671,7 +673,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
671
673
|
};
|
|
672
674
|
}
|
|
673
675
|
});
|
|
674
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
676
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
675
677
|
__name: "TextEditor",
|
|
676
678
|
props: {
|
|
677
679
|
decorator: { type: Function },
|
|
@@ -896,7 +898,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
896
898
|
onCut
|
|
897
899
|
}, [
|
|
898
900
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(store).blocks, (block) => {
|
|
899
|
-
return openBlock(), createBlock(_sfc_main$
|
|
901
|
+
return openBlock(), createBlock(_sfc_main$2, {
|
|
900
902
|
key: block.id,
|
|
901
903
|
block,
|
|
902
904
|
slots: unref(slots),
|
|
@@ -910,6 +912,39 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
910
912
|
};
|
|
911
913
|
}
|
|
912
914
|
});
|
|
915
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
916
|
+
__name: "TextEditorView",
|
|
917
|
+
props: {
|
|
918
|
+
modelValue: {},
|
|
919
|
+
decorator: { type: Function },
|
|
920
|
+
parser: {},
|
|
921
|
+
styles: {}
|
|
922
|
+
},
|
|
923
|
+
setup(__props) {
|
|
924
|
+
const props = __props;
|
|
925
|
+
const slots = useSlots();
|
|
926
|
+
const blocks = computed(() => {
|
|
927
|
+
if (Array.isArray(props.modelValue)) {
|
|
928
|
+
return props.modelValue;
|
|
929
|
+
}
|
|
930
|
+
return [{ text: props.modelValue, styles: props.styles ?? [] }];
|
|
931
|
+
});
|
|
932
|
+
return (_ctx, _cache) => {
|
|
933
|
+
return openBlock(), createElementBlock("div", null, [
|
|
934
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(blocks.value, (block) => {
|
|
935
|
+
return openBlock(), createBlock(_sfc_main$2, {
|
|
936
|
+
key: block.id,
|
|
937
|
+
block,
|
|
938
|
+
slots: unref(slots),
|
|
939
|
+
decorator: props.decorator,
|
|
940
|
+
parser: props.parser
|
|
941
|
+
}, null, 8, ["block", "slots", "decorator", "parser"]);
|
|
942
|
+
}), 128))
|
|
943
|
+
]);
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
});
|
|
913
947
|
export {
|
|
914
|
-
_sfc_main as TextEditor
|
|
948
|
+
_sfc_main$1 as TextEditor,
|
|
949
|
+
_sfc_main as TextEditorView
|
|
915
950
|
};
|