dragon-editor 3.5.14 → 3.5.16
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/dist/module.json +1 -1
- package/dist/module.mjs +18 -2
- package/dist/runtime/components/DragonEditor.vue +6 -1
- package/dist/runtime/components/DragonEditorViewer.vue +5 -0
- package/dist/runtime/scss/editor.css +5 -0
- package/dist/runtime/scss/viewer.css +5 -0
- package/dist/runtime/utils/event/block.d.ts +6 -0
- package/dist/runtime/utils/event/cursor.d.ts +6 -0
- package/dist/runtime/utils/event/data.d.ts +7 -0
- package/dist/runtime/utils/event/keyboard.d.ts +7 -0
- package/dist/runtime/utils/event/mouse.d.ts +11 -0
- package/dist/runtime/utils/event/scroll.d.ts +3 -0
- package/dist/runtime/utils/event/touch.d.ts +5 -0
- package/dist/runtime/utils/event/window.d.ts +5 -0
- package/dist/runtime/utils/layout/block.d.ts +7 -0
- package/dist/runtime/utils/layout/body.d.ts +3 -0
- package/dist/runtime/utils/layout/controlbar.d.ts +3 -0
- package/dist/runtime/utils/layout/icon.d.ts +3 -0
- package/dist/runtime/utils/layout/menuBar.d.ts +3 -0
- package/dist/runtime/utils/node/block.d.ts +19 -0
- package/dist/runtime/utils/node/block.js +14 -8
- package/dist/runtime/utils/node/element.d.ts +4 -0
- package/dist/runtime/utils/style/anchor.d.ts +5 -0
- package/dist/runtime/utils/style/decoration.d.ts +4 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -18,6 +18,7 @@ const module = defineNuxtModule({
|
|
|
18
18
|
},
|
|
19
19
|
async setup(options, nuxt) {
|
|
20
20
|
const resolver = createResolver(import.meta.url);
|
|
21
|
+
const typeContent = await readFile(`${__dirname}/runtime/type.d.ts`);
|
|
21
22
|
addComponent({
|
|
22
23
|
name: "DragonEditor",
|
|
23
24
|
filePath: resolver.resolve(__dirname, "./runtime/components/DragonEditor")
|
|
@@ -28,10 +29,25 @@ const module = defineNuxtModule({
|
|
|
28
29
|
});
|
|
29
30
|
addTypeTemplate({
|
|
30
31
|
filename: "types/dragon-editor.d.ts",
|
|
31
|
-
src: resolver.resolve(__dirname, "./runtime/type.d.ts"),
|
|
32
|
-
write: true
|
|
32
|
+
// src: resolver.resolve(__dirname, "./runtime/type.d.ts"),
|
|
33
|
+
// write: true,
|
|
34
|
+
getContents: () => `
|
|
35
|
+
declare global {
|
|
36
|
+
${typeContent}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export {}
|
|
40
|
+
`
|
|
33
41
|
});
|
|
34
42
|
}
|
|
35
43
|
});
|
|
44
|
+
async function readFile(path) {
|
|
45
|
+
if (typeof Bun !== "undefined" && Bun.file) {
|
|
46
|
+
const file = Bun.file(path);
|
|
47
|
+
return await file.text();
|
|
48
|
+
}
|
|
49
|
+
const { promises: fs } = await import('fs');
|
|
50
|
+
return await fs.readFile(path, "utf-8");
|
|
51
|
+
}
|
|
36
52
|
|
|
37
53
|
export { module as default };
|
|
@@ -10,7 +10,7 @@ import { _addBlock } from "../utils/node";
|
|
|
10
10
|
import { _setDecoration, _setTextAlign } from "../utils/style";
|
|
11
11
|
import type { VNode } from "vue";
|
|
12
12
|
import { codeToHtml } from "shiki";
|
|
13
|
-
import "../type.d.ts";
|
|
13
|
+
import type { DEBlockData, DEBlockMenutype, DEContentData, DEDecoration, DETextalign, DragonEditorStore } from "../type.d.ts";
|
|
14
14
|
|
|
15
15
|
interface DEOption {
|
|
16
16
|
modelValue: DEContentData;
|
|
@@ -552,6 +552,7 @@ defineExpose({
|
|
|
552
552
|
}
|
|
553
553
|
.dragon-editor .de-text-block {
|
|
554
554
|
min-height: 1.6em;
|
|
555
|
+
word-break: break-all;
|
|
555
556
|
outline: 0;
|
|
556
557
|
}
|
|
557
558
|
.dragon-editor .de-text-block:empty:hover::before, .dragon-editor .de-text-block:empty:focus::before {
|
|
@@ -562,6 +563,7 @@ defineExpose({
|
|
|
562
563
|
}
|
|
563
564
|
.dragon-editor .de-heading-block {
|
|
564
565
|
min-height: 1.6em;
|
|
566
|
+
word-break: break-all;
|
|
565
567
|
outline: 0;
|
|
566
568
|
}
|
|
567
569
|
.dragon-editor .de-heading-block[data-level="1"] {
|
|
@@ -608,6 +610,7 @@ defineExpose({
|
|
|
608
610
|
}
|
|
609
611
|
.dragon-editor .de-list-block .de-item {
|
|
610
612
|
min-height: 1.6em;
|
|
613
|
+
word-break: break-all;
|
|
611
614
|
outline: 0;
|
|
612
615
|
list-style: inherit;
|
|
613
616
|
}
|
|
@@ -896,6 +899,7 @@ defineExpose({
|
|
|
896
899
|
min-height: 1.6em;
|
|
897
900
|
color: #909090;
|
|
898
901
|
text-align: center;
|
|
902
|
+
word-break: break-all;
|
|
899
903
|
outline: 0;
|
|
900
904
|
}
|
|
901
905
|
.dragon-editor .de-image-block .de-caption:empty:hover::before, .dragon-editor .de-image-block .de-caption:empty:focus::before {
|
|
@@ -912,6 +916,7 @@ defineExpose({
|
|
|
912
916
|
}
|
|
913
917
|
.dragon-editor .de-code-block .de-filename {
|
|
914
918
|
flex: 1;
|
|
919
|
+
max-width: calc(100% - 120px);
|
|
915
920
|
padding: 5px 10px;
|
|
916
921
|
box-sizing: border-box;
|
|
917
922
|
outline: 0;
|
|
@@ -205,10 +205,12 @@ function structure(): VNode {
|
|
|
205
205
|
}
|
|
206
206
|
.dragon-editor-viewer .de-text-block {
|
|
207
207
|
min-height: 1.6em;
|
|
208
|
+
word-break: break-all;
|
|
208
209
|
outline: 0;
|
|
209
210
|
}
|
|
210
211
|
.dragon-editor-viewer .de-heading-block {
|
|
211
212
|
min-height: 1.6em;
|
|
213
|
+
word-break: break-all;
|
|
212
214
|
outline: 0;
|
|
213
215
|
}
|
|
214
216
|
.dragon-editor-viewer .de-heading-block[data-level="1"] {
|
|
@@ -249,6 +251,7 @@ function structure(): VNode {
|
|
|
249
251
|
}
|
|
250
252
|
.dragon-editor-viewer .de-list-block .de-item {
|
|
251
253
|
min-height: 1.6em;
|
|
254
|
+
word-break: break-all;
|
|
252
255
|
outline: 0;
|
|
253
256
|
list-style: inherit;
|
|
254
257
|
}
|
|
@@ -531,6 +534,7 @@ function structure(): VNode {
|
|
|
531
534
|
min-height: 1.6em;
|
|
532
535
|
color: #909090;
|
|
533
536
|
text-align: center;
|
|
537
|
+
word-break: break-all;
|
|
534
538
|
outline: 0;
|
|
535
539
|
}
|
|
536
540
|
.dragon-editor-viewer .de-code-block {
|
|
@@ -541,6 +545,7 @@ function structure(): VNode {
|
|
|
541
545
|
}
|
|
542
546
|
.dragon-editor-viewer .de-code-block .de-filename {
|
|
543
547
|
flex: 1;
|
|
548
|
+
max-width: calc(100% - 120px);
|
|
544
549
|
padding: 5px 10px;
|
|
545
550
|
box-sizing: border-box;
|
|
546
551
|
outline: 0;
|
|
@@ -339,6 +339,7 @@
|
|
|
339
339
|
}
|
|
340
340
|
.dragon-editor .de-text-block {
|
|
341
341
|
min-height: 1.6em;
|
|
342
|
+
word-break: break-all;
|
|
342
343
|
outline: 0;
|
|
343
344
|
}
|
|
344
345
|
.dragon-editor .de-text-block:empty:hover::before, .dragon-editor .de-text-block:empty:focus::before {
|
|
@@ -349,6 +350,7 @@
|
|
|
349
350
|
}
|
|
350
351
|
.dragon-editor .de-heading-block {
|
|
351
352
|
min-height: 1.6em;
|
|
353
|
+
word-break: break-all;
|
|
352
354
|
outline: 0;
|
|
353
355
|
}
|
|
354
356
|
.dragon-editor .de-heading-block[data-level="1"] {
|
|
@@ -395,6 +397,7 @@
|
|
|
395
397
|
}
|
|
396
398
|
.dragon-editor .de-list-block .de-item {
|
|
397
399
|
min-height: 1.6em;
|
|
400
|
+
word-break: break-all;
|
|
398
401
|
outline: 0;
|
|
399
402
|
list-style: inherit;
|
|
400
403
|
}
|
|
@@ -683,6 +686,7 @@
|
|
|
683
686
|
min-height: 1.6em;
|
|
684
687
|
color: #909090;
|
|
685
688
|
text-align: center;
|
|
689
|
+
word-break: break-all;
|
|
686
690
|
outline: 0;
|
|
687
691
|
}
|
|
688
692
|
.dragon-editor .de-image-block .de-caption:empty:hover::before, .dragon-editor .de-image-block .de-caption:empty:focus::before {
|
|
@@ -699,6 +703,7 @@
|
|
|
699
703
|
}
|
|
700
704
|
.dragon-editor .de-code-block .de-filename {
|
|
701
705
|
flex: 1;
|
|
706
|
+
max-width: calc(100% - 120px);
|
|
702
707
|
padding: 5px 10px;
|
|
703
708
|
box-sizing: border-box;
|
|
704
709
|
outline: 0;
|
|
@@ -170,10 +170,12 @@
|
|
|
170
170
|
}
|
|
171
171
|
.dragon-editor-viewer .de-text-block {
|
|
172
172
|
min-height: 1.6em;
|
|
173
|
+
word-break: break-all;
|
|
173
174
|
outline: 0;
|
|
174
175
|
}
|
|
175
176
|
.dragon-editor-viewer .de-heading-block {
|
|
176
177
|
min-height: 1.6em;
|
|
178
|
+
word-break: break-all;
|
|
177
179
|
outline: 0;
|
|
178
180
|
}
|
|
179
181
|
.dragon-editor-viewer .de-heading-block[data-level="1"] {
|
|
@@ -214,6 +216,7 @@
|
|
|
214
216
|
}
|
|
215
217
|
.dragon-editor-viewer .de-list-block .de-item {
|
|
216
218
|
min-height: 1.6em;
|
|
219
|
+
word-break: break-all;
|
|
217
220
|
outline: 0;
|
|
218
221
|
list-style: inherit;
|
|
219
222
|
}
|
|
@@ -496,6 +499,7 @@
|
|
|
496
499
|
min-height: 1.6em;
|
|
497
500
|
color: #909090;
|
|
498
501
|
text-align: center;
|
|
502
|
+
word-break: break-all;
|
|
499
503
|
outline: 0;
|
|
500
504
|
}
|
|
501
505
|
.dragon-editor-viewer .de-code-block {
|
|
@@ -506,6 +510,7 @@
|
|
|
506
510
|
}
|
|
507
511
|
.dragon-editor-viewer .de-code-block .de-filename {
|
|
508
512
|
flex: 1;
|
|
513
|
+
max-width: calc(100% - 120px);
|
|
509
514
|
padding: 5px 10px;
|
|
510
515
|
box-sizing: border-box;
|
|
511
516
|
outline: 0;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { DragonEditorStore } from "../../type.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;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { DEArrangeCursorData, DEditorCursor, DragonEditorStore } from "../../type.js";
|
|
3
|
+
export declare function _updateCursorData(store: Ref<DragonEditorStore>): void;
|
|
4
|
+
export declare function _setCursor($target: Node, startIdx: number): void;
|
|
5
|
+
export declare function _setRangeCursor($startTarget: Element, $endTarget: Element, startIdx: number, endIdx: number): void;
|
|
6
|
+
export declare function _sortingCursorDataOnElement(cursorData: DEditorCursor, $element: HTMLElement): DEArrangeCursorData;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { DECodeItem, DECodeblockLang, DragonEditorStore, DEBlockData, DEBlockMenutype } from "../../type.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;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { DragonEditorStore } from "../../type.js";
|
|
3
|
+
export declare function _contentKeydownEvent(event: KeyboardEvent, store: Ref<DragonEditorStore>): void;
|
|
4
|
+
export declare function _contentPasteEvent(event: ClipboardEvent, store: Ref<DragonEditorStore>): Promise<void>;
|
|
5
|
+
export declare function _setIndent(store: Ref<DragonEditorStore>, type: "plus" | "minus"): void;
|
|
6
|
+
export declare function _hotKeyEvent(event: KeyboardEvent, store: Ref<DragonEditorStore>): void;
|
|
7
|
+
export declare function _contentKeyupEvent(event: KeyboardEvent, store: Ref<DragonEditorStore>): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { DragonEditorStore } from "../../type.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(store: Ref<DragonEditorStore>): void;
|
|
10
|
+
export declare function _decideWhetherOpenControlBar(store: Ref<DragonEditorStore>): void;
|
|
11
|
+
export declare function _editorContextMenuEvent(event: MouseEvent, store: Ref<DragonEditorStore>): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { DragonEditorStore } from "../../type.js";
|
|
3
|
+
export declare function _contentTouchstartEvent(event: TouchEvent, store: Ref<DragonEditorStore>): void;
|
|
4
|
+
export declare function _editorTouchmoveEvent(event: TouchEvent, store: Ref<DragonEditorStore>): void;
|
|
5
|
+
export declare function _editorTouchendEvent(event: TouchEvent, store: Ref<DragonEditorStore>): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { DragonEditorStore } from "../../type.js";
|
|
3
|
+
export declare function _eidtorMountEvent(store: Ref<DragonEditorStore>): void;
|
|
4
|
+
export declare function _eidtorUnmountEvent(store: Ref<DragonEditorStore>): void;
|
|
5
|
+
export declare function _windowResizeEvent(event: Event, store: Ref<DragonEditorStore>): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
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.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 _updateCurrentBlock(event: Event, store: Ref<DragonEditorStore>): void;
|
|
16
|
+
export declare function _updateHeadingBlockList(store: Ref<DragonEditorStore>): void;
|
|
17
|
+
export declare function _setCodeBlockTheme(theme: DECodeblockTheme, store: Ref<DragonEditorStore>): Promise<void>;
|
|
18
|
+
export declare function _setCodeBlockLanguage(language: DECodeblockLang, store: Ref<DragonEditorStore>): Promise<void>;
|
|
19
|
+
export declare function _setListBlockStyle(style: DEListStyle, store: Ref<DragonEditorStore>): void;
|
|
@@ -213,9 +213,12 @@ export async function _setCodeBlockTheme(theme, store) {
|
|
|
213
213
|
const convert = await store.value.codeToHtml($code.textContent ?? "", { lang: store.value.controlStatus.codeBlockLang, theme });
|
|
214
214
|
const $div = document.createElement("div");
|
|
215
215
|
$div.innerHTML = convert;
|
|
216
|
-
$
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
const $childCode = $div.querySelector("code");
|
|
217
|
+
if ($childCode !== null) {
|
|
218
|
+
$code.innerHTML = $childCode.innerHTML;
|
|
219
|
+
store.value.controlStatus.codeBlockTheme = theme;
|
|
220
|
+
store.value.controlStatus.$currentBlock.dataset["theme"] = theme;
|
|
221
|
+
}
|
|
219
222
|
_updateCursorData(store);
|
|
220
223
|
_updateModelData(store);
|
|
221
224
|
}
|
|
@@ -231,11 +234,14 @@ export async function _setCodeBlockLanguage(language, store) {
|
|
|
231
234
|
const convert = await store.value.codeToHtml($code.textContent ?? "", { lang: language, theme: store.value.controlStatus.codeBlockTheme });
|
|
232
235
|
const $div = document.createElement("div");
|
|
233
236
|
$div.innerHTML = convert;
|
|
234
|
-
$
|
|
235
|
-
$
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
const $childCode = $div.querySelector("code");
|
|
238
|
+
if ($childCode !== null) {
|
|
239
|
+
$target.textContent = targetValue.text;
|
|
240
|
+
$code.innerHTML = $childCode.innerHTML;
|
|
241
|
+
store.value.controlStatus.codeBlockLang = targetValue.code;
|
|
242
|
+
_updateCursorData(store);
|
|
243
|
+
_updateModelData(store);
|
|
244
|
+
}
|
|
239
245
|
}
|
|
240
246
|
}
|
|
241
247
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function _findScrollingElement($target: HTMLElement): HTMLElement | Window;
|
|
2
|
+
export declare function _getParentElementIfNodeIsText($target: Node, $block: HTMLElement): Node;
|
|
3
|
+
export declare function _findContentEditableElement($target: Node): HTMLElement | null;
|
|
4
|
+
export declare function _findPoverTextNode(node: Element, idx: number): number;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { DragonEditorStore } from "../../type.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(store: Ref<DragonEditorStore>, previous?: boolean): void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { DragonEditorStore, DETextalign } from "../../type.js";
|
|
3
|
+
export declare function _setDecoration(className: string, store: Ref<DragonEditorStore>): void;
|
|
4
|
+
export declare function _setTextAlign(type: DETextalign, store: Ref<DragonEditorStore>): void;
|