@agent-native/core 0.82.0 → 0.84.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/README.md +2 -2
- package/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +34 -0
- package/corpus/core/README.md +2 -2
- package/corpus/core/docs/content/cloneable-saas.mdx +2 -2
- package/corpus/core/docs/content/faq.mdx +1 -1
- package/corpus/core/docs/content/locales/ar-SA/cloneable-saas.mdx +2 -2
- package/corpus/core/docs/content/locales/ar-SA/faq.mdx +1 -1
- package/corpus/core/docs/content/locales/ar-SA/template-chat.mdx +1 -1
- package/corpus/core/docs/content/locales/de-DE/cloneable-saas.mdx +2 -2
- package/corpus/core/docs/content/locales/de-DE/faq.mdx +1 -1
- package/corpus/core/docs/content/locales/de-DE/template-chat.mdx +1 -1
- package/corpus/core/docs/content/locales/es-ES/cloneable-saas.mdx +2 -2
- package/corpus/core/docs/content/locales/es-ES/faq.mdx +1 -1
- package/corpus/core/docs/content/locales/es-ES/template-chat.mdx +1 -1
- package/corpus/core/docs/content/locales/fr-FR/cloneable-saas.mdx +2 -2
- package/corpus/core/docs/content/locales/fr-FR/faq.mdx +1 -1
- package/corpus/core/docs/content/locales/fr-FR/template-chat.mdx +1 -1
- package/corpus/core/docs/content/locales/hi-IN/cloneable-saas.mdx +2 -2
- package/corpus/core/docs/content/locales/hi-IN/faq.mdx +1 -1
- package/corpus/core/docs/content/locales/hi-IN/template-chat.mdx +1 -1
- package/corpus/core/docs/content/locales/ja-JP/cloneable-saas.mdx +2 -2
- package/corpus/core/docs/content/locales/ja-JP/faq.mdx +1 -1
- package/corpus/core/docs/content/locales/ja-JP/template-chat.mdx +1 -1
- package/corpus/core/docs/content/locales/ko-KR/cloneable-saas.mdx +2 -2
- package/corpus/core/docs/content/locales/ko-KR/faq.mdx +1 -1
- package/corpus/core/docs/content/locales/ko-KR/template-chat.mdx +1 -1
- package/corpus/core/docs/content/locales/pt-BR/cloneable-saas.mdx +2 -2
- package/corpus/core/docs/content/locales/pt-BR/faq.mdx +1 -1
- package/corpus/core/docs/content/locales/pt-BR/template-chat.mdx +1 -1
- package/corpus/core/docs/content/locales/zh-CN/cloneable-saas.mdx +2 -2
- package/corpus/core/docs/content/locales/zh-CN/faq.mdx +1 -1
- package/corpus/core/docs/content/locales/zh-CN/template-chat.mdx +1 -1
- package/corpus/core/docs/content/locales/zh-TW/cloneable-saas.mdx +2 -2
- package/corpus/core/docs/content/locales/zh-TW/faq.mdx +1 -1
- package/corpus/core/docs/content/locales/zh-TW/template-chat.mdx +1 -1
- package/corpus/core/docs/content/template-chat.mdx +1 -1
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/agent/engine/builtin.ts +1 -1
- package/corpus/core/src/agent/engine/output-tokens.ts +1 -1
- package/corpus/core/src/agent/harness/acp-adapter.ts +28 -4
- package/corpus/core/src/agent/harness/ai-sdk-adapter.ts +3 -0
- package/corpus/core/src/agent/harness/translate.ts +3 -0
- package/corpus/core/src/agent/harness/types.ts +1 -0
- package/corpus/core/src/agent/model-config.ts +34 -13
- package/corpus/core/src/agent/production-agent.ts +87 -10
- package/corpus/core/src/agent/thread-data-builder.ts +29 -4
- package/corpus/core/src/agent/tool-call-journal.ts +109 -48
- package/corpus/core/src/agent/types.ts +6 -1
- package/corpus/core/src/cli/design-connect.ts +106 -0
- package/corpus/core/src/cli/gateway-helpers.ts +17 -0
- package/corpus/core/src/cli/recap.ts +0 -2
- package/corpus/core/src/cli/skills.ts +54 -16
- package/corpus/core/src/cli/workspace-dev.ts +29 -5
- package/corpus/core/src/client/AssistantChat.tsx +89 -42
- package/corpus/core/src/client/CommandMenu.tsx +34 -12
- package/corpus/core/src/client/DefaultSpinner.tsx +8 -1
- package/corpus/core/src/client/chat/message-components.tsx +49 -1
- package/corpus/core/src/client/chat/repo-helpers.ts +71 -0
- package/corpus/core/src/client/chat/run-recovery.tsx +15 -5
- package/corpus/core/src/client/components/ApiKeySettings.tsx +8 -8
- package/corpus/core/src/client/components/CodeRequiredDialog.tsx +26 -15
- package/corpus/core/src/client/components/MissingKeyCard.tsx +13 -6
- package/corpus/core/src/client/composer/TiptapComposer.tsx +4 -3
- package/corpus/core/src/client/extensions/ExtensionsSidebarSection.tsx +0 -1
- package/corpus/core/src/client/guided-questions.tsx +21 -27
- package/corpus/core/src/client/integrations/IntegrationCard.tsx +1 -1
- package/corpus/core/src/client/integrations/IntegrationsPanel.tsx +1 -1
- package/corpus/core/src/client/onboarding/OnboardingBanner.tsx +2 -2
- package/corpus/core/src/client/onboarding/OnboardingPanel.tsx +23 -19
- package/corpus/core/src/client/resources/ResourceEditor.tsx +18 -10
- package/corpus/core/src/client/resources/ResourcesPanel.tsx +5 -1
- package/corpus/core/src/client/settings/SettingsPanel.tsx +8 -3
- package/corpus/core/src/client/settings/useBuilderStatus.ts +8 -41
- package/corpus/core/src/client/useProductionAgent.ts +6 -2
- package/corpus/core/src/deploy/build.ts +1 -1
- package/corpus/core/src/observability/traces.ts +3 -3
- package/corpus/core/src/onboarding/default-steps.ts +1 -1
- package/corpus/core/src/scripts/agent-engines/manage-agent-engine.ts +1 -1
- package/corpus/core/src/scripts/agent-engines/set-agent-engine.ts +1 -1
- package/corpus/core/src/server/agent-chat-plugin.ts +177 -81
- package/corpus/core/src/server/core-routes-plugin.ts +7 -1
- package/corpus/core/src/server/open-route.ts +59 -40
- package/corpus/core/src/shared/reasoning-effort.ts +2 -0
- package/corpus/core/src/sharing/access.ts +22 -2
- package/corpus/core/src/sharing/registry.ts +18 -0
- package/corpus/core/src/styles/agent-native.css +104 -20
- package/corpus/core/src/styles/rich-markdown-editor.css +11 -10
- package/corpus/templates/analytics/actions/hubspot-deals.ts +64 -4
- package/corpus/templates/analytics/app/components/dashboard/CumulativeNetChart.tsx +10 -10
- package/corpus/templates/analytics/app/components/dashboard/RevenueChart.tsx +10 -10
- package/corpus/templates/analytics/app/components/dashboard/RevenueComparisonChart.tsx +6 -5
- package/corpus/templates/analytics/app/components/dashboard/TimeSeriesChart.tsx +9 -9
- package/corpus/templates/analytics/app/global.css +4 -0
- package/corpus/templates/analytics/app/lib/chart-theme.ts +13 -0
- package/corpus/templates/analytics/app/pages/adhoc/_shared/KpiChart.tsx +22 -24
- package/corpus/templates/analytics/changelog/2026-06-30-dashboard-charts-now-use-theme-aware-tooltip-and-grid-colors.md +6 -0
- package/corpus/templates/analytics/changelog/2026-06-30-fixed-ask-composer-spacing-so-the-chat-field-has-a-comfortab.md +6 -0
- package/corpus/templates/calendar/AGENTS.md +4 -0
- package/corpus/templates/calendar/actions/connect-google-calendar.ts +80 -0
- package/corpus/templates/calendar/changelog/2026-06-30-calendar-now-gives-the-agent-a-safe-google-connection-link-i.md +6 -0
- package/corpus/templates/calendar/server/plugins/agent-chat.ts +4 -0
- package/corpus/templates/content/.env.local.example +6 -0
- package/corpus/templates/content/AGENTS.md +10 -1
- package/corpus/templates/content/actions/_builder-cms-read-client.ts +14 -1
- package/corpus/templates/content/actions/_builder-cms-source-adapter.ts +43 -0
- package/corpus/templates/content/actions/_builder-cms-write-adapter.ts +79 -7
- package/corpus/templates/content/actions/_database-source-utils.ts +987 -22
- package/corpus/templates/content/actions/_database-utils.ts +41 -0
- package/corpus/templates/content/actions/_local-file-documents.ts +74 -1
- package/corpus/templates/content/actions/attach-content-database-source.ts +33 -8
- package/corpus/templates/content/actions/change-content-database-source-role.ts +14 -0
- package/corpus/templates/content/actions/disconnect-content-database-source.ts +3 -0
- package/corpus/templates/content/actions/execute-builder-source-execution.ts +71 -3
- package/corpus/templates/content/actions/list-content-databases.ts +41 -33
- package/corpus/templates/content/actions/process-builder-body-hydration.ts +47 -0
- package/corpus/templates/content/actions/update-document.ts +93 -0
- package/corpus/templates/content/app/blocks/SourceComponentBlock.tsx +277 -0
- package/corpus/templates/content/app/blocks/contentBlockRegistry.tsx +2 -0
- package/corpus/templates/content/app/components/editor/BubbleToolbar.tsx +5 -5
- package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +45 -4
- package/corpus/templates/content/app/components/editor/VisualEditor.tsx +5 -1
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +92 -0
- package/corpus/templates/content/app/components/editor/database-sources/BuilderSourceReviewDialog.tsx +5 -3
- package/corpus/templates/content/app/components/editor/extensions/registryBlocks.ts +41 -0
- package/corpus/templates/content/app/components/editor/registrySlashItems.ts +4 -0
- package/corpus/templates/content/app/global.css +16 -8
- package/corpus/templates/content/app/hooks/use-content-database.ts +24 -0
- package/corpus/templates/content/app/i18n/zh-TW.ts +24 -0
- package/corpus/templates/content/app/i18n-data.ts +212 -0
- package/corpus/templates/content/app/lib/content-command-search.ts +64 -0
- package/corpus/templates/content/app/root.tsx +236 -8
- package/corpus/templates/content/changelog/2026-06-29-builder-cms-sources-now-sync-article-bodies-through-content.md +6 -0
- package/corpus/templates/content/changelog/2026-06-30-builder-article-media-now-render-as-images-and-embeds-when-r.md +6 -0
- package/corpus/templates/content/changelog/2026-06-30-builder-source-components-now-render-as-preserved-preview-bl.md +6 -0
- package/corpus/templates/content/changelog/2026-06-30-cmd-k-search-now-opens-from-the-editor-and-finds-real-content.md +6 -0
- package/corpus/templates/content/changelog/2026-06-30-editor-floating-toolbars-now-use-theme-aware-colors-in-light.md +6 -0
- package/corpus/templates/content/package.json +3 -1
- package/corpus/templates/content/scripts/check-native-deps.mjs +57 -0
- package/corpus/templates/content/scripts/dev-database.mjs +83 -0
- package/corpus/templates/content/scripts/seed-demo-user.mjs +107 -0
- package/corpus/templates/content/server/db/schema.ts +27 -0
- package/corpus/templates/content/server/plugins/db.ts +33 -0
- package/corpus/templates/content/shared/api.ts +45 -0
- package/corpus/templates/content/shared/builder-mdx.ts +905 -5
- package/corpus/templates/content/shared/nfm-registry.ts +2 -0
- package/corpus/templates/content/shared/source-component-block.ts +141 -0
- package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +6 -1
- package/corpus/templates/design/actions/add-localhost-screens.ts +63 -8
- package/corpus/templates/design/actions/apply-motion-edit.ts +12 -46
- package/corpus/templates/design/actions/list-design-native-assets.ts +2 -1
- package/corpus/templates/design/actions/migrate-board-objects-to-file.ts +49 -1
- package/corpus/templates/design/actions/navigate.ts +3 -12
- package/corpus/templates/design/actions/open-visual-edit.ts +341 -0
- package/corpus/templates/design/actions/view-screen.ts +1 -1
- package/corpus/templates/design/app/components/design/CanvasContextMenu.tsx +1 -1
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +350 -15
- package/corpus/templates/design/app/components/design/DesignEditorSkeleton.tsx +71 -91
- package/corpus/templates/design/app/components/design/DesignExtensionsPanel.tsx +25 -27
- package/corpus/templates/design/app/components/design/DeviceFrame.tsx +1 -1
- package/corpus/templates/design/app/components/design/DrawOverlay.tsx +2 -2
- package/corpus/templates/design/app/components/design/EditPanel.tsx +1111 -570
- package/corpus/templates/design/app/components/design/LayersPanel.tsx +162 -32
- package/corpus/templates/design/app/components/design/MotionDock.tsx +268 -240
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +1193 -207
- package/corpus/templates/design/app/components/design/QuestionFlow.tsx +1 -1
- package/corpus/templates/design/app/components/design/ReviewPanel.tsx +81 -102
- package/corpus/templates/design/app/components/design/StatesPanel.tsx +6 -6
- package/corpus/templates/design/app/components/design/TokensPanel.tsx +11 -11
- package/corpus/templates/design/app/components/design/TweaksPanel.tsx +9 -7
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +1225 -154
- package/corpus/templates/design/app/components/design/bridge/hit-test.bridge.ts +130 -37
- package/corpus/templates/design/app/components/design/canvas-primitive-style.ts +24 -11
- package/corpus/templates/design/app/components/design/inspector/AutoLayoutMatrix.tsx +184 -162
- package/corpus/templates/design/app/components/design/inspector/ConstraintsWidget.tsx +137 -79
- package/corpus/templates/design/app/components/design/inspector/DesignColorPicker.tsx +13 -13
- package/corpus/templates/design/app/components/design/inspector/ExportSettingsPanel.tsx +8 -8
- package/corpus/templates/design/app/components/design/inspector/GradientEditor.tsx +2 -2
- package/corpus/templates/design/app/components/design/inspector/ImageFillControls.tsx +4 -4
- package/corpus/templates/design/app/components/design/inspector/InspectorAiActions.tsx +3 -3
- package/corpus/templates/design/app/components/design/inspector/ScrubInput.tsx +13 -7
- package/corpus/templates/design/app/components/design/inspector/ShaderControls.tsx +14 -11
- package/corpus/templates/design/app/components/design/inspector/ShaderFillsPanel.tsx +4 -4
- package/corpus/templates/design/app/components/design/inspector/index.ts +2 -0
- package/corpus/templates/design/app/components/design/types.ts +19 -0
- package/corpus/templates/design/app/components/editor/PromptDialog.tsx +61 -78
- package/corpus/templates/design/app/components/layout/Header.tsx +0 -1
- package/corpus/templates/design/app/components/layout/Layout.tsx +3 -2
- package/corpus/templates/design/app/components/layout/Sidebar.tsx +0 -2
- package/corpus/templates/design/app/components/visual-editor/CanvasCommentPins.tsx +5 -4
- package/corpus/templates/design/app/components/visual-editor/DrawOverlay.tsx +1 -1
- package/corpus/templates/design/app/components/visual-editor/SaveStatusIndicator.tsx +2 -2
- package/corpus/templates/design/app/global.css +56 -0
- package/corpus/templates/design/app/hooks/use-agent-generating.ts +4 -5
- package/corpus/templates/design/app/hooks/use-navigation-state.ts +6 -7
- package/corpus/templates/design/app/hooks/use-question-flow.ts +3 -2
- package/corpus/templates/design/app/hooks/useAgentEditRequest.ts +6 -4
- package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +6 -3
- package/corpus/templates/design/app/i18n/zh-TW.ts +5 -14
- package/corpus/templates/design/app/i18n-data.ts +63 -188
- package/corpus/templates/design/app/lib/agent-chat.ts +13 -0
- package/corpus/templates/design/app/pages/DesignEditor.tsx +1755 -401
- package/corpus/templates/design/app/pages/DesignSystemSetup.tsx +9 -5
- package/corpus/templates/design/app/pages/DesignSystems.tsx +2 -2
- package/corpus/templates/design/app/pages/Index.tsx +49 -26
- package/corpus/templates/design/app/pages/NotFound.tsx +25 -8
- package/corpus/templates/design/app/pages/VisualEdit.tsx +17 -5
- package/corpus/templates/design/app/routes/examples.tsx +1 -7
- package/corpus/templates/design/app/routes/templates.tsx +7 -4
- package/corpus/templates/design/changelog/2026-06-30-board-shapes-and-auto-layout-controls-are-clearer.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-canvas-editing-now-keeps-undo-redo-and-cross-screen-layer-mo.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-component-selections-now-use-purple-component-chrome-and-sho.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-constraints-now-stay-tucked-into-a-compact-inspector-preview.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-creating-a-component-now-opens-in-a-compact-inspector-popove.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-design-cards-no-longer-show-legacy-project-type-badges.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-design-chat-now-keeps-new-turns-in-the-visible-design-agent-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-design-editor-panels-now-keep-their-compact-text-sizing-cons.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-design-no-longer-shows-the-connected-local-code-warning-bann.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-design-now-opens-to-the-files-panel-unless-a-generation-is-a.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-design-opens-with-a-cleaner-empty-canvas-and-loading-preview.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-design-tools-use-simpler-less-decorative-icons.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-dragging-absolute-elements-no-longer-shows-coordinate-labels.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-fixed-all-screens-opening-too-zoomed-in-by-default.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-fixed-the-public-design-assets-sidebar-so-native-components-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-fixed-the-screen-overview-board-so-empty-board-space-no-long.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-full-view-screens-can-now-scroll-while-remaining-editable.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-inspector-element-headers-show-the-selected-html-tag-and-the.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-inspector-inputs-stay-compact-across-desktop-breakpoints.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-layers-can-be-multi-selected-from-the-canvas-and-edited-toge.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-local-visual-edit-links-can-edit-localhost-frames-without-si.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-localhost-visual-edit-frames-can-now-be-selected-and-edited.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-marquee-selection-now-works-inside-screens-multi-selected-la.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-motion-is-now-available-from-the-persistent-left-rail-and-th.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-motion-timeline-collapse-and-reopen-animations-feel-smoother.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-multi-select-outlines-now-stay-consistent-across-all-screens.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-new-board-shapes-now-start-with-neutral-gray-styling.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-new-designs-open-into-a-steadier-loading-state-before-the-ed.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-new-designs-show-a-loading-state-during-handoff-and-keep-edi.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-public-visual-edit-design-links-now-open-directly-instead-of.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-removed-the-confusing-states-section-from-the-design-editor-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-removed-the-templates-gallery-from-design-navigation.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-share-stays-visible-as-soon-as-editable-designs-load.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-signed-out-save-and-share-controls-use-simpler-labels-and-op.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-text-added-on-the-canvas-now-focuses-cleanly-with-the-right-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-the-design-editor-loading-skeleton-is-simpler-and-its-bottom.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-the-design-editor-loading-skeleton-now-follows-the-current-t.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-the-design-inspector-no-longer-shows-child-layout-controls-o.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-the-design-inspector-no-longer-shows-the-ask-ai-section-abov.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-the-design-review-panel-no-longer-shows-a-separate-inline-au.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-the-empty-designs-page-now-focuses-on-a-single-primary-new-d.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-the-layers-panel-header-stays-as-layers-while-multiple-items.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-the-missing-design-screen-now-uses-a-neutral-back-button.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-the-motion-timeline-now-closes-without-squeezing-the-canvas-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-the-new-design-connect-ai-setup-now-lines-up-with-the-compos.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-the-screen-overview-board-now-blends-into-the-canvas-and-new.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-top-level-canvas-drops-now-show-screen-guides.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-top-level-canvas-layers-now-keep-a-transparent-backdrop-and-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-top-level-canvas-layers-now-select-reliably-from-all-screens.md +6 -0
- package/corpus/templates/design/changelog/2026-06-30-visual-edit-can-open-and-refresh-localhost-screens-in-one-au.md +6 -0
- package/corpus/templates/design/e2e/helpers.ts +15 -4
- package/corpus/templates/design/server/db/index.ts +52 -0
- package/corpus/templates/design/server/plugins/agent-chat.ts +5 -0
- package/corpus/templates/design/server/plugins/auth.ts +1 -0
- package/corpus/templates/design/server/plugins/core-routes.ts +4 -0
- package/corpus/templates/design/shared/board-file.ts +380 -5
- package/corpus/templates/design/shared/board-objects.ts +2 -2
- package/corpus/templates/design/shared/code-layer.ts +50 -6
- package/corpus/templates/design/shared/motion-compiler.ts +27 -0
- package/corpus/templates/macros/app/components/DailyProgress.tsx +41 -37
- package/corpus/templates/macros/app/components/ExerciseCard.tsx +2 -2
- package/corpus/templates/macros/app/components/MealCard.tsx +2 -2
- package/corpus/templates/macros/app/components/VoiceDictation.tsx +1 -1
- package/corpus/templates/macros/app/components/WeeklyCaloriesChart.tsx +1 -1
- package/corpus/templates/macros/app/components/WeightCard.tsx +2 -2
- package/corpus/templates/macros/app/components/WeightTracker.tsx +1 -1
- package/corpus/templates/macros/app/components/layout/AppLayout.tsx +1 -1
- package/corpus/templates/macros/app/routes/_index.tsx +5 -5
- package/corpus/templates/macros/app/routes/analytics.tsx +1 -1
- package/corpus/templates/macros/changelog/2026-06-30-dashboard-loading-and-chart-surfaces-now-use-theme-aware-col.md +6 -0
- package/corpus/templates/mail/app/components/email/ComposeBubbleToolbar.tsx +14 -11
- package/corpus/templates/mail/app/global.css +3 -2
- package/corpus/templates/mail/changelog/2026-06-30-compose-floating-toolbars-now-use-theme-aware-colors-in-ligh.md +6 -0
- package/corpus/templates/plan/app/pages/PlansPage.tsx +2 -2
- package/corpus/templates/slides/app/components/deck/DeckCard.tsx +3 -3
- package/corpus/templates/slides/app/global.css +10 -0
- package/corpus/templates/slides/app/pages/Index.tsx +55 -51
- package/corpus/templates/slides/changelog/2026-06-30-deck-thumbnails-collapse-cleanly-to-one-column-when-the-chat.md +6 -0
- package/dist/agent/engine/anthropic-engine.d.ts +2 -2
- package/dist/agent/engine/anthropic-engine.d.ts.map +1 -1
- package/dist/agent/engine/builder-engine.d.ts +2 -2
- package/dist/agent/engine/builder-engine.d.ts.map +1 -1
- package/dist/agent/engine/builtin.js +1 -1
- package/dist/agent/engine/builtin.js.map +1 -1
- package/dist/agent/engine/output-tokens.js +1 -1
- package/dist/agent/engine/output-tokens.js.map +1 -1
- package/dist/agent/harness/acp-adapter.d.ts +4 -1
- package/dist/agent/harness/acp-adapter.d.ts.map +1 -1
- package/dist/agent/harness/acp-adapter.js +19 -2
- package/dist/agent/harness/acp-adapter.js.map +1 -1
- package/dist/agent/harness/ai-sdk-adapter.d.ts.map +1 -1
- package/dist/agent/harness/ai-sdk-adapter.js +3 -0
- package/dist/agent/harness/ai-sdk-adapter.js.map +1 -1
- package/dist/agent/harness/translate.d.ts.map +1 -1
- package/dist/agent/harness/translate.js +3 -0
- package/dist/agent/harness/translate.js.map +1 -1
- package/dist/agent/harness/types.d.ts +1 -0
- package/dist/agent/harness/types.d.ts.map +1 -1
- package/dist/agent/harness/types.js.map +1 -1
- package/dist/agent/model-config.d.ts +21 -20
- package/dist/agent/model-config.d.ts.map +1 -1
- package/dist/agent/model-config.js +31 -13
- package/dist/agent/model-config.js.map +1 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +85 -10
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/thread-data-builder.d.ts.map +1 -1
- package/dist/agent/thread-data-builder.js +27 -6
- package/dist/agent/thread-data-builder.js.map +1 -1
- package/dist/agent/tool-call-journal.d.ts +11 -9
- package/dist/agent/tool-call-journal.d.ts.map +1 -1
- package/dist/agent/tool-call-journal.js +92 -40
- package/dist/agent/tool-call-journal.js.map +1 -1
- package/dist/agent/types.d.ts +5 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/cli/design-connect.d.ts.map +1 -1
- package/dist/cli/design-connect.js +84 -0
- package/dist/cli/design-connect.js.map +1 -1
- package/dist/cli/gateway-helpers.d.ts +4 -0
- package/dist/cli/gateway-helpers.d.ts.map +1 -1
- package/dist/cli/gateway-helpers.js +9 -0
- package/dist/cli/gateway-helpers.js.map +1 -1
- package/dist/cli/recap.d.ts.map +1 -1
- package/dist/cli/recap.js +0 -2
- package/dist/cli/recap.js.map +1 -1
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +54 -16
- package/dist/cli/skills.js.map +1 -1
- package/dist/cli/workspace-dev.d.ts.map +1 -1
- package/dist/cli/workspace-dev.js +33 -6
- package/dist/cli/workspace-dev.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +72 -26
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/CommandMenu.d.ts +6 -2
- package/dist/client/CommandMenu.d.ts.map +1 -1
- package/dist/client/CommandMenu.js +25 -14
- package/dist/client/CommandMenu.js.map +1 -1
- package/dist/client/DefaultSpinner.d.ts.map +1 -1
- package/dist/client/DefaultSpinner.js +8 -1
- package/dist/client/DefaultSpinner.js.map +1 -1
- package/dist/client/chat/message-components.d.ts +7 -1
- package/dist/client/chat/message-components.d.ts.map +1 -1
- package/dist/client/chat/message-components.js +37 -1
- package/dist/client/chat/message-components.js.map +1 -1
- package/dist/client/chat/repo-helpers.d.ts +1 -0
- package/dist/client/chat/repo-helpers.d.ts.map +1 -1
- package/dist/client/chat/repo-helpers.js +59 -0
- package/dist/client/chat/repo-helpers.js.map +1 -1
- package/dist/client/chat/run-recovery.d.ts.map +1 -1
- package/dist/client/chat/run-recovery.js +4 -4
- package/dist/client/chat/run-recovery.js.map +1 -1
- package/dist/client/components/ApiKeySettings.js +8 -8
- package/dist/client/components/ApiKeySettings.js.map +1 -1
- package/dist/client/components/CodeRequiredDialog.d.ts.map +1 -1
- package/dist/client/components/CodeRequiredDialog.js +24 -15
- package/dist/client/components/CodeRequiredDialog.js.map +1 -1
- package/dist/client/components/MissingKeyCard.d.ts.map +1 -1
- package/dist/client/components/MissingKeyCard.js +11 -6
- package/dist/client/components/MissingKeyCard.js.map +1 -1
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +4 -3
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/extensions/ExtensionsSidebarSection.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionsSidebarSection.js +1 -1
- package/dist/client/extensions/ExtensionsSidebarSection.js.map +1 -1
- package/dist/client/guided-questions.d.ts.map +1 -1
- package/dist/client/guided-questions.js +6 -6
- package/dist/client/guided-questions.js.map +1 -1
- package/dist/client/integrations/IntegrationCard.js +1 -1
- package/dist/client/integrations/IntegrationCard.js.map +1 -1
- package/dist/client/integrations/IntegrationsPanel.js +1 -1
- package/dist/client/integrations/IntegrationsPanel.js.map +1 -1
- package/dist/client/onboarding/OnboardingBanner.js +2 -2
- package/dist/client/onboarding/OnboardingBanner.js.map +1 -1
- package/dist/client/onboarding/OnboardingPanel.js +23 -19
- package/dist/client/onboarding/OnboardingPanel.js.map +1 -1
- package/dist/client/resources/ResourceEditor.d.ts.map +1 -1
- package/dist/client/resources/ResourceEditor.js +13 -10
- package/dist/client/resources/ResourceEditor.js.map +1 -1
- package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
- package/dist/client/resources/ResourcesPanel.js +2 -1
- package/dist/client/resources/ResourcesPanel.js.map +1 -1
- package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
- package/dist/client/settings/SettingsPanel.js +8 -3
- package/dist/client/settings/SettingsPanel.js.map +1 -1
- package/dist/client/settings/useBuilderStatus.d.ts.map +1 -1
- package/dist/client/settings/useBuilderStatus.js +6 -38
- package/dist/client/settings/useBuilderStatus.js.map +1 -1
- package/dist/client/useProductionAgent.d.ts +2 -1
- package/dist/client/useProductionAgent.d.ts.map +1 -1
- package/dist/client/useProductionAgent.js.map +1 -1
- package/dist/deploy/build.js +1 -1
- package/dist/deploy/build.js.map +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/observability/routes.d.ts +3 -3
- package/dist/observability/traces.d.ts.map +1 -1
- package/dist/observability/traces.js.map +1 -1
- package/dist/onboarding/default-steps.js +1 -1
- package/dist/onboarding/default-steps.js.map +1 -1
- package/dist/scripts/agent-engines/manage-agent-engine.js +1 -1
- package/dist/scripts/agent-engines/manage-agent-engine.js.map +1 -1
- package/dist/scripts/agent-engines/set-agent-engine.js +1 -1
- package/dist/scripts/agent-engines/set-agent-engine.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +3 -0
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +134 -72
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/core-routes-plugin.d.ts +3 -0
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +4 -1
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/open-route.d.ts +9 -0
- package/dist/server/open-route.d.ts.map +1 -1
- package/dist/server/open-route.js +48 -38
- package/dist/server/open-route.js.map +1 -1
- package/dist/shared/reasoning-effort.js +3 -0
- package/dist/shared/reasoning-effort.js.map +1 -1
- package/dist/sharing/access.d.ts.map +1 -1
- package/dist/sharing/access.js +18 -2
- package/dist/sharing/access.js.map +1 -1
- package/dist/sharing/registry.d.ts +10 -0
- package/dist/sharing/registry.d.ts.map +1 -1
- package/dist/sharing/registry.js.map +1 -1
- package/dist/styles/agent-native.css +104 -20
- package/dist/styles/rich-markdown-editor.css +11 -10
- package/docs/content/cloneable-saas.mdx +2 -2
- package/docs/content/faq.mdx +1 -1
- package/docs/content/locales/ar-SA/cloneable-saas.mdx +2 -2
- package/docs/content/locales/ar-SA/faq.mdx +1 -1
- package/docs/content/locales/ar-SA/template-chat.mdx +1 -1
- package/docs/content/locales/de-DE/cloneable-saas.mdx +2 -2
- package/docs/content/locales/de-DE/faq.mdx +1 -1
- package/docs/content/locales/de-DE/template-chat.mdx +1 -1
- package/docs/content/locales/es-ES/cloneable-saas.mdx +2 -2
- package/docs/content/locales/es-ES/faq.mdx +1 -1
- package/docs/content/locales/es-ES/template-chat.mdx +1 -1
- package/docs/content/locales/fr-FR/cloneable-saas.mdx +2 -2
- package/docs/content/locales/fr-FR/faq.mdx +1 -1
- package/docs/content/locales/fr-FR/template-chat.mdx +1 -1
- package/docs/content/locales/hi-IN/cloneable-saas.mdx +2 -2
- package/docs/content/locales/hi-IN/faq.mdx +1 -1
- package/docs/content/locales/hi-IN/template-chat.mdx +1 -1
- package/docs/content/locales/ja-JP/cloneable-saas.mdx +2 -2
- package/docs/content/locales/ja-JP/faq.mdx +1 -1
- package/docs/content/locales/ja-JP/template-chat.mdx +1 -1
- package/docs/content/locales/ko-KR/cloneable-saas.mdx +2 -2
- package/docs/content/locales/ko-KR/faq.mdx +1 -1
- package/docs/content/locales/ko-KR/template-chat.mdx +1 -1
- package/docs/content/locales/pt-BR/cloneable-saas.mdx +2 -2
- package/docs/content/locales/pt-BR/faq.mdx +1 -1
- package/docs/content/locales/pt-BR/template-chat.mdx +1 -1
- package/docs/content/locales/zh-CN/cloneable-saas.mdx +2 -2
- package/docs/content/locales/zh-CN/faq.mdx +1 -1
- package/docs/content/locales/zh-CN/template-chat.mdx +1 -1
- package/docs/content/locales/zh-TW/cloneable-saas.mdx +2 -2
- package/docs/content/locales/zh-TW/faq.mdx +1 -1
- package/docs/content/locales/zh-TW/template-chat.mdx +1 -1
- package/docs/content/template-chat.mdx +1 -1
- package/package.json +1 -1
- package/corpus/templates/design/app/components/design/LocalSourceEditBanner.tsx +0 -157
- package/corpus/templates/design/app/lib/design-templates.ts +0 -1305
- package/corpus/templates/design/app/pages/Templates.tsx +0 -279
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
* __TEXT_EDITING_ENABLED__ — boolean literal "true"/"false"
|
|
12
12
|
* __EDITOR_CHROME_SCALE_X__ — number string, e.g. "1.5"
|
|
13
13
|
* __EDITOR_CHROME_SCALE_Y__ — number string, e.g. "1.5"
|
|
14
|
+
* __DESIGN_CANVAS_SCREEN_ID__ — string literal for the owning screen/file id
|
|
15
|
+
* __DESIGN_CANVAS_BOARD_SURFACE__ — boolean literal for top-level board iframe
|
|
14
16
|
*
|
|
15
17
|
* Rules:
|
|
16
18
|
* • No import/require of any module (DOM globals only).
|
|
@@ -24,10 +26,14 @@ declare var __READ_ONLY__: boolean;
|
|
|
24
26
|
declare var __TEXT_EDITING_ENABLED__: boolean;
|
|
25
27
|
declare var __EDITOR_CHROME_SCALE_X__: string;
|
|
26
28
|
declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
29
|
+
declare var __DESIGN_CANVAS_SCREEN_ID__: string;
|
|
30
|
+
declare var __DESIGN_CANVAS_BOARD_SURFACE__: boolean;
|
|
27
31
|
|
|
28
32
|
(function () {
|
|
29
33
|
var readOnly = __READ_ONLY__;
|
|
30
34
|
var textEditingEnabled = !readOnly && __TEXT_EDITING_ENABLED__;
|
|
35
|
+
var designCanvasScreenId = __DESIGN_CANVAS_SCREEN_ID__ || "";
|
|
36
|
+
var designCanvasBoardSurface = !!__DESIGN_CANVAS_BOARD_SURFACE__;
|
|
31
37
|
var scaleToolEnabled = false;
|
|
32
38
|
var editorChromeScaleX = Math.max(
|
|
33
39
|
0.05,
|
|
@@ -41,8 +47,15 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
41
47
|
// Ease the constant-size selection chrome to its new size when overview zoom
|
|
42
48
|
// settles (parent posts set-editor-chrome-scale), matching the canvas chrome.
|
|
43
49
|
// Only chrome-scale-driven props animate; the overlay's live position is excluded.
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
var chromeTransitionStyle: HTMLStyleElement | null = null;
|
|
51
|
+
|
|
52
|
+
function ensureEditorChromeStyle(): void {
|
|
53
|
+
if (chromeTransitionStyle && chromeTransitionStyle.isConnected) return;
|
|
54
|
+
chromeTransitionStyle = document.createElement("style");
|
|
55
|
+
chromeTransitionStyle.setAttribute(
|
|
56
|
+
"data-agent-native-editor-chrome-style",
|
|
57
|
+
"",
|
|
58
|
+
);
|
|
46
59
|
chromeTransitionStyle.textContent =
|
|
47
60
|
'[data-agent-native-edit-overlay="selection"]{transition:border-width 150ms ease-out}' +
|
|
48
61
|
"[data-agent-native-edge-handle],[data-agent-native-edit-handle],[data-agent-native-rotate-handle]{transition:width 150ms ease-out,height 150ms ease-out,border-width 150ms ease-out,top 150ms ease-out,bottom 150ms ease-out,left 150ms ease-out,right 150ms ease-out}" +
|
|
@@ -53,7 +66,20 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
53
66
|
(document.head || document.documentElement).appendChild(
|
|
54
67
|
chromeTransitionStyle,
|
|
55
68
|
);
|
|
56
|
-
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
ensureEditorChromeStyle();
|
|
72
|
+
|
|
73
|
+
function runtimeHeadHtmlWithoutEditorChrome(): string {
|
|
74
|
+
if (!document.head) return "";
|
|
75
|
+
var clone = document.head.cloneNode(true) as HTMLElement;
|
|
76
|
+
Array.prototype.slice
|
|
77
|
+
.call(clone.querySelectorAll("[data-agent-native-editor-chrome-style]"))
|
|
78
|
+
.forEach(function (node) {
|
|
79
|
+
if (node.parentNode) node.parentNode.removeChild(node);
|
|
80
|
+
});
|
|
81
|
+
return clone.innerHTML;
|
|
82
|
+
}
|
|
57
83
|
|
|
58
84
|
function chromeScaleX(): number {
|
|
59
85
|
return 1 / Math.max(0.05, editorChromeScaleX);
|
|
@@ -163,6 +189,20 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
163
189
|
return el === document.body || el === document.documentElement;
|
|
164
190
|
}
|
|
165
191
|
|
|
192
|
+
function isBoardRootMarqueeSurface(el: Element | null): boolean {
|
|
193
|
+
if (!designCanvasBoardSurface || !el) return false;
|
|
194
|
+
if (isDocumentRootElement(el)) return true;
|
|
195
|
+
if (el.parentElement !== document.body) return false;
|
|
196
|
+
var sourceId = (getSourceId(el) || "").toLowerCase();
|
|
197
|
+
var layerName = (
|
|
198
|
+
(el.getAttribute && el.getAttribute("data-agent-native-layer-name")) ||
|
|
199
|
+
""
|
|
200
|
+
).toLowerCase();
|
|
201
|
+
return (
|
|
202
|
+
sourceId === "body" || layerName === "body" || layerName === "<body>"
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
166
206
|
function closestStableSourceElement(el: Element | null): Element | null {
|
|
167
207
|
if (!el || !el.closest) return null;
|
|
168
208
|
var stable = el.closest(
|
|
@@ -246,9 +286,104 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
246
286
|
return selectorPath(el);
|
|
247
287
|
}
|
|
248
288
|
|
|
289
|
+
function explicitComponentNameForElement(el: Element | null): string {
|
|
290
|
+
var raw =
|
|
291
|
+
el && el.getAttribute && el.getAttribute("data-agent-native-component");
|
|
292
|
+
return raw && raw.trim ? raw.trim() : "";
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function elementLooksLikeComponent(el: Element | null): boolean {
|
|
296
|
+
if (!el || !el.getAttribute || !el.tagName) return false;
|
|
297
|
+
if (explicitComponentNameForElement(el)) return true;
|
|
298
|
+
var tag = el.tagName.toLowerCase();
|
|
299
|
+
if (
|
|
300
|
+
tag === "button" ||
|
|
301
|
+
tag === "input" ||
|
|
302
|
+
tag === "select" ||
|
|
303
|
+
tag === "textarea"
|
|
304
|
+
) {
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
var layerName = el.getAttribute("data-agent-native-layer-name") || "";
|
|
308
|
+
if (/component|card|button|control/i.test(layerName)) return true;
|
|
309
|
+
if (!el.classList) return false;
|
|
310
|
+
for (var i = 0; i < el.classList.length; i += 1) {
|
|
311
|
+
if (/component|card|button|control/i.test(el.classList.item(i) || "")) {
|
|
312
|
+
return true;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function componentNameForElement(el: Element | null): string {
|
|
319
|
+
var explicit = explicitComponentNameForElement(el);
|
|
320
|
+
if (explicit) return explicit;
|
|
321
|
+
if (!elementLooksLikeComponent(el) || !el || !el.getAttribute) return "";
|
|
322
|
+
var layerName = el.getAttribute("data-agent-native-layer-name");
|
|
323
|
+
return layerName && layerName.trim ? layerName.trim() : "";
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function isAutoLayoutDisplay(display: string | undefined): boolean {
|
|
327
|
+
return (
|
|
328
|
+
display === "flex" ||
|
|
329
|
+
display === "inline-flex" ||
|
|
330
|
+
display === "grid" ||
|
|
331
|
+
display === "inline-grid"
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function rectInfoForElement(el: Element) {
|
|
336
|
+
var rect = el.getBoundingClientRect();
|
|
337
|
+
return {
|
|
338
|
+
x: rect.x + (window.scrollX || window.pageXOffset || 0),
|
|
339
|
+
y: rect.y + (window.scrollY || window.pageYOffset || 0),
|
|
340
|
+
width: rect.width,
|
|
341
|
+
height: rect.height,
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function autoLayoutParentInfo(el: Element) {
|
|
346
|
+
var parent = el.parentElement;
|
|
347
|
+
if (
|
|
348
|
+
!parent ||
|
|
349
|
+
parent === document.body ||
|
|
350
|
+
parent === document.documentElement
|
|
351
|
+
) {
|
|
352
|
+
return undefined;
|
|
353
|
+
}
|
|
354
|
+
var parentStyles = window.getComputedStyle(parent);
|
|
355
|
+
if (!isAutoLayoutDisplay(parentStyles.display)) return undefined;
|
|
356
|
+
return {
|
|
357
|
+
display: parentStyles.display,
|
|
358
|
+
selector: getSelector(parent),
|
|
359
|
+
sourceId: getSourceId(parent) || getSelector(parent),
|
|
360
|
+
boundingRect: rectInfoForElement(parent),
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function chromeColorForElement(el: Element | null): string {
|
|
365
|
+
return elementLooksLikeComponent(el)
|
|
366
|
+
? "var(--design-editor-component-color)"
|
|
367
|
+
: "var(--design-editor-accent-color)";
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function chromeStrongColorForElement(el: Element | null): string {
|
|
371
|
+
return elementLooksLikeComponent(el)
|
|
372
|
+
? "var(--design-editor-component-strong-color)"
|
|
373
|
+
: "var(--design-editor-accent-strong-color)";
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function chromeContrastColorForElement(el: Element | null): string {
|
|
377
|
+
return elementLooksLikeComponent(el)
|
|
378
|
+
? "var(--design-editor-component-contrast-color)"
|
|
379
|
+
: "var(--design-editor-accent-contrast-color)";
|
|
380
|
+
}
|
|
381
|
+
|
|
249
382
|
function getElementInfo(el: Element): unknown {
|
|
250
383
|
var cs = window.getComputedStyle(el);
|
|
251
384
|
var rect = el.getBoundingClientRect();
|
|
385
|
+
var componentName = componentNameForElement(el);
|
|
386
|
+
var parentAutoLayout = autoLayoutParentInfo(el);
|
|
252
387
|
var parentStyles = el.parentElement
|
|
253
388
|
? window.getComputedStyle(el.parentElement)
|
|
254
389
|
: null;
|
|
@@ -294,13 +429,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
294
429
|
reason: "Class tokens are visible on the selected element.",
|
|
295
430
|
});
|
|
296
431
|
}
|
|
297
|
-
if (
|
|
298
|
-
sourceBacked &&
|
|
299
|
-
(parentDisplay === "flex" ||
|
|
300
|
-
parentDisplay === "inline-flex" ||
|
|
301
|
-
parentDisplay === "grid" ||
|
|
302
|
-
parentDisplay === "inline-grid")
|
|
303
|
-
) {
|
|
432
|
+
if (sourceBacked && isAutoLayoutDisplay(parentDisplay)) {
|
|
304
433
|
capabilities.push({
|
|
305
434
|
kind: "agent-structural-edit",
|
|
306
435
|
label: "agent-structural-edit",
|
|
@@ -367,6 +496,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
367
496
|
}
|
|
368
497
|
return {
|
|
369
498
|
tagName: el.tagName.toLowerCase(),
|
|
499
|
+
componentName: componentName || undefined,
|
|
370
500
|
id: el.id || undefined,
|
|
371
501
|
sourceId: sourceId,
|
|
372
502
|
selector: getSelector(el),
|
|
@@ -443,9 +573,12 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
443
573
|
el.innerHTML && el.innerHTML !== el.textContent
|
|
444
574
|
? el.innerHTML.slice(0, 4000)
|
|
445
575
|
: undefined,
|
|
576
|
+
childElementCount: el.children ? el.children.length : 0,
|
|
446
577
|
isFlexContainer: cs.display === "flex" || cs.display === "inline-flex",
|
|
578
|
+
isGridContainer: cs.display === "grid" || cs.display === "inline-grid",
|
|
447
579
|
isFlexChild: parentDisplay === "flex" || parentDisplay === "inline-flex",
|
|
448
580
|
parentDisplay: parentDisplay,
|
|
581
|
+
parentAutoLayout: parentAutoLayout,
|
|
449
582
|
parentLayout: parentLayout,
|
|
450
583
|
editCapabilities: capabilities,
|
|
451
584
|
confidence: capabilities.reduce(function (best, item) {
|
|
@@ -455,6 +588,72 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
455
588
|
};
|
|
456
589
|
}
|
|
457
590
|
|
|
591
|
+
function selectionIntentFromEvent(e): {
|
|
592
|
+
additive: boolean;
|
|
593
|
+
range: boolean;
|
|
594
|
+
source: "pointer";
|
|
595
|
+
shiftKey: boolean;
|
|
596
|
+
metaKey: boolean;
|
|
597
|
+
ctrlKey: boolean;
|
|
598
|
+
} {
|
|
599
|
+
var additive = Boolean(e && (e.metaKey || e.ctrlKey || e.shiftKey));
|
|
600
|
+
return {
|
|
601
|
+
additive: additive,
|
|
602
|
+
range: Boolean(e && e.shiftKey),
|
|
603
|
+
source: "pointer",
|
|
604
|
+
shiftKey: Boolean(e && e.shiftKey),
|
|
605
|
+
metaKey: Boolean(e && e.metaKey),
|
|
606
|
+
ctrlKey: Boolean(e && e.ctrlKey),
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
function postElementSelect(el: Element, e?: MouseEvent): void {
|
|
611
|
+
var message: {
|
|
612
|
+
type: string;
|
|
613
|
+
payload: unknown;
|
|
614
|
+
intent?: ReturnType<typeof selectionIntentFromEvent>;
|
|
615
|
+
} = {
|
|
616
|
+
type: "element-select",
|
|
617
|
+
payload: getElementInfo(el),
|
|
618
|
+
};
|
|
619
|
+
if (e) message.intent = selectionIntentFromEvent(e);
|
|
620
|
+
(window.parent as Window).postMessage(message, "*");
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
function collectSelectableElements(): Element[] {
|
|
624
|
+
var nodes = Array.prototype.slice.call(
|
|
625
|
+
document.querySelectorAll(
|
|
626
|
+
"[data-agent-native-node-id],[data-code-layer-id],[data-layer-id],[data-builder-id],[data-loc]",
|
|
627
|
+
),
|
|
628
|
+
) as Element[];
|
|
629
|
+
var seen = new Set<Element>();
|
|
630
|
+
var elements: Element[] = [];
|
|
631
|
+
nodes.forEach(function (node) {
|
|
632
|
+
var target = selectionTargetForHit(node);
|
|
633
|
+
if (
|
|
634
|
+
!target ||
|
|
635
|
+
isDocumentRootElement(target) ||
|
|
636
|
+
isBoardRootMarqueeSurface(target) ||
|
|
637
|
+
isOverlayElement(target) ||
|
|
638
|
+
isLayerInteractionBlocked(target) ||
|
|
639
|
+
seen.has(target)
|
|
640
|
+
) {
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
var rect = target.getBoundingClientRect();
|
|
644
|
+
if (rect.width <= 0 || rect.height <= 0) return;
|
|
645
|
+
seen.add(target);
|
|
646
|
+
elements.push(target);
|
|
647
|
+
});
|
|
648
|
+
return elements;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
function collectSelectableElementInfos(): unknown[] {
|
|
652
|
+
return collectSelectableElements().map(function (target) {
|
|
653
|
+
return getElementInfo(target);
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
|
|
458
657
|
var shieldOverlay = document.createElement("div");
|
|
459
658
|
shieldOverlay.setAttribute("data-agent-native-edit-overlay", "shield");
|
|
460
659
|
shieldOverlay.style.cssText =
|
|
@@ -467,6 +666,24 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
467
666
|
"position:fixed;pointer-events:none;z-index:99997;border:1.5px solid var(--design-editor-accent-color);background:transparent;display:none;box-sizing:border-box;";
|
|
468
667
|
document.body.appendChild(highlightOverlay);
|
|
469
668
|
|
|
669
|
+
var marqueeSelectionOverlay = document.createElement("div");
|
|
670
|
+
marqueeSelectionOverlay.setAttribute(
|
|
671
|
+
"data-agent-native-edit-overlay",
|
|
672
|
+
"marquee-selection",
|
|
673
|
+
);
|
|
674
|
+
marqueeSelectionOverlay.style.cssText =
|
|
675
|
+
"position:fixed;pointer-events:none;z-index:99995;border:1px solid var(--design-editor-accent-color);background:color-mix(in srgb,var(--design-editor-accent-color) 14%,transparent);display:none;box-sizing:border-box;";
|
|
676
|
+
document.body.appendChild(marqueeSelectionOverlay);
|
|
677
|
+
|
|
678
|
+
var parentAutoLayoutOverlay = document.createElement("div");
|
|
679
|
+
parentAutoLayoutOverlay.setAttribute(
|
|
680
|
+
"data-agent-native-edit-overlay",
|
|
681
|
+
"parent-auto-layout",
|
|
682
|
+
);
|
|
683
|
+
parentAutoLayoutOverlay.style.cssText =
|
|
684
|
+
"position:fixed;pointer-events:none;z-index:99996;border:1px dashed var(--design-editor-accent-color);background:transparent;display:none;box-sizing:border-box;border-radius:2px;opacity:0.68;";
|
|
685
|
+
document.body.appendChild(parentAutoLayoutOverlay);
|
|
686
|
+
|
|
470
687
|
var selectionOverlay = document.createElement("div");
|
|
471
688
|
selectionOverlay.setAttribute("data-agent-native-edit-overlay", "selection");
|
|
472
689
|
selectionOverlay.style.cssText =
|
|
@@ -598,10 +815,10 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
598
815
|
"white-space:nowrap",
|
|
599
816
|
"user-select:none",
|
|
600
817
|
"-webkit-user-select:none",
|
|
601
|
-
"background:var(--design-editor-
|
|
602
|
-
"color:var(--design-editor-
|
|
603
|
-
"box-shadow:0 1px 4px color-mix(in srgb,var(--design-editor-
|
|
604
|
-
"border:1px solid color-mix(in srgb,var(--design-editor-
|
|
818
|
+
"background:var(--design-editor-component-color)",
|
|
819
|
+
"color:var(--design-editor-component-contrast-color)",
|
|
820
|
+
"box-shadow:0 1px 4px color-mix(in srgb,var(--design-editor-component-color) 40%,transparent)",
|
|
821
|
+
"border:1px solid color-mix(in srgb,var(--design-editor-component-strong-color) 60%,transparent)",
|
|
605
822
|
"outline:2px solid transparent",
|
|
606
823
|
"transition:opacity 0.1s",
|
|
607
824
|
].join(";") + ";";
|
|
@@ -632,8 +849,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
632
849
|
clearComponentTag();
|
|
633
850
|
return;
|
|
634
851
|
}
|
|
635
|
-
var compName =
|
|
636
|
-
el.getAttribute && el.getAttribute("data-agent-native-component");
|
|
852
|
+
var compName = explicitComponentNameForElement(el);
|
|
637
853
|
if (!compName) {
|
|
638
854
|
clearComponentTag();
|
|
639
855
|
return;
|
|
@@ -655,9 +871,9 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
655
871
|
componentTagOverlay.style.display = "block";
|
|
656
872
|
componentTagOverlay.style.left = rect.left + "px";
|
|
657
873
|
componentTagOverlay.style.top = tagTop + "px";
|
|
658
|
-
//
|
|
874
|
+
// Purple outline on the selection overlay distinguishes component roots.
|
|
659
875
|
selectionOverlay.style.outline =
|
|
660
|
-
"2px solid
|
|
876
|
+
"2px solid " + chromeStrongColorForElement(el);
|
|
661
877
|
selectionOverlay.style.outlineOffset = "2px";
|
|
662
878
|
}
|
|
663
879
|
|
|
@@ -669,8 +885,77 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
669
885
|
selectionOverlay.style.outlineOffset = "";
|
|
670
886
|
}
|
|
671
887
|
|
|
888
|
+
function applyElementOverlayChrome(
|
|
889
|
+
overlay: HTMLElement,
|
|
890
|
+
el: Element | null,
|
|
891
|
+
): void {
|
|
892
|
+
var color = chromeColorForElement(el);
|
|
893
|
+
var contrast = chromeContrastColorForElement(el);
|
|
894
|
+
overlay.style.borderColor = color;
|
|
895
|
+
overlay
|
|
896
|
+
.querySelectorAll(
|
|
897
|
+
"[data-agent-native-edit-handle],[data-agent-native-edit-overlay='multi-selection-handle']",
|
|
898
|
+
)
|
|
899
|
+
.forEach(function (node) {
|
|
900
|
+
if (!(node instanceof HTMLElement)) return;
|
|
901
|
+
node.style.borderColor = color;
|
|
902
|
+
node.style.background = contrast;
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
function applySelectionChrome(el: Element | null): void {
|
|
907
|
+
applyElementOverlayChrome(selectionOverlay, el);
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
function hideParentAutoLayoutOverlay(): void {
|
|
911
|
+
parentAutoLayoutOverlay.style.display = "none";
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
function updateParentAutoLayoutOverlay(el: Element | null): void {
|
|
915
|
+
var parent = el && el.parentElement;
|
|
916
|
+
if (
|
|
917
|
+
!parent ||
|
|
918
|
+
parent === document.body ||
|
|
919
|
+
parent === document.documentElement
|
|
920
|
+
) {
|
|
921
|
+
hideParentAutoLayoutOverlay();
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
924
|
+
var parentStyles = window.getComputedStyle(parent);
|
|
925
|
+
if (!isAutoLayoutDisplay(parentStyles.display)) {
|
|
926
|
+
hideParentAutoLayoutOverlay();
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
positionOverlay(parentAutoLayoutOverlay, parent);
|
|
930
|
+
var color = chromeColorForElement(el);
|
|
931
|
+
parentAutoLayoutOverlay.style.borderColor =
|
|
932
|
+
"color-mix(in srgb," + color + " 68%,transparent)";
|
|
933
|
+
parentAutoLayoutOverlay.style.background =
|
|
934
|
+
"color-mix(in srgb," + color + " 5%,transparent)";
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
function hideSelectionOverlay(): void {
|
|
938
|
+
selectionOverlay.style.display = "none";
|
|
939
|
+
hideSpacingOverlay();
|
|
940
|
+
hideParentAutoLayoutOverlay();
|
|
941
|
+
clearComponentTag();
|
|
942
|
+
}
|
|
943
|
+
|
|
672
944
|
var selectedEl: Element | null = null;
|
|
673
945
|
var hoveredEl: Element | null = null;
|
|
946
|
+
var passiveSelectionEls: Element[] = [];
|
|
947
|
+
var passiveSelectionOverlays: HTMLElement[] = [];
|
|
948
|
+
var activeMarqueeSelection: {
|
|
949
|
+
startX: number;
|
|
950
|
+
startY: number;
|
|
951
|
+
additive: boolean;
|
|
952
|
+
moved: boolean;
|
|
953
|
+
pointerId?: number;
|
|
954
|
+
move: string;
|
|
955
|
+
up: string;
|
|
956
|
+
onMove: (ev: MouseEvent) => void;
|
|
957
|
+
onUp: (ev: MouseEvent) => void;
|
|
958
|
+
} | null = null;
|
|
674
959
|
var activeTextEditEl: HTMLElement | null = null;
|
|
675
960
|
var textEditPointerState: {
|
|
676
961
|
shield: string;
|
|
@@ -702,6 +987,8 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
702
987
|
var suppressNextShieldClickTimer: ReturnType<typeof setTimeout> | null = null;
|
|
703
988
|
var selectedSpacingHovered = false;
|
|
704
989
|
var hoveredSpacingHandleKey = "";
|
|
990
|
+
var spacingHoverClearTimer: ReturnType<typeof setTimeout> | null = null;
|
|
991
|
+
var lastSpacingPointerPoint: { x: number; y: number } | null = null;
|
|
705
992
|
var spacingHandleStateByKey: Record<string, { value: number }> = {};
|
|
706
993
|
var spacingHandleNodesByKey: Record<string, Element> = {};
|
|
707
994
|
var spacingOverlayRenderKey = "";
|
|
@@ -725,14 +1012,110 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
725
1012
|
function clearRuntimeSelection(): void {
|
|
726
1013
|
selectedEl = null;
|
|
727
1014
|
hoveredEl = null;
|
|
1015
|
+
setPassiveSelectionElements([]);
|
|
1016
|
+
clearSpacingHoverTimer();
|
|
728
1017
|
selectedSpacingHovered = false;
|
|
729
1018
|
hoveredSpacingHandleKey = "";
|
|
1019
|
+
lastSpacingPointerPoint = null;
|
|
730
1020
|
spacingDrag = null;
|
|
731
|
-
|
|
1021
|
+
hideSelectionOverlay();
|
|
732
1022
|
highlightOverlay.style.display = "none";
|
|
1023
|
+
marqueeSelectionOverlay.style.display = "none";
|
|
1024
|
+
clearActiveMarqueeSelection();
|
|
733
1025
|
hideSpacingOverlay();
|
|
734
1026
|
hideMeasurements();
|
|
735
|
-
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
function removePassiveSelectionOverlays(): void {
|
|
1030
|
+
passiveSelectionOverlays.forEach(function (overlay) {
|
|
1031
|
+
if (overlay.parentNode) overlay.parentNode.removeChild(overlay);
|
|
1032
|
+
});
|
|
1033
|
+
passiveSelectionOverlays = [];
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
function appendPassiveSelectionHandles(overlay: HTMLElement): void {
|
|
1037
|
+
["nw", "ne", "se", "sw"].forEach(function (pos) {
|
|
1038
|
+
var handle = document.createElement("span");
|
|
1039
|
+
handle.setAttribute(
|
|
1040
|
+
"data-agent-native-edit-overlay",
|
|
1041
|
+
"multi-selection-handle",
|
|
1042
|
+
);
|
|
1043
|
+
handle.setAttribute("data-corner", pos);
|
|
1044
|
+
handle.style.cssText =
|
|
1045
|
+
"position:absolute;z-index:1;width:7px;height:7px;border:1px solid var(--design-editor-accent-color);background:var(--design-editor-accent-contrast-color);box-sizing:border-box;border-radius:1px;pointer-events:none;";
|
|
1046
|
+
if (pos.indexOf("n") !== -1) handle.style.top = "-4px";
|
|
1047
|
+
if (pos.indexOf("s") !== -1) handle.style.bottom = "-4px";
|
|
1048
|
+
if (pos.indexOf("w") !== -1) handle.style.left = "-4px";
|
|
1049
|
+
if (pos.indexOf("e") !== -1) handle.style.right = "-4px";
|
|
1050
|
+
overlay.appendChild(handle);
|
|
1051
|
+
});
|
|
1052
|
+
scalePassiveSelectionOverlay(overlay);
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
function makePassiveSelectionOverlay(): HTMLElement {
|
|
1056
|
+
var overlay = document.createElement("div");
|
|
1057
|
+
overlay.setAttribute("data-agent-native-edit-overlay", "multi-selection");
|
|
1058
|
+
overlay.style.cssText =
|
|
1059
|
+
"position:fixed;pointer-events:none;z-index:99996;border:1.5px solid var(--design-editor-accent-color);background:transparent;display:none;box-sizing:border-box;";
|
|
1060
|
+
appendPassiveSelectionHandles(overlay);
|
|
1061
|
+
document.body.appendChild(overlay);
|
|
1062
|
+
return overlay;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
function scalePassiveSelectionOverlay(overlay: HTMLElement): void {
|
|
1066
|
+
var sx = chromeScaleX();
|
|
1067
|
+
var sy = chromeScaleY();
|
|
1068
|
+
var line = chromeLineScale();
|
|
1069
|
+
overlay.style.borderWidth = 1.5 * line + "px";
|
|
1070
|
+
overlay
|
|
1071
|
+
.querySelectorAll(
|
|
1072
|
+
"[data-agent-native-edit-overlay='multi-selection-handle']",
|
|
1073
|
+
)
|
|
1074
|
+
.forEach(function (handle) {
|
|
1075
|
+
var pos = handle.getAttribute("data-corner") || "";
|
|
1076
|
+
handle.style.width = 7 * sx + "px";
|
|
1077
|
+
handle.style.height = 7 * sy + "px";
|
|
1078
|
+
handle.style.borderWidth = Math.max(1, 1 * line) + "px";
|
|
1079
|
+
if (pos.indexOf("n") !== -1) handle.style.top = -4 * sy + "px";
|
|
1080
|
+
if (pos.indexOf("s") !== -1) handle.style.bottom = -4 * sy + "px";
|
|
1081
|
+
if (pos.indexOf("w") !== -1) handle.style.left = -4 * sx + "px";
|
|
1082
|
+
if (pos.indexOf("e") !== -1) handle.style.right = -4 * sx + "px";
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
function setPassiveSelectionElements(elements: Element[]): void {
|
|
1087
|
+
passiveSelectionEls = elements.filter(function (el, index, all) {
|
|
1088
|
+
return (
|
|
1089
|
+
el &&
|
|
1090
|
+
el !== selectedEl &&
|
|
1091
|
+
document.documentElement.contains(el) &&
|
|
1092
|
+
all.indexOf(el) === index
|
|
1093
|
+
);
|
|
1094
|
+
});
|
|
1095
|
+
removePassiveSelectionOverlays();
|
|
1096
|
+
passiveSelectionEls.forEach(function (el) {
|
|
1097
|
+
var overlay = makePassiveSelectionOverlay();
|
|
1098
|
+
passiveSelectionOverlays.push(overlay);
|
|
1099
|
+
positionOverlay(overlay, el);
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
function preservePreviousSelectedElementForShiftClick(
|
|
1104
|
+
previous: Element | null,
|
|
1105
|
+
next: Element | null,
|
|
1106
|
+
e?: MouseEvent,
|
|
1107
|
+
): void {
|
|
1108
|
+
if (
|
|
1109
|
+
!e?.shiftKey ||
|
|
1110
|
+
!previous ||
|
|
1111
|
+
!next ||
|
|
1112
|
+
previous === next ||
|
|
1113
|
+
!document.documentElement.contains(previous) ||
|
|
1114
|
+
isLayerInteractionBlocked(previous)
|
|
1115
|
+
) {
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
setPassiveSelectionElements([previous].concat(passiveSelectionEls));
|
|
736
1119
|
}
|
|
737
1120
|
|
|
738
1121
|
function matchesSelectorList(
|
|
@@ -810,13 +1193,20 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
810
1193
|
html: string,
|
|
811
1194
|
preferredSelector: string,
|
|
812
1195
|
selectorCandidates: string[],
|
|
1196
|
+
forceFullDocument?: boolean,
|
|
813
1197
|
): void {
|
|
814
1198
|
if (typeof html !== "string") return;
|
|
815
|
-
if (activeTextEditEl) {
|
|
1199
|
+
if (activeTextEditEl && !forceFullDocument) {
|
|
816
1200
|
applyHiddenSelectors();
|
|
817
1201
|
refreshOverlays();
|
|
818
1202
|
return;
|
|
819
1203
|
}
|
|
1204
|
+
if (activeTextEditEl) {
|
|
1205
|
+
postTextEditingState(activeTextEditEl, false);
|
|
1206
|
+
activeTextEditEl = null;
|
|
1207
|
+
setTextEditingPointerPassthrough(false);
|
|
1208
|
+
setSelectionOverlayResizeChromeVisible(true);
|
|
1209
|
+
}
|
|
820
1210
|
var parser = new DOMParser();
|
|
821
1211
|
var nextDoc = parser.parseFromString(html, "text/html");
|
|
822
1212
|
if (!nextDoc || !nextDoc.body) return;
|
|
@@ -843,10 +1233,9 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
843
1233
|
}
|
|
844
1234
|
|
|
845
1235
|
var nextHeadHtml = nextDoc.head ? nextDoc.head.innerHTML : "";
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
) {
|
|
1236
|
+
ensureEditorChromeStyle();
|
|
1237
|
+
var currentHeadHtml = runtimeHeadHtmlWithoutEditorChrome();
|
|
1238
|
+
if (nextHeadHtml === currentHeadHtml && activeCandidates.length > 0) {
|
|
850
1239
|
var currentMatch = null;
|
|
851
1240
|
var nextMatch = null;
|
|
852
1241
|
var matchedSelector = "";
|
|
@@ -912,12 +1301,9 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
912
1301
|
hoveredEl = null;
|
|
913
1302
|
if (selectedEl && !isLayerInteractionBlocked(selectedEl)) {
|
|
914
1303
|
positionOverlay(selectionOverlay, selectedEl);
|
|
915
|
-
(
|
|
916
|
-
{ type: "element-select", payload: getElementInfo(selectedEl) },
|
|
917
|
-
"*",
|
|
918
|
-
);
|
|
1304
|
+
postElementSelect(selectedEl);
|
|
919
1305
|
} else {
|
|
920
|
-
|
|
1306
|
+
hideSelectionOverlay();
|
|
921
1307
|
}
|
|
922
1308
|
highlightOverlay.style.display = "none";
|
|
923
1309
|
hideMeasurements();
|
|
@@ -925,8 +1311,9 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
925
1311
|
return;
|
|
926
1312
|
}
|
|
927
1313
|
}
|
|
928
|
-
if (
|
|
1314
|
+
if (currentHeadHtml !== nextHeadHtml) {
|
|
929
1315
|
document.head.innerHTML = nextHeadHtml;
|
|
1316
|
+
ensureEditorChromeStyle();
|
|
930
1317
|
}
|
|
931
1318
|
Array.prototype.slice.call(document.body.attributes).forEach(function (
|
|
932
1319
|
attribute: Attr,
|
|
@@ -965,12 +1352,9 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
965
1352
|
}
|
|
966
1353
|
if (selectedEl) {
|
|
967
1354
|
positionOverlay(selectionOverlay, selectedEl);
|
|
968
|
-
(
|
|
969
|
-
{ type: "element-select", payload: getElementInfo(selectedEl) },
|
|
970
|
-
"*",
|
|
971
|
-
);
|
|
1355
|
+
postElementSelect(selectedEl);
|
|
972
1356
|
} else {
|
|
973
|
-
|
|
1357
|
+
hideSelectionOverlay();
|
|
974
1358
|
}
|
|
975
1359
|
highlightOverlay.style.display = "none";
|
|
976
1360
|
hideMeasurements();
|
|
@@ -986,6 +1370,13 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
986
1370
|
if (!spacingDrag) spacingBadge.style.display = "none";
|
|
987
1371
|
}
|
|
988
1372
|
|
|
1373
|
+
function clearSpacingHoverTimer(): void {
|
|
1374
|
+
if (spacingHoverClearTimer !== null) {
|
|
1375
|
+
clearTimeout(spacingHoverClearTimer);
|
|
1376
|
+
spacingHoverClearTimer = null;
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
|
|
989
1380
|
function visibleLayoutChildren(el: Element | null): Element[] {
|
|
990
1381
|
if (!el || !el.children) return [];
|
|
991
1382
|
return Array.prototype.slice.call(el.children).filter(function (child) {
|
|
@@ -1397,7 +1788,10 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
1397
1788
|
);
|
|
1398
1789
|
var lineNode = document.createElement("span");
|
|
1399
1790
|
lineNode.setAttribute("data-agent-native-spacing-line", handle.kind);
|
|
1791
|
+
lineNode.style.position = "absolute";
|
|
1400
1792
|
lineNode.style.display = "block";
|
|
1793
|
+
lineNode.style.pointerEvents = "none";
|
|
1794
|
+
lineNode.style.borderRadius = "999px";
|
|
1401
1795
|
lineNode.style.left = handle.line.x + "px";
|
|
1402
1796
|
lineNode.style.top = handle.line.y + "px";
|
|
1403
1797
|
lineNode.style.width = Math.max(1, handle.line.width) + "px";
|
|
@@ -1409,7 +1803,13 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
1409
1803
|
regionNode.setAttribute("data-agent-native-spacing-region", handle.kind);
|
|
1410
1804
|
regionNode.setAttribute("data-orientation", handle.orientation);
|
|
1411
1805
|
regionNode.setAttribute("data-spacing-key", handle.key);
|
|
1806
|
+
regionNode.style.position = "absolute";
|
|
1412
1807
|
regionNode.style.display = "block";
|
|
1808
|
+
regionNode.style.boxSizing = "border-box";
|
|
1809
|
+
regionNode.style.pointerEvents = "auto";
|
|
1810
|
+
regionNode.style.backgroundSize = "6px 6px";
|
|
1811
|
+
regionNode.style.cursor =
|
|
1812
|
+
handle.orientation === "vertical" ? "ew-resize" : "ns-resize";
|
|
1413
1813
|
regionNode.style.left = handle.region.x + "px";
|
|
1414
1814
|
regionNode.style.top = handle.region.y + "px";
|
|
1415
1815
|
regionNode.style.width = handle.region.width + "px";
|
|
@@ -1421,6 +1821,14 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
1421
1821
|
? "1px solid " + spacingColor(handle.kind)
|
|
1422
1822
|
: "0";
|
|
1423
1823
|
regionNode.style.outlineOffset = "-1px";
|
|
1824
|
+
regionNode.addEventListener(
|
|
1825
|
+
"pointerdown",
|
|
1826
|
+
function (event) {
|
|
1827
|
+
activateSpacingHandle(handle.key);
|
|
1828
|
+
startSpacingDrag(handle.key, event);
|
|
1829
|
+
},
|
|
1830
|
+
true,
|
|
1831
|
+
);
|
|
1424
1832
|
regionNode.addEventListener(
|
|
1425
1833
|
"mousedown",
|
|
1426
1834
|
function (event) {
|
|
@@ -1432,6 +1840,31 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
1432
1840
|
spacingOverlay.appendChild(regionNode);
|
|
1433
1841
|
}
|
|
1434
1842
|
|
|
1843
|
+
function updateSpacingHandleHighlights(
|
|
1844
|
+
handles: ({
|
|
1845
|
+
key: string;
|
|
1846
|
+
groupKey: string;
|
|
1847
|
+
kind: string;
|
|
1848
|
+
orientation: string;
|
|
1849
|
+
} | null)[],
|
|
1850
|
+
activeGroupKey: string,
|
|
1851
|
+
): void {
|
|
1852
|
+
handles.forEach(function (handle) {
|
|
1853
|
+
if (!handle) return;
|
|
1854
|
+
var regionNode = spacingHandleNodesByKey[handle.key];
|
|
1855
|
+
if (!regionNode) return;
|
|
1856
|
+
var highlighted = Boolean(
|
|
1857
|
+
activeGroupKey && handle.groupKey === activeGroupKey,
|
|
1858
|
+
);
|
|
1859
|
+
(regionNode as HTMLElement).style.background = highlighted
|
|
1860
|
+
? spacingFill(handle.kind, handle.orientation)
|
|
1861
|
+
: "transparent";
|
|
1862
|
+
(regionNode as HTMLElement).style.outline = highlighted
|
|
1863
|
+
? "1px solid " + spacingColor(handle.kind)
|
|
1864
|
+
: "0";
|
|
1865
|
+
});
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1435
1868
|
function updateSpacingOverlay(el: Element | null): void {
|
|
1436
1869
|
if (el && el !== selectedEl) {
|
|
1437
1870
|
hideSpacingOverlay();
|
|
@@ -1441,45 +1874,34 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
1441
1874
|
hideSpacingOverlay();
|
|
1442
1875
|
return;
|
|
1443
1876
|
}
|
|
1444
|
-
if (!selectedSpacingHovered && !hoveredSpacingHandleKey && !spacingDrag) {
|
|
1445
|
-
hideSpacingOverlay();
|
|
1446
|
-
return;
|
|
1447
|
-
}
|
|
1448
1877
|
var handles = buildSpacingHandles(selectedEl);
|
|
1449
1878
|
if (handles.length === 0) {
|
|
1450
1879
|
hideSpacingOverlay();
|
|
1451
1880
|
return;
|
|
1452
1881
|
}
|
|
1453
|
-
var activeHandle =
|
|
1454
|
-
(spacingDrag && spacingDrag.handle) ||
|
|
1455
|
-
handles.find(function (handle) {
|
|
1456
|
-
return handle.key === hoveredSpacingHandleKey;
|
|
1457
|
-
}) ||
|
|
1458
|
-
null;
|
|
1882
|
+
var activeHandle = spacingDrag ? spacingDrag.handle : null;
|
|
1459
1883
|
var activeGroupKey = activeHandle ? activeHandle.groupKey : "";
|
|
1460
|
-
var nextRenderKey =
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
].join(",");
|
|
1477
|
-
})
|
|
1478
|
-
.join("|");
|
|
1884
|
+
var nextRenderKey = handles
|
|
1885
|
+
.map(function (handle) {
|
|
1886
|
+
return [
|
|
1887
|
+
handle.key,
|
|
1888
|
+
handle.value,
|
|
1889
|
+
handle.region.x,
|
|
1890
|
+
handle.region.y,
|
|
1891
|
+
handle.region.width,
|
|
1892
|
+
handle.region.height,
|
|
1893
|
+
handle.line.x,
|
|
1894
|
+
handle.line.y,
|
|
1895
|
+
handle.line.width,
|
|
1896
|
+
handle.line.height,
|
|
1897
|
+
].join(",");
|
|
1898
|
+
})
|
|
1899
|
+
.join("|");
|
|
1479
1900
|
if (
|
|
1480
1901
|
spacingOverlay.style.display === "block" &&
|
|
1481
1902
|
spacingOverlayRenderKey === nextRenderKey
|
|
1482
1903
|
) {
|
|
1904
|
+
updateSpacingHandleHighlights(handles, activeGroupKey);
|
|
1483
1905
|
if (activeHandle) {
|
|
1484
1906
|
showSpacingBadgeForHandle(
|
|
1485
1907
|
activeHandle,
|
|
@@ -1508,25 +1930,40 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
1508
1930
|
}
|
|
1509
1931
|
}
|
|
1510
1932
|
|
|
1511
|
-
function
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
? e.target.closest("[data-agent-native-spacing-region]")
|
|
1933
|
+
function spacingKeyFromTarget(target: Element | null): string {
|
|
1934
|
+
var region =
|
|
1935
|
+
target && target.closest
|
|
1936
|
+
? target.closest("[data-agent-native-spacing-region]")
|
|
1516
1937
|
: null;
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1938
|
+
return region && region.getAttribute
|
|
1939
|
+
? region.getAttribute("data-spacing-key") || ""
|
|
1940
|
+
: "";
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
function activateSpacingHandle(spacingKey: string): void {
|
|
1521
1944
|
if (!spacingKey) return;
|
|
1522
|
-
|
|
1945
|
+
clearSpacingHoverTimer();
|
|
1523
1946
|
selectedSpacingHovered = true;
|
|
1524
|
-
if (
|
|
1947
|
+
if (
|
|
1948
|
+
hoveredSpacingHandleKey !== spacingKey ||
|
|
1949
|
+
spacingOverlay.style.display !== "block"
|
|
1950
|
+
) {
|
|
1525
1951
|
hoveredSpacingHandleKey = spacingKey;
|
|
1526
1952
|
updateSpacingOverlay(selectedEl);
|
|
1527
1953
|
}
|
|
1528
1954
|
}
|
|
1529
1955
|
|
|
1956
|
+
function handleSpacingOverlayPointerMove(e: PointerEvent): void {
|
|
1957
|
+
if (spacingDrag) return;
|
|
1958
|
+
lastSpacingPointerPoint = { x: e.clientX, y: e.clientY };
|
|
1959
|
+
var spacingKey = spacingKeyFromTarget(
|
|
1960
|
+
e.target && e.target.nodeType === 1 ? e.target : null,
|
|
1961
|
+
);
|
|
1962
|
+
if (!spacingKey) return;
|
|
1963
|
+
stopNativeInteraction(e);
|
|
1964
|
+
activateSpacingHandle(spacingKey);
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1530
1967
|
function spacingRegionFromPoint(
|
|
1531
1968
|
clientX: number,
|
|
1532
1969
|
clientY: number,
|
|
@@ -1554,8 +1991,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
1554
1991
|
var spacingKey = region.getAttribute
|
|
1555
1992
|
? region.getAttribute("data-spacing-key")
|
|
1556
1993
|
: "";
|
|
1557
|
-
if (spacingKey)
|
|
1558
|
-
selectedSpacingHovered = true;
|
|
1994
|
+
if (spacingKey) activateSpacingHandle(spacingKey);
|
|
1559
1995
|
return true;
|
|
1560
1996
|
}
|
|
1561
1997
|
var hit = elementFromEditorPoint(clientX, clientY);
|
|
@@ -1569,6 +2005,25 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
1569
2005
|
return false;
|
|
1570
2006
|
}
|
|
1571
2007
|
|
|
2008
|
+
function scheduleSpacingHoverClear(e: PointerEvent): void {
|
|
2009
|
+
if (spacingDrag) return;
|
|
2010
|
+
if (Number.isFinite(e.clientX) && Number.isFinite(e.clientY)) {
|
|
2011
|
+
lastSpacingPointerPoint = { x: e.clientX, y: e.clientY };
|
|
2012
|
+
}
|
|
2013
|
+
clearSpacingHoverTimer();
|
|
2014
|
+
spacingHoverClearTimer = setTimeout(function () {
|
|
2015
|
+
spacingHoverClearTimer = null;
|
|
2016
|
+
var point = lastSpacingPointerPoint;
|
|
2017
|
+
if (point && selectedSpacingSurfaceContainsPoint(point.x, point.y)) {
|
|
2018
|
+
updateSpacingOverlay(selectedEl);
|
|
2019
|
+
return;
|
|
2020
|
+
}
|
|
2021
|
+
selectedSpacingHovered = false;
|
|
2022
|
+
hoveredSpacingHandleKey = "";
|
|
2023
|
+
updateSpacingOverlay(selectedEl);
|
|
2024
|
+
}, 80);
|
|
2025
|
+
}
|
|
2026
|
+
|
|
1572
2027
|
function shouldKeepSpacingOverlayForLeave(e: PointerEvent): boolean {
|
|
1573
2028
|
if (spacingDrag) return true;
|
|
1574
2029
|
if (e.relatedTarget && isOverlayElement(e.relatedTarget)) return true;
|
|
@@ -1584,7 +2039,9 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
1584
2039
|
var sy = chromeScaleY();
|
|
1585
2040
|
var line = chromeLineScale();
|
|
1586
2041
|
highlightOverlay.style.borderWidth = 1.5 * line + "px";
|
|
2042
|
+
parentAutoLayoutOverlay.style.borderWidth = Math.max(1, 1 * line) + "px";
|
|
1587
2043
|
selectionOverlay.style.borderWidth = 1.5 * line + "px";
|
|
2044
|
+
passiveSelectionOverlays.forEach(scalePassiveSelectionOverlay);
|
|
1588
2045
|
if (selectedEl) updateSpacingOverlay(selectedEl);
|
|
1589
2046
|
|
|
1590
2047
|
selectionOverlay
|
|
@@ -1630,7 +2087,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
1630
2087
|
function positionOverlay(overlay: HTMLElement, el: Element): void {
|
|
1631
2088
|
if (!el || !document.documentElement.contains(el)) {
|
|
1632
2089
|
overlay.style.display = "none";
|
|
1633
|
-
if (overlay === selectionOverlay)
|
|
2090
|
+
if (overlay === selectionOverlay) hideSelectionOverlay();
|
|
1634
2091
|
return;
|
|
1635
2092
|
}
|
|
1636
2093
|
// For the selection overlay, prefer the CSS box + rotation transform so
|
|
@@ -1661,8 +2118,10 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
1661
2118
|
overlay.style.height = elH + "px";
|
|
1662
2119
|
overlay.style.transform = "rotate(" + elRot + "deg)";
|
|
1663
2120
|
overlay.style.transformOrigin = "0 0";
|
|
2121
|
+
applySelectionChrome(el);
|
|
1664
2122
|
updateSpacingOverlay(el);
|
|
1665
2123
|
updateComponentTag(el);
|
|
2124
|
+
updateParentAutoLayoutOverlay(el);
|
|
1666
2125
|
return;
|
|
1667
2126
|
}
|
|
1668
2127
|
}
|
|
@@ -1674,8 +2133,12 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
1674
2133
|
overlay.style.height = rect.height + "px";
|
|
1675
2134
|
overlay.style.transform = "";
|
|
1676
2135
|
if (overlay === selectionOverlay) {
|
|
2136
|
+
applySelectionChrome(el);
|
|
1677
2137
|
updateSpacingOverlay(el);
|
|
1678
2138
|
updateComponentTag(el);
|
|
2139
|
+
updateParentAutoLayoutOverlay(el);
|
|
2140
|
+
} else {
|
|
2141
|
+
applyElementOverlayChrome(overlay, el);
|
|
1679
2142
|
}
|
|
1680
2143
|
}
|
|
1681
2144
|
|
|
@@ -1685,7 +2148,15 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
1685
2148
|
} else {
|
|
1686
2149
|
highlightOverlay.style.display = "none";
|
|
1687
2150
|
}
|
|
1688
|
-
if (selectedEl)
|
|
2151
|
+
if (selectedEl) {
|
|
2152
|
+
positionOverlay(selectionOverlay, selectedEl);
|
|
2153
|
+
} else {
|
|
2154
|
+
hideParentAutoLayoutOverlay();
|
|
2155
|
+
}
|
|
2156
|
+
passiveSelectionEls.forEach(function (el, index) {
|
|
2157
|
+
var overlay = passiveSelectionOverlays[index];
|
|
2158
|
+
if (overlay) positionOverlay(overlay, el);
|
|
2159
|
+
});
|
|
1689
2160
|
}
|
|
1690
2161
|
|
|
1691
2162
|
function hideMeasurements(): void {
|
|
@@ -1864,6 +2335,118 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
1864
2335
|
if (e.stopImmediatePropagation) e.stopImmediatePropagation();
|
|
1865
2336
|
}
|
|
1866
2337
|
|
|
2338
|
+
function normalizedWheelDelta(e: WheelEvent): { x: number; y: number } {
|
|
2339
|
+
var multiplier =
|
|
2340
|
+
e.deltaMode === WheelEvent.DOM_DELTA_LINE
|
|
2341
|
+
? 16
|
|
2342
|
+
: e.deltaMode === WheelEvent.DOM_DELTA_PAGE
|
|
2343
|
+
? Math.max(
|
|
2344
|
+
1,
|
|
2345
|
+
window.innerHeight || document.documentElement.clientHeight,
|
|
2346
|
+
)
|
|
2347
|
+
: 1;
|
|
2348
|
+
return {
|
|
2349
|
+
x: e.deltaX * multiplier,
|
|
2350
|
+
y: e.deltaY * multiplier,
|
|
2351
|
+
};
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2354
|
+
function scrollableOverflow(value: string | undefined): boolean {
|
|
2355
|
+
return value === "auto" || value === "scroll" || value === "overlay";
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
function canScrollElement(
|
|
2359
|
+
el: Element | null,
|
|
2360
|
+
axis: "x" | "y",
|
|
2361
|
+
delta: number,
|
|
2362
|
+
): boolean {
|
|
2363
|
+
if (!el || !(el instanceof HTMLElement)) return false;
|
|
2364
|
+
var style = window.getComputedStyle(el);
|
|
2365
|
+
var overflow = axis === "y" ? style.overflowY : style.overflowX;
|
|
2366
|
+
if (!scrollableOverflow(overflow)) return false;
|
|
2367
|
+
var max =
|
|
2368
|
+
axis === "y"
|
|
2369
|
+
? el.scrollHeight - el.clientHeight
|
|
2370
|
+
: el.scrollWidth - el.clientWidth;
|
|
2371
|
+
if (max <= 1) return false;
|
|
2372
|
+
var current = axis === "y" ? el.scrollTop : el.scrollLeft;
|
|
2373
|
+
if (delta < 0) return current > 0;
|
|
2374
|
+
if (delta > 0) return current < max - 1;
|
|
2375
|
+
return false;
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
function findScrollableElementForWheel(
|
|
2379
|
+
start: Element | null,
|
|
2380
|
+
deltaX: number,
|
|
2381
|
+
deltaY: number,
|
|
2382
|
+
): HTMLElement | Element | null {
|
|
2383
|
+
var node: Element | null = start;
|
|
2384
|
+
while (node && node.nodeType === 1) {
|
|
2385
|
+
if (
|
|
2386
|
+
canScrollElement(node, "y", deltaY) ||
|
|
2387
|
+
canScrollElement(node, "x", deltaX)
|
|
2388
|
+
) {
|
|
2389
|
+
return node;
|
|
2390
|
+
}
|
|
2391
|
+
node = node.parentElement;
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
var scrollingElement =
|
|
2395
|
+
document.scrollingElement || document.documentElement;
|
|
2396
|
+
var maxY = scrollingElement.scrollHeight - scrollingElement.clientHeight;
|
|
2397
|
+
var maxX = scrollingElement.scrollWidth - scrollingElement.clientWidth;
|
|
2398
|
+
var canScrollUp = false;
|
|
2399
|
+
var canScrollDown = false;
|
|
2400
|
+
var canScrollLeft = false;
|
|
2401
|
+
var canScrollRight = false;
|
|
2402
|
+
if (deltaY < 0) {
|
|
2403
|
+
canScrollUp = scrollingElement.scrollTop > 0;
|
|
2404
|
+
}
|
|
2405
|
+
if (deltaY > 0) {
|
|
2406
|
+
canScrollDown = scrollingElement.scrollTop < maxY - 1;
|
|
2407
|
+
}
|
|
2408
|
+
if (deltaX < 0) {
|
|
2409
|
+
canScrollLeft = scrollingElement.scrollLeft > 0;
|
|
2410
|
+
}
|
|
2411
|
+
if (deltaX > 0) {
|
|
2412
|
+
canScrollRight = scrollingElement.scrollLeft < maxX - 1;
|
|
2413
|
+
}
|
|
2414
|
+
if (canScrollUp || canScrollDown || canScrollLeft || canScrollRight) {
|
|
2415
|
+
return scrollingElement;
|
|
2416
|
+
}
|
|
2417
|
+
return null;
|
|
2418
|
+
}
|
|
2419
|
+
|
|
2420
|
+
function scrollElementByWheelDelta(
|
|
2421
|
+
el: HTMLElement | Element,
|
|
2422
|
+
deltaX: number,
|
|
2423
|
+
deltaY: number,
|
|
2424
|
+
): boolean {
|
|
2425
|
+
var anyEl = el as HTMLElement;
|
|
2426
|
+
var beforeLeft = anyEl.scrollLeft || 0;
|
|
2427
|
+
var beforeTop = anyEl.scrollTop || 0;
|
|
2428
|
+
if (typeof anyEl.scrollBy === "function") {
|
|
2429
|
+
anyEl.scrollBy({ left: deltaX, top: deltaY, behavior: "auto" });
|
|
2430
|
+
} else {
|
|
2431
|
+
anyEl.scrollLeft = beforeLeft + deltaX;
|
|
2432
|
+
anyEl.scrollTop = beforeTop + deltaY;
|
|
2433
|
+
}
|
|
2434
|
+
return anyEl.scrollLeft !== beforeLeft || anyEl.scrollTop !== beforeTop;
|
|
2435
|
+
}
|
|
2436
|
+
|
|
2437
|
+
function scrollUnderlyingElementAtWheel(e: WheelEvent): void {
|
|
2438
|
+
if (e.ctrlKey || e.metaKey) return;
|
|
2439
|
+
if (Math.abs(e.deltaX) < 0.01 && Math.abs(e.deltaY) < 0.01) return;
|
|
2440
|
+
var delta = normalizedWheelDelta(e);
|
|
2441
|
+
var target = elementFromEditorPoint(e.clientX, e.clientY);
|
|
2442
|
+
var scrollTarget = findScrollableElementForWheel(target, delta.x, delta.y);
|
|
2443
|
+
if (!scrollTarget) return;
|
|
2444
|
+
var didScroll = scrollElementByWheelDelta(scrollTarget, delta.x, delta.y);
|
|
2445
|
+
if (!didScroll) return;
|
|
2446
|
+
stopNativeInteraction(e);
|
|
2447
|
+
window.requestAnimationFrame(refreshOverlays);
|
|
2448
|
+
}
|
|
2449
|
+
|
|
1867
2450
|
function isEditorTypingTarget(target) {
|
|
1868
2451
|
if (!target || !target.closest) return false;
|
|
1869
2452
|
return !!target.closest(
|
|
@@ -1957,6 +2540,41 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
1957
2540
|
return !!(el && el.textContent && el.textContent.trim().length > 0);
|
|
1958
2541
|
}
|
|
1959
2542
|
|
|
2543
|
+
function hasTextCharacters(el: Element | null): boolean {
|
|
2544
|
+
return !!(el && el.textContent && el.textContent.length > 0);
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2547
|
+
function setSelectionOverlayResizeChromeVisible(visible: boolean): void {
|
|
2548
|
+
selectionOverlay
|
|
2549
|
+
.querySelectorAll(
|
|
2550
|
+
"[data-agent-native-edge-handle],[data-agent-native-edit-handle],[data-agent-native-rotate-handle]",
|
|
2551
|
+
)
|
|
2552
|
+
.forEach(function (node) {
|
|
2553
|
+
if (!(node instanceof HTMLElement)) return;
|
|
2554
|
+
node.style.display = visible ? "" : "none";
|
|
2555
|
+
});
|
|
2556
|
+
}
|
|
2557
|
+
|
|
2558
|
+
function updateTextEditingChrome(
|
|
2559
|
+
target: HTMLElement,
|
|
2560
|
+
originalMinWidth: string,
|
|
2561
|
+
originalMinHeight: string,
|
|
2562
|
+
): void {
|
|
2563
|
+
target.style.outline = "";
|
|
2564
|
+
target.style.outlineOffset = "";
|
|
2565
|
+
if (hasTextCharacters(target)) {
|
|
2566
|
+
target.style.minWidth = originalMinWidth;
|
|
2567
|
+
target.style.minHeight = originalMinHeight;
|
|
2568
|
+
positionOverlay(selectionOverlay, target);
|
|
2569
|
+
setSelectionOverlayResizeChromeVisible(false);
|
|
2570
|
+
return;
|
|
2571
|
+
}
|
|
2572
|
+
target.style.minWidth = originalMinWidth || "1px";
|
|
2573
|
+
target.style.minHeight = originalMinHeight || "1em";
|
|
2574
|
+
hideSelectionOverlay();
|
|
2575
|
+
setSelectionOverlayResizeChromeVisible(false);
|
|
2576
|
+
}
|
|
2577
|
+
|
|
1960
2578
|
function isInlineEditableDescendant(el: Element | null): boolean {
|
|
1961
2579
|
if (!el || !el.tagName) return false;
|
|
1962
2580
|
// Allowlist covers inline markup AND common block-level text containers
|
|
@@ -2075,19 +2693,20 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
2075
2693
|
}
|
|
2076
2694
|
selectedSpacingHovered = false;
|
|
2077
2695
|
hoveredSpacingHandleKey = "";
|
|
2696
|
+
var previousSelectedEl = selectedEl;
|
|
2078
2697
|
selectedEl = selectionTargetForHit(target);
|
|
2079
2698
|
if (!selectedEl || isLayerInteractionBlocked(selectedEl)) {
|
|
2080
2699
|
selectedEl = null;
|
|
2081
|
-
|
|
2082
|
-
clearComponentTag();
|
|
2700
|
+
hideSelectionOverlay();
|
|
2083
2701
|
return;
|
|
2084
2702
|
}
|
|
2085
|
-
var info = getElementInfo(selectedEl);
|
|
2086
2703
|
positionOverlay(selectionOverlay, selectedEl);
|
|
2087
|
-
(
|
|
2088
|
-
|
|
2089
|
-
|
|
2704
|
+
preservePreviousSelectedElementForShiftClick(
|
|
2705
|
+
previousSelectedEl,
|
|
2706
|
+
selectedEl,
|
|
2707
|
+
e,
|
|
2090
2708
|
);
|
|
2709
|
+
postElementSelect(selectedEl, e);
|
|
2091
2710
|
}
|
|
2092
2711
|
|
|
2093
2712
|
function suppressNextShieldClickBriefly() {
|
|
@@ -2101,6 +2720,182 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
2101
2720
|
}, 250);
|
|
2102
2721
|
}
|
|
2103
2722
|
|
|
2723
|
+
function clearActiveMarqueeSelection(): void {
|
|
2724
|
+
if (!activeMarqueeSelection) return;
|
|
2725
|
+
document.removeEventListener(
|
|
2726
|
+
activeMarqueeSelection.move,
|
|
2727
|
+
activeMarqueeSelection.onMove,
|
|
2728
|
+
true,
|
|
2729
|
+
);
|
|
2730
|
+
document.removeEventListener(
|
|
2731
|
+
activeMarqueeSelection.up,
|
|
2732
|
+
activeMarqueeSelection.onUp,
|
|
2733
|
+
true,
|
|
2734
|
+
);
|
|
2735
|
+
if (
|
|
2736
|
+
activeMarqueeSelection.pointerId !== undefined &&
|
|
2737
|
+
shieldOverlay.releasePointerCapture
|
|
2738
|
+
) {
|
|
2739
|
+
try {
|
|
2740
|
+
shieldOverlay.releasePointerCapture(activeMarqueeSelection.pointerId);
|
|
2741
|
+
} catch (_err) {}
|
|
2742
|
+
}
|
|
2743
|
+
activeMarqueeSelection = null;
|
|
2744
|
+
}
|
|
2745
|
+
|
|
2746
|
+
function marqueeRectFromPoints(
|
|
2747
|
+
startX: number,
|
|
2748
|
+
startY: number,
|
|
2749
|
+
endX: number,
|
|
2750
|
+
endY: number,
|
|
2751
|
+
): {
|
|
2752
|
+
left: number;
|
|
2753
|
+
top: number;
|
|
2754
|
+
right: number;
|
|
2755
|
+
bottom: number;
|
|
2756
|
+
width: number;
|
|
2757
|
+
height: number;
|
|
2758
|
+
} {
|
|
2759
|
+
var left = Math.min(startX, endX);
|
|
2760
|
+
var top = Math.min(startY, endY);
|
|
2761
|
+
var right = Math.max(startX, endX);
|
|
2762
|
+
var bottom = Math.max(startY, endY);
|
|
2763
|
+
return {
|
|
2764
|
+
left: left,
|
|
2765
|
+
top: top,
|
|
2766
|
+
right: right,
|
|
2767
|
+
bottom: bottom,
|
|
2768
|
+
width: Math.max(1, right - left),
|
|
2769
|
+
height: Math.max(1, bottom - top),
|
|
2770
|
+
};
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2773
|
+
function rectsIntersect(
|
|
2774
|
+
a: { left: number; top: number; right: number; bottom: number },
|
|
2775
|
+
b: { left: number; top: number; right: number; bottom: number },
|
|
2776
|
+
): boolean {
|
|
2777
|
+
return (
|
|
2778
|
+
a.left <= b.right &&
|
|
2779
|
+
a.right >= b.left &&
|
|
2780
|
+
a.top <= b.bottom &&
|
|
2781
|
+
a.bottom >= b.top
|
|
2782
|
+
);
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2785
|
+
function postElementMarqueeSelect(
|
|
2786
|
+
elements: Element[],
|
|
2787
|
+
additive: boolean,
|
|
2788
|
+
e,
|
|
2789
|
+
): void {
|
|
2790
|
+
(window.parent as Window).postMessage(
|
|
2791
|
+
{
|
|
2792
|
+
type: "agent-native:layer-marquee-selection",
|
|
2793
|
+
phase: "change",
|
|
2794
|
+
payload: elements.map(function (el) {
|
|
2795
|
+
return getElementInfo(el);
|
|
2796
|
+
}),
|
|
2797
|
+
intent: {
|
|
2798
|
+
additive: additive,
|
|
2799
|
+
range: Boolean(e && e.shiftKey),
|
|
2800
|
+
source: "marquee",
|
|
2801
|
+
shiftKey: Boolean(e && e.shiftKey),
|
|
2802
|
+
metaKey: Boolean(e && e.metaKey),
|
|
2803
|
+
ctrlKey: Boolean(e && e.ctrlKey),
|
|
2804
|
+
},
|
|
2805
|
+
},
|
|
2806
|
+
"*",
|
|
2807
|
+
);
|
|
2808
|
+
}
|
|
2809
|
+
|
|
2810
|
+
function updateMarqueeSelection(e): void {
|
|
2811
|
+
if (!activeMarqueeSelection) return;
|
|
2812
|
+
var rect = marqueeRectFromPoints(
|
|
2813
|
+
activeMarqueeSelection.startX,
|
|
2814
|
+
activeMarqueeSelection.startY,
|
|
2815
|
+
e.clientX,
|
|
2816
|
+
e.clientY,
|
|
2817
|
+
);
|
|
2818
|
+
marqueeSelectionOverlay.style.display = "block";
|
|
2819
|
+
marqueeSelectionOverlay.style.left = rect.left + "px";
|
|
2820
|
+
marqueeSelectionOverlay.style.top = rect.top + "px";
|
|
2821
|
+
marqueeSelectionOverlay.style.width = rect.width + "px";
|
|
2822
|
+
marqueeSelectionOverlay.style.height = rect.height + "px";
|
|
2823
|
+
|
|
2824
|
+
var hitElements = collectSelectableElements().filter(function (el) {
|
|
2825
|
+
var bounds = el.getBoundingClientRect();
|
|
2826
|
+
if (bounds.width <= 0 || bounds.height <= 0) return false;
|
|
2827
|
+
return rectsIntersect(rect, {
|
|
2828
|
+
left: bounds.left,
|
|
2829
|
+
top: bounds.top,
|
|
2830
|
+
right: bounds.right,
|
|
2831
|
+
bottom: bounds.bottom,
|
|
2832
|
+
});
|
|
2833
|
+
});
|
|
2834
|
+
var primary = hitElements[hitElements.length - 1] || null;
|
|
2835
|
+
if (primary) {
|
|
2836
|
+
selectedEl = primary;
|
|
2837
|
+
positionOverlay(selectionOverlay, primary);
|
|
2838
|
+
} else if (!activeMarqueeSelection.additive) {
|
|
2839
|
+
selectedEl = null;
|
|
2840
|
+
hideSelectionOverlay();
|
|
2841
|
+
}
|
|
2842
|
+
setPassiveSelectionElements(hitElements);
|
|
2843
|
+
postElementMarqueeSelect(hitElements, activeMarqueeSelection.additive, e);
|
|
2844
|
+
}
|
|
2845
|
+
|
|
2846
|
+
function beginMarqueeSelection(e): void {
|
|
2847
|
+
if (e.button !== 0 || activeTextEditEl) return;
|
|
2848
|
+
clearActiveMarqueeSelection();
|
|
2849
|
+
var events = dragEventNames(e);
|
|
2850
|
+
var additive = Boolean(e && (e.metaKey || e.ctrlKey || e.shiftKey));
|
|
2851
|
+
function onMove(ev) {
|
|
2852
|
+
if (!activeMarqueeSelection) return;
|
|
2853
|
+
if (
|
|
2854
|
+
!activeMarqueeSelection.moved &&
|
|
2855
|
+
Math.hypot(
|
|
2856
|
+
ev.clientX - activeMarqueeSelection.startX,
|
|
2857
|
+
ev.clientY - activeMarqueeSelection.startY,
|
|
2858
|
+
) <= 3
|
|
2859
|
+
) {
|
|
2860
|
+
return;
|
|
2861
|
+
}
|
|
2862
|
+
if (!activeMarqueeSelection.moved) {
|
|
2863
|
+
activeMarqueeSelection.moved = true;
|
|
2864
|
+
suppressNextShieldClickBriefly();
|
|
2865
|
+
}
|
|
2866
|
+
stopNativeInteraction(ev);
|
|
2867
|
+
updateMarqueeSelection(ev);
|
|
2868
|
+
}
|
|
2869
|
+
function onUp(ev) {
|
|
2870
|
+
var didMove = Boolean(activeMarqueeSelection?.moved);
|
|
2871
|
+
if (didMove) {
|
|
2872
|
+
stopNativeInteraction(ev);
|
|
2873
|
+
updateMarqueeSelection(ev);
|
|
2874
|
+
suppressNextShieldClickBriefly();
|
|
2875
|
+
}
|
|
2876
|
+
marqueeSelectionOverlay.style.display = "none";
|
|
2877
|
+
clearActiveMarqueeSelection();
|
|
2878
|
+
}
|
|
2879
|
+
activeMarqueeSelection = {
|
|
2880
|
+
startX: e.clientX,
|
|
2881
|
+
startY: e.clientY,
|
|
2882
|
+
additive: additive,
|
|
2883
|
+
moved: false,
|
|
2884
|
+
pointerId: e.pointerId,
|
|
2885
|
+
move: events.move,
|
|
2886
|
+
up: events.up,
|
|
2887
|
+
onMove: onMove,
|
|
2888
|
+
onUp: onUp,
|
|
2889
|
+
};
|
|
2890
|
+
if (e.pointerId !== undefined && shieldOverlay.setPointerCapture) {
|
|
2891
|
+
try {
|
|
2892
|
+
shieldOverlay.setPointerCapture(e.pointerId);
|
|
2893
|
+
} catch (_err) {}
|
|
2894
|
+
}
|
|
2895
|
+
document.addEventListener(events.move, onMove, true);
|
|
2896
|
+
document.addEventListener(events.up, onUp, true);
|
|
2897
|
+
}
|
|
2898
|
+
|
|
2104
2899
|
function openContextMenuAtEvent(e) {
|
|
2105
2900
|
stopNativeInteraction(e);
|
|
2106
2901
|
blurActiveTextEditor();
|
|
@@ -2114,14 +2909,10 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
2114
2909
|
if (selectedEl && !isLayerInteractionBlocked(selectedEl)) {
|
|
2115
2910
|
info = getElementInfo(selectedEl);
|
|
2116
2911
|
positionOverlay(selectionOverlay, selectedEl);
|
|
2117
|
-
(
|
|
2118
|
-
{ type: "element-select", payload: info },
|
|
2119
|
-
"*",
|
|
2120
|
-
);
|
|
2912
|
+
postElementSelect(selectedEl, e);
|
|
2121
2913
|
} else {
|
|
2122
2914
|
selectedEl = null;
|
|
2123
|
-
|
|
2124
|
-
clearComponentTag();
|
|
2915
|
+
hideSelectionOverlay();
|
|
2125
2916
|
}
|
|
2126
2917
|
}
|
|
2127
2918
|
(window.parent as Window).postMessage(
|
|
@@ -2181,7 +2972,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
2181
2972
|
!document.documentElement.contains(selectedEl)
|
|
2182
2973
|
) {
|
|
2183
2974
|
selectedEl = null;
|
|
2184
|
-
|
|
2975
|
+
hideSelectionOverlay();
|
|
2185
2976
|
}
|
|
2186
2977
|
hoveredEl = null;
|
|
2187
2978
|
highlightOverlay.style.display = "none";
|
|
@@ -2299,8 +3090,13 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
2299
3090
|
}
|
|
2300
3091
|
|
|
2301
3092
|
function startSpacingDrag(key, e) {
|
|
3093
|
+
if (spacingDrag) {
|
|
3094
|
+
stopNativeInteraction(e);
|
|
3095
|
+
return;
|
|
3096
|
+
}
|
|
2302
3097
|
var handle = spacingHandleStateByKey[key];
|
|
2303
3098
|
if (!selectedEl || !handle || isLayerInteractionBlocked(selectedEl)) return;
|
|
3099
|
+
clearSpacingHoverTimer();
|
|
2304
3100
|
e.preventDefault();
|
|
2305
3101
|
e.stopPropagation();
|
|
2306
3102
|
if (e.stopImmediatePropagation) e.stopImmediatePropagation();
|
|
@@ -2309,6 +3105,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
2309
3105
|
var originValue = handle.value;
|
|
2310
3106
|
var startX = e.clientX;
|
|
2311
3107
|
var startY = e.clientY;
|
|
3108
|
+
lastSpacingPointerPoint = { x: startX, y: startY };
|
|
2312
3109
|
hoveredSpacingHandleKey = key;
|
|
2313
3110
|
selectedSpacingHovered = true;
|
|
2314
3111
|
spacingDrag = {
|
|
@@ -2333,6 +3130,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
2333
3130
|
currentValue: nextValue,
|
|
2334
3131
|
mirrorOpposite: !!ev.altKey,
|
|
2335
3132
|
};
|
|
3133
|
+
lastSpacingPointerPoint = { x: ev.clientX, y: ev.clientY };
|
|
2336
3134
|
applySpacingDragValue(dragEl, handle, nextValue, !!ev.altKey);
|
|
2337
3135
|
positionOverlay(selectionOverlay, dragEl);
|
|
2338
3136
|
showSpacingBadgeForHandle(handle, nextValue);
|
|
@@ -2533,6 +3331,72 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
2533
3331
|
return true;
|
|
2534
3332
|
}
|
|
2535
3333
|
|
|
3334
|
+
function isAutoLayoutElement(el: Element | null): boolean {
|
|
3335
|
+
if (!el) return false;
|
|
3336
|
+
var cs = window.getComputedStyle(el);
|
|
3337
|
+
return (
|
|
3338
|
+
cs.display === "flex" ||
|
|
3339
|
+
cs.display === "inline-flex" ||
|
|
3340
|
+
cs.display === "grid" ||
|
|
3341
|
+
cs.display === "inline-grid"
|
|
3342
|
+
);
|
|
3343
|
+
}
|
|
3344
|
+
|
|
3345
|
+
function isOutsideIframeViewport(clientX: number, clientY: number): boolean {
|
|
3346
|
+
return (
|
|
3347
|
+
clientX < 0 ||
|
|
3348
|
+
clientY < 0 ||
|
|
3349
|
+
clientX > window.innerWidth ||
|
|
3350
|
+
clientY > window.innerHeight
|
|
3351
|
+
);
|
|
3352
|
+
}
|
|
3353
|
+
|
|
3354
|
+
function postCrossScreenDrag(
|
|
3355
|
+
phase: "start" | "move" | "end" | "cancel",
|
|
3356
|
+
el?: Element | null,
|
|
3357
|
+
ev?: { clientX?: number; clientY?: number } | null,
|
|
3358
|
+
): void {
|
|
3359
|
+
if (phase === "cancel") {
|
|
3360
|
+
(window.parent as Window).postMessage(
|
|
3361
|
+
{ type: "agent-native:cross-screen-drag", phase: "cancel" },
|
|
3362
|
+
"*",
|
|
3363
|
+
);
|
|
3364
|
+
return;
|
|
3365
|
+
}
|
|
3366
|
+
var rect = el ? el.getBoundingClientRect() : null;
|
|
3367
|
+
var pointerOffset =
|
|
3368
|
+
rect && ev?.clientX !== undefined && ev.clientY !== undefined
|
|
3369
|
+
? {
|
|
3370
|
+
x: ev.clientX - rect.left,
|
|
3371
|
+
y: ev.clientY - rect.top,
|
|
3372
|
+
}
|
|
3373
|
+
: undefined;
|
|
3374
|
+
(window.parent as Window).postMessage(
|
|
3375
|
+
{
|
|
3376
|
+
type: "agent-native:cross-screen-drag",
|
|
3377
|
+
phase,
|
|
3378
|
+
screenId: designCanvasScreenId,
|
|
3379
|
+
boardSurface: designCanvasBoardSurface,
|
|
3380
|
+
selector: getSelector(el ?? null),
|
|
3381
|
+
sourceId: getSourceId(el ?? null),
|
|
3382
|
+
iframeX: ev?.clientX ?? 0,
|
|
3383
|
+
iframeY: ev?.clientY ?? 0,
|
|
3384
|
+
viewportW: window.innerWidth,
|
|
3385
|
+
viewportH: window.innerHeight,
|
|
3386
|
+
elementRect: rect
|
|
3387
|
+
? {
|
|
3388
|
+
left: rect.left,
|
|
3389
|
+
top: rect.top,
|
|
3390
|
+
width: rect.width,
|
|
3391
|
+
height: rect.height,
|
|
3392
|
+
}
|
|
3393
|
+
: undefined,
|
|
3394
|
+
pointerOffset,
|
|
3395
|
+
},
|
|
3396
|
+
"*",
|
|
3397
|
+
);
|
|
3398
|
+
}
|
|
3399
|
+
|
|
2536
3400
|
// keep in sync with EditPanel.tsx CONTAINER_TAGS/LEAF_TAGS (~line 1679)
|
|
2537
3401
|
var BRIDGE_CONTAINER_TAGS = [
|
|
2538
3402
|
"div",
|
|
@@ -2711,6 +3575,66 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
2711
3575
|
return { anchor: anchor, placement: placement, axis: axis };
|
|
2712
3576
|
}
|
|
2713
3577
|
|
|
3578
|
+
function elementFromEditorPointIgnoring(
|
|
3579
|
+
clientX: number,
|
|
3580
|
+
clientY: number,
|
|
3581
|
+
ignore: Element | null,
|
|
3582
|
+
): Element | null {
|
|
3583
|
+
var previousPointerEvents: string | null = null;
|
|
3584
|
+
if (ignore && ignore instanceof HTMLElement) {
|
|
3585
|
+
previousPointerEvents = ignore.style.pointerEvents;
|
|
3586
|
+
ignore.style.pointerEvents = "none";
|
|
3587
|
+
}
|
|
3588
|
+
var hit = elementFromEditorPoint(clientX, clientY);
|
|
3589
|
+
if (ignore && ignore instanceof HTMLElement) {
|
|
3590
|
+
ignore.style.pointerEvents = previousPointerEvents ?? "";
|
|
3591
|
+
}
|
|
3592
|
+
return hit;
|
|
3593
|
+
}
|
|
3594
|
+
|
|
3595
|
+
function autoLayoutInsertionTargetForPoint(el, clientX, clientY) {
|
|
3596
|
+
var hit = elementFromEditorPointIgnoring(clientX, clientY, el);
|
|
3597
|
+
if (!hit || hit === document.documentElement || hit === document.body) {
|
|
3598
|
+
return null;
|
|
3599
|
+
}
|
|
3600
|
+
var cursor = hit;
|
|
3601
|
+
while (cursor && cursor !== document.body) {
|
|
3602
|
+
if (
|
|
3603
|
+
cursor === el ||
|
|
3604
|
+
(el && el.contains && el.contains(cursor)) ||
|
|
3605
|
+
isOverlayElement(cursor) ||
|
|
3606
|
+
isLayerInteractionBlocked(cursor)
|
|
3607
|
+
) {
|
|
3608
|
+
cursor = cursor.parentElement;
|
|
3609
|
+
continue;
|
|
3610
|
+
}
|
|
3611
|
+
var parent = cursor.parentElement;
|
|
3612
|
+
if (parent && isAutoLayoutElement(parent)) {
|
|
3613
|
+
var parentAxis = parentFlowAxis(parent);
|
|
3614
|
+
var childRect = cursor.getBoundingClientRect();
|
|
3615
|
+
var childCenter =
|
|
3616
|
+
parentAxis === "x"
|
|
3617
|
+
? childRect.left + childRect.width / 2
|
|
3618
|
+
: childRect.top + childRect.height / 2;
|
|
3619
|
+
var childPointer = parentAxis === "x" ? clientX : clientY;
|
|
3620
|
+
return {
|
|
3621
|
+
anchor: cursor,
|
|
3622
|
+
placement: childPointer < childCenter ? "before" : "after",
|
|
3623
|
+
axis: parentAxis,
|
|
3624
|
+
};
|
|
3625
|
+
}
|
|
3626
|
+
if (isAutoLayoutElement(cursor) && isContainerDropTarget(cursor)) {
|
|
3627
|
+
return {
|
|
3628
|
+
anchor: cursor,
|
|
3629
|
+
placement: "inside",
|
|
3630
|
+
axis: parentFlowAxis(cursor),
|
|
3631
|
+
};
|
|
3632
|
+
}
|
|
3633
|
+
cursor = parent;
|
|
3634
|
+
}
|
|
3635
|
+
return null;
|
|
3636
|
+
}
|
|
3637
|
+
|
|
2714
3638
|
function showInsertionGuideFor(target) {
|
|
2715
3639
|
if (!target || !target.anchor) {
|
|
2716
3640
|
hideInsertionGuide();
|
|
@@ -2830,10 +3754,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
2830
3754
|
selectedEl = clone;
|
|
2831
3755
|
duplicatedForDrag = true;
|
|
2832
3756
|
positionOverlay(selectionOverlay, selectedEl);
|
|
2833
|
-
(
|
|
2834
|
-
{ type: "element-select", payload: getElementInfo(selectedEl) },
|
|
2835
|
-
"*",
|
|
2836
|
-
);
|
|
3757
|
+
postElementSelect(selectedEl, e);
|
|
2837
3758
|
}
|
|
2838
3759
|
if (isFlowReorderCandidate(selectedEl)) {
|
|
2839
3760
|
// Snapshot the element being reordered so a concurrent select-element or
|
|
@@ -2905,10 +3826,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
2905
3826
|
reorderEl.parentElement.removeChild(reorderEl);
|
|
2906
3827
|
selectedEl = originalSelectedEl;
|
|
2907
3828
|
positionOverlay(selectionOverlay, selectedEl);
|
|
2908
|
-
(
|
|
2909
|
-
{ type: "element-select", payload: getElementInfo(selectedEl) },
|
|
2910
|
-
"*",
|
|
2911
|
-
);
|
|
3829
|
+
postElementSelect(selectedEl);
|
|
2912
3830
|
}
|
|
2913
3831
|
}
|
|
2914
3832
|
function onReorderKeyDown(ev) {
|
|
@@ -2964,10 +3882,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
2964
3882
|
reorderEl.parentElement.removeChild(reorderEl);
|
|
2965
3883
|
selectedEl = originalSelectedEl;
|
|
2966
3884
|
positionOverlay(selectionOverlay, selectedEl);
|
|
2967
|
-
(
|
|
2968
|
-
{ type: "element-select", payload: getElementInfo(selectedEl) },
|
|
2969
|
-
"*",
|
|
2970
|
-
);
|
|
3885
|
+
postElementSelect(selectedEl);
|
|
2971
3886
|
}
|
|
2972
3887
|
return;
|
|
2973
3888
|
}
|
|
@@ -3000,6 +3915,10 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3000
3915
|
}
|
|
3001
3916
|
ensurePositionable(selectedEl);
|
|
3002
3917
|
var cs = window.getComputedStyle(selectedEl);
|
|
3918
|
+
var originalInlinePosition = (selectedEl as HTMLElement).style.position;
|
|
3919
|
+
var originalInlineLeft = (selectedEl as HTMLElement).style.left;
|
|
3920
|
+
var originalInlineTop = (selectedEl as HTMLElement).style.top;
|
|
3921
|
+
var originalInlineOpacity = (selectedEl as HTMLElement).style.opacity;
|
|
3003
3922
|
var originLeft = readPx((selectedEl as HTMLElement).style.left || cs.left);
|
|
3004
3923
|
var originTop = readPx(selectedEl.style.top || cs.top);
|
|
3005
3924
|
var startX = e.clientX;
|
|
@@ -3010,6 +3929,14 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3010
3929
|
var dragEl = selectedEl;
|
|
3011
3930
|
var moved = false;
|
|
3012
3931
|
var DRAG_THRESHOLD = 3;
|
|
3932
|
+
var currentAutoLayoutTarget: {
|
|
3933
|
+
anchor: Element;
|
|
3934
|
+
placement: string;
|
|
3935
|
+
axis?: string;
|
|
3936
|
+
} | null = null;
|
|
3937
|
+
if (!duplicatedForDrag) {
|
|
3938
|
+
postCrossScreenDrag("start", dragEl, e);
|
|
3939
|
+
}
|
|
3013
3940
|
function onMove(ev) {
|
|
3014
3941
|
if (
|
|
3015
3942
|
!moved &&
|
|
@@ -3021,32 +3948,80 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3021
3948
|
var nextTop = originTop + ev.clientY - startY;
|
|
3022
3949
|
(dragEl as HTMLElement).style.left = Math.round(nextLeft) + "px";
|
|
3023
3950
|
(dragEl as HTMLElement).style.top = Math.round(nextTop) + "px";
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3951
|
+
if (!duplicatedForDrag) {
|
|
3952
|
+
postCrossScreenDrag("move", dragEl, ev);
|
|
3953
|
+
}
|
|
3954
|
+
if (
|
|
3955
|
+
!duplicatedForDrag &&
|
|
3956
|
+
isOutsideIframeViewport(ev.clientX, ev.clientY)
|
|
3957
|
+
) {
|
|
3958
|
+
currentAutoLayoutTarget = null;
|
|
3959
|
+
hideInsertionGuide();
|
|
3960
|
+
(dragEl as HTMLElement).style.opacity = originalInlineOpacity;
|
|
3961
|
+
} else {
|
|
3962
|
+
currentAutoLayoutTarget = !duplicatedForDrag
|
|
3963
|
+
? autoLayoutInsertionTargetForPoint(dragEl, ev.clientX, ev.clientY)
|
|
3964
|
+
: null;
|
|
3965
|
+
if (currentAutoLayoutTarget) {
|
|
3966
|
+
showInsertionGuideFor(currentAutoLayoutTarget);
|
|
3967
|
+
(dragEl as HTMLElement).style.opacity = "0.4";
|
|
3968
|
+
} else {
|
|
3969
|
+
hideInsertionGuide();
|
|
3970
|
+
(dragEl as HTMLElement).style.opacity = originalInlineOpacity;
|
|
3971
|
+
}
|
|
3972
|
+
}
|
|
3973
|
+
hideTransformBadge();
|
|
3029
3974
|
refreshOverlays();
|
|
3030
3975
|
}
|
|
3031
|
-
function
|
|
3976
|
+
function restoreSourceDragPosition(): void {
|
|
3977
|
+
(dragEl as HTMLElement).style.position = originalInlinePosition;
|
|
3978
|
+
(dragEl as HTMLElement).style.left = originalInlineLeft;
|
|
3979
|
+
(dragEl as HTMLElement).style.top = originalInlineTop;
|
|
3980
|
+
(dragEl as HTMLElement).style.opacity = originalInlineOpacity;
|
|
3981
|
+
selectedEl = originalSelectedEl;
|
|
3982
|
+
positionOverlay(selectionOverlay, selectedEl);
|
|
3983
|
+
}
|
|
3984
|
+
function onUp(ev) {
|
|
3032
3985
|
document.removeEventListener(events.move, onMove, true);
|
|
3033
3986
|
document.removeEventListener(events.up, onUp, true);
|
|
3034
3987
|
hideTransformBadge();
|
|
3988
|
+
hideInsertionGuide();
|
|
3035
3989
|
if (!dragEl) return;
|
|
3990
|
+
var outsideOnDrop = ev
|
|
3991
|
+
? isOutsideIframeViewport(ev.clientX, ev.clientY)
|
|
3992
|
+
: false;
|
|
3993
|
+
if (
|
|
3994
|
+
ev &&
|
|
3995
|
+
!duplicatedForDrag &&
|
|
3996
|
+
(outsideOnDrop || designCanvasBoardSurface)
|
|
3997
|
+
) {
|
|
3998
|
+
postCrossScreenDrag("end", dragEl, ev);
|
|
3999
|
+
}
|
|
4000
|
+
if (ev && !duplicatedForDrag && outsideOnDrop) {
|
|
4001
|
+
restoreSourceDragPosition();
|
|
4002
|
+
return;
|
|
4003
|
+
}
|
|
3036
4004
|
if (duplicatedForDrag && !moved) {
|
|
3037
4005
|
// Alt-click with no real drag — remove the premature clone and restore the original selection.
|
|
3038
4006
|
if (dragEl.parentElement) dragEl.parentElement.removeChild(dragEl);
|
|
3039
4007
|
selectedEl = originalSelectedEl;
|
|
3040
4008
|
positionOverlay(selectionOverlay, selectedEl);
|
|
3041
|
-
(
|
|
3042
|
-
{ type: "element-select", payload: getElementInfo(selectedEl) },
|
|
3043
|
-
"*",
|
|
3044
|
-
);
|
|
4009
|
+
postElementSelect(selectedEl);
|
|
3045
4010
|
return;
|
|
3046
4011
|
}
|
|
3047
4012
|
if (duplicatedForDrag) {
|
|
3048
4013
|
postVisualDuplicateChange(originalSelectedEl, dragEl);
|
|
4014
|
+
} else if (currentAutoLayoutTarget) {
|
|
4015
|
+
(dragEl as HTMLElement).style.opacity = originalInlineOpacity;
|
|
4016
|
+
var prevParent = dragEl.parentElement;
|
|
4017
|
+
var prevNextSibling = dragEl.nextSibling;
|
|
4018
|
+
applyRuntimeReorder(dragEl, currentAutoLayoutTarget);
|
|
4019
|
+
postVisualStructureChange(dragEl, currentAutoLayoutTarget, {
|
|
4020
|
+
prevParent: prevParent,
|
|
4021
|
+
prevNextSibling: prevNextSibling,
|
|
4022
|
+
});
|
|
3049
4023
|
} else {
|
|
4024
|
+
(dragEl as HTMLElement).style.opacity = originalInlineOpacity;
|
|
3050
4025
|
(window.parent as Window).postMessage(
|
|
3051
4026
|
{
|
|
3052
4027
|
type: "visual-style-change",
|
|
@@ -3060,6 +4035,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3060
4035
|
},
|
|
3061
4036
|
"*",
|
|
3062
4037
|
);
|
|
4038
|
+
postCrossScreenDrag("cancel");
|
|
3063
4039
|
}
|
|
3064
4040
|
}
|
|
3065
4041
|
document.addEventListener(events.move, onMove, true);
|
|
@@ -3274,6 +4250,14 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3274
4250
|
pendingShieldDrag.onUp,
|
|
3275
4251
|
true,
|
|
3276
4252
|
);
|
|
4253
|
+
if (
|
|
4254
|
+
pendingShieldDrag.pointerId !== undefined &&
|
|
4255
|
+
shieldOverlay.releasePointerCapture
|
|
4256
|
+
) {
|
|
4257
|
+
try {
|
|
4258
|
+
shieldOverlay.releasePointerCapture(pendingShieldDrag.pointerId);
|
|
4259
|
+
} catch (_err) {}
|
|
4260
|
+
}
|
|
3277
4261
|
pendingShieldDrag = null;
|
|
3278
4262
|
}
|
|
3279
4263
|
|
|
@@ -3282,15 +4266,23 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3282
4266
|
if (e.button !== 0 || activeTextEditEl) return;
|
|
3283
4267
|
var events = dragEventNames(e);
|
|
3284
4268
|
var hit = elementFromEditorPoint(e.clientX, e.clientY);
|
|
3285
|
-
|
|
4269
|
+
var hitTarget = selectionTargetForHit(hit);
|
|
4270
|
+
if (
|
|
4271
|
+
!hit ||
|
|
4272
|
+
hit === document.body ||
|
|
4273
|
+
hit === document.documentElement ||
|
|
4274
|
+
isBoardRootMarqueeSurface(hitTarget)
|
|
4275
|
+
) {
|
|
4276
|
+
beginMarqueeSelection(e);
|
|
3286
4277
|
return;
|
|
4278
|
+
}
|
|
3287
4279
|
var dragTarget =
|
|
3288
4280
|
selectedEl &&
|
|
3289
4281
|
document.documentElement.contains(selectedEl) &&
|
|
3290
4282
|
selectedEl.contains(hit)
|
|
3291
4283
|
? selectedEl
|
|
3292
|
-
:
|
|
3293
|
-
var clickTarget =
|
|
4284
|
+
: hitTarget;
|
|
4285
|
+
var clickTarget = hitTarget;
|
|
3294
4286
|
if (
|
|
3295
4287
|
!dragTarget ||
|
|
3296
4288
|
dragTarget === document.body ||
|
|
@@ -3299,30 +4291,48 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3299
4291
|
) {
|
|
3300
4292
|
return;
|
|
3301
4293
|
}
|
|
4294
|
+
if (
|
|
4295
|
+
e.pointerId !== undefined &&
|
|
4296
|
+
shieldOverlay.setPointerCapture &&
|
|
4297
|
+
!e.altKey
|
|
4298
|
+
) {
|
|
4299
|
+
try {
|
|
4300
|
+
shieldOverlay.setPointerCapture(e.pointerId);
|
|
4301
|
+
} catch (_err) {}
|
|
4302
|
+
}
|
|
4303
|
+
if (!e.altKey) {
|
|
4304
|
+
postCrossScreenDrag("start", dragTarget, e);
|
|
4305
|
+
}
|
|
3302
4306
|
var startX = e.clientX;
|
|
3303
4307
|
var startY = e.clientY;
|
|
3304
4308
|
var didStartDrag = false;
|
|
3305
|
-
function selectTarget(target) {
|
|
4309
|
+
function selectTarget(target, ev?: MouseEvent) {
|
|
4310
|
+
var previousSelectedEl = selectedEl;
|
|
3306
4311
|
selectedEl = target;
|
|
3307
4312
|
positionOverlay(selectionOverlay, selectedEl);
|
|
3308
|
-
(
|
|
3309
|
-
|
|
3310
|
-
|
|
4313
|
+
preservePreviousSelectedElementForShiftClick(
|
|
4314
|
+
previousSelectedEl,
|
|
4315
|
+
selectedEl,
|
|
4316
|
+
ev,
|
|
3311
4317
|
);
|
|
4318
|
+
postElementSelect(selectedEl, ev);
|
|
3312
4319
|
}
|
|
3313
4320
|
function onMove(ev) {
|
|
3314
4321
|
if (Math.hypot(ev.clientX - startX, ev.clientY - startY) <= 3) return;
|
|
3315
4322
|
clearPendingShieldDrag();
|
|
3316
4323
|
didStartDrag = true;
|
|
3317
|
-
selectTarget(dragTarget);
|
|
4324
|
+
selectTarget(dragTarget, ev);
|
|
3318
4325
|
suppressNextShieldClickBriefly();
|
|
3319
4326
|
startMove(ev);
|
|
3320
4327
|
}
|
|
3321
4328
|
function onUp(ev) {
|
|
3322
4329
|
clearPendingShieldDrag();
|
|
3323
4330
|
if (didStartDrag) return;
|
|
4331
|
+
if (!e.altKey) {
|
|
4332
|
+
postCrossScreenDrag("cancel");
|
|
4333
|
+
}
|
|
3324
4334
|
if (ev) stopNativeInteraction(ev);
|
|
3325
|
-
selectTarget(clickTarget || dragTarget);
|
|
4335
|
+
selectTarget(clickTarget || dragTarget, ev);
|
|
3326
4336
|
suppressNextShieldClickBriefly();
|
|
3327
4337
|
}
|
|
3328
4338
|
clearPendingShieldDrag();
|
|
@@ -3331,6 +4341,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3331
4341
|
up: events.up,
|
|
3332
4342
|
onMove: onMove,
|
|
3333
4343
|
onUp: onUp,
|
|
4344
|
+
pointerId: e.pointerId,
|
|
3334
4345
|
};
|
|
3335
4346
|
document.addEventListener(events.move, onMove, true);
|
|
3336
4347
|
document.addEventListener(events.up, onUp, true);
|
|
@@ -3372,6 +4383,10 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3372
4383
|
);
|
|
3373
4384
|
|
|
3374
4385
|
shieldOverlay.addEventListener("pointerdown", beginPotentialShieldDrag, true);
|
|
4386
|
+
shieldOverlay.addEventListener("wheel", scrollUnderlyingElementAtWheel, {
|
|
4387
|
+
passive: false,
|
|
4388
|
+
capture: true,
|
|
4389
|
+
});
|
|
3375
4390
|
|
|
3376
4391
|
["pointerdown", "pointerup", "mousedown", "mouseup", "auxclick"].forEach(
|
|
3377
4392
|
function (type) {
|
|
@@ -3491,19 +4506,18 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3491
4506
|
selectedEl = selectionTargetForHit(target) || target;
|
|
3492
4507
|
var originalText = target.textContent || "";
|
|
3493
4508
|
var originalHtml = target.innerHTML || "";
|
|
4509
|
+
var originalMinWidth = target.style.minWidth;
|
|
4510
|
+
var originalMinHeight = target.style.minHeight;
|
|
4511
|
+
var originalBorderColor = target.style.borderColor;
|
|
3494
4512
|
var committed = false;
|
|
3495
4513
|
activeTextEditEl = target;
|
|
3496
4514
|
target.setAttribute("contenteditable", "true");
|
|
3497
4515
|
target.setAttribute("data-agent-native-text-editing", "true");
|
|
3498
4516
|
target.style.cursor = "text";
|
|
3499
|
-
target.style.
|
|
3500
|
-
target.style.outlineOffset = "2px";
|
|
4517
|
+
target.style.borderColor = "transparent";
|
|
3501
4518
|
setTextEditingPointerPassthrough(true);
|
|
3502
|
-
|
|
3503
|
-
(
|
|
3504
|
-
{ type: "element-select", payload: getElementInfo(target) },
|
|
3505
|
-
"*",
|
|
3506
|
-
);
|
|
4519
|
+
updateTextEditingChrome(target, originalMinWidth, originalMinHeight);
|
|
4520
|
+
postElementSelect(target, e);
|
|
3507
4521
|
(window.parent as Window).postMessage(
|
|
3508
4522
|
{ type: "element-dblclick-text", payload: getElementInfo(target) },
|
|
3509
4523
|
"*",
|
|
@@ -3516,6 +4530,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3516
4530
|
target.removeEventListener("blur", onBlur, true);
|
|
3517
4531
|
target.removeEventListener("keydown", onKeyDown, true);
|
|
3518
4532
|
target.removeEventListener("paste", onPaste, true);
|
|
4533
|
+
target.removeEventListener("input", onInput, true);
|
|
3519
4534
|
target.removeEventListener("keyup", onSelectionChange, true);
|
|
3520
4535
|
target.removeEventListener("mouseup", onSelectionChange, true);
|
|
3521
4536
|
document.removeEventListener("selectionchange", onSelectionChange);
|
|
@@ -3524,7 +4539,11 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3524
4539
|
target.style.cursor = "";
|
|
3525
4540
|
target.style.outline = "";
|
|
3526
4541
|
target.style.outlineOffset = "";
|
|
4542
|
+
target.style.minWidth = originalMinWidth;
|
|
4543
|
+
target.style.minHeight = originalMinHeight;
|
|
4544
|
+
target.style.borderColor = originalBorderColor;
|
|
3527
4545
|
setTextEditingPointerPassthrough(false);
|
|
4546
|
+
setSelectionOverlayResizeChromeVisible(true);
|
|
3528
4547
|
if (activeTextEditEl === target) activeTextEditEl = null;
|
|
3529
4548
|
postTextEditingState(target, false);
|
|
3530
4549
|
if (!commit) {
|
|
@@ -3547,7 +4566,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3547
4566
|
function onKeyDown(ev) {
|
|
3548
4567
|
if (ev.key === "Escape") {
|
|
3549
4568
|
ev.preventDefault();
|
|
3550
|
-
finish(
|
|
4569
|
+
finish(true);
|
|
3551
4570
|
target.blur();
|
|
3552
4571
|
return;
|
|
3553
4572
|
}
|
|
@@ -3563,15 +4582,24 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3563
4582
|
insertPlainTextAtSelection(
|
|
3564
4583
|
(ev.clipboardData && ev.clipboardData.getData("text/plain")) || "",
|
|
3565
4584
|
);
|
|
4585
|
+
updateTextEditingChrome(target, originalMinWidth, originalMinHeight);
|
|
4586
|
+
postTextEditingState(target, true);
|
|
4587
|
+
}
|
|
4588
|
+
|
|
4589
|
+
function onInput() {
|
|
4590
|
+
updateTextEditingChrome(target, originalMinWidth, originalMinHeight);
|
|
4591
|
+
postTextEditingState(target, true);
|
|
3566
4592
|
}
|
|
3567
4593
|
|
|
3568
4594
|
function onSelectionChange() {
|
|
4595
|
+
updateTextEditingChrome(target, originalMinWidth, originalMinHeight);
|
|
3569
4596
|
postTextEditingState(target, true);
|
|
3570
4597
|
}
|
|
3571
4598
|
|
|
3572
4599
|
target.addEventListener("blur", onBlur, true);
|
|
3573
4600
|
target.addEventListener("keydown", onKeyDown, true);
|
|
3574
4601
|
target.addEventListener("paste", onPaste, true);
|
|
4602
|
+
target.addEventListener("input", onInput, true);
|
|
3575
4603
|
target.addEventListener("keyup", onSelectionChange, true);
|
|
3576
4604
|
target.addEventListener("mouseup", onSelectionChange, true);
|
|
3577
4605
|
document.addEventListener("selectionchange", onSelectionChange);
|
|
@@ -3602,9 +4630,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3602
4630
|
if (!hoveredEl) {
|
|
3603
4631
|
highlightOverlay.style.display = "none";
|
|
3604
4632
|
if (!spacingDrag) {
|
|
3605
|
-
|
|
3606
|
-
hoveredSpacingHandleKey = "";
|
|
3607
|
-
updateSpacingOverlay(selectedEl);
|
|
4633
|
+
scheduleSpacingHoverClear(e);
|
|
3608
4634
|
}
|
|
3609
4635
|
hideMeasurements();
|
|
3610
4636
|
return;
|
|
@@ -3612,14 +4638,19 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3612
4638
|
if (hoveredEl && hoveredEl.closest("[data-agent-native-text-editing]"))
|
|
3613
4639
|
return;
|
|
3614
4640
|
if (!spacingDrag) {
|
|
3615
|
-
|
|
4641
|
+
var hoveringSelectedSpacingSurface = Boolean(
|
|
3616
4642
|
selectedEl &&
|
|
3617
4643
|
hoveredEl &&
|
|
3618
4644
|
(hoveredEl === selectedEl ||
|
|
3619
4645
|
(selectedEl.contains && selectedEl.contains(hoveredEl))),
|
|
3620
4646
|
);
|
|
3621
|
-
if (
|
|
3622
|
-
|
|
4647
|
+
if (hoveringSelectedSpacingSurface) {
|
|
4648
|
+
clearSpacingHoverTimer();
|
|
4649
|
+
selectedSpacingHovered = true;
|
|
4650
|
+
updateSpacingOverlay(selectedEl);
|
|
4651
|
+
} else {
|
|
4652
|
+
scheduleSpacingHoverClear(e);
|
|
4653
|
+
}
|
|
3623
4654
|
}
|
|
3624
4655
|
if (hoveredEl === selectedEl) {
|
|
3625
4656
|
highlightOverlay.style.display = "none";
|
|
@@ -3655,9 +4686,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3655
4686
|
return;
|
|
3656
4687
|
}
|
|
3657
4688
|
if (!spacingDrag) {
|
|
3658
|
-
|
|
3659
|
-
hoveredSpacingHandleKey = "";
|
|
3660
|
-
updateSpacingOverlay(selectedEl);
|
|
4689
|
+
scheduleSpacingHoverClear(e);
|
|
3661
4690
|
}
|
|
3662
4691
|
},
|
|
3663
4692
|
true,
|
|
@@ -3673,9 +4702,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3673
4702
|
}
|
|
3674
4703
|
hoveredEl = null;
|
|
3675
4704
|
if (!spacingDrag) {
|
|
3676
|
-
|
|
3677
|
-
hoveredSpacingHandleKey = "";
|
|
3678
|
-
updateSpacingOverlay(selectedEl);
|
|
4705
|
+
scheduleSpacingHoverClear(e);
|
|
3679
4706
|
}
|
|
3680
4707
|
highlightOverlay.style.display = "none";
|
|
3681
4708
|
hideMeasurements();
|
|
@@ -3783,9 +4810,59 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3783
4810
|
return;
|
|
3784
4811
|
}
|
|
3785
4812
|
if (e.data.type === "clear-selection") {
|
|
4813
|
+
// During marquee drag, empty hit sets are replayed back from the host as a
|
|
4814
|
+
// clear-selection state. Keep the drag-owned rectangle alive until pointer-up.
|
|
4815
|
+
if (activeMarqueeSelection) return;
|
|
3786
4816
|
clearRuntimeSelection();
|
|
3787
4817
|
return;
|
|
3788
4818
|
}
|
|
4819
|
+
if (e.data.type === "agent-native:collect-selectable-rects") {
|
|
4820
|
+
(window.parent as Window).postMessage(
|
|
4821
|
+
{
|
|
4822
|
+
type: "agent-native:selectable-rects-result",
|
|
4823
|
+
correlationId:
|
|
4824
|
+
typeof e.data.correlationId === "string"
|
|
4825
|
+
? e.data.correlationId
|
|
4826
|
+
: "",
|
|
4827
|
+
payload: collectSelectableElementInfos(),
|
|
4828
|
+
},
|
|
4829
|
+
"*",
|
|
4830
|
+
);
|
|
4831
|
+
return;
|
|
4832
|
+
}
|
|
4833
|
+
if (e.data.type === "select-elements") {
|
|
4834
|
+
var passiveTargets: Element[] = [];
|
|
4835
|
+
var selectorGroups: unknown[] = Array.isArray(e.data.selectorGroups)
|
|
4836
|
+
? e.data.selectorGroups
|
|
4837
|
+
: [];
|
|
4838
|
+
selectorGroups.forEach(function (group) {
|
|
4839
|
+
var selectors: string[] = [];
|
|
4840
|
+
if (Array.isArray(group)) {
|
|
4841
|
+
group.forEach(function (selector) {
|
|
4842
|
+
if (
|
|
4843
|
+
typeof selector === "string" &&
|
|
4844
|
+
selector &&
|
|
4845
|
+
selectors.indexOf(selector) === -1
|
|
4846
|
+
) {
|
|
4847
|
+
selectors.push(selector);
|
|
4848
|
+
}
|
|
4849
|
+
});
|
|
4850
|
+
}
|
|
4851
|
+
for (var i = 0; i < selectors.length; i += 1) {
|
|
4852
|
+
try {
|
|
4853
|
+
var matches = document.querySelectorAll(selectors[i]);
|
|
4854
|
+
for (var j = 0; j < matches.length; j += 1) {
|
|
4855
|
+
if (!isLayerInteractionBlocked(matches[j])) {
|
|
4856
|
+
passiveTargets.push(matches[j]);
|
|
4857
|
+
return;
|
|
4858
|
+
}
|
|
4859
|
+
}
|
|
4860
|
+
} catch (_err) {}
|
|
4861
|
+
}
|
|
4862
|
+
});
|
|
4863
|
+
setPassiveSelectionElements(passiveTargets);
|
|
4864
|
+
return;
|
|
4865
|
+
}
|
|
3789
4866
|
if (e.data.type === "select-element") {
|
|
3790
4867
|
var candidates: string[] = [];
|
|
3791
4868
|
if (Array.isArray(e.data.selectorCandidates)) {
|
|
@@ -3885,8 +4962,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3885
4962
|
: [];
|
|
3886
4963
|
if (selectedEl && isLayerInteractionBlocked(selectedEl)) {
|
|
3887
4964
|
selectedEl = null;
|
|
3888
|
-
|
|
3889
|
-
clearComponentTag();
|
|
4965
|
+
hideSelectionOverlay();
|
|
3890
4966
|
}
|
|
3891
4967
|
if (hoveredEl && isLayerInteractionBlocked(hoveredEl)) {
|
|
3892
4968
|
hoveredEl = null;
|
|
@@ -3904,10 +4980,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3904
4980
|
applyRuntimeReorder(move.el, move.target);
|
|
3905
4981
|
selectedEl = move.el;
|
|
3906
4982
|
positionOverlay(selectionOverlay, selectedEl);
|
|
3907
|
-
(
|
|
3908
|
-
{ type: "element-select", payload: getElementInfo(selectedEl) },
|
|
3909
|
-
"*",
|
|
3910
|
-
);
|
|
4983
|
+
postElementSelect(selectedEl);
|
|
3911
4984
|
}
|
|
3912
4985
|
} else {
|
|
3913
4986
|
// Revert the optimistic reorder to its pre-drag position.
|
|
@@ -3924,10 +4997,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3924
4997
|
);
|
|
3925
4998
|
selectedEl = move.el;
|
|
3926
4999
|
positionOverlay(selectionOverlay, selectedEl);
|
|
3927
|
-
(
|
|
3928
|
-
{ type: "element-select", payload: getElementInfo(selectedEl) },
|
|
3929
|
-
"*",
|
|
3930
|
-
);
|
|
5000
|
+
postElementSelect(selectedEl);
|
|
3931
5001
|
}
|
|
3932
5002
|
}
|
|
3933
5003
|
return;
|
|
@@ -3937,6 +5007,7 @@ declare var __EDITOR_CHROME_SCALE_Y__: string;
|
|
|
3937
5007
|
e.data.content,
|
|
3938
5008
|
e.data.forceFullDocument ? "" : e.data.selectedSelector,
|
|
3939
5009
|
e.data.forceFullDocument ? [] : e.data.selectorCandidates,
|
|
5010
|
+
Boolean(e.data.forceFullDocument),
|
|
3940
5011
|
);
|
|
3941
5012
|
return;
|
|
3942
5013
|
}
|