@lvce-editor/virtual-dom 2.3.0 → 2.5.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.d.ts
CHANGED
|
@@ -50,6 +50,9 @@ export declare const applyPatch: ($Element: Node, patches: readonly Patch[]) =>
|
|
|
50
50
|
export declare const setComponentUid: ($Element: any, uid: any) => void;
|
|
51
51
|
export declare const getComponentUid: ($Element: any) => number;
|
|
52
52
|
export declare const getComponentUidFromEvent: (event: any) => number;
|
|
53
|
+
export declare const setDragInfo: (id: string | number, data: any) => void;
|
|
54
|
+
export declare const getDragInfo: (id: string | number) => any;
|
|
55
|
+
export declare const removeDragInfo: (id: string | number) => void;
|
|
53
56
|
export declare const getFileHandles: (ids: readonly number[]) => Promise<readonly FileSystemHandle[]>;
|
|
54
57
|
export declare const addFileHandle: (fileHandle: FileSystemHandle) => number;
|
|
55
58
|
export declare const setIpc: (value: any) => void;
|
package/dist/index.js
CHANGED
|
@@ -540,6 +540,17 @@ const applyPatch = ($Element, patches) => {
|
|
|
540
540
|
}
|
|
541
541
|
};
|
|
542
542
|
|
|
543
|
+
const dragInfos = Object.create(null);
|
|
544
|
+
const setDragInfo = (id, data) => {
|
|
545
|
+
dragInfos[id] = data;
|
|
546
|
+
};
|
|
547
|
+
const getDragInfo = id => {
|
|
548
|
+
return dragInfos[id];
|
|
549
|
+
};
|
|
550
|
+
const removeDragInfo = id => {
|
|
551
|
+
delete dragInfos[id];
|
|
552
|
+
};
|
|
553
|
+
|
|
543
554
|
let id = 0;
|
|
544
555
|
const create = () => {
|
|
545
556
|
return ++id;
|
|
@@ -653,6 +664,7 @@ const getEventListenerArgs = (params, event) => {
|
|
|
653
664
|
const isInputElement = element => {
|
|
654
665
|
return element instanceof HTMLInputElement;
|
|
655
666
|
};
|
|
667
|
+
|
|
656
668
|
const preventEventsMaybe = (info, event) => {
|
|
657
669
|
if (info.preventDefault === 2) {
|
|
658
670
|
if (!isInputElement(event.target)) {
|
|
@@ -664,6 +676,16 @@ const preventEventsMaybe = (info, event) => {
|
|
|
664
676
|
if (info.stopPropagation) {
|
|
665
677
|
event.stopPropagation();
|
|
666
678
|
}
|
|
679
|
+
if (event.dataTransfer) {
|
|
680
|
+
const uid = getComponentUid(event.target);
|
|
681
|
+
const dragInfo = getDragInfo(uid);
|
|
682
|
+
if (!dragInfo) {
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
for (const item of info.dragInfo) {
|
|
686
|
+
event.dataTransfer.setData(item.type, item.data);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
667
689
|
};
|
|
668
690
|
|
|
669
691
|
const createFn = info => {
|
|
@@ -813,4 +835,4 @@ const rememberFocus = ($Viewlet, dom, eventMap, uid = 0) => {
|
|
|
813
835
|
return $Viewlet;
|
|
814
836
|
};
|
|
815
837
|
|
|
816
|
-
export { addFileHandle, applyPatch, getComponentUid, getComponentUidFromEvent, getFileHandles, registerEventListeners, rememberFocus, render, renderInto, setComponentUid, setIpc };
|
|
838
|
+
export { addFileHandle, applyPatch, getComponentUid, getComponentUidFromEvent, getDragInfo, getFileHandles, registerEventListeners, rememberFocus, removeDragInfo, render, renderInto, setComponentUid, setDragInfo, setIpc };
|
package/package.json
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const dragInfos = Object.create(null)
|
|
2
|
+
|
|
3
|
+
export const setDragInfo = (id: string | number, data: any): void => {
|
|
4
|
+
dragInfos[id] = data
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const getDragInfo = (id: string | number): any => {
|
|
8
|
+
return dragInfos[id]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const removeDragInfo = (id: string | number): void => {
|
|
12
|
+
delete dragInfos[id]
|
|
13
|
+
}
|
package/src/parts/Main/Main.ts
CHANGED
|
@@ -4,6 +4,11 @@ export {
|
|
|
4
4
|
getComponentUidFromEvent,
|
|
5
5
|
setComponentUid,
|
|
6
6
|
} from '../ComponentUid/ComponentUid.ts'
|
|
7
|
+
export {
|
|
8
|
+
getDragInfo,
|
|
9
|
+
removeDragInfo,
|
|
10
|
+
setDragInfo,
|
|
11
|
+
} from '../DragInfo/DragInfo.ts'
|
|
7
12
|
export { addFileHandle, getFileHandles } from '../FileHandles/FileHandles.ts'
|
|
8
13
|
export { setIpc } from '../IpcState/IpcState.ts'
|
|
9
14
|
export { registerEventListeners } from '../RegisterEventListeners/RegisterEventListeners.ts'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}
|
|
1
|
+
import { getComponentUid } from '../ComponentUid/ComponentUid.ts'
|
|
2
|
+
import { getDragInfo } from '../DragInfo/DragInfo.ts'
|
|
3
|
+
import { isInputElement } from '../IsInputElement/IsInputElement.ts'
|
|
4
4
|
|
|
5
5
|
export const preventEventsMaybe = (info: any, event: any): void => {
|
|
6
6
|
if (info.preventDefault === 2) {
|
|
@@ -13,4 +13,14 @@ export const preventEventsMaybe = (info: any, event: any): void => {
|
|
|
13
13
|
if (info.stopPropagation) {
|
|
14
14
|
event.stopPropagation()
|
|
15
15
|
}
|
|
16
|
+
if (event.dataTransfer) {
|
|
17
|
+
const uid = getComponentUid(event.target)
|
|
18
|
+
const dragInfo = getDragInfo(uid)
|
|
19
|
+
if (!dragInfo) {
|
|
20
|
+
return
|
|
21
|
+
}
|
|
22
|
+
for (const item of info.dragInfo) {
|
|
23
|
+
event.dataTransfer.setData(item.type, item.data)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
16
26
|
}
|