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 CHANGED
@@ -4,7 +4,7 @@
4
4
  "nuxt": ">=3.0.0"
5
5
  },
6
6
  "configKey": "dragon-editor",
7
- "version": "3.8.3",
7
+ "version": "3.8.5",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
@@ -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
  }
@@ -52,6 +52,7 @@ interface DragonEditorStore {
52
52
  controlStatus: {
53
53
  isMobile: boolean;
54
54
  hasTransformParent: boolean;
55
+ hasHiddenStyleParent: boolean;
55
56
  anchorValidation: boolean;
56
57
  currentBlockType: DEBlock;
57
58
  codeBlockTheme: DECodeblockTheme;
@@ -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 $transformWrap = _findTransformElement($editor);
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 ($transformWrap === null) {
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 = $transformWrap;
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dragon-editor",
3
- "version": "3.8.3",
3
+ "version": "3.8.5",
4
4
  "description": "Javascript WYSIWYG editor in Nuxt!",
5
5
  "repository": {
6
6
  "type": "git",