dragon-editor 3.5.13 → 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 CHANGED
@@ -4,7 +4,7 @@
4
4
  "nuxt": ">=3.0.0"
5
5
  },
6
6
  "configKey": "dragon-editor",
7
- "version": "3.5.13",
7
+ "version": "3.5.15",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
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, "./types.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,3 @@
1
+ import type { DragonEditorStore } from "../../type.js";
2
+ import type { Ref } from "vue";
3
+ export declare function _parentWrapScollEvent(event: Event, 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,7 @@
1
+ import type { VNode } from "vue";
2
+ import type { DEContentData } from "../../type.js";
3
+ export declare function _createBlockList({ blockList, isEditable, imageHostURL }?: {
4
+ blockList: DEContentData;
5
+ isEditable: boolean;
6
+ imageHostURL: string;
7
+ }): VNode[];
@@ -0,0 +1,3 @@
1
+ import type { VNode, Ref } from "vue";
2
+ import type { DragonEditorStore } from "../../type.js";
3
+ export declare function _getBodyVNodeStructure(store: Ref<DragonEditorStore>): VNode;
@@ -0,0 +1,3 @@
1
+ import type { VNode, Ref } from "vue";
2
+ import type { DragonEditorStore } from "../../type.js";
3
+ export declare function _getControlbarVNodeStructure(store: Ref<DragonEditorStore>): VNode;
@@ -0,0 +1,3 @@
1
+ import type { VNode } from "vue";
2
+ import type { DEIconKind } from "../../type.js";
3
+ export declare function _getIconNode(kind: DEIconKind): VNode;
@@ -0,0 +1,3 @@
1
+ import type { VNode, Ref } from "vue";
2
+ import type { DragonEditorStore } from "../../type.js";
3
+ export declare function _getMenuBarVNodeStructure(store: Ref<DragonEditorStore>): VNode;
@@ -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
- $code.innerHTML = $div.querySelector("code").innerHTML;
217
- store.value.controlStatus.codeBlockTheme = theme;
218
- store.value.controlStatus.$currentBlock.dataset["theme"] = theme;
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
- $target.textContent = targetValue.text;
235
- $code.innerHTML = $div.querySelector("code").innerHTML;
236
- store.value.controlStatus.codeBlockLang = targetValue.code;
237
- _updateCursorData(store);
238
- _updateModelData(store);
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dragon-editor",
3
- "version": "3.5.13",
3
+ "version": "3.5.15",
4
4
  "description": "Javascript WYSIWYG editor in Nuxt3!",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,7 +10,7 @@
10
10
  "type": "module",
11
11
  "exports": {
12
12
  ".": {
13
- "types": "./dist/types.d.ts",
13
+ "types": "./dist/module.d.ts",
14
14
  "import": "./dist/module.mjs",
15
15
  "require": "./dist/module.cjs"
16
16
  }