@agent-native/core 0.84.0 → 0.84.2
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/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +13 -0
- package/corpus/core/docs/content/evals.mdx +34 -12
- package/corpus/core/docs/content/locales/ar-SA/evals.mdx +7 -0
- package/corpus/core/docs/content/locales/de-DE/evals.mdx +8 -0
- package/corpus/core/docs/content/locales/es-ES/evals.mdx +8 -0
- package/corpus/core/docs/content/locales/fr-FR/evals.mdx +8 -0
- package/corpus/core/docs/content/locales/hi-IN/evals.mdx +8 -0
- package/corpus/core/docs/content/locales/ja-JP/evals.mdx +7 -0
- package/corpus/core/docs/content/locales/ko-KR/evals.mdx +7 -0
- package/corpus/core/docs/content/locales/pt-BR/evals.mdx +8 -0
- package/corpus/core/docs/content/locales/zh-CN/evals.mdx +7 -0
- package/corpus/core/docs/content/locales/zh-TW/evals.mdx +7 -0
- package/corpus/core/docs/design/durable-agent-runs.md +34 -35
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/agent/engine/builder-engine.ts +81 -9
- package/corpus/core/src/agent/run-manager.ts +8 -7
- package/corpus/core/src/cli/design-connect.ts +175 -0
- package/corpus/core/src/cli/skills.ts +5 -7
- package/corpus/core/src/client/AgentPanel.tsx +8 -0
- package/corpus/core/src/client/MultiTabAssistantChat.tsx +4 -1
- package/corpus/core/src/client/agent-chat-adapter.ts +45 -15
- package/corpus/core/src/client/sse-event-processor.ts +31 -4
- package/corpus/core/src/eval/define-eval.ts +4 -1
- package/corpus/core/src/eval/report.ts +23 -8
- package/corpus/core/src/eval/runner.ts +41 -6
- package/corpus/core/src/eval/types.ts +11 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/reliable-mutations/SKILL.md +15 -17
- package/corpus/templates/content/AGENTS.md +9 -2
- package/corpus/templates/content/actions/_database-row-batch.ts +230 -0
- package/corpus/templates/content/actions/_database-utils.ts +17 -9
- package/corpus/templates/content/actions/_notion-action-utils.ts +26 -0
- package/corpus/templates/content/actions/connect-notion-status.ts +13 -4
- package/corpus/templates/content/actions/create-and-link-notion-page.ts +23 -0
- package/corpus/templates/content/actions/delete-database-items.ts +55 -0
- package/corpus/templates/content/actions/delete-document.ts +4 -4
- package/corpus/templates/content/actions/disconnect-notion.ts +16 -0
- package/corpus/templates/content/actions/duplicate-database-item.ts +1 -1
- package/corpus/templates/content/actions/duplicate-database-items.ts +191 -0
- package/corpus/templates/content/actions/link-notion-page.ts +10 -7
- package/corpus/templates/content/actions/list-notion-links.ts +3 -4
- package/corpus/templates/content/actions/pull-notion-page.ts +7 -9
- package/corpus/templates/content/actions/push-notion-page.ts +7 -9
- package/corpus/templates/content/actions/refresh-notion-sync-status.ts +24 -0
- package/corpus/templates/content/actions/resolve-notion-sync-conflict.ts +23 -0
- package/corpus/templates/content/actions/search-notion-pages.ts +67 -0
- package/corpus/templates/content/actions/unlink-notion-page.ts +23 -0
- package/corpus/templates/content/app/components/editor/DocumentDatabase.tsx +27 -34
- package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +16 -13
- package/corpus/templates/content/app/components/editor/DocumentToolbar.tsx +10 -10
- package/corpus/templates/content/app/components/editor/NotionConflictBanner.tsx +1 -1
- package/corpus/templates/content/app/components/editor/NotionSyncBar.tsx +18 -9
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +27 -34
- package/corpus/templates/content/app/components/editor/database/navigation-state.ts +10 -4
- package/corpus/templates/content/app/components/sidebar/NotionButton.tsx +32 -17
- package/corpus/templates/content/app/hooks/use-content-database.ts +35 -0
- package/corpus/templates/content/app/hooks/use-notion.ts +108 -99
- package/corpus/templates/content/package.json +3 -0
- package/corpus/templates/content/parity/README.md +69 -0
- package/corpus/templates/content/parity/eval-scenarios.ts +118 -0
- package/corpus/templates/content/parity/exceptions.allowlist.ts +17 -0
- package/corpus/templates/content/parity/matrix.md +28 -0
- package/corpus/templates/content/parity/matrix.ts +606 -0
- package/corpus/templates/content/parity/matrix.types.ts +42 -0
- package/corpus/templates/content/parity/parity-evals.eval.ts +4 -0
- package/corpus/templates/content/parity/render-matrix.ts +90 -0
- package/corpus/templates/content/parity/scenario-to-eval.ts +57 -0
- package/corpus/templates/content/shared/api.ts +11 -0
- package/corpus/templates/design/actions/apply-motion-edit.ts +50 -18
- package/corpus/templates/design/actions/get-motion-timeline.ts +4 -14
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +156 -12
- package/corpus/templates/design/app/components/design/MotionDock.tsx +2 -3
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +217 -75
- package/corpus/templates/design/app/components/design/QuestionFlow.tsx +39 -39
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +558 -37
- package/corpus/templates/design/app/components/design/bridge/hit-test.bridge.ts +75 -3
- package/corpus/templates/design/app/components/design/types.ts +13 -0
- package/corpus/templates/design/app/components/layout/Layout.tsx +1 -0
- package/corpus/templates/design/app/i18n/zh-TW.ts +17 -0
- package/corpus/templates/design/app/i18n-data.ts +245 -0
- package/corpus/templates/design/app/pages/DesignEditor.tsx +762 -153
- package/corpus/templates/design/changelog/2026-06-30-copying-or-dragging-screen-elements-onto-the-infinite-canvas.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-design-questions-now-use-tighter-editor-typography-and-contr.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-element-drags-can-be-cancelled-with-escape-before-they-commi.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-pending-visual-style-edits-now-warn-before-you-leave-the-edi.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-visual-style-drags-stay-live-while-pending-edits-can-be-appl.md +6 -0
- package/corpus/templates/design/changelog/2026-07-01-design-chat-no-longer-shows-a-redundant-context-tab-above-the-composer.md +6 -0
- package/corpus/templates/design/changelog/2026-07-01-motion-track-creation-no-longer-fails-in-local-editors.md +6 -0
- package/corpus/templates/design/server/plugins/db.ts +10 -0
- package/dist/agent/engine/builder-engine.d.ts.map +1 -1
- package/dist/agent/engine/builder-engine.js +61 -10
- package/dist/agent/engine/builder-engine.js.map +1 -1
- package/dist/agent/run-manager.d.ts +8 -7
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +8 -7
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/cli/design-connect.d.ts +2 -0
- package/dist/cli/design-connect.d.ts.map +1 -1
- package/dist/cli/design-connect.js +140 -0
- package/dist/cli/design-connect.js.map +1 -1
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +5 -7
- package/dist/cli/skills.js.map +1 -1
- package/dist/client/AgentPanel.d.ts +5 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +4 -4
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts +3 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +2 -2
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +37 -14
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts +14 -1
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +21 -5
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/eval/define-eval.d.ts.map +1 -1
- package/dist/eval/define-eval.js +2 -1
- package/dist/eval/define-eval.js.map +1 -1
- package/dist/eval/report.d.ts.map +1 -1
- package/dist/eval/report.js +19 -4
- package/dist/eval/report.js.map +1 -1
- package/dist/eval/runner.d.ts.map +1 -1
- package/dist/eval/runner.js +38 -6
- package/dist/eval/runner.js.map +1 -1
- package/dist/eval/types.d.ts +11 -0
- package/dist/eval/types.d.ts.map +1 -1
- package/dist/eval/types.js.map +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +2 -2
- package/dist/observability/routes.d.ts +2 -2
- package/dist/progress/routes.d.ts +1 -1
- package/dist/resources/handlers.d.ts +3 -3
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/templates/workspace-core/.agents/skills/reliable-mutations/SKILL.md +15 -17
- package/docs/content/evals.mdx +34 -12
- package/docs/content/locales/ar-SA/evals.mdx +7 -0
- package/docs/content/locales/de-DE/evals.mdx +8 -0
- package/docs/content/locales/es-ES/evals.mdx +8 -0
- package/docs/content/locales/fr-FR/evals.mdx +8 -0
- package/docs/content/locales/hi-IN/evals.mdx +8 -0
- package/docs/content/locales/ja-JP/evals.mdx +7 -0
- package/docs/content/locales/ko-KR/evals.mdx +7 -0
- package/docs/content/locales/pt-BR/evals.mdx +8 -0
- package/docs/content/locales/zh-CN/evals.mdx +7 -0
- package/docs/content/locales/zh-TW/evals.mdx +7 -0
- package/docs/design/durable-agent-runs.md +34 -35
- package/package.json +1 -1
- package/src/templates/workspace-core/.agents/skills/reliable-mutations/SKILL.md +15 -17
- package/corpus/templates/content/server/routes/api/notion/disconnect.post.ts +0 -12
|
@@ -361,6 +361,191 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
361
361
|
};
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
+
var PORTABLE_STYLE_PROPERTIES = [
|
|
365
|
+
"alignContent",
|
|
366
|
+
"alignItems",
|
|
367
|
+
"alignSelf",
|
|
368
|
+
"aspectRatio",
|
|
369
|
+
"background",
|
|
370
|
+
"backgroundAttachment",
|
|
371
|
+
"backgroundClip",
|
|
372
|
+
"backgroundColor",
|
|
373
|
+
"backgroundImage",
|
|
374
|
+
"backgroundOrigin",
|
|
375
|
+
"backgroundPosition",
|
|
376
|
+
"backgroundRepeat",
|
|
377
|
+
"backgroundSize",
|
|
378
|
+
"border",
|
|
379
|
+
"borderBottom",
|
|
380
|
+
"borderBottomColor",
|
|
381
|
+
"borderBottomLeftRadius",
|
|
382
|
+
"borderBottomRightRadius",
|
|
383
|
+
"borderBottomStyle",
|
|
384
|
+
"borderBottomWidth",
|
|
385
|
+
"borderColor",
|
|
386
|
+
"borderLeft",
|
|
387
|
+
"borderLeftColor",
|
|
388
|
+
"borderLeftStyle",
|
|
389
|
+
"borderLeftWidth",
|
|
390
|
+
"borderRadius",
|
|
391
|
+
"borderRight",
|
|
392
|
+
"borderRightColor",
|
|
393
|
+
"borderRightStyle",
|
|
394
|
+
"borderRightWidth",
|
|
395
|
+
"borderStyle",
|
|
396
|
+
"borderTop",
|
|
397
|
+
"borderTopColor",
|
|
398
|
+
"borderTopLeftRadius",
|
|
399
|
+
"borderTopRightRadius",
|
|
400
|
+
"borderTopStyle",
|
|
401
|
+
"borderTopWidth",
|
|
402
|
+
"borderWidth",
|
|
403
|
+
"boxShadow",
|
|
404
|
+
"boxSizing",
|
|
405
|
+
"color",
|
|
406
|
+
"columnGap",
|
|
407
|
+
"display",
|
|
408
|
+
"filter",
|
|
409
|
+
"flex",
|
|
410
|
+
"flexBasis",
|
|
411
|
+
"flexDirection",
|
|
412
|
+
"flexGrow",
|
|
413
|
+
"flexShrink",
|
|
414
|
+
"flexWrap",
|
|
415
|
+
"font",
|
|
416
|
+
"fontFamily",
|
|
417
|
+
"fontSize",
|
|
418
|
+
"fontStyle",
|
|
419
|
+
"fontWeight",
|
|
420
|
+
"gap",
|
|
421
|
+
"gridAutoColumns",
|
|
422
|
+
"gridAutoFlow",
|
|
423
|
+
"gridAutoRows",
|
|
424
|
+
"gridColumn",
|
|
425
|
+
"gridColumnEnd",
|
|
426
|
+
"gridColumnStart",
|
|
427
|
+
"gridRow",
|
|
428
|
+
"gridRowEnd",
|
|
429
|
+
"gridRowStart",
|
|
430
|
+
"gridTemplateColumns",
|
|
431
|
+
"gridTemplateRows",
|
|
432
|
+
"height",
|
|
433
|
+
"justifyContent",
|
|
434
|
+
"justifyItems",
|
|
435
|
+
"justifySelf",
|
|
436
|
+
"letterSpacing",
|
|
437
|
+
"lineHeight",
|
|
438
|
+
"margin",
|
|
439
|
+
"marginBottom",
|
|
440
|
+
"marginLeft",
|
|
441
|
+
"marginRight",
|
|
442
|
+
"marginTop",
|
|
443
|
+
"maxHeight",
|
|
444
|
+
"maxWidth",
|
|
445
|
+
"minHeight",
|
|
446
|
+
"minWidth",
|
|
447
|
+
"mixBlendMode",
|
|
448
|
+
"objectFit",
|
|
449
|
+
"objectPosition",
|
|
450
|
+
"opacity",
|
|
451
|
+
"order",
|
|
452
|
+
"outline",
|
|
453
|
+
"outlineColor",
|
|
454
|
+
"outlineOffset",
|
|
455
|
+
"outlineStyle",
|
|
456
|
+
"outlineWidth",
|
|
457
|
+
"overflow",
|
|
458
|
+
"overflowX",
|
|
459
|
+
"overflowY",
|
|
460
|
+
"padding",
|
|
461
|
+
"paddingBottom",
|
|
462
|
+
"paddingLeft",
|
|
463
|
+
"paddingRight",
|
|
464
|
+
"paddingTop",
|
|
465
|
+
"placeContent",
|
|
466
|
+
"placeItems",
|
|
467
|
+
"placeSelf",
|
|
468
|
+
"position",
|
|
469
|
+
"rowGap",
|
|
470
|
+
"textAlign",
|
|
471
|
+
"textDecoration",
|
|
472
|
+
"textDecorationColor",
|
|
473
|
+
"textDecorationLine",
|
|
474
|
+
"textDecorationStyle",
|
|
475
|
+
"textShadow",
|
|
476
|
+
"textTransform",
|
|
477
|
+
"transform",
|
|
478
|
+
"transformOrigin",
|
|
479
|
+
"verticalAlign",
|
|
480
|
+
"whiteSpace",
|
|
481
|
+
"width",
|
|
482
|
+
"wordBreak",
|
|
483
|
+
"zIndex",
|
|
484
|
+
];
|
|
485
|
+
|
|
486
|
+
function elementPathFromRoot(root: Element, node: Element): number[] {
|
|
487
|
+
var path = [];
|
|
488
|
+
var current: Element | null = node;
|
|
489
|
+
while (current && current !== root && current.parentElement) {
|
|
490
|
+
var siblings = Array.prototype.slice.call(current.parentElement.children);
|
|
491
|
+
path.unshift(Math.max(0, siblings.indexOf(current)));
|
|
492
|
+
current = current.parentElement;
|
|
493
|
+
}
|
|
494
|
+
return path;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
function collectPortableComputedStyles(
|
|
498
|
+
el: Element | null,
|
|
499
|
+
): Record<string, string> {
|
|
500
|
+
if (!el) return {};
|
|
501
|
+
var cs = window.getComputedStyle(el);
|
|
502
|
+
var styles: Record<string, string> = {};
|
|
503
|
+
PORTABLE_STYLE_PROPERTIES.forEach(function (property) {
|
|
504
|
+
var value = cs[property] || cs.getPropertyValue(property);
|
|
505
|
+
if (typeof value === "string" && value.trim()) {
|
|
506
|
+
styles[property] = value;
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
for (var index = 0; index < cs.length; index += 1) {
|
|
510
|
+
var name = cs.item(index);
|
|
511
|
+
if (name && name.indexOf("--") === 0) {
|
|
512
|
+
var customValue = cs.getPropertyValue(name);
|
|
513
|
+
if (customValue && customValue.trim()) {
|
|
514
|
+
styles[name] = customValue.trim();
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
return styles;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
function collectPortableStyleSnapshot(root: Element | null) {
|
|
522
|
+
if (!root || isDocumentRootElement(root)) return undefined;
|
|
523
|
+
var nodes = [];
|
|
524
|
+
var maxNodes = 80;
|
|
525
|
+
function pushNode(node: Element) {
|
|
526
|
+
if (nodes.length >= maxNodes) return;
|
|
527
|
+
nodes.push({
|
|
528
|
+
sourceId: getSourceId(node) || undefined,
|
|
529
|
+
path: elementPathFromRoot(root, node),
|
|
530
|
+
styles: collectPortableComputedStyles(node),
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
pushNode(root);
|
|
534
|
+
var descendants = Array.prototype.slice.call(root.querySelectorAll("*"));
|
|
535
|
+
for (
|
|
536
|
+
var index = 0;
|
|
537
|
+
index < descendants.length && nodes.length < maxNodes;
|
|
538
|
+
index += 1
|
|
539
|
+
) {
|
|
540
|
+
pushNode(descendants[index]);
|
|
541
|
+
}
|
|
542
|
+
return {
|
|
543
|
+
version: 1,
|
|
544
|
+
rootSourceId: getSourceId(root) || undefined,
|
|
545
|
+
nodes: nodes,
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
|
|
364
549
|
function chromeColorForElement(el: Element | null): string {
|
|
365
550
|
return elementLooksLikeComponent(el)
|
|
366
551
|
? "var(--design-editor-component-color)"
|
|
@@ -562,6 +747,7 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
562
747
|
mixBlendMode: cs.mixBlendMode,
|
|
563
748
|
zIndex: cs.zIndex,
|
|
564
749
|
},
|
|
750
|
+
portableStyleSnapshot: collectPortableStyleSnapshot(el),
|
|
565
751
|
boundingRect: {
|
|
566
752
|
x: rect.x + (window.scrollX || window.pageXOffset || 0),
|
|
567
753
|
y: rect.y + (window.scrollY || window.pageYOffset || 0),
|
|
@@ -992,6 +1178,8 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
992
1178
|
var spacingHandleStateByKey: Record<string, { value: number }> = {};
|
|
993
1179
|
var spacingHandleNodesByKey: Record<string, Element> = {};
|
|
994
1180
|
var spacingOverlayRenderKey = "";
|
|
1181
|
+
var activeDragCancel: (() => boolean) | null = null;
|
|
1182
|
+
var activeCrossScreenStyleSnapshot: unknown | undefined = undefined;
|
|
995
1183
|
var spacingDrag: {
|
|
996
1184
|
key: string;
|
|
997
1185
|
groupKey: string;
|
|
@@ -1026,6 +1214,33 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
1026
1214
|
hideMeasurements();
|
|
1027
1215
|
}
|
|
1028
1216
|
|
|
1217
|
+
function postEditorDragState(active: boolean): void {
|
|
1218
|
+
(window.parent as Window).postMessage(
|
|
1219
|
+
{ type: "agent-native:editor-drag-state", active },
|
|
1220
|
+
"*",
|
|
1221
|
+
);
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
function setActiveDragCancel(cancel: () => boolean): void {
|
|
1225
|
+
activeDragCancel = cancel;
|
|
1226
|
+
postEditorDragState(true);
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
function clearActiveDragCancel(cancel?: () => boolean): void {
|
|
1230
|
+
if (cancel && activeDragCancel !== cancel) return;
|
|
1231
|
+
if (!activeDragCancel) return;
|
|
1232
|
+
activeDragCancel = null;
|
|
1233
|
+
postEditorDragState(false);
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
function cancelActiveBridgeDrag(): boolean {
|
|
1237
|
+
var cancel = activeDragCancel;
|
|
1238
|
+
if (!cancel) return false;
|
|
1239
|
+
activeDragCancel = null;
|
|
1240
|
+
postEditorDragState(false);
|
|
1241
|
+
return cancel();
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1029
1244
|
function removePassiveSelectionOverlays(): void {
|
|
1030
1245
|
passiveSelectionOverlays.forEach(function (overlay) {
|
|
1031
1246
|
if (overlay.parentNode) overlay.parentNode.removeChild(overlay);
|
|
@@ -1779,13 +1994,11 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
1779
1994
|
region: { x: number; y: number; width: number; height: number };
|
|
1780
1995
|
line: { x: number; y: number; width: number; height: number } | undefined;
|
|
1781
1996
|
} | null,
|
|
1782
|
-
|
|
1997
|
+
activeGroupKeys: Record<string, boolean>,
|
|
1783
1998
|
): void {
|
|
1784
1999
|
if (!handle) return;
|
|
1785
2000
|
spacingHandleStateByKey[handle.key] = handle;
|
|
1786
|
-
var highlighted = Boolean(
|
|
1787
|
-
activeGroupKey && handle.groupKey === activeGroupKey,
|
|
1788
|
-
);
|
|
2001
|
+
var highlighted = Boolean(activeGroupKeys[handle.groupKey]);
|
|
1789
2002
|
var lineNode = document.createElement("span");
|
|
1790
2003
|
lineNode.setAttribute("data-agent-native-spacing-line", handle.kind);
|
|
1791
2004
|
lineNode.style.position = "absolute";
|
|
@@ -1845,17 +2058,16 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
1845
2058
|
key: string;
|
|
1846
2059
|
groupKey: string;
|
|
1847
2060
|
kind: string;
|
|
2061
|
+
property?: string;
|
|
1848
2062
|
orientation: string;
|
|
1849
2063
|
} | null)[],
|
|
1850
|
-
|
|
2064
|
+
activeGroupKeys: Record<string, boolean>,
|
|
1851
2065
|
): void {
|
|
1852
2066
|
handles.forEach(function (handle) {
|
|
1853
2067
|
if (!handle) return;
|
|
1854
2068
|
var regionNode = spacingHandleNodesByKey[handle.key];
|
|
1855
2069
|
if (!regionNode) return;
|
|
1856
|
-
var highlighted = Boolean(
|
|
1857
|
-
activeGroupKey && handle.groupKey === activeGroupKey,
|
|
1858
|
-
);
|
|
2070
|
+
var highlighted = Boolean(activeGroupKeys[handle.groupKey]);
|
|
1859
2071
|
(regionNode as HTMLElement).style.background = highlighted
|
|
1860
2072
|
? spacingFill(handle.kind, handle.orientation)
|
|
1861
2073
|
: "transparent";
|
|
@@ -1865,6 +2077,37 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
1865
2077
|
});
|
|
1866
2078
|
}
|
|
1867
2079
|
|
|
2080
|
+
function activeSpacingGroupKeys(
|
|
2081
|
+
handles: ({
|
|
2082
|
+
groupKey: string;
|
|
2083
|
+
kind: string;
|
|
2084
|
+
property: string;
|
|
2085
|
+
} | null)[],
|
|
2086
|
+
activeHandle: {
|
|
2087
|
+
groupKey: string;
|
|
2088
|
+
kind: string;
|
|
2089
|
+
oppositeProperty: string;
|
|
2090
|
+
} | null,
|
|
2091
|
+
): Record<string, boolean> {
|
|
2092
|
+
var activeGroupKeys: Record<string, boolean> = {};
|
|
2093
|
+
if (!activeHandle) return activeGroupKeys;
|
|
2094
|
+
activeGroupKeys[activeHandle.groupKey] = true;
|
|
2095
|
+
if (
|
|
2096
|
+
spacingDrag &&
|
|
2097
|
+
spacingDrag.mirrorOpposite &&
|
|
2098
|
+
activeHandle.kind === "padding" &&
|
|
2099
|
+
activeHandle.oppositeProperty
|
|
2100
|
+
) {
|
|
2101
|
+
handles.forEach(function (handle) {
|
|
2102
|
+
if (!handle) return;
|
|
2103
|
+
if (handle.property === activeHandle.oppositeProperty) {
|
|
2104
|
+
activeGroupKeys[handle.groupKey] = true;
|
|
2105
|
+
}
|
|
2106
|
+
});
|
|
2107
|
+
}
|
|
2108
|
+
return activeGroupKeys;
|
|
2109
|
+
}
|
|
2110
|
+
|
|
1868
2111
|
function updateSpacingOverlay(el: Element | null): void {
|
|
1869
2112
|
if (el && el !== selectedEl) {
|
|
1870
2113
|
hideSpacingOverlay();
|
|
@@ -1880,7 +2123,7 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
1880
2123
|
return;
|
|
1881
2124
|
}
|
|
1882
2125
|
var activeHandle = spacingDrag ? spacingDrag.handle : null;
|
|
1883
|
-
var
|
|
2126
|
+
var activeGroupKeys = activeSpacingGroupKeys(handles, activeHandle);
|
|
1884
2127
|
var nextRenderKey = handles
|
|
1885
2128
|
.map(function (handle) {
|
|
1886
2129
|
return [
|
|
@@ -1901,7 +2144,7 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
1901
2144
|
spacingOverlay.style.display === "block" &&
|
|
1902
2145
|
spacingOverlayRenderKey === nextRenderKey
|
|
1903
2146
|
) {
|
|
1904
|
-
updateSpacingHandleHighlights(handles,
|
|
2147
|
+
updateSpacingHandleHighlights(handles, activeGroupKeys);
|
|
1905
2148
|
if (activeHandle) {
|
|
1906
2149
|
showSpacingBadgeForHandle(
|
|
1907
2150
|
activeHandle,
|
|
@@ -1918,7 +2161,7 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
1918
2161
|
spacingHandleStateByKey = {};
|
|
1919
2162
|
spacingHandleNodesByKey = {};
|
|
1920
2163
|
handles.forEach(function (handle) {
|
|
1921
|
-
renderSpacingHandle(handle,
|
|
2164
|
+
renderSpacingHandle(handle, activeGroupKeys);
|
|
1922
2165
|
});
|
|
1923
2166
|
if (activeHandle) {
|
|
1924
2167
|
showSpacingBadgeForHandle(
|
|
@@ -1940,10 +2183,25 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
1940
2183
|
: "";
|
|
1941
2184
|
}
|
|
1942
2185
|
|
|
2186
|
+
function setHoverToSelectedElementFromSpacingSurface(): void {
|
|
2187
|
+
if (!selectedEl || !document.documentElement.contains(selectedEl)) return;
|
|
2188
|
+
var changed = hoveredEl !== selectedEl;
|
|
2189
|
+
hoveredEl = selectedEl;
|
|
2190
|
+
highlightOverlay.style.display = "none";
|
|
2191
|
+
hideMeasurements();
|
|
2192
|
+
if (changed) {
|
|
2193
|
+
(window.parent as Window).postMessage(
|
|
2194
|
+
{ type: "element-hover", payload: getElementInfo(selectedEl) },
|
|
2195
|
+
"*",
|
|
2196
|
+
);
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
|
|
1943
2200
|
function activateSpacingHandle(spacingKey: string): void {
|
|
1944
2201
|
if (!spacingKey) return;
|
|
1945
2202
|
clearSpacingHoverTimer();
|
|
1946
2203
|
selectedSpacingHovered = true;
|
|
2204
|
+
setHoverToSelectedElementFromSpacingSurface();
|
|
1947
2205
|
if (
|
|
1948
2206
|
hoveredSpacingHandleKey !== spacingKey ||
|
|
1949
2207
|
spacingOverlay.style.display !== "block"
|
|
@@ -1992,6 +2250,7 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
1992
2250
|
? region.getAttribute("data-spacing-key")
|
|
1993
2251
|
: "";
|
|
1994
2252
|
if (spacingKey) activateSpacingHandle(spacingKey);
|
|
2253
|
+
setHoverToSelectedElementFromSpacingSurface();
|
|
1995
2254
|
return true;
|
|
1996
2255
|
}
|
|
1997
2256
|
var hit = elementFromEditorPoint(clientX, clientY);
|
|
@@ -3103,6 +3362,10 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3103
3362
|
var events = dragEventNames(e);
|
|
3104
3363
|
var dragEl = selectedEl;
|
|
3105
3364
|
var originValue = handle.value;
|
|
3365
|
+
var originInlineValue = (dragEl as HTMLElement).style[handle.property];
|
|
3366
|
+
var originInlineOppositeValue = handle.oppositeProperty
|
|
3367
|
+
? (dragEl as HTMLElement).style[handle.oppositeProperty]
|
|
3368
|
+
: "";
|
|
3106
3369
|
var startX = e.clientX;
|
|
3107
3370
|
var startY = e.clientY;
|
|
3108
3371
|
lastSpacingPointerPoint = { x: startX, y: startY };
|
|
@@ -3115,6 +3378,56 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3115
3378
|
};
|
|
3116
3379
|
showSpacingBadgeForHandle(handle, originValue);
|
|
3117
3380
|
|
|
3381
|
+
function updateSpacingDragMirrorState(mirrorOpposite: boolean) {
|
|
3382
|
+
if (!spacingDrag) return;
|
|
3383
|
+
if (spacingDrag.mirrorOpposite === mirrorOpposite) return;
|
|
3384
|
+
spacingDrag = {
|
|
3385
|
+
handle: handle,
|
|
3386
|
+
currentValue: spacingDrag.currentValue,
|
|
3387
|
+
mirrorOpposite: mirrorOpposite,
|
|
3388
|
+
};
|
|
3389
|
+
positionOverlay(selectionOverlay, dragEl);
|
|
3390
|
+
showSpacingBadgeForHandle(handle, spacingDrag.currentValue);
|
|
3391
|
+
}
|
|
3392
|
+
|
|
3393
|
+
function cleanupSpacingDrag() {
|
|
3394
|
+
document.removeEventListener(events.move, onMove, true);
|
|
3395
|
+
document.removeEventListener(events.up, onUp, true);
|
|
3396
|
+
document.removeEventListener("keydown", onKey, true);
|
|
3397
|
+
document.removeEventListener("keyup", onKey, true);
|
|
3398
|
+
clearActiveDragCancel(cancelSpacingDrag);
|
|
3399
|
+
}
|
|
3400
|
+
|
|
3401
|
+
function restoreSpacingDragValue() {
|
|
3402
|
+
if (dragEl && document.documentElement.contains(dragEl)) {
|
|
3403
|
+
(dragEl as HTMLElement).style[handle.property] = originInlineValue;
|
|
3404
|
+
if (handle.oppositeProperty) {
|
|
3405
|
+
(dragEl as HTMLElement).style[handle.oppositeProperty] =
|
|
3406
|
+
originInlineOppositeValue;
|
|
3407
|
+
}
|
|
3408
|
+
selectedEl = dragEl;
|
|
3409
|
+
positionOverlay(selectionOverlay, dragEl);
|
|
3410
|
+
}
|
|
3411
|
+
spacingDrag = null;
|
|
3412
|
+
spacingBadge.style.display = "none";
|
|
3413
|
+
}
|
|
3414
|
+
|
|
3415
|
+
function cancelSpacingDrag() {
|
|
3416
|
+
cleanupSpacingDrag();
|
|
3417
|
+
restoreSpacingDragValue();
|
|
3418
|
+
return true;
|
|
3419
|
+
}
|
|
3420
|
+
|
|
3421
|
+
function onKey(ev) {
|
|
3422
|
+
if (ev.key === "Escape") {
|
|
3423
|
+
stopNativeInteraction(ev);
|
|
3424
|
+
cancelSpacingDrag();
|
|
3425
|
+
return;
|
|
3426
|
+
}
|
|
3427
|
+
if (ev.key !== "Alt") return;
|
|
3428
|
+
updateSpacingDragMirrorState(!!ev.altKey);
|
|
3429
|
+
}
|
|
3430
|
+
|
|
3118
3431
|
function onMove(ev) {
|
|
3119
3432
|
if (!dragEl || !document.documentElement.contains(dragEl)) return;
|
|
3120
3433
|
var nextValue = spacingValueFromPointer(
|
|
@@ -3137,10 +3450,10 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3137
3450
|
}
|
|
3138
3451
|
|
|
3139
3452
|
function onUp(ev) {
|
|
3140
|
-
|
|
3141
|
-
document.removeEventListener(events.up, onUp, true);
|
|
3453
|
+
cleanupSpacingDrag();
|
|
3142
3454
|
if (!dragEl || !document.documentElement.contains(dragEl)) {
|
|
3143
3455
|
spacingDrag = null;
|
|
3456
|
+
spacingBadge.style.display = "none";
|
|
3144
3457
|
return;
|
|
3145
3458
|
}
|
|
3146
3459
|
var finalValue = spacingDrag ? spacingDrag.currentValue : originValue;
|
|
@@ -3165,6 +3478,9 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3165
3478
|
|
|
3166
3479
|
document.addEventListener(events.move, onMove, true);
|
|
3167
3480
|
document.addEventListener(events.up, onUp, true);
|
|
3481
|
+
document.addEventListener("keydown", onKey, true);
|
|
3482
|
+
document.addEventListener("keyup", onKey, true);
|
|
3483
|
+
setActiveDragCancel(cancelSpacingDrag);
|
|
3168
3484
|
}
|
|
3169
3485
|
|
|
3170
3486
|
function postTextContentChange(el, value, html) {
|
|
@@ -3342,6 +3658,55 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3342
3658
|
);
|
|
3343
3659
|
}
|
|
3344
3660
|
|
|
3661
|
+
function isAbsolutePrimitiveContainer(el: Element | null): boolean {
|
|
3662
|
+
if (!el || (el.tagName || "").toLowerCase() !== "div") return false;
|
|
3663
|
+
var primitive = (
|
|
3664
|
+
el.getAttribute("data-an-primitive") ||
|
|
3665
|
+
el.getAttribute("data-agent-native-primitive") ||
|
|
3666
|
+
""
|
|
3667
|
+
).toLowerCase();
|
|
3668
|
+
if (primitive !== "rectangle" && primitive !== "rect") return false;
|
|
3669
|
+
var cs = window.getComputedStyle(el);
|
|
3670
|
+
return cs.position === "absolute" || cs.position === "fixed";
|
|
3671
|
+
}
|
|
3672
|
+
|
|
3673
|
+
function absolutePrimitiveContainerTargetForPoint(
|
|
3674
|
+
el: Element | null,
|
|
3675
|
+
clientX: number,
|
|
3676
|
+
clientY: number,
|
|
3677
|
+
) {
|
|
3678
|
+
var hits: Element[] = document.elementsFromPoint
|
|
3679
|
+
? document.elementsFromPoint(clientX, clientY)
|
|
3680
|
+
: ([document.elementFromPoint(clientX, clientY)] as Element[]);
|
|
3681
|
+
var seen: Element[] = [];
|
|
3682
|
+
for (var i = 0; i < hits.length; i += 1) {
|
|
3683
|
+
var cursor: Element | null = hits[i];
|
|
3684
|
+
var candidate: Element | null = null;
|
|
3685
|
+
while (cursor && cursor !== document.body) {
|
|
3686
|
+
if (isAbsolutePrimitiveContainer(cursor)) {
|
|
3687
|
+
candidate = cursor;
|
|
3688
|
+
break;
|
|
3689
|
+
}
|
|
3690
|
+
cursor = cursor.parentElement;
|
|
3691
|
+
}
|
|
3692
|
+
if (!candidate || seen.indexOf(candidate) !== -1) continue;
|
|
3693
|
+
seen.push(candidate);
|
|
3694
|
+
if (candidate === el) continue;
|
|
3695
|
+
if (el && el.contains && el.contains(candidate)) continue;
|
|
3696
|
+
if (el && candidate.contains && candidate.contains(el)) continue;
|
|
3697
|
+
if (isOverlayElement(candidate) || isLayerInteractionBlocked(candidate)) {
|
|
3698
|
+
continue;
|
|
3699
|
+
}
|
|
3700
|
+
return {
|
|
3701
|
+
anchor: candidate,
|
|
3702
|
+
placement: "inside",
|
|
3703
|
+
axis: "y",
|
|
3704
|
+
dropMode: "absolute-container",
|
|
3705
|
+
};
|
|
3706
|
+
}
|
|
3707
|
+
return null;
|
|
3708
|
+
}
|
|
3709
|
+
|
|
3345
3710
|
function isOutsideIframeViewport(clientX: number, clientY: number): boolean {
|
|
3346
3711
|
return (
|
|
3347
3712
|
clientX < 0 ||
|
|
@@ -3357,12 +3722,16 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3357
3722
|
ev?: { clientX?: number; clientY?: number } | null,
|
|
3358
3723
|
): void {
|
|
3359
3724
|
if (phase === "cancel") {
|
|
3725
|
+
activeCrossScreenStyleSnapshot = undefined;
|
|
3360
3726
|
(window.parent as Window).postMessage(
|
|
3361
3727
|
{ type: "agent-native:cross-screen-drag", phase: "cancel" },
|
|
3362
3728
|
"*",
|
|
3363
3729
|
);
|
|
3364
3730
|
return;
|
|
3365
3731
|
}
|
|
3732
|
+
if (phase === "start") {
|
|
3733
|
+
activeCrossScreenStyleSnapshot = collectPortableStyleSnapshot(el ?? null);
|
|
3734
|
+
}
|
|
3366
3735
|
var rect = el ? el.getBoundingClientRect() : null;
|
|
3367
3736
|
var pointerOffset =
|
|
3368
3737
|
rect && ev?.clientX !== undefined && ev.clientY !== undefined
|
|
@@ -3392,9 +3761,13 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3392
3761
|
}
|
|
3393
3762
|
: undefined,
|
|
3394
3763
|
pointerOffset,
|
|
3764
|
+
styleSnapshot: activeCrossScreenStyleSnapshot,
|
|
3395
3765
|
},
|
|
3396
3766
|
"*",
|
|
3397
3767
|
);
|
|
3768
|
+
if (phase === "end") {
|
|
3769
|
+
activeCrossScreenStyleSnapshot = undefined;
|
|
3770
|
+
}
|
|
3398
3771
|
}
|
|
3399
3772
|
|
|
3400
3773
|
// keep in sync with EditPanel.tsx CONTAINER_TAGS/LEAF_TAGS (~line 1679)
|
|
@@ -3533,9 +3906,17 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3533
3906
|
anchor: hit,
|
|
3534
3907
|
placement: "inside",
|
|
3535
3908
|
axis: parentFlowAxis(hit),
|
|
3909
|
+
dropMode: isAbsolutePrimitiveContainer(hit)
|
|
3910
|
+
? "absolute-container"
|
|
3911
|
+
: "flow-insert",
|
|
3536
3912
|
};
|
|
3537
3913
|
}
|
|
3538
|
-
return {
|
|
3914
|
+
return {
|
|
3915
|
+
anchor: hit,
|
|
3916
|
+
placement: edgePlacement,
|
|
3917
|
+
axis: edgeAxis,
|
|
3918
|
+
dropMode: "flow-insert",
|
|
3919
|
+
};
|
|
3539
3920
|
}
|
|
3540
3921
|
var hitParent = hit.parentElement;
|
|
3541
3922
|
if (hitParent) {
|
|
@@ -3550,6 +3931,7 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3550
3931
|
anchor: hit,
|
|
3551
3932
|
placement: hitPointer < hitCenter ? "before" : "after",
|
|
3552
3933
|
axis: hitAxis,
|
|
3934
|
+
dropMode: "flow-insert",
|
|
3553
3935
|
};
|
|
3554
3936
|
}
|
|
3555
3937
|
}
|
|
@@ -3572,7 +3954,12 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3572
3954
|
}
|
|
3573
3955
|
var anchor = beforeTarget || siblings[siblings.length - 1];
|
|
3574
3956
|
var placement = beforeTarget ? "before" : "after";
|
|
3575
|
-
return {
|
|
3957
|
+
return {
|
|
3958
|
+
anchor: anchor,
|
|
3959
|
+
placement: placement,
|
|
3960
|
+
axis: axis,
|
|
3961
|
+
dropMode: "flow-insert",
|
|
3962
|
+
};
|
|
3576
3963
|
}
|
|
3577
3964
|
|
|
3578
3965
|
function elementFromEditorPointIgnoring(
|
|
@@ -3621,6 +4008,7 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3621
4008
|
anchor: cursor,
|
|
3622
4009
|
placement: childPointer < childCenter ? "before" : "after",
|
|
3623
4010
|
axis: parentAxis,
|
|
4011
|
+
dropMode: "flow-insert",
|
|
3624
4012
|
};
|
|
3625
4013
|
}
|
|
3626
4014
|
if (isAutoLayoutElement(cursor) && isContainerDropTarget(cursor)) {
|
|
@@ -3628,11 +4016,20 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3628
4016
|
anchor: cursor,
|
|
3629
4017
|
placement: "inside",
|
|
3630
4018
|
axis: parentFlowAxis(cursor),
|
|
4019
|
+
dropMode: "flow-insert",
|
|
4020
|
+
};
|
|
4021
|
+
}
|
|
4022
|
+
if (isAbsolutePrimitiveContainer(cursor)) {
|
|
4023
|
+
return {
|
|
4024
|
+
anchor: cursor,
|
|
4025
|
+
placement: "inside",
|
|
4026
|
+
axis: "y",
|
|
4027
|
+
dropMode: "absolute-container",
|
|
3631
4028
|
};
|
|
3632
4029
|
}
|
|
3633
4030
|
cursor = parent;
|
|
3634
4031
|
}
|
|
3635
|
-
return
|
|
4032
|
+
return absolutePrimitiveContainerTargetForPoint(el, clientX, clientY);
|
|
3636
4033
|
}
|
|
3637
4034
|
|
|
3638
4035
|
function showInsertionGuideFor(target) {
|
|
@@ -3709,6 +4106,9 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3709
4106
|
anchorSelector: getSelector(target.anchor),
|
|
3710
4107
|
anchorSourceId: getSourceId(target.anchor),
|
|
3711
4108
|
placement: target.placement,
|
|
4109
|
+
dropMode: target.dropMode || "flow-insert",
|
|
4110
|
+
sourceRect: rectInfoForElement(el),
|
|
4111
|
+
anchorRect: rectInfoForElement(target.anchor),
|
|
3712
4112
|
payload: getElementInfo(el),
|
|
3713
4113
|
},
|
|
3714
4114
|
"*",
|
|
@@ -3772,6 +4172,12 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3772
4172
|
var pointerOutsideIframe = false;
|
|
3773
4173
|
var reorderSelector = getSelector(reorderEl);
|
|
3774
4174
|
var reorderSourceId = getSourceId(reorderEl);
|
|
4175
|
+
var reorderStyleSnapshot = collectPortableStyleSnapshot(reorderEl);
|
|
4176
|
+
var reorderRect = reorderEl.getBoundingClientRect();
|
|
4177
|
+
var reorderPointerOffset = {
|
|
4178
|
+
x: e.clientX - reorderRect.left,
|
|
4179
|
+
y: e.clientY - reorderRect.top,
|
|
4180
|
+
};
|
|
3775
4181
|
function onReorderMove(ev) {
|
|
3776
4182
|
var vw = window.innerWidth;
|
|
3777
4183
|
var vh = window.innerHeight;
|
|
@@ -3791,6 +4197,8 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3791
4197
|
iframeY: cy,
|
|
3792
4198
|
viewportW: vw,
|
|
3793
4199
|
viewportH: vh,
|
|
4200
|
+
pointerOffset: reorderPointerOffset,
|
|
4201
|
+
styleSnapshot: reorderStyleSnapshot,
|
|
3794
4202
|
},
|
|
3795
4203
|
"*",
|
|
3796
4204
|
);
|
|
@@ -3806,10 +4214,14 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3806
4214
|
showTransformBadge(currentTarget ? "Move layer" : "Move", cx, cy);
|
|
3807
4215
|
}
|
|
3808
4216
|
}
|
|
3809
|
-
function
|
|
4217
|
+
function cleanupReorderDrag() {
|
|
3810
4218
|
document.removeEventListener(events.move, onReorderMove, true);
|
|
3811
4219
|
document.removeEventListener(events.up, onReorderUp, true);
|
|
3812
4220
|
document.removeEventListener("keydown", onReorderKeyDown, true);
|
|
4221
|
+
clearActiveDragCancel(onReorderEscape);
|
|
4222
|
+
}
|
|
4223
|
+
function onReorderEscape() {
|
|
4224
|
+
cleanupReorderDrag();
|
|
3813
4225
|
hideTransformBadge();
|
|
3814
4226
|
hideInsertionGuide();
|
|
3815
4227
|
(window.parent as Window).postMessage(
|
|
@@ -3828,19 +4240,17 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3828
4240
|
positionOverlay(selectionOverlay, selectedEl);
|
|
3829
4241
|
postElementSelect(selectedEl);
|
|
3830
4242
|
}
|
|
4243
|
+
suppressNextShieldClickBriefly();
|
|
4244
|
+
return true;
|
|
3831
4245
|
}
|
|
3832
4246
|
function onReorderKeyDown(ev) {
|
|
3833
4247
|
if (ev.key === "Escape") {
|
|
3834
|
-
ev
|
|
3835
|
-
ev.stopPropagation();
|
|
3836
|
-
if (ev.stopImmediatePropagation) ev.stopImmediatePropagation();
|
|
4248
|
+
stopNativeInteraction(ev);
|
|
3837
4249
|
onReorderEscape();
|
|
3838
4250
|
}
|
|
3839
4251
|
}
|
|
3840
4252
|
function onReorderUp(ev) {
|
|
3841
|
-
|
|
3842
|
-
document.removeEventListener(events.up, onReorderUp, true);
|
|
3843
|
-
document.removeEventListener("keydown", onReorderKeyDown, true);
|
|
4253
|
+
cleanupReorderDrag();
|
|
3844
4254
|
hideTransformBadge();
|
|
3845
4255
|
hideInsertionGuide();
|
|
3846
4256
|
var vw = window.innerWidth;
|
|
@@ -3859,6 +4269,8 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3859
4269
|
iframeY: cy,
|
|
3860
4270
|
viewportW: vw,
|
|
3861
4271
|
viewportH: vh,
|
|
4272
|
+
pointerOffset: reorderPointerOffset,
|
|
4273
|
+
styleSnapshot: reorderStyleSnapshot,
|
|
3862
4274
|
},
|
|
3863
4275
|
"*",
|
|
3864
4276
|
);
|
|
@@ -3911,14 +4323,15 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3911
4323
|
document.addEventListener(events.move, onReorderMove, true);
|
|
3912
4324
|
document.addEventListener(events.up, onReorderUp, true);
|
|
3913
4325
|
document.addEventListener("keydown", onReorderKeyDown, true);
|
|
4326
|
+
setActiveDragCancel(onReorderEscape);
|
|
3914
4327
|
return;
|
|
3915
4328
|
}
|
|
3916
|
-
ensurePositionable(selectedEl);
|
|
3917
|
-
var cs = window.getComputedStyle(selectedEl);
|
|
3918
4329
|
var originalInlinePosition = (selectedEl as HTMLElement).style.position;
|
|
3919
4330
|
var originalInlineLeft = (selectedEl as HTMLElement).style.left;
|
|
3920
4331
|
var originalInlineTop = (selectedEl as HTMLElement).style.top;
|
|
3921
4332
|
var originalInlineOpacity = (selectedEl as HTMLElement).style.opacity;
|
|
4333
|
+
ensurePositionable(selectedEl);
|
|
4334
|
+
var cs = window.getComputedStyle(selectedEl);
|
|
3922
4335
|
var originLeft = readPx((selectedEl as HTMLElement).style.left || cs.left);
|
|
3923
4336
|
var originTop = readPx(selectedEl.style.top || cs.top);
|
|
3924
4337
|
var startX = e.clientX;
|
|
@@ -3981,9 +4394,39 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
3981
4394
|
selectedEl = originalSelectedEl;
|
|
3982
4395
|
positionOverlay(selectionOverlay, selectedEl);
|
|
3983
4396
|
}
|
|
3984
|
-
function
|
|
4397
|
+
function cleanupMoveDrag() {
|
|
3985
4398
|
document.removeEventListener(events.move, onMove, true);
|
|
3986
4399
|
document.removeEventListener(events.up, onUp, true);
|
|
4400
|
+
document.removeEventListener("keydown", onMoveKeyDown, true);
|
|
4401
|
+
clearActiveDragCancel(cancelMoveDrag);
|
|
4402
|
+
}
|
|
4403
|
+
function cancelMoveDrag() {
|
|
4404
|
+
cleanupMoveDrag();
|
|
4405
|
+
hideTransformBadge();
|
|
4406
|
+
hideInsertionGuide();
|
|
4407
|
+
currentAutoLayoutTarget = null;
|
|
4408
|
+
if (duplicatedForDrag) {
|
|
4409
|
+
if (dragEl && dragEl.parentElement) {
|
|
4410
|
+
dragEl.parentElement.removeChild(dragEl);
|
|
4411
|
+
}
|
|
4412
|
+
selectedEl = originalSelectedEl;
|
|
4413
|
+
positionOverlay(selectionOverlay, selectedEl);
|
|
4414
|
+
postElementSelect(selectedEl);
|
|
4415
|
+
} else if (dragEl && document.documentElement.contains(dragEl)) {
|
|
4416
|
+
restoreSourceDragPosition();
|
|
4417
|
+
postCrossScreenDrag("cancel");
|
|
4418
|
+
}
|
|
4419
|
+
suppressNextShieldClickBriefly();
|
|
4420
|
+
refreshOverlays();
|
|
4421
|
+
return true;
|
|
4422
|
+
}
|
|
4423
|
+
function onMoveKeyDown(ev) {
|
|
4424
|
+
if (ev.key !== "Escape") return;
|
|
4425
|
+
stopNativeInteraction(ev);
|
|
4426
|
+
cancelMoveDrag();
|
|
4427
|
+
}
|
|
4428
|
+
function onUp(ev) {
|
|
4429
|
+
cleanupMoveDrag();
|
|
3987
4430
|
hideTransformBadge();
|
|
3988
4431
|
hideInsertionGuide();
|
|
3989
4432
|
if (!dragEl) return;
|
|
@@ -4001,6 +4444,16 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
4001
4444
|
restoreSourceDragPosition();
|
|
4002
4445
|
return;
|
|
4003
4446
|
}
|
|
4447
|
+
if (ev && !duplicatedForDrag && !outsideOnDrop) {
|
|
4448
|
+
var finalAutoLayoutTarget = autoLayoutInsertionTargetForPoint(
|
|
4449
|
+
dragEl,
|
|
4450
|
+
ev.clientX,
|
|
4451
|
+
ev.clientY,
|
|
4452
|
+
);
|
|
4453
|
+
if (finalAutoLayoutTarget) {
|
|
4454
|
+
currentAutoLayoutTarget = finalAutoLayoutTarget;
|
|
4455
|
+
}
|
|
4456
|
+
}
|
|
4004
4457
|
if (duplicatedForDrag && !moved) {
|
|
4005
4458
|
// Alt-click with no real drag — remove the premature clone and restore the original selection.
|
|
4006
4459
|
if (dragEl.parentElement) dragEl.parentElement.removeChild(dragEl);
|
|
@@ -4040,6 +4493,8 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
4040
4493
|
}
|
|
4041
4494
|
document.addEventListener(events.move, onMove, true);
|
|
4042
4495
|
document.addEventListener(events.up, onUp, true);
|
|
4496
|
+
document.addEventListener("keydown", onMoveKeyDown, true);
|
|
4497
|
+
setActiveDragCancel(cancelMoveDrag);
|
|
4043
4498
|
}
|
|
4044
4499
|
|
|
4045
4500
|
function startResize(handle, e) {
|
|
@@ -4048,25 +4503,30 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
4048
4503
|
e.preventDefault();
|
|
4049
4504
|
e.stopPropagation();
|
|
4050
4505
|
var events = dragEventNames(e);
|
|
4051
|
-
|
|
4052
|
-
|
|
4506
|
+
// Snapshot the element so a concurrent clear-selection postMessage cannot
|
|
4507
|
+
// cause a null-deref in onMove/onUp.
|
|
4508
|
+
var resizeEl = selectedEl;
|
|
4509
|
+
var originalInlinePosition = resizeEl.style.position;
|
|
4510
|
+
var originalInlineLeft = resizeEl.style.left;
|
|
4511
|
+
var originalInlineTop = resizeEl.style.top;
|
|
4512
|
+
var originalInlineWidth = resizeEl.style.width;
|
|
4513
|
+
var originalInlineHeight = resizeEl.style.height;
|
|
4514
|
+
ensurePositionable(resizeEl);
|
|
4515
|
+
var cs = window.getComputedStyle(resizeEl);
|
|
4053
4516
|
// Bug fix: use CSS width/height (not getBoundingClientRect) for the resize
|
|
4054
4517
|
// origin dimensions so that rotated elements don't use the inflated
|
|
4055
4518
|
// axis-aligned bounding box as the starting size.
|
|
4056
|
-
var originW = readPx(
|
|
4057
|
-
var originH = readPx(
|
|
4519
|
+
var originW = readPx(resizeEl.style.width || cs.width);
|
|
4520
|
+
var originH = readPx(resizeEl.style.height || cs.height);
|
|
4058
4521
|
var origin = {
|
|
4059
|
-
left: readPx(
|
|
4060
|
-
top: readPx(
|
|
4522
|
+
left: readPx(resizeEl.style.left || cs.left),
|
|
4523
|
+
top: readPx(resizeEl.style.top || cs.top),
|
|
4061
4524
|
width: originW,
|
|
4062
4525
|
height: originH,
|
|
4063
4526
|
ratio: originW / Math.max(1, originH),
|
|
4064
4527
|
};
|
|
4065
4528
|
var startX = e.clientX;
|
|
4066
4529
|
var startY = e.clientY;
|
|
4067
|
-
// Snapshot the element so a concurrent clear-selection postMessage cannot
|
|
4068
|
-
// cause a null-deref in onMove/onUp.
|
|
4069
|
-
var resizeEl = selectedEl;
|
|
4070
4530
|
// Capture the element rotation once at drag-start so per-move projection is
|
|
4071
4531
|
// cheap and consistent even if the transform changes during the drag.
|
|
4072
4532
|
var resizeTheta = (currentRotation(resizeEl) * Math.PI) / 180;
|
|
@@ -4163,9 +4623,35 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
4163
4623
|
);
|
|
4164
4624
|
refreshOverlays();
|
|
4165
4625
|
}
|
|
4166
|
-
function
|
|
4626
|
+
function cleanupResizeDrag() {
|
|
4167
4627
|
document.removeEventListener(events.move, onMove, true);
|
|
4168
4628
|
document.removeEventListener(events.up, onUp, true);
|
|
4629
|
+
document.removeEventListener("keydown", onResizeKeyDown, true);
|
|
4630
|
+
clearActiveDragCancel(cancelResizeDrag);
|
|
4631
|
+
}
|
|
4632
|
+
function cancelResizeDrag() {
|
|
4633
|
+
cleanupResizeDrag();
|
|
4634
|
+
hideTransformBadge();
|
|
4635
|
+
if (resizeEl && document.documentElement.contains(resizeEl)) {
|
|
4636
|
+
resizeEl.style.position = originalInlinePosition;
|
|
4637
|
+
resizeEl.style.left = originalInlineLeft;
|
|
4638
|
+
resizeEl.style.top = originalInlineTop;
|
|
4639
|
+
resizeEl.style.width = originalInlineWidth;
|
|
4640
|
+
resizeEl.style.height = originalInlineHeight;
|
|
4641
|
+
selectedEl = resizeEl;
|
|
4642
|
+
positionOverlay(selectionOverlay, selectedEl);
|
|
4643
|
+
}
|
|
4644
|
+
suppressNextShieldClickBriefly();
|
|
4645
|
+
refreshOverlays();
|
|
4646
|
+
return true;
|
|
4647
|
+
}
|
|
4648
|
+
function onResizeKeyDown(ev) {
|
|
4649
|
+
if (ev.key !== "Escape") return;
|
|
4650
|
+
stopNativeInteraction(ev);
|
|
4651
|
+
cancelResizeDrag();
|
|
4652
|
+
}
|
|
4653
|
+
function onUp() {
|
|
4654
|
+
cleanupResizeDrag();
|
|
4169
4655
|
hideTransformBadge();
|
|
4170
4656
|
if (!resizeEl) return;
|
|
4171
4657
|
(window.parent as Window).postMessage(
|
|
@@ -4186,6 +4672,8 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
4186
4672
|
}
|
|
4187
4673
|
document.addEventListener(events.move, onMove, true);
|
|
4188
4674
|
document.addEventListener(events.up, onUp, true);
|
|
4675
|
+
document.addEventListener("keydown", onResizeKeyDown, true);
|
|
4676
|
+
setActiveDragCancel(cancelResizeDrag);
|
|
4189
4677
|
}
|
|
4190
4678
|
|
|
4191
4679
|
function startRotate(e) {
|
|
@@ -4207,6 +4695,7 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
4207
4695
|
// Snapshot so a concurrent clear-selection postMessage cannot cause a
|
|
4208
4696
|
// null-deref in onMove/onUp.
|
|
4209
4697
|
var rotateEl = selectedEl;
|
|
4698
|
+
var originalInlineTransform = rotateEl.style.transform;
|
|
4210
4699
|
function onMove(ev) {
|
|
4211
4700
|
if (!rotateEl) return;
|
|
4212
4701
|
var pointerAngle =
|
|
@@ -4219,9 +4708,31 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
4219
4708
|
showTransformBadge(next + "deg", ev.clientX, ev.clientY);
|
|
4220
4709
|
refreshOverlays();
|
|
4221
4710
|
}
|
|
4222
|
-
function
|
|
4711
|
+
function cleanupRotateDrag() {
|
|
4223
4712
|
document.removeEventListener(events.move, onMove, true);
|
|
4224
4713
|
document.removeEventListener(events.up, onUp, true);
|
|
4714
|
+
document.removeEventListener("keydown", onRotateKeyDown, true);
|
|
4715
|
+
clearActiveDragCancel(cancelRotateDrag);
|
|
4716
|
+
}
|
|
4717
|
+
function cancelRotateDrag() {
|
|
4718
|
+
cleanupRotateDrag();
|
|
4719
|
+
hideTransformBadge();
|
|
4720
|
+
if (rotateEl && document.documentElement.contains(rotateEl)) {
|
|
4721
|
+
rotateEl.style.transform = originalInlineTransform;
|
|
4722
|
+
selectedEl = rotateEl;
|
|
4723
|
+
positionOverlay(selectionOverlay, selectedEl);
|
|
4724
|
+
}
|
|
4725
|
+
suppressNextShieldClickBriefly();
|
|
4726
|
+
refreshOverlays();
|
|
4727
|
+
return true;
|
|
4728
|
+
}
|
|
4729
|
+
function onRotateKeyDown(ev) {
|
|
4730
|
+
if (ev.key !== "Escape") return;
|
|
4731
|
+
stopNativeInteraction(ev);
|
|
4732
|
+
cancelRotateDrag();
|
|
4733
|
+
}
|
|
4734
|
+
function onUp() {
|
|
4735
|
+
cleanupRotateDrag();
|
|
4225
4736
|
hideTransformBadge();
|
|
4226
4737
|
if (!rotateEl) return;
|
|
4227
4738
|
(window.parent as Window).postMessage(
|
|
@@ -4236,6 +4747,8 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
4236
4747
|
}
|
|
4237
4748
|
document.addEventListener(events.move, onMove, true);
|
|
4238
4749
|
document.addEventListener(events.up, onUp, true);
|
|
4750
|
+
document.addEventListener("keydown", onRotateKeyDown, true);
|
|
4751
|
+
setActiveDragCancel(cancelRotateDrag);
|
|
4239
4752
|
}
|
|
4240
4753
|
|
|
4241
4754
|
function clearPendingShieldDrag() {
|
|
@@ -4432,6 +4945,10 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
4432
4945
|
"keydown",
|
|
4433
4946
|
function (e) {
|
|
4434
4947
|
if (!shouldForwardDesignHotkey(e)) return;
|
|
4948
|
+
if (e.key === "Escape" && cancelActiveBridgeDrag()) {
|
|
4949
|
+
stopNativeInteraction(e);
|
|
4950
|
+
return;
|
|
4951
|
+
}
|
|
4435
4952
|
stopNativeInteraction(e);
|
|
4436
4953
|
if (e.key === "Escape") clearRuntimeSelection();
|
|
4437
4954
|
(window.parent as Window).postMessage(
|
|
@@ -4809,6 +5326,10 @@ declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
|
4809
5326
|
scaleToolEnabled = !!e.data.enabled;
|
|
4810
5327
|
return;
|
|
4811
5328
|
}
|
|
5329
|
+
if (e.data.type === "agent-native:cancel-active-drag") {
|
|
5330
|
+
cancelActiveBridgeDrag();
|
|
5331
|
+
return;
|
|
5332
|
+
}
|
|
4812
5333
|
if (e.data.type === "clear-selection") {
|
|
4813
5334
|
// During marquee drag, empty hit sets are replayed back from the host as a
|
|
4814
5335
|
// clear-selection state. Keep the drag-owned rectangle alive until pointer-up.
|