dragon-editor 3.8.2 → 3.8.4
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.vue +17 -2
- package/dist/runtime/scss/editor.css +12 -0
- package/dist/runtime/type.d.mts +3 -0
- 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 +15 -1
- package/dist/runtime/utils/node/element.d.ts +2 -0
- package/dist/runtime/utils/node/element.js +41 -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 };
|
|
@@ -45,6 +45,8 @@ const editorStore = ref({
|
|
|
45
45
|
},
|
|
46
46
|
controlStatus: {
|
|
47
47
|
isMobile: false,
|
|
48
|
+
hasTransformParent: false,
|
|
49
|
+
hasHiddenStyleParent: false,
|
|
48
50
|
currentBlockType: "text",
|
|
49
51
|
codeBlockTheme: "github-light",
|
|
50
52
|
codeBlockLang: "text",
|
|
@@ -55,7 +57,8 @@ const editorStore = ref({
|
|
|
55
57
|
anchorValidation: false,
|
|
56
58
|
previousCorsorData: null,
|
|
57
59
|
$anchorInput: null,
|
|
58
|
-
$currentBlock: null
|
|
60
|
+
$currentBlock: null,
|
|
61
|
+
$transformElement: null
|
|
59
62
|
},
|
|
60
63
|
codeBlockTheme: [
|
|
61
64
|
{
|
|
@@ -130,7 +133,7 @@ function mainStrucutre() {
|
|
|
130
133
|
return h(
|
|
131
134
|
"div",
|
|
132
135
|
{
|
|
133
|
-
class: ["dragon-editor", "js-dragon-editor", { "--has-menu": editorStore.value.useMenuBar === true }, { "--mobile": editorStore.value.controlStatus.isMobile === true }],
|
|
136
|
+
class: ["dragon-editor", "js-dragon-editor", { "--has-menu": editorStore.value.useMenuBar === true }, { "--mobile": editorStore.value.controlStatus.isMobile === true }, { "--hidden-parent": editorStore.value.controlStatus.hasHiddenStyleParent === true }],
|
|
134
137
|
onMousemove: (event) => _editorMousemoveEvent(event, editorStore),
|
|
135
138
|
onMouseup: (event) => _editorMouseupEvent(event, editorStore),
|
|
136
139
|
onMouseleave: (event) => _editorMouseleaveEvent(event, editorStore),
|
|
@@ -382,6 +385,15 @@ defineExpose({
|
|
|
382
385
|
left: auto;
|
|
383
386
|
right: 0;
|
|
384
387
|
}
|
|
388
|
+
.dragon-editor.--hidden-parent {
|
|
389
|
+
height: 100%;
|
|
390
|
+
box-sizing: border-box;
|
|
391
|
+
}
|
|
392
|
+
.dragon-editor.--hidden-parent .de-body {
|
|
393
|
+
height: 100%;
|
|
394
|
+
overflow-y: auto;
|
|
395
|
+
box-sizing: border-box;
|
|
396
|
+
}
|
|
385
397
|
.dragon-editor .de-body {
|
|
386
398
|
display: flex;
|
|
387
399
|
flex-direction: column;
|
|
@@ -548,6 +560,9 @@ defineExpose({
|
|
|
548
560
|
height: 100%;
|
|
549
561
|
border: 0;
|
|
550
562
|
}
|
|
563
|
+
.dragon-editor .de-controlbar .de-col .de-name {
|
|
564
|
+
width: 70px;
|
|
565
|
+
}
|
|
551
566
|
.dragon-editor .de-block {
|
|
552
567
|
width: 100%;
|
|
553
568
|
padding: 2px 0;
|
|
@@ -173,6 +173,15 @@
|
|
|
173
173
|
left: auto;
|
|
174
174
|
right: 0;
|
|
175
175
|
}
|
|
176
|
+
.dragon-editor.--hidden-parent {
|
|
177
|
+
height: 100%;
|
|
178
|
+
box-sizing: border-box;
|
|
179
|
+
}
|
|
180
|
+
.dragon-editor.--hidden-parent .de-body {
|
|
181
|
+
height: 100%;
|
|
182
|
+
overflow-y: auto;
|
|
183
|
+
box-sizing: border-box;
|
|
184
|
+
}
|
|
176
185
|
.dragon-editor .de-body {
|
|
177
186
|
display: flex;
|
|
178
187
|
flex-direction: column;
|
|
@@ -339,6 +348,9 @@
|
|
|
339
348
|
height: 100%;
|
|
340
349
|
border: 0;
|
|
341
350
|
}
|
|
351
|
+
.dragon-editor .de-controlbar .de-col .de-name {
|
|
352
|
+
width: 70px;
|
|
353
|
+
}
|
|
342
354
|
.dragon-editor .de-block {
|
|
343
355
|
width: 100%;
|
|
344
356
|
padding: 2px 0;
|
package/dist/runtime/type.d.mts
CHANGED
|
@@ -51,6 +51,8 @@ interface DragonEditorStore {
|
|
|
51
51
|
};
|
|
52
52
|
controlStatus: {
|
|
53
53
|
isMobile: boolean;
|
|
54
|
+
hasTransformParent: boolean;
|
|
55
|
+
hasHiddenStyleParent: boolean;
|
|
54
56
|
anchorValidation: boolean;
|
|
55
57
|
currentBlockType: DEBlock;
|
|
56
58
|
codeBlockTheme: DECodeblockTheme;
|
|
@@ -62,6 +64,7 @@ interface DragonEditorStore {
|
|
|
62
64
|
previousCorsorData: DEditorCursor | null;
|
|
63
65
|
$anchorInput: HTMLInputElement | null;
|
|
64
66
|
$currentBlock: HTMLDivElement | null;
|
|
67
|
+
$transformElement: HTMLElement | null;
|
|
65
68
|
};
|
|
66
69
|
codeToHtml: codeToHtml;
|
|
67
70
|
codeBlockTheme: DECodeItem<DECodeblockTheme>[];
|
|
@@ -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,27 @@
|
|
|
1
|
-
import { _findScrollingElement } from "../node/index.js";
|
|
1
|
+
import { _findScrollingElement, _findTransformElement, _findHiddenStyleElement } 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 $hiddenStyleElement = _findHiddenStyleElement($editor);
|
|
8
|
+
const $transformElement = _findTransformElement($editor);
|
|
7
9
|
store.value.$editor = $editor;
|
|
8
10
|
store.value.$body = $body;
|
|
9
11
|
store.value.$controlBar = $controlBar;
|
|
10
12
|
store.value.$parentWrap = $parentWrap;
|
|
13
|
+
if ($hiddenStyleElement === $editor.parentElement) {
|
|
14
|
+
store.value.controlStatus.hasHiddenStyleParent = true;
|
|
15
|
+
} else {
|
|
16
|
+
store.value.controlStatus.hasHiddenStyleParent = false;
|
|
17
|
+
}
|
|
18
|
+
if ($transformElement === null) {
|
|
19
|
+
store.value.controlStatus.hasTransformParent = false;
|
|
20
|
+
store.value.controlStatus.$transformElement = null;
|
|
21
|
+
} else {
|
|
22
|
+
store.value.controlStatus.hasTransformParent = true;
|
|
23
|
+
store.value.controlStatus.$transformElement = $transformElement;
|
|
24
|
+
}
|
|
11
25
|
__checkAndSetUpMobile(store);
|
|
12
26
|
window.addEventListener("click", store.value.windowClickEvent);
|
|
13
27
|
window.addEventListener("resize", store.value.windowResizeEvent);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare function _findScrollingElement($target: HTMLElement): HTMLElement | Window;
|
|
2
|
+
export declare function _findHiddenStyleElement($target: HTMLElement): HTMLElement | null;
|
|
3
|
+
export declare function _findTransformElement($target: HTMLElement): HTMLElement | null;
|
|
2
4
|
export declare function _getParentElementIfNodeIsText($target: Node, $block: HTMLElement): Node;
|
|
3
5
|
export declare function _findContentEditableElement($target: Node): HTMLElement | null;
|
|
4
6
|
export declare function _findPoverTextNode(node: Element, idx: number): number;
|
|
@@ -1,18 +1,54 @@
|
|
|
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" && style.overflow !== "hidden") {
|
|
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 _findHiddenStyleElement($target) {
|
|
19
|
+
const $wrap = $target.parentElement;
|
|
20
|
+
if ($wrap !== null) {
|
|
21
|
+
const style = window.getComputedStyle($wrap);
|
|
22
|
+
if (style.overflow === "hidden") {
|
|
23
|
+
return $wrap;
|
|
24
|
+
} else {
|
|
25
|
+
if ($wrap.tagName === "HTML") {
|
|
26
|
+
return null;
|
|
27
|
+
} else {
|
|
28
|
+
return _findHiddenStyleElement($wrap);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function _findTransformElement($target) {
|
|
36
|
+
const $wrap = $target.parentElement;
|
|
37
|
+
if ($wrap !== null) {
|
|
38
|
+
const style = window.getComputedStyle($wrap);
|
|
39
|
+
if (style.transform !== "none") {
|
|
40
|
+
return $wrap;
|
|
41
|
+
} else {
|
|
42
|
+
if ($wrap.tagName === "BODY") {
|
|
43
|
+
return null;
|
|
44
|
+
} else {
|
|
45
|
+
return _findTransformElement($wrap);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
16
52
|
export function _getParentElementIfNodeIsText($target, $block) {
|
|
17
53
|
if ($target.constructor.name === "Text") {
|
|
18
54
|
const $parent = $target.parentElement;
|