vuewrite 0.0.23-a → 0.0.23-b
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 +3 -1
- package/dist/vuewrite.js +12 -0
- 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;
|
|
@@ -150,7 +151,7 @@ declare class TextEditorHistory {
|
|
|
150
151
|
redo(): void;
|
|
151
152
|
}
|
|
152
153
|
|
|
153
|
-
export declare type TextEditorRef = Pick<TextEditorStore, "currentStyles" | "currentBlock" | "isCollapsed" | "selection" | "toggleStyle" | "applyStyle" | "removeStyle" | "insertText" | "insertBlock" | "addNewLine" | "removeNewLine" | "selectAll" | "removeCurrentBlock"> & {
|
|
154
|
+
export declare type TextEditorRef = Pick<TextEditorStore, "currentStyles" | "currentBlock" | "isCollapsed" | "selection" | "getCurrentBlocks" | "toggleStyle" | "applyStyle" | "removeStyle" | "insertText" | "insertBlock" | "addNewLine" | "removeNewLine" | "selectAll" | "removeCurrentBlock"> & {
|
|
154
155
|
isFocused: boolean;
|
|
155
156
|
getClientRects: (selection: TextEditorSelection) => DOMRectList;
|
|
156
157
|
pushHistory: TextEditorHistory["push"];
|
|
@@ -218,6 +219,7 @@ declare class TextEditorStore {
|
|
|
218
219
|
}[] | undefined;
|
|
219
220
|
editable?: boolean | undefined;
|
|
220
221
|
} | null;
|
|
222
|
+
getCurrentBlocks(): Generator<Block>;
|
|
221
223
|
_selectedText: ComputedRef<string>;
|
|
222
224
|
get selectedText(): string;
|
|
223
225
|
moveOffset(newOffset: number): void;
|
package/dist/vuewrite.js
CHANGED
|
@@ -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),
|