dragon-editor 3.8.1 → 3.8.3
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 +13 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -2
- package/dist/runtime/components/DragonEditor.d.vue.ts +2 -1
- package/dist/runtime/components/DragonEditor.vue +16 -2
- package/dist/runtime/components/DragonEditor.vue.d.ts +2 -1
- package/dist/runtime/scss/editor.css +3 -0
- package/dist/runtime/type.d.mts +3 -1
- package/dist/runtime/utils/event/keyboard.js +168 -147
- package/dist/runtime/utils/event/mouse.js +16 -2
- package/dist/runtime/utils/event/window.js +9 -1
- package/dist/runtime/utils/node/element.d.ts +1 -0
- package/dist/runtime/utils/node/element.js +24 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
[license-src]: https://img.shields.io/npm/l/dragon-editor
|
|
14
14
|
[nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
|
|
15
15
|
[nuxt-href]: https://nuxt.com
|
|
16
|
+
[sponsors-src]: https://img.shields.io/github/sponsors/lovefields
|
|
17
|
+
[sponsors-href]: https://github.com/sponsors/lovefields
|
|
16
18
|
|
|
17
19
|
[![stars-src]][stars-href]
|
|
18
20
|
[![forks-src]][forks-href]
|
|
@@ -21,6 +23,7 @@
|
|
|
21
23
|
[![npm-version-src]][npm-version-href]
|
|
22
24
|
[![npm-downloads-src]][npm-downloads-href]
|
|
23
25
|
![NPM][license-src]
|
|
26
|
+
[![sponsors-src]][sponsors-href]
|
|
24
27
|
[![Nuxt][nuxt-src]][nuxt-href]
|
|
25
28
|
|
|
26
29
|
# DragonEditor
|
|
@@ -84,3 +87,13 @@ Done!
|
|
|
84
87
|
```
|
|
85
88
|
|
|
86
89
|
More information is [here](https://lovefields.github.io/dragonEditor-doc/)
|
|
90
|
+
|
|
91
|
+
# Sponsors
|
|
92
|
+
|
|
93
|
+
Support this project by becoming a sponsor. [GitHub Sponsors](https://github.com/sponsors/lovefields)
|
|
94
|
+
|
|
95
|
+
<div align="center">
|
|
96
|
+
<a href="https://github.com/kyu91">
|
|
97
|
+
<img src="https://github.com/kyu91.png" width="50" title="kyu91" />
|
|
98
|
+
</a>
|
|
99
|
+
</div>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, addComponent, addTypeTemplate } from '@nuxt/kit';
|
|
2
2
|
|
|
3
|
-
const module = defineNuxtModule({
|
|
3
|
+
const module$1 = defineNuxtModule({
|
|
4
4
|
meta: {
|
|
5
5
|
name: "dragon-editor",
|
|
6
6
|
compatibility: {
|
|
@@ -40,4 +40,4 @@ async function readFile(path) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export { module as default };
|
|
43
|
+
export { module$1 as default };
|
|
@@ -10,13 +10,14 @@ declare function setDecoration(style: DEDecoration): void;
|
|
|
10
10
|
declare function setAlign(align: DETextalign): void;
|
|
11
11
|
declare function changeEditorData(data: DEContentData): void;
|
|
12
12
|
declare function updateLayout(): void;
|
|
13
|
+
declare function checkDataEmpty(data?: DEContentData): boolean;
|
|
13
14
|
declare const __VLS_export: import("vue").DefineComponent<DEOption, {
|
|
14
15
|
addBlock: typeof addBlock;
|
|
15
16
|
setDecoration: typeof setDecoration;
|
|
16
17
|
setAlign: typeof setAlign;
|
|
17
18
|
changeEditorData: typeof changeEditorData;
|
|
18
19
|
updateLayout: typeof updateLayout;
|
|
19
|
-
checkDataEmpty:
|
|
20
|
+
checkDataEmpty: typeof checkDataEmpty;
|
|
20
21
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
21
22
|
"update:modelValue": (data: DEContentData) => any;
|
|
22
23
|
uploadImageEvent: (file: File) => any;
|
|
@@ -45,6 +45,7 @@ const editorStore = ref({
|
|
|
45
45
|
},
|
|
46
46
|
controlStatus: {
|
|
47
47
|
isMobile: false,
|
|
48
|
+
hasTransformParent: false,
|
|
48
49
|
currentBlockType: "text",
|
|
49
50
|
codeBlockTheme: "github-light",
|
|
50
51
|
codeBlockLang: "text",
|
|
@@ -55,7 +56,8 @@ const editorStore = ref({
|
|
|
55
56
|
anchorValidation: false,
|
|
56
57
|
previousCorsorData: null,
|
|
57
58
|
$anchorInput: null,
|
|
58
|
-
$currentBlock: null
|
|
59
|
+
$currentBlock: null,
|
|
60
|
+
$transformElement: null
|
|
59
61
|
},
|
|
60
62
|
codeBlockTheme: [
|
|
61
63
|
{
|
|
@@ -181,6 +183,15 @@ function updateLayout() {
|
|
|
181
183
|
_eidtorMountEvent(editorStore);
|
|
182
184
|
}, 500);
|
|
183
185
|
}
|
|
186
|
+
function checkDataEmpty(data) {
|
|
187
|
+
let suitable = false;
|
|
188
|
+
if (data !== void 0) {
|
|
189
|
+
suitable = _checkDataEmpty(data);
|
|
190
|
+
} else {
|
|
191
|
+
suitable = _checkDataEmpty(props.modelValue);
|
|
192
|
+
}
|
|
193
|
+
return suitable;
|
|
194
|
+
}
|
|
184
195
|
onMounted(() => {
|
|
185
196
|
_eidtorMountEvent(editorStore);
|
|
186
197
|
});
|
|
@@ -193,7 +204,7 @@ defineExpose({
|
|
|
193
204
|
setAlign,
|
|
194
205
|
changeEditorData,
|
|
195
206
|
updateLayout,
|
|
196
|
-
checkDataEmpty
|
|
207
|
+
checkDataEmpty
|
|
197
208
|
});
|
|
198
209
|
</script>
|
|
199
210
|
|
|
@@ -539,6 +550,9 @@ defineExpose({
|
|
|
539
550
|
height: 100%;
|
|
540
551
|
border: 0;
|
|
541
552
|
}
|
|
553
|
+
.dragon-editor .de-controlbar .de-col .de-name {
|
|
554
|
+
width: 70px;
|
|
555
|
+
}
|
|
542
556
|
.dragon-editor .de-block {
|
|
543
557
|
width: 100%;
|
|
544
558
|
padding: 2px 0;
|
|
@@ -10,13 +10,14 @@ declare function setDecoration(style: DEDecoration): void;
|
|
|
10
10
|
declare function setAlign(align: DETextalign): void;
|
|
11
11
|
declare function changeEditorData(data: DEContentData): void;
|
|
12
12
|
declare function updateLayout(): void;
|
|
13
|
+
declare function checkDataEmpty(data?: DEContentData): boolean;
|
|
13
14
|
declare const __VLS_export: import("vue").DefineComponent<DEOption, {
|
|
14
15
|
addBlock: typeof addBlock;
|
|
15
16
|
setDecoration: typeof setDecoration;
|
|
16
17
|
setAlign: typeof setAlign;
|
|
17
18
|
changeEditorData: typeof changeEditorData;
|
|
18
19
|
updateLayout: typeof updateLayout;
|
|
19
|
-
checkDataEmpty:
|
|
20
|
+
checkDataEmpty: typeof checkDataEmpty;
|
|
20
21
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
21
22
|
"update:modelValue": (data: DEContentData) => any;
|
|
22
23
|
uploadImageEvent: (file: File) => any;
|
package/dist/runtime/type.d.mts
CHANGED
|
@@ -51,6 +51,7 @@ interface DragonEditorStore {
|
|
|
51
51
|
};
|
|
52
52
|
controlStatus: {
|
|
53
53
|
isMobile: boolean;
|
|
54
|
+
hasTransformParent: boolean;
|
|
54
55
|
anchorValidation: boolean;
|
|
55
56
|
currentBlockType: DEBlock;
|
|
56
57
|
codeBlockTheme: DECodeblockTheme;
|
|
@@ -62,6 +63,7 @@ interface DragonEditorStore {
|
|
|
62
63
|
previousCorsorData: DEditorCursor | null;
|
|
63
64
|
$anchorInput: HTMLInputElement | null;
|
|
64
65
|
$currentBlock: HTMLDivElement | null;
|
|
66
|
+
$transformElement: HTMLElement | null;
|
|
65
67
|
};
|
|
66
68
|
codeToHtml: codeToHtml;
|
|
67
69
|
codeBlockTheme: DECodeItem<DECodeblockTheme>[];
|
|
@@ -115,7 +117,7 @@ interface DragonEditor {
|
|
|
115
117
|
setTextAlign: (type: DETextalign) => void;
|
|
116
118
|
changeEditorData: (data: DEContentData) => void;
|
|
117
119
|
updateLayout: () => void;
|
|
118
|
-
checkDataEmpty: () => boolean;
|
|
120
|
+
checkDataEmpty: (data?: DEContentData) => boolean;
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
interface DETextBlock {
|
|
@@ -72,180 +72,201 @@ function __pasteToMarkDownFormat(value, store) {
|
|
|
72
72
|
const codeBlockReg = new RegExp("^```");
|
|
73
73
|
let tempData = null;
|
|
74
74
|
let isCodeBlock = false;
|
|
75
|
-
lineList.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
75
|
+
if (lineList.length === 1) {
|
|
76
|
+
const selection = window.getSelection();
|
|
77
|
+
const textNode = document.createTextNode(lineList[0]);
|
|
78
|
+
selection.deleteFromDocument();
|
|
79
|
+
selection.getRangeAt(0).insertNode(textNode);
|
|
80
|
+
_setCursor(textNode, textNode.length);
|
|
81
|
+
} else {
|
|
82
|
+
let isDelete = false;
|
|
83
|
+
let $target = null;
|
|
84
|
+
lineList.forEach((text, lineIndex) => {
|
|
85
|
+
switch (true) {
|
|
86
|
+
case new RegExp("^(---|___|\\*\\*\\*)").test(text):
|
|
87
|
+
blockList.push({
|
|
88
|
+
type: "divider"
|
|
89
|
+
});
|
|
90
|
+
break;
|
|
91
|
+
case (codeBlockReg.test(text) || isCodeBlock === true):
|
|
92
|
+
if (isCodeBlock === false) {
|
|
93
|
+
const startLineText = text.split("```");
|
|
94
|
+
let codeBlockLang = "text";
|
|
95
|
+
if (["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"].includes(startLineText[1]) === true) {
|
|
96
|
+
codeBlockLang = startLineText[1];
|
|
97
|
+
}
|
|
98
|
+
isCodeBlock = true;
|
|
99
|
+
tempData = {
|
|
100
|
+
type: "code",
|
|
101
|
+
filename: "",
|
|
102
|
+
theme: "github-light",
|
|
103
|
+
language: codeBlockLang,
|
|
104
|
+
textContent: ""
|
|
105
|
+
};
|
|
106
|
+
} else {
|
|
107
|
+
if (tempData !== null) {
|
|
108
|
+
if (codeBlockReg.test(text) !== true) {
|
|
109
|
+
if (tempData.type === "code") {
|
|
110
|
+
tempData.textContent += `${text}
|
|
102
111
|
`;
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
blockList.push(tempData);
|
|
115
|
+
isCodeBlock = false;
|
|
116
|
+
tempData = null;
|
|
103
117
|
}
|
|
104
|
-
} else {
|
|
105
|
-
blockList.push(tempData);
|
|
106
|
-
isCodeBlock = false;
|
|
107
|
-
tempData = null;
|
|
108
118
|
}
|
|
109
119
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
};
|
|
123
|
-
tempData.child.push({
|
|
124
|
-
classList: [],
|
|
125
|
-
textContent: ___replaceTextData(olSplitText[1].trim())
|
|
126
|
-
});
|
|
127
|
-
} else {
|
|
128
|
-
if (tempData.type === "list") {
|
|
129
|
-
const nextLine = lineList[lineIndex + 1];
|
|
120
|
+
break;
|
|
121
|
+
case orderListReg.test(text):
|
|
122
|
+
const olSplitText = text.split(new RegExp("\\d+.(?= )"));
|
|
123
|
+
const olDepth = Math.floor(olSplitText[0].length / 4);
|
|
124
|
+
if (tempData === null) {
|
|
125
|
+
tempData = {
|
|
126
|
+
type: "list",
|
|
127
|
+
style: ["decimal", "lower-alpha", "upper-alpha", "lower-roman", "upper-roman"][olDepth],
|
|
128
|
+
depth: olDepth,
|
|
129
|
+
element: "ol",
|
|
130
|
+
child: []
|
|
131
|
+
};
|
|
130
132
|
tempData.child.push({
|
|
131
133
|
classList: [],
|
|
132
134
|
textContent: ___replaceTextData(olSplitText[1].trim())
|
|
133
135
|
});
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
136
|
+
} else {
|
|
137
|
+
if (tempData.type === "list") {
|
|
138
|
+
const nextLine = lineList[lineIndex + 1];
|
|
139
|
+
tempData.child.push({
|
|
140
|
+
classList: [],
|
|
141
|
+
textContent: ___replaceTextData(olSplitText[1].trim())
|
|
142
|
+
});
|
|
143
|
+
if (nextLine !== void 0) {
|
|
144
|
+
const nextOlSplitText = nextLine.split(new RegExp("\\d+.(?= )"));
|
|
145
|
+
const nextOlDepth = Math.floor(nextOlSplitText[0].length / 4);
|
|
146
|
+
if (orderListReg.test(nextLine) === false) {
|
|
142
147
|
blockList.push(tempData);
|
|
143
148
|
tempData = null;
|
|
149
|
+
} else {
|
|
150
|
+
if (tempData.depth !== nextOlDepth) {
|
|
151
|
+
blockList.push(tempData);
|
|
152
|
+
tempData = null;
|
|
153
|
+
}
|
|
144
154
|
}
|
|
155
|
+
} else {
|
|
156
|
+
blockList.push(tempData);
|
|
157
|
+
tempData = null;
|
|
145
158
|
}
|
|
146
|
-
} else {
|
|
147
|
-
blockList.push(tempData);
|
|
148
|
-
tempData = null;
|
|
149
159
|
}
|
|
150
160
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
};
|
|
164
|
-
tempData.child.push({
|
|
165
|
-
classList: [],
|
|
166
|
-
textContent: ___replaceTextData(ulSplitText[1].trim())
|
|
167
|
-
});
|
|
168
|
-
} else {
|
|
169
|
-
if (tempData.type === "list") {
|
|
170
|
-
const nextLine = lineList[lineIndex + 1];
|
|
161
|
+
break;
|
|
162
|
+
case unorderListReg.test(text):
|
|
163
|
+
const ulSplitText = text.split(new RegExp("\\+|\\*|-"));
|
|
164
|
+
const ulDepth = Math.floor(ulSplitText[0].length / 4);
|
|
165
|
+
if (tempData === null) {
|
|
166
|
+
tempData = {
|
|
167
|
+
type: "list",
|
|
168
|
+
style: ulDepth % 2 === 0 ? "disc" : "square",
|
|
169
|
+
depth: ulDepth,
|
|
170
|
+
element: "ul",
|
|
171
|
+
child: []
|
|
172
|
+
};
|
|
171
173
|
tempData.child.push({
|
|
172
174
|
classList: [],
|
|
173
175
|
textContent: ___replaceTextData(ulSplitText[1].trim())
|
|
174
176
|
});
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
177
|
+
} else {
|
|
178
|
+
if (tempData.type === "list") {
|
|
179
|
+
const nextLine = lineList[lineIndex + 1];
|
|
180
|
+
tempData.child.push({
|
|
181
|
+
classList: [],
|
|
182
|
+
textContent: ___replaceTextData(ulSplitText[1].trim())
|
|
183
|
+
});
|
|
184
|
+
if (nextLine !== void 0) {
|
|
185
|
+
const nextUlSplitText = nextLine.split(new RegExp("\\+|\\*|-"));
|
|
186
|
+
const nextUlDepth = Math.floor(nextUlSplitText[0].length / 4);
|
|
187
|
+
if (unorderListReg.test(nextLine) === false) {
|
|
183
188
|
blockList.push(tempData);
|
|
184
189
|
tempData = null;
|
|
190
|
+
} else {
|
|
191
|
+
if (tempData.depth !== nextUlDepth) {
|
|
192
|
+
blockList.push(tempData);
|
|
193
|
+
tempData = null;
|
|
194
|
+
}
|
|
185
195
|
}
|
|
196
|
+
} else {
|
|
197
|
+
blockList.push(tempData);
|
|
198
|
+
tempData = null;
|
|
186
199
|
}
|
|
187
|
-
} else {
|
|
188
|
-
blockList.push(tempData);
|
|
189
|
-
tempData = null;
|
|
190
200
|
}
|
|
191
201
|
}
|
|
202
|
+
break;
|
|
203
|
+
case new RegExp("^###(?= )").test(text):
|
|
204
|
+
blockList.push({
|
|
205
|
+
type: "heading",
|
|
206
|
+
level: 3,
|
|
207
|
+
id: _generateId(),
|
|
208
|
+
classList: [],
|
|
209
|
+
textContent: ___replaceTextData(text.substring(4))
|
|
210
|
+
});
|
|
211
|
+
break;
|
|
212
|
+
case new RegExp("^##(?= )").test(text):
|
|
213
|
+
blockList.push({
|
|
214
|
+
type: "heading",
|
|
215
|
+
level: 2,
|
|
216
|
+
id: _generateId(),
|
|
217
|
+
classList: [],
|
|
218
|
+
textContent: ___replaceTextData(text.substring(3))
|
|
219
|
+
});
|
|
220
|
+
break;
|
|
221
|
+
case new RegExp("^#(?= )").test(text):
|
|
222
|
+
blockList.push({
|
|
223
|
+
type: "heading",
|
|
224
|
+
level: 1,
|
|
225
|
+
id: _generateId(),
|
|
226
|
+
classList: [],
|
|
227
|
+
textContent: ___replaceTextData(text.substring(2))
|
|
228
|
+
});
|
|
229
|
+
break;
|
|
230
|
+
default:
|
|
231
|
+
blockList.push({
|
|
232
|
+
type: "text",
|
|
233
|
+
classList: [],
|
|
234
|
+
textContent: ___replaceTextData(text)
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
if (store.value.controlStatus.currentBlockType === "heading" || store.value.controlStatus.currentBlockType === "text") {
|
|
239
|
+
if (store.value.controlStatus.$currentBlock !== null) {
|
|
240
|
+
if (store.value.controlStatus.$currentBlock.textContent === "") {
|
|
241
|
+
isDelete = true;
|
|
242
|
+
$target = store.value.controlStatus.$currentBlock;
|
|
192
243
|
}
|
|
193
|
-
|
|
194
|
-
case new RegExp("^###(?= )").test(text):
|
|
195
|
-
blockList.push({
|
|
196
|
-
type: "heading",
|
|
197
|
-
level: 3,
|
|
198
|
-
id: _generateId(),
|
|
199
|
-
classList: [],
|
|
200
|
-
textContent: ___replaceTextData(text.substring(4))
|
|
201
|
-
});
|
|
202
|
-
break;
|
|
203
|
-
case new RegExp("^##(?= )").test(text):
|
|
204
|
-
blockList.push({
|
|
205
|
-
type: "heading",
|
|
206
|
-
level: 2,
|
|
207
|
-
id: _generateId(),
|
|
208
|
-
classList: [],
|
|
209
|
-
textContent: ___replaceTextData(text.substring(3))
|
|
210
|
-
});
|
|
211
|
-
break;
|
|
212
|
-
case new RegExp("^#(?= )").test(text):
|
|
213
|
-
blockList.push({
|
|
214
|
-
type: "heading",
|
|
215
|
-
level: 1,
|
|
216
|
-
id: _generateId(),
|
|
217
|
-
classList: [],
|
|
218
|
-
textContent: ___replaceTextData(text.substring(2))
|
|
219
|
-
});
|
|
220
|
-
break;
|
|
221
|
-
default:
|
|
222
|
-
blockList.push({
|
|
223
|
-
type: "text",
|
|
224
|
-
classList: [],
|
|
225
|
-
textContent: ___replaceTextData(text)
|
|
226
|
-
});
|
|
244
|
+
}
|
|
227
245
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
246
|
+
blockList.forEach((data) => {
|
|
247
|
+
switch (data.type) {
|
|
248
|
+
case "heading":
|
|
249
|
+
if (data.level === 1) {
|
|
250
|
+
_addBlock("heading1", store, data);
|
|
251
|
+
}
|
|
252
|
+
if (data.level === 2) {
|
|
253
|
+
_addBlock("heading2", store, data);
|
|
254
|
+
}
|
|
255
|
+
if (data.level === 3) {
|
|
256
|
+
_addBlock("heading3", store, data);
|
|
257
|
+
}
|
|
258
|
+
break;
|
|
259
|
+
case "list":
|
|
260
|
+
_addBlock(data.element, store, data);
|
|
261
|
+
break;
|
|
262
|
+
default:
|
|
263
|
+
_addBlock(data.type, store, data);
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
if (isDelete === true) {
|
|
267
|
+
$target?.remove();
|
|
247
268
|
}
|
|
248
|
-
}
|
|
269
|
+
}
|
|
249
270
|
}
|
|
250
271
|
}
|
|
251
272
|
function ___replaceTextData(text) {
|
|
@@ -56,8 +56,22 @@ export function _decideWhetherOpenControlBar(store) {
|
|
|
56
56
|
const allowTypeList = ["code", "ol", "ul"];
|
|
57
57
|
if (allowTypeList.includes(type) === true && $element !== null) {
|
|
58
58
|
const targetRect = $element.getBoundingClientRect();
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
let x = Math.floor(targetRect.left + targetRect.width / 2);
|
|
60
|
+
let y = Math.floor(targetRect.top - 8 - 32);
|
|
61
|
+
if (store.value.controlStatus.hasTransformParent === true && store.value.controlStatus.$transformElement !== null) {
|
|
62
|
+
const transformRect = store.value.controlStatus.$transformElement.getBoundingClientRect();
|
|
63
|
+
x -= transformRect.left;
|
|
64
|
+
y -= transformRect.top;
|
|
65
|
+
if (store.value.$parentWrap !== null) {
|
|
66
|
+
if (store.value.$parentWrap === window) {
|
|
67
|
+
y += store.value.$parentWrap.scrollY;
|
|
68
|
+
} else {
|
|
69
|
+
y += store.value.$parentWrap.scrollTop;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
store.value.controlBar.x = x;
|
|
74
|
+
store.value.controlBar.y = y;
|
|
61
75
|
store.value.controlBar.$element = $element;
|
|
62
76
|
store.value.controlBar.active = true;
|
|
63
77
|
} else {
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import { _findScrollingElement } from "../node/index.js";
|
|
1
|
+
import { _findScrollingElement, _findTransformElement } from "../node/index.js";
|
|
2
2
|
export function _eidtorMountEvent(store) {
|
|
3
3
|
const $editor = document.querySelector(".js-dragon-editor");
|
|
4
4
|
const $body = document.querySelector(".js-de-body");
|
|
5
5
|
const $controlBar = document.querySelector(".js-de-controlbar");
|
|
6
6
|
const $parentWrap = _findScrollingElement($editor);
|
|
7
|
+
const $transformWrap = _findTransformElement($editor);
|
|
7
8
|
store.value.$editor = $editor;
|
|
8
9
|
store.value.$body = $body;
|
|
9
10
|
store.value.$controlBar = $controlBar;
|
|
10
11
|
store.value.$parentWrap = $parentWrap;
|
|
12
|
+
if ($transformWrap === null) {
|
|
13
|
+
store.value.controlStatus.hasTransformParent = false;
|
|
14
|
+
store.value.controlStatus.$transformElement = null;
|
|
15
|
+
} else {
|
|
16
|
+
store.value.controlStatus.hasTransformParent = true;
|
|
17
|
+
store.value.controlStatus.$transformElement = $transformWrap;
|
|
18
|
+
}
|
|
11
19
|
__checkAndSetUpMobile(store);
|
|
12
20
|
window.addEventListener("click", store.value.windowClickEvent);
|
|
13
21
|
window.addEventListener("resize", store.value.windowResizeEvent);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function _findScrollingElement($target: HTMLElement): HTMLElement | Window;
|
|
2
|
+
export declare function _findTransformElement($target: HTMLElement): HTMLElement | null;
|
|
2
3
|
export declare function _getParentElementIfNodeIsText($target: Node, $block: HTMLElement): Node;
|
|
3
4
|
export declare function _findContentEditableElement($target: Node): HTMLElement | null;
|
|
4
5
|
export declare function _findPoverTextNode(node: Element, idx: number): number;
|
|
@@ -1,18 +1,37 @@
|
|
|
1
1
|
export function _findScrollingElement($target) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
const $wrap = $target.parentElement;
|
|
3
|
+
if ($wrap !== null) {
|
|
4
|
+
const style = window.getComputedStyle($wrap);
|
|
5
|
+
if (style.overflow !== "visible") {
|
|
6
|
+
return $wrap;
|
|
5
7
|
} else {
|
|
6
|
-
if ($
|
|
8
|
+
if ($wrap.tagName === "BODY") {
|
|
7
9
|
return window;
|
|
8
10
|
} else {
|
|
9
|
-
return _findScrollingElement($
|
|
11
|
+
return _findScrollingElement($wrap);
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
14
|
} else {
|
|
13
15
|
return window;
|
|
14
16
|
}
|
|
15
17
|
}
|
|
18
|
+
export function _findTransformElement($target) {
|
|
19
|
+
const $wrap = $target.parentElement;
|
|
20
|
+
if ($wrap !== null) {
|
|
21
|
+
const style = window.getComputedStyle($wrap);
|
|
22
|
+
if (style.transform !== "none") {
|
|
23
|
+
return $wrap;
|
|
24
|
+
} else {
|
|
25
|
+
if ($wrap.tagName === "BODY") {
|
|
26
|
+
return null;
|
|
27
|
+
} else {
|
|
28
|
+
return _findTransformElement($wrap);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
16
35
|
export function _getParentElementIfNodeIsText($target, $block) {
|
|
17
36
|
if ($target.constructor.name === "Text") {
|
|
18
37
|
const $parent = $target.parentElement;
|