vuewrite 0.0.23 → 0.0.24
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 +4 -1
- package/dist/vuewrite.js +14 -1
- package/package.json +1 -1
package/dist/vuewrite.d.ts
CHANGED
|
@@ -97,6 +97,7 @@ offset: number;
|
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
99
|
isFocused: Ref<boolean>;
|
|
100
|
+
getCurrentBlocks: () => Generator<Block, any, unknown>;
|
|
100
101
|
toggleStyle: (style: string) => void;
|
|
101
102
|
applyStyle: (_style: string, meta?: any) => void;
|
|
102
103
|
removeStyle: (_style: string) => void;
|
|
@@ -131,6 +132,7 @@ onKeydown?: ((...args: any[]) => any) | undefined;
|
|
|
131
132
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
132
133
|
"onUpdate:styles"?: ((...args: any[]) => any) | undefined;
|
|
133
134
|
}, {}, {}>, {
|
|
135
|
+
_before?(_: {}): any;
|
|
134
136
|
placeholder?(_: {}): any;
|
|
135
137
|
}>;
|
|
136
138
|
|
|
@@ -150,7 +152,7 @@ declare class TextEditorHistory {
|
|
|
150
152
|
redo(): void;
|
|
151
153
|
}
|
|
152
154
|
|
|
153
|
-
export declare type TextEditorRef = Pick<TextEditorStore, "currentStyles" | "currentBlock" | "isCollapsed" | "selection" | "toggleStyle" | "applyStyle" | "removeStyle" | "insertText" | "insertBlock" | "addNewLine" | "removeNewLine" | "selectAll" | "removeCurrentBlock"> & {
|
|
155
|
+
export declare type TextEditorRef = Pick<TextEditorStore, "currentStyles" | "currentBlock" | "isCollapsed" | "selection" | "getCurrentBlocks" | "toggleStyle" | "applyStyle" | "removeStyle" | "insertText" | "insertBlock" | "addNewLine" | "removeNewLine" | "selectAll" | "removeCurrentBlock"> & {
|
|
154
156
|
isFocused: boolean;
|
|
155
157
|
getClientRects: (selection: TextEditorSelection) => DOMRectList;
|
|
156
158
|
pushHistory: TextEditorHistory["push"];
|
|
@@ -218,6 +220,7 @@ declare class TextEditorStore {
|
|
|
218
220
|
}[] | undefined;
|
|
219
221
|
editable?: boolean | undefined;
|
|
220
222
|
} | null;
|
|
223
|
+
getCurrentBlocks(): Generator<Block>;
|
|
221
224
|
_selectedText: ComputedRef<string>;
|
|
222
225
|
get selectedText(): string;
|
|
223
226
|
moveOffset(newOffset: number): void;
|
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, reactive, computed, ref, defineComponent, getCurrentInstance, h, nextTick, useSlots, isProxy, toRaw, onMounted, openBlock, createElementBlock, Fragment, renderList, createBlock,
|
|
7
|
+
import { getCurrentScope, onScopeDispose, unref, watch, reactive, computed, ref, defineComponent, getCurrentInstance, h, nextTick, useSlots, isProxy, toRaw, onMounted, openBlock, createElementBlock, renderSlot, Fragment, renderList, createBlock, createCommentVNode } from "vue";
|
|
8
8
|
function tryOnScopeDispose(fn) {
|
|
9
9
|
if (getCurrentScope()) {
|
|
10
10
|
onScopeDispose(fn);
|
|
@@ -281,6 +281,17 @@ class TextEditorStore {
|
|
|
281
281
|
get currentBlock() {
|
|
282
282
|
return this._currentBlock.value;
|
|
283
283
|
}
|
|
284
|
+
*getCurrentBlocks() {
|
|
285
|
+
const blockAnchorIndex = this.blocks.findIndex((item) => item.id === this.selection.anchor.blockId);
|
|
286
|
+
const focusAnchorIndex = this.blocks.findIndex((item) => item.id === this.selection.focus.blockId);
|
|
287
|
+
if (blockAnchorIndex === -1 || focusAnchorIndex === -1)
|
|
288
|
+
return;
|
|
289
|
+
const start = Math.min(blockAnchorIndex, focusAnchorIndex);
|
|
290
|
+
const end = Math.max(blockAnchorIndex, focusAnchorIndex);
|
|
291
|
+
for (let i = start; i <= end; i++) {
|
|
292
|
+
yield this.blocks[i];
|
|
293
|
+
}
|
|
294
|
+
}
|
|
284
295
|
get selectedText() {
|
|
285
296
|
return this._selectedText.value;
|
|
286
297
|
}
|
|
@@ -1050,6 +1061,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1050
1061
|
isCollapsed: store._isCollapsed,
|
|
1051
1062
|
selection: store.selection,
|
|
1052
1063
|
isFocused: store.isFocused,
|
|
1064
|
+
getCurrentBlocks: store.getCurrentBlocks.bind(store),
|
|
1053
1065
|
toggleStyle: store.toggleStyle.bind(store),
|
|
1054
1066
|
applyStyle: store.applyStyle.bind(store),
|
|
1055
1067
|
removeStyle: store.removeStyle.bind(store),
|
|
@@ -1077,6 +1089,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1077
1089
|
onCut: _cache[3] || (_cache[3] = //@ts-ignore
|
|
1078
1090
|
(...args) => unref(onCut) && unref(onCut)(...args))
|
|
1079
1091
|
}, [
|
|
1092
|
+
renderSlot(_ctx.$slots, "_before"),
|
|
1080
1093
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(store).blocks, (block) => {
|
|
1081
1094
|
return openBlock(), createBlock(_sfc_main$2, {
|
|
1082
1095
|
key: block.id,
|