dragon-editor 3.4.4 → 3.5.0

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.
Files changed (70) hide show
  1. package/README.md +9 -15
  2. package/dist/module.d.mts +5 -0
  3. package/dist/module.json +8 -1
  4. package/dist/module.mjs +5 -3
  5. package/dist/runtime/components/DragonEditor.vue +252 -720
  6. package/dist/runtime/components/DragonEditorViewer.vue +59 -45
  7. package/dist/runtime/scss/editor.css +83 -34
  8. package/dist/runtime/scss/viewer.css +31 -4
  9. package/dist/runtime/type.d.ts +78 -23
  10. package/dist/runtime/utils/event/block.d.ts +0 -0
  11. package/dist/runtime/utils/event/block.js +78 -0
  12. package/dist/runtime/utils/event/cursor.d.ts +0 -0
  13. package/dist/runtime/utils/{cursor.mjs → event/cursor.js} +4 -16
  14. package/dist/runtime/utils/event/data.d.ts +0 -0
  15. package/dist/runtime/utils/event/data.js +342 -0
  16. package/dist/runtime/utils/event/index.d.ts +8 -0
  17. package/dist/runtime/utils/event/index.js +8 -0
  18. package/dist/runtime/utils/event/keyboard.d.ts +0 -0
  19. package/dist/runtime/utils/event/keyboard.js +1368 -0
  20. package/dist/runtime/utils/event/mouse.d.ts +0 -0
  21. package/dist/runtime/utils/event/mouse.js +70 -0
  22. package/dist/runtime/utils/event/scroll.d.ts +0 -0
  23. package/dist/runtime/utils/event/scroll.js +29 -0
  24. package/dist/runtime/utils/event/touch.d.ts +0 -0
  25. package/dist/runtime/utils/event/touch.js +10 -0
  26. package/dist/runtime/utils/event/window.d.ts +0 -0
  27. package/dist/runtime/utils/event/window.js +32 -0
  28. package/dist/runtime/utils/layout/block.d.ts +0 -0
  29. package/dist/runtime/utils/layout/block.js +105 -0
  30. package/dist/runtime/utils/layout/body.d.ts +0 -0
  31. package/dist/runtime/utils/layout/body.js +22 -0
  32. package/dist/runtime/utils/layout/controlbar.d.ts +0 -0
  33. package/dist/runtime/utils/layout/controlbar.js +99 -0
  34. package/dist/runtime/utils/layout/icon.d.ts +0 -0
  35. package/dist/runtime/utils/layout/icon.js +156 -0
  36. package/dist/runtime/utils/layout/index.d.ts +5 -0
  37. package/dist/runtime/utils/layout/index.js +5 -0
  38. package/dist/runtime/utils/layout/menuBar.d.ts +0 -0
  39. package/dist/runtime/utils/layout/menuBar.js +358 -0
  40. package/dist/runtime/utils/node/block.d.ts +0 -0
  41. package/dist/runtime/utils/node/block.js +235 -0
  42. package/dist/runtime/utils/{element.d.ts → node/element.d.ts} +1 -0
  43. package/dist/runtime/utils/{element.mjs → node/element.js} +19 -4
  44. package/dist/runtime/utils/node/index.d.ts +2 -0
  45. package/dist/runtime/utils/node/index.js +2 -0
  46. package/dist/runtime/utils/style/anchor.d.ts +0 -0
  47. package/dist/runtime/utils/style/anchor.js +240 -0
  48. package/dist/runtime/utils/style/decoration.d.ts +0 -0
  49. package/dist/runtime/utils/style/decoration.js +378 -0
  50. package/dist/runtime/utils/style/index.d.ts +2 -0
  51. package/dist/runtime/utils/style/index.js +2 -0
  52. package/dist/types.d.mts +7 -0
  53. package/dist/types.d.ts +3 -3
  54. package/package.json +15 -16
  55. package/dist/runtime/store.d.ts +0 -11
  56. package/dist/runtime/store.mjs +0 -51
  57. package/dist/runtime/utils/block.d.ts +0 -13
  58. package/dist/runtime/utils/block.mjs +0 -144
  59. package/dist/runtime/utils/content.d.ts +0 -2
  60. package/dist/runtime/utils/content.mjs +0 -19
  61. package/dist/runtime/utils/controlBar.d.ts +0 -9
  62. package/dist/runtime/utils/controlBar.mjs +0 -172
  63. package/dist/runtime/utils/convertor.d.ts +0 -3
  64. package/dist/runtime/utils/convertor.mjs +0 -138
  65. package/dist/runtime/utils/cursor.d.ts +0 -6
  66. package/dist/runtime/utils/keyboardEvent.d.ts +0 -10
  67. package/dist/runtime/utils/keyboardEvent.mjs +0 -978
  68. package/dist/runtime/utils/style.d.ts +0 -5
  69. package/dist/runtime/utils/style.mjs +0 -617
  70. /package/dist/runtime/{plugin.mjs → plugin.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dragon-editor",
3
- "version": "3.4.4",
3
+ "version": "3.5.0",
4
4
  "description": "Javascript WYSIWYG editor in Nuxt3!",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,29 +24,28 @@
24
24
  "prepack": "nuxt-module-build",
25
25
  "dev": "nuxi dev playground",
26
26
  "dev:build": "nuxi build playground",
27
- "dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
27
+ "dev:prepare": "nuxt-module-build build --stub && nuxi prepare playground",
28
28
  "release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
29
29
  "lint": "eslint .",
30
30
  "test": "vitest run",
31
31
  "test:watch": "vitest watch"
32
32
  },
33
33
  "dependencies": {
34
- "@nuxt/kit": "^3.5.0",
35
- "@pinia/nuxt": "^0.5.3",
36
- "highlight.js": "^11.10.0",
37
- "sass": "^1.77.8"
34
+ "@nuxt/kit": "^3.16.1",
35
+ "highlight.js": "^11.11.1"
38
36
  },
39
37
  "devDependencies": {
40
- "@nuxt/eslint-config": "^0.1.1",
41
- "@nuxt/module-builder": "^0.3.1",
42
- "@nuxt/schema": "^3.5.0",
43
- "@nuxt/test-utils": "^3.5.0",
44
- "@types/node": "^18",
45
- "changelogen": "^0.5.3",
46
- "eslint": "^8.40.0",
47
- "nuxt": "^3.5.0",
48
- "sass-embedded": "^1.77.8",
49
- "vitest": "^0.31.0"
38
+ "@nuxt/eslint-config": "^1.2.0",
39
+ "@nuxt/module-builder": "^0.8.4",
40
+ "@nuxt/schema": "^3.16.1",
41
+ "@nuxt/test-utils": "^3.17.2",
42
+ "@types/bun": "^1.2.8",
43
+ "changelogen": "^0.6.1",
44
+ "eslint": "^9.23.0",
45
+ "nuxt": "^3.16.1",
46
+ "sass": "^1.86.0",
47
+ "sass-embedded": "^1.86.0",
48
+ "vitest": "^3.0.9"
50
49
  },
51
50
  "keywords": [
52
51
  "editor",
@@ -1,11 +0,0 @@
1
- import "./type.d.ts";
2
- export declare const useEditorStore: import("pinia").StoreDefinition<"editorStore", EditorStore, {}, {
3
- setWrapElement(value: HTMLDivElement): void;
4
- setContentElement(value: HTMLDivElement): void;
5
- setParentWrapElement(value: HTMLElement | Window): void;
6
- setCursorData(data: DEditorCursor): void;
7
- setCurrentBlock(block: HTMLElement | null): void;
8
- setContrulBar(value: HTMLDivElement): void;
9
- controlBarActive(): void;
10
- controlBarDeactive(): void;
11
- }>;
@@ -1,51 +0,0 @@
1
- import { defineStore } from "pinia";
2
- import "./type.d.ts";
3
- export const useEditorStore = defineStore("editorStore", {
4
- state: () => ({
5
- cursorData: null,
6
- message: {
7
- linkTextNoStyle: "Link text can't set any style."
8
- },
9
- controlBar: {
10
- active: false,
11
- x: 0,
12
- y: 0,
13
- $element: null
14
- },
15
- $currentBlock: null,
16
- $editor: null,
17
- $content: null,
18
- $parentWrap: null
19
- }),
20
- actions: {
21
- setWrapElement(value) {
22
- this.$editor = value;
23
- },
24
- setContentElement(value) {
25
- this.$content = value;
26
- },
27
- setParentWrapElement(value) {
28
- this.$parentWrap = value;
29
- },
30
- setCursorData(data) {
31
- this.cursorData = data;
32
- },
33
- setCurrentBlock(block) {
34
- this.$currentBlock = block;
35
- },
36
- setContrulBar(value) {
37
- this.controlBar.$element = value;
38
- },
39
- controlBarActive() {
40
- if (this.$currentBlock !== null) {
41
- const currentRect = this.$currentBlock.getBoundingClientRect();
42
- this.controlBar.active = true;
43
- this.controlBar.x = Math.floor(currentRect.x + currentRect.width / 2);
44
- this.controlBar.y = Math.floor(currentRect.y - 50);
45
- }
46
- },
47
- controlBarDeactive() {
48
- this.controlBar.active = false;
49
- }
50
- }
51
- });
@@ -1,13 +0,0 @@
1
- import "../type.d.ts";
2
- export declare function _getBlockType(element: HTMLElement): {
3
- $element: Element;
4
- type: string;
5
- };
6
- export declare function _createTextBlock(data?: DETextBlock): HTMLParagraphElement;
7
- export declare function _createHeadingBlock(data: DEHeadingBlock): HTMLHeadingElement;
8
- export declare function _createListBlock(data: DEListBlock): HTMLElement;
9
- export declare function _createListItemBlock(child?: DEListItem): HTMLLIElement;
10
- export declare function _createImageBlock(data: DEImageBlock, imageHostURL?: string): HTMLDivElement;
11
- export declare function _createCodeBlock(data: DECodeBlock): HTMLDivElement;
12
- export declare function _generateId(): string;
13
- export declare function _createCustomBlock(data: DECustomBlock): HTMLDivElement;
@@ -1,144 +0,0 @@
1
- import "../type.d.ts";
2
- export function _getBlockType(element) {
3
- const $block = element.closest(".de-block");
4
- let typeName;
5
- switch (true) {
6
- case $block.classList.contains("de-text-block"):
7
- typeName = "text";
8
- break;
9
- case $block.classList.contains("de-heading-block"):
10
- typeName = "heading";
11
- break;
12
- case $block.classList.contains("de-list-block"):
13
- typeName = "list";
14
- break;
15
- case $block.classList.contains("de-image-block"):
16
- typeName = "image";
17
- break;
18
- case $block.classList.contains("de-code-block"):
19
- typeName = "code";
20
- break;
21
- default:
22
- typeName = "other";
23
- }
24
- return {
25
- $element: $block,
26
- type: typeName
27
- };
28
- }
29
- export function _createTextBlock(data = { type: "text", classList: [], textContent: "" }) {
30
- const $paragraph = document.createElement("p");
31
- $paragraph.classList.add("de-block", "de-text-block", ...data.classList);
32
- $paragraph.setAttribute("contenteditable", "true");
33
- if (data.textContent !== "") {
34
- $paragraph.innerHTML = data.textContent;
35
- }
36
- return $paragraph;
37
- }
38
- export function _createHeadingBlock(data) {
39
- const $headingBlock = document.createElement(`h${data.level}`);
40
- if (data.id === "") {
41
- $headingBlock.id = _generateId();
42
- } else {
43
- $headingBlock.id = data.id;
44
- }
45
- $headingBlock.classList.add("de-block", "de-heading-block", ...data.classList);
46
- $headingBlock.dataset["level"] = String(data.level);
47
- $headingBlock.setAttribute("contenteditable", "true");
48
- if (data.textContent !== "") {
49
- $headingBlock.innerHTML = data.textContent;
50
- }
51
- return $headingBlock;
52
- }
53
- export function _createListBlock(data) {
54
- const $block = document.createElement(data.element);
55
- $block.classList.add("de-block", "de-list-block");
56
- $block.dataset["style"] = data.style;
57
- data.child.forEach((child) => {
58
- $block.appendChild(_createListItemBlock(child));
59
- });
60
- return $block;
61
- }
62
- export function _createListItemBlock(child = { textContent: "", classList: [] }) {
63
- const $li = document.createElement("li");
64
- $li.classList.add("de-item", ...child.classList);
65
- $li.setAttribute("contenteditable", "true");
66
- if (child.textContent !== "") {
67
- $li.innerHTML = child.textContent;
68
- }
69
- return $li;
70
- }
71
- export function _createImageBlock(data, imageHostURL = "") {
72
- const $wrap = document.createElement("div");
73
- const $div = document.createElement("div");
74
- const $leftBtn = document.createElement("button");
75
- const $rightBtn = document.createElement("button");
76
- const $image = document.createElement("img");
77
- const $p = document.createElement("p");
78
- $wrap.classList.add("de-block", "de-image-block", ...data.classList);
79
- $div.classList.add("de-image-area");
80
- $leftBtn.classList.add("de-btn", "de-btn-left");
81
- $rightBtn.classList.add("de-btn", "de-btn-right");
82
- $image.classList.add("de-img");
83
- $p.contentEditable = "true";
84
- $p.classList.add("de-caption");
85
- if (data.width / data.height < 1) {
86
- $div.dataset["maxwidth"] = "40";
87
- } else {
88
- $div.dataset["maxwidth"] = String(data.maxWidth);
89
- }
90
- $image.src = imageHostURL + data.src;
91
- $image.width = data.width;
92
- $image.height = data.height;
93
- $image.draggable = false;
94
- if (data.caption !== void 0) {
95
- $p.textContent = data.caption;
96
- }
97
- $div.appendChild($image);
98
- $div.appendChild($leftBtn);
99
- $div.appendChild($rightBtn);
100
- $wrap.appendChild($div);
101
- $wrap.appendChild($p);
102
- return $wrap;
103
- }
104
- export function _createCodeBlock(data) {
105
- const $wrap = document.createElement("div");
106
- const $file = document.createElement("p");
107
- const $lang = document.createElement("p");
108
- const $pre = document.createElement("pre");
109
- const $code = document.createElement("code");
110
- $wrap.classList.add("de-block", "de-code-block");
111
- $wrap.dataset["theme"] = data.theme;
112
- $file.contentEditable = "true";
113
- $file.classList.add("de-filename");
114
- $lang.textContent = data.language;
115
- $lang.classList.add("de-language");
116
- $pre.classList.add("de-pre");
117
- $code.contentEditable = "true";
118
- $code.classList.add("de-code-content");
119
- if (data.filename !== "") {
120
- $file.textContent = data.filename;
121
- }
122
- if (data.textContent !== "") {
123
- $code.innerHTML = data.textContent;
124
- }
125
- $pre.appendChild($code);
126
- $wrap.appendChild($file);
127
- $wrap.appendChild($lang);
128
- $wrap.appendChild($pre);
129
- return $wrap;
130
- }
131
- export function _generateId() {
132
- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
133
- let str = "";
134
- for (let i = 0; i < 6; i++) {
135
- str += chars.charAt(Math.floor(Math.random() * chars.length));
136
- }
137
- return str;
138
- }
139
- export function _createCustomBlock(data) {
140
- const $block = document.createElement("div");
141
- $block.classList.add("de-block", "de-custom-block", ...data.classList);
142
- $block.innerHTML = data.textContent;
143
- return $block;
144
- }
@@ -1,2 +0,0 @@
1
- import "../type.d.ts";
2
- export declare function _addBlockToContent($block: HTMLElement, store: any): void;
@@ -1,19 +0,0 @@
1
- import { _clenupCursor } from "./cursor.mjs";
2
- import "../type.d.ts";
3
- export function _addBlockToContent($block, store) {
4
- if (store.cursorData === null && store.$currentBlock === null) {
5
- store.$content.insertAdjacentElement("beforeend", $block);
6
- } else {
7
- _clenupCursor(store);
8
- if (store.$currentBlock === null) {
9
- let $target = store.cursorData.startNode;
10
- if ($target.constructor.name === "Text") {
11
- $target = $target.parentNode;
12
- }
13
- const $targetBlock = $target.closest(".de-block");
14
- $targetBlock.insertAdjacentElement("afterend", $block);
15
- } else {
16
- store.$currentBlock.insertAdjacentElement("afterend", $block);
17
- }
18
- }
19
- }
@@ -1,9 +0,0 @@
1
- import type { Ref } from "vue";
2
- import "../type.d.ts";
3
- export declare function _getCodeBlockTheme(): DECodeItem[];
4
- export declare function _getCodeBlockLanguage(): DECodeItem[];
5
- export declare function _setCodeBlockTheme(store: any, theme: string): void;
6
- export declare function _setCodeBlockLanguage(store: any, lang: string): void;
7
- export declare function _updateCodeBlockStyle(store: any, themeRef: Ref<string>, langRef: Ref<string>): void;
8
- export declare function _setListBlockStyle(store: any, style: DEListStyle): void;
9
- export declare function _updateListBlockStyle(store: any, styleRef: Ref<DEListStyle>): void;
@@ -1,172 +0,0 @@
1
- import { _getBlockType } from "./block.mjs";
2
- import hljs from "highlight.js";
3
- import "../type.d.ts";
4
- export function _getCodeBlockTheme() {
5
- return [
6
- {
7
- text: "GitHub",
8
- code: "github"
9
- },
10
- {
11
- text: "GitHub Dark Dimmed",
12
- code: "github-dark-dimmed"
13
- }
14
- ];
15
- }
16
- export function _getCodeBlockLanguage() {
17
- return [
18
- {
19
- text: "Plain Text",
20
- code: "text"
21
- },
22
- {
23
- text: "Bash",
24
- code: "bash"
25
- },
26
- {
27
- text: "C#",
28
- code: "csharp"
29
- },
30
- {
31
- text: "C",
32
- code: "c"
33
- },
34
- {
35
- text: "C++",
36
- code: "cpp"
37
- },
38
- {
39
- text: "CSS",
40
- code: "css"
41
- },
42
- {
43
- text: "Django",
44
- code: "django"
45
- },
46
- {
47
- text: "Dockerfile",
48
- code: "dockerfile"
49
- },
50
- {
51
- text: "Go",
52
- code: "go"
53
- },
54
- {
55
- text: "HTML, XML",
56
- code: "html"
57
- },
58
- {
59
- text: "JSON",
60
- code: "json"
61
- },
62
- {
63
- text: "Java",
64
- code: "java"
65
- },
66
- {
67
- text: "JavaScript",
68
- code: "js"
69
- },
70
- {
71
- text: "TypeScript",
72
- code: "ts"
73
- },
74
- {
75
- text: "Kotlin",
76
- code: "kotlin"
77
- },
78
- {
79
- text: "Lua",
80
- code: "lua"
81
- },
82
- {
83
- text: "Markdown",
84
- code: "md"
85
- },
86
- {
87
- text: "Nginx",
88
- code: "nginx"
89
- },
90
- {
91
- text: "PHP",
92
- code: "php"
93
- },
94
- {
95
- text: "Python",
96
- code: "python"
97
- },
98
- {
99
- text: "Ruby",
100
- code: "ruby"
101
- },
102
- {
103
- text: "SCSS",
104
- code: "scss"
105
- },
106
- {
107
- text: "SQL",
108
- code: "sql"
109
- },
110
- {
111
- text: "Shell",
112
- code: "shell"
113
- },
114
- {
115
- text: "Swift",
116
- code: "swift"
117
- },
118
- {
119
- text: "YAML",
120
- code: "yml"
121
- }
122
- ];
123
- }
124
- export function _setCodeBlockTheme(store, theme) {
125
- if (store.$currentBlock !== null) {
126
- const { $element, type } = _getBlockType(store.$currentBlock);
127
- if (type === "code") {
128
- $element.dataset["theme"] = theme;
129
- }
130
- }
131
- }
132
- export function _setCodeBlockLanguage(store, lang) {
133
- if (store.$currentBlock !== null) {
134
- const { $element, type } = _getBlockType(store.$currentBlock);
135
- if (type === "code") {
136
- const $langText = $element.querySelector(".de-language");
137
- const $code = $element.querySelector(".de-code-content");
138
- const convert = hljs.highlight($code.textContent ?? "", { language: lang });
139
- $langText.textContent = convert._top.name ?? "";
140
- $code.innerHTML = convert.value;
141
- }
142
- }
143
- }
144
- export function _updateCodeBlockStyle(store, themeRef, langRef) {
145
- if (store.$currentBlock !== null) {
146
- const { $element, type } = _getBlockType(store.$currentBlock);
147
- if (type === "code") {
148
- const theme = $element.dataset["theme"] ?? "github";
149
- const $langText = $element.querySelector(".de-language").textContent;
150
- const langItem = _getCodeBlockLanguage().find((item) => item.text === $langText);
151
- themeRef.value = theme;
152
- langRef.value = langItem?.code ?? "Plain Text";
153
- }
154
- }
155
- }
156
- export function _setListBlockStyle(store, style) {
157
- if (store.$currentBlock !== null) {
158
- const { $element, type } = _getBlockType(store.$currentBlock);
159
- if (type === "list") {
160
- $element.dataset["style"] = style;
161
- }
162
- }
163
- }
164
- export function _updateListBlockStyle(store, styleRef) {
165
- if (store.$currentBlock !== null) {
166
- const { $element, type } = _getBlockType(store.$currentBlock);
167
- if (type === "list") {
168
- const style = $element.dataset["style"];
169
- styleRef.value = style;
170
- }
171
- }
172
- }
@@ -1,3 +0,0 @@
1
- import "../type.d.ts";
2
- export declare function _getContentData($content: HTMLDivElement, imageHostURL: string): DEContentData;
3
- export declare function _setContentData(data: DEContentData, store: any, imageHostURL: string): void;
@@ -1,138 +0,0 @@
1
- import { _createTextBlock, _createHeadingBlock, _createListBlock, _createImageBlock, _createCodeBlock, _createCustomBlock } from "./block.mjs";
2
- import "../type.d.ts";
3
- export function _getContentData($content, imageHostURL) {
4
- const childList = $content.children;
5
- const data = [];
6
- [...childList].forEach(($child) => {
7
- const tagName = $child.tagName;
8
- switch (tagName) {
9
- case "P":
10
- data.push(converteParagraphToData($child));
11
- break;
12
- case "H1":
13
- data.push(converteHeadingToData($child, 1));
14
- break;
15
- case "H2":
16
- data.push(converteHeadingToData($child, 2));
17
- break;
18
- case "H3":
19
- data.push(converteHeadingToData($child, 3));
20
- break;
21
- case "UL":
22
- case "OL":
23
- data.push(converteListToData($child));
24
- break;
25
- case "DIV":
26
- data.push(converteDivToData($child, imageHostURL));
27
- break;
28
- }
29
- });
30
- return data;
31
- }
32
- export function _setContentData(data, store, imageHostURL) {
33
- const childList = [];
34
- data.forEach((item) => {
35
- switch (item.type) {
36
- case "text":
37
- childList.push(_createTextBlock(item));
38
- break;
39
- case "heading":
40
- childList.push(_createHeadingBlock(item));
41
- break;
42
- case "list":
43
- childList.push(_createListBlock(item));
44
- break;
45
- case "image":
46
- childList.push(_createImageBlock(item, imageHostURL));
47
- break;
48
- case "code":
49
- childList.push(_createCodeBlock(item));
50
- break;
51
- case "custom":
52
- childList.push(_createCustomBlock(item));
53
- break;
54
- }
55
- });
56
- store.$content.replaceChildren(...childList);
57
- }
58
- function converteParagraphToData($child) {
59
- return {
60
- type: "text",
61
- classList: getClassListWithoutDefaultClass($child),
62
- textContent: $child.innerHTML
63
- };
64
- }
65
- function converteHeadingToData($child, level) {
66
- return {
67
- type: "heading",
68
- level,
69
- id: $child.id,
70
- classList: getClassListWithoutDefaultClass($child),
71
- textContent: $child.innerHTML
72
- };
73
- }
74
- function converteListToData($child) {
75
- return {
76
- type: "list",
77
- element: $child.tagName.toLowerCase(),
78
- style: $child.dataset["style"],
79
- child: [...$child.children].map(($li) => {
80
- return {
81
- classList: getClassListWithoutDefaultClass($li),
82
- textContent: $li.innerHTML
83
- };
84
- })
85
- };
86
- }
87
- function converteDivToData($child, imageHostURL) {
88
- let data;
89
- switch (true) {
90
- case $child.classList.contains("de-image-block"):
91
- data = convertImageBlock($child, imageHostURL);
92
- break;
93
- case $child.classList.contains("de-code-block"):
94
- data = convertCodeBlock($child);
95
- break;
96
- case $child.classList.contains("de-custom-block"):
97
- data = convertCustomBlock($child);
98
- break;
99
- }
100
- return data;
101
- }
102
- function convertImageBlock($imageBlock, imageHostURL) {
103
- const $imgArea = $imageBlock.querySelector(".de-image-area");
104
- const $img = $imageBlock.querySelector(".de-img");
105
- const $caption = $imageBlock.querySelector(".de-caption");
106
- return {
107
- type: "image",
108
- src: imageHostURL === "" ? $img.src : $img.src.replace(imageHostURL, ""),
109
- maxWidth: parseInt($imgArea.dataset["maxwidth"]),
110
- width: $img.width,
111
- height: $img.height,
112
- caption: $caption.textContent ?? "",
113
- classList: getClassListWithoutDefaultClass($imageBlock)
114
- };
115
- }
116
- function convertCodeBlock($codeBlock) {
117
- const $code = $codeBlock.querySelector(".de-code-content");
118
- const $file = $codeBlock.querySelector(".de-filename");
119
- const $lang = $codeBlock.querySelector(".de-language");
120
- return {
121
- type: "code",
122
- theme: $codeBlock.dataset["theme"],
123
- filename: $file?.textContent ?? "",
124
- language: $lang?.textContent ?? "text",
125
- textContent: $code?.innerHTML ?? ""
126
- };
127
- }
128
- function convertCustomBlock($block) {
129
- return {
130
- type: "custom",
131
- classList: getClassListWithoutDefaultClass($block),
132
- textContent: $block.innerHTML
133
- };
134
- }
135
- function getClassListWithoutDefaultClass($element) {
136
- const defaultClassList = ["de-block", "de-text-block", "de-heading-block", "de-list-block", "de-image-block"];
137
- return [...$element.classList].filter((className) => defaultClassList.includes(className) === false);
138
- }
@@ -1,6 +0,0 @@
1
- import "../type.d.ts";
2
- export declare function _setCursorData(store: any): void;
3
- export declare function _setCursor($target: Node, startIdx: number): void;
4
- export declare function _setRangeCursor($startTarget: Element, $endTarget: Element, startIdx: number, endIdx: number): void;
5
- export declare function _clenupCursor(store: any): void;
6
- export declare function _soltingCursorDataOnElement(cursorData: DEditorCursor, $element: HTMLElement): DEArrangeCursorData;
@@ -1,10 +0,0 @@
1
- export declare function _elementKeyEvent(event: KeyboardEvent, store: any): void;
2
- /**
3
- * 핫 키 이벤트
4
- */
5
- export declare function _hotKeyEvent(event: KeyboardEvent, store: any): void;
6
- /**
7
- * 복사 & 붙여넣기 이벤트
8
- */
9
- export declare function _copyEvent(event: ClipboardEvent, store: any): void;
10
- export declare function _pasteEvent(event: ClipboardEvent, store: any, emit: any): Promise<void>;