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,179 +1,156 @@
1
- import type { codeToHtml } from "shiki";
1
+ // 컨텐츠 데이터
2
+ export type DEContentData = DEBlockData[];
2
3
 
3
- type DEContentData = DEBlockData[];
4
+ // 컨텐츠 타입
5
+ export type DEBlockData = DETextBlock | DEHeadingBlock | DEListBlock | DEImageBlock | DECodeBlock | DECustomBlock | DEDividerBlock;
4
6
 
5
- type DEBlockData = DETextBlock | DEHeadingBlock | DEListBlock | DEImageBlock | DECodeBlock | DECustomBlock | DEDividerBlock;
7
+ // 블록 타입
8
+ export type DEBlockType = DEBlockData["type"];
6
9
 
7
- type DEIconKind = "plus" | "bold" | "italic" | "underline" | "strikethrough" | "codeblock" | "add-link" | "remove-link" | "image" | "align-center" | "align-left" | "align-right" | "align-justify" | "move-up" | "move-down" | "indent-decrease" | "indent-increase";
10
+ // 리스트 엘리먼트 태그
11
+ export type DEListElementName = "ul" | "ol";
8
12
 
9
- type DEDecoration = "bold" | "italic" | "underline" | "strikethrough" | "code";
13
+ // 해딩 테그 레벨
14
+ export type DEHeadingElementLevel = 1 | 2 | 3;
10
15
 
11
- type DETextalign = "left" | "right" | "center" | "justify";
16
+ // 아이콘 종류
17
+ export type DEIconKind = "plus" | "bold" | "italic" | "underline" | "strikethrough" | "codeblock" | "add-link" | "remove-link" | "image" | "align-center" | "align-left" | "align-right" | "align-justify" | "move-up" | "move-down" | "move-first" | "move-last" | "indent-decrease" | "indent-increase";
12
18
 
13
- type DEBlock = "text" | "heading" | "ul" | "ol" | "image" | "code" | "custom";
19
+ // 메뉴용 블럭 추가 타입
20
+ export type DEBlockMenutype = Exclude<DEBlockType, "heading" | "list" | "image"> | "heading1" | "heading2" | "heading3" | "unordered-list" | "ordered-list";
14
21
 
15
- type DEBlockMenutype = "text" | "heading1" | "heading2" | "heading3" | "ul" | "ol" | "image" | "code" | "custom" | "divider";
22
+ // 정렬 종류
23
+ export type DETextalign = "left" | "right" | "center" | "justify";
16
24
 
17
- type DEListStyle = "disc" | "square" | "decimal" | "lower-alpha" | "upper-alpha" | "lower-roman" | "upper-roman";
25
+ // 데코레이션 클레스 종류
26
+ export type DEDecorationClass = "de-bold" | "de-italic" | "de-underline" | "de-strikethrough" | "de-code";
18
27
 
19
- type DECodeblockTheme = "github-light" | "github-dark-dimmed";
20
-
21
- type DECodeblockLang = "text" | "csharp" | "c" | "cpp" | "css" | "django" | "dockerfile" | "go" | "html" | "json" | "java" | "javascript" | "typescript" | "kotlin" | "lua" | "markdown" | "nginx" | "php" | "python" | "ruby" | "scss" | "sql" | "shellscript" | "swift" | "yaml";
22
-
23
- type DEBlockElement = HTMLParagraphElement | HTMLHeadingElement | HTMLElement | HTMLDivElement;
24
-
25
- type DEListElementName = "ul" | "ol";
28
+ // 에디터 컴포넌트
29
+ export interface DragonEditor {
30
+ addBlock(name: DEBlockMenutype, textContent: string = ""): Promise<void>;
31
+ addImageBlock(src: string, caption: string = ""): Promise<void>;
32
+ updateLayout(): void;
33
+ checkDataIsEmpty(data?: DEContentData): boolean;
34
+ setDecoration(type: "bold" | "italic" | "underline" | "strikethrough" | "code"): void;
35
+ setAlign(align: DETextalign): void;
36
+ }
26
37
 
27
- interface DragonEditorStore {
28
- cursorData: DEditorCursor | null;
29
- message: { [key: string]: string };
30
- controlBar: {
31
- active: boolean;
32
- x: number;
33
- y: number;
34
- $element: HTMLDivElement | null;
35
- };
36
- useMenuBar: boolean;
37
- imageHostURL: string;
38
- screenChangePoint: number;
39
- firstData: DEContentData;
40
- menuBarTop: number;
41
- activeStatus: {
42
- addBlockMenu: boolean;
43
- anchorInputArea: boolean;
44
- imageResizeEvent: boolean;
38
+ // 스토어 구조체
39
+ export interface DragonEditorStore {
40
+ data: DEContentData;
41
+ selectedBlockId: string;
42
+ selectedBlockIndex: number;
43
+ option: DEOption;
44
+ status: {
45
+ isParentOverflowHidden: boolean;
46
+ isImageResizeActive: boolean;
47
+ anchorHerf: string;
48
+ menuTop: number;
45
49
  };
46
- eventStatus: {
47
- imageResizeEventStartX: number;
48
- imageResizeEventType: "right" | "left";
49
- imageResizeEventEndX: number;
50
- imageResizeCurrentWidth: number;
50
+ cursorSelection: null | Selection;
51
+ cursorRange: null | Range;
52
+ fn: {
53
+ updateEditorData: ((data: DEContentData) => void) | null;
54
+ uploadImage: ((files: File[]) => void) | null;
51
55
  };
52
- controlStatus: {
53
- isMobile: boolean;
54
- hasTransformParent: boolean;
55
- hasHiddenStyleParent: boolean;
56
- anchorValidation: boolean;
57
- currentBlockType: DEBlock;
58
- codeBlockTheme: DECodeblockTheme;
59
- codeBlockLang: DECodeblockLang;
60
- listBlockStyle: DEListStyle;
61
- anchorTabType: "url" | "heading";
62
- anchorHeadingList: DEHeadingItem[];
63
- anchorHref: string;
64
- previousCorsorData: DEditorCursor | null;
65
- $anchorInput: HTMLInputElement | null;
66
- $currentBlock: HTMLDivElement | null;
67
- $transformElement: HTMLElement | null;
56
+ element: {
57
+ editor: null | HTMLDivElement;
58
+ body: null | HTMLDivElement;
59
+ scrollParentElement: HTMLElement | Window | null;
68
60
  };
69
- codeToHtml: codeToHtml;
70
- codeBlockTheme: DECodeItem<DECodeblockTheme>[];
71
- listUlType: DECodeItem<DEListStyle>[];
72
- listOlType: DECodeItem<DEListStyle>[];
73
- $editor: HTMLDivElement | null;
74
- $body: HTMLDivElement | null;
75
- $controlBar: HTMLDivElement | null;
76
- $parentWrap: HTMLElement | Window | null;
77
- windowClickEvent(event: MouseEvent): void;
78
- windowResizeEvent(event: Event): void;
79
- windowMouseUpEvent(event: MouseEvent): void;
80
- parentWrapScollEvent(event: Event): void;
81
- emit: {
82
- (e: "update:modelValue", data: DEContentData): void;
83
- (e: "uploadImageEvent", file: File): void;
84
- };
85
- }
86
-
87
- interface DEditorCursor {
88
- type: "Range" | "Caret" | "None";
89
- startNode: Node;
90
- startOffset: number;
91
- endNode: Node;
92
- endOffset: number;
93
- }
94
-
95
- interface DEArrangeCursorData {
96
- startNode: Node;
97
- startNodeIdx: number;
98
- startOffset: number;
99
- endNode: Node;
100
- endNodeIdx: number;
101
- endOffset: number;
61
+ codeBlockLnaguageList: { [key: string]: string };
102
62
  }
103
63
 
104
- interface DECodeItem<T = string> {
105
- text: string;
106
- code: T;
64
+ // 스토어용 에디터 옵션
65
+ export interface DEOption {
66
+ mediaHostURL: string;
67
+ isMobile: boolean;
68
+ codeBlockSpaces: number;
69
+ acceptImageFormat: string;
70
+ anchorTagTarget: string;
107
71
  }
108
72
 
109
- interface DEHeadingItem {
110
- name: string;
73
+ // 컨텐츠 블럭 타입
74
+ export interface DETextBlock {
111
75
  id: string;
112
- }
113
-
114
- // 컴포넌트 메서드용 타입
115
- interface DragonEditor {
116
- addBlock: (type: DEBlockData) => void;
117
- setDecoration: (data: DEDecoration) => void;
118
- setTextAlign: (type: DETextalign) => void;
119
- changeEditorData: (data: DEContentData) => void;
120
- updateLayout: () => void;
121
- checkDataEmpty: (data?: DEContentData) => boolean;
122
- }
123
-
124
- interface DETextBlock {
125
76
  type: "text";
126
77
  classList: string[];
127
78
  depth?: number;
128
79
  textContent: string;
129
80
  }
130
81
 
131
- interface DEHeadingBlock {
132
- type: "heading";
133
- level: number;
82
+ // 컨텐츠 해딩 타입
83
+ export interface DEHeadingBlock {
134
84
  id: string;
135
- depth?: number;
85
+ type: "heading";
136
86
  classList: string[];
87
+ level: DEHeadingElementLevel;
88
+ depth?: number;
137
89
  textContent: string;
138
90
  }
139
91
 
140
- interface DEListItem {
92
+ // 컨텐츠 리스트 자식 타입
93
+ export interface DEListItem {
94
+ id: string;
141
95
  classList: string[];
96
+ depth?: number;
142
97
  textContent: string;
143
98
  }
144
99
 
145
- interface DEListBlock {
100
+ // 컨텐츠 리스트 타입
101
+ export interface DEListBlock {
102
+ id: string;
146
103
  type: "list";
147
104
  element: DEListElementName;
148
- depth?: number;
149
- style: DEListStyle;
150
105
  child: DEListItem[];
151
106
  }
152
107
 
153
- interface DEImageBlock {
108
+ // 컨텐츠 이미지 타입
109
+ export interface DEImageBlock {
110
+ id: string;
154
111
  type: "image";
112
+ classList: string[];
155
113
  maxWidth: number;
156
114
  src: string;
157
- width: number;
158
- height: number;
159
115
  caption: string;
160
- classList: string[];
161
116
  }
162
117
 
163
- interface DECodeBlock {
118
+ // 컨텐츠 코드 블럭 타입
119
+ export interface DECodeBlock {
120
+ id: string;
164
121
  type: "code";
165
- language: DECodeblockLang;
166
- theme: DECodeblockTheme;
122
+ language: string;
167
123
  filename: string;
168
124
  textContent: string;
169
125
  }
170
126
 
171
- interface DECustomBlock {
127
+ // 컨텐츠 커스텀 타입
128
+ export interface DECustomBlock {
129
+ id: string;
172
130
  type: "custom";
173
- classList: string[];
174
131
  textContent: string;
175
132
  }
176
133
 
177
- interface DEDividerBlock {
134
+ // 컨텐츠 구분선 타입
135
+ export interface DEDividerBlock {
136
+ id: string;
178
137
  type: "divider";
179
138
  }
139
+
140
+ // 멀티라인 포지션
141
+ export interface DELinePosition {
142
+ curruntLine: number;
143
+ lineCount: number;
144
+ }
145
+
146
+ // 커서 포지션
147
+ export interface DECurSorPosition {
148
+ isStart: boolean;
149
+ isEnd: boolean;
150
+ }
151
+
152
+ // 커서 오프샛
153
+ export interface DECursorOffset {
154
+ nodeIndex: number;
155
+ offset: number;
156
+ }
@@ -0,0 +1,20 @@
1
+ import type { DEContentData, DETextBlock, DEHeadingBlock, DEHeadingElementLevel, DEBlockType, DEBlockMenutype, DECodeBlock, DEImageBlock, DEDividerBlock, DECustomBlock, DEBlockData } from "../../type.d.mts.js";
2
+ export declare function _arrangementContentData(data: DEContentData): DEContentData;
3
+ export declare function _createTextBlockData(textContent?: string): DETextBlock;
4
+ export declare function _createHeadingBlockData(level: DEHeadingElementLevel, textContent?: string): DEHeadingBlock;
5
+ export declare function _createListBlockData(element: DEListElementName, childList?: DEListItem[]): DEListBlock;
6
+ export declare function _createListBlockChildData(textContent?: string, depth?: number): DEListItem;
7
+ export declare function _createImageBlockData(src: string, caption?: string, useHost?: boolean): DEImageBlock;
8
+ export declare function _createCodeBlockData(language?: string, textContent?: string, filename?: string): DECodeBlock;
9
+ export declare function _createDividerBlockData(): DEDividerBlock;
10
+ export declare function _createCustomBlockData(textContent?: string): DECustomBlock;
11
+ export declare function _getBlockType($block: HTMLElement): DEBlockType;
12
+ export declare function _addBlock(name: DEBlockMenutype, textContent?: string): Promise<void>;
13
+ export declare function _addImageBlock(src: string, caption?: string): Promise<void>;
14
+ export declare function _convertMarkdownToEditor(textDataList: string[]): Promise<DEBlockData[]>;
15
+ export declare function _moveBlockIndex(duration: "first" | "up" | "down" | "last"): Promise<void>;
16
+ export declare function _checkCanUseIndent(): boolean;
17
+ export declare function _setIndentData(type: "decrease" | "increase"): Promise<void>;
18
+ export declare function _checkCanUseAlign(): boolean;
19
+ export declare function _checkCanUseDecoration(): boolean;
20
+ export declare function _checkDataIsEmpty(data?: DEContentData): boolean;