dragon-editor 3.5.14 → 3.5.15
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/module.json +1 -1
- package/dist/module.mjs +18 -2
- package/dist/runtime/components/DragonEditor.vue +1 -1
- package/dist/runtime/utils/event/block.d.ts +6 -0
- package/dist/runtime/utils/event/cursor.d.ts +6 -0
- package/dist/runtime/utils/event/data.d.ts +7 -0
- package/dist/runtime/utils/event/keyboard.d.ts +7 -0
- package/dist/runtime/utils/event/mouse.d.ts +11 -0
- package/dist/runtime/utils/event/scroll.d.ts +3 -0
- package/dist/runtime/utils/event/touch.d.ts +5 -0
- package/dist/runtime/utils/event/window.d.ts +5 -0
- package/dist/runtime/utils/layout/block.d.ts +7 -0
- package/dist/runtime/utils/layout/body.d.ts +3 -0
- package/dist/runtime/utils/layout/controlbar.d.ts +3 -0
- package/dist/runtime/utils/layout/icon.d.ts +3 -0
- package/dist/runtime/utils/layout/menuBar.d.ts +3 -0
- package/dist/runtime/utils/node/block.d.ts +19 -0
- package/dist/runtime/utils/node/block.js +14 -8
- package/dist/runtime/utils/node/element.d.ts +4 -0
- package/dist/runtime/utils/style/anchor.d.ts +5 -0
- package/dist/runtime/utils/style/decoration.d.ts +4 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -18,6 +18,7 @@ const module = defineNuxtModule({
|
|
|
18
18
|
},
|
|
19
19
|
async setup(options, nuxt) {
|
|
20
20
|
const resolver = createResolver(import.meta.url);
|
|
21
|
+
const typeContent = await readFile(`${__dirname}/runtime/type.d.ts`);
|
|
21
22
|
addComponent({
|
|
22
23
|
name: "DragonEditor",
|
|
23
24
|
filePath: resolver.resolve(__dirname, "./runtime/components/DragonEditor")
|
|
@@ -28,10 +29,25 @@ const module = defineNuxtModule({
|
|
|
28
29
|
});
|
|
29
30
|
addTypeTemplate({
|
|
30
31
|
filename: "types/dragon-editor.d.ts",
|
|
31
|
-
src: resolver.resolve(__dirname, "./runtime/type.d.ts"),
|
|
32
|
-
write: true
|
|
32
|
+
// src: resolver.resolve(__dirname, "./runtime/type.d.ts"),
|
|
33
|
+
// write: true,
|
|
34
|
+
getContents: () => `
|
|
35
|
+
declare global {
|
|
36
|
+
${typeContent}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export {}
|
|
40
|
+
`
|
|
33
41
|
});
|
|
34
42
|
}
|
|
35
43
|
});
|
|
44
|
+
async function readFile(path) {
|
|
45
|
+
if (typeof Bun !== "undefined" && Bun.file) {
|
|
46
|
+
const file = Bun.file(path);
|
|
47
|
+
return await file.text();
|
|
48
|
+
}
|
|
49
|
+
const { promises: fs } = await import('fs');
|
|
50
|
+
return await fs.readFile(path, "utf-8");
|
|
51
|
+
}
|
|
36
52
|
|
|
37
53
|
export { module as default };
|
|
@@ -10,7 +10,7 @@ import { _addBlock } from "../utils/node";
|
|
|
10
10
|
import { _setDecoration, _setTextAlign } from "../utils/style";
|
|
11
11
|
import type { VNode } from "vue";
|
|
12
12
|
import { codeToHtml } from "shiki";
|
|
13
|
-
import "../type.d.ts";
|
|
13
|
+
import type { DEBlockData, DEBlockMenutype, DEContentData, DEDecoration, DETextalign, DragonEditorStore } from "../type.d.ts";
|
|
14
14
|
|
|
15
15
|
interface DEOption {
|
|
16
16
|
modelValue: DEContentData;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { DragonEditorStore } from "../../type.js";
|
|
3
|
+
export declare function _imageResizeEventStart(event: Event, store: Ref<DragonEditorStore>): void;
|
|
4
|
+
export declare function _imageResizeEvent(event: Event, store: Ref<DragonEditorStore>): void;
|
|
5
|
+
export declare function _imageResizeEventEnd(event: Event, store: Ref<DragonEditorStore>): void;
|
|
6
|
+
export declare function _moveBlock(type: "up" | "down", store: Ref<DragonEditorStore>): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { DEArrangeCursorData, DEditorCursor, DragonEditorStore } from "../../type.js";
|
|
3
|
+
export declare function _updateCursorData(store: Ref<DragonEditorStore>): void;
|
|
4
|
+
export declare function _setCursor($target: Node, startIdx: number): void;
|
|
5
|
+
export declare function _setRangeCursor($startTarget: Element, $endTarget: Element, startIdx: number, endIdx: number): void;
|
|
6
|
+
export declare function _sortingCursorDataOnElement(cursorData: DEditorCursor, $element: HTMLElement): DEArrangeCursorData;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { DECodeItem, DECodeblockLang, DragonEditorStore, DEBlockData, DEBlockMenutype } from "../../type.js";
|
|
3
|
+
export declare const CODEBLOCKLANG: DECodeItem<DECodeblockLang>[];
|
|
4
|
+
export declare function _updateModelData(store: Ref<DragonEditorStore>): void;
|
|
5
|
+
export declare function _getDefaultBlockData(type: DEBlockMenutype): DEBlockData;
|
|
6
|
+
export declare function _generateId(): string;
|
|
7
|
+
export declare function _updateControlBarStatus(store: Ref<DragonEditorStore>): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { DragonEditorStore } from "../../type.js";
|
|
3
|
+
export declare function _contentKeydownEvent(event: KeyboardEvent, store: Ref<DragonEditorStore>): void;
|
|
4
|
+
export declare function _contentPasteEvent(event: ClipboardEvent, store: Ref<DragonEditorStore>): Promise<void>;
|
|
5
|
+
export declare function _setIndent(store: Ref<DragonEditorStore>, type: "plus" | "minus"): void;
|
|
6
|
+
export declare function _hotKeyEvent(event: KeyboardEvent, store: Ref<DragonEditorStore>): void;
|
|
7
|
+
export declare function _contentKeyupEvent(event: KeyboardEvent, store: Ref<DragonEditorStore>): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { DragonEditorStore } from "../../type.js";
|
|
3
|
+
export declare function _contentMouseupEvent(event: MouseEvent, store: Ref<DragonEditorStore>): void;
|
|
4
|
+
export declare function _contentMousedownEvnet(event: MouseEvent, store: Ref<DragonEditorStore>): void;
|
|
5
|
+
export declare function _editorMousemoveEvent(event: MouseEvent, store: Ref<DragonEditorStore>): void;
|
|
6
|
+
export declare function _editorMouseupEvent(event: MouseEvent, store: Ref<DragonEditorStore>): void;
|
|
7
|
+
export declare function _editorMouseleaveEvent(event: MouseEvent, store: Ref<DragonEditorStore>): void;
|
|
8
|
+
export declare function _checkOthersideClick(event: MouseEvent, store: Ref<DragonEditorStore>): void;
|
|
9
|
+
export declare function _openAnchorArea(store: Ref<DragonEditorStore>): void;
|
|
10
|
+
export declare function _decideWhetherOpenControlBar(store: Ref<DragonEditorStore>): void;
|
|
11
|
+
export declare function _editorContextMenuEvent(event: MouseEvent, store: Ref<DragonEditorStore>): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { DragonEditorStore } from "../../type.js";
|
|
3
|
+
export declare function _contentTouchstartEvent(event: TouchEvent, store: Ref<DragonEditorStore>): void;
|
|
4
|
+
export declare function _editorTouchmoveEvent(event: TouchEvent, store: Ref<DragonEditorStore>): void;
|
|
5
|
+
export declare function _editorTouchendEvent(event: TouchEvent, store: Ref<DragonEditorStore>): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { DragonEditorStore } from "../../type.js";
|
|
3
|
+
export declare function _eidtorMountEvent(store: Ref<DragonEditorStore>): void;
|
|
4
|
+
export declare function _eidtorUnmountEvent(store: Ref<DragonEditorStore>): void;
|
|
5
|
+
export declare function _windowResizeEvent(event: Event, store: Ref<DragonEditorStore>): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { DEBlockMenutype, DragonEditorStore, DEBlockData, DETextBlock, DEBlock, DEHeadingBlock, DEListBlock, DEListItem, DEImageBlock, DECodeBlock, DECustomBlock, DECodeblockTheme, DECodeblockLang, DEListStyle } from "../../type.js";
|
|
3
|
+
export declare function _addBlock(type: DEBlockMenutype, store: Ref<DragonEditorStore>, data?: DEBlockData): void;
|
|
4
|
+
export declare function _getCurrentBlock($target: EventTarget): {
|
|
5
|
+
type: DEBlock;
|
|
6
|
+
$element: HTMLDivElement | null;
|
|
7
|
+
};
|
|
8
|
+
export declare function _createTextBlock(data: DETextBlock): HTMLParagraphElement;
|
|
9
|
+
export declare function _createHeadingBlock(data: DEHeadingBlock): HTMLHeadingElement;
|
|
10
|
+
export declare function _createListBlock(data: DEListBlock): HTMLElement;
|
|
11
|
+
export declare function _createListItemBlock(child?: DEListItem): HTMLLIElement;
|
|
12
|
+
export declare function _createImageBlock(data: DEImageBlock, imageHostURL?: string): HTMLDivElement;
|
|
13
|
+
export declare function _createCodeBlock(data: DECodeBlock, store: Ref<DragonEditorStore>): HTMLDivElement;
|
|
14
|
+
export declare function _createCustomBlock(data: DECustomBlock): HTMLDivElement;
|
|
15
|
+
export declare function _updateCurrentBlock(event: Event, store: Ref<DragonEditorStore>): void;
|
|
16
|
+
export declare function _updateHeadingBlockList(store: Ref<DragonEditorStore>): void;
|
|
17
|
+
export declare function _setCodeBlockTheme(theme: DECodeblockTheme, store: Ref<DragonEditorStore>): Promise<void>;
|
|
18
|
+
export declare function _setCodeBlockLanguage(language: DECodeblockLang, store: Ref<DragonEditorStore>): Promise<void>;
|
|
19
|
+
export declare function _setListBlockStyle(style: DEListStyle, store: Ref<DragonEditorStore>): void;
|
|
@@ -213,9 +213,12 @@ export async function _setCodeBlockTheme(theme, store) {
|
|
|
213
213
|
const convert = await store.value.codeToHtml($code.textContent ?? "", { lang: store.value.controlStatus.codeBlockLang, theme });
|
|
214
214
|
const $div = document.createElement("div");
|
|
215
215
|
$div.innerHTML = convert;
|
|
216
|
-
$
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
const $childCode = $div.querySelector("code");
|
|
217
|
+
if ($childCode !== null) {
|
|
218
|
+
$code.innerHTML = $childCode.innerHTML;
|
|
219
|
+
store.value.controlStatus.codeBlockTheme = theme;
|
|
220
|
+
store.value.controlStatus.$currentBlock.dataset["theme"] = theme;
|
|
221
|
+
}
|
|
219
222
|
_updateCursorData(store);
|
|
220
223
|
_updateModelData(store);
|
|
221
224
|
}
|
|
@@ -231,11 +234,14 @@ export async function _setCodeBlockLanguage(language, store) {
|
|
|
231
234
|
const convert = await store.value.codeToHtml($code.textContent ?? "", { lang: language, theme: store.value.controlStatus.codeBlockTheme });
|
|
232
235
|
const $div = document.createElement("div");
|
|
233
236
|
$div.innerHTML = convert;
|
|
234
|
-
$
|
|
235
|
-
$
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
const $childCode = $div.querySelector("code");
|
|
238
|
+
if ($childCode !== null) {
|
|
239
|
+
$target.textContent = targetValue.text;
|
|
240
|
+
$code.innerHTML = $childCode.innerHTML;
|
|
241
|
+
store.value.controlStatus.codeBlockLang = targetValue.code;
|
|
242
|
+
_updateCursorData(store);
|
|
243
|
+
_updateModelData(store);
|
|
244
|
+
}
|
|
239
245
|
}
|
|
240
246
|
}
|
|
241
247
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function _findScrollingElement($target: HTMLElement): HTMLElement | Window;
|
|
2
|
+
export declare function _getParentElementIfNodeIsText($target: Node, $block: HTMLElement): Node;
|
|
3
|
+
export declare function _findContentEditableElement($target: Node): HTMLElement | null;
|
|
4
|
+
export declare function _findPoverTextNode(node: Element, idx: number): number;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { DragonEditorStore } from "../../type.js";
|
|
3
|
+
export declare function _setAnchorTag(url: string, isOutsideLink: boolean, store: Ref<DragonEditorStore>): void;
|
|
4
|
+
export declare function _unsetAnchorTag(store: Ref<DragonEditorStore>): false | undefined;
|
|
5
|
+
export declare function _updateAnchorTagValue(store: Ref<DragonEditorStore>, previous?: boolean): void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { DragonEditorStore, DETextalign } from "../../type.js";
|
|
3
|
+
export declare function _setDecoration(className: string, store: Ref<DragonEditorStore>): void;
|
|
4
|
+
export declare function _setTextAlign(type: DETextalign, store: Ref<DragonEditorStore>): void;
|