@fulate/tools 1.0.13 → 1.0.14

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/README.md CHANGED
@@ -208,7 +208,9 @@ aggregate frame 为 world 轴对齐,因此沿 world 水平/垂直轴镜像。
208
208
  策略,使用同一批 selected owner baseline、trusted batch 与 semantic History;Group 不承载这次镜像的
209
209
  scale,镜像会递归 bake children authored geometry。空选择或被策略禁止的方向是普通 noop。
210
210
 
211
- ## Keyboard、Clipboard 与应用命令 owner
211
+ ## Keyboard、Clipboard 与应用命令 owner
212
+
213
+ HTTP 页面在 Async Clipboard 不可用时,会把当前序列化 payload 共享到同源 tab 的 `localStorage`;跨不同 origin 的 tab 仍需要 HTTPS 或外部中转能力。
212
214
 
213
215
  每个活动 Root 由当前 `EditorInteractionController` 安装一个 DOM `keydown` listener。应用若要接管
214
216
  `Ctrl/Meta+C`、`Ctrl/Meta+X`、`Ctrl/Meta+V`、`Delete` 或 `Backspace`,只绑定一个命令 owner:
package/dist/index.js CHANGED
@@ -3233,6 +3233,7 @@ function arrangeElements(select, type) {
3233
3233
  //#endregion
3234
3234
  //#region packages/tools/src/select/clipboard.ts
3235
3235
  var PASTE_OFFSET = 20;
3236
+ var CLIPBOARD_STORAGE_KEY = "fulate:clipboard";
3236
3237
  var memoryClipboard = null;
3237
3238
  function collectSubtreeKeys(elements) {
3238
3239
  const keys = /* @__PURE__ */ new Set();
@@ -3302,9 +3303,25 @@ function snapshotSelection(select, producer) {
3302
3303
  if (!isCurrentSelection(select, controller, sources)) return;
3303
3304
  return data;
3304
3305
  }
3305
- function writeSystemClipboard(data) {
3306
+ function serializeClipboard(data) {
3307
+ return JSON.stringify(data);
3308
+ }
3309
+ function writeSharedClipboard(text) {
3306
3310
  try {
3307
- const text = JSON.stringify(data);
3311
+ globalThis.localStorage.setItem(CLIPBOARD_STORAGE_KEY, text);
3312
+ } catch {}
3313
+ }
3314
+ function readSharedClipboard() {
3315
+ try {
3316
+ return globalThis.localStorage.getItem(CLIPBOARD_STORAGE_KEY);
3317
+ } catch {
3318
+ return null;
3319
+ }
3320
+ }
3321
+ function writeClipboard(data) {
3322
+ try {
3323
+ const text = serializeClipboard(data);
3324
+ writeSharedClipboard(text);
3308
3325
  Promise.resolve(navigator.clipboard.writeText(text)).catch(() => {});
3309
3326
  } catch {}
3310
3327
  }
@@ -3312,7 +3329,7 @@ function copyElements(select, producer) {
3312
3329
  const data = snapshotSelection(select, producer);
3313
3330
  if (!data) return;
3314
3331
  memoryClipboard = data;
3315
- writeSystemClipboard(data);
3332
+ writeClipboard(data);
3316
3333
  }
3317
3334
  function removeKeys(data) {
3318
3335
  delete data.key;
@@ -3462,8 +3479,13 @@ function pasteElements(select, deserializers, options) {
3462
3479
  try {
3463
3480
  text = await navigator.clipboard.readText();
3464
3481
  } catch {
3465
- if (isCurrentPasteController(select, controller)) pasteMemory(select, controller, pasteSelection, task, deserializers, options);
3466
- return;
3482
+ if (isCurrentPasteController(select, controller)) if (memoryClipboard) pasteMemory(select, controller, pasteSelection, task, deserializers, options);
3483
+ else {
3484
+ const sharedText = readSharedClipboard();
3485
+ if (sharedText === null) return;
3486
+ text = sharedText;
3487
+ }
3488
+ if (text === void 0) return;
3467
3489
  }
3468
3490
  if (!isCurrentPasteController(select, controller)) return;
3469
3491
  const data = JSON.parse(text);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fulate/tools",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",