dragon-editor 3.8.3 → 3.8.5
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/runtime/components/DragonEditor.vue +11 -3
- package/dist/runtime/scss/editor.css +9 -2
- package/dist/runtime/type.d.mts +1 -0
- package/dist/runtime/utils/event/mouse.js +7 -7
- package/dist/runtime/utils/event/window.js +10 -4
- package/dist/runtime/utils/node/element.d.ts +1 -0
- package/dist/runtime/utils/node/element.js +18 -1
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -46,6 +46,7 @@ const editorStore = ref({
|
|
|
46
46
|
controlStatus: {
|
|
47
47
|
isMobile: false,
|
|
48
48
|
hasTransformParent: false,
|
|
49
|
+
hasHiddenStyleParent: false,
|
|
49
50
|
currentBlockType: "text",
|
|
50
51
|
codeBlockTheme: "github-light",
|
|
51
52
|
codeBlockLang: "text",
|
|
@@ -132,7 +133,7 @@ function mainStrucutre() {
|
|
|
132
133
|
return h(
|
|
133
134
|
"div",
|
|
134
135
|
{
|
|
135
|
-
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 }],
|
|
136
137
|
onMousemove: (event) => _editorMousemoveEvent(event, editorStore),
|
|
137
138
|
onMouseup: (event) => _editorMouseupEvent(event, editorStore),
|
|
138
139
|
onMouseleave: (event) => _editorMouseleaveEvent(event, editorStore),
|
|
@@ -384,9 +385,16 @@ defineExpose({
|
|
|
384
385
|
left: auto;
|
|
385
386
|
right: 0;
|
|
386
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
|
+
}
|
|
387
397
|
.dragon-editor .de-body {
|
|
388
|
-
display: flex;
|
|
389
|
-
flex-direction: column;
|
|
390
398
|
padding: 16px 20px;
|
|
391
399
|
line-height: 1.6;
|
|
392
400
|
}
|
|
@@ -173,9 +173,16 @@
|
|
|
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
|
-
display: flex;
|
|
178
|
-
flex-direction: column;
|
|
179
186
|
padding: 16px 20px;
|
|
180
187
|
line-height: 1.6;
|
|
181
188
|
}
|
package/dist/runtime/type.d.mts
CHANGED
|
@@ -58,17 +58,17 @@ export function _decideWhetherOpenControlBar(store) {
|
|
|
58
58
|
const targetRect = $element.getBoundingClientRect();
|
|
59
59
|
let x = Math.floor(targetRect.left + targetRect.width / 2);
|
|
60
60
|
let y = Math.floor(targetRect.top - 8 - 32);
|
|
61
|
+
if (y < 0) {
|
|
62
|
+
y = 44;
|
|
63
|
+
if (store.value.$parentWrap !== null && store.value.$editor !== null) {
|
|
64
|
+
const editorRect = store.value.$editor.getBoundingClientRect();
|
|
65
|
+
y += editorRect.top;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
61
68
|
if (store.value.controlStatus.hasTransformParent === true && store.value.controlStatus.$transformElement !== null) {
|
|
62
69
|
const transformRect = store.value.controlStatus.$transformElement.getBoundingClientRect();
|
|
63
70
|
x -= transformRect.left;
|
|
64
71
|
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
72
|
}
|
|
73
73
|
store.value.controlBar.x = x;
|
|
74
74
|
store.value.controlBar.y = y;
|
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
import { _findScrollingElement, _findTransformElement } 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 $
|
|
7
|
+
const $hiddenStyleElement = _findHiddenStyleElement($editor);
|
|
8
|
+
const $transformElement = _findTransformElement($editor);
|
|
8
9
|
store.value.$editor = $editor;
|
|
9
10
|
store.value.$body = $body;
|
|
10
11
|
store.value.$controlBar = $controlBar;
|
|
11
12
|
store.value.$parentWrap = $parentWrap;
|
|
12
|
-
if ($
|
|
13
|
+
if ($hiddenStyleElement === $editor.parentElement) {
|
|
14
|
+
store.value.controlStatus.hasHiddenStyleParent = true;
|
|
15
|
+
} else {
|
|
16
|
+
store.value.controlStatus.hasHiddenStyleParent = false;
|
|
17
|
+
}
|
|
18
|
+
if ($transformElement === null) {
|
|
13
19
|
store.value.controlStatus.hasTransformParent = false;
|
|
14
20
|
store.value.controlStatus.$transformElement = null;
|
|
15
21
|
} else {
|
|
16
22
|
store.value.controlStatus.hasTransformParent = true;
|
|
17
|
-
store.value.controlStatus.$transformElement = $
|
|
23
|
+
store.value.controlStatus.$transformElement = $transformElement;
|
|
18
24
|
}
|
|
19
25
|
__checkAndSetUpMobile(store);
|
|
20
26
|
window.addEventListener("click", store.value.windowClickEvent);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function _findScrollingElement($target: HTMLElement): HTMLElement | Window;
|
|
2
|
+
export declare function _findHiddenStyleElement($target: HTMLElement): HTMLElement | null;
|
|
2
3
|
export declare function _findTransformElement($target: HTMLElement): HTMLElement | null;
|
|
3
4
|
export declare function _getParentElementIfNodeIsText($target: Node, $block: HTMLElement): Node;
|
|
4
5
|
export declare function _findContentEditableElement($target: Node): HTMLElement | null;
|
|
@@ -2,7 +2,7 @@ export function _findScrollingElement($target) {
|
|
|
2
2
|
const $wrap = $target.parentElement;
|
|
3
3
|
if ($wrap !== null) {
|
|
4
4
|
const style = window.getComputedStyle($wrap);
|
|
5
|
-
if (style.overflow !== "visible") {
|
|
5
|
+
if (style.overflow !== "visible" && style.overflow !== "hidden") {
|
|
6
6
|
return $wrap;
|
|
7
7
|
} else {
|
|
8
8
|
if ($wrap.tagName === "BODY") {
|
|
@@ -15,6 +15,23 @@ export function _findScrollingElement($target) {
|
|
|
15
15
|
return window;
|
|
16
16
|
}
|
|
17
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
|
+
}
|
|
18
35
|
export function _findTransformElement($target) {
|
|
19
36
|
const $wrap = $target.parentElement;
|
|
20
37
|
if ($wrap !== null) {
|