dragon-editor 3.8.7 → 4.0.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 (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 +28 -22
  26. package/dist/runtime/components/DragonEditor.vue +75 -1225
  27. package/dist/runtime/components/DragonEditor.vue.d.ts +28 -22
  28. package/dist/runtime/components/DragonEditorViewer.d.vue.ts +13 -5
  29. package/dist/runtime/components/DragonEditorViewer.vue +17 -813
  30. package/dist/runtime/components/DragonEditorViewer.vue.d.ts +13 -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 +31 -17
  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,9 +1,17 @@
1
- type __VLS_Props = {
1
+ import "../scss/viewer.scss.js";
2
+ import type { DEContentData } from "../type.d.mts.js";
3
+ interface DragonEditorViewerOption {
2
4
  content: DEContentData;
3
- imageHostURL?: string;
4
- };
5
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
- imageHostURL: string;
5
+ mediaHostURL?: string;
6
+ isMobile?: boolean;
7
+ theme?: "dark" | "white";
8
+ codeBlockSpaces?: number;
9
+ }
10
+ declare const __VLS_export: import("vue").DefineComponent<DragonEditorViewerOption, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<DragonEditorViewerOption> & Readonly<{}>, {
11
+ mediaHostURL: string;
12
+ isMobile: boolean;
13
+ codeBlockSpaces: number;
14
+ theme: "dark" | "white";
7
15
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
16
  declare const _default: typeof __VLS_export;
9
17
  export default _default;
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,385 @@
1
+ <template>
2
+ <div class="de-menu-bar" :style="{ top: `${editorStore.status.menuTop}px` }">
3
+ <div class="de-menu-wrap">
4
+ <div class="de-col">
5
+ <button
6
+ class="de-menu"
7
+ type="button"
8
+ @click="isActiveMenuArea = !isActiveMenuArea"
9
+ ref="$addMenuButton"
10
+ >
11
+ <component :is="_getIconNode('plus')" />
12
+ </button>
13
+ </div>
14
+
15
+ <div class="de-col">
16
+ <button
17
+ class="de-menu"
18
+ type="button"
19
+ :disabled="_checkCanUseDecoration() === false"
20
+ @click="_setDecoration('de-bold')"
21
+ >
22
+ <component :is="_getIconNode('bold')" />
23
+ </button>
24
+
25
+ <button
26
+ class="de-menu"
27
+ type="button"
28
+ :disabled="_checkCanUseDecoration() === false"
29
+ @click="_setDecoration('de-italic')"
30
+ >
31
+ <component :is="_getIconNode('italic')" />
32
+ </button>
33
+
34
+ <button
35
+ class="de-menu"
36
+ type="button"
37
+ :disabled="_checkCanUseDecoration() === false"
38
+ @click="_setDecoration('de-underline')"
39
+ >
40
+ <component :is="_getIconNode('underline')" />
41
+ </button>
42
+
43
+ <button
44
+ class="de-menu"
45
+ type="button"
46
+ :disabled="_checkCanUseDecoration() === false"
47
+ @click="_setDecoration('de-strikethrough')"
48
+ >
49
+ <component :is="_getIconNode('strikethrough')" />
50
+ </button>
51
+
52
+ <button
53
+ class="de-menu"
54
+ type="button"
55
+ :disabled="_checkCanUseDecoration() === false"
56
+ @click="_setDecoration('de-code')"
57
+ >
58
+ <component :is="_getIconNode('codeblock')" />
59
+ </button>
60
+ </div>
61
+
62
+ <div class="de-col">
63
+ <button
64
+ class="de-menu"
65
+ type="button"
66
+ :disabled="_checkCanUseDecoration() === false || editorStore.cursorSelection?.isCollapsed === true"
67
+ @click="isActiveLinkArea = !isActiveLinkArea"
68
+ ref="$exitLinkMenuButton"
69
+ >
70
+ <component :is="_getIconNode('add-link')" />
71
+ </button>
72
+
73
+ <button
74
+ class="de-menu"
75
+ type="button"
76
+ :disabled="_checkCanUseDecoration() === false"
77
+ @click="_removeLink"
78
+ >
79
+ <component :is="_getIconNode('remove-link')" />
80
+ </button>
81
+ </div>
82
+
83
+ <div class="de-col">
84
+ <label
85
+ class="de-menu"
86
+ type="button"
87
+ >
88
+ <component :is="_getIconNode('image')" />
89
+ <input
90
+ type="file"
91
+ hidden
92
+ :accept="editorStore.option.acceptImageFormat"
93
+ multiple
94
+ @change="imageUploadEvent"
95
+ />
96
+ </label>
97
+ </div>
98
+
99
+ <div class="de-col">
100
+ <button
101
+ class="de-menu"
102
+ type="button"
103
+ :disabled="_checkCanUseAlign() === false"
104
+ @click="_setAlign('left')"
105
+ >
106
+ <component :is="_getIconNode('align-left')" />
107
+ </button>
108
+
109
+ <button
110
+ class="de-menu"
111
+ type="button"
112
+ :disabled="_checkCanUseAlign() === false"
113
+ @click="_setAlign('center')"
114
+ >
115
+ <component :is="_getIconNode('align-center')" />
116
+ </button>
117
+
118
+ <button
119
+ class="de-menu"
120
+ type="button"
121
+ :disabled="_checkCanUseAlign() === false"
122
+ @click="_setAlign('right')"
123
+ >
124
+ <component :is="_getIconNode('align-right')" />
125
+ </button>
126
+
127
+ <button
128
+ class="de-menu"
129
+ type="button"
130
+ :disabled="_checkCanUseAlign() === false"
131
+ @click="_setAlign('justify')"
132
+ >
133
+ <component :is="_getIconNode('align-justify')" />
134
+ </button>
135
+ </div>
136
+
137
+ <div class="de-col">
138
+ <button
139
+ class="de-menu"
140
+ type="button"
141
+ :disabled="_checkCanUseIndent() === false"
142
+ @click="_setIndentData('decrease')"
143
+ >
144
+ <component :is="_getIconNode('indent-decrease')" />
145
+ </button>
146
+
147
+ <button
148
+ class="de-menu"
149
+ type="button"
150
+ :disabled="_checkCanUseIndent() === false"
151
+ @click="_setIndentData('increase')"
152
+ >
153
+ <component :is="_getIconNode('indent-increase')" />
154
+ </button>
155
+ </div>
156
+
157
+ <div class="de-col">
158
+ <button
159
+ class="de-menu"
160
+ type="button"
161
+ :disabled="editorStore.selectedBlockIndex < 1"
162
+ @click="_moveBlockIndex('first')"
163
+ >
164
+ <component :is="_getIconNode('move-first')" />
165
+ </button>
166
+
167
+ <button
168
+ class="de-menu"
169
+ type="button"
170
+ :disabled="editorStore.selectedBlockIndex < 1"
171
+ @click="_moveBlockIndex('up')"
172
+ >
173
+ <component :is="_getIconNode('move-up')" />
174
+ </button>
175
+
176
+ <button
177
+ class="de-menu"
178
+ type="button"
179
+ :disabled="editorStore.selectedBlockIndex === editorStore.data.length - 1 || editorStore.selectedBlockIndex === -1"
180
+ @click="_moveBlockIndex('down')"
181
+ >
182
+ <component :is="_getIconNode('move-down')" />
183
+ </button>
184
+
185
+ <button
186
+ class="de-menu"
187
+ type="button"
188
+ :disabled="editorStore.selectedBlockIndex === editorStore.data.length - 1 || editorStore.selectedBlockIndex === -1"
189
+ @click="_moveBlockIndex('last')"
190
+ >
191
+ <component :is="_getIconNode('move-last')" />
192
+ </button>
193
+ </div>
194
+ </div>
195
+
196
+ <div
197
+ class="de-block-menu-area"
198
+ :class="{ '--active': isActiveMenuArea === true }"
199
+ ref="$addBlockMenu"
200
+ >
201
+ <div class="de-list">
202
+ <button
203
+ class="de-add-block"
204
+ type="button"
205
+ @click="addBlockEvent('text')"
206
+ >
207
+ Text
208
+ </button>
209
+ <button
210
+ class="de-add-block"
211
+ type="button"
212
+ @click="addBlockEvent('heading1')"
213
+ >
214
+ Heading-1
215
+ </button>
216
+ <button
217
+ class="de-add-block"
218
+ type="button"
219
+ @click="addBlockEvent('heading2')"
220
+ >
221
+ Heading-2
222
+ </button>
223
+ <button
224
+ class="de-add-block"
225
+ type="button"
226
+ @click="addBlockEvent('heading3')"
227
+ >
228
+ Heading-3
229
+ </button>
230
+ <button
231
+ class="de-add-block"
232
+ type="button"
233
+ @click="addBlockEvent('unordered-list')"
234
+ >
235
+ Unodered List
236
+ </button>
237
+ <button
238
+ class="de-add-block"
239
+ type="button"
240
+ @click="addBlockEvent('ordered-list')"
241
+ >
242
+ Odered List
243
+ </button>
244
+ <button
245
+ class="de-add-block"
246
+ type="button"
247
+ @click="addBlockEvent('code')"
248
+ >
249
+ Code Block
250
+ </button>
251
+ <button
252
+ class="de-add-block"
253
+ type="button"
254
+ @click="addBlockEvent('divider')"
255
+ >
256
+ Divider
257
+ </button>
258
+ </div>
259
+ </div>
260
+
261
+ <div
262
+ class="de-link-exit-area"
263
+ :class="{ '--active': isActiveLinkArea === true }"
264
+ ref="$exitLinkMenu"
265
+ >
266
+ <div class="de-btn-area">
267
+ <button
268
+ class="de-btn"
269
+ :class="{ '--active': anchorInputType === 'url' }"
270
+ type="button"
271
+ @click="anchorInputType = 'url'"
272
+ >
273
+ Text
274
+ </button>
275
+ <button
276
+ class="de-btn"
277
+ :class="{ '--active': anchorInputType === 'hash' }"
278
+ type="button"
279
+ @click="anchorInputType = 'hash'"
280
+ >
281
+ Heading
282
+ </button>
283
+ </div>
284
+
285
+ <div
286
+ v-if="anchorInputType === 'url'"
287
+ class="de-link-text-area"
288
+ >
289
+ <input
290
+ v-model="editorStore.status.anchorHerf"
291
+ class="de-input"
292
+ :class="{ '--error': urlValidation === false }"
293
+ name="url"
294
+ type="url"
295
+ />
296
+ <button
297
+ class="de-btn"
298
+ type="button"
299
+ @click="setLinkEvent()"
300
+ >
301
+ Set
302
+ </button>
303
+ </div>
304
+
305
+ <div
306
+ v-else
307
+ class="de-link-heading-area"
308
+ >
309
+ <button
310
+ v-for="item in editorStore.data.filter((i) => i.type === 'heading')"
311
+ v-html="item.textContent"
312
+ class="de-btn"
313
+ :class="{ '--active': `#${item.id}` === editorStore.status.anchorHerf }"
314
+ :key="item.id"
315
+ @click="setLinkEvent(`#${item.id}`)"
316
+ >
317
+ </button>
318
+ </div>
319
+ </div>
320
+ </div>
321
+ </template>
322
+
323
+ <script setup>
324
+ import { ref } from "vue";
325
+ import { onClickOutside } from "@vueuse/core";
326
+ import { useEditorStore } from "../store/editor";
327
+ import { _addBlock, _moveBlockIndex, _checkCanUseIndent, _setIndentData, _checkCanUseAlign, _checkCanUseDecoration } from "../utils/data";
328
+ import { _getIconNode } from "../utils/layout";
329
+ import { _setAlign, _setDecoration, _setLink, _removeLink } from "../utils/node";
330
+ const editorStore = useEditorStore();
331
+ const isActiveMenuArea = ref(false);
332
+ const isActiveLinkArea = ref(false);
333
+ const anchorInputType = ref("url");
334
+ const urlValidation = ref(true);
335
+ const $addBlockMenu = ref();
336
+ const $addMenuButton = ref();
337
+ const $exitLinkMenu = ref();
338
+ const $exitLinkMenuButton = ref();
339
+ function addBlockEvent(name) {
340
+ _addBlock(name);
341
+ isActiveMenuArea.value = false;
342
+ }
343
+ function imageUploadEvent(event) {
344
+ const $target = event.currentTarget;
345
+ if ($target !== null) {
346
+ const files = $target.files;
347
+ if (files !== null && files.length > 0 && editorStore.fn.uploadImage !== null) {
348
+ editorStore.fn.uploadImage(Array.from(files));
349
+ $target.value = "";
350
+ }
351
+ }
352
+ }
353
+ function setLinkEvent(url) {
354
+ const urlReg = /^(https?:\/\/|#).+/;
355
+ if (url === void 0) {
356
+ url = editorStore.status.anchorHerf;
357
+ }
358
+ if (urlReg.test(url) === true) {
359
+ isActiveLinkArea.value = false;
360
+ urlValidation.value = true;
361
+ _setLink(url);
362
+ } else {
363
+ urlValidation.value = false;
364
+ }
365
+ }
366
+ onClickOutside(
367
+ $addBlockMenu,
368
+ () => {
369
+ isActiveMenuArea.value = false;
370
+ },
371
+ {
372
+ ignore: [$addMenuButton]
373
+ }
374
+ );
375
+ onClickOutside(
376
+ $exitLinkMenu,
377
+ () => {
378
+ isActiveLinkArea.value = false;
379
+ urlValidation.value = true;
380
+ },
381
+ {
382
+ ignore: [$exitLinkMenuButton]
383
+ }
384
+ );
385
+ </script>
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;