@lvce-editor/virtual-dom 1.32.0 → 1.34.0

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/index.js CHANGED
@@ -533,6 +533,17 @@ const applyPatch = ($Element, patches) => {
533
533
  }
534
534
  };
535
535
 
536
+ let ignore = false;
537
+ const startIgnore = () => {
538
+ ignore = true;
539
+ };
540
+ const stopIgnore = () => {
541
+ ignore = false;
542
+ };
543
+ const enabled = () => {
544
+ return ignore;
545
+ };
546
+
536
547
  let id = 0;
537
548
  const create = () => {
538
549
  return ++id;
@@ -624,6 +635,9 @@ const getEventListenerArgs = (params, event) => {
624
635
 
625
636
  const createFn = info => {
626
637
  const fn = event => {
638
+ if (enabled()) {
639
+ return;
640
+ }
627
641
  if (info.preventDefault) {
628
642
  event.preventDefault(event);
629
643
  }
@@ -682,6 +696,7 @@ const render = (elements, eventMap = {}, newEventMap = {}) => {
682
696
  };
683
697
 
684
698
  const rememberFocus = ($Viewlet, dom, eventMap, uid = 0) => {
699
+ startIgnore();
685
700
  const oldLeft = $Viewlet.style.left;
686
701
  const oldTop = $Viewlet.style.top;
687
702
  const oldWidth = $Viewlet.style.width;
@@ -721,6 +736,9 @@ const rememberFocus = ($Viewlet, dom, eventMap, uid = 0) => {
721
736
  const $Previous = $Hidden.firstChild;
722
737
  $Previous.className = $NewFocused.className;
723
738
  $Previous.placeholder = $NewFocused.placeholder;
739
+ if ($NewFocused.childNodes) {
740
+ $Previous.append(...$NewFocused.childNodes);
741
+ }
724
742
  $NewFocused.replaceWith($Previous);
725
743
  }
726
744
  }
@@ -748,6 +766,7 @@ const rememberFocus = ($Viewlet, dom, eventMap, uid = 0) => {
748
766
  $Viewlet.style.left = oldLeft;
749
767
  $Viewlet.style.height = oldHeight;
750
768
  $Viewlet.style.width = oldWidth;
769
+ stopIgnore();
751
770
  return $Viewlet;
752
771
  };
753
772
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/virtual-dom",
3
- "version": "1.32.0",
3
+ "version": "1.34.0",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -1,10 +1,14 @@
1
1
  import * as ComponentUid from '../ComponentUid/ComponentUid.ts'
2
+ import * as EventState from '../EventState/EventState.ts'
2
3
  import * as GetEventListenerArgs from '../GetEventListenerArgs/GetEventListenerArgs.ts'
3
4
  import * as IpcState from '../IpcState/IpcState.ts'
4
5
  import * as NameAnonymousFunction from '../NameAnonymousFunction/NameAnonymousFunction.ts'
5
6
 
6
7
  export const createFn = (info): any => {
7
8
  const fn = (event): void => {
9
+ if (EventState.enabled()) {
10
+ return
11
+ }
8
12
  if (info.preventDefault) {
9
13
  event.preventDefault(event)
10
14
  }
@@ -0,0 +1,13 @@
1
+ let ignore = false
2
+
3
+ export const startIgnore = (): void => {
4
+ ignore = true
5
+ }
6
+
7
+ export const stopIgnore = (): void => {
8
+ ignore = false
9
+ }
10
+
11
+ export const enabled = (): boolean => {
12
+ return ignore
13
+ }
@@ -1,4 +1,5 @@
1
1
  import * as ComponentUid from '../ComponentUid/ComponentUid.ts'
2
+ import * as EventState from '../EventState/EventState.ts'
2
3
  import * as QueryInputs from '../QueryInputs/QueryInputs.ts'
3
4
  import * as RegisterEventListeners from '../RegisterEventListeners/RegisterEventListeners.ts'
4
5
  import * as VirtualDom from '../VirtualDom/VirtualDom.ts'
@@ -9,6 +10,7 @@ export const rememberFocus = (
9
10
  eventMap: any,
10
11
  uid = 0,
11
12
  ): any => {
13
+ EventState.startIgnore()
12
14
  const oldLeft = $Viewlet.style.left
13
15
  const oldTop = $Viewlet.style.top
14
16
  const oldWidth = $Viewlet.style.width
@@ -50,6 +52,9 @@ export const rememberFocus = (
50
52
  const $Previous = $Hidden.firstChild as HTMLInputElement
51
53
  $Previous.className = $NewFocused.className
52
54
  $Previous.placeholder = $NewFocused.placeholder
55
+ if ($NewFocused.childNodes) {
56
+ $Previous.append(...$NewFocused.childNodes)
57
+ }
53
58
  $NewFocused.replaceWith($Previous)
54
59
  }
55
60
  }
@@ -81,5 +86,7 @@ export const rememberFocus = (
81
86
  $Viewlet.style.height = oldHeight
82
87
  $Viewlet.style.width = oldWidth
83
88
 
89
+ EventState.stopIgnore()
90
+
84
91
  return $Viewlet
85
92
  }