dragon-editor 3.0.1 → 3.1.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.
- package/README.md +4 -4
- package/dist/module.json +1 -1
- package/dist/runtime/components/DragonEditor.vue +513 -23
- package/dist/runtime/components/DragonEditorViewer.vue +308 -7
- package/dist/runtime/scss/editor.css +300 -0
- package/dist/runtime/scss/viewer.css +291 -0
- package/dist/runtime/store.d.ts +1 -0
- package/dist/runtime/store.mjs +4 -0
- package/dist/runtime/type.d.ts +74 -0
- package/dist/runtime/utils/block.d.ts +6 -4
- package/dist/runtime/utils/block.mjs +63 -22
- package/dist/runtime/utils/content.d.ts +2 -0
- package/dist/runtime/utils/content.mjs +15 -0
- package/dist/runtime/utils/convertor.d.ts +3 -2
- package/dist/runtime/utils/convertor.mjs +68 -9
- package/dist/runtime/utils/keyboardEvent.mjs +30 -19
- package/dist/runtime/utils/style.d.ts +1 -0
- package/dist/runtime/utils/style.mjs +288 -263
- package/dist/runtime/utils/ui.d.ts +0 -1
- package/dist/runtime/utils/ui.mjs +0 -35
- package/package.json +3 -2
- package/dist/runtime/plugin.d.ts +0 -2
- package/dist/runtime/plugin.mjs +0 -10
|
@@ -172,6 +172,285 @@
|
|
|
172
172
|
.dragon-editor-viewer ol.de-list-block {
|
|
173
173
|
list-style: decimal;
|
|
174
174
|
}
|
|
175
|
+
.dragon-editor-viewer .de-image-block {
|
|
176
|
+
display: flex;
|
|
177
|
+
align-items: center;
|
|
178
|
+
flex-direction: column;
|
|
179
|
+
row-gap: 8px;
|
|
180
|
+
}
|
|
181
|
+
.dragon-editor-viewer .de-image-block.de-align-left {
|
|
182
|
+
align-items: flex-start;
|
|
183
|
+
}
|
|
184
|
+
.dragon-editor-viewer .de-image-block.de-align-left .de-caption {
|
|
185
|
+
text-align: left;
|
|
186
|
+
}
|
|
187
|
+
.dragon-editor-viewer .de-image-block.de-align-right {
|
|
188
|
+
align-items: flex-end;
|
|
189
|
+
}
|
|
190
|
+
.dragon-editor-viewer .de-image-block.de-align-right .de-caption {
|
|
191
|
+
text-align: right;
|
|
192
|
+
}
|
|
193
|
+
.dragon-editor-viewer .de-image-block .de-image-area {
|
|
194
|
+
position: relative;
|
|
195
|
+
max-width: 25%;
|
|
196
|
+
}
|
|
197
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="25"] {
|
|
198
|
+
max-width: 25%;
|
|
199
|
+
}
|
|
200
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="26"] {
|
|
201
|
+
max-width: 26%;
|
|
202
|
+
}
|
|
203
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="27"] {
|
|
204
|
+
max-width: 27%;
|
|
205
|
+
}
|
|
206
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="28"] {
|
|
207
|
+
max-width: 28%;
|
|
208
|
+
}
|
|
209
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="29"] {
|
|
210
|
+
max-width: 29%;
|
|
211
|
+
}
|
|
212
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="30"] {
|
|
213
|
+
max-width: 30%;
|
|
214
|
+
}
|
|
215
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="31"] {
|
|
216
|
+
max-width: 31%;
|
|
217
|
+
}
|
|
218
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="32"] {
|
|
219
|
+
max-width: 32%;
|
|
220
|
+
}
|
|
221
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="33"] {
|
|
222
|
+
max-width: 33%;
|
|
223
|
+
}
|
|
224
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="34"] {
|
|
225
|
+
max-width: 34%;
|
|
226
|
+
}
|
|
227
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="35"] {
|
|
228
|
+
max-width: 35%;
|
|
229
|
+
}
|
|
230
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="36"] {
|
|
231
|
+
max-width: 36%;
|
|
232
|
+
}
|
|
233
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="37"] {
|
|
234
|
+
max-width: 37%;
|
|
235
|
+
}
|
|
236
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="38"] {
|
|
237
|
+
max-width: 38%;
|
|
238
|
+
}
|
|
239
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="39"] {
|
|
240
|
+
max-width: 39%;
|
|
241
|
+
}
|
|
242
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="40"] {
|
|
243
|
+
max-width: 40%;
|
|
244
|
+
}
|
|
245
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="41"] {
|
|
246
|
+
max-width: 41%;
|
|
247
|
+
}
|
|
248
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="42"] {
|
|
249
|
+
max-width: 42%;
|
|
250
|
+
}
|
|
251
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="43"] {
|
|
252
|
+
max-width: 43%;
|
|
253
|
+
}
|
|
254
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="44"] {
|
|
255
|
+
max-width: 44%;
|
|
256
|
+
}
|
|
257
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="45"] {
|
|
258
|
+
max-width: 45%;
|
|
259
|
+
}
|
|
260
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="46"] {
|
|
261
|
+
max-width: 46%;
|
|
262
|
+
}
|
|
263
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="47"] {
|
|
264
|
+
max-width: 47%;
|
|
265
|
+
}
|
|
266
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="48"] {
|
|
267
|
+
max-width: 48%;
|
|
268
|
+
}
|
|
269
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="49"] {
|
|
270
|
+
max-width: 49%;
|
|
271
|
+
}
|
|
272
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="50"] {
|
|
273
|
+
max-width: 50%;
|
|
274
|
+
}
|
|
275
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="51"] {
|
|
276
|
+
max-width: 51%;
|
|
277
|
+
}
|
|
278
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="52"] {
|
|
279
|
+
max-width: 52%;
|
|
280
|
+
}
|
|
281
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="53"] {
|
|
282
|
+
max-width: 53%;
|
|
283
|
+
}
|
|
284
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="54"] {
|
|
285
|
+
max-width: 54%;
|
|
286
|
+
}
|
|
287
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="55"] {
|
|
288
|
+
max-width: 55%;
|
|
289
|
+
}
|
|
290
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="56"] {
|
|
291
|
+
max-width: 56%;
|
|
292
|
+
}
|
|
293
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="57"] {
|
|
294
|
+
max-width: 57%;
|
|
295
|
+
}
|
|
296
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="58"] {
|
|
297
|
+
max-width: 58%;
|
|
298
|
+
}
|
|
299
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="59"] {
|
|
300
|
+
max-width: 59%;
|
|
301
|
+
}
|
|
302
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="60"] {
|
|
303
|
+
max-width: 60%;
|
|
304
|
+
}
|
|
305
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="61"] {
|
|
306
|
+
max-width: 61%;
|
|
307
|
+
}
|
|
308
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="62"] {
|
|
309
|
+
max-width: 62%;
|
|
310
|
+
}
|
|
311
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="63"] {
|
|
312
|
+
max-width: 63%;
|
|
313
|
+
}
|
|
314
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="64"] {
|
|
315
|
+
max-width: 64%;
|
|
316
|
+
}
|
|
317
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="65"] {
|
|
318
|
+
max-width: 65%;
|
|
319
|
+
}
|
|
320
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="66"] {
|
|
321
|
+
max-width: 66%;
|
|
322
|
+
}
|
|
323
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="67"] {
|
|
324
|
+
max-width: 67%;
|
|
325
|
+
}
|
|
326
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="68"] {
|
|
327
|
+
max-width: 68%;
|
|
328
|
+
}
|
|
329
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="69"] {
|
|
330
|
+
max-width: 69%;
|
|
331
|
+
}
|
|
332
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="70"] {
|
|
333
|
+
max-width: 70%;
|
|
334
|
+
}
|
|
335
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="71"] {
|
|
336
|
+
max-width: 71%;
|
|
337
|
+
}
|
|
338
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="72"] {
|
|
339
|
+
max-width: 72%;
|
|
340
|
+
}
|
|
341
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="73"] {
|
|
342
|
+
max-width: 73%;
|
|
343
|
+
}
|
|
344
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="74"] {
|
|
345
|
+
max-width: 74%;
|
|
346
|
+
}
|
|
347
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="75"] {
|
|
348
|
+
max-width: 75%;
|
|
349
|
+
}
|
|
350
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="76"] {
|
|
351
|
+
max-width: 76%;
|
|
352
|
+
}
|
|
353
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="77"] {
|
|
354
|
+
max-width: 77%;
|
|
355
|
+
}
|
|
356
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="78"] {
|
|
357
|
+
max-width: 78%;
|
|
358
|
+
}
|
|
359
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="79"] {
|
|
360
|
+
max-width: 79%;
|
|
361
|
+
}
|
|
362
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="80"] {
|
|
363
|
+
max-width: 80%;
|
|
364
|
+
}
|
|
365
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="81"] {
|
|
366
|
+
max-width: 81%;
|
|
367
|
+
}
|
|
368
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="82"] {
|
|
369
|
+
max-width: 82%;
|
|
370
|
+
}
|
|
371
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="83"] {
|
|
372
|
+
max-width: 83%;
|
|
373
|
+
}
|
|
374
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="84"] {
|
|
375
|
+
max-width: 84%;
|
|
376
|
+
}
|
|
377
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="85"] {
|
|
378
|
+
max-width: 85%;
|
|
379
|
+
}
|
|
380
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="86"] {
|
|
381
|
+
max-width: 86%;
|
|
382
|
+
}
|
|
383
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="87"] {
|
|
384
|
+
max-width: 87%;
|
|
385
|
+
}
|
|
386
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="88"] {
|
|
387
|
+
max-width: 88%;
|
|
388
|
+
}
|
|
389
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="89"] {
|
|
390
|
+
max-width: 89%;
|
|
391
|
+
}
|
|
392
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="90"] {
|
|
393
|
+
max-width: 90%;
|
|
394
|
+
}
|
|
395
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="91"] {
|
|
396
|
+
max-width: 91%;
|
|
397
|
+
}
|
|
398
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="92"] {
|
|
399
|
+
max-width: 92%;
|
|
400
|
+
}
|
|
401
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="93"] {
|
|
402
|
+
max-width: 93%;
|
|
403
|
+
}
|
|
404
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="94"] {
|
|
405
|
+
max-width: 94%;
|
|
406
|
+
}
|
|
407
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="95"] {
|
|
408
|
+
max-width: 95%;
|
|
409
|
+
}
|
|
410
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="96"] {
|
|
411
|
+
max-width: 96%;
|
|
412
|
+
}
|
|
413
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="97"] {
|
|
414
|
+
max-width: 97%;
|
|
415
|
+
}
|
|
416
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="98"] {
|
|
417
|
+
max-width: 98%;
|
|
418
|
+
}
|
|
419
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="99"] {
|
|
420
|
+
max-width: 99%;
|
|
421
|
+
}
|
|
422
|
+
.dragon-editor-viewer .de-image-block .de-image-area[data-maxwidth="100"] {
|
|
423
|
+
max-width: 100%;
|
|
424
|
+
}
|
|
425
|
+
.dragon-editor-viewer .de-image-block .de-image-area .de-img {
|
|
426
|
+
width: 100%;
|
|
427
|
+
height: auto;
|
|
428
|
+
}
|
|
429
|
+
.dragon-editor-viewer .de-image-block .de-image-area .de-btn {
|
|
430
|
+
position: absolute;
|
|
431
|
+
top: 50%;
|
|
432
|
+
width: 8px;
|
|
433
|
+
height: 100px;
|
|
434
|
+
background: #ccc;
|
|
435
|
+
border: 1px solid #333;
|
|
436
|
+
transform: translate(-50%, -50%);
|
|
437
|
+
cursor: col-resize;
|
|
438
|
+
user-select: none;
|
|
439
|
+
z-index: 100;
|
|
440
|
+
}
|
|
441
|
+
.dragon-editor-viewer .de-image-block .de-image-area .de-btn.de-btn-left {
|
|
442
|
+
left: 0;
|
|
443
|
+
}
|
|
444
|
+
.dragon-editor-viewer .de-image-block .de-image-area .de-btn.de-btn-right {
|
|
445
|
+
left: 100%;
|
|
446
|
+
}
|
|
447
|
+
.dragon-editor-viewer .de-image-block .de-caption {
|
|
448
|
+
width: 100%;
|
|
449
|
+
min-height: 1.6em;
|
|
450
|
+
color: #909090;
|
|
451
|
+
text-align: center;
|
|
452
|
+
outline: 0;
|
|
453
|
+
}
|
|
175
454
|
.dragon-editor-viewer .de-bold {
|
|
176
455
|
font-weight: 700;
|
|
177
456
|
}
|
|
@@ -195,4 +474,16 @@
|
|
|
195
474
|
background: #f1f1f1;
|
|
196
475
|
color: #ff0000;
|
|
197
476
|
border-radius: 5px;
|
|
477
|
+
}
|
|
478
|
+
.dragon-editor-viewer .de-align-left {
|
|
479
|
+
text-align: left;
|
|
480
|
+
}
|
|
481
|
+
.dragon-editor-viewer .de-align-right {
|
|
482
|
+
text-align: right;
|
|
483
|
+
}
|
|
484
|
+
.dragon-editor-viewer .de-align-center {
|
|
485
|
+
text-align: center;
|
|
486
|
+
}
|
|
487
|
+
.dragon-editor-viewer .de-align-justify {
|
|
488
|
+
text-align: justify;
|
|
198
489
|
}
|
package/dist/runtime/store.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"editorStor
|
|
|
4
4
|
setContentElement(value: HTMLDivElement): void;
|
|
5
5
|
setParentWrapElement(value: HTMLElement | Window): void;
|
|
6
6
|
setCursorData(data: DEditorCursor): void;
|
|
7
|
+
setCurrentBlock(block: HTMLElement): void;
|
|
7
8
|
}>;
|
package/dist/runtime/store.mjs
CHANGED
|
@@ -6,6 +6,7 @@ export const useEditorStore = defineStore("editorStore", {
|
|
|
6
6
|
message: {
|
|
7
7
|
linkTextNoStyle: "Link text can't set any style."
|
|
8
8
|
},
|
|
9
|
+
$currentBlock: null,
|
|
9
10
|
$editor: null,
|
|
10
11
|
$content: null,
|
|
11
12
|
$parentWrap: null
|
|
@@ -22,6 +23,9 @@ export const useEditorStore = defineStore("editorStore", {
|
|
|
22
23
|
},
|
|
23
24
|
setCursorData(data) {
|
|
24
25
|
this.cursorData = data;
|
|
26
|
+
},
|
|
27
|
+
setCurrentBlock(block) {
|
|
28
|
+
this.$currentBlock = block;
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
31
|
});
|
package/dist/runtime/type.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ interface EditorStore {
|
|
|
3
3
|
message: { [key: string]: string };
|
|
4
4
|
$editor: HTMLDivElement | null;
|
|
5
5
|
$content: HTMLDivElement | null;
|
|
6
|
+
$currentBlock: HTMLElement | null;
|
|
6
7
|
$parentWrap: HTMLElement | Window | null;
|
|
7
8
|
}
|
|
8
9
|
|
|
@@ -22,3 +23,76 @@ interface DEArrangeCursorData {
|
|
|
22
23
|
endNodeIdx: number;
|
|
23
24
|
endOffset: number;
|
|
24
25
|
}
|
|
26
|
+
|
|
27
|
+
interface DEImage {
|
|
28
|
+
src: string;
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
classList?: string[];
|
|
32
|
+
caption?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type DEDecoration = "bold" | "italic" | "underline" | "strikethrough" | "code";
|
|
36
|
+
|
|
37
|
+
type DETextalign = "left" | "right" | "center" | "justify";
|
|
38
|
+
|
|
39
|
+
type DEBlock = "text" | "heading" | "ul" | "ol" | "image";
|
|
40
|
+
|
|
41
|
+
// 컴포넌트 메서드용 타입
|
|
42
|
+
interface DragonEditor {
|
|
43
|
+
addBlock: (type: DEBlock) => void;
|
|
44
|
+
addImageBlock: (data: DEImage) => void;
|
|
45
|
+
setDecoration: (data: DEDecoration) => void;
|
|
46
|
+
setTextAlign: (type: DETextalign) => void;
|
|
47
|
+
getContentData: () => DEContentData;
|
|
48
|
+
setContentData: (data: DEContentData) => void;
|
|
49
|
+
addCustomBlock: (HTML: string, classList: string[]) => void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface DETextBlock {
|
|
53
|
+
type: "text";
|
|
54
|
+
classList: string[];
|
|
55
|
+
textContent: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface DEHeadingBlock {
|
|
59
|
+
type: "heading";
|
|
60
|
+
level: number;
|
|
61
|
+
id: string;
|
|
62
|
+
classList: string[];
|
|
63
|
+
textContent: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface DEListItem {
|
|
67
|
+
classList: string[];
|
|
68
|
+
textContent: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface DEUListBlock {
|
|
72
|
+
type: "ul";
|
|
73
|
+
child: DEListItem[];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface DEOListBlock {
|
|
77
|
+
type: "ol";
|
|
78
|
+
pattern: "a" | "i" | "1" | "A" | "I";
|
|
79
|
+
child: DEListItem[];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface DEImageBlock {
|
|
83
|
+
type: "image";
|
|
84
|
+
maxWidth: number;
|
|
85
|
+
src: string;
|
|
86
|
+
width: number;
|
|
87
|
+
height: number;
|
|
88
|
+
caption: string;
|
|
89
|
+
classList: string[];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
interface DECustomBlock {
|
|
93
|
+
type: "custom";
|
|
94
|
+
classList: string[];
|
|
95
|
+
textContent: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
type DEContentData = (DETextBlock | DEHeadingBlock | DEUListBlock | DEOListBlock | DEImageBlock | DECustomBlock)[];
|
|
@@ -2,8 +2,10 @@ export declare function _getBlockType(element: HTMLElement): {
|
|
|
2
2
|
$element: Element;
|
|
3
3
|
type: string;
|
|
4
4
|
};
|
|
5
|
-
export declare function _createTextBlock(
|
|
6
|
-
export declare function _createHeadingBlock(
|
|
7
|
-
export declare function _createListBlock(
|
|
8
|
-
export declare function _createListItemBlock(
|
|
5
|
+
export declare function _createTextBlock(data?: DETextBlock): HTMLParagraphElement;
|
|
6
|
+
export declare function _createHeadingBlock(data: DEHeadingBlock): HTMLHeadingElement;
|
|
7
|
+
export declare function _createListBlock(data: DEUListBlock | DEOListBlock): HTMLElement;
|
|
8
|
+
export declare function _createListItemBlock(child?: DEListItem): HTMLLIElement;
|
|
9
|
+
export declare function _createImageBlock(data: DEImageBlock): HTMLDivElement;
|
|
9
10
|
export declare function generateId(): string;
|
|
11
|
+
export declare function _createCustomBlock(data: DECustomBlock): HTMLDivElement;
|
|
@@ -11,6 +11,9 @@ export function _getBlockType(element) {
|
|
|
11
11
|
case $block.classList.contains("de-list-block"):
|
|
12
12
|
typeName = "list";
|
|
13
13
|
break;
|
|
14
|
+
case $block.classList.contains("de-image-block"):
|
|
15
|
+
typeName = "image";
|
|
16
|
+
break;
|
|
14
17
|
default:
|
|
15
18
|
typeName = "other";
|
|
16
19
|
}
|
|
@@ -19,47 +22,79 @@ export function _getBlockType(element) {
|
|
|
19
22
|
type: typeName
|
|
20
23
|
};
|
|
21
24
|
}
|
|
22
|
-
export function _createTextBlock(
|
|
25
|
+
export function _createTextBlock(data = { type: "text", classList: [], textContent: "" }) {
|
|
23
26
|
const $paragraph = document.createElement("p");
|
|
24
|
-
$paragraph.classList.add("de-block", "de-text-block");
|
|
27
|
+
$paragraph.classList.add("de-block", "de-text-block", ...data.classList);
|
|
25
28
|
$paragraph.setAttribute("contenteditable", "true");
|
|
26
|
-
if (
|
|
27
|
-
$paragraph.innerHTML =
|
|
29
|
+
if (data.textContent !== "") {
|
|
30
|
+
$paragraph.innerHTML = data.textContent;
|
|
28
31
|
}
|
|
29
32
|
return $paragraph;
|
|
30
33
|
}
|
|
31
|
-
export function _createHeadingBlock(
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
export function _createHeadingBlock(data) {
|
|
35
|
+
const $headingBlock = document.createElement(`h${data.level}`);
|
|
36
|
+
if (data.id === "") {
|
|
37
|
+
$headingBlock.id = generateId();
|
|
38
|
+
} else {
|
|
39
|
+
$headingBlock.id = data.id;
|
|
40
|
+
}
|
|
41
|
+
$headingBlock.classList.add("de-block", "de-heading-block", ...data.classList);
|
|
42
|
+
$headingBlock.dataset["level"] = String(data.level);
|
|
37
43
|
$headingBlock.setAttribute("contenteditable", "true");
|
|
38
|
-
if (
|
|
39
|
-
$headingBlock.innerHTML =
|
|
44
|
+
if (data.textContent !== "") {
|
|
45
|
+
$headingBlock.innerHTML = data.textContent;
|
|
40
46
|
}
|
|
41
47
|
return $headingBlock;
|
|
42
48
|
}
|
|
43
|
-
export function _createListBlock(
|
|
44
|
-
const $block = document.createElement(type);
|
|
49
|
+
export function _createListBlock(data) {
|
|
50
|
+
const $block = document.createElement(data.type);
|
|
45
51
|
$block.classList.add("de-block", "de-list-block");
|
|
46
|
-
if (type === "ol") {
|
|
47
|
-
$block.type = pattern ?? "1";
|
|
52
|
+
if (data.type === "ol") {
|
|
53
|
+
$block.type = data.pattern ?? "1";
|
|
48
54
|
}
|
|
49
|
-
|
|
50
|
-
$block.appendChild(_createListItemBlock(
|
|
55
|
+
data.child.forEach((child) => {
|
|
56
|
+
$block.appendChild(_createListItemBlock(child));
|
|
51
57
|
});
|
|
52
58
|
return $block;
|
|
53
59
|
}
|
|
54
|
-
export function _createListItemBlock(
|
|
60
|
+
export function _createListItemBlock(child = { textContent: "", classList: [] }) {
|
|
55
61
|
const $li = document.createElement("li");
|
|
56
|
-
$li.classList.add("de-item");
|
|
62
|
+
$li.classList.add("de-item", ...child.classList);
|
|
57
63
|
$li.setAttribute("contenteditable", "true");
|
|
58
|
-
if (
|
|
59
|
-
$li.innerHTML =
|
|
64
|
+
if (child.textContent !== "") {
|
|
65
|
+
$li.innerHTML = child.textContent;
|
|
60
66
|
}
|
|
61
67
|
return $li;
|
|
62
68
|
}
|
|
69
|
+
export function _createImageBlock(data) {
|
|
70
|
+
const $wrap = document.createElement("div");
|
|
71
|
+
const $div = document.createElement("div");
|
|
72
|
+
const $leftBtn = document.createElement("button");
|
|
73
|
+
const $rightBtn = document.createElement("button");
|
|
74
|
+
const $image = document.createElement("img");
|
|
75
|
+
const $p = document.createElement("p");
|
|
76
|
+
$wrap.classList.add("de-block", "de-image-block", ...data.classList);
|
|
77
|
+
$div.classList.add("de-image-area");
|
|
78
|
+
$div.dataset["maxwidth"] = String(data.maxWidth);
|
|
79
|
+
$leftBtn.classList.add("de-btn", "de-btn-left");
|
|
80
|
+
$rightBtn.classList.add("de-btn", "de-btn-right");
|
|
81
|
+
$image.classList.add("de-img");
|
|
82
|
+
$p.contentEditable = "true";
|
|
83
|
+
$p.classList.add("de-caption");
|
|
84
|
+
$image.src = data.src;
|
|
85
|
+
$image.width = data.width;
|
|
86
|
+
$image.height = data.height;
|
|
87
|
+
$image.draggable = false;
|
|
88
|
+
if (data.caption !== void 0) {
|
|
89
|
+
$p.textContent = data.caption;
|
|
90
|
+
}
|
|
91
|
+
$div.appendChild($image);
|
|
92
|
+
$div.appendChild($leftBtn);
|
|
93
|
+
$div.appendChild($rightBtn);
|
|
94
|
+
$wrap.appendChild($div);
|
|
95
|
+
$wrap.appendChild($p);
|
|
96
|
+
return $wrap;
|
|
97
|
+
}
|
|
63
98
|
export function generateId() {
|
|
64
99
|
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
65
100
|
let str = "";
|
|
@@ -68,3 +103,9 @@ export function generateId() {
|
|
|
68
103
|
}
|
|
69
104
|
return str;
|
|
70
105
|
}
|
|
106
|
+
export function _createCustomBlock(data) {
|
|
107
|
+
const $block = document.createElement("div");
|
|
108
|
+
$block.classList.add("de-block", "de-custom-block", ...data.classList);
|
|
109
|
+
$block.innerHTML = data.textContent;
|
|
110
|
+
return $block;
|
|
111
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { _clenupCursor } from "./cursor.mjs";
|
|
2
|
+
import "../type.d.ts";
|
|
3
|
+
export function _addBlockToContent($block, store) {
|
|
4
|
+
if (store.cursorData === null) {
|
|
5
|
+
store.$content.insertAdjacentElement("beforeend", $block);
|
|
6
|
+
} else {
|
|
7
|
+
_clenupCursor(store);
|
|
8
|
+
let $target = store.cursorData.startNode;
|
|
9
|
+
if ($target.constructor.name === "Text") {
|
|
10
|
+
$target = $target.parentNode;
|
|
11
|
+
}
|
|
12
|
+
const $block2 = $target.closest(".de-block");
|
|
13
|
+
$block2.insertAdjacentElement("afterend", $block2);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function
|
|
1
|
+
import "../type.d.ts";
|
|
2
|
+
export declare function _getContentData($content: HTMLDivElement): DEContentData;
|
|
3
|
+
export declare function _setContentData(data: DEContentData, store: any): void;
|