@lvce-editor/renderer-process 21.10.0 → 21.11.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/rendererProcessMain.js +28 -6
- package/package.json +1 -1
|
@@ -9208,13 +9208,35 @@ const setPatches = (uid, patches) => {
|
|
|
9208
9208
|
}
|
|
9209
9209
|
applyPatch($Viewlet, patches, {}, uid);
|
|
9210
9210
|
};
|
|
9211
|
-
const
|
|
9211
|
+
const waitForElement = selector => {
|
|
9212
|
+
const element = document.querySelector(selector);
|
|
9213
|
+
if (element) {
|
|
9214
|
+
return Promise.resolve(element);
|
|
9215
|
+
}
|
|
9216
|
+
const {
|
|
9217
|
+
promise,
|
|
9218
|
+
resolve
|
|
9219
|
+
} = withResolvers();
|
|
9220
|
+
const observer = new MutationObserver(() => {
|
|
9221
|
+
const element = document.querySelector(selector);
|
|
9222
|
+
if (element) {
|
|
9223
|
+
observer.disconnect();
|
|
9224
|
+
resolve(element);
|
|
9225
|
+
}
|
|
9226
|
+
});
|
|
9227
|
+
observer.observe(document.body, {
|
|
9228
|
+
childList: true,
|
|
9229
|
+
subtree: true
|
|
9230
|
+
});
|
|
9231
|
+
return promise;
|
|
9232
|
+
};
|
|
9233
|
+
const move = async (uid, selector, target) => {
|
|
9212
9234
|
const $Source = document.querySelector(selector);
|
|
9213
|
-
|
|
9214
|
-
|
|
9215
|
-
|
|
9216
|
-
|
|
9217
|
-
|
|
9235
|
+
if (!$Source) {
|
|
9236
|
+
throw new Error(`Source element not found: ${selector}`);
|
|
9237
|
+
}
|
|
9238
|
+
const $Target = await waitForElement(target);
|
|
9239
|
+
$Target.append($Source);
|
|
9218
9240
|
};
|
|
9219
9241
|
|
|
9220
9242
|
// TODO this code is bad
|