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
@@ -1,408 +0,0 @@
1
- import { h } from "vue";
2
- import { _getIconNode } from "./index.js";
3
- import { _addBlock } from "../node/index.js";
4
- import { _setDecoration, _setTextAlign, _setAnchorTag, _unsetAnchorTag } from "../style/index.js";
5
- import { _setIndent, _moveBlock, _openAnchorArea } from "../event/index.js";
6
- export function _getMenuBarVNodeStructure(store) {
7
- const childNode = [];
8
- childNode.push(__getMenuListStructure(store));
9
- childNode.push(__getBlockListStructure(store));
10
- childNode.push(
11
- h("div", { class: ["de-link-exit-area", "js-de-link-exit-area", { "--active": store.value.activeStatus.anchorInputArea }] }, [
12
- h("div", { class: ["de-btn-area"] }, [
13
- h(
14
- "button",
15
- {
16
- class: ["de-btn", { "--active": store.value.controlStatus.anchorTabType === "url" }],
17
- type: "button",
18
- onClick: () => {
19
- store.value.controlStatus.anchorTabType = "url";
20
- }
21
- },
22
- "Text"
23
- ),
24
- h(
25
- "button",
26
- {
27
- class: ["de-btn", { "--active": store.value.controlStatus.anchorTabType === "heading" }],
28
- type: "button",
29
- onClick: () => {
30
- store.value.controlStatus.anchorTabType = "heading";
31
- }
32
- },
33
- "Heading"
34
- )
35
- ]),
36
- store.value.controlStatus.anchorTabType === "url" ? h("div", { class: ["de-link-text-area"] }, [
37
- h("input", {
38
- class: ["de-input", { "--error": store.value.controlStatus.anchorValidation === false }],
39
- value: store.value.controlStatus.anchorHref,
40
- onInput: (event) => {
41
- store.value.controlStatus.anchorHref = event.currentTarget.value;
42
- }
43
- }),
44
- h(
45
- "button",
46
- {
47
- class: ["de-btn"],
48
- type: "button",
49
- onClick: () => {
50
- _setAnchorTag(store.value.controlStatus.anchorHref, true, store);
51
- }
52
- },
53
- "Set"
54
- )
55
- ]) : h(
56
- "div",
57
- { class: ["de-link-heading-area"] },
58
- store.value.controlStatus.anchorHeadingList.map((item) => {
59
- return h(
60
- "button",
61
- {
62
- class: ["de-btn", { "--active": store.value.controlStatus.anchorHref === `#${item.id}` }],
63
- type: "button",
64
- onClick: () => {
65
- store.value.activeStatus.anchorInputArea = false;
66
- _setAnchorTag(item.id, false, store);
67
- }
68
- },
69
- item.name
70
- );
71
- })
72
- )
73
- ])
74
- );
75
- return h("div", { class: ["de-menu-bar"], style: { top: `${store.value.menuBarTop}px` } }, childNode);
76
- }
77
- function __getMenuListStructure(store) {
78
- const menuGroupNode = [];
79
- menuGroupNode.push(
80
- h("div", { class: ["de-col"] }, [
81
- h(
82
- "button",
83
- {
84
- class: ["de-menu", "de-menu-add", "js-de-menu-add"],
85
- type: "button",
86
- onClick: () => {
87
- store.value.activeStatus.addBlockMenu = !store.value.activeStatus.addBlockMenu;
88
- }
89
- },
90
- [_getIconNode("plus")]
91
- )
92
- ])
93
- );
94
- menuGroupNode.push(
95
- h("div", { class: ["de-col"] }, [
96
- h(
97
- "button",
98
- {
99
- class: ["de-menu"],
100
- type: "button",
101
- onClick: () => {
102
- _setDecoration("de-bold", store);
103
- }
104
- },
105
- [_getIconNode("bold")]
106
- ),
107
- h(
108
- "button",
109
- {
110
- class: ["de-menu"],
111
- type: "button",
112
- onClick: () => {
113
- _setDecoration("de-italic", store);
114
- }
115
- },
116
- [_getIconNode("italic")]
117
- ),
118
- h(
119
- "button",
120
- {
121
- class: ["de-menu"],
122
- type: "button",
123
- onClick: () => {
124
- _setDecoration("de-underline", store);
125
- }
126
- },
127
- [_getIconNode("underline")]
128
- ),
129
- h(
130
- "button",
131
- {
132
- class: ["de-menu"],
133
- type: "button",
134
- onClick: () => {
135
- _setDecoration("de-strikethrough", store);
136
- }
137
- },
138
- [_getIconNode("strikethrough")]
139
- ),
140
- h(
141
- "button",
142
- {
143
- class: ["de-menu"],
144
- type: "button",
145
- onClick: () => {
146
- _setDecoration("de-code", store);
147
- }
148
- },
149
- [_getIconNode("codeblock")]
150
- )
151
- ])
152
- );
153
- menuGroupNode.push(
154
- h("div", { class: ["de-col"] }, [
155
- h(
156
- "button",
157
- {
158
- class: ["de-menu", "js-de-link-btn"],
159
- type: "button",
160
- onClick: (event) => {
161
- _openAnchorArea(event, store);
162
- }
163
- },
164
- [_getIconNode("add-link")]
165
- ),
166
- h(
167
- "button",
168
- {
169
- class: ["de-menu", { "--disabled": store.value.controlStatus.anchorHref === "" }],
170
- type: "button",
171
- onClick: () => {
172
- _unsetAnchorTag(store);
173
- }
174
- },
175
- [_getIconNode("remove-link")]
176
- )
177
- ])
178
- );
179
- menuGroupNode.push(
180
- h("div", { class: ["de-col"] }, [
181
- h("label", { class: ["de-menu"] }, [
182
- h("input", {
183
- type: "file",
184
- hidden: true,
185
- accept: ".jpg,.jpeg,.png,.webp,.gif",
186
- onChange: (event) => {
187
- const $target = event.target;
188
- if ($target.files !== null) {
189
- const file = $target.files[0];
190
- store.value.emit("uploadImageEvent", file);
191
- $target.value = "";
192
- }
193
- }
194
- }),
195
- _getIconNode("image")
196
- ])
197
- ])
198
- );
199
- menuGroupNode.push(
200
- h("div", { class: ["de-col"] }, [
201
- h(
202
- "button",
203
- {
204
- class: ["de-menu"],
205
- type: "button",
206
- onClick: () => {
207
- _setTextAlign("left", store);
208
- }
209
- },
210
- [_getIconNode("align-left")]
211
- ),
212
- h(
213
- "button",
214
- {
215
- class: ["de-menu"],
216
- type: "button",
217
- onClick: () => {
218
- _setTextAlign("center", store);
219
- }
220
- },
221
- [_getIconNode("align-center")]
222
- ),
223
- h(
224
- "button",
225
- {
226
- class: ["de-menu"],
227
- type: "button",
228
- onClick: () => {
229
- _setTextAlign("right", store);
230
- }
231
- },
232
- [_getIconNode("align-right")]
233
- ),
234
- h(
235
- "button",
236
- {
237
- class: ["de-menu"],
238
- type: "button",
239
- onClick: () => {
240
- _setTextAlign("justify", store);
241
- }
242
- },
243
- [_getIconNode("align-justify")]
244
- )
245
- ])
246
- );
247
- menuGroupNode.push(
248
- h("div", { class: ["de-col"] }, [
249
- h(
250
- "button",
251
- {
252
- class: ["de-menu"],
253
- type: "button",
254
- onClick: () => {
255
- _setIndent(store, "minus");
256
- }
257
- },
258
- [_getIconNode("indent-decrease")]
259
- ),
260
- h(
261
- "button",
262
- {
263
- class: ["de-menu"],
264
- type: "button",
265
- onClick: () => {
266
- _setIndent(store, "plus");
267
- }
268
- },
269
- [_getIconNode("indent-increase")]
270
- )
271
- ])
272
- );
273
- menuGroupNode.push(
274
- h("div", { class: ["de-col"] }, [
275
- h(
276
- "button",
277
- {
278
- class: ["de-menu"],
279
- type: "button",
280
- onClick: () => {
281
- _moveBlock("up", store);
282
- }
283
- },
284
- [_getIconNode("move-up")]
285
- ),
286
- h(
287
- "button",
288
- {
289
- class: ["de-menu"],
290
- type: "button",
291
- onClick: () => {
292
- _moveBlock("down", store);
293
- }
294
- },
295
- [_getIconNode("move-down")]
296
- )
297
- ])
298
- );
299
- return h("div", { class: ["de-menu-wrap"] }, menuGroupNode);
300
- }
301
- function __getBlockListStructure(store) {
302
- const menuList = [];
303
- menuList.push(
304
- h(
305
- "button",
306
- {
307
- class: ["de-add-block"],
308
- type: "button",
309
- onClick: () => {
310
- _addBlock("text", store);
311
- }
312
- },
313
- "Text"
314
- )
315
- );
316
- menuList.push(
317
- h(
318
- "button",
319
- {
320
- class: ["de-add-block"],
321
- type: "button",
322
- onClick: () => {
323
- _addBlock("heading1", store);
324
- }
325
- },
326
- "Heading-1"
327
- )
328
- );
329
- menuList.push(
330
- h(
331
- "button",
332
- {
333
- class: ["de-add-block"],
334
- type: "button",
335
- onClick: () => {
336
- _addBlock("heading2", store);
337
- }
338
- },
339
- "Heading-2"
340
- )
341
- );
342
- menuList.push(
343
- h(
344
- "button",
345
- {
346
- class: ["de-add-block"],
347
- type: "button",
348
- onClick: () => {
349
- _addBlock("heading3", store);
350
- }
351
- },
352
- "Heading-3"
353
- )
354
- );
355
- menuList.push(
356
- h(
357
- "button",
358
- {
359
- class: ["de-add-block"],
360
- type: "button",
361
- onClick: () => {
362
- _addBlock("ul", store);
363
- }
364
- },
365
- "Unodered List"
366
- )
367
- );
368
- menuList.push(
369
- h(
370
- "button",
371
- {
372
- class: ["de-add-block"],
373
- type: "button",
374
- onClick: () => {
375
- _addBlock("ol", store);
376
- }
377
- },
378
- "Odered List"
379
- )
380
- );
381
- menuList.push(
382
- h(
383
- "button",
384
- {
385
- class: ["de-add-block"],
386
- type: "button",
387
- onClick: () => {
388
- _addBlock("code", store);
389
- }
390
- },
391
- "Code Block"
392
- )
393
- );
394
- menuList.push(
395
- h(
396
- "button",
397
- {
398
- class: ["de-add-block"],
399
- type: "button",
400
- onClick: () => {
401
- _addBlock("divider", store);
402
- }
403
- },
404
- "Divider"
405
- )
406
- );
407
- return h("div", { class: ["de-block-menu-area", "js-de-block-menu-area", { "--active": store.value.activeStatus.addBlockMenu }] }, h("div", { class: ["de-list"] }, menuList));
408
- }
@@ -1,19 +0,0 @@
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.d.mts.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 _createDividerBlock(): HTMLDivElement;
16
- export declare function _updateCurrentBlock(event: Event, store: Ref<DragonEditorStore>): void;
17
- export declare function _updateHeadingBlockList(store: Ref<DragonEditorStore>): void;
18
- export declare function _setCodeBlockStatus(theme: DECodeblockTheme, language: DECodeblockLang, store: Ref<DragonEditorStore>): Promise<void>;
19
- export declare function _setListBlockStyle(style: DEListStyle, store: Ref<DragonEditorStore>): void;
@@ -1,256 +0,0 @@
1
- import { _getDefaultBlockData, _generateId, _updateModelData, _updateCursorData, _decideWhetherOpenControlBar, _updateControlBarStatus, CODEBLOCKLANG } from "../event/index.js";
2
- export function _addBlock(type, store, data) {
3
- const blockData = data === void 0 ? _getDefaultBlockData(type) : data;
4
- let $block = _createTextBlock(_getDefaultBlockData("text"));
5
- switch (blockData.type) {
6
- case "text":
7
- $block = _createTextBlock(blockData);
8
- break;
9
- case "heading":
10
- $block = _createHeadingBlock(blockData);
11
- break;
12
- case "image":
13
- $block = _createImageBlock(blockData, store.value.imageHostURL);
14
- break;
15
- case "list":
16
- $block = _createListBlock(blockData);
17
- break;
18
- case "code":
19
- $block = _createCodeBlock(blockData, store);
20
- break;
21
- case "custom":
22
- $block = _createCustomBlock(blockData);
23
- break;
24
- case "divider":
25
- $block = _createDividerBlock();
26
- break;
27
- }
28
- if (store.value.controlStatus.$currentBlock === null) {
29
- if (store.value.$body !== null) {
30
- store.value.$body.insertAdjacentElement("beforeend", $block);
31
- } else {
32
- }
33
- } else {
34
- store.value.controlStatus.$currentBlock.insertAdjacentElement("afterend", $block);
35
- }
36
- if (blockData.type === "list") {
37
- $block.children[0].focus();
38
- } else if (blockData.type === "code") {
39
- $block.querySelector(".de-code-content").focus();
40
- } else if (blockData.type === "text" || blockData.type === "heading") {
41
- $block.focus();
42
- } else if (blockData.type === "image") {
43
- $block.querySelector(".de-caption").focus();
44
- }
45
- const { type: blockType, $element } = _getCurrentBlock($block);
46
- store.value.activeStatus.addBlockMenu = false;
47
- store.value.controlStatus.currentBlockType = blockType;
48
- store.value.controlStatus.$currentBlock = $element;
49
- _updateModelData(store);
50
- _updateCursorData(store);
51
- _decideWhetherOpenControlBar(store);
52
- }
53
- export function _getCurrentBlock($target) {
54
- const $block = $target.closest(".de-block");
55
- let typeName = "text";
56
- if ($block !== null) {
57
- switch (true) {
58
- case $block.classList.contains("de-text-block"):
59
- typeName = "text";
60
- break;
61
- case $block.classList.contains("de-heading-block"):
62
- typeName = "heading";
63
- break;
64
- case $block.classList.contains("de-list-block"):
65
- if ($block.tagName === "OL") {
66
- typeName = "ol";
67
- } else {
68
- typeName = "ul";
69
- }
70
- break;
71
- case $block.classList.contains("de-image-block"):
72
- typeName = "image";
73
- break;
74
- case $block.classList.contains("de-code-block"):
75
- typeName = "code";
76
- break;
77
- default:
78
- typeName = "custom";
79
- }
80
- }
81
- return {
82
- type: typeName,
83
- $element: $block
84
- };
85
- }
86
- export function _createTextBlock(data) {
87
- const $paragraph = document.createElement("p");
88
- if (data.depth !== void 0 && data.depth !== 0) {
89
- $paragraph.dataset["depth"] = String(data.depth);
90
- }
91
- $paragraph.classList.add("de-block", "de-text-block", ...data.classList);
92
- $paragraph.setAttribute("contenteditable", "true");
93
- $paragraph.innerHTML = data.textContent;
94
- return $paragraph;
95
- }
96
- export function _createHeadingBlock(data) {
97
- const $headingBlock = document.createElement(`h${data.level}`);
98
- if (data.id === "") {
99
- $headingBlock.id = _generateId();
100
- } else {
101
- $headingBlock.id = data.id;
102
- }
103
- if (data.depth !== void 0 && data.depth !== 0) {
104
- $headingBlock.dataset["depth"] = String(data.depth);
105
- }
106
- $headingBlock.classList.add("de-block", "de-heading-block", ...data.classList);
107
- $headingBlock.dataset["level"] = String(data.level);
108
- $headingBlock.setAttribute("contenteditable", "true");
109
- $headingBlock.innerHTML = data.textContent;
110
- return $headingBlock;
111
- }
112
- export function _createListBlock(data) {
113
- const $block = document.createElement(data.element);
114
- if (data.depth !== void 0 && data.depth !== 0) {
115
- $block.dataset["depth"] = String(data.depth);
116
- }
117
- $block.classList.add("de-block", "de-list-block");
118
- $block.dataset["style"] = data.style;
119
- data.child.forEach((child) => {
120
- $block.appendChild(_createListItemBlock(child));
121
- });
122
- return $block;
123
- }
124
- export function _createListItemBlock(child = { textContent: "", classList: [] }) {
125
- const $li = document.createElement("li");
126
- $li.classList.add("de-item", ...child.classList);
127
- $li.setAttribute("contenteditable", "true");
128
- $li.innerHTML = child.textContent;
129
- return $li;
130
- }
131
- export function _createImageBlock(data, imageHostURL = "") {
132
- const $wrap = document.createElement("div");
133
- const $div = document.createElement("div");
134
- const $leftBtn = document.createElement("button");
135
- const $rightBtn = document.createElement("button");
136
- const $image = document.createElement("img");
137
- const $p = document.createElement("p");
138
- $wrap.classList.add("de-block", "de-image-block", ...data.classList);
139
- $div.classList.add("de-image-area");
140
- $leftBtn.classList.add("de-btn", "de-btn-left");
141
- $rightBtn.classList.add("de-btn", "de-btn-right");
142
- $image.classList.add("de-img");
143
- $p.contentEditable = "true";
144
- $p.classList.add("de-caption");
145
- if (data.width / data.height < 1) {
146
- $div.dataset["maxwidth"] = "40";
147
- } else {
148
- $div.dataset["maxwidth"] = String(data.maxWidth);
149
- }
150
- $image.src = imageHostURL + data.src;
151
- $image.width = data.width;
152
- $image.height = data.height;
153
- $image.draggable = false;
154
- if (data.caption !== void 0) {
155
- $p.textContent = data.caption;
156
- }
157
- $div.appendChild($image);
158
- $div.appendChild($leftBtn);
159
- $div.appendChild($rightBtn);
160
- $wrap.appendChild($div);
161
- $wrap.appendChild($p);
162
- return $wrap;
163
- }
164
- export function _createCodeBlock(data, store) {
165
- const $wrap = document.createElement("div");
166
- const $file = document.createElement("p");
167
- const $lang = document.createElement("p");
168
- const $pre = document.createElement("pre");
169
- const $code = document.createElement("code");
170
- const targetValue = CODEBLOCKLANG.find((item) => item.code === data.language);
171
- $wrap.classList.add("de-block", "de-code-block");
172
- $wrap.dataset["theme"] = data.theme;
173
- $file.contentEditable = "true";
174
- $file.classList.add("de-filename");
175
- $file.textContent = data.filename;
176
- $lang.textContent = targetValue?.text ?? "Plan Text";
177
- $lang.classList.add("de-language");
178
- $pre.classList.add("de-pre");
179
- $code.contentEditable = "true";
180
- $code.classList.add("de-code-content");
181
- $code.innerHTML = data.textContent;
182
- $pre.appendChild($code);
183
- $wrap.appendChild($file);
184
- $wrap.appendChild($lang);
185
- $wrap.appendChild($pre);
186
- return $wrap;
187
- }
188
- export function _createCustomBlock(data) {
189
- const $block = document.createElement("div");
190
- $block.classList.add("de-block", "de-custom-block", ...data.classList);
191
- $block.innerHTML = data.textContent;
192
- return $block;
193
- }
194
- export function _createDividerBlock() {
195
- const $block = document.createElement("div");
196
- $block.classList.add("de-block", "de-divider-block");
197
- return $block;
198
- }
199
- export function _updateCurrentBlock(event, store) {
200
- let $target = event.target;
201
- if ($target !== null) {
202
- $target = $target.constructor.name === "Text" ? $target.parentElement : $target;
203
- const $menuBar = $target.closest(".de-menu-bar");
204
- const $controlBar = $target.closest(".js-de-controlbar");
205
- if ($menuBar === null && $controlBar === null) {
206
- const { type, $element } = _getCurrentBlock($target);
207
- store.value.controlStatus.currentBlockType = type;
208
- store.value.controlStatus.$currentBlock = $element;
209
- _decideWhetherOpenControlBar(store);
210
- _updateControlBarStatus(store);
211
- }
212
- }
213
- }
214
- export function _updateHeadingBlockList(store) {
215
- if (store.value.$body !== null) {
216
- const $headingList = store.value.$body.querySelectorAll(".de-heading-block");
217
- store.value.controlStatus.anchorHeadingList = Array.from($headingList).map(($element) => {
218
- return {
219
- name: $element.textContent ?? "",
220
- id: $element.id ?? ""
221
- };
222
- });
223
- }
224
- }
225
- export async function _setCodeBlockStatus(theme, language, store) {
226
- if (store.value.controlStatus.$currentBlock !== null) {
227
- const $target = store.value.controlStatus.$currentBlock.querySelector(".de-language");
228
- const $code = store.value.controlStatus.$currentBlock.querySelector(".de-code-content");
229
- if ($target !== null && $code !== null) {
230
- const targetValue = CODEBLOCKLANG.find((item) => item.code === language);
231
- if (targetValue !== void 0) {
232
- const convert = await store.value.codeToHtml($code.textContent ?? "", { lang: language, theme });
233
- const $div = document.createElement("div");
234
- $div.innerHTML = convert;
235
- const $childCode = $div.querySelector("code");
236
- if ($childCode !== null) {
237
- $target.textContent = targetValue.text;
238
- $code.innerHTML = $childCode.innerHTML;
239
- store.value.controlStatus.codeBlockLang = targetValue.code;
240
- store.value.controlStatus.codeBlockTheme = theme;
241
- store.value.controlStatus.$currentBlock.dataset["theme"] = theme;
242
- _updateCursorData(store);
243
- _updateModelData(store);
244
- }
245
- }
246
- }
247
- }
248
- }
249
- export function _setListBlockStyle(style, store) {
250
- if (store.value.controlStatus.$currentBlock !== null) {
251
- store.value.controlStatus.listBlockStyle = style;
252
- store.value.controlStatus.$currentBlock.dataset["style"] = style;
253
- _updateCursorData(store);
254
- _updateModelData(store);
255
- }
256
- }
@@ -1,5 +0,0 @@
1
- import type { Ref } from "vue";
2
- import type { DragonEditorStore } from "../../type.d.mts.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(event: MouseEvent, store: Ref<DragonEditorStore>, previous?: boolean): void;