dragon-editor 2.1.2 → 3.0.0-beta
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 +40 -115
- package/dist/module.json +1 -1
- package/dist/module.mjs +10 -12
- package/dist/runtime/components/DragonEditor.vue +441 -0
- package/dist/runtime/plugin.d.ts +2 -0
- package/dist/runtime/plugin.mjs +10 -0
- package/dist/runtime/scss/editor.css +262 -0
- package/dist/runtime/scss/viewer.css +129 -0
- package/dist/runtime/store.d.ts +7 -0
- package/dist/runtime/store.mjs +27 -0
- package/dist/runtime/type.d.ts +24 -0
- package/dist/runtime/utils/block.d.ts +9 -0
- package/dist/runtime/utils/block.mjs +70 -0
- package/dist/runtime/utils/cursor.d.ts +6 -0
- package/dist/runtime/utils/cursor.mjs +132 -0
- package/dist/runtime/utils/element.d.ts +3 -0
- package/dist/runtime/utils/element.mjs +39 -0
- package/dist/runtime/utils/keyboardEvent.d.ts +10 -0
- package/dist/runtime/utils/keyboardEvent.mjs +781 -0
- package/dist/runtime/utils/style.d.ts +1 -0
- package/dist/runtime/utils/style.mjs +330 -0
- package/dist/runtime/utils/ui.d.ts +1 -0
- package/dist/runtime/utils/ui.mjs +35 -0
- package/package.json +10 -4
- package/README_en.md +0 -30
- package/dist/runtime/core/components/SvgIcon.d.ts +0 -10
- package/dist/runtime/core/components/SvgIcon.mjs +0 -98
- package/dist/runtime/core/components/editor/ImageBlock.vue +0 -175
- package/dist/runtime/core/components/editor/OlBlock.vue +0 -162
- package/dist/runtime/core/components/editor/TextBlock.vue +0 -172
- package/dist/runtime/core/components/editor/UlBlock.vue +0 -162
- package/dist/runtime/core/style/common.css +0 -496
- package/dist/runtime/core/style/viewer.css +0 -205
- package/dist/runtime/core/utils/converter.d.ts +0 -2
- package/dist/runtime/core/utils/converter.mjs +0 -90
- package/dist/runtime/core/utils/cursor.d.ts +0 -4
- package/dist/runtime/core/utils/cursor.mjs +0 -84
- package/dist/runtime/core/utils/element.d.ts +0 -3
- package/dist/runtime/core/utils/element.mjs +0 -40
- package/dist/runtime/core/utils/global.d.ts +0 -3
- package/dist/runtime/core/utils/global.mjs +0 -81
- package/dist/runtime/core/utils/index.d.ts +0 -7
- package/dist/runtime/core/utils/index.mjs +0 -7
- package/dist/runtime/core/utils/keyboard.d.ts +0 -6
- package/dist/runtime/core/utils/keyboard.mjs +0 -565
- package/dist/runtime/core/utils/style.d.ts +0 -6
- package/dist/runtime/core/utils/style.mjs +0 -374
- package/dist/runtime/core/utils/ui.d.ts +0 -4
- package/dist/runtime/core/utils/ui.mjs +0 -13
- package/dist/runtime/shared/components/DragonEditor.vue +0 -695
- package/dist/runtime/shared/components/DragonEditorComment.vue +0 -172
- package/dist/runtime/shared/components/DragonEditorNew.d.ts +0 -16
- package/dist/runtime/shared/components/DragonEditorNew.mjs +0 -62
- package/dist/runtime/shared/components/DragonEditorViewer.d.ts +0 -14
- package/dist/runtime/shared/components/DragonEditorViewer.mjs +0 -15
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
@charset "UTF-8";
|
|
2
|
+
.dragon-editor,
|
|
3
|
+
.dragon-editor-viewer {
|
|
4
|
+
/**
|
|
5
|
+
* Reset style start
|
|
6
|
+
*/
|
|
7
|
+
}
|
|
8
|
+
.dragon-editor h1,
|
|
9
|
+
.dragon-editor h2,
|
|
10
|
+
.dragon-editor h3,
|
|
11
|
+
.dragon-editor h4,
|
|
12
|
+
.dragon-editor h5,
|
|
13
|
+
.dragon-editor h6,
|
|
14
|
+
.dragon-editor p,
|
|
15
|
+
.dragon-editor blockquote,
|
|
16
|
+
.dragon-editor pre,
|
|
17
|
+
.dragon-editor dl,
|
|
18
|
+
.dragon-editor dd,
|
|
19
|
+
.dragon-editor ol,
|
|
20
|
+
.dragon-editor ul,
|
|
21
|
+
.dragon-editor fieldset,
|
|
22
|
+
.dragon-editor legend,
|
|
23
|
+
.dragon-editor figure,
|
|
24
|
+
.dragon-editor menu,
|
|
25
|
+
.dragon-editor-viewer h1,
|
|
26
|
+
.dragon-editor-viewer h2,
|
|
27
|
+
.dragon-editor-viewer h3,
|
|
28
|
+
.dragon-editor-viewer h4,
|
|
29
|
+
.dragon-editor-viewer h5,
|
|
30
|
+
.dragon-editor-viewer h6,
|
|
31
|
+
.dragon-editor-viewer p,
|
|
32
|
+
.dragon-editor-viewer blockquote,
|
|
33
|
+
.dragon-editor-viewer pre,
|
|
34
|
+
.dragon-editor-viewer dl,
|
|
35
|
+
.dragon-editor-viewer dd,
|
|
36
|
+
.dragon-editor-viewer ol,
|
|
37
|
+
.dragon-editor-viewer ul,
|
|
38
|
+
.dragon-editor-viewer fieldset,
|
|
39
|
+
.dragon-editor-viewer legend,
|
|
40
|
+
.dragon-editor-viewer figure,
|
|
41
|
+
.dragon-editor-viewer menu {
|
|
42
|
+
margin: 0;
|
|
43
|
+
padding: 0;
|
|
44
|
+
border: 0;
|
|
45
|
+
}
|
|
46
|
+
.dragon-editor table,
|
|
47
|
+
.dragon-editor th,
|
|
48
|
+
.dragon-editor td,
|
|
49
|
+
.dragon-editor-viewer table,
|
|
50
|
+
.dragon-editor-viewer th,
|
|
51
|
+
.dragon-editor-viewer td {
|
|
52
|
+
border-spacing: 0;
|
|
53
|
+
border-collapse: collapse;
|
|
54
|
+
}
|
|
55
|
+
.dragon-editor ol,
|
|
56
|
+
.dragon-editor ul,
|
|
57
|
+
.dragon-editor li,
|
|
58
|
+
.dragon-editor-viewer ol,
|
|
59
|
+
.dragon-editor-viewer ul,
|
|
60
|
+
.dragon-editor-viewer li {
|
|
61
|
+
list-style: none;
|
|
62
|
+
}
|
|
63
|
+
.dragon-editor h1,
|
|
64
|
+
.dragon-editor h2,
|
|
65
|
+
.dragon-editor h3,
|
|
66
|
+
.dragon-editor h4,
|
|
67
|
+
.dragon-editor h5,
|
|
68
|
+
.dragon-editor h6,
|
|
69
|
+
.dragon-editor-viewer h1,
|
|
70
|
+
.dragon-editor-viewer h2,
|
|
71
|
+
.dragon-editor-viewer h3,
|
|
72
|
+
.dragon-editor-viewer h4,
|
|
73
|
+
.dragon-editor-viewer h5,
|
|
74
|
+
.dragon-editor-viewer h6 {
|
|
75
|
+
font-size: 1em;
|
|
76
|
+
font-weight: normal;
|
|
77
|
+
}
|
|
78
|
+
.dragon-editor input,
|
|
79
|
+
.dragon-editor textarea,
|
|
80
|
+
.dragon-editor select,
|
|
81
|
+
.dragon-editor button,
|
|
82
|
+
.dragon-editor-viewer input,
|
|
83
|
+
.dragon-editor-viewer textarea,
|
|
84
|
+
.dragon-editor-viewer select,
|
|
85
|
+
.dragon-editor-viewer button {
|
|
86
|
+
margin: 0;
|
|
87
|
+
padding: 0;
|
|
88
|
+
border-radius: 0;
|
|
89
|
+
outline: 0;
|
|
90
|
+
vertical-align: middle;
|
|
91
|
+
}
|
|
92
|
+
.dragon-editor a,
|
|
93
|
+
.dragon-editor button,
|
|
94
|
+
.dragon-editor input[type=submit],
|
|
95
|
+
.dragon-editor input[type=button],
|
|
96
|
+
.dragon-editor input[type=reset],
|
|
97
|
+
.dragon-editor-viewer a,
|
|
98
|
+
.dragon-editor-viewer button,
|
|
99
|
+
.dragon-editor-viewer input[type=submit],
|
|
100
|
+
.dragon-editor-viewer input[type=button],
|
|
101
|
+
.dragon-editor-viewer input[type=reset] {
|
|
102
|
+
border: 0;
|
|
103
|
+
background: transparent;
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
}
|
|
106
|
+
.dragon-editor img,
|
|
107
|
+
.dragon-editor-viewer img {
|
|
108
|
+
border: 0;
|
|
109
|
+
vertical-align: top;
|
|
110
|
+
}
|
|
111
|
+
.dragon-editor .de-block[data-depth="1"],
|
|
112
|
+
.dragon-editor-viewer .de-block[data-depth="1"] {
|
|
113
|
+
padding-left: 30px;
|
|
114
|
+
}
|
|
115
|
+
.dragon-editor .de-block[data-depth="2"],
|
|
116
|
+
.dragon-editor-viewer .de-block[data-depth="2"] {
|
|
117
|
+
padding-left: 60px;
|
|
118
|
+
}
|
|
119
|
+
.dragon-editor .de-block[data-depth="3"],
|
|
120
|
+
.dragon-editor-viewer .de-block[data-depth="3"] {
|
|
121
|
+
padding-left: 90px;
|
|
122
|
+
}
|
|
123
|
+
.dragon-editor .de-block[data-depth="4"],
|
|
124
|
+
.dragon-editor-viewer .de-block[data-depth="4"] {
|
|
125
|
+
padding-left: 120px;
|
|
126
|
+
}
|
|
127
|
+
.dragon-editor .de-block[data-depth="5"],
|
|
128
|
+
.dragon-editor-viewer .de-block[data-depth="5"] {
|
|
129
|
+
padding-left: 150px;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 노드 스타일
|
|
134
|
+
*/
|
|
135
|
+
.dragon-editor {
|
|
136
|
+
position: relative;
|
|
137
|
+
border: 1px solid #ccc;
|
|
138
|
+
}
|
|
139
|
+
.dragon-editor.--hasMenu {
|
|
140
|
+
padding-top: 38px;
|
|
141
|
+
}
|
|
142
|
+
.dragon-editor .de-body {
|
|
143
|
+
display: grid;
|
|
144
|
+
gap: 4px;
|
|
145
|
+
padding: 20px;
|
|
146
|
+
}
|
|
147
|
+
.dragon-editor .de-control-bar {
|
|
148
|
+
position: absolute;
|
|
149
|
+
top: 0;
|
|
150
|
+
left: 0;
|
|
151
|
+
right: 0;
|
|
152
|
+
height: 38px;
|
|
153
|
+
border-bottom: 1px solid #ccc;
|
|
154
|
+
}
|
|
155
|
+
.dragon-editor .de-control-bar .de-menu {
|
|
156
|
+
min-width: 38px;
|
|
157
|
+
height: 38px;
|
|
158
|
+
padding: 0 8px;
|
|
159
|
+
border-right: 1px solid #ccc;
|
|
160
|
+
box-sizing: border-box;
|
|
161
|
+
}
|
|
162
|
+
.dragon-editor .de-control-bar .de-menu.--lastchild {
|
|
163
|
+
border-right: 0;
|
|
164
|
+
}
|
|
165
|
+
.dragon-editor .de-control-bar .de-block-menu-area {
|
|
166
|
+
display: none;
|
|
167
|
+
position: absolute;
|
|
168
|
+
top: 39px;
|
|
169
|
+
left: 0;
|
|
170
|
+
width: 120px;
|
|
171
|
+
background: #fff;
|
|
172
|
+
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.25);
|
|
173
|
+
z-index: 1000;
|
|
174
|
+
}
|
|
175
|
+
.dragon-editor .de-control-bar .de-block-menu-area.--active {
|
|
176
|
+
display: block;
|
|
177
|
+
}
|
|
178
|
+
.dragon-editor .de-control-bar .de-block-menu-area .de-list {
|
|
179
|
+
display: flex;
|
|
180
|
+
flex-direction: column;
|
|
181
|
+
gap: 5px;
|
|
182
|
+
padding: 5px;
|
|
183
|
+
}
|
|
184
|
+
.dragon-editor .de-control-bar .de-block-menu-area .de-add-block {
|
|
185
|
+
line-height: 1.6;
|
|
186
|
+
}
|
|
187
|
+
.dragon-editor .de-text-block {
|
|
188
|
+
min-height: 1.6em;
|
|
189
|
+
outline: 0;
|
|
190
|
+
}
|
|
191
|
+
.dragon-editor .de-text-block:empty:hover::before, .dragon-editor .de-text-block:empty:focus::before {
|
|
192
|
+
display: inline;
|
|
193
|
+
content: "Type a paragraph";
|
|
194
|
+
color: #ccc;
|
|
195
|
+
cursor: text;
|
|
196
|
+
}
|
|
197
|
+
.dragon-editor .de-heading-block {
|
|
198
|
+
outline: 0;
|
|
199
|
+
}
|
|
200
|
+
.dragon-editor .de-heading-block[data-level="1"] {
|
|
201
|
+
font-size: 2em;
|
|
202
|
+
min-height: 2em;
|
|
203
|
+
}
|
|
204
|
+
.dragon-editor .de-heading-block[data-level="2"] {
|
|
205
|
+
font-size: 1.5em;
|
|
206
|
+
min-height: 1.5em;
|
|
207
|
+
}
|
|
208
|
+
.dragon-editor .de-heading-block[data-level="3"] {
|
|
209
|
+
font-size: 1.17em;
|
|
210
|
+
min-height: 1.17em;
|
|
211
|
+
}
|
|
212
|
+
.dragon-editor .de-heading-block:empty:hover::before, .dragon-editor .de-heading-block:empty:focus::before {
|
|
213
|
+
display: inline;
|
|
214
|
+
content: "Type a Heading";
|
|
215
|
+
color: #ccc;
|
|
216
|
+
cursor: text;
|
|
217
|
+
}
|
|
218
|
+
.dragon-editor .de-list-block {
|
|
219
|
+
display: flex;
|
|
220
|
+
flex-direction: column;
|
|
221
|
+
row-gap: 4px;
|
|
222
|
+
padding-left: 24px;
|
|
223
|
+
list-style: disc;
|
|
224
|
+
}
|
|
225
|
+
.dragon-editor .de-list-block .de-item {
|
|
226
|
+
min-height: 1.6em;
|
|
227
|
+
outline: 0;
|
|
228
|
+
list-style: inherit;
|
|
229
|
+
}
|
|
230
|
+
.dragon-editor .de-list-block .de-item:empty:hover::before, .dragon-editor .de-list-block .de-item:empty:focus::before {
|
|
231
|
+
display: inline;
|
|
232
|
+
content: "Type a list item";
|
|
233
|
+
color: #ccc;
|
|
234
|
+
cursor: text;
|
|
235
|
+
}
|
|
236
|
+
.dragon-editor ol.de-list-block {
|
|
237
|
+
list-style: decimal;
|
|
238
|
+
}
|
|
239
|
+
.dragon-editor .de-bold {
|
|
240
|
+
font-weight: 700;
|
|
241
|
+
}
|
|
242
|
+
.dragon-editor .de-italic {
|
|
243
|
+
font-style: italic;
|
|
244
|
+
}
|
|
245
|
+
.dragon-editor .de-underline {
|
|
246
|
+
text-decoration: underline;
|
|
247
|
+
}
|
|
248
|
+
.dragon-editor .de-underline.de-strikethrough {
|
|
249
|
+
text-decoration: underline line-through;
|
|
250
|
+
}
|
|
251
|
+
.dragon-editor .de-strikethrough {
|
|
252
|
+
text-decoration: line-through;
|
|
253
|
+
}
|
|
254
|
+
.dragon-editor .de-strikethrough.de-underline {
|
|
255
|
+
text-decoration: line-through underline;
|
|
256
|
+
}
|
|
257
|
+
.dragon-editor .de-code {
|
|
258
|
+
padding: 2px 4px;
|
|
259
|
+
background: #f1f1f1;
|
|
260
|
+
color: #ff0000;
|
|
261
|
+
border-radius: 5px;
|
|
262
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
.dragon-editor,
|
|
2
|
+
.dragon-editor-viewer {
|
|
3
|
+
/**
|
|
4
|
+
* Reset style start
|
|
5
|
+
*/
|
|
6
|
+
}
|
|
7
|
+
.dragon-editor h1,
|
|
8
|
+
.dragon-editor h2,
|
|
9
|
+
.dragon-editor h3,
|
|
10
|
+
.dragon-editor h4,
|
|
11
|
+
.dragon-editor h5,
|
|
12
|
+
.dragon-editor h6,
|
|
13
|
+
.dragon-editor p,
|
|
14
|
+
.dragon-editor blockquote,
|
|
15
|
+
.dragon-editor pre,
|
|
16
|
+
.dragon-editor dl,
|
|
17
|
+
.dragon-editor dd,
|
|
18
|
+
.dragon-editor ol,
|
|
19
|
+
.dragon-editor ul,
|
|
20
|
+
.dragon-editor fieldset,
|
|
21
|
+
.dragon-editor legend,
|
|
22
|
+
.dragon-editor figure,
|
|
23
|
+
.dragon-editor menu,
|
|
24
|
+
.dragon-editor-viewer h1,
|
|
25
|
+
.dragon-editor-viewer h2,
|
|
26
|
+
.dragon-editor-viewer h3,
|
|
27
|
+
.dragon-editor-viewer h4,
|
|
28
|
+
.dragon-editor-viewer h5,
|
|
29
|
+
.dragon-editor-viewer h6,
|
|
30
|
+
.dragon-editor-viewer p,
|
|
31
|
+
.dragon-editor-viewer blockquote,
|
|
32
|
+
.dragon-editor-viewer pre,
|
|
33
|
+
.dragon-editor-viewer dl,
|
|
34
|
+
.dragon-editor-viewer dd,
|
|
35
|
+
.dragon-editor-viewer ol,
|
|
36
|
+
.dragon-editor-viewer ul,
|
|
37
|
+
.dragon-editor-viewer fieldset,
|
|
38
|
+
.dragon-editor-viewer legend,
|
|
39
|
+
.dragon-editor-viewer figure,
|
|
40
|
+
.dragon-editor-viewer menu {
|
|
41
|
+
margin: 0;
|
|
42
|
+
padding: 0;
|
|
43
|
+
border: 0;
|
|
44
|
+
}
|
|
45
|
+
.dragon-editor table,
|
|
46
|
+
.dragon-editor th,
|
|
47
|
+
.dragon-editor td,
|
|
48
|
+
.dragon-editor-viewer table,
|
|
49
|
+
.dragon-editor-viewer th,
|
|
50
|
+
.dragon-editor-viewer td {
|
|
51
|
+
border-spacing: 0;
|
|
52
|
+
border-collapse: collapse;
|
|
53
|
+
}
|
|
54
|
+
.dragon-editor ol,
|
|
55
|
+
.dragon-editor ul,
|
|
56
|
+
.dragon-editor li,
|
|
57
|
+
.dragon-editor-viewer ol,
|
|
58
|
+
.dragon-editor-viewer ul,
|
|
59
|
+
.dragon-editor-viewer li {
|
|
60
|
+
list-style: none;
|
|
61
|
+
}
|
|
62
|
+
.dragon-editor h1,
|
|
63
|
+
.dragon-editor h2,
|
|
64
|
+
.dragon-editor h3,
|
|
65
|
+
.dragon-editor h4,
|
|
66
|
+
.dragon-editor h5,
|
|
67
|
+
.dragon-editor h6,
|
|
68
|
+
.dragon-editor-viewer h1,
|
|
69
|
+
.dragon-editor-viewer h2,
|
|
70
|
+
.dragon-editor-viewer h3,
|
|
71
|
+
.dragon-editor-viewer h4,
|
|
72
|
+
.dragon-editor-viewer h5,
|
|
73
|
+
.dragon-editor-viewer h6 {
|
|
74
|
+
font-size: 1em;
|
|
75
|
+
font-weight: normal;
|
|
76
|
+
}
|
|
77
|
+
.dragon-editor input,
|
|
78
|
+
.dragon-editor textarea,
|
|
79
|
+
.dragon-editor select,
|
|
80
|
+
.dragon-editor button,
|
|
81
|
+
.dragon-editor-viewer input,
|
|
82
|
+
.dragon-editor-viewer textarea,
|
|
83
|
+
.dragon-editor-viewer select,
|
|
84
|
+
.dragon-editor-viewer button {
|
|
85
|
+
margin: 0;
|
|
86
|
+
padding: 0;
|
|
87
|
+
border-radius: 0;
|
|
88
|
+
outline: 0;
|
|
89
|
+
vertical-align: middle;
|
|
90
|
+
}
|
|
91
|
+
.dragon-editor a,
|
|
92
|
+
.dragon-editor button,
|
|
93
|
+
.dragon-editor input[type=submit],
|
|
94
|
+
.dragon-editor input[type=button],
|
|
95
|
+
.dragon-editor input[type=reset],
|
|
96
|
+
.dragon-editor-viewer a,
|
|
97
|
+
.dragon-editor-viewer button,
|
|
98
|
+
.dragon-editor-viewer input[type=submit],
|
|
99
|
+
.dragon-editor-viewer input[type=button],
|
|
100
|
+
.dragon-editor-viewer input[type=reset] {
|
|
101
|
+
border: 0;
|
|
102
|
+
background: transparent;
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
}
|
|
105
|
+
.dragon-editor img,
|
|
106
|
+
.dragon-editor-viewer img {
|
|
107
|
+
border: 0;
|
|
108
|
+
vertical-align: top;
|
|
109
|
+
}
|
|
110
|
+
.dragon-editor .de-block[data-depth="1"],
|
|
111
|
+
.dragon-editor-viewer .de-block[data-depth="1"] {
|
|
112
|
+
padding-left: 30px;
|
|
113
|
+
}
|
|
114
|
+
.dragon-editor .de-block[data-depth="2"],
|
|
115
|
+
.dragon-editor-viewer .de-block[data-depth="2"] {
|
|
116
|
+
padding-left: 60px;
|
|
117
|
+
}
|
|
118
|
+
.dragon-editor .de-block[data-depth="3"],
|
|
119
|
+
.dragon-editor-viewer .de-block[data-depth="3"] {
|
|
120
|
+
padding-left: 90px;
|
|
121
|
+
}
|
|
122
|
+
.dragon-editor .de-block[data-depth="4"],
|
|
123
|
+
.dragon-editor-viewer .de-block[data-depth="4"] {
|
|
124
|
+
padding-left: 120px;
|
|
125
|
+
}
|
|
126
|
+
.dragon-editor .de-block[data-depth="5"],
|
|
127
|
+
.dragon-editor-viewer .de-block[data-depth="5"] {
|
|
128
|
+
padding-left: 150px;
|
|
129
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "./type.d.ts";
|
|
2
|
+
export declare const useEditorStore: import("pinia").StoreDefinition<"editorStore", EditorStore, {}, {
|
|
3
|
+
setWrapElement(value: HTMLDivElement): void;
|
|
4
|
+
setContentElement(value: HTMLDivElement): void;
|
|
5
|
+
setParentWrapElement(value: HTMLElement | Window): void;
|
|
6
|
+
setCursorData(data: DEditorCursor): void;
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
import "./type.d.ts";
|
|
3
|
+
export const useEditorStore = defineStore("editorStore", {
|
|
4
|
+
state: () => ({
|
|
5
|
+
cursorData: null,
|
|
6
|
+
message: {
|
|
7
|
+
linkTextNoStyle: "Link text can't set any style."
|
|
8
|
+
},
|
|
9
|
+
$editor: null,
|
|
10
|
+
$content: null,
|
|
11
|
+
$parentWrap: null
|
|
12
|
+
}),
|
|
13
|
+
actions: {
|
|
14
|
+
setWrapElement(value) {
|
|
15
|
+
this.$editor = value;
|
|
16
|
+
},
|
|
17
|
+
setContentElement(value) {
|
|
18
|
+
this.$content = value;
|
|
19
|
+
},
|
|
20
|
+
setParentWrapElement(value) {
|
|
21
|
+
this.$parentWrap = value;
|
|
22
|
+
},
|
|
23
|
+
setCursorData(data) {
|
|
24
|
+
this.cursorData = data;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
interface EditorStore {
|
|
2
|
+
cursorData: DEditorCursor | null;
|
|
3
|
+
message: { [key: string]: string };
|
|
4
|
+
$editor: HTMLDivElement | null;
|
|
5
|
+
$content: HTMLDivElement | null;
|
|
6
|
+
$parentWrap: HTMLElement | Window | null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface DEditorCursor {
|
|
10
|
+
type: "Range" | "Caret" | "None";
|
|
11
|
+
startNode: Node;
|
|
12
|
+
startOffset: number;
|
|
13
|
+
endNode: Node;
|
|
14
|
+
endOffset: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface DEArrangeCursorData {
|
|
18
|
+
startNode: Node;
|
|
19
|
+
startNodeIdx: number;
|
|
20
|
+
startOffset: number;
|
|
21
|
+
endNode: Node;
|
|
22
|
+
endNodeIdx: number;
|
|
23
|
+
endOffset: number;
|
|
24
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function _getBlockType(element: HTMLElement): {
|
|
2
|
+
$element: Element;
|
|
3
|
+
type: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function _createTextBlock(content?: string, isEdit?: boolean): HTMLParagraphElement;
|
|
6
|
+
export declare function _createHeadingBlock(type: string, content?: string, isEdit?: boolean): HTMLElement;
|
|
7
|
+
export declare function _createListBlock(type: string, content?: string[], isEdit?: boolean): HTMLElement;
|
|
8
|
+
export declare function _createListItemBlock(content?: string, isEdit?: boolean): HTMLLIElement;
|
|
9
|
+
export declare function generateId(): string;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export function _getBlockType(element) {
|
|
2
|
+
const $block = element.closest(".de-block");
|
|
3
|
+
let typeName;
|
|
4
|
+
switch (true) {
|
|
5
|
+
case $block.classList.contains("de-text-block"):
|
|
6
|
+
typeName = "text";
|
|
7
|
+
break;
|
|
8
|
+
case $block.classList.contains("de-heading-block"):
|
|
9
|
+
typeName = "heading";
|
|
10
|
+
break;
|
|
11
|
+
case $block.classList.contains("de-list-block"):
|
|
12
|
+
typeName = "list";
|
|
13
|
+
break;
|
|
14
|
+
default:
|
|
15
|
+
typeName = "other";
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
$element: $block,
|
|
19
|
+
type: typeName
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function _createTextBlock(content = "", isEdit = true) {
|
|
23
|
+
const $paragraph = document.createElement("p");
|
|
24
|
+
$paragraph.classList.add("de-block", "de-text-block");
|
|
25
|
+
if (isEdit === true) {
|
|
26
|
+
$paragraph.setAttribute("contenteditable", "true");
|
|
27
|
+
}
|
|
28
|
+
if (content !== "") {
|
|
29
|
+
$paragraph.innerHTML = content;
|
|
30
|
+
}
|
|
31
|
+
return $paragraph;
|
|
32
|
+
}
|
|
33
|
+
export function _createHeadingBlock(type, content = "", isEdit = true) {
|
|
34
|
+
const level = parseInt(type.replace("heading", ""));
|
|
35
|
+
const $headingBlock = document.createElement(`h${level}`);
|
|
36
|
+
$headingBlock.classList.add("de-block", "de-heading-block");
|
|
37
|
+
$headingBlock.id = generateId();
|
|
38
|
+
$headingBlock.dataset["level"] = String(level);
|
|
39
|
+
if (isEdit === true) {
|
|
40
|
+
$headingBlock.setAttribute("contenteditable", "true");
|
|
41
|
+
}
|
|
42
|
+
if (content !== "") {
|
|
43
|
+
$headingBlock.innerHTML = content;
|
|
44
|
+
}
|
|
45
|
+
return $headingBlock;
|
|
46
|
+
}
|
|
47
|
+
export function _createListBlock(type, content = [""], isEdit = true) {
|
|
48
|
+
const $block = document.createElement(type);
|
|
49
|
+
$block.classList.add("de-block", "de-list-block");
|
|
50
|
+
content.forEach((text) => {
|
|
51
|
+
$block.appendChild(_createListItemBlock(text, isEdit));
|
|
52
|
+
});
|
|
53
|
+
return $block;
|
|
54
|
+
}
|
|
55
|
+
export function _createListItemBlock(content = "", isEdit = true) {
|
|
56
|
+
const $li = document.createElement("li");
|
|
57
|
+
$li.classList.add("de-item");
|
|
58
|
+
if (isEdit === true) {
|
|
59
|
+
$li.setAttribute("contenteditable", "true");
|
|
60
|
+
}
|
|
61
|
+
return $li;
|
|
62
|
+
}
|
|
63
|
+
export function generateId() {
|
|
64
|
+
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
65
|
+
let str = "";
|
|
66
|
+
for (let i = 0; i < 6; i++) {
|
|
67
|
+
str += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
68
|
+
}
|
|
69
|
+
return str;
|
|
70
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "../type.d.ts";
|
|
2
|
+
export declare function _setCursorData(store: any): void;
|
|
3
|
+
export declare function _setCursor($target: Node, startIdx: number): void;
|
|
4
|
+
export declare function _setRangeCursor($startTarget: Element, $endTarget: Element, startIdx: number, endIdx: number): void;
|
|
5
|
+
export declare function _clenupCursor(store: any): void;
|
|
6
|
+
export declare function _soltingCursorDataOnElement(cursorData: DEditorCursor, $element: HTMLElement): DEArrangeCursorData;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import "../type.d.ts";
|
|
2
|
+
export function _setCursorData(store) {
|
|
3
|
+
const selection = window.getSelection();
|
|
4
|
+
if (selection.type !== "None") {
|
|
5
|
+
store.setCursorData({
|
|
6
|
+
type: selection.type,
|
|
7
|
+
startNode: selection.anchorNode,
|
|
8
|
+
startOffset: selection.anchorOffset,
|
|
9
|
+
endNode: selection.focusNode,
|
|
10
|
+
endOffset: selection.focusOffset
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function _setCursor($target, startIdx) {
|
|
15
|
+
const range = document.createRange();
|
|
16
|
+
const selection = window.getSelection();
|
|
17
|
+
if ($target.constructor.name === "Text") {
|
|
18
|
+
range.setStart($target, startIdx);
|
|
19
|
+
} else {
|
|
20
|
+
if ($target.hasChildNodes() === true) {
|
|
21
|
+
if ($target.textContent === "") {
|
|
22
|
+
range.setStart($target.childNodes[startIdx], 0);
|
|
23
|
+
} else {
|
|
24
|
+
range.setStart($target.childNodes[0], startIdx);
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
range.setStart($target, startIdx);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
selection.removeAllRanges();
|
|
31
|
+
selection.addRange(range);
|
|
32
|
+
}
|
|
33
|
+
export function _setRangeCursor($startTarget, $endTarget, startIdx, endIdx) {
|
|
34
|
+
const range = document.createRange();
|
|
35
|
+
const selection = window.getSelection();
|
|
36
|
+
if ($startTarget.constructor.name === "Text") {
|
|
37
|
+
range.setStart($startTarget, startIdx);
|
|
38
|
+
} else {
|
|
39
|
+
if ($startTarget.hasChildNodes() === true) {
|
|
40
|
+
if ($startTarget.textContent === "") {
|
|
41
|
+
range.setStart($startTarget.childNodes[startIdx], 0);
|
|
42
|
+
} else {
|
|
43
|
+
range.setStart($startTarget.childNodes[0], startIdx);
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
range.setStart($startTarget, startIdx);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if ($endTarget.constructor.name === "Text") {
|
|
50
|
+
range.setEnd($endTarget, endIdx);
|
|
51
|
+
} else {
|
|
52
|
+
if ($endTarget.hasChildNodes() === true) {
|
|
53
|
+
if ($endTarget.textContent === "") {
|
|
54
|
+
range.setEnd($endTarget.childNodes[endIdx], 0);
|
|
55
|
+
} else {
|
|
56
|
+
range.setEnd($endTarget.childNodes[0], endIdx);
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
range.setEnd($endTarget, endIdx);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
selection.removeAllRanges();
|
|
63
|
+
selection.addRange(range);
|
|
64
|
+
}
|
|
65
|
+
export function _clenupCursor(store) {
|
|
66
|
+
_setCursorData(store);
|
|
67
|
+
if (store.cursorData.startNode !== store.cursorData.endNode || store.cursorData.startOffset !== store.cursorData.endOffset) {
|
|
68
|
+
} else {
|
|
69
|
+
if (store.cursorData.startNode.hasChildNodes() === true) {
|
|
70
|
+
_setCursor(store.cursorData.startNode.childNodes[store.cursorData.startOffset], 0);
|
|
71
|
+
} else {
|
|
72
|
+
_setCursor(store.cursorData.startNode, store.cursorData.startOffset);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export function _soltingCursorDataOnElement(cursorData, $element) {
|
|
77
|
+
const childList = $element.childNodes;
|
|
78
|
+
let startNode = cursorData.startNode;
|
|
79
|
+
let startIdx = -1;
|
|
80
|
+
let startOffset = cursorData.startOffset;
|
|
81
|
+
let endNode = cursorData.endNode;
|
|
82
|
+
let endIdx = -1;
|
|
83
|
+
let endOffset = cursorData.endOffset;
|
|
84
|
+
if (startNode.constructor.name === "Text") {
|
|
85
|
+
if (startNode.parentElement !== $element) {
|
|
86
|
+
startNode = startNode.parentElement;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (endNode.constructor.name === "Text") {
|
|
90
|
+
if (endNode.parentElement !== $element) {
|
|
91
|
+
endNode = endNode.parentElement;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
for (let i = 0; childList.length > i; i += 1) {
|
|
95
|
+
if (startIdx !== -1 && endIdx !== -1) {
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
if (startNode === childList[i]) {
|
|
99
|
+
startIdx = i;
|
|
100
|
+
}
|
|
101
|
+
if (endNode === childList[i]) {
|
|
102
|
+
endIdx = i;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (startIdx === endIdx) {
|
|
106
|
+
if (cursorData.startOffset > cursorData.endOffset) {
|
|
107
|
+
startOffset = cursorData.endOffset;
|
|
108
|
+
endOffset = cursorData.startOffset;
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
if (startIdx > endIdx) {
|
|
112
|
+
const originStartNode = startNode;
|
|
113
|
+
const originStartIdx = startIdx;
|
|
114
|
+
const originEndNode = endNode;
|
|
115
|
+
const originEndIdx = endIdx;
|
|
116
|
+
startNode = originEndNode;
|
|
117
|
+
startIdx = originEndIdx;
|
|
118
|
+
startOffset = cursorData.endOffset;
|
|
119
|
+
endNode = originStartNode;
|
|
120
|
+
endIdx = originStartIdx;
|
|
121
|
+
endOffset = cursorData.startOffset;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
startNode,
|
|
126
|
+
startNodeIdx: startIdx,
|
|
127
|
+
startOffset,
|
|
128
|
+
endNode,
|
|
129
|
+
endNodeIdx: endIdx,
|
|
130
|
+
endOffset
|
|
131
|
+
};
|
|
132
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
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;
|