dragon-editor 3.8.7 → 4.0.1

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 (91) hide show
  1. package/README.md +10 -9
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +9 -7
  4. package/dist/runtime/components/Block/Code.d.vue.ts +13 -0
  5. package/dist/runtime/components/Block/Code.vue +193 -0
  6. package/dist/runtime/components/Block/Code.vue.d.ts +13 -0
  7. package/dist/runtime/components/Block/Custom.d.vue.ts +9 -0
  8. package/dist/runtime/components/Block/Custom.vue +28 -0
  9. package/dist/runtime/components/Block/Custom.vue.d.ts +9 -0
  10. package/dist/runtime/components/Block/Divider.d.vue.ts +9 -0
  11. package/dist/runtime/components/Block/Divider.vue +27 -0
  12. package/dist/runtime/components/Block/Divider.vue.d.ts +9 -0
  13. package/dist/runtime/components/Block/Heading.d.vue.ts +13 -0
  14. package/dist/runtime/components/Block/Heading.vue +84 -0
  15. package/dist/runtime/components/Block/Heading.vue.d.ts +13 -0
  16. package/dist/runtime/components/Block/Image.d.vue.ts +13 -0
  17. package/dist/runtime/components/Block/Image.vue +146 -0
  18. package/dist/runtime/components/Block/Image.vue.d.ts +13 -0
  19. package/dist/runtime/components/Block/List.d.vue.ts +13 -0
  20. package/dist/runtime/components/Block/List.vue +170 -0
  21. package/dist/runtime/components/Block/List.vue.d.ts +13 -0
  22. package/dist/runtime/components/Block/Text.d.vue.ts +13 -0
  23. package/dist/runtime/components/Block/Text.vue +84 -0
  24. package/dist/runtime/components/Block/Text.vue.d.ts +13 -0
  25. package/dist/runtime/components/DragonEditor.d.vue.ts +27 -22
  26. package/dist/runtime/components/DragonEditor.vue +311 -474
  27. package/dist/runtime/components/DragonEditor.vue.d.ts +27 -22
  28. package/dist/runtime/components/DragonEditorViewer.d.vue.ts +12 -5
  29. package/dist/runtime/components/DragonEditorViewer.vue +200 -227
  30. package/dist/runtime/components/DragonEditorViewer.vue.d.ts +12 -5
  31. package/dist/runtime/components/MenuBar.d.vue.ts +3 -0
  32. package/dist/runtime/components/MenuBar.vue +385 -0
  33. package/dist/runtime/components/MenuBar.vue.d.ts +3 -0
  34. package/dist/runtime/scss/editor.css +237 -283
  35. package/dist/runtime/scss/viewer.css +184 -210
  36. package/dist/runtime/store/editor.d.ts +2 -0
  37. package/dist/runtime/store/editor.js +59 -0
  38. package/dist/runtime/type.d.mts +101 -124
  39. package/dist/runtime/utils/data/block.d.ts +20 -0
  40. package/dist/runtime/utils/data/block.js +663 -0
  41. package/dist/runtime/utils/data/cursor.d.ts +9 -0
  42. package/dist/runtime/utils/data/cursor.js +137 -0
  43. package/dist/runtime/utils/data/index.d.ts +5 -0
  44. package/dist/runtime/utils/data/index.js +17 -0
  45. package/dist/runtime/utils/data/node.d.ts +9 -0
  46. package/dist/runtime/utils/data/node.js +101 -0
  47. package/dist/runtime/utils/event/cursor.d.ts +3 -6
  48. package/dist/runtime/utils/event/cursor.js +52 -105
  49. package/dist/runtime/utils/event/index.d.ts +2 -6
  50. package/dist/runtime/utils/event/index.js +48 -6
  51. package/dist/runtime/utils/event/keyboard.d.ts +22 -7
  52. package/dist/runtime/utils/event/keyboard.js +910 -1406
  53. package/dist/runtime/utils/layout/body.d.ts +3 -4
  54. package/dist/runtime/utils/layout/body.js +83 -51
  55. package/dist/runtime/utils/layout/icon.d.ts +1 -2
  56. package/dist/runtime/utils/layout/icon.js +64 -67
  57. package/dist/runtime/utils/layout/index.d.ts +0 -3
  58. package/dist/runtime/utils/layout/index.js +0 -3
  59. package/dist/runtime/utils/node/element.d.ts +4 -6
  60. package/dist/runtime/utils/node/element.js +58 -71
  61. package/dist/runtime/utils/node/index.d.ts +1 -1
  62. package/dist/runtime/utils/node/index.js +1 -1
  63. package/dist/runtime/utils/node/style.d.ts +5 -0
  64. package/dist/runtime/utils/node/style.js +702 -0
  65. package/package.json +32 -18
  66. package/dist/runtime/utils/event/block.d.ts +0 -7
  67. package/dist/runtime/utils/event/block.js +0 -110
  68. package/dist/runtime/utils/event/data.d.ts +0 -8
  69. package/dist/runtime/utils/event/data.js +0 -379
  70. package/dist/runtime/utils/event/mouse.d.ts +0 -11
  71. package/dist/runtime/utils/event/mouse.js +0 -85
  72. package/dist/runtime/utils/event/scroll.d.ts +0 -3
  73. package/dist/runtime/utils/event/scroll.js +0 -29
  74. package/dist/runtime/utils/event/touch.d.ts +0 -5
  75. package/dist/runtime/utils/event/touch.js +0 -10
  76. package/dist/runtime/utils/event/window.d.ts +0 -5
  77. package/dist/runtime/utils/event/window.js +0 -47
  78. package/dist/runtime/utils/layout/block.d.ts +0 -7
  79. package/dist/runtime/utils/layout/block.js +0 -123
  80. package/dist/runtime/utils/layout/controlbar.d.ts +0 -3
  81. package/dist/runtime/utils/layout/controlbar.js +0 -99
  82. package/dist/runtime/utils/layout/menuBar.d.ts +0 -3
  83. package/dist/runtime/utils/layout/menuBar.js +0 -408
  84. package/dist/runtime/utils/node/block.d.ts +0 -19
  85. package/dist/runtime/utils/node/block.js +0 -256
  86. package/dist/runtime/utils/style/anchor.d.ts +0 -5
  87. package/dist/runtime/utils/style/anchor.js +0 -245
  88. package/dist/runtime/utils/style/decoration.d.ts +0 -4
  89. package/dist/runtime/utils/style/decoration.js +0 -378
  90. package/dist/runtime/utils/style/index.d.ts +0 -2
  91. package/dist/runtime/utils/style/index.js +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dragon-editor",
3
- "version": "3.8.7",
3
+ "version": "4.0.1",
4
4
  "description": "Javascript WYSIWYG editor in Nuxt!",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,41 +18,55 @@
18
18
  "files": [
19
19
  "dist"
20
20
  ],
21
+ "typesVersions": {
22
+ "*": {
23
+ ".": [
24
+ "./dist/types.d.mts"
25
+ ]
26
+ }
27
+ },
28
+ "workspaces": [
29
+ "playground"
30
+ ],
21
31
  "scripts": {
22
32
  "prepack": "nuxt-module-build build",
23
- "dev": "nuxi dev playground",
24
- "dev:build": "nuxi build playground",
25
- "dev:prepare": "nuxt-module-build build --stub && nuxi prepare playground",
33
+ "dev": "npm run dev:prepare && nuxt dev playground",
34
+ "dev:build": "nuxt build playground",
35
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
26
36
  "release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
27
37
  "lint": "eslint .",
28
38
  "test": "vitest run",
29
- "test:watch": "vitest watch"
39
+ "test:watch": "vitest watch",
40
+ "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
30
41
  },
31
42
  "dependencies": {
32
- "@nuxt/kit": "^4.0.3",
33
- "shiki": "^3.12.1"
43
+ "@nuxt/kit": "^4.4.8",
44
+ "@pinia/nuxt": "^0.11.3",
45
+ "@vueuse/nuxt": "^14.3.0",
46
+ "highlight.js": "^11.11.1",
47
+ "pinia": "^3.0.4"
34
48
  },
35
49
  "devDependencies": {
36
- "@nuxt/eslint-config": "^1.9.0",
50
+ "@nuxt/eslint-config": "^1.16.0",
37
51
  "@nuxt/module-builder": "^1.0.2",
38
- "@nuxt/schema": "^4.0.3",
39
- "@nuxt/test-utils": "^3.19.2",
40
- "@types/bun": "^1.2.21",
52
+ "@nuxt/schema": "^4.4.8",
53
+ "@nuxt/test-utils": "^4.0.3",
54
+ "@types/bun": "^1.3.14",
41
55
  "changelogen": "^0.6.2",
42
- "eslint": "^9.34.0",
43
- "nuxt": "^4.0.3",
44
- "sass": "^1.91.0",
45
- "sass-embedded": "^1.91.0",
56
+ "eslint": "^10.5.0",
57
+ "nuxt": "^4.4.8",
58
+ "sass": "^1.101.0",
59
+ "sass-embedded": "^1.100.0",
46
60
  "typescript": "^5.1.6",
47
- "vitest": "^3.2.4",
48
- "vue-tsc": "^3.0.6"
61
+ "vitest": "^4.1.9",
62
+ "vue-tsc": "^3.3.5"
49
63
  },
50
64
  "keywords": [
51
65
  "editor",
52
66
  "wysiwyg-editor",
53
67
  "korean",
54
68
  "language",
55
- "nuxt3"
69
+ "nuxt4"
56
70
  ],
57
71
  "author": "Lovefields <lovefield@dico.me> (https://dico.me)",
58
72
  "bugs": {
@@ -1,7 +0,0 @@
1
- import type { Ref } from "vue";
2
- import type { DragonEditorStore } from "../../type.d.mts.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;
7
- export declare function _checkNeedNewBlock(event: MouseEvent, store: Ref<DragonEditorStore>): void;
@@ -1,110 +0,0 @@
1
- import { _updateModelData, _getDefaultBlockData } from "./index.js";
2
- import { _updateCurrentBlock, _createTextBlock } from "../node/index.js";
3
- export function _imageResizeEventStart(event, store) {
4
- const $target = event.target;
5
- if ($target !== null) {
6
- const $block = $target.closest(".de-block");
7
- if ($block !== null && $block.classList.contains("de-image-block") === true && $target.classList.contains("de-btn") === true) {
8
- _updateCurrentBlock(event, store);
9
- store.value.activeStatus.imageResizeEvent = true;
10
- if (event.type === "touchstart") {
11
- store.value.eventStatus.imageResizeEventStartX = event.touches[0].clientX;
12
- } else {
13
- store.value.eventStatus.imageResizeEventStartX = event.clientX;
14
- }
15
- if ($target.classList.contains("de-btn-left") === true) {
16
- store.value.eventStatus.imageResizeEventType = "left";
17
- } else {
18
- store.value.eventStatus.imageResizeEventType = "right";
19
- }
20
- const $imgArea = $block.querySelector(".de-image-area");
21
- store.value.eventStatus.imageResizeEventEndX = store.value.eventStatus.imageResizeEventStartX;
22
- store.value.eventStatus.imageResizeCurrentWidth = parseInt($imgArea.dataset["maxwidth"] ?? "25");
23
- }
24
- }
25
- }
26
- export function _imageResizeEvent(event, store) {
27
- if (store.value.activeStatus.imageResizeEvent === true && store.value.controlStatus.$currentBlock !== null && store.value.$body !== null) {
28
- const $imgArea = store.value.controlStatus.$currentBlock.querySelector(".de-image-area");
29
- const contentWidth = store.value.$body.offsetWidth / 2;
30
- let gap = 0;
31
- if (event.type === "touchmove") {
32
- store.value.eventStatus.imageResizeEventEndX = event.touches[0].clientX;
33
- } else {
34
- store.value.eventStatus.imageResizeEventEndX = event.clientX;
35
- }
36
- if (store.value.eventStatus.imageResizeEventType === "right") {
37
- gap = Math.floor(store.value.eventStatus.imageResizeEventStartX - store.value.eventStatus.imageResizeEventEndX);
38
- } else {
39
- gap = Math.floor(store.value.eventStatus.imageResizeEventEndX - store.value.eventStatus.imageResizeEventStartX);
40
- }
41
- const percent = 100 / contentWidth * gap;
42
- let value = Math.floor(store.value.eventStatus.imageResizeCurrentWidth - percent);
43
- if (value < 25) {
44
- value = 25;
45
- }
46
- if (value > 100) {
47
- value = 100;
48
- }
49
- $imgArea.dataset["maxwidth"] = String(value);
50
- }
51
- }
52
- export function _imageResizeEventEnd(event, store) {
53
- if (store.value.activeStatus.imageResizeEvent === true) {
54
- store.value.activeStatus.imageResizeEvent = false;
55
- _updateModelData(store);
56
- }
57
- }
58
- export function _moveBlock(type, store) {
59
- if (store.value.controlStatus.$currentBlock !== null) {
60
- const $block = store.value.controlStatus.$currentBlock;
61
- let $target;
62
- if (type === "up") {
63
- $target = $block.previousElementSibling;
64
- } else {
65
- $target = $block.nextElementSibling;
66
- }
67
- if ($target !== null) {
68
- $target.insertAdjacentHTML(type === "up" ? "beforebegin" : "afterend", $block.outerHTML);
69
- $block.remove();
70
- if (type === "up") {
71
- store.value.controlStatus.$currentBlock = $target.previousElementSibling;
72
- } else {
73
- store.value.controlStatus.$currentBlock = $target.nextElementSibling;
74
- }
75
- }
76
- _updateModelData(store);
77
- }
78
- }
79
- export function _checkNeedNewBlock(event, store) {
80
- const $target = event.target;
81
- if ($target !== null) {
82
- const $element = $target;
83
- if ($element.classList.contains("js-de-body") === true) {
84
- const bodyRect = $element.getBoundingClientRect();
85
- const blockList = $element.querySelectorAll(".de-block");
86
- const $targetBlock = blockList[blockList.length - 1];
87
- let isAllowed = true;
88
- switch (true) {
89
- case event.clientX > bodyRect.left + bodyRect.width - 20:
90
- case event.clientX < bodyRect.left + 20:
91
- isAllowed = false;
92
- }
93
- if (isAllowed === true) {
94
- if ($targetBlock.classList.contains("de-text-block") === true) {
95
- if ($targetBlock.textContent === "") {
96
- $targetBlock.focus();
97
- } else {
98
- const $block = _createTextBlock(_getDefaultBlockData("text"));
99
- $targetBlock.insertAdjacentElement("afterend", $block);
100
- $block.focus();
101
- }
102
- } else {
103
- const $block = _createTextBlock(_getDefaultBlockData("text"));
104
- $targetBlock.insertAdjacentElement("afterend", $block);
105
- $block.focus();
106
- }
107
- }
108
- }
109
- }
110
- }
@@ -1,8 +0,0 @@
1
- import type { Ref } from "vue";
2
- import type { DECodeItem, DECodeblockLang, DragonEditorStore, DEBlockData, DEBlockMenutype, DEContentData } from "../../type.d.mts.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;
8
- export declare function _checkDataEmpty(data: DEContentData): boolean;
@@ -1,379 +0,0 @@
1
- import { _getCurrentBlock } from "../node/index.js";
2
- export const CODEBLOCKLANG = [
3
- {
4
- text: "Plain Text",
5
- code: "text"
6
- },
7
- {
8
- text: "C#",
9
- code: "csharp"
10
- },
11
- {
12
- text: "C",
13
- code: "c"
14
- },
15
- {
16
- text: "C++",
17
- code: "cpp"
18
- },
19
- {
20
- text: "CSS",
21
- code: "css"
22
- },
23
- {
24
- text: "Dockerfile",
25
- code: "dockerfile"
26
- },
27
- {
28
- text: "Go",
29
- code: "go"
30
- },
31
- {
32
- text: "HTML, XML",
33
- code: "html"
34
- },
35
- {
36
- text: "JSON",
37
- code: "json"
38
- },
39
- {
40
- text: "Java",
41
- code: "java"
42
- },
43
- {
44
- text: "JavaScript",
45
- code: "javascript"
46
- },
47
- {
48
- text: "TypeScript",
49
- code: "typescript"
50
- },
51
- {
52
- text: "Kotlin",
53
- code: "kotlin"
54
- },
55
- {
56
- text: "Lua",
57
- code: "lua"
58
- },
59
- {
60
- text: "Markdown",
61
- code: "markdown"
62
- },
63
- {
64
- text: "Nginx",
65
- code: "nginx"
66
- },
67
- {
68
- text: "PHP",
69
- code: "php"
70
- },
71
- {
72
- text: "Python",
73
- code: "python"
74
- },
75
- {
76
- text: "Ruby",
77
- code: "ruby"
78
- },
79
- {
80
- text: "SCSS",
81
- code: "scss"
82
- },
83
- {
84
- text: "SQL",
85
- code: "sql"
86
- },
87
- {
88
- text: "Shell",
89
- code: "shellscript"
90
- },
91
- {
92
- text: "Swift",
93
- code: "swift"
94
- },
95
- {
96
- text: "YAML",
97
- code: "yaml"
98
- }
99
- ];
100
- export function _updateModelData(store) {
101
- const $body = store.value.$body;
102
- if ($body !== null) {
103
- const $blockList = $body.querySelectorAll(".de-block");
104
- const workList = [];
105
- $blockList.forEach(($el) => {
106
- let classListText = $el.classList.value.replaceAll("de-block", "");
107
- let classList = "";
108
- switch (true) {
109
- case $el.classList.contains("de-text-block"):
110
- workList.push(
111
- new Promise((done) => {
112
- classList = classListText.replaceAll("de-text-block", "").trim();
113
- const textBlockDepth = $el.dataset["depth"];
114
- let textBlockData = {
115
- type: "text",
116
- classList: classList === "" ? [] : classList.split(" "),
117
- textContent: $el.innerHTML
118
- };
119
- if (textBlockDepth !== void 0) {
120
- textBlockData.depth = parseInt(textBlockDepth);
121
- }
122
- done(textBlockData);
123
- })
124
- );
125
- break;
126
- case $el.classList.contains("de-heading-block"):
127
- workList.push(
128
- new Promise((done) => {
129
- classList = classListText.replaceAll("de-heading-block", "").trim();
130
- const headingBlockDepth = $el.dataset["depth"];
131
- let headingBlockData = {
132
- type: "heading",
133
- id: $el.id,
134
- level: parseInt($el.dataset["level"] ?? "3"),
135
- classList: classList === "" ? [] : classList.split(" "),
136
- textContent: $el.innerHTML
137
- };
138
- if (headingBlockDepth !== void 0) {
139
- headingBlockData.depth = parseInt(headingBlockDepth);
140
- }
141
- done(headingBlockData);
142
- })
143
- );
144
- break;
145
- case $el.classList.contains("de-list-block"):
146
- workList.push(
147
- new Promise((done) => {
148
- const $li = $el.querySelectorAll(".de-item");
149
- const liList = [];
150
- classList = classListText.replaceAll("de-list-block", "").trim();
151
- $li.forEach(($child) => {
152
- let childClassName = $child.classList.value.replace("de-item", "");
153
- liList.push({
154
- classList: childClassName === "" ? [] : childClassName.split(" "),
155
- textContent: $child.innerHTML
156
- });
157
- });
158
- const listBlockDepth = $el.dataset["depth"];
159
- let listBlockData = {
160
- type: "list",
161
- element: $el.tagName.toLowerCase(),
162
- style: $el.dataset["style"],
163
- child: liList
164
- };
165
- if (listBlockDepth !== void 0) {
166
- listBlockData.depth = parseInt(listBlockDepth);
167
- }
168
- done(listBlockData);
169
- })
170
- );
171
- break;
172
- case $el.classList.contains("de-image-block"):
173
- workList.push(
174
- new Promise((done) => {
175
- const $imageArea = $el.querySelector(".de-image-area");
176
- const $img = $el.querySelector(".de-img");
177
- const $caption = $el.querySelector(".de-caption");
178
- classList = classListText.replaceAll("de-image-block", "").trim();
179
- if ($img.complete === false) {
180
- $img.onload = () => {
181
- done({
182
- type: "image",
183
- src: $img.src.replace(store.value.imageHostURL, ""),
184
- maxWidth: parseInt($imageArea.dataset["maxwidth"] ?? "25"),
185
- width: $img.width,
186
- height: $img.height,
187
- caption: $caption?.textContent ?? "",
188
- classList: classList === "" ? [] : classList.split(" ")
189
- });
190
- };
191
- } else {
192
- done({
193
- type: "image",
194
- src: $img.src.replace(store.value.imageHostURL, ""),
195
- maxWidth: parseInt($imageArea.dataset["maxwidth"] ?? "25"),
196
- width: $img.width,
197
- height: $img.height,
198
- caption: $caption?.textContent ?? "",
199
- classList: classList === "" ? [] : classList.split(" ")
200
- });
201
- }
202
- })
203
- );
204
- break;
205
- case $el.classList.contains("de-code-block"):
206
- workList.push(
207
- new Promise((done) => {
208
- const $language = $el.querySelector(".de-language");
209
- const $fileName = $el.querySelector(".de-filename");
210
- const $codeBlock = $el.querySelector(".de-code-content");
211
- let language = "text";
212
- classList = classListText.replaceAll("de-code-block", "").trim();
213
- if ($language !== null) {
214
- const value = $language.textContent ?? "";
215
- const targetValue = CODEBLOCKLANG.find((item) => item.text === value);
216
- if (targetValue !== void 0) {
217
- language = targetValue.code;
218
- }
219
- }
220
- done({
221
- type: "code",
222
- theme: $el.dataset["theme"],
223
- filename: $fileName?.textContent || "",
224
- language,
225
- textContent: $codeBlock === null ? "" : $codeBlock.innerHTML
226
- });
227
- })
228
- );
229
- break;
230
- case $el.classList.contains("de-divider-block"):
231
- workList.push(
232
- new Promise((done) => {
233
- done({
234
- type: "divider"
235
- });
236
- })
237
- );
238
- break;
239
- default:
240
- workList.push(
241
- new Promise((done) => {
242
- classList = classListText.replaceAll("de-custom-block", "").trim();
243
- done({
244
- type: "custom",
245
- classList: classList === "" ? [] : classList.split(" "),
246
- textContent: $el.innerHTML
247
- });
248
- })
249
- );
250
- }
251
- });
252
- Promise.all(workList).then((data) => {
253
- store.value.emit("update:modelValue", data);
254
- });
255
- }
256
- }
257
- export function _getDefaultBlockData(type) {
258
- let data = { type: "text", classList: [], textContent: "" };
259
- switch (type) {
260
- case "heading1":
261
- case "heading2":
262
- case "heading3":
263
- data = {
264
- type: "heading",
265
- level: parseInt(type.replace("heading", "")),
266
- id: _generateId(),
267
- classList: [],
268
- textContent: ""
269
- };
270
- break;
271
- case "ol":
272
- case "ul":
273
- data = {
274
- type: "list",
275
- element: type,
276
- style: type === "ol" ? "decimal" : "disc",
277
- child: [
278
- {
279
- classList: [],
280
- textContent: ""
281
- }
282
- ]
283
- };
284
- break;
285
- case "code":
286
- data = {
287
- type: "code",
288
- language: "text",
289
- theme: "github-light",
290
- filename: "",
291
- textContent: ""
292
- };
293
- break;
294
- case "divider":
295
- data = {
296
- type: "divider"
297
- };
298
- break;
299
- }
300
- return data;
301
- }
302
- export function _generateId() {
303
- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
304
- let str = "";
305
- for (let i = 0; i < 6; i += 1) {
306
- str += chars.charAt(Math.floor(Math.random() * chars.length));
307
- }
308
- return str;
309
- }
310
- export function _updateControlBarStatus(store) {
311
- if (store.value.controlStatus.$currentBlock !== null) {
312
- const { type } = _getCurrentBlock(store.value.controlStatus.$currentBlock);
313
- const allowTypeList = ["code", "ol", "ul"];
314
- if (allowTypeList.includes(type) === true) {
315
- switch (type) {
316
- case "code":
317
- __updateCodeBlockStyle(store);
318
- break;
319
- case "ol":
320
- case "ul":
321
- __updateListBlockStyle(store);
322
- break;
323
- }
324
- }
325
- }
326
- }
327
- function __updateCodeBlockStyle(store) {
328
- if (store.value.controlStatus.$currentBlock !== null) {
329
- const $block = store.value.controlStatus.$currentBlock;
330
- const $language = $block.querySelector(".de-language");
331
- let language = "text";
332
- if ($language !== null) {
333
- const value = $language.textContent ?? "";
334
- const targetValue = CODEBLOCKLANG.find((item) => item.text === value);
335
- if (targetValue !== void 0) {
336
- language = targetValue.code;
337
- }
338
- }
339
- store.value.controlStatus.codeBlockTheme = $block.dataset["theme"] ?? "github-light";
340
- store.value.controlStatus.codeBlockLang = language;
341
- }
342
- }
343
- function __updateListBlockStyle(store) {
344
- if (store.value.controlStatus.$currentBlock !== null) {
345
- const $block = store.value.controlStatus.$currentBlock;
346
- store.value.controlStatus.listBlockStyle = $block.dataset["style"] ?? "disc";
347
- }
348
- }
349
- export function _checkDataEmpty(data) {
350
- let suitable = true;
351
- data.forEach((item) => {
352
- switch (item.type) {
353
- case "heading":
354
- case "text":
355
- if (item.textContent !== "") {
356
- suitable = false;
357
- }
358
- break;
359
- case "list":
360
- item.child.forEach((listChild) => {
361
- if (listChild.textContent !== "") {
362
- suitable = false;
363
- }
364
- });
365
- break;
366
- case "code":
367
- if (item.filename !== "" || item.textContent !== "") {
368
- suitable = false;
369
- }
370
- break;
371
- case "image":
372
- case "divider":
373
- case "custom":
374
- suitable = false;
375
- break;
376
- }
377
- });
378
- return suitable;
379
- }
@@ -1,11 +0,0 @@
1
- import type { Ref } from "vue";
2
- import type { DragonEditorStore } from "../../type.d.mts.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(event: MouseEvent, store: Ref<DragonEditorStore>): void;
10
- export declare function _decideWhetherOpenControlBar(store: Ref<DragonEditorStore>): void;
11
- export declare function _editorContextMenuEvent(event: MouseEvent, store: Ref<DragonEditorStore>): void;
@@ -1,85 +0,0 @@
1
- import { _updateCursorData, _imageResizeEventStart, _imageResizeEvent, _imageResizeEventEnd, _checkNeedNewBlock } from "./index.js";
2
- import { _getCurrentBlock, _updateCurrentBlock, _updateHeadingBlockList } from "../node/index.js";
3
- import { _updateAnchorTagValue } from "../style/index.js";
4
- export function _contentMouseupEvent(event, store) {
5
- _updateCurrentBlock(event, store);
6
- _updateCursorData(store);
7
- _checkNeedNewBlock(event, store);
8
- }
9
- export function _contentMousedownEvnet(event, store) {
10
- _imageResizeEventStart(event, store);
11
- }
12
- export function _editorMousemoveEvent(event, store) {
13
- _imageResizeEvent(event, store);
14
- }
15
- export function _editorMouseupEvent(event, store) {
16
- _imageResizeEventEnd(event, store);
17
- _updateAnchorTagValue(event, store);
18
- }
19
- export function _editorMouseleaveEvent(event, store) {
20
- _imageResizeEventEnd(event, store);
21
- }
22
- export function _checkOthersideClick(event, store) {
23
- _updateCurrentBlock(event, store);
24
- __blockAddOthersideEvent(event, store);
25
- _decideWhetherOpenControlBar(store);
26
- }
27
- function __blockAddOthersideEvent(event, store) {
28
- const $target = event.target;
29
- if ($target !== null) {
30
- const $menuBtn = $target.closest(".js-de-menu-add");
31
- const $menuArea = $target.closest(".js-de-block-menu-area");
32
- const $linkAreaBtn = $target.closest(".js-de-link-btn");
33
- const $linkInputArea = $target.closest(".js-de-link-exit-area");
34
- if ($menuBtn === null && $menuArea === null) {
35
- store.value.activeStatus.addBlockMenu = false;
36
- }
37
- if ($linkAreaBtn === null && $linkInputArea === null) {
38
- store.value.activeStatus.anchorInputArea = false;
39
- }
40
- }
41
- }
42
- export function _openAnchorArea(event, store) {
43
- store.value.controlStatus.previousCorsorData = store.value.cursorData;
44
- _updateAnchorTagValue(event, store, true);
45
- _updateHeadingBlockList(store);
46
- if (store.value.controlStatus.anchorHref !== "" && store.value.controlStatus.anchorHref.charAt(0) === "#") {
47
- store.value.controlStatus.anchorTabType = "heading";
48
- } else {
49
- store.value.controlStatus.anchorTabType = "url";
50
- }
51
- store.value.activeStatus.anchorInputArea = !store.value.activeStatus.anchorInputArea;
52
- }
53
- export function _decideWhetherOpenControlBar(store) {
54
- if (store.value.controlStatus.$currentBlock !== null) {
55
- const { type, $element } = _getCurrentBlock(store.value.controlStatus.$currentBlock);
56
- const allowTypeList = ["code", "ol", "ul"];
57
- if (allowTypeList.includes(type) === true && $element !== null) {
58
- const targetRect = $element.getBoundingClientRect();
59
- let x = Math.floor(targetRect.left + targetRect.width / 2);
60
- let y = Math.floor(targetRect.top - 8 - 32);
61
- if (y < 0) {
62
- y = 44;
63
- if (store.value.$parentWrap !== null && store.value.$editor !== null) {
64
- const editorRect = store.value.$editor.getBoundingClientRect();
65
- y += editorRect.top;
66
- }
67
- }
68
- if (store.value.controlStatus.hasTransformParent === true && store.value.controlStatus.$transformElement !== null) {
69
- const transformRect = store.value.controlStatus.$transformElement.getBoundingClientRect();
70
- x -= transformRect.left;
71
- y -= transformRect.top;
72
- }
73
- store.value.controlBar.x = x;
74
- store.value.controlBar.y = y;
75
- store.value.controlBar.$element = $element;
76
- store.value.controlBar.active = true;
77
- } else {
78
- store.value.controlBar.active = false;
79
- }
80
- } else {
81
- store.value.controlBar.active = false;
82
- }
83
- }
84
- export function _editorContextMenuEvent(event, store) {
85
- }
@@ -1,3 +0,0 @@
1
- import type { DragonEditorStore } from "../../type.d.mts.js";
2
- import type { Ref } from "vue";
3
- export declare function _parentWrapScollEvent(event: Event, store: Ref<DragonEditorStore>): void;