@agent-native/core-corpus 0.213.1 → 0.216.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/corpus/README.md +1 -1
- package/corpus/templates/analytics/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/analytics/CHANGELOG.md +1 -0
- package/corpus/templates/analytics/changelog/2026-10-21-session-replay-quotas-count-the-compressed-size-analytics-st.md +6 -0
- package/corpus/templates/analytics/server/lib/session-replay.ts +40 -9
- package/corpus/templates/assets/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/brain/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/calendar/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/chat/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/clips/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/community/qr/package.json +1 -1
- package/corpus/templates/content/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/content/.agents/skills/content-product-development/references/verification.md +36 -0
- package/corpus/templates/content/.agents/skills/document-editing/SKILL.md +10 -0
- package/corpus/templates/content/.agents/skills/document-editing/references/databases.md +26 -1
- package/corpus/templates/content/.agents/skills/notion-integration/SKILL.md +4 -2
- package/corpus/templates/content/CHANGELOG.md +51 -0
- package/corpus/templates/content/acceptance/_writers.ts +604 -0
- package/corpus/templates/content/acceptance/generate-action-registry.ts +10 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/create-document.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/duplicate-page.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/edit-document-find-and-replace-without-a-revision.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/edit-document-find-and-replace.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/edit-document-initializecontent.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/import-content.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/local-files-import-content-source-existing-page.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/local-files-import-content-source-new-page.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/local-files-sync-local-folder-source-changed-file.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/local-files-sync-local-folder-source-new-file.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/restore-document-version.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/set-document-property-primary-blocks-field.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/set-image-alt-text.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/undo-content-import.json +75 -0
- package/corpus/templates/content/acceptance/golden/gate-off-stored-bytes/update-document-browser-full-rewrite.json +75 -0
- package/corpus/templates/content/acceptance/known-loss.ts +69 -0
- package/corpus/templates/content/acceptance/round-trip-corpus.ts +1397 -0
- package/corpus/templates/content/actions/_blocks-field-identity.ts +35 -1
- package/corpus/templates/content/actions/_content-database-lifecycle.ts +11 -11
- package/corpus/templates/content/actions/_content-database-personal-view.ts +2 -0
- package/corpus/templates/content/actions/_content-favorites.ts +37 -0
- package/corpus/templates/content/actions/_database-membership-lock.ts +39 -8
- package/corpus/templates/content/actions/_database-navigation.ts +19 -21
- package/corpus/templates/content/actions/_database-row-batch.ts +41 -18
- package/corpus/templates/content/actions/_database-row-mutation.ts +17 -28
- package/corpus/templates/content/actions/_database-source-utils.ts +18 -1
- package/corpus/templates/content/actions/_database-utils.ts +3 -0
- package/corpus/templates/content/actions/_database-view-setup.ts +321 -11
- package/corpus/templates/content/actions/_document-edit-mutation.ts +33 -32
- package/corpus/templates/content/actions/_document-flush.ts +593 -171
- package/corpus/templates/content/actions/_document-save-locks.ts +54 -0
- package/corpus/templates/content/actions/_document-save-row.ts +133 -0
- package/corpus/templates/content/actions/_github-source.ts +18 -8
- package/corpus/templates/content/actions/_move-page-to-space.ts +189 -25
- package/corpus/templates/content/actions/_nfm-syntax.ts +2 -0
- package/corpus/templates/content/actions/_property-utils.ts +3 -0
- package/corpus/templates/content/actions/_row-lock-order.ts +115 -0
- package/corpus/templates/content/actions/create-content-database.ts +11 -0
- package/corpus/templates/content/actions/create-document.ts +13 -1
- package/corpus/templates/content/actions/delete-content-database.ts +17 -14
- package/corpus/templates/content/actions/delete-document-property.ts +5 -0
- package/corpus/templates/content/actions/delete-document.ts +270 -97
- package/corpus/templates/content/actions/edit-document.ts +18 -5
- package/corpus/templates/content/actions/export-document.ts +3 -0
- package/corpus/templates/content/actions/get-blocks-field-word-count.ts +22 -5
- package/corpus/templates/content/actions/import-content-source.ts +170 -54
- package/corpus/templates/content/actions/move-document.ts +191 -73
- package/corpus/templates/content/actions/pull-document.ts +8 -2
- package/corpus/templates/content/actions/remove-database-items.ts +23 -4
- package/corpus/templates/content/actions/restore-content-database.ts +76 -55
- package/corpus/templates/content/actions/restore-document-version.ts +19 -35
- package/corpus/templates/content/actions/restore-document.ts +65 -53
- package/corpus/templates/content/actions/rollback-created-slash-document.ts +11 -16
- package/corpus/templates/content/actions/set-document-property.ts +15 -1
- package/corpus/templates/content/actions/share-local-file-document.ts +18 -14
- package/corpus/templates/content/actions/suggest-document-edit.ts +2 -3
- package/corpus/templates/content/actions/sync-local-folder-source.ts +35 -1
- package/corpus/templates/content/actions/undo-content-import.ts +16 -12
- package/corpus/templates/content/actions/update-content-database-view.ts +20 -2
- package/corpus/templates/content/actions/update-document.ts +19 -14
- package/corpus/templates/content/actions/view-screen.ts +12 -0
- package/corpus/templates/content/app/components/editor/BubbleToolbar.tsx +1 -6
- package/corpus/templates/content/app/components/editor/CommentsSidebar.tsx +49 -3
- package/corpus/templates/content/app/components/editor/ContentImportDialog.tsx +2 -0
- package/corpus/templates/content/app/components/editor/DocumentBlockFields.tsx +53 -11
- package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +608 -353
- package/corpus/templates/content/app/components/editor/StaticDocumentBody.tsx +765 -0
- package/corpus/templates/content/app/components/editor/VisualEditor.tsx +233 -80
- package/corpus/templates/content/app/components/editor/blockFieldSaveController.ts +32 -3
- package/corpus/templates/content/app/components/editor/blockFieldSaveRegistry.ts +88 -23
- package/corpus/templates/content/app/components/editor/comment-anchors.ts +19 -0
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +296 -87
- package/corpus/templates/content/app/components/editor/database/ListItemLayout.tsx +410 -0
- package/corpus/templates/content/app/components/editor/database/ListItemRow.tsx +426 -0
- package/corpus/templates/content/app/components/editor/database/ListView.tsx +136 -18
- package/corpus/templates/content/app/components/editor/database/navigation-state.ts +3 -0
- package/corpus/templates/content/app/components/editor/database/settings.tsx +3 -3
- package/corpus/templates/content/app/components/editor/database/view-config.ts +4 -0
- package/corpus/templates/content/app/components/editor/document-flush-participant.ts +253 -0
- package/corpus/templates/content/app/components/editor/editor-transaction-meta.ts +28 -0
- package/corpus/templates/content/app/components/editor/extensions/AudioBlock.tsx +2 -1
- package/corpus/templates/content/app/components/editor/extensions/ImageBlock.tsx +27 -6
- package/corpus/templates/content/app/components/editor/extensions/LocalMdxComponentNode.tsx +0 -1
- package/corpus/templates/content/app/components/editor/extensions/NotionExtensions.tsx +4 -4
- package/corpus/templates/content/app/components/editor/extensions/SuggestionHighlight.ts +24 -2
- package/corpus/templates/content/app/components/editor/extensions/VideoBlock.tsx +25 -6
- package/corpus/templates/content/app/components/editor/pending-document-persistence.ts +59 -1
- package/corpus/templates/content/app/components/editor/stored-body-images.ts +27 -0
- package/corpus/templates/content/app/components/editor/suggestions/presentation-rebase.ts +17 -0
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +11 -4
- package/corpus/templates/content/app/components/trash/TrashBrowser.tsx +4 -1
- package/corpus/templates/content/app/global.css +34 -0
- package/corpus/templates/content/app/hooks/use-content-trash.ts +8 -0
- package/corpus/templates/content/app/i18n-data.ts +32 -0
- package/corpus/templates/content/app/import-messages.ts +25 -0
- package/corpus/templates/content/app/trash-messages.ts +16 -0
- package/corpus/templates/content/changelog/2026-10-16-a-page-open-in-a-tab-that-shows-it-s-in-the-trash-reopens-wi.md +6 -0
- package/corpus/templates/content/changelog/2026-10-16-a-page-restored-from-trash-returns-to-its-place-in-its-colle.md +6 -0
- package/corpus/templates/content/changelog/2026-10-16-agent-written-markdown-keeps-nested-lists-indented-with-spac.md +6 -0
- package/corpus/templates/content/changelog/2026-10-16-opening-a-page-you-can-edit-no-longer-rebuilds-its-editor-on.md +6 -0
- package/corpus/templates/content/changelog/2026-10-16-pages-moved-or-imported-at-the-same-time-can-no-longer-end-u.md +6 -0
- package/corpus/templates/content/changelog/2026-10-16-re-importing-a-markdown-export-of-a-page-no-longer-reports-t.md +6 -0
- package/corpus/templates/content/changelog/2026-10-16-saving-a-page-or-restoring-one-of-its-versions-no-longer-fai.md +6 -0
- package/corpus/templates/content/changelog/2026-10-17-agents-reading-a-page-you-have-open-no-longer-wait-or-fail-w.md +6 -0
- package/corpus/templates/content/changelog/2026-10-19-fresh-document-reads-require-confirmation-from-every-open-ed.md +6 -0
- package/corpus/templates/content/changelog/2026-10-19-list-rows-can-be-customized.md +6 -0
- package/corpus/templates/content/changelog/2026-10-19-list-views-fit-phone-screens.md +6 -0
- package/corpus/templates/content/changelog/2026-10-20-html-table-cells-preserve-a-trailing-backslash-when-opening-.md +6 -0
- package/corpus/templates/content/changelog/2026-10-20-preserve-empty-paragraph-colors-and-refuse-unsupported-inlin.md +6 -0
- package/corpus/templates/content/changelog/2026-10-20-the-advanced-filter-and-each-filter-group-inside-it-have-the.md +6 -0
- package/corpus/templates/content/changelog/2026-10-21-blocks-fields-keep-unconfirmed-saves-visible-and-agent-reads.md +6 -0
- package/corpus/templates/content/changelog/2026-10-21-preserve-compact-table-row-groups-and-report-invalid-block-colors.md +6 -0
- package/corpus/templates/content/changelog/2026-10-21-suggested-edits-show-an-agent-s-whole-reason-open-a-group-to.md +6 -0
- package/corpus/templates/content/changelog/2026-10-21-suggestions-keep-refusing-unmatched-emphasis-in-stored-markd.md +6 -0
- package/corpus/templates/content/changelog/2026-10-22-accept-remaining-and-reject-remaining-show-the-result-for-ev.md +6 -0
- package/corpus/templates/content/changelog/2026-10-22-accepting-a-group-of-suggested-edits-saves-faster-and-adds-o.md +6 -0
- package/corpus/templates/content/changelog/2026-10-22-agents-read-saved-page-text-after-failed-icon-change.md +6 -0
- package/corpus/templates/content/changelog/2026-10-22-changes-made-from-a-menu-or-popover-such-as-an-image-s-alt-t.md +6 -0
- package/corpus/templates/content/changelog/2026-10-22-text-an-agent-writes-inside-a-callout-column-or-synced-block.md +6 -0
- package/corpus/templates/content/e2e/auth-files.ts +28 -0
- package/corpus/templates/content/e2e/convergence-summary.ts +84 -29
- package/corpus/templates/content/e2e/gate-arm.ts +15 -0
- package/corpus/templates/content/e2e/global-setup.ts +43 -75
- package/corpus/templates/content/e2e/global-teardown.ts +34 -0
- package/corpus/templates/content/e2e/helpers.ts +598 -92
- package/corpus/templates/content/e2e/live-body-gate.ts +188 -0
- package/corpus/templates/content/e2e/playwright.config.ts +12 -3
- package/corpus/templates/content/e2e/server-identity.ts +47 -0
- package/corpus/templates/content/e2e/stored-form/collab-blocks.ts +123 -0
- package/corpus/templates/content/package.json +1 -1
- package/corpus/templates/content/scripts/_stored-form-census-kinds.ts +30 -2
- package/corpus/templates/content/scripts/historical-icon-apply.ts +9 -1
- package/corpus/templates/content/scripts/trace-startup.mjs +460 -133
- package/corpus/templates/content/server/db/exec.ts +58 -0
- package/corpus/templates/content/server/db/schema.ts +1 -0
- package/corpus/templates/content/server/lib/content-trash-purge.ts +208 -144
- package/corpus/templates/content/server/lib/document-metadata-updated-at.ts +43 -1
- package/corpus/templates/content/server/lib/document-revision.ts +23 -0
- package/corpus/templates/content/server/lib/live-body-writer.ts +199 -0
- package/corpus/templates/content/server/lib/notion-sync.ts +63 -29
- package/corpus/templates/content/server/lib/notion.ts +5 -5
- package/corpus/templates/content/server/lib/suggested-edits.ts +357 -230
- package/corpus/templates/content/server/plugins/db.ts +5 -0
- package/corpus/templates/content/server/routes/api/documents/[id]/move.patch.ts +50 -168
- package/corpus/templates/content/shared/api.ts +20 -0
- package/corpus/templates/content/shared/blocks-fields-manifest.ts +106 -0
- package/corpus/templates/content/shared/database-item-layout.ts +591 -0
- package/corpus/templates/content/shared/database-query.ts +192 -30
- package/corpus/templates/content/shared/document-export.ts +12 -14
- package/corpus/templates/content/shared/document-flush-protocol.ts +88 -0
- package/corpus/templates/content/shared/editor-save-state.ts +97 -0
- package/corpus/templates/content/shared/feature-flags.ts +10 -0
- package/corpus/templates/content/shared/import/markdown.ts +91 -7
- package/corpus/templates/content/shared/import/types.ts +2 -0
- package/corpus/templates/content/shared/inline-math.ts +6 -4
- package/corpus/templates/content/shared/nfm-fidelity.ts +247 -0
- package/corpus/templates/content/shared/nfm.ts +1933 -340
- package/corpus/templates/content/shared/suggestion-diff.ts +13 -0
- package/corpus/templates/content/shared/suggestion-formatting.ts +143 -20
- package/corpus/templates/content/shared/suggestion-text.ts +39 -0
- package/corpus/templates/content/vitest.config.ts +10 -0
- package/corpus/templates/crm/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/design/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/design/.agents/skills/native-effects/SKILL.md +9 -2
- package/corpus/templates/design/.generated/bridge/shader-fill-preview.generated.ts +3 -249
- package/corpus/templates/design/.generated/bridge/shader-runtime.generated.ts +5 -88
- package/corpus/templates/design/AGENTS.md +1 -3
- package/corpus/templates/design/CHANGELOG.md +32 -0
- package/corpus/templates/design/CODE_NATIVE_DESIGN_STUDIO_IMPLEMENTATION_PLAN.md +1 -6
- package/corpus/templates/design/DESIGN-STUDIO-PLAN.md +5 -7
- package/corpus/templates/design/actions/_native-local-export-server.ts +44 -31
- package/corpus/templates/design/actions/_native-render-contexts.ts +76 -21
- package/corpus/templates/design/actions/claim-native-local-export.ts +5 -0
- package/corpus/templates/design/actions/finish-native-local-export.ts +13 -2
- package/corpus/templates/design/actions/get-native-shader-approvals.ts +35 -0
- package/corpus/templates/design/actions/get-shader.ts +134 -219
- package/corpus/templates/design/actions/list-design-extensions.ts +3 -58
- package/corpus/templates/design/actions/request-native-local-export.ts +32 -6
- package/corpus/templates/design/actions/run-design-extension-action.ts +0 -29
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +131 -108
- package/corpus/templates/design/app/components/design/DesignExtensionsPanel.tsx +0 -218
- package/corpus/templates/design/app/components/design/DesignThumbnail.tsx +59 -3
- package/corpus/templates/design/app/components/design/EditPanel.tsx +35 -47
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +242 -62
- package/corpus/templates/design/app/components/design/NativePreviewErrorBoundary.tsx +53 -0
- package/corpus/templates/design/app/components/design/bridge/codegen.ts +18 -3
- package/corpus/templates/design/app/components/design/bridge/native-composition-clock.ts +5 -4
- package/corpus/templates/design/app/components/design/bridge/native-dom.ts +37 -0
- package/corpus/templates/design/app/components/design/bridge/native-intrinsic-image.ts +2 -1
- package/corpus/templates/design/app/components/design/bridge/native-mesh-grid.ts +90 -0
- package/corpus/templates/design/app/components/design/bridge/native-opaque-public-asset.ts +363 -0
- package/corpus/templates/design/app/components/design/bridge/native-opaque-worker-lease.ts +179 -0
- package/corpus/templates/design/app/components/design/bridge/native-preview-geometry.ts +132 -7
- package/corpus/templates/design/app/components/design/bridge/native-preview-policy.ts +4 -0
- package/corpus/templates/design/app/components/design/bridge/native-preview-viewport-transport.ts +378 -0
- package/corpus/templates/design/app/components/design/bridge/native-scene-body-transform.ts +62 -0
- package/corpus/templates/design/app/components/design/bridge/native-scene-presentation-element.ts +10 -0
- package/corpus/templates/design/app/components/design/bridge/native-shader-runtime.bridge.ts +646 -167
- package/corpus/templates/design/app/components/design/bridge/native-source-provider.ts +246 -192
- package/corpus/templates/design/app/components/design/bridge/native-stateful-resource.ts +2 -2
- package/corpus/templates/design/app/components/design/bridge/native-stateless-compute.ts +5 -2
- package/corpus/templates/design/app/components/design/bridge/native-svg-source.ts +11 -1
- package/corpus/templates/design/app/components/design/bridge/native-worker-broker.ts +6 -0
- package/corpus/templates/design/app/components/design/bridge/native-worker-entry.ts +761 -303
- package/corpus/templates/design/app/components/design/bridge/native-worker-fill.ts +16 -6
- package/corpus/templates/design/app/components/design/bridge/native-worker-gpu.ts +854 -91
- package/corpus/templates/design/app/components/design/bridge/native-worker-host.ts +15 -1
- package/corpus/templates/design/app/components/design/bridge/native-worker-input-assets.ts +200 -0
- package/corpus/templates/design/app/components/design/bridge/native-worker-protocol.ts +40 -1
- package/corpus/templates/design/app/components/design/bridge/native-worker-scene-host.ts +425 -126
- package/corpus/templates/design/app/components/design/bridge/native-worker-source-snapshot.ts +21 -0
- package/corpus/templates/design/app/components/design/bridge/shader-fill-preview.bridge.ts +5 -371
- package/corpus/templates/design/app/components/design/bridge/shader-runtime.bridge.ts +4 -146
- package/corpus/templates/design/app/components/design/design-canvas/interact-document.ts +5 -9
- package/corpus/templates/design/app/components/design/design-canvas/native-preview-surface.ts +150 -0
- package/corpus/templates/design/app/components/design/design-canvas/native-public-asset-preview.ts +409 -0
- package/corpus/templates/design/app/components/design/design-canvas/native-public-worker-preview.ts +1086 -0
- package/corpus/templates/design/app/components/design/design-canvas/private-replay-screenshot-preview.ts +2 -2
- package/corpus/templates/design/app/components/design/edit-panel/effects-properties.tsx +15 -26
- package/corpus/templates/design/app/components/design/edit-panel/fill-properties.tsx +74 -67
- package/corpus/templates/design/app/components/design/edit-panel/panel-primitives.tsx +7 -19
- package/corpus/templates/design/app/components/design/inspector/DesignColorPicker.tsx +39 -30
- package/corpus/templates/design/app/components/design/inspector/GradientEditor.tsx +4 -0
- package/corpus/templates/design/app/components/design/inspector/NativeShaderColorControls.tsx +3 -7
- package/corpus/templates/design/app/components/design/inspector/NativeShaderPaintControls.tsx +12 -5
- package/corpus/templates/design/app/components/design/inspector/NativeShaderPanel.tsx +705 -190
- package/corpus/templates/design/app/components/design/inspector/fill-field-reading.ts +1 -2
- package/corpus/templates/design/app/components/design/inspector/index.ts +0 -6
- package/corpus/templates/design/app/components/design/inspector/native-catalog-display.ts +26 -5
- package/corpus/templates/design/app/components/design/inspector/native-shader-catalog-fixture.ts +42 -0
- package/corpus/templates/design/app/components/design/inspector/native-shader-catalog-preview.ts +51 -33
- package/corpus/templates/design/app/components/design/inspector/native-shader-paint.ts +1 -0
- package/corpus/templates/design/app/components/design/inspector/native-shader-property-draft.ts +89 -23
- package/corpus/templates/design/app/components/design/inspector/saved-glsl-shader.tsx +243 -0
- package/corpus/templates/design/app/components/design/multi-screen/board-surface-html.ts +54 -5
- package/corpus/templates/design/app/components/design/shader-source-coordination.ts +66 -0
- package/corpus/templates/design/app/components/design/use-native-shader-approvals.ts +36 -8
- package/corpus/templates/design/app/components/templates/TemplatePreview.tsx +60 -3
- package/corpus/templates/design/app/i18n/en-US.ts +78 -2
- package/corpus/templates/design/app/pages/Present.tsx +36 -1
- package/corpus/templates/design/app/pages/design-editor/commands/apply-file-content-update.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/commands/apply-local-content-update.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/commands/commit-visual-styles.ts +2 -3
- package/corpus/templates/design/app/pages/design-editor/commands/cross-screen-element-drop.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/commands/layer-move-to-screen.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/commands/paste-selection.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/commands/paste-svg-layer.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/commands/prepare-content-history-replay.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/commands/redo.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/commands/render-png-blob.ts +84 -41
- package/corpus/templates/design/app/pages/design-editor/commands/shader-source-edit.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/commands/undo.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/design-editor-view.tsx +0 -2
- package/corpus/templates/design/app/pages/design-editor/domains/use-editor-content-and-components.ts +4 -33
- package/corpus/templates/design/app/pages/design-editor/domains/use-editor-export-and-handoff.ts +2 -2
- package/corpus/templates/design/app/pages/design-editor/domains/use-editor-history.ts +0 -11
- package/corpus/templates/design/app/pages/design-editor/domains/use-editor-layer-models.ts +2 -55
- package/corpus/templates/design/app/pages/design-editor/domains/use-editor-screen-rendering.tsx +0 -3
- package/corpus/templates/design/app/pages/design-editor/domains/use-editor-selection-and-styles.ts +0 -24
- package/corpus/templates/design/app/pages/design-editor/text-edit-utils.ts +0 -16
- package/corpus/templates/design/app/pages/design-editor/use-native-local-export-requests.ts +70 -11
- package/corpus/templates/design/app/pages/design-editor/view/single-screen-canvas.tsx +0 -2
- package/corpus/templates/design/changelog/2026-10-20-folded-mesh-adds-an-animated-sculpted-fill-with-editable-col.md +6 -0
- package/corpus/templates/design/changelog/2026-10-20-read-only-design-views-render-native-shader-previews-in-nest.md +6 -0
- package/corpus/templates/design/changelog/2026-10-20-selected-screens-with-shader-effects-can-be-exported-togethe.md +6 -0
- package/corpus/templates/design/changelog/2026-10-20-shader-previews-reuse-validated-scene-data-while-panning-inc.md +6 -0
- package/corpus/templates/design/changelog/2026-10-20-shader-previews-stay-aligned-while-you-zoom.md +6 -0
- package/corpus/templates/design/changelog/2026-10-20-signed-out-sessions-no-longer-watch-for-private-png-export-r.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-effect-thumbnails-show-richer-previews.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-native-effects-render-across-previews.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-native-shader-previews-use-less-gpu-memory-when-many-mesh-ef.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-opening-design-no-longer-shows-png-export-errors-when-no-exp.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-pulsing-border-controls-grouped.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-pulsing-border-follows-element-outlines.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-remove-obsolete-shader-fills.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-shader-previews-recover-from-temporary-gpu-and-image-failure.md +6 -0
- package/corpus/templates/design/changelog/2026-10-22-shader-fills-and-effects-render-correctly-on-canvas-elements.md +6 -0
- package/corpus/templates/design/package.json +0 -1
- package/corpus/templates/design/playwright.config.ts +1 -1
- package/corpus/templates/design/scripts/runtime-budget-zoom.ts +9 -21
- package/corpus/templates/design/scripts/runtime-budget.ts +10 -24
- package/corpus/templates/design/server/plugins/agent-chat.ts +0 -2
- package/corpus/templates/design/shared/effect-graph.ts +46 -1
- package/corpus/templates/design/shared/generation-output-receipt.ts +0 -1
- package/corpus/templates/design/shared/native-effect-animation-capability.ts +6 -0
- package/corpus/templates/design/shared/native-effect-folded-mesh-v1.ts +268 -0
- package/corpus/templates/design/shared/native-effect-folded-mesh-v2.ts +310 -0
- package/corpus/templates/design/shared/native-effect-folded-mesh.ts +489 -0
- package/corpus/templates/design/shared/native-effect-gallery-additions.ts +2 -2
- package/corpus/templates/design/shared/native-effect-paint.ts +8 -0
- package/corpus/templates/design/shared/native-effect-parameter-constraints.ts +8 -1
- package/corpus/templates/design/shared/native-effect-presets.ts +18 -1
- package/corpus/templates/design/shared/native-effect-property-presentation.ts +81 -0
- package/corpus/templates/design/shared/native-effect-pulsing-border-v3.ts +281 -0
- package/corpus/templates/design/shared/native-effect-pulsing-border-v4.ts +284 -0
- package/corpus/templates/design/shared/native-effect-pulsing-border.ts +300 -0
- package/corpus/templates/design/shared/native-effect-trust.ts +6 -0
- package/corpus/templates/design/shared/native-effect-wgsl.ts +12 -0
- package/corpus/templates/design/shared/native-effects.ts +528 -15
- package/corpus/templates/design/shared/native-input-resources.ts +36 -0
- package/corpus/templates/design/shared/native-local-export.ts +14 -0
- package/corpus/templates/design/shared/native-parameter-animation.ts +1 -0
- package/corpus/templates/design/shared/native-pointer-input.ts +9 -11
- package/corpus/templates/design/shared/shader-fills.ts +0 -513
- package/corpus/templates/design/vitest.setup.ts +7 -1
- package/corpus/templates/dispatch/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/dispatch/.agents/skills/turn-into-app/SKILL.md +20 -18
- package/corpus/templates/factory/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/factory/.agents/skills/review-latest-feedback/SKILL.md +36 -80
- package/corpus/templates/factory/.agents/skills/review-latest-feedback/references/channel-inventory.md +54 -16
- package/corpus/templates/factory/.agents/skills/review-latest-feedback/references/slack-reaction-replies.md +50 -73
- package/corpus/templates/factory/.agents/skills/turn-into-app/SKILL.md +20 -18
- package/corpus/templates/forms/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/mail/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/plan/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/slides/.agents/skills/actions/references/action-fields.md +1 -1
- package/corpus/templates/slides-2/.agents/skills/actions/SKILL.md +199 -0
- package/corpus/templates/slides-2/.agents/skills/actions/references/action-fields.md +145 -0
- package/corpus/templates/slides-2/.agents/skills/actions/references/examples.md +96 -0
- package/corpus/templates/slides-2/.agents/skills/actions/references/provider-apis.md +95 -0
- package/corpus/templates/slides-2/.agents/skills/adding-a-feature/SKILL.md +235 -0
- package/corpus/templates/slides-2/.agents/skills/agent-native-docs/SKILL.md +161 -0
- package/corpus/templates/slides-2/.agents/skills/agent-native-toolkit/SKILL.md +314 -0
- package/corpus/templates/slides-2/.agents/skills/analytics-data-for-decks/SKILL.md +44 -0
- package/corpus/templates/slides-2/.agents/skills/apply-slide-comments/SKILL.md +63 -0
- package/corpus/templates/slides-2/.agents/skills/client-side-routing/SKILL.md +87 -0
- package/corpus/templates/slides-2/.agents/skills/context-awareness/SKILL.md +282 -0
- package/corpus/templates/slides-2/.agents/skills/create-deck/SKILL.md +263 -0
- package/corpus/templates/slides-2/.agents/skills/create-deck/references/reference-inputs.md +72 -0
- package/corpus/templates/slides-2/.agents/skills/create-deck/references/slide-templates.md +93 -0
- package/corpus/templates/slides-2/.agents/skills/create-deck/references/source-material.md +16 -0
- package/corpus/templates/slides-2/.agents/skills/creative-context/SKILL.md +134 -0
- package/corpus/templates/slides-2/.agents/skills/customizing-agent-native/SKILL.md +219 -0
- package/corpus/templates/slides-2/.agents/skills/deck-management/SKILL.md +182 -0
- package/corpus/templates/slides-2/.agents/skills/delegate-to-agent/SKILL.md +62 -0
- package/corpus/templates/slides-2/.agents/skills/design-systems/SKILL.md +233 -0
- package/corpus/templates/slides-2/.agents/skills/external-agents/SKILL.md +549 -0
- package/corpus/templates/slides-2/.agents/skills/external-agents/references/mcp-apps-embedding.md +169 -0
- package/corpus/templates/slides-2/.agents/skills/frontend-design/SKILL.md +102 -0
- package/corpus/templates/slides-2/.agents/skills/frontend-design/references/visual-direction.md +102 -0
- package/corpus/templates/slides-2/.agents/skills/image-generation-via-a2a/SKILL.md +134 -0
- package/corpus/templates/slides-2/.agents/skills/performance/SKILL.md +79 -0
- package/corpus/templates/slides-2/.agents/skills/portability/SKILL.md +108 -0
- package/corpus/templates/slides-2/.agents/skills/real-time-sync/SKILL.md +146 -0
- package/corpus/templates/slides-2/.agents/skills/reliable-mutations/SKILL.md +72 -0
- package/corpus/templates/slides-2/.agents/skills/secrets/SKILL.md +82 -0
- package/corpus/templates/slides-2/.agents/skills/security/SKILL.md +80 -0
- package/corpus/templates/slides-2/.agents/skills/self-modifying-code/SKILL.md +123 -0
- package/corpus/templates/slides-2/.agents/skills/shadcn-ui/SKILL.md +71 -0
- package/corpus/templates/slides-2/.agents/skills/sharing/SKILL.md +286 -0
- package/corpus/templates/slides-2/.agents/skills/slide-design/SKILL.md +144 -0
- package/corpus/templates/slides-2/.agents/skills/slide-editing/SKILL.md +284 -0
- package/corpus/templates/slides-2/.agents/skills/slide-editing/references/animations.md +33 -0
- package/corpus/templates/slides-2/.agents/skills/slide-editing/references/freeform-objects.md +22 -0
- package/corpus/templates/slides-2/.agents/skills/slide-editing/references/restyling.md +69 -0
- package/corpus/templates/slides-2/.agents/skills/slide-editing/references/transitions.md +26 -0
- package/corpus/templates/slides-2/.agents/skills/slide-editing/references/video.md +45 -0
- package/corpus/templates/slides-2/.agents/skills/slide-images/SKILL.md +136 -0
- package/corpus/templates/slides-2/.agents/skills/storing-data/SKILL.md +234 -0
- package/corpus/templates/slides-2/.agents/skills/turn-into-skill/SKILL.md +112 -0
- package/corpus/templates/slides-2/.agents/skills/turn-into-skill/agents/openai.yaml +4 -0
- package/corpus/templates/slides-2/.agents/skills/workspace-conventions/SKILL.md +103 -0
- package/corpus/templates/slides-2/.builder/rules/deploy-app.mdc +22 -0
- package/corpus/templates/slides-2/.builder/rules/organize-ui.mdc +9 -0
- package/corpus/templates/slides-2/.dockerignore +61 -0
- package/corpus/templates/slides-2/.env.example +23 -0
- package/corpus/templates/slides-2/.ignore +3 -0
- package/corpus/templates/slides-2/.mcp.json +8 -0
- package/corpus/templates/slides-2/.oxfmtrc.json +8 -0
- package/corpus/templates/slides-2/AGENTS.md +66 -0
- package/corpus/templates/slides-2/CHANGELOG.md +76 -0
- package/corpus/templates/slides-2/DEVELOPING.md +157 -0
- package/corpus/templates/slides-2/README.md +58 -0
- package/corpus/templates/slides-2/THIRD_PARTY_NOTICES.md +33 -0
- package/corpus/templates/slides-2/_gitignore +38 -0
- package/corpus/templates/slides-2/actions/_agent-presence.ts +29 -0
- package/corpus/templates/slides-2/actions/_app-url.ts +37 -0
- package/corpus/templates/slides-2/actions/_deck-app-scope.ts +30 -0
- package/corpus/templates/slides-2/actions/_deck-tracking.ts +260 -0
- package/corpus/templates/slides-2/actions/_deck-write.ts +206 -0
- package/corpus/templates/slides-2/actions/_imported-slide-source.ts +162 -0
- package/corpus/templates/slides-2/actions/_inline-image-storage.ts +1013 -0
- package/corpus/templates/slides-2/actions/_linked-design-system.ts +83 -0
- package/corpus/templates/slides-2/actions/_presenter-notes.ts +83 -0
- package/corpus/templates/slides-2/actions/_render-artifacts.ts +111 -0
- package/corpus/templates/slides-2/actions/_slide-source.ts +344 -0
- package/corpus/templates/slides-2/actions/_tab-state.ts +51 -0
- package/corpus/templates/slides-2/actions/_test-brandfetch.ts +31 -0
- package/corpus/templates/slides-2/actions/_uploaded-files.ts +114 -0
- package/corpus/templates/slides-2/actions/add-deck.ts +123 -0
- package/corpus/templates/slides-2/actions/add-slide-comment.ts +267 -0
- package/corpus/templates/slides-2/actions/add-slide.ts +888 -0
- package/corpus/templates/slides-2/actions/analyze-brand-assets.ts +66 -0
- package/corpus/templates/slides-2/actions/apply-design-system.ts +111 -0
- package/corpus/templates/slides-2/actions/approve-deck-access-request.ts +287 -0
- package/corpus/templates/slides-2/actions/audit-contrast.ts +143 -0
- package/corpus/templates/slides-2/actions/check-image-gen.ts +17 -0
- package/corpus/templates/slides-2/actions/clone-context-slide.ts +340 -0
- package/corpus/templates/slides-2/actions/clone-creative-context-deck.ts +143 -0
- package/corpus/templates/slides-2/actions/control-deck-history.ts +186 -0
- package/corpus/templates/slides-2/actions/control-presenter.ts +117 -0
- package/corpus/templates/slides-2/actions/control-slide-editor.ts +267 -0
- package/corpus/templates/slides-2/actions/create-deck-from-template.ts +274 -0
- package/corpus/templates/slides-2/actions/create-deck.ts +1243 -0
- package/corpus/templates/slides-2/actions/create-design-system.ts +131 -0
- package/corpus/templates/slides-2/actions/create-share-link.ts +127 -0
- package/corpus/templates/slides-2/actions/db-health.ts +22 -0
- package/corpus/templates/slides-2/actions/delete-asset.ts +154 -0
- package/corpus/templates/slides-2/actions/delete-deck.ts +427 -0
- package/corpus/templates/slides-2/actions/delete-design-system.ts +167 -0
- package/corpus/templates/slides-2/actions/delete-slide-comment.ts +143 -0
- package/corpus/templates/slides-2/actions/delete-staged-dataset.ts +30 -0
- package/corpus/templates/slides-2/actions/duplicate-deck.ts +299 -0
- package/corpus/templates/slides-2/actions/export-google-slides.ts +41 -0
- package/corpus/templates/slides-2/actions/export-html.ts +770 -0
- package/corpus/templates/slides-2/actions/export-pptx.ts +2203 -0
- package/corpus/templates/slides-2/actions/extract-pdf.ts +49 -0
- package/corpus/templates/slides-2/actions/generate-image-api.ts +671 -0
- package/corpus/templates/slides-2/actions/generate-image.ts +492 -0
- package/corpus/templates/slides-2/actions/get-agent-access-deck.ts +52 -0
- package/corpus/templates/slides-2/actions/get-deck-access-status.ts +130 -0
- package/corpus/templates/slides-2/actions/get-deck-design-tokens.ts +62 -0
- package/corpus/templates/slides-2/actions/get-deck-reference-context.ts +232 -0
- package/corpus/templates/slides-2/actions/get-deck-template.ts +38 -0
- package/corpus/templates/slides-2/actions/get-deck-version.ts +85 -0
- package/corpus/templates/slides-2/actions/get-deck.ts +562 -0
- package/corpus/templates/slides-2/actions/get-design-system-decode-job-status.ts +57 -0
- package/corpus/templates/slides-2/actions/get-design-system-tier-limit.ts +12 -0
- package/corpus/templates/slides-2/actions/get-design-system.ts +453 -0
- package/corpus/templates/slides-2/actions/get-google-docs-status.ts +106 -0
- package/corpus/templates/slides-2/actions/get-google-picker-token.ts +84 -0
- package/corpus/templates/slides-2/actions/get-home-suggestions.ts +52 -0
- package/corpus/templates/slides-2/actions/get-layout-overflows.ts +192 -0
- package/corpus/templates/slides-2/actions/get-slide-render.ts +125 -0
- package/corpus/templates/slides-2/actions/get-slide-source.ts +115 -0
- package/corpus/templates/slides-2/actions/get-slide-theme-preview.ts +64 -0
- package/corpus/templates/slides-2/actions/get-slide-theme.ts +44 -0
- package/corpus/templates/slides-2/actions/get-slides-2-upload-storage-status.ts +17 -0
- package/corpus/templates/slides-2/actions/get-slides-notification-prefs.ts +37 -0
- package/corpus/templates/slides-2/actions/get-workspace-defaults.ts +51 -0
- package/corpus/templates/slides-2/actions/image-gen-status.ts +35 -0
- package/corpus/templates/slides-2/actions/import-code.ts +26 -0
- package/corpus/templates/slides-2/actions/import-design-project.ts +49 -0
- package/corpus/templates/slides-2/actions/import-document.ts +125 -0
- package/corpus/templates/slides-2/actions/import-docx.ts +57 -0
- package/corpus/templates/slides-2/actions/import-file.ts +1273 -0
- package/corpus/templates/slides-2/actions/import-from-url.ts +25 -0
- package/corpus/templates/slides-2/actions/import-google-doc.ts +208 -0
- package/corpus/templates/slides-2/actions/import-google-font.ts +110 -0
- package/corpus/templates/slides-2/actions/import-google-slides-reference.ts +667 -0
- package/corpus/templates/slides-2/actions/import-pptx.ts +564 -0
- package/corpus/templates/slides-2/actions/import-svgl-logo.ts +115 -0
- package/corpus/templates/slides-2/actions/index-design-system-with-builder.ts +181 -0
- package/corpus/templates/slides-2/actions/index-uploaded-design-system-files.ts +77 -0
- package/corpus/templates/slides-2/actions/list-assets.ts +286 -0
- package/corpus/templates/slides-2/actions/list-deck-templates.ts +83 -0
- package/corpus/templates/slides-2/actions/list-deck-versions.ts +185 -0
- package/corpus/templates/slides-2/actions/list-decks.ts +591 -0
- package/corpus/templates/slides-2/actions/list-design-systems.ts +180 -0
- package/corpus/templates/slides-2/actions/list-slide-comments.ts +128 -0
- package/corpus/templates/slides-2/actions/list-slide-themes.ts +17 -0
- package/corpus/templates/slides-2/actions/list-staged-datasets.ts +14 -0
- package/corpus/templates/slides-2/actions/logo-config.ts +13 -0
- package/corpus/templates/slides-2/actions/navigate.ts +158 -0
- package/corpus/templates/slides-2/actions/patch-deck.ts +2378 -0
- package/corpus/templates/slides-2/actions/provider-api-catalog.ts +25 -0
- package/corpus/templates/slides-2/actions/provider-api-docs.ts +83 -0
- package/corpus/templates/slides-2/actions/provider-api-request.ts +222 -0
- package/corpus/templates/slides-2/actions/query-staged-dataset.ts +83 -0
- package/corpus/templates/slides-2/actions/read-composer-source.ts +108 -0
- package/corpus/templates/slides-2/actions/request-deck-access.ts +803 -0
- package/corpus/templates/slides-2/actions/restore-deck-version.ts +203 -0
- package/corpus/templates/slides-2/actions/run.ts +2 -0
- package/corpus/templates/slides-2/actions/save-deck.ts +313 -0
- package/corpus/templates/slides-2/actions/search-google-fonts.ts +61 -0
- package/corpus/templates/slides-2/actions/search-images.ts +30 -0
- package/corpus/templates/slides-2/actions/search-logos.ts +23 -0
- package/corpus/templates/slides-2/actions/search-svgl-logos.ts +42 -0
- package/corpus/templates/slides-2/actions/set-default-design-system.ts +88 -0
- package/corpus/templates/slides-2/actions/set-workspace-defaults.ts +61 -0
- package/corpus/templates/slides-2/actions/start-design-system-upload.ts +80 -0
- package/corpus/templates/slides-2/actions/sync-design-system-with-builder.ts +84 -0
- package/corpus/templates/slides-2/actions/toggle-slide-comment-reaction.ts +150 -0
- package/corpus/templates/slides-2/actions/transform-slide-objects.ts +1528 -0
- package/corpus/templates/slides-2/actions/update-asset.ts +499 -0
- package/corpus/templates/slides-2/actions/update-deck-aspect-ratio.ts +95 -0
- package/corpus/templates/slides-2/actions/update-deck-design-tokens.ts +175 -0
- package/corpus/templates/slides-2/actions/update-design-system.ts +95 -0
- package/corpus/templates/slides-2/actions/update-slide-comment.ts +213 -0
- package/corpus/templates/slides-2/actions/update-slide-source.ts +353 -0
- package/corpus/templates/slides-2/actions/update-slide.ts +850 -0
- package/corpus/templates/slides-2/actions/update-slides-notification-prefs.ts +55 -0
- package/corpus/templates/slides-2/actions/view-screen.ts +1098 -0
- package/corpus/templates/slides-2/agent-native.app-skill.json +165 -0
- package/corpus/templates/slides-2/agent-native.config.ts +20 -0
- package/corpus/templates/slides-2/agent-native.json +18 -0
- package/corpus/templates/slides-2/app/components/ThemeToggle.tsx +47 -0
- package/corpus/templates/slides-2/app/components/comments/SlideCommentPins.tsx +781 -0
- package/corpus/templates/slides-2/app/components/comments/SlideCommentsPanel.tsx +1075 -0
- package/corpus/templates/slides-2/app/components/deck/DeckCard.tsx +304 -0
- package/corpus/templates/slides-2/app/components/deck/DeckFilterMenu.tsx +83 -0
- package/corpus/templates/slides-2/app/components/deck/ExcalidrawSlide.tsx +183 -0
- package/corpus/templates/slides-2/app/components/deck/MermaidRenderer.tsx +126 -0
- package/corpus/templates/slides-2/app/components/deck/SlideRenderer.tsx +1553 -0
- package/corpus/templates/slides-2/app/components/design-system/DesignSystemCard.tsx +235 -0
- package/corpus/templates/slides-2/app/components/design-system/DesignSystemSetup.tsx +2021 -0
- package/corpus/templates/slides-2/app/components/design-system/builder-design-system-upload.ts +200 -0
- package/corpus/templates/slides-2/app/components/design-system/builder-index-response.ts +104 -0
- package/corpus/templates/slides-2/app/components/editor/AddSlidePopover.tsx +461 -0
- package/corpus/templates/slides-2/app/components/editor/AiEditingMarker.tsx +24 -0
- package/corpus/templates/slides-2/app/components/editor/AlignmentGuides.tsx +82 -0
- package/corpus/templates/slides-2/app/components/editor/AnimationsPanel.tsx +698 -0
- package/corpus/templates/slides-2/app/components/editor/AppMenu.tsx +356 -0
- package/corpus/templates/slides-2/app/components/editor/AssetLibraryPanel.tsx +508 -0
- package/corpus/templates/slides-2/app/components/editor/BlockBubbleMenu.tsx +548 -0
- package/corpus/templates/slides-2/app/components/editor/DeckAccessDeniedPage.tsx +173 -0
- package/corpus/templates/slides-2/app/components/editor/DeckEditorSkeleton.tsx +35 -0
- package/corpus/templates/slides-2/app/components/editor/DeferredPopoverFallback.tsx +148 -0
- package/corpus/templates/slides-2/app/components/editor/EditorActionCluster.tsx +217 -0
- package/corpus/templates/slides-2/app/components/editor/EditorSidebar.tsx +1047 -0
- package/corpus/templates/slides-2/app/components/editor/EditorToolbar.tsx +1285 -0
- package/corpus/templates/slides-2/app/components/editor/ExportMenu.tsx +579 -0
- package/corpus/templates/slides-2/app/components/editor/GeneratingOverlay.tsx +21 -0
- package/corpus/templates/slides-2/app/components/editor/GeneratingSlidePreview.tsx +73 -0
- package/corpus/templates/slides-2/app/components/editor/GoogleDocImportHint.tsx +378 -0
- package/corpus/templates/slides-2/app/components/editor/GoogleDriveConnectionCta.tsx +154 -0
- package/corpus/templates/slides-2/app/components/editor/GoogleSlidesReferenceImport.tsx +299 -0
- package/corpus/templates/slides-2/app/components/editor/HistoryPanel.tsx +354 -0
- package/corpus/templates/slides-2/app/components/editor/HomeQuickStartDialog.tsx +202 -0
- package/corpus/templates/slides-2/app/components/editor/ImageCropOverlay.tsx +820 -0
- package/corpus/templates/slides-2/app/components/editor/ImageDropPromptPopover.tsx +280 -0
- package/corpus/templates/slides-2/app/components/editor/ImageGenPanel.tsx +244 -0
- package/corpus/templates/slides-2/app/components/editor/ImageOverlay.tsx +280 -0
- package/corpus/templates/slides-2/app/components/editor/ImageSearchPanel.tsx +183 -0
- package/corpus/templates/slides-2/app/components/editor/ImportDeckButton.tsx +247 -0
- package/corpus/templates/slides-2/app/components/editor/LogoSearchPanel.tsx +366 -0
- package/corpus/templates/slides-2/app/components/editor/MermaidToExcalidrawPanel.tsx +99 -0
- package/corpus/templates/slides-2/app/components/editor/MissingDeckAccessPane.tsx +219 -0
- package/corpus/templates/slides-2/app/components/editor/NewDeckReferenceStep.tsx +812 -0
- package/corpus/templates/slides-2/app/components/editor/PromptDialog.tsx +963 -0
- package/corpus/templates/slides-2/app/components/editor/QuestionFlow.tsx +119 -0
- package/corpus/templates/slides-2/app/components/editor/RequestDeckAccessDialog.tsx +101 -0
- package/corpus/templates/slides-2/app/components/editor/ShareDialog.tsx +126 -0
- package/corpus/templates/slides-2/app/components/editor/SlideContextToolbar.tsx +1471 -0
- package/corpus/templates/slides-2/app/components/editor/SlideEditor.tsx +11183 -0
- package/corpus/templates/slides-2/app/components/editor/SlideOverflowWarning.tsx +82 -0
- package/corpus/templates/slides-2/app/components/editor/SlideScrollStack.tsx +307 -0
- package/corpus/templates/slides-2/app/components/editor/SlideSlashCommandMenu.tsx +692 -0
- package/corpus/templates/slides-2/app/components/editor/SlideThumbnailContextMenu.tsx +52 -0
- package/corpus/templates/slides-2/app/components/editor/SlideTransitionControl.tsx +184 -0
- package/corpus/templates/slides-2/app/components/editor/SlidesComposerContext.tsx +789 -0
- package/corpus/templates/slides-2/app/components/editor/SlidesComposerContextProvider.tsx +74 -0
- package/corpus/templates/slides-2/app/components/editor/SlidesLayersPanel.tsx +377 -0
- package/corpus/templates/slides-2/app/components/editor/SpeakerNotesPanel.tsx +119 -0
- package/corpus/templates/slides-2/app/components/editor/TweaksPanel.tsx +77 -0
- package/corpus/templates/slides-2/app/components/editor/UploadStorageGate.tsx +37 -0
- package/corpus/templates/slides-2/app/components/editor/bullet-editing.ts +880 -0
- package/corpus/templates/slides-2/app/components/editor/canvas-interactions/index.ts +12 -0
- package/corpus/templates/slides-2/app/components/editor/canvas-interactions/slides-canvas-adapter.ts +119 -0
- package/corpus/templates/slides-2/app/components/editor/commit-active-edit.ts +14 -0
- package/corpus/templates/slides-2/app/components/editor/editor-command-model.ts +35 -0
- package/corpus/templates/slides-2/app/components/editor/fit-text-object.ts +31 -0
- package/corpus/templates/slides-2/app/components/editor/in-place-text-session.browser-cases.json +983 -0
- package/corpus/templates/slides-2/app/components/editor/in-place-text-session.browser-host.ts +747 -0
- package/corpus/templates/slides-2/app/components/editor/in-place-text-session.ts +6891 -0
- package/corpus/templates/slides-2/app/components/editor/inline-edit-session.ts +26 -0
- package/corpus/templates/slides-2/app/components/editor/list-editing.ts +501 -0
- package/corpus/templates/slides-2/app/components/editor/rich-text-selection.ts +975 -0
- package/corpus/templates/slides-2/app/components/editor/rte-test-utils.ts +265 -0
- package/corpus/templates/slides-2/app/components/editor/selection-overlay-measurement.ts +191 -0
- package/corpus/templates/slides-2/app/components/editor/slide-escape-arbiter.ts +34 -0
- package/corpus/templates/slides-2/app/components/editor/slide-object-interactions.ts +6362 -0
- package/corpus/templates/slides-2/app/components/editor/slide-object-transform.browser-host.ts +19 -0
- package/corpus/templates/slides-2/app/components/editor/slide-pointer-target.ts +432 -0
- package/corpus/templates/slides-2/app/components/editor/slide-presence.ts +13 -0
- package/corpus/templates/slides-2/app/components/editor/slide-style.ts +243 -0
- package/corpus/templates/slides-2/app/components/editor/slide-text-targets.ts +540 -0
- package/corpus/templates/slides-2/app/components/editor/style-clipboard.ts +102 -0
- package/corpus/templates/slides-2/app/components/editor/use-prompt-import.ts +159 -0
- package/corpus/templates/slides-2/app/components/home/SlidesHomeLibrary.tsx +79 -0
- package/corpus/templates/slides-2/app/components/layout/AgentWorkIndicator.tsx +193 -0
- package/corpus/templates/slides-2/app/components/layout/Header.tsx +110 -0
- package/corpus/templates/slides-2/app/components/layout/Layout.tsx +492 -0
- package/corpus/templates/slides-2/app/components/layout/Sidebar.tsx +109 -0
- package/corpus/templates/slides-2/app/components/layout/layout-route-policy.ts +28 -0
- package/corpus/templates/slides-2/app/components/presentation/PresentationView.tsx +1116 -0
- package/corpus/templates/slides-2/app/components/presentation/PresenterView.tsx +526 -0
- package/corpus/templates/slides-2/app/components/presentation/SlideTransitionStage.tsx +297 -0
- package/corpus/templates/slides-2/app/components/presentation/present-channel.ts +31 -0
- package/corpus/templates/slides-2/app/components/presentation/slide-build-steps.ts +231 -0
- package/corpus/templates/slides-2/app/components/presentation/slide-navigation.ts +273 -0
- package/corpus/templates/slides-2/app/components/presentation/slide-transition-motion.ts +258 -0
- package/corpus/templates/slides-2/app/components/presentation/voice-navigation.ts +61 -0
- package/corpus/templates/slides-2/app/components/settings/notification-settings.tsx +93 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2AssetBrowser.tsx +726 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2CommandMenu.tsx +453 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2Comments.tsx +571 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2DesignTokens.tsx +345 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2Editor.tsx +4804 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2ExportMenu.tsx +671 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2FontBrowser.tsx +342 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2ImageCropControls.tsx +487 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2Inspector.tsx +950 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/Slides2SvglLogoSearchDialog.tsx +332 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/cross-slide-edit-history.ts +151 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/design-token-presets.ts +140 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/editor-action-errors.ts +47 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/editor-export-errors.ts +60 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/geometry.ts +275 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/image-crop-style.ts +82 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/inline-text-editor.tsx +631 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/keyboard-shortcuts.ts +104 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/object-insertion.ts +13 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/preview-patches.ts +54 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/sandbox-render-errors.ts +23 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/source-structure.ts +634 -0
- package/corpus/templates/slides-2/app/components/slides-2-editor/types.ts +85 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/Slides2BlackoutOverlay.tsx +13 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/Slides2ControlBar.tsx +285 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/Slides2HelpDialog.tsx +72 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/Slides2JumpInput.tsx +38 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/Slides2LaserPointer.tsx +67 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/Slides2Overview.tsx +161 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/Slides2Player.tsx +839 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/Slides2ProgressBar.tsx +23 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/keyboard.ts +36 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/presenter-channel.ts +131 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/use-presenter-action-bridge.ts +296 -0
- package/corpus/templates/slides-2/app/components/slides-2-presenter/useSlides2TouchSwipe.ts +80 -0
- package/corpus/templates/slides-2/app/components/slides-2-runtime/SandboxedSlide.tsx +724 -0
- package/corpus/templates/slides-2/app/components/slides-2-runtime/SlideContentRenderer.tsx +137 -0
- package/corpus/templates/slides-2/app/components/slides-2-runtime/Slides2Canvas.tsx +99 -0
- package/corpus/templates/slides-2/app/components/slides-2-runtime/constants.ts +4 -0
- package/corpus/templates/slides-2/app/components/slides-2-runtime/protocol.ts +1400 -0
- package/corpus/templates/slides-2/app/components/slides-2-runtime/transition-frame.ts +439 -0
- package/corpus/templates/slides-2/app/components/templates/DeckTemplateLibrary.tsx +314 -0
- package/corpus/templates/slides-2/app/components/templates/DeckTemplatePreview.tsx +60 -0
- package/corpus/templates/slides-2/app/components/templates/DeckTemplateStage.tsx +45 -0
- package/corpus/templates/slides-2/app/components/ui/alert-dialog.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/avatar.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/button-group.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/button.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/card.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/command.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/context-menu.tsx +32 -0
- package/corpus/templates/slides-2/app/components/ui/dialog.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/dropdown-menu.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/filter-trigger.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/input.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/label.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/popover.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/progress.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/scroll-area.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/select.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/separator.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/sheet.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/skeleton.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/slider.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/spinner.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/switch.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/tabs.tsx +59 -0
- package/corpus/templates/slides-2/app/components/ui/textarea.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/toggle-group.tsx +1 -0
- package/corpus/templates/slides-2/app/components/ui/toolkit-provider.tsx +17 -0
- package/corpus/templates/slides-2/app/components/ui/tooltip.tsx +1 -0
- package/corpus/templates/slides-2/app/components/visual-editor/CanvasCommentPins.tsx +46 -0
- package/corpus/templates/slides-2/app/components/visual-editor/DrawOverlay.tsx +27 -0
- package/corpus/templates/slides-2/app/components/visual-editor/MultiSelectChip.tsx +97 -0
- package/corpus/templates/slides-2/app/components/visual-editor/SaveStatusIndicator.tsx +273 -0
- package/corpus/templates/slides-2/app/components/visual-editor/index.ts +4 -0
- package/corpus/templates/slides-2/app/context/DeckContext.tsx +7486 -0
- package/corpus/templates/slides-2/app/design-system.ts +3 -0
- package/corpus/templates/slides-2/app/entry.client.tsx +10 -0
- package/corpus/templates/slides-2/app/entry.server.tsx +10 -0
- package/corpus/templates/slides-2/app/global.css +1626 -0
- package/corpus/templates/slides-2/app/hooks/use-agent-generating.ts +517 -0
- package/corpus/templates/slides-2/app/hooks/use-compact-editor-layout.ts +26 -0
- package/corpus/templates/slides-2/app/hooks/use-contrast-audit-bridge.ts +49 -0
- package/corpus/templates/slides-2/app/hooks/use-deck-access-reload.ts +70 -0
- package/corpus/templates/slides-2/app/hooks/use-deck-access.ts +50 -0
- package/corpus/templates/slides-2/app/hooks/use-deck-design-system.ts +146 -0
- package/corpus/templates/slides-2/app/hooks/use-deck-history-action-bridge.ts +266 -0
- package/corpus/templates/slides-2/app/hooks/use-deck-presence.ts +89 -0
- package/corpus/templates/slides-2/app/hooks/use-deck-role.ts +46 -0
- package/corpus/templates/slides-2/app/hooks/use-deck-versions.ts +43 -0
- package/corpus/templates/slides-2/app/hooks/use-design-system-workflows.ts +11 -0
- package/corpus/templates/slides-2/app/hooks/use-design-systems.ts +31 -0
- package/corpus/templates/slides-2/app/hooks/use-generating-slide-preview.ts +115 -0
- package/corpus/templates/slides-2/app/hooks/use-navigation-state.ts +229 -0
- package/corpus/templates/slides-2/app/hooks/use-new-deck-generation-signal.ts +46 -0
- package/corpus/templates/slides-2/app/hooks/use-new-deck-generation.ts +710 -0
- package/corpus/templates/slides-2/app/hooks/use-sidebar-collapsed.ts +95 -0
- package/corpus/templates/slides-2/app/hooks/use-slide-comments.ts +202 -0
- package/corpus/templates/slides-2/app/hooks/use-slide-file-storage-status.ts +55 -0
- package/corpus/templates/slides-2/app/hooks/use-undo-selection.ts +66 -0
- package/corpus/templates/slides-2/app/hooks/use-workspace-defaults.ts +31 -0
- package/corpus/templates/slides-2/app/i18n/en-US.ts +1507 -0
- package/corpus/templates/slides-2/app/i18n/index.ts +19 -0
- package/corpus/templates/slides-2/app/lib/agent-visible-message.ts +21 -0
- package/corpus/templates/slides-2/app/lib/aspect-ratios.ts +7 -0
- package/corpus/templates/slides-2/app/lib/asset-error-copy.ts +59 -0
- package/corpus/templates/slides-2/app/lib/canvas-zoom.ts +47 -0
- package/corpus/templates/slides-2/app/lib/composer-context.ts +152 -0
- package/corpus/templates/slides-2/app/lib/composer-draft.ts +34 -0
- package/corpus/templates/slides-2/app/lib/contrast-audit.ts +390 -0
- package/corpus/templates/slides-2/app/lib/contrast-resolve.ts +240 -0
- package/corpus/templates/slides-2/app/lib/create-deck-generation.ts +938 -0
- package/corpus/templates/slides-2/app/lib/deck-access-lost.ts +4 -0
- package/corpus/templates/slides-2/app/lib/deck-backup.ts +186 -0
- package/corpus/templates/slides-2/app/lib/deck-editor-loading.ts +91 -0
- package/corpus/templates/slides-2/app/lib/deck-export-file-client.ts +77 -0
- package/corpus/templates/slides-2/app/lib/deck-filter.ts +52 -0
- package/corpus/templates/slides-2/app/lib/deck-list-loading.ts +16 -0
- package/corpus/templates/slides-2/app/lib/deck-preview-frame.ts +15 -0
- package/corpus/templates/slides-2/app/lib/deck-share-links.ts +9 -0
- package/corpus/templates/slides-2/app/lib/deck-sorting.ts +19 -0
- package/corpus/templates/slides-2/app/lib/deferred-editor-surfaces.ts +24 -0
- package/corpus/templates/slides-2/app/lib/design-system-selection.ts +11 -0
- package/corpus/templates/slides-2/app/lib/design-systems.ts +231 -0
- package/corpus/templates/slides-2/app/lib/dynamic-import.ts +50 -0
- package/corpus/templates/slides-2/app/lib/editor-agent-handoff.ts +92 -0
- package/corpus/templates/slides-2/app/lib/editor-shortcuts.ts +153 -0
- package/corpus/templates/slides-2/app/lib/export-google-slides-client.ts +168 -0
- package/corpus/templates/slides-2/app/lib/export-pdf-client.ts +684 -0
- package/corpus/templates/slides-2/app/lib/export-pptx-client.ts +2420 -0
- package/corpus/templates/slides-2/app/lib/generation-lifecycle.ts +24 -0
- package/corpus/templates/slides-2/app/lib/generation-state.ts +247 -0
- package/corpus/templates/slides-2/app/lib/google-docs-client.ts +110 -0
- package/corpus/templates/slides-2/app/lib/google-slides-export-availability-client.ts +53 -0
- package/corpus/templates/slides-2/app/lib/google-slides-reference-source.ts +18 -0
- package/corpus/templates/slides-2/app/lib/image-download.ts +85 -0
- package/corpus/templates/slides-2/app/lib/image-drop-to-agent.ts +210 -0
- package/corpus/templates/slides-2/app/lib/import-uploaded-deck.ts +132 -0
- package/corpus/templates/slides-2/app/lib/inline-edit-remote.ts +55 -0
- package/corpus/templates/slides-2/app/lib/localize-slides-changelog.ts +47 -0
- package/corpus/templates/slides-2/app/lib/mermaid-blocks.ts +18 -0
- package/corpus/templates/slides-2/app/lib/new-deck-reference-selection.ts +174 -0
- package/corpus/templates/slides-2/app/lib/normalize-slide-padding.ts +74 -0
- package/corpus/templates/slides-2/app/lib/pending-deck-changes.ts +33 -0
- package/corpus/templates/slides-2/app/lib/portaled-layer.ts +7 -0
- package/corpus/templates/slides-2/app/lib/pptx-google-slides.ts +204 -0
- package/corpus/templates/slides-2/app/lib/prompt-attachment-adapter.ts +37 -0
- package/corpus/templates/slides-2/app/lib/prompt-file-uploads.ts +557 -0
- package/corpus/templates/slides-2/app/lib/recent-references.ts +106 -0
- package/corpus/templates/slides-2/app/lib/reference-document-hydration.ts +406 -0
- package/corpus/templates/slides-2/app/lib/register-chat-renderers.tsx +645 -0
- package/corpus/templates/slides-2/app/lib/reveal-after-delete.ts +55 -0
- package/corpus/templates/slides-2/app/lib/sanitize-slide-html.ts +752 -0
- package/corpus/templates/slides-2/app/lib/slide-agent-context.ts +148 -0
- package/corpus/templates/slides-2/app/lib/slide-animation-elements.ts +900 -0
- package/corpus/templates/slides-2/app/lib/slide-clipboard.ts +534 -0
- package/corpus/templates/slides-2/app/lib/slide-comment-anchor.ts +286 -0
- package/corpus/templates/slides-2/app/lib/slide-content-merge.ts +295 -0
- package/corpus/templates/slides-2/app/lib/slide-image-replacement.ts +1919 -0
- package/corpus/templates/slides-2/app/lib/slide-live-remote.ts +215 -0
- package/corpus/templates/slides-2/app/lib/slide-scroll.ts +56 -0
- package/corpus/templates/slides-2/app/lib/slide-source-map.ts +1099 -0
- package/corpus/templates/slides-2/app/lib/slide-video.ts +390 -0
- package/corpus/templates/slides-2/app/lib/slides-relay-tracking.ts +114 -0
- package/corpus/templates/slides-2/app/lib/streaming-slide-html.ts +77 -0
- package/corpus/templates/slides-2/app/lib/tab-id.ts +3 -0
- package/corpus/templates/slides-2/app/lib/template-navigation.ts +15 -0
- package/corpus/templates/slides-2/app/lib/text-tool-shortcut.ts +75 -0
- package/corpus/templates/slides-2/app/lib/undo-reveal.ts +332 -0
- package/corpus/templates/slides-2/app/lib/upload-response.ts +107 -0
- package/corpus/templates/slides-2/app/lib/utils.ts +38 -0
- package/corpus/templates/slides-2/app/lib/validate-native-slide-html.ts +177 -0
- package/corpus/templates/slides-2/app/lib/video-upload.ts +354 -0
- package/corpus/templates/slides-2/app/pages/DeckEditor.tsx +6158 -0
- package/corpus/templates/slides-2/app/pages/DesignSystems.tsx +363 -0
- package/corpus/templates/slides-2/app/pages/Index.tsx +3254 -0
- package/corpus/templates/slides-2/app/pages/NotFound.tsx +33 -0
- package/corpus/templates/slides-2/app/pages/Presentation.tsx +120 -0
- package/corpus/templates/slides-2/app/pages/SharedPresentation.tsx +174 -0
- package/corpus/templates/slides-2/app/pages/SlideThemeDetail.tsx +227 -0
- package/corpus/templates/slides-2/app/pages/SlideThemes.tsx +155 -0
- package/corpus/templates/slides-2/app/pages/Slides2EditorPage.tsx +1618 -0
- package/corpus/templates/slides-2/app/pages/Slides2PresenterConsolePage.tsx +937 -0
- package/corpus/templates/slides-2/app/pages/Slides2PresenterPage.tsx +979 -0
- package/corpus/templates/slides-2/app/pages/Templates.tsx +32 -0
- package/corpus/templates/slides-2/app/root.tsx +391 -0
- package/corpus/templates/slides-2/app/routes/$.tsx +10 -0
- package/corpus/templates/slides-2/app/routes/_index.tsx +1 -0
- package/corpus/templates/slides-2/app/routes/access-request.approve.tsx +276 -0
- package/corpus/templates/slides-2/app/routes/agent.tsx +19 -0
- package/corpus/templates/slides-2/app/routes/chat.$threadId.tsx +1 -0
- package/corpus/templates/slides-2/app/routes/chat.tsx +190 -0
- package/corpus/templates/slides-2/app/routes/deck.$id.tsx +10 -0
- package/corpus/templates/slides-2/app/routes/deck.$id_.present.tsx +10 -0
- package/corpus/templates/slides-2/app/routes/design-systems.tsx +10 -0
- package/corpus/templates/slides-2/app/routes/extensions.$id.$slug.tsx +2 -0
- package/corpus/templates/slides-2/app/routes/extensions.$id.tsx +5 -0
- package/corpus/templates/slides-2/app/routes/extensions._index.tsx +5 -0
- package/corpus/templates/slides-2/app/routes/extensions.tsx +5 -0
- package/corpus/templates/slides-2/app/routes/home-layout.tsx +31 -0
- package/corpus/templates/slides-2/app/routes/home.tsx +22 -0
- package/corpus/templates/slides-2/app/routes/p.$id.tsx +195 -0
- package/corpus/templates/slides-2/app/routes/settings.$.tsx +1 -0
- package/corpus/templates/slides-2/app/routes/settings.tsx +131 -0
- package/corpus/templates/slides-2/app/routes/share.$token.tsx +137 -0
- package/corpus/templates/slides-2/app/routes/slide.tsx +209 -0
- package/corpus/templates/slides-2/app/routes/team.tsx +11 -0
- package/corpus/templates/slides-2/app/routes/templates.tsx +1 -0
- package/corpus/templates/slides-2/app/routes/themes.$id.tsx +1 -0
- package/corpus/templates/slides-2/app/routes/themes.tsx +1 -0
- package/corpus/templates/slides-2/app/routes.ts +24 -0
- package/corpus/templates/slides-2/app/vite-env.d.ts +24 -0
- package/corpus/templates/slides-2/changelog/2026-10-17-find-and-switch-decks-from-the-presenter-console.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-17-meet-slides-2-create-and-refine-editable-slide-decks-with-an.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-17-pptx-image-export.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-17-visual-editor.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-18-apply-an-accessible-design-system-to-an-existing-deck-before.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-18-choose-a-template-or-start-a-new-presentation-from-the-slide.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-18-generate-decks-from-a-prompt-then-edit-slide-elements-direct.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-18-generate-presentation-decks-from-a-prompt-and-edit-every-sli.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-18-new-presentation-drafts-save-before-generation-starts-so-you.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-18-the-assistant-can-undo-redo-and-save-pending-edits-in-the-vi.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-agents-can-insert-duplicate-and-delete-canvas-objects-in-sou.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-browse-slide-themes.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-clicking-a-slide-preview-in-overview-selects-that-slide.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-create-decks-from-a-prompt-and-edit-slides-directly-on-the-c.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-creating-and-editing-decks-now-starts-with-the-tools-most-re.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-deleting-decks-revokes-public-links.md +7 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-escape-cancels-an-in-progress-slide-drag-without-losing-earl.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-import-failures-now-show-clear-localized-descriptions-instea.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-presenter-controls-stay-responsive-when-moving-over-the-slid.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-presenter-notes-stay-private-from-viewers-and-commenters.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-preview-generated-slides-in-chat.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-remote-image-previews-accept-supported-raster-formats.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-search-the-svgl-catalog-and-add-svg-logos-to-a-deck-or-the-g.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-slide-generation-explains-when-react-effect-hooks-cannot-run.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-the-editor-highlights-hovered-objects-and-keeps-image-replac.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-19-the-slide-editor-uses-the-shared-agent-native-controls.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-20-deck-editing-controls-match-the-workspace.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-20-google-slides-imports-now-report-missing-image-data-instead-.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-20-imports-and-previews-handle-large-content-safely.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-20-public-deck-pages-can-export-source-backed-slides-to-pdf.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-20-saved-slide-images-stay-available.md +6 -0
- package/corpus/templates/slides-2/changelog/2026-10-20-scope-global-media-picks-to-assets-the-current-deck-can-reso.md +6 -0
- package/corpus/templates/slides-2/components.json +20 -0
- package/corpus/templates/slides-2/drizzle.config.ts +3 -0
- package/corpus/templates/slides-2/learnings.defaults.md +5 -0
- package/corpus/templates/slides-2/netlify.toml +24 -0
- package/corpus/templates/slides-2/package.json +147 -0
- package/corpus/templates/slides-2/public/agent-native-icon-dark.svg +10 -0
- package/corpus/templates/slides-2/public/agent-native-icon-light.svg +10 -0
- package/corpus/templates/slides-2/public/agent-native-logo-dark.svg +21 -0
- package/corpus/templates/slides-2/public/agent-native-logo-light.svg +21 -0
- package/corpus/templates/slides-2/public/assets/builder-logo-white.svg +15 -0
- package/corpus/templates/slides-2/public/assets/generated/preview.html +61 -0
- package/corpus/templates/slides-2/public/assets/intuit-logo-white.svg +6 -0
- package/corpus/templates/slides-2/public/assets/walmart-logo-white.svg +6 -0
- package/corpus/templates/slides-2/public/chatgpt-plugin-icon.svg +7 -0
- package/corpus/templates/slides-2/public/favicon.svg +1 -0
- package/corpus/templates/slides-2/public/icon-180.svg +1 -0
- package/corpus/templates/slides-2/public/icon-192.svg +1 -0
- package/corpus/templates/slides-2/public/icon-512.svg +1 -0
- package/corpus/templates/slides-2/public/manifest.json +20 -0
- package/corpus/templates/slides-2/public/placeholder.svg +1 -0
- package/corpus/templates/slides-2/public/robots.txt +14 -0
- package/corpus/templates/slides-2/public/visual-edit-structure-proof.html +99 -0
- package/corpus/templates/slides-2/react-router.config.ts +7 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/README.md +499 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/authoring-fuzz.ts +9517 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/baseline.json +16427 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/dev-server-url.ts +10 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/lib/in-page.ts +1975 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/lib/metrics.ts +1401 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/retry-infra.ts +7 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/run-options.ts +21 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/run-outcomes.ts +127 -0
- package/corpus/templates/slides-2/scripts/edit-fidelity/run.ts +8451 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/README.md +116 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/compare-layout-lib.ts +241 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/compare-layout.ts +30 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/diff.ts +222 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/export.ts +765 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/fixtures/agent-dark-deck.json +48 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/generate-calibration.ts +765 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/google-export.ts +137 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/google-layout.ts +82 -0
- package/corpus/templates/slides-2/scripts/export-fidelity/resolve-pkg.ts +29 -0
- package/corpus/templates/slides-2/scripts/migrate-production.ts +22 -0
- package/corpus/templates/slides-2/server/db/index.ts +73 -0
- package/corpus/templates/slides-2/server/db/schema.ts +189 -0
- package/corpus/templates/slides-2/server/handlers/assets-url.ts +13 -0
- package/corpus/templates/slides-2/server/handlers/assets.ts +3217 -0
- package/corpus/templates/slides-2/server/handlers/decks.ts +185 -0
- package/corpus/templates/slides-2/server/handlers/demo.ts +9 -0
- package/corpus/templates/slides-2/server/handlers/design-systems.ts +219 -0
- package/corpus/templates/slides-2/server/handlers/google-docs-auth.ts +165 -0
- package/corpus/templates/slides-2/server/handlers/image-gen.ts +153 -0
- package/corpus/templates/slides-2/server/handlers/image-providers/gemini.ts +209 -0
- package/corpus/templates/slides-2/server/handlers/image-providers/index.ts +61 -0
- package/corpus/templates/slides-2/server/handlers/image-providers/openai.ts +288 -0
- package/corpus/templates/slides-2/server/handlers/image-providers/types.ts +35 -0
- package/corpus/templates/slides-2/server/handlers/import/docx-parser.ts +31 -0
- package/corpus/templates/slides-2/server/handlers/import/html-converter.ts +1534 -0
- package/corpus/templates/slides-2/server/handlers/import/pdf-fidelity-parser.ts +1039 -0
- package/corpus/templates/slides-2/server/handlers/import/pdf-sidecar-reader.ts +81 -0
- package/corpus/templates/slides-2/server/handlers/import/pdf-style-digest.ts +187 -0
- package/corpus/templates/slides-2/server/handlers/import/pptx-assets.ts +155 -0
- package/corpus/templates/slides-2/server/handlers/import/pptx-parser.ts +57 -0
- package/corpus/templates/slides-2/server/handlers/request-auth-context.ts +108 -0
- package/corpus/templates/slides-2/server/handlers/share.ts +52 -0
- package/corpus/templates/slides-2/server/handlers/uploads-chunked.ts +1066 -0
- package/corpus/templates/slides-2/server/handlers/uploads.ts +457 -0
- package/corpus/templates/slides-2/server/lib/access-request-email.ts +66 -0
- package/corpus/templates/slides-2/server/lib/assets-image-delegation.ts +331 -0
- package/corpus/templates/slides-2/server/lib/bounded-multipart.ts +49 -0
- package/corpus/templates/slides-2/server/lib/builder-design-system-proxy.ts +122 -0
- package/corpus/templates/slides-2/server/lib/chat-attachments.ts +425 -0
- package/corpus/templates/slides-2/server/lib/chatgpt-directory-tools.ts +246 -0
- package/corpus/templates/slides-2/server/lib/chunked-upload-session.ts +195 -0
- package/corpus/templates/slides-2/server/lib/comment-notifications.ts +184 -0
- package/corpus/templates/slides-2/server/lib/deck-access-requests.ts +102 -0
- package/corpus/templates/slides-2/server/lib/deck-asset-scope.ts +150 -0
- package/corpus/templates/slides-2/server/lib/deck-export-tracking.ts +119 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/a-case-study.ts +154 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/a-company.ts +160 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/a-pitch.ts +151 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/a-quarterly.ts +264 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/a-shared.ts +35 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/a-update.ts +188 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/a-workshop.ts +196 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/b-keynote.ts +131 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/b-lesson.ts +209 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/b-manifesto.ts +149 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/b-portfolio.ts +144 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/b-research.ts +221 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/b-roadmap.ts +264 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/b-shared.ts +44 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/group-a.ts +16 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/group-b.ts +16 -0
- package/corpus/templates/slides-2/server/lib/deck-templates/legacy.ts +567 -0
- package/corpus/templates/slides-2/server/lib/deck-templates.ts +60 -0
- package/corpus/templates/slides-2/server/lib/deck-versions.ts +233 -0
- package/corpus/templates/slides-2/server/lib/design-system-workflows.ts +22 -0
- package/corpus/templates/slides-2/server/lib/emails.ts +84 -0
- package/corpus/templates/slides-2/server/lib/env-config.ts +15 -0
- package/corpus/templates/slides-2/server/lib/fetch-remote-image.ts +245 -0
- package/corpus/templates/slides-2/server/lib/generation-completion.ts +278 -0
- package/corpus/templates/slides-2/server/lib/google-docs-access.ts +51 -0
- package/corpus/templates/slides-2/server/lib/google-docs-error.ts +54 -0
- package/corpus/templates/slides-2/server/lib/google-docs-oauth.ts +422 -0
- package/corpus/templates/slides-2/server/lib/google-fonts.ts +509 -0
- package/corpus/templates/slides-2/server/lib/google-oauth-preflight.ts +119 -0
- package/corpus/templates/slides-2/server/lib/google-slides-export-availability.ts +55 -0
- package/corpus/templates/slides-2/server/lib/image-proxy-response.ts +16 -0
- package/corpus/templates/slides-2/server/lib/image-proxy-url.ts +155 -0
- package/corpus/templates/slides-2/server/lib/import-asset-storage.ts +214 -0
- package/corpus/templates/slides-2/server/lib/imported-asset-batch.ts +218 -0
- package/corpus/templates/slides-2/server/lib/legacy-slide-source.ts +692 -0
- package/corpus/templates/slides-2/server/lib/media-search-providers.ts +216 -0
- package/corpus/templates/slides-2/server/lib/native-creative-context.ts +295 -0
- package/corpus/templates/slides-2/server/lib/pdf-parse-setup.ts +115 -0
- package/corpus/templates/slides-2/server/lib/provider-api.ts +57 -0
- package/corpus/templates/slides-2/server/lib/request-wait-until.ts +30 -0
- package/corpus/templates/slides-2/server/lib/shared-deck.ts +29 -0
- package/corpus/templates/slides-2/server/lib/slide-asset-references.ts +309 -0
- package/corpus/templates/slides-2/server/lib/slide-content-patch.ts +1004 -0
- package/corpus/templates/slides-2/server/lib/slide-hygiene.ts +731 -0
- package/corpus/templates/slides-2/server/lib/slide-image-insertion.ts +136 -0
- package/corpus/templates/slides-2/server/lib/slide-reveal-issues.ts +41 -0
- package/corpus/templates/slides-2/server/lib/slide-source-editing/babel-walk.ts +117 -0
- package/corpus/templates/slides-2/server/lib/slide-source-editing/batch-edit.ts +152 -0
- package/corpus/templates/slides-2/server/lib/slide-source-editing/edit-ops.ts +1478 -0
- package/corpus/templates/slides-2/server/lib/slide-source-editing/image-target.ts +128 -0
- package/corpus/templates/slides-2/server/lib/slide-source-editing/text-diff.ts +23 -0
- package/corpus/templates/slides-2/server/lib/slide-source-limits.ts +9 -0
- package/corpus/templates/slides-2/server/lib/slide-source.ts +1786 -0
- package/corpus/templates/slides-2/server/lib/slide-theme-demo-sources.ts +2106 -0
- package/corpus/templates/slides-2/server/lib/slide-themes.ts +2174 -0
- package/corpus/templates/slides-2/server/lib/slide-worker-runtime.ts +1995 -0
- package/corpus/templates/slides-2/server/lib/slides-tracking.ts +73 -0
- package/corpus/templates/slides-2/server/lib/source-import.ts +213 -0
- package/corpus/templates/slides-2/server/lib/svgl.ts +364 -0
- package/corpus/templates/slides-2/server/lib/tenant-files.ts +179 -0
- package/corpus/templates/slides-2/server/lib/upload-storage-status.ts +9 -0
- package/corpus/templates/slides-2/server/lib/uploaded-asset-cleanup-outbox.ts +521 -0
- package/corpus/templates/slides-2/server/lib/uploaded-asset-object-lifecycle.ts +404 -0
- package/corpus/templates/slides-2/server/lib/uploaded-fonts.ts +696 -0
- package/corpus/templates/slides-2/server/lib/uploaded-reference-storage.ts +77 -0
- package/corpus/templates/slides-2/server/lib/validate-slide-animations.ts +341 -0
- package/corpus/templates/slides-2/server/middleware/auth.ts +6 -0
- package/corpus/templates/slides-2/server/plugins/_dev-upload-stub.ts +6 -0
- package/corpus/templates/slides-2/server/plugins/agent-chat.ts +402 -0
- package/corpus/templates/slides-2/server/plugins/auth.ts +31 -0
- package/corpus/templates/slides-2/server/plugins/collab.ts +30 -0
- package/corpus/templates/slides-2/server/plugins/config.ts +6 -0
- package/corpus/templates/slides-2/server/plugins/core-routes.ts +30 -0
- package/corpus/templates/slides-2/server/plugins/creative-context.ts +187 -0
- package/corpus/templates/slides-2/server/plugins/db.ts +462 -0
- package/corpus/templates/slides-2/server/plugins/feature-flags.ts +5 -0
- package/corpus/templates/slides-2/server/plugins/labs.ts +8 -0
- package/corpus/templates/slides-2/server/plugins/orphaned-asset-cleanup.ts +17 -0
- package/corpus/templates/slides-2/server/plugins/otel.ts +6 -0
- package/corpus/templates/slides-2/server/plugins/transactional-emails.ts +5 -0
- package/corpus/templates/slides-2/server/register-secrets.ts +209 -0
- package/corpus/templates/slides-2/server/routes/[...page].get.ts +5 -0
- package/corpus/templates/slides-2/server/routes/[...page].head.ts +1 -0
- package/corpus/templates/slides-2/server/routes/[base]/_agent-native/google-docs/auth-url.get.ts +1 -0
- package/corpus/templates/slides-2/server/routes/[base]/_agent-native/google-docs/callback.get.ts +1 -0
- package/corpus/templates/slides-2/server/routes/_agent-native/google-docs/auth-url.get.ts +1 -0
- package/corpus/templates/slides-2/server/routes/_agent-native/google-docs/callback.get.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/assets/upload-video.post.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/assets/upload.post.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/assets/video-uploads.delete.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/deck-agent-context.json.get.ts +105 -0
- package/corpus/templates/slides-2/server/routes/api/decks/events.get.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/demo.get.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/exports/[filename].get.ts +221 -0
- package/corpus/templates/slides-2/server/routes/api/exports/google-slides.post.ts +240 -0
- package/corpus/templates/slides-2/server/routes/api/exports/html.post.ts +67 -0
- package/corpus/templates/slides-2/server/routes/api/exports/pptx.post.ts +100 -0
- package/corpus/templates/slides-2/server/routes/api/gen-preview/[...].get.ts +24 -0
- package/corpus/templates/slides-2/server/routes/api/generated/[...].get.ts +24 -0
- package/corpus/templates/slides-2/server/routes/api/image-proxy.get.ts +518 -0
- package/corpus/templates/slides-2/server/routes/api/import-assets/[token].get.ts +70 -0
- package/corpus/templates/slides-2/server/routes/api/preview-images.get.ts +20 -0
- package/corpus/templates/slides-2/server/routes/api/share/[token].get.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/uploads-chunked/[sessionId]/chunk.post.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/uploads-chunked/[sessionId]/status.get.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/uploads-chunked/[sessionId].delete.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/uploads-chunked/start.post.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/uploads.delete.ts +1 -0
- package/corpus/templates/slides-2/server/routes/api/uploads.post.ts +1 -0
- package/corpus/templates/slides-2/server/workspace-defaults.ts +196 -0
- package/corpus/templates/slides-2/shared/action-ui.ts +147 -0
- package/corpus/templates/slides-2/shared/agent-readable.ts +2 -0
- package/corpus/templates/slides-2/shared/api.ts +406 -0
- package/corpus/templates/slides-2/shared/app-state-tabs.ts +30 -0
- package/corpus/templates/slides-2/shared/app-storage.ts +9 -0
- package/corpus/templates/slides-2/shared/aspect-ratios.ts +49 -0
- package/corpus/templates/slides-2/shared/blank-slide.ts +179 -0
- package/corpus/templates/slides-2/shared/client-compatibility.ts +2 -0
- package/corpus/templates/slides-2/shared/contrast-audit.ts +255 -0
- package/corpus/templates/slides-2/shared/deck-access.ts +26 -0
- package/corpus/templates/slides-2/shared/deck-app-scope.ts +14 -0
- package/corpus/templates/slides-2/shared/deck-content.ts +37 -0
- package/corpus/templates/slides-2/shared/deck-history-control.ts +79 -0
- package/corpus/templates/slides-2/shared/deck-scope.ts +5 -0
- package/corpus/templates/slides-2/shared/deck-title.ts +199 -0
- package/corpus/templates/slides-2/shared/deck-write.ts +61 -0
- package/corpus/templates/slides-2/shared/design-flags.ts +7 -0
- package/corpus/templates/slides-2/shared/design-system-validation.ts +88 -0
- package/corpus/templates/slides-2/shared/editor-control.ts +120 -0
- package/corpus/templates/slides-2/shared/generation-timing.ts +19 -0
- package/corpus/templates/slides-2/shared/google-docs.ts +69 -0
- package/corpus/templates/slides-2/shared/labs.ts +10 -0
- package/corpus/templates/slides-2/shared/overview-navigation.ts +34 -0
- package/corpus/templates/slides-2/shared/ownership.ts +6 -0
- package/corpus/templates/slides-2/shared/pdf-sidecar.ts +130 -0
- package/corpus/templates/slides-2/shared/presenter-control.ts +111 -0
- package/corpus/templates/slides-2/shared/representative-slide.ts +89 -0
- package/corpus/templates/slides-2/shared/slide-background.ts +30 -0
- package/corpus/templates/slides-2/shared/slide-comment-anchor.ts +117 -0
- package/corpus/templates/slides-2/shared/slide-comment-reactions.ts +47 -0
- package/corpus/templates/slides-2/shared/slide-design-tokens.ts +92 -0
- package/corpus/templates/slides-2/shared/slide-fit.ts +78 -0
- package/corpus/templates/slides-2/shared/slide-ids.ts +133 -0
- package/corpus/templates/slides-2/shared/slide-number.ts +124 -0
- package/corpus/templates/slides-2/shared/slide-object-structure.ts +790 -0
- package/corpus/templates/slides-2/shared/slide-text-range-selection.ts +50 -0
- package/corpus/templates/slides-2/shared/slide-transitions.ts +70 -0
- package/corpus/templates/slides-2/shared/slides-2-transition.ts +194 -0
- package/corpus/templates/slides-2/shared/slides-user-prefs.ts +22 -0
- package/corpus/templates/slides-2/shared/source-import-errors.ts +12 -0
- package/corpus/templates/slides-2/shared/source-runtime-export.ts +76 -0
- package/corpus/templates/slides-2/shared/upload-types.ts +41 -0
- package/corpus/templates/slides-2/ssr-entry.ts +11 -0
- package/corpus/templates/slides-2/tsconfig.json +27 -0
- package/corpus/templates/slides-2/vite.config.ts +77 -0
- package/corpus/templates/slides-2/vitest.config.ts +28 -0
- package/corpus/templates/tasks/.agents/skills/actions/references/action-fields.md +1 -1
- package/package.json +1 -1
- package/corpus/templates/design/.agents/skills/shader-fills/SKILL.md +0 -182
- package/corpus/templates/design/actions/apply-shader-fill.ts +0 -450
- package/corpus/templates/design/actions/apply-shader.ts +0 -257
- package/corpus/templates/design/actions/preview-shader-fill.ts +0 -157
- package/corpus/templates/design/app/components/design/inspector/GlslShaderPanel.tsx +0 -1144
- package/corpus/templates/design/app/components/design/inspector/SHADER_INTEGRATION.md +0 -450
- package/corpus/templates/design/app/components/design/inspector/ShaderControls.stories.tsx +0 -71
- package/corpus/templates/design/app/components/design/inspector/ShaderControls.tsx +0 -555
- package/corpus/templates/design/app/components/design/inspector/ShaderEffectRow.tsx +0 -105
- package/corpus/templates/design/app/components/design/inspector/ShaderFillsPanel.tsx +0 -433
- package/corpus/templates/design/app/components/design/inspector/color-picker-shader-pane.tsx +0 -648
- package/corpus/templates/design/shared/shader-fill.ts +0 -174
- package/corpus/templates/design/shared/shader-presets.ts +0 -1523
|
@@ -0,0 +1,2420 @@
|
|
|
1
|
+
import {
|
|
2
|
+
materializeSlideNumberTokens,
|
|
3
|
+
slideNumberRootAttrs,
|
|
4
|
+
} from "@shared/slide-number";
|
|
5
|
+
|
|
6
|
+
import { type AspectRatio, getAspectRatioDims } from "./aspect-ratios";
|
|
7
|
+
import { importExportModule } from "./dynamic-import";
|
|
8
|
+
import {
|
|
9
|
+
exposeGoogleFontStylesheetsForExport,
|
|
10
|
+
findSlideExportSource,
|
|
11
|
+
preloadImagesWithCors,
|
|
12
|
+
} from "./export-pdf-client";
|
|
13
|
+
import {
|
|
14
|
+
type FontMetrics,
|
|
15
|
+
retargetPptxForGoogleSlides,
|
|
16
|
+
WRAP_MARK,
|
|
17
|
+
} from "./pptx-google-slides";
|
|
18
|
+
import {
|
|
19
|
+
browserExportErrorType,
|
|
20
|
+
trackBrowserDeckExported,
|
|
21
|
+
type BrowserDeckExportFacts,
|
|
22
|
+
} from "./slides-relay-tracking";
|
|
23
|
+
|
|
24
|
+
interface PptxExportSlide {
|
|
25
|
+
id: string;
|
|
26
|
+
notes?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function safePptxName(title: string) {
|
|
30
|
+
const safeName = title.replace(/[^a-zA-Z0-9]/g, "-") || "deck";
|
|
31
|
+
return `${safeName}.pptx`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function triggerBlobDownload(blob: Blob, filename: string) {
|
|
35
|
+
const url = URL.createObjectURL(blob);
|
|
36
|
+
const a = document.createElement("a");
|
|
37
|
+
a.href = url;
|
|
38
|
+
a.download = filename;
|
|
39
|
+
a.rel = "noopener";
|
|
40
|
+
document.body.appendChild(a);
|
|
41
|
+
a.click();
|
|
42
|
+
a.remove();
|
|
43
|
+
window.setTimeout(() => URL.revokeObjectURL(url), 60_000);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const IMAGE_SETTLE_TIMEOUT_MS = 5_000;
|
|
47
|
+
|
|
48
|
+
function waitForImageToSettle(image: HTMLImageElement): Promise<void> {
|
|
49
|
+
return new Promise<void>((resolve, reject) => {
|
|
50
|
+
let decodeStarted = false;
|
|
51
|
+
let settled = false;
|
|
52
|
+
let timeoutId: number | undefined;
|
|
53
|
+
|
|
54
|
+
const cleanup = () => {
|
|
55
|
+
image.removeEventListener("error", handleLoad);
|
|
56
|
+
image.removeEventListener("load", handleLoad);
|
|
57
|
+
if (timeoutId !== undefined) window.clearTimeout(timeoutId);
|
|
58
|
+
};
|
|
59
|
+
const finish = () => {
|
|
60
|
+
if (settled) return;
|
|
61
|
+
settled = true;
|
|
62
|
+
cleanup();
|
|
63
|
+
resolve();
|
|
64
|
+
};
|
|
65
|
+
const fail = (error: unknown) => {
|
|
66
|
+
if (settled) return;
|
|
67
|
+
settled = true;
|
|
68
|
+
cleanup();
|
|
69
|
+
reject(error);
|
|
70
|
+
};
|
|
71
|
+
const decode = () => {
|
|
72
|
+
if (decodeStarted) return;
|
|
73
|
+
decodeStarted = true;
|
|
74
|
+
if (!image.complete || image.naturalWidth <= 0) {
|
|
75
|
+
console.warn(
|
|
76
|
+
`[export-pptx] image could not be loaded for export: ${image.src}`,
|
|
77
|
+
);
|
|
78
|
+
finish();
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
Promise.resolve()
|
|
82
|
+
.then(() => image.decode())
|
|
83
|
+
.then(finish, (error: unknown) => {
|
|
84
|
+
if (error instanceof Error && error.name === "EncodingError") {
|
|
85
|
+
finish();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
fail(error);
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
const handleLoad = () => decode();
|
|
92
|
+
|
|
93
|
+
timeoutId = window.setTimeout(finish, IMAGE_SETTLE_TIMEOUT_MS);
|
|
94
|
+
image.addEventListener("error", handleLoad);
|
|
95
|
+
image.addEventListener("load", handleLoad);
|
|
96
|
+
if (image.complete) decode();
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function waitForImagesToSettle(root: HTMLElement) {
|
|
101
|
+
const images = Array.from(root.querySelectorAll<HTMLImageElement>("img"));
|
|
102
|
+
await Promise.all(images.map((image) => waitForImageToSettle(image)));
|
|
103
|
+
if (typeof window.requestAnimationFrame === "function") {
|
|
104
|
+
await new Promise<void>((resolve) => {
|
|
105
|
+
window.requestAnimationFrame(() =>
|
|
106
|
+
window.requestAnimationFrame(() => resolve()),
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function escapeXml(value: string) {
|
|
113
|
+
return value
|
|
114
|
+
.replace(/&/g, "&")
|
|
115
|
+
.replace(/</g, "<")
|
|
116
|
+
.replace(/>/g, ">")
|
|
117
|
+
.replace(/"/g, """)
|
|
118
|
+
.replace(/'/g, "'");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function addRelationship(xml: string, relationship: string) {
|
|
122
|
+
if (xml.includes(relationship)) return xml;
|
|
123
|
+
return xml.replace("</Relationships>", `${relationship}</Relationships>`);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function addContentTypeOverride(xml: string, partName: string, type: string) {
|
|
127
|
+
if (xml.includes(`PartName="${partName}"`)) return xml;
|
|
128
|
+
return xml.replace(
|
|
129
|
+
"</Types>",
|
|
130
|
+
`<Override PartName="${partName}" ContentType="${type}"/></Types>`,
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function nextRelationshipId(xml: string) {
|
|
135
|
+
const ids = Array.from(xml.matchAll(/\bId="rId(\d+)"/g)).map((match) =>
|
|
136
|
+
Number(match[1]),
|
|
137
|
+
);
|
|
138
|
+
return `rId${Math.max(0, ...ids) + 1}`;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function notesTextBody(notes: string) {
|
|
142
|
+
const lines = notes.split(/\r?\n/);
|
|
143
|
+
return lines
|
|
144
|
+
.map(
|
|
145
|
+
(line) =>
|
|
146
|
+
`<a:p><a:r><a:rPr lang="en-US" dirty="0"/><a:t>${escapeXml(line)}</a:t></a:r><a:endParaRPr lang="en-US" dirty="0"/></a:p>`,
|
|
147
|
+
)
|
|
148
|
+
.join("");
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function notesSlideXml(notes: string, slideNumber: number) {
|
|
152
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
153
|
+
<p:notes xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"><p:cSld><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr><p:sp><p:nvSpPr><p:cNvPr id="2" name="Slide Image Placeholder 1"/><p:cNvSpPr><a:spLocks noGrp="1" noRot="1" noChangeAspect="1"/></p:cNvSpPr><p:nvPr><p:ph type="sldImg"/></p:nvPr></p:nvSpPr><p:spPr/></p:sp><p:sp><p:nvSpPr><p:cNvPr id="3" name="Notes Placeholder 2"/><p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr><p:ph type="body" idx="1"/></p:nvPr></p:nvSpPr><p:spPr/><p:txBody><a:bodyPr/><a:lstStyle/>${notesTextBody(notes)}</p:txBody></p:sp><p:sp><p:nvSpPr><p:cNvPr id="4" name="Slide Number Placeholder 3"/><p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr><p:ph type="sldNum" sz="quarter" idx="10"/></p:nvPr></p:nvSpPr><p:spPr/><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:fld id="{F7021451-1387-4CA6-816F-3879F97B5CBC}" type="slidenum"><a:rPr lang="en-US"/><a:t>${slideNumber}</a:t></a:fld><a:endParaRPr lang="en-US"/></a:p></p:txBody></p:sp></p:spTree></p:cSld><p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr></p:notes>`;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const NOTES_MASTER_XML = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
157
|
+
<p:notesMaster xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"><p:cSld><p:bg><p:bgRef idx="1001"><a:schemeClr val="bg1"/></p:bgRef></p:bg><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr></p:spTree></p:cSld><p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/><p:notesStyle><a:lvl1pPr marL="0" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1"><a:defRPr sz="1200" kern="1200"><a:solidFill><a:schemeClr val="tx1"/></a:solidFill><a:latin typeface="+mn-lt"/><a:ea typeface="+mn-ea"/><a:cs typeface="+mn-cs"/></a:defRPr></a:lvl1pPr></p:notesStyle></p:notesMaster>`;
|
|
158
|
+
|
|
159
|
+
const NOTES_MASTER_RELS_XML = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
160
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="../theme/theme1.xml"/></Relationships>`;
|
|
161
|
+
|
|
162
|
+
const EMU_PER_INCH = 914_400;
|
|
163
|
+
|
|
164
|
+
export async function addSpeakerNotesToPptxBlob(
|
|
165
|
+
blob: Blob,
|
|
166
|
+
slides: PptxExportSlide[],
|
|
167
|
+
pptxInches: { w: number; h: number },
|
|
168
|
+
): Promise<Blob> {
|
|
169
|
+
const hasNotes = slides.some((slide) => slide.notes?.trim());
|
|
170
|
+
if (!hasNotes) return blob;
|
|
171
|
+
|
|
172
|
+
const { default: JSZip } = await importExportModule(() => import("jszip"));
|
|
173
|
+
const zip = await JSZip.loadAsync(blob);
|
|
174
|
+
|
|
175
|
+
const contentTypesFile = zip.file("[Content_Types].xml");
|
|
176
|
+
const presentationFile = zip.file("ppt/presentation.xml");
|
|
177
|
+
const presentationRelsFile = zip.file("ppt/_rels/presentation.xml.rels");
|
|
178
|
+
|
|
179
|
+
if (!contentTypesFile || !presentationFile || !presentationRelsFile) {
|
|
180
|
+
return blob;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
let contentTypes = await contentTypesFile.async("string");
|
|
184
|
+
let presentationXml = await presentationFile.async("string");
|
|
185
|
+
let presentationRels = await presentationRelsFile.async("string");
|
|
186
|
+
|
|
187
|
+
if (!zip.file("ppt/notesMasters/notesMaster1.xml")) {
|
|
188
|
+
zip.file("ppt/notesMasters/notesMaster1.xml", NOTES_MASTER_XML);
|
|
189
|
+
}
|
|
190
|
+
if (!zip.file("ppt/notesMasters/_rels/notesMaster1.xml.rels")) {
|
|
191
|
+
zip.file(
|
|
192
|
+
"ppt/notesMasters/_rels/notesMaster1.xml.rels",
|
|
193
|
+
NOTES_MASTER_RELS_XML,
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
contentTypes = addContentTypeOverride(
|
|
198
|
+
contentTypes,
|
|
199
|
+
"/ppt/notesMasters/notesMaster1.xml",
|
|
200
|
+
"application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml",
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
if (!presentationRels.includes("relationships/notesMaster")) {
|
|
204
|
+
const relId = nextRelationshipId(presentationRels);
|
|
205
|
+
presentationRels = addRelationship(
|
|
206
|
+
presentationRels,
|
|
207
|
+
`<Relationship Id="${relId}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster" Target="notesMasters/notesMaster1.xml"/>`,
|
|
208
|
+
);
|
|
209
|
+
if (!presentationXml.includes("<p:notesMasterIdLst>")) {
|
|
210
|
+
presentationXml = presentationXml.replace(
|
|
211
|
+
"</p:sldIdLst>",
|
|
212
|
+
`</p:sldIdLst><p:notesMasterIdLst><p:notesMasterId r:id="${relId}"/></p:notesMasterIdLst>`,
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (!presentationXml.includes("<p:notesSz")) {
|
|
218
|
+
const notesCx = Math.round(pptxInches.h * EMU_PER_INCH);
|
|
219
|
+
const notesCy = Math.round(pptxInches.w * EMU_PER_INCH);
|
|
220
|
+
presentationXml = presentationXml.replace(
|
|
221
|
+
"<p:defaultTextStyle>",
|
|
222
|
+
`<p:notesSz cx="${notesCx}" cy="${notesCy}"/><p:defaultTextStyle>`,
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
for (let i = 0; i < slides.length; i++) {
|
|
227
|
+
const notes = slides[i].notes?.trim();
|
|
228
|
+
if (!notes) continue;
|
|
229
|
+
|
|
230
|
+
const slideNumber = i + 1;
|
|
231
|
+
const slideRelsPath = `ppt/slides/_rels/slide${slideNumber}.xml.rels`;
|
|
232
|
+
const slideRelsFile = zip.file(slideRelsPath);
|
|
233
|
+
if (!slideRelsFile) continue;
|
|
234
|
+
|
|
235
|
+
let slideRels = await slideRelsFile.async("string");
|
|
236
|
+
if (!slideRels.includes("relationships/notesSlide")) {
|
|
237
|
+
const relId = nextRelationshipId(slideRels);
|
|
238
|
+
slideRels = addRelationship(
|
|
239
|
+
slideRels,
|
|
240
|
+
`<Relationship Id="${relId}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide" Target="../notesSlides/notesSlide${slideNumber}.xml"/>`,
|
|
241
|
+
);
|
|
242
|
+
zip.file(slideRelsPath, slideRels);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
zip.file(
|
|
246
|
+
`ppt/notesSlides/notesSlide${slideNumber}.xml`,
|
|
247
|
+
notesSlideXml(notes, slideNumber),
|
|
248
|
+
);
|
|
249
|
+
zip.file(
|
|
250
|
+
`ppt/notesSlides/_rels/notesSlide${slideNumber}.xml.rels`,
|
|
251
|
+
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
252
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster" Target="../notesMasters/notesMaster1.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="../slides/slide${slideNumber}.xml"/></Relationships>`,
|
|
253
|
+
);
|
|
254
|
+
contentTypes = addContentTypeOverride(
|
|
255
|
+
contentTypes,
|
|
256
|
+
`/ppt/notesSlides/notesSlide${slideNumber}.xml`,
|
|
257
|
+
"application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml",
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
zip.file("[Content_Types].xml", contentTypes);
|
|
262
|
+
zip.file("ppt/presentation.xml", presentationXml);
|
|
263
|
+
zip.file("ppt/_rels/presentation.xml.rels", presentationRels);
|
|
264
|
+
|
|
265
|
+
return zip.generateAsync({
|
|
266
|
+
type: "blob",
|
|
267
|
+
compression: "DEFLATE",
|
|
268
|
+
compressionOptions: { level: 6 },
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function createUnscaledExportClone(
|
|
273
|
+
source: HTMLElement,
|
|
274
|
+
dims: { width: number; height: number },
|
|
275
|
+
) {
|
|
276
|
+
const sourceRect = source.getBoundingClientRect();
|
|
277
|
+
const imageGeometry = collectImageGeometry(source);
|
|
278
|
+
const textGeometry = collectTextGeometry(source, {
|
|
279
|
+
x: sourceRect.width / dims.width || 1,
|
|
280
|
+
y: sourceRect.height / dims.height || 1,
|
|
281
|
+
});
|
|
282
|
+
const positionedGeometry = collectPositionedGeometry(source);
|
|
283
|
+
|
|
284
|
+
const stage = document.createElement("div");
|
|
285
|
+
stage.setAttribute("aria-hidden", "true");
|
|
286
|
+
Object.assign(stage.style, {
|
|
287
|
+
height: `${dims.height}px`,
|
|
288
|
+
left: "-100000px",
|
|
289
|
+
overflow: "hidden",
|
|
290
|
+
pointerEvents: "none",
|
|
291
|
+
position: "fixed",
|
|
292
|
+
top: "0",
|
|
293
|
+
width: `${dims.width}px`,
|
|
294
|
+
zIndex: "-1",
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
const clone = source.cloneNode(true) as HTMLElement;
|
|
298
|
+
Object.assign(clone.style, {
|
|
299
|
+
height: `${dims.height}px`,
|
|
300
|
+
maxHeight: `${dims.height}px`,
|
|
301
|
+
maxWidth: `${dims.width}px`,
|
|
302
|
+
position: "relative",
|
|
303
|
+
transform: "none",
|
|
304
|
+
width: `${dims.width}px`,
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
stage.appendChild(clone);
|
|
308
|
+
document.body.appendChild(stage);
|
|
309
|
+
|
|
310
|
+
return {
|
|
311
|
+
element: clone,
|
|
312
|
+
cleanup: () => stage.remove(),
|
|
313
|
+
imageGeometry,
|
|
314
|
+
positionedGeometry,
|
|
315
|
+
textGeometry,
|
|
316
|
+
sourceRect,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
interface ElementPathRecord {
|
|
321
|
+
path: number[];
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
interface PositionedGeometryRecord extends ElementPathRecord {
|
|
325
|
+
rect: DOMRect;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
interface ImageGeometryRecord extends ElementPathRecord {
|
|
329
|
+
position: string;
|
|
330
|
+
rect: DOMRect;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
interface TextGeometryRecord extends ElementPathRecord {
|
|
334
|
+
fontSize: number;
|
|
335
|
+
heading: boolean;
|
|
336
|
+
letterSpacing: number;
|
|
337
|
+
lineHeight: number;
|
|
338
|
+
position: string;
|
|
339
|
+
rect: DOMRect;
|
|
340
|
+
scaleX: number;
|
|
341
|
+
scaleY: number;
|
|
342
|
+
singleLine: boolean;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function getElementPath(root: HTMLElement, element: HTMLElement) {
|
|
346
|
+
const path: number[] = [];
|
|
347
|
+
let current: HTMLElement | null = element;
|
|
348
|
+
|
|
349
|
+
while (current && current !== root) {
|
|
350
|
+
const parent: HTMLElement | null = current.parentElement;
|
|
351
|
+
if (!parent) return null;
|
|
352
|
+
const index = Array.prototype.indexOf.call(parent.children, current);
|
|
353
|
+
if (index < 0) return null;
|
|
354
|
+
path.unshift(index);
|
|
355
|
+
current = parent;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
return current === root ? path : null;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function getElementAtPath(root: HTMLElement, path: number[]) {
|
|
362
|
+
let current: Element = root;
|
|
363
|
+
for (const index of path) {
|
|
364
|
+
const child = current.children[index];
|
|
365
|
+
if (!(child instanceof HTMLElement)) return null;
|
|
366
|
+
current = child;
|
|
367
|
+
}
|
|
368
|
+
return current instanceof HTMLElement ? current : null;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function isPositionedElement(element: HTMLElement) {
|
|
372
|
+
const position = window.getComputedStyle(element).position;
|
|
373
|
+
return position === "absolute" || position === "fixed";
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function hasPositionedAncestor(element: HTMLElement, root: HTMLElement) {
|
|
377
|
+
let parent = element.parentElement;
|
|
378
|
+
while (parent && parent !== root) {
|
|
379
|
+
if (isPositionedElement(parent)) return true;
|
|
380
|
+
parent = parent.parentElement;
|
|
381
|
+
}
|
|
382
|
+
return false;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function isTextGeometryCandidate(element: HTMLElement) {
|
|
386
|
+
if (!element.textContent?.trim()) return false;
|
|
387
|
+
if (element.querySelector("img,svg,video,canvas")) return false;
|
|
388
|
+
if (element.closest('[aria-hidden="true"]')) return false;
|
|
389
|
+
if (
|
|
390
|
+
element.tagName === "LI" ||
|
|
391
|
+
element.tagName === "UL" ||
|
|
392
|
+
element.tagName === "OL"
|
|
393
|
+
) {
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
const isHeading = /^H[1-3]$/.test(element.tagName);
|
|
397
|
+
const isTextBlock = element.tagName === "P";
|
|
398
|
+
const isLeafText =
|
|
399
|
+
element.tagName === "DIV" &&
|
|
400
|
+
(element.children.length === 0 ||
|
|
401
|
+
element.hasAttribute("data-slide-object-id"));
|
|
402
|
+
if (!isHeading && !isTextBlock && !isLeafText) {
|
|
403
|
+
return false;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const style = window.getComputedStyle(element);
|
|
407
|
+
if (style.display === "none" || style.visibility === "hidden") {
|
|
408
|
+
return false;
|
|
409
|
+
}
|
|
410
|
+
const rect = element.getBoundingClientRect();
|
|
411
|
+
return rect.width > 0 && rect.height > 0;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function computedLength(value: string, fallback: number) {
|
|
415
|
+
const parsed = Number.parseFloat(value);
|
|
416
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function collectImageGeometry(root: HTMLElement) {
|
|
420
|
+
return Array.from(root.querySelectorAll<HTMLImageElement>("img")).flatMap(
|
|
421
|
+
(element): ImageGeometryRecord[] => {
|
|
422
|
+
const style = window.getComputedStyle(element);
|
|
423
|
+
const rect = element.getBoundingClientRect();
|
|
424
|
+
const path = getElementPath(root, element);
|
|
425
|
+
if (
|
|
426
|
+
!path ||
|
|
427
|
+
style.display === "none" ||
|
|
428
|
+
style.visibility === "hidden" ||
|
|
429
|
+
!rect.width ||
|
|
430
|
+
!rect.height
|
|
431
|
+
) {
|
|
432
|
+
return [];
|
|
433
|
+
}
|
|
434
|
+
return [{ path, position: style.position, rect }];
|
|
435
|
+
},
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function collectTextGeometry(
|
|
440
|
+
root: HTMLElement,
|
|
441
|
+
slideScale: { x: number; y: number },
|
|
442
|
+
) {
|
|
443
|
+
return Array.from(root.querySelectorAll<HTMLElement>("h1,h2,h3,p,div"))
|
|
444
|
+
.filter(isTextGeometryCandidate)
|
|
445
|
+
.flatMap((element): TextGeometryRecord[] => {
|
|
446
|
+
const path = getElementPath(root, element);
|
|
447
|
+
if (!path) return [];
|
|
448
|
+
|
|
449
|
+
const style = window.getComputedStyle(element);
|
|
450
|
+
const rect = element.getBoundingClientRect();
|
|
451
|
+
const layoutWidth = computedLength(style.width, rect.width);
|
|
452
|
+
const layoutHeight = computedLength(style.height, rect.height);
|
|
453
|
+
const fontSize = computedLength(style.fontSize, 16);
|
|
454
|
+
const lineHeight = computedLength(
|
|
455
|
+
style.lineHeight,
|
|
456
|
+
Math.max(16, fontSize * 1.2),
|
|
457
|
+
);
|
|
458
|
+
return [
|
|
459
|
+
{
|
|
460
|
+
fontSize,
|
|
461
|
+
heading: /^H[1-3]$/.test(element.tagName),
|
|
462
|
+
letterSpacing: computedLength(style.letterSpacing, 0),
|
|
463
|
+
lineHeight,
|
|
464
|
+
path,
|
|
465
|
+
position: style.position,
|
|
466
|
+
rect,
|
|
467
|
+
scaleX: rect.width / Math.max(1, layoutWidth) / slideScale.x,
|
|
468
|
+
scaleY: rect.height / Math.max(1, layoutHeight) / slideScale.y,
|
|
469
|
+
singleLine: rect.height / slideScale.y <= lineHeight * 1.35,
|
|
470
|
+
},
|
|
471
|
+
];
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
function collectPositionedGeometry(root: HTMLElement) {
|
|
476
|
+
return Array.from(root.querySelectorAll<HTMLElement>("*"))
|
|
477
|
+
.filter((element) => {
|
|
478
|
+
if (!isPositionedElement(element)) return false;
|
|
479
|
+
if (hasPositionedAncestor(element, root)) return false;
|
|
480
|
+
const rect = element.getBoundingClientRect();
|
|
481
|
+
return rect.width > 0 && rect.height > 0;
|
|
482
|
+
})
|
|
483
|
+
.flatMap((element): PositionedGeometryRecord[] => {
|
|
484
|
+
const path = getElementPath(root, element);
|
|
485
|
+
return path ? [{ path, rect: element.getBoundingClientRect() }] : [];
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function restorePositionedGeometry(
|
|
490
|
+
clone: HTMLElement,
|
|
491
|
+
sourceRect: DOMRect,
|
|
492
|
+
records: PositionedGeometryRecord[],
|
|
493
|
+
dims: { width: number; height: number },
|
|
494
|
+
) {
|
|
495
|
+
const cloneRect = clone.getBoundingClientRect();
|
|
496
|
+
if (
|
|
497
|
+
!sourceRect.width ||
|
|
498
|
+
!sourceRect.height ||
|
|
499
|
+
!cloneRect.width ||
|
|
500
|
+
!cloneRect.height
|
|
501
|
+
) {
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
const scaleX = dims.width / sourceRect.width;
|
|
506
|
+
const scaleY = dims.height / sourceRect.height;
|
|
507
|
+
|
|
508
|
+
for (const record of records) {
|
|
509
|
+
const element = getElementAtPath(clone, record.path);
|
|
510
|
+
if (!element) continue;
|
|
511
|
+
|
|
512
|
+
const currentRect = element.getBoundingClientRect();
|
|
513
|
+
const desiredLeft = (record.rect.left - sourceRect.left) * scaleX;
|
|
514
|
+
const desiredTop = (record.rect.top - sourceRect.top) * scaleY;
|
|
515
|
+
const currentLeft = currentRect.left - cloneRect.left;
|
|
516
|
+
const currentTop = currentRect.top - cloneRect.top;
|
|
517
|
+
const currentStyle = window.getComputedStyle(element);
|
|
518
|
+
const currentCssLeft = Number.parseFloat(currentStyle.left);
|
|
519
|
+
const currentCssTop = Number.parseFloat(currentStyle.top);
|
|
520
|
+
|
|
521
|
+
element.style.position = "absolute";
|
|
522
|
+
element.style.right = "auto";
|
|
523
|
+
element.style.bottom = "auto";
|
|
524
|
+
element.style.left = `${(Number.isFinite(currentCssLeft)
|
|
525
|
+
? currentCssLeft + (desiredLeft - currentLeft)
|
|
526
|
+
: desiredLeft
|
|
527
|
+
).toFixed(3)}px`;
|
|
528
|
+
element.style.top = `${(Number.isFinite(currentCssTop)
|
|
529
|
+
? currentCssTop + (desiredTop - currentTop)
|
|
530
|
+
: desiredTop
|
|
531
|
+
).toFixed(3)}px`;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
function resetAutofitTransforms(root: HTMLElement) {
|
|
536
|
+
for (const layer of root.querySelectorAll<HTMLElement>(
|
|
537
|
+
"[data-fmd-autofit-content]",
|
|
538
|
+
)) {
|
|
539
|
+
layer.style.transform = "none";
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
function noWrapWhiteSpace(element: HTMLElement) {
|
|
544
|
+
return window.getComputedStyle(element).whiteSpace.startsWith("pre")
|
|
545
|
+
? "pre"
|
|
546
|
+
: "nowrap";
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function restoreTextGeometry(
|
|
550
|
+
clone: HTMLElement,
|
|
551
|
+
sourceRect: DOMRect,
|
|
552
|
+
records: TextGeometryRecord[],
|
|
553
|
+
dims: { width: number; height: number },
|
|
554
|
+
) {
|
|
555
|
+
if (!sourceRect.width || !sourceRect.height) return;
|
|
556
|
+
|
|
557
|
+
const scaleX = dims.width / sourceRect.width;
|
|
558
|
+
const scaleY = dims.height / sourceRect.height;
|
|
559
|
+
for (const record of records) {
|
|
560
|
+
const element = getElementAtPath(clone, record.path);
|
|
561
|
+
if (!element) continue;
|
|
562
|
+
|
|
563
|
+
let ancestor = element.parentElement;
|
|
564
|
+
while (ancestor && ancestor !== clone) {
|
|
565
|
+
if (window.getComputedStyle(ancestor).transform !== "none") {
|
|
566
|
+
ancestor.style.transform = "none";
|
|
567
|
+
}
|
|
568
|
+
ancestor = ancestor.parentElement;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
const cloneRect = clone.getBoundingClientRect();
|
|
572
|
+
const desiredLeft = (record.rect.left - sourceRect.left) * scaleX;
|
|
573
|
+
const desiredTop = (record.rect.top - sourceRect.top) * scaleY;
|
|
574
|
+
const currentRect = element.getBoundingClientRect();
|
|
575
|
+
const currentLeft = currentRect.left - cloneRect.left;
|
|
576
|
+
const currentTop = currentRect.top - cloneRect.top;
|
|
577
|
+
const translateX = desiredLeft - currentLeft;
|
|
578
|
+
const translateY = desiredTop - currentTop;
|
|
579
|
+
|
|
580
|
+
if (record.position === "static" || record.position === "relative") {
|
|
581
|
+
element.dataset.exportTextGeometry = "true";
|
|
582
|
+
if (record.singleLine) {
|
|
583
|
+
element.style.whiteSpace = noWrapWhiteSpace(element);
|
|
584
|
+
}
|
|
585
|
+
element.style.left = `${translateX.toFixed(3)}px`;
|
|
586
|
+
element.style.position = "relative";
|
|
587
|
+
element.style.top = `${translateY.toFixed(3)}px`;
|
|
588
|
+
element.style.transform = "none";
|
|
589
|
+
if (Math.abs(record.scaleY - 1) >= 0.01) {
|
|
590
|
+
element.style.fontSize = `${Math.max(1, record.fontSize * record.scaleY)}px`;
|
|
591
|
+
element.style.letterSpacing = `${(record.letterSpacing * record.scaleX).toFixed(3)}px`;
|
|
592
|
+
element.style.lineHeight = record.lineHeight
|
|
593
|
+
? `${(record.lineHeight * record.scaleY).toFixed(3)}px`
|
|
594
|
+
: "normal";
|
|
595
|
+
}
|
|
596
|
+
continue;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
element.dataset.exportTextGeometry = "true";
|
|
600
|
+
if (record.singleLine) {
|
|
601
|
+
element.style.whiteSpace = noWrapWhiteSpace(element);
|
|
602
|
+
}
|
|
603
|
+
element.style.boxSizing = "border-box";
|
|
604
|
+
element.style.bottom = "auto";
|
|
605
|
+
element.style.display = "block";
|
|
606
|
+
element.style.fontSize = `${Math.max(1, record.fontSize * record.scaleY)}px`;
|
|
607
|
+
element.style.height = `${Math.max(1, record.rect.height * scaleY)}px`;
|
|
608
|
+
element.style.left = `${desiredLeft.toFixed(3)}px`;
|
|
609
|
+
element.style.letterSpacing = `${(record.letterSpacing * record.scaleX).toFixed(3)}px`;
|
|
610
|
+
element.style.lineHeight = record.lineHeight
|
|
611
|
+
? `${(record.lineHeight * record.scaleY).toFixed(3)}px`
|
|
612
|
+
: "normal";
|
|
613
|
+
element.style.margin = "0";
|
|
614
|
+
element.style.maxHeight = "none";
|
|
615
|
+
element.style.maxWidth = "none";
|
|
616
|
+
element.style.minHeight = "0";
|
|
617
|
+
element.style.minWidth = "0";
|
|
618
|
+
element.style.position = "absolute";
|
|
619
|
+
element.style.right = "auto";
|
|
620
|
+
element.style.top = `${desiredTop.toFixed(3)}px`;
|
|
621
|
+
element.style.transform = "none";
|
|
622
|
+
element.style.width = `${Math.max(1, record.rect.width * scaleX)}px`;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
function restoreImageGeometry(
|
|
627
|
+
clone: HTMLElement,
|
|
628
|
+
sourceRect: DOMRect,
|
|
629
|
+
records: ImageGeometryRecord[],
|
|
630
|
+
dims: { width: number; height: number },
|
|
631
|
+
) {
|
|
632
|
+
if (!sourceRect.width || !sourceRect.height) return;
|
|
633
|
+
|
|
634
|
+
const cloneRect = clone.getBoundingClientRect();
|
|
635
|
+
const scaleX = dims.width / sourceRect.width;
|
|
636
|
+
const scaleY = dims.height / sourceRect.height;
|
|
637
|
+
for (const record of records) {
|
|
638
|
+
const element = getElementAtPath(
|
|
639
|
+
clone,
|
|
640
|
+
record.path,
|
|
641
|
+
) as HTMLImageElement | null;
|
|
642
|
+
if (!element) continue;
|
|
643
|
+
|
|
644
|
+
const desiredLeft = (record.rect.left - sourceRect.left) * scaleX;
|
|
645
|
+
const desiredTop = (record.rect.top - sourceRect.top) * scaleY;
|
|
646
|
+
const desiredWidth = record.rect.width * scaleX;
|
|
647
|
+
const desiredHeight = record.rect.height * scaleY;
|
|
648
|
+
element.style.boxSizing = "border-box";
|
|
649
|
+
element.style.height = `${Math.max(1, desiredHeight)}px`;
|
|
650
|
+
element.style.maxHeight = "none";
|
|
651
|
+
element.style.maxWidth = "none";
|
|
652
|
+
element.style.width = `${Math.max(1, desiredWidth)}px`;
|
|
653
|
+
|
|
654
|
+
const currentRect = element.getBoundingClientRect();
|
|
655
|
+
const deltaX = desiredLeft - (currentRect.left - cloneRect.left);
|
|
656
|
+
const deltaY = desiredTop - (currentRect.top - cloneRect.top);
|
|
657
|
+
|
|
658
|
+
if (record.position === "absolute" || record.position === "fixed") {
|
|
659
|
+
const style = window.getComputedStyle(element);
|
|
660
|
+
const cssLeft = Number.parseFloat(style.left);
|
|
661
|
+
const cssTop = Number.parseFloat(style.top);
|
|
662
|
+
element.style.bottom = "auto";
|
|
663
|
+
element.style.left = `${(Number.isFinite(cssLeft)
|
|
664
|
+
? cssLeft + deltaX
|
|
665
|
+
: desiredLeft
|
|
666
|
+
).toFixed(3)}px`;
|
|
667
|
+
element.style.position = "absolute";
|
|
668
|
+
element.style.right = "auto";
|
|
669
|
+
element.style.top = `${(Number.isFinite(cssTop)
|
|
670
|
+
? cssTop + deltaY
|
|
671
|
+
: desiredTop
|
|
672
|
+
).toFixed(3)}px`;
|
|
673
|
+
element.style.transform = "none";
|
|
674
|
+
continue;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
element.style.transform = `translate(${deltaX.toFixed(3)}px, ${deltaY.toFixed(3)}px)`;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
export function widenInPlace(element: HTMLElement, width: number) {
|
|
682
|
+
const rect = element.getBoundingClientRect();
|
|
683
|
+
const extra = width - rect.width;
|
|
684
|
+
if (!(extra > 0)) return;
|
|
685
|
+
const style = window.getComputedStyle(element);
|
|
686
|
+
const rightToLeft = style.direction === "rtl";
|
|
687
|
+
const align =
|
|
688
|
+
style.textAlign === "start" || style.textAlign === "justify"
|
|
689
|
+
? rightToLeft
|
|
690
|
+
? "right"
|
|
691
|
+
: "left"
|
|
692
|
+
: style.textAlign === "end"
|
|
693
|
+
? rightToLeft
|
|
694
|
+
? "left"
|
|
695
|
+
: "right"
|
|
696
|
+
: style.textAlign;
|
|
697
|
+
const share =
|
|
698
|
+
align === "center" || align === "-webkit-center"
|
|
699
|
+
? 0.5
|
|
700
|
+
: align === "right"
|
|
701
|
+
? 1
|
|
702
|
+
: 0;
|
|
703
|
+
const marginLeft = Number.parseFloat(style.marginLeft) || 0;
|
|
704
|
+
const marginRight = Number.parseFloat(style.marginRight) || 0;
|
|
705
|
+
element.style.boxSizing = "border-box";
|
|
706
|
+
element.style.maxWidth = "none";
|
|
707
|
+
element.style.width = `${width}px`;
|
|
708
|
+
element.style.marginLeft = `${marginLeft - extra * share}px`;
|
|
709
|
+
element.style.marginRight = `${marginRight - extra * (1 - share)}px`;
|
|
710
|
+
const drift =
|
|
711
|
+
element.getBoundingClientRect().left - (rect.left - extra * share);
|
|
712
|
+
if (Math.abs(drift) > 0.5) {
|
|
713
|
+
element.style.marginLeft = `${marginLeft - extra * share - drift}px`;
|
|
714
|
+
element.style.marginRight = `${marginRight - extra * (1 - share) + drift}px`;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
function normalizeSingleLineText(
|
|
719
|
+
clone: HTMLElement,
|
|
720
|
+
records: TextGeometryRecord[],
|
|
721
|
+
) {
|
|
722
|
+
const cloneRect = clone.getBoundingClientRect();
|
|
723
|
+
for (const record of records) {
|
|
724
|
+
if (!record.singleLine) continue;
|
|
725
|
+
const element = getElementAtPath(clone, record.path);
|
|
726
|
+
if (!element) continue;
|
|
727
|
+
|
|
728
|
+
const rect = element.getBoundingClientRect();
|
|
729
|
+
if (!rect.width || !rect.height) continue;
|
|
730
|
+
|
|
731
|
+
element.dataset.exportSingleLineText = "true";
|
|
732
|
+
element.style.boxSizing = "border-box";
|
|
733
|
+
element.style.whiteSpace = noWrapWhiteSpace(element);
|
|
734
|
+
if (record.heading) {
|
|
735
|
+
widenInPlace(
|
|
736
|
+
element,
|
|
737
|
+
Math.max(rect.width, Math.ceil(cloneRect.right - rect.left)),
|
|
738
|
+
);
|
|
739
|
+
continue;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
const buffer = Math.max(24, rect.width * 0.25);
|
|
743
|
+
const available = Math.max(rect.width, cloneRect.right - rect.left);
|
|
744
|
+
widenInPlace(
|
|
745
|
+
element,
|
|
746
|
+
Math.max(1, Math.ceil(Math.min(rect.width + buffer, available))),
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
const CSS_PX_PER_INCH = 96;
|
|
752
|
+
|
|
753
|
+
export function pptxExportScale(dims: {
|
|
754
|
+
width: number;
|
|
755
|
+
height: number;
|
|
756
|
+
pptxInches: { w: number; h: number };
|
|
757
|
+
}) {
|
|
758
|
+
return Math.min(
|
|
759
|
+
dims.pptxInches.w / (dims.width / CSS_PX_PER_INCH),
|
|
760
|
+
dims.pptxInches.h / (dims.height / CSS_PX_PER_INCH),
|
|
761
|
+
);
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
function normalizeListsForPptx(
|
|
765
|
+
root: HTMLElement,
|
|
766
|
+
dims: { width: number; height: number; pptxInches: { w: number; h: number } },
|
|
767
|
+
) {
|
|
768
|
+
const bulletIndents: number[] = [];
|
|
769
|
+
const scale = pptxExportScale(dims);
|
|
770
|
+
|
|
771
|
+
for (const list of root.querySelectorAll<HTMLElement>("ul,ol")) {
|
|
772
|
+
const listStyle = window.getComputedStyle(list);
|
|
773
|
+
const listStyleType = listStyle.listStyleType || "disc";
|
|
774
|
+
const paddingLeft = Number.parseFloat(listStyle.paddingLeft) || 0;
|
|
775
|
+
if (
|
|
776
|
+
paddingLeft > 0 &&
|
|
777
|
+
listStyle.listStylePosition === "inside" &&
|
|
778
|
+
listStyle.transform === "none"
|
|
779
|
+
) {
|
|
780
|
+
list.style.transform = `translateX(${paddingLeft}px)`;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
for (const item of list.children) {
|
|
784
|
+
if (!(item instanceof HTMLElement) || item.tagName !== "LI") continue;
|
|
785
|
+
const itemStyle = window.getComputedStyle(item);
|
|
786
|
+
const currentMarginLeft = Number.parseFloat(itemStyle.marginLeft) || 0;
|
|
787
|
+
const markerStyle = window.getComputedStyle(item, "::marker");
|
|
788
|
+
const markerSize = Number.parseFloat(markerStyle.fontSize) || 20;
|
|
789
|
+
const markerGap = Math.max(24, markerSize * 1.2);
|
|
790
|
+
if (currentMarginLeft < markerGap) {
|
|
791
|
+
item.style.marginLeft = `${markerGap}px`;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
if (listStyleType === "none") continue;
|
|
796
|
+
const firstItem = Array.from(list.children).find(
|
|
797
|
+
(item): item is HTMLElement =>
|
|
798
|
+
item instanceof HTMLElement && item.tagName === "LI",
|
|
799
|
+
);
|
|
800
|
+
if (!firstItem) continue;
|
|
801
|
+
|
|
802
|
+
const listRect = list.getBoundingClientRect();
|
|
803
|
+
const itemRect = firstItem.getBoundingClientRect();
|
|
804
|
+
if (!listRect.width || !itemRect.width) continue;
|
|
805
|
+
|
|
806
|
+
const visualIndentPx = itemRect.left - listRect.left;
|
|
807
|
+
bulletIndents.push(
|
|
808
|
+
Math.max(0, (visualIndentPx - paddingLeft) * 0.75 * scale),
|
|
809
|
+
);
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
return bulletIndents;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
function ensureBulletMarkerSpacing(root: HTMLElement) {
|
|
816
|
+
for (const marker of root.querySelectorAll<HTMLElement>(
|
|
817
|
+
'p[data-pptx-paragraph] > span[aria-hidden="true"]:first-child',
|
|
818
|
+
)) {
|
|
819
|
+
const next = marker.nextSibling;
|
|
820
|
+
if (
|
|
821
|
+
next?.nodeType === Node.TEXT_NODE &&
|
|
822
|
+
/^\s/.test(next.textContent ?? "")
|
|
823
|
+
) {
|
|
824
|
+
continue;
|
|
825
|
+
}
|
|
826
|
+
marker.after(document.createTextNode(" "));
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
const EMU_PER_POINT = 12_700;
|
|
831
|
+
|
|
832
|
+
function patchBulletIndentsInXml(xml: string, indentPoints: number[]) {
|
|
833
|
+
let result = "";
|
|
834
|
+
let cursor = 0;
|
|
835
|
+
let listIndex = 0;
|
|
836
|
+
|
|
837
|
+
while (true) {
|
|
838
|
+
const shapeStart = xml.indexOf("<p:sp>", cursor);
|
|
839
|
+
if (shapeStart < 0) {
|
|
840
|
+
result += xml.slice(cursor);
|
|
841
|
+
break;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
const shapeEnd = xml.indexOf("</p:sp>", shapeStart);
|
|
845
|
+
if (shapeEnd < 0) {
|
|
846
|
+
result += xml.slice(cursor);
|
|
847
|
+
break;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
result += xml.slice(cursor, shapeStart);
|
|
851
|
+
let shapeXml = xml.slice(shapeStart, shapeEnd + "</p:sp>".length);
|
|
852
|
+
if (
|
|
853
|
+
shapeXml.includes("<a:buChar") &&
|
|
854
|
+
indentPoints[listIndex] !== undefined
|
|
855
|
+
) {
|
|
856
|
+
const indent = Math.max(
|
|
857
|
+
0,
|
|
858
|
+
Math.round(indentPoints[listIndex] * EMU_PER_POINT),
|
|
859
|
+
);
|
|
860
|
+
let patchedShape = "";
|
|
861
|
+
let shapeCursor = 0;
|
|
862
|
+
|
|
863
|
+
while (true) {
|
|
864
|
+
const bulletStart = shapeXml.indexOf("<a:buChar", shapeCursor);
|
|
865
|
+
if (bulletStart < 0) {
|
|
866
|
+
patchedShape += shapeXml.slice(shapeCursor);
|
|
867
|
+
break;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
const paragraphStart = shapeXml.lastIndexOf("<a:pPr", bulletStart);
|
|
871
|
+
const paragraphEnd = shapeXml.indexOf("</a:pPr>", bulletStart);
|
|
872
|
+
if (paragraphStart < shapeCursor || paragraphEnd < 0) {
|
|
873
|
+
patchedShape += shapeXml.slice(shapeCursor);
|
|
874
|
+
break;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
patchedShape += shapeXml.slice(shapeCursor, paragraphStart);
|
|
878
|
+
const paragraphXml = shapeXml.slice(
|
|
879
|
+
paragraphStart,
|
|
880
|
+
paragraphEnd + "</a:pPr>".length,
|
|
881
|
+
);
|
|
882
|
+
const openingEnd = paragraphXml.indexOf(">");
|
|
883
|
+
const openingTag = paragraphXml
|
|
884
|
+
.slice(0, openingEnd)
|
|
885
|
+
.replace(/\s(?:marL|indent)="[^"]*"/g, "");
|
|
886
|
+
patchedShape +=
|
|
887
|
+
`${openingTag} marL="${indent}" indent="-${indent}"` +
|
|
888
|
+
paragraphXml.slice(openingEnd);
|
|
889
|
+
shapeCursor = paragraphEnd + "</a:pPr>".length;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
shapeXml = patchedShape;
|
|
893
|
+
listIndex += 1;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
result += shapeXml;
|
|
897
|
+
cursor = shapeEnd + "</p:sp>".length;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
return result;
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
export async function patchBulletIndentsInPptxBlob(
|
|
904
|
+
blob: Blob,
|
|
905
|
+
slideBulletIndents: number[][],
|
|
906
|
+
) {
|
|
907
|
+
if (!slideBulletIndents.some((indents) => indents.length > 0)) return blob;
|
|
908
|
+
|
|
909
|
+
const { default: JSZip } = await importExportModule(() => import("jszip"));
|
|
910
|
+
const zip = await JSZip.loadAsync(blob);
|
|
911
|
+
|
|
912
|
+
for (let i = 0; i < slideBulletIndents.length; i++) {
|
|
913
|
+
const indents = slideBulletIndents[i];
|
|
914
|
+
if (!indents.length) continue;
|
|
915
|
+
|
|
916
|
+
const slideFile = zip.file(`ppt/slides/slide${i + 1}.xml`);
|
|
917
|
+
if (!slideFile) continue;
|
|
918
|
+
|
|
919
|
+
const slideXml = await slideFile.async("string");
|
|
920
|
+
zip.file(
|
|
921
|
+
`ppt/slides/slide${i + 1}.xml`,
|
|
922
|
+
patchBulletIndentsInXml(slideXml, indents),
|
|
923
|
+
);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
return zip.generateAsync({
|
|
927
|
+
type: "blob",
|
|
928
|
+
compression: "DEFLATE",
|
|
929
|
+
compressionOptions: { level: 6 },
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
const FONT_RESOLVE_TIMEOUT_MS = 4_000;
|
|
934
|
+
|
|
935
|
+
interface ResolvedExportFont {
|
|
936
|
+
name: string;
|
|
937
|
+
urls: string[];
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
export function usedFontFamilies(roots: HTMLElement[]): string[] {
|
|
941
|
+
const weight = new Map<string, number>();
|
|
942
|
+
for (const root of roots) {
|
|
943
|
+
for (const node of [root, ...Array.from(root.querySelectorAll("*"))]) {
|
|
944
|
+
if (!(node instanceof HTMLElement)) continue;
|
|
945
|
+
if (NON_RENDERING_TAGS.has(node.tagName)) continue;
|
|
946
|
+
const own = Array.from(node.childNodes)
|
|
947
|
+
.filter((child) => child.nodeType === Node.TEXT_NODE)
|
|
948
|
+
.map((child) => child.nodeValue ?? "")
|
|
949
|
+
.join("")
|
|
950
|
+
.trim();
|
|
951
|
+
if (!own) continue;
|
|
952
|
+
const primary = window
|
|
953
|
+
.getComputedStyle(node)
|
|
954
|
+
.fontFamily.split(",")[0]
|
|
955
|
+
.trim()
|
|
956
|
+
.replace(/^["']|["']$/g, "");
|
|
957
|
+
if (
|
|
958
|
+
!primary ||
|
|
959
|
+
primary.startsWith("-") ||
|
|
960
|
+
GENERIC_FAMILIES.has(primary)
|
|
961
|
+
) {
|
|
962
|
+
continue;
|
|
963
|
+
}
|
|
964
|
+
weight.set(primary, (weight.get(primary) ?? 0) + own.length);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
return Array.from(weight.entries())
|
|
968
|
+
.sort((a, b) => b[1] - a[1])
|
|
969
|
+
.map(([family]) => family);
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
const NON_RENDERING_TAGS = new Set(["SCRIPT", "STYLE", "TEMPLATE", "TITLE"]);
|
|
973
|
+
|
|
974
|
+
const GENERIC_FAMILIES = new Set([
|
|
975
|
+
"cursive",
|
|
976
|
+
"fantasy",
|
|
977
|
+
"monospace",
|
|
978
|
+
"sans-serif",
|
|
979
|
+
"serif",
|
|
980
|
+
"system-ui",
|
|
981
|
+
"ui-monospace",
|
|
982
|
+
"ui-rounded",
|
|
983
|
+
"ui-sans-serif",
|
|
984
|
+
"ui-serif",
|
|
985
|
+
]);
|
|
986
|
+
|
|
987
|
+
function romanFaceUrls(cssText: string, family: string): string[] {
|
|
988
|
+
const urls: string[] = [];
|
|
989
|
+
for (const block of cssText.split("@font-face")) {
|
|
990
|
+
if (!block.includes("font-family")) continue;
|
|
991
|
+
const name = block
|
|
992
|
+
.match(/font-family:\s*(?:"([^"]+)"|'([^']+)'|([^;]+))/)
|
|
993
|
+
?.slice(1)
|
|
994
|
+
.find(Boolean)
|
|
995
|
+
?.trim();
|
|
996
|
+
if (name !== family) continue;
|
|
997
|
+
if (/font-style:\s*italic/.test(block)) continue;
|
|
998
|
+
const url = block.match(/url\(\s*["']?([^"')]+)["']?\s*\)/)?.[1];
|
|
999
|
+
if (url) urls.push(url);
|
|
1000
|
+
}
|
|
1001
|
+
return urls;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
function localFaceUrls(family: string): string[] {
|
|
1005
|
+
const urls: string[] = [];
|
|
1006
|
+
for (const sheet of Array.from(document.styleSheets)) {
|
|
1007
|
+
let rules: CSSRuleList | undefined;
|
|
1008
|
+
try {
|
|
1009
|
+
rules = sheet.cssRules ?? undefined;
|
|
1010
|
+
} catch {
|
|
1011
|
+
// coercion-ok: a cross-origin sheet is unreadable by design. The Google
|
|
1012
|
+
// Fonts fetch below is what covers those families, so this is a skip with
|
|
1013
|
+
// a defined successor, not a swallowed failure.
|
|
1014
|
+
continue;
|
|
1015
|
+
}
|
|
1016
|
+
for (const rule of Array.from(rules ?? [])) {
|
|
1017
|
+
if (!(rule instanceof CSSFontFaceRule)) continue;
|
|
1018
|
+
const name = rule.style
|
|
1019
|
+
.getPropertyValue("font-family")
|
|
1020
|
+
.trim()
|
|
1021
|
+
.replace(/^["']|["']$/g, "");
|
|
1022
|
+
if (name !== family) continue;
|
|
1023
|
+
if (rule.style.getPropertyValue("font-style").trim() === "italic")
|
|
1024
|
+
continue;
|
|
1025
|
+
const url = rule.style
|
|
1026
|
+
.getPropertyValue("src")
|
|
1027
|
+
.match(/url\(\s*["']?([^"')]+)["']?\s*\)/)?.[1];
|
|
1028
|
+
if (url) urls.push(url);
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
return urls;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
function isLoadedWebFont(family: string): boolean {
|
|
1035
|
+
let found = false;
|
|
1036
|
+
document.fonts?.forEach?.((face) => {
|
|
1037
|
+
if (face.family.replace(/^["']|["']$/g, "") === family) found = true;
|
|
1038
|
+
});
|
|
1039
|
+
return found;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
async function resolveExportFonts(
|
|
1043
|
+
roots: HTMLElement[],
|
|
1044
|
+
): Promise<ResolvedExportFont[]> {
|
|
1045
|
+
const pending = usedFontFamilies(roots).map(
|
|
1046
|
+
async (family): Promise<ResolvedExportFont | undefined> => {
|
|
1047
|
+
const local = localFaceUrls(family);
|
|
1048
|
+
if (local.length) return { name: family, urls: local };
|
|
1049
|
+
if (!isLoadedWebFont(family)) return undefined;
|
|
1050
|
+
try {
|
|
1051
|
+
const href = `https://fonts.googleapis.com/css2?family=${encodeURIComponent(
|
|
1052
|
+
family,
|
|
1053
|
+
).replace(/%20/g, "+")}:wght@400;500;600;700&display=swap`;
|
|
1054
|
+
const response = await fetch(href, {
|
|
1055
|
+
mode: "cors",
|
|
1056
|
+
signal: AbortSignal.timeout(FONT_RESOLVE_TIMEOUT_MS),
|
|
1057
|
+
});
|
|
1058
|
+
if (!response.ok) return undefined;
|
|
1059
|
+
const urls = romanFaceUrls(await response.text(), family);
|
|
1060
|
+
if (!urls.length) return undefined;
|
|
1061
|
+
return { name: family, urls };
|
|
1062
|
+
} catch (err) {
|
|
1063
|
+
console.warn(
|
|
1064
|
+
`[export-pptx] could not resolve "${family}" for embedding; the receiving app will substitute it`,
|
|
1065
|
+
err,
|
|
1066
|
+
);
|
|
1067
|
+
return undefined;
|
|
1068
|
+
}
|
|
1069
|
+
},
|
|
1070
|
+
);
|
|
1071
|
+
return (await Promise.all(pending)).filter(
|
|
1072
|
+
(font): font is ResolvedExportFont => font !== undefined,
|
|
1073
|
+
);
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
export async function pinTextBoxesForImport(
|
|
1077
|
+
blob: Blob,
|
|
1078
|
+
themeFont?: string,
|
|
1079
|
+
): Promise<Blob> {
|
|
1080
|
+
const { default: JSZip } = await importExportModule(() => import("jszip"));
|
|
1081
|
+
const zip = await JSZip.loadAsync(blob);
|
|
1082
|
+
|
|
1083
|
+
const slideNames = Object.keys(zip.files).filter((name) =>
|
|
1084
|
+
/^ppt\/slides\/slide\d+\.xml$/.test(name),
|
|
1085
|
+
);
|
|
1086
|
+
for (const name of slideNames) {
|
|
1087
|
+
const xml = await zip.file(name)!.async("string");
|
|
1088
|
+
zip.file(name, pinTextBoxesInXml(xml));
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
if (themeFont) {
|
|
1092
|
+
for (const name of Object.keys(zip.files).filter((file) =>
|
|
1093
|
+
/^ppt\/theme\/theme\d+\.xml$/.test(file),
|
|
1094
|
+
)) {
|
|
1095
|
+
const xml = await zip.file(name)!.async("string");
|
|
1096
|
+
zip.file(name, retypeThemeFonts(xml, themeFont));
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
return zip.generateAsync({
|
|
1101
|
+
type: "blob",
|
|
1102
|
+
compression: "DEFLATE",
|
|
1103
|
+
compressionOptions: { level: 6 },
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
export function retypeThemeFonts(xml: string, family: string): string {
|
|
1108
|
+
const escaped = family.replace(/&/g, "&").replace(/"/g, """);
|
|
1109
|
+
return xml.replace(
|
|
1110
|
+
/(<a:(?:majorFont|minorFont)>\s*<a:latin typeface=")[^"]*"/g,
|
|
1111
|
+
`$1${escaped}"`,
|
|
1112
|
+
);
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
export function pinTextBoxesInXml(xml: string): string {
|
|
1116
|
+
return xml
|
|
1117
|
+
.replace(/(<a:bodyPr\b[^>]*?)\swrap="none"/g, '$1 wrap="square"')
|
|
1118
|
+
.replace(/<a:spAutoFit\s*\/>/g, "<a:noAutofit/>");
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
const SVG_PLACEMENT_PROPERTIES = [
|
|
1122
|
+
"bottom",
|
|
1123
|
+
"left",
|
|
1124
|
+
"position",
|
|
1125
|
+
"right",
|
|
1126
|
+
"top",
|
|
1127
|
+
"transform",
|
|
1128
|
+
];
|
|
1129
|
+
|
|
1130
|
+
function svgDataUrl(svg: SVGSVGElement) {
|
|
1131
|
+
const copy = svg.cloneNode(true) as SVGSVGElement;
|
|
1132
|
+
if (!copy.getAttribute("xmlns")) {
|
|
1133
|
+
copy.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
|
1134
|
+
}
|
|
1135
|
+
for (const property of SVG_PLACEMENT_PROPERTIES) {
|
|
1136
|
+
copy.style.removeProperty(property);
|
|
1137
|
+
}
|
|
1138
|
+
const serialized = new XMLSerializer().serializeToString(copy);
|
|
1139
|
+
return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(serialized)}`;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
export function blankRasterResult(
|
|
1143
|
+
data: Uint8ClampedArray | undefined,
|
|
1144
|
+
): boolean | undefined {
|
|
1145
|
+
if (!data || data.length === 0) return undefined;
|
|
1146
|
+
for (let i = 3; i < data.length; i += 4) {
|
|
1147
|
+
if (data[i] !== 0) return false;
|
|
1148
|
+
}
|
|
1149
|
+
return true;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
async function rasterizeSvgElement(
|
|
1153
|
+
svg: SVGSVGElement,
|
|
1154
|
+
width: number,
|
|
1155
|
+
height: number,
|
|
1156
|
+
): Promise<{ dataUrl: string; blank: boolean | undefined }> {
|
|
1157
|
+
const fallback = svgDataUrl(svg);
|
|
1158
|
+
const canvas = document.createElement("canvas");
|
|
1159
|
+
const ctx = canvas.getContext("2d");
|
|
1160
|
+
if (!ctx || typeof Image === "undefined") {
|
|
1161
|
+
return { dataUrl: fallback, blank: undefined };
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
const scale = Math.max(2, window.devicePixelRatio || 1);
|
|
1165
|
+
canvas.width = Math.max(1, Math.ceil(width * scale));
|
|
1166
|
+
canvas.height = Math.max(1, Math.ceil(height * scale));
|
|
1167
|
+
|
|
1168
|
+
const image = new Image();
|
|
1169
|
+
const loaded = new Promise<void>((resolve, reject) => {
|
|
1170
|
+
image.onload = () => resolve();
|
|
1171
|
+
image.onerror = () => reject(new Error("Could not rasterize SVG"));
|
|
1172
|
+
});
|
|
1173
|
+
image.src = fallback;
|
|
1174
|
+
|
|
1175
|
+
try {
|
|
1176
|
+
await loaded;
|
|
1177
|
+
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
1178
|
+
let pixels: Uint8ClampedArray | undefined;
|
|
1179
|
+
try {
|
|
1180
|
+
pixels = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
|
|
1181
|
+
} catch {
|
|
1182
|
+
console.warn(
|
|
1183
|
+
"[export-pptx] rasterized shape could not be inspected; it may be missing from the export",
|
|
1184
|
+
);
|
|
1185
|
+
pixels = undefined;
|
|
1186
|
+
}
|
|
1187
|
+
return {
|
|
1188
|
+
dataUrl: canvas.toDataURL("image/png"),
|
|
1189
|
+
blank: blankRasterResult(pixels),
|
|
1190
|
+
};
|
|
1191
|
+
} catch {
|
|
1192
|
+
return { dataUrl: fallback, blank: undefined };
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
1197
|
+
|
|
1198
|
+
function clipPathOutline(
|
|
1199
|
+
clipPath: string,
|
|
1200
|
+
width: number,
|
|
1201
|
+
height: number,
|
|
1202
|
+
): string | undefined {
|
|
1203
|
+
const path = clipPath.match(/^path\(\s*["']?([^"')]*)["']?\s*\)$/i)?.[1];
|
|
1204
|
+
if (path) return path;
|
|
1205
|
+
const polygon = clipPath.match(/^polygon\(([^)]*)\)$/i)?.[1];
|
|
1206
|
+
if (!polygon) return undefined;
|
|
1207
|
+
const points = polygon.split(",").map((pair) => {
|
|
1208
|
+
const [rawX, rawY] = pair.trim().split(/\s+/);
|
|
1209
|
+
const x = clipPathPixels(rawX, width);
|
|
1210
|
+
const y = clipPathPixels(rawY, height);
|
|
1211
|
+
return x == null || y == null ? null : `${x} ${y}`;
|
|
1212
|
+
});
|
|
1213
|
+
if (points.length < 3 || points.some((point) => point == null)) {
|
|
1214
|
+
return undefined;
|
|
1215
|
+
}
|
|
1216
|
+
return `M${points.join(" L")} Z`;
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
let gradientId = 0;
|
|
1220
|
+
|
|
1221
|
+
const GRADIENT_SIDE_ANGLES: Record<string, number> = {
|
|
1222
|
+
"to top": 0,
|
|
1223
|
+
"to right": 90,
|
|
1224
|
+
"to bottom": 180,
|
|
1225
|
+
"to left": 270,
|
|
1226
|
+
};
|
|
1227
|
+
|
|
1228
|
+
function splitTopLevel(list: string): string[] | undefined {
|
|
1229
|
+
const parts: string[] = [];
|
|
1230
|
+
let depth = 0;
|
|
1231
|
+
let current = "";
|
|
1232
|
+
for (const character of list) {
|
|
1233
|
+
if (character === "(") depth++;
|
|
1234
|
+
else if (character === ")") depth--;
|
|
1235
|
+
if (depth < 0) return undefined;
|
|
1236
|
+
if (character === "," && depth === 0) {
|
|
1237
|
+
parts.push(current.trim());
|
|
1238
|
+
current = "";
|
|
1239
|
+
continue;
|
|
1240
|
+
}
|
|
1241
|
+
current += character;
|
|
1242
|
+
}
|
|
1243
|
+
if (depth !== 0) return undefined;
|
|
1244
|
+
parts.push(current.trim());
|
|
1245
|
+
return parts;
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
const round3 = (value: number) => `${Math.round(value * 1000) / 1000}`;
|
|
1249
|
+
|
|
1250
|
+
function stopPaint(color: string): { color: string; opacity?: string } {
|
|
1251
|
+
const rgba = color.match(
|
|
1252
|
+
/^rgba\(\s*(\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\s*\)$/i,
|
|
1253
|
+
);
|
|
1254
|
+
if (rgba) {
|
|
1255
|
+
return {
|
|
1256
|
+
color: `#${rgba
|
|
1257
|
+
.slice(1, 4)
|
|
1258
|
+
.map((channel) => Number(channel).toString(16).padStart(2, "0"))
|
|
1259
|
+
.join("")}`,
|
|
1260
|
+
opacity: round3(Number(rgba[4])),
|
|
1261
|
+
};
|
|
1262
|
+
}
|
|
1263
|
+
if (color.toLowerCase() === "transparent") {
|
|
1264
|
+
// guard:allow-raw-color — CSS `transparent` as Chrome computes it, not a theme color
|
|
1265
|
+
return stopPaint("rgba(0, 0, 0, 0)");
|
|
1266
|
+
}
|
|
1267
|
+
const hex8 = color.match(/^#([\da-f]{6})([\da-f]{2})$/i);
|
|
1268
|
+
if (!hex8) return { color };
|
|
1269
|
+
return {
|
|
1270
|
+
color: `#${hex8[1]}`,
|
|
1271
|
+
opacity: round3(Number.parseInt(hex8[2], 16) / 255),
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
const STOP_POSITION = /^(.*\S)\s+(-?[\d.]+)([a-z%]*)$/i;
|
|
1276
|
+
const STOP_COLOR = /^(?:#[\da-f]{3,8}|rgba?\([\d\s.,%/-]+\)|[a-z]+)$/i;
|
|
1277
|
+
|
|
1278
|
+
const isClearStop = (paint: { opacity?: string }) =>
|
|
1279
|
+
paint.opacity !== undefined && Number(paint.opacity) === 0;
|
|
1280
|
+
|
|
1281
|
+
/** Undefined when a stop has a length position or a colour SVG would paint black. */
|
|
1282
|
+
function appendGradientStops(
|
|
1283
|
+
gradient: SVGElement,
|
|
1284
|
+
stopParts: string[],
|
|
1285
|
+
): SVGElement | undefined {
|
|
1286
|
+
const stops: Array<{
|
|
1287
|
+
position?: string;
|
|
1288
|
+
paint: ReturnType<typeof stopPaint>;
|
|
1289
|
+
}> = [];
|
|
1290
|
+
for (const part of stopParts) {
|
|
1291
|
+
const located = part.match(STOP_POSITION);
|
|
1292
|
+
if (located && located[3] !== "%") return undefined;
|
|
1293
|
+
const raw = (located ? located[1] : part).trim();
|
|
1294
|
+
if (!STOP_COLOR.test(raw)) return undefined;
|
|
1295
|
+
stops.push({ position: located?.[2], paint: stopPaint(raw) });
|
|
1296
|
+
}
|
|
1297
|
+
// SVG interpolates without premultiplying, so a clear stop keeps its
|
|
1298
|
+
// neighbour's colour or the fade runs through black.
|
|
1299
|
+
stops.forEach(({ paint }, index) => {
|
|
1300
|
+
if (!isClearStop(paint)) return;
|
|
1301
|
+
const neighbour = [
|
|
1302
|
+
...stops.slice(0, index).reverse(),
|
|
1303
|
+
...stops.slice(index + 1),
|
|
1304
|
+
].find((other) => !isClearStop(other.paint));
|
|
1305
|
+
if (neighbour) paint.color = neighbour.paint.color;
|
|
1306
|
+
});
|
|
1307
|
+
stops.forEach(({ position, paint }, index) => {
|
|
1308
|
+
const stop = document.createElementNS(SVG_NAMESPACE, "stop");
|
|
1309
|
+
stop.setAttribute(
|
|
1310
|
+
"offset",
|
|
1311
|
+
position != null
|
|
1312
|
+
? `${position}%`
|
|
1313
|
+
: `${(index / (stops.length - 1)) * 100}%`,
|
|
1314
|
+
);
|
|
1315
|
+
stop.setAttribute("stop-color", paint.color);
|
|
1316
|
+
if (paint.opacity) stop.setAttribute("stop-opacity", paint.opacity);
|
|
1317
|
+
gradient.appendChild(stop);
|
|
1318
|
+
});
|
|
1319
|
+
return gradient;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
export function gradientPaint(
|
|
1323
|
+
backgroundImage: string,
|
|
1324
|
+
width: number,
|
|
1325
|
+
height: number,
|
|
1326
|
+
id: string,
|
|
1327
|
+
): SVGElement | undefined {
|
|
1328
|
+
const declaration = backgroundImage
|
|
1329
|
+
.trim()
|
|
1330
|
+
.match(/^(linear|radial)-gradient\(([\s\S]*)\)$/i);
|
|
1331
|
+
if (!declaration) return undefined;
|
|
1332
|
+
const parts = splitTopLevel(declaration[2]);
|
|
1333
|
+
if (!parts || parts.length < 2) return undefined;
|
|
1334
|
+
const head = parts[0].toLowerCase();
|
|
1335
|
+
|
|
1336
|
+
if (declaration[1].toLowerCase() === "radial") {
|
|
1337
|
+
const focus = head.match(
|
|
1338
|
+
/^(?:circle|ellipse)?\s*at\s+(-?[\d.]+)%\s+(-?[\d.]+)%$/,
|
|
1339
|
+
);
|
|
1340
|
+
// A bare colour list is CSS's default: an ellipse at the centre.
|
|
1341
|
+
const headless = /^(?:#|[a-z]+\(|transparent\b)/.test(head);
|
|
1342
|
+
if (!focus && !headless && head !== "circle" && head !== "ellipse") {
|
|
1343
|
+
return undefined;
|
|
1344
|
+
}
|
|
1345
|
+
const stopParts = headless ? parts : parts.slice(1);
|
|
1346
|
+
if (stopParts.length < 2) return undefined;
|
|
1347
|
+
const cx = focus ? (Number.parseFloat(focus[1]) / 100) * width : width / 2;
|
|
1348
|
+
const cy = focus
|
|
1349
|
+
? (Number.parseFloat(focus[2]) / 100) * height
|
|
1350
|
+
: height / 2;
|
|
1351
|
+
const gradient = document.createElementNS(SVG_NAMESPACE, "radialGradient");
|
|
1352
|
+
gradient.setAttribute("id", id);
|
|
1353
|
+
gradient.setAttribute("gradientUnits", "userSpaceOnUse");
|
|
1354
|
+
if (head.startsWith("circle")) {
|
|
1355
|
+
gradient.setAttribute("cx", round3(cx));
|
|
1356
|
+
gradient.setAttribute("cy", round3(cy));
|
|
1357
|
+
gradient.setAttribute(
|
|
1358
|
+
"r",
|
|
1359
|
+
round3(
|
|
1360
|
+
Math.max(
|
|
1361
|
+
Math.hypot(cx, cy),
|
|
1362
|
+
Math.hypot(width - cx, cy),
|
|
1363
|
+
Math.hypot(cx, height - cy),
|
|
1364
|
+
Math.hypot(width - cx, height - cy),
|
|
1365
|
+
),
|
|
1366
|
+
),
|
|
1367
|
+
);
|
|
1368
|
+
} else {
|
|
1369
|
+
// Farthest-corner ellipse: the farthest-side ratio, scaled to reach the corner.
|
|
1370
|
+
gradient.setAttribute("cx", "0");
|
|
1371
|
+
gradient.setAttribute("cy", "0");
|
|
1372
|
+
gradient.setAttribute("r", "1");
|
|
1373
|
+
gradient.setAttribute(
|
|
1374
|
+
"gradientTransform",
|
|
1375
|
+
`translate(${round3(cx)} ${round3(cy)}) scale(${round3(Math.SQRT2 * Math.max(cx, width - cx))} ${round3(Math.SQRT2 * Math.max(cy, height - cy))})`,
|
|
1376
|
+
);
|
|
1377
|
+
}
|
|
1378
|
+
return appendGradientStops(gradient, stopParts);
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
const declaredAngle = head.match(/^(-?[\d.]+)deg$/)?.[1];
|
|
1382
|
+
const sideAngle = GRADIENT_SIDE_ANGLES[head];
|
|
1383
|
+
const hasDirection = declaredAngle != null || sideAngle !== undefined;
|
|
1384
|
+
if (
|
|
1385
|
+
!hasDirection &&
|
|
1386
|
+
/^(to\b|calc\(|-?[\d.]+(deg|rad|grad|turn))/.test(head)
|
|
1387
|
+
) {
|
|
1388
|
+
return undefined;
|
|
1389
|
+
}
|
|
1390
|
+
const angle =
|
|
1391
|
+
declaredAngle != null
|
|
1392
|
+
? Number.parseFloat(declaredAngle)
|
|
1393
|
+
: (sideAngle ?? 180);
|
|
1394
|
+
const stopParts = hasDirection ? parts.slice(1) : parts;
|
|
1395
|
+
if (stopParts.length < 2) return undefined;
|
|
1396
|
+
|
|
1397
|
+
const radians = ((angle - 90) * Math.PI) / 180;
|
|
1398
|
+
const dx = Math.cos(radians);
|
|
1399
|
+
const dy = Math.sin(radians);
|
|
1400
|
+
const lineLength = Math.abs(width * dx) + Math.abs(height * dy);
|
|
1401
|
+
const gradient = document.createElementNS(SVG_NAMESPACE, "linearGradient");
|
|
1402
|
+
gradient.setAttribute("id", id);
|
|
1403
|
+
gradient.setAttribute("gradientUnits", "userSpaceOnUse");
|
|
1404
|
+
gradient.setAttribute("x1", round3(width / 2 - (dx * lineLength) / 2));
|
|
1405
|
+
gradient.setAttribute("y1", round3(height / 2 - (dy * lineLength) / 2));
|
|
1406
|
+
gradient.setAttribute("x2", round3(width / 2 + (dx * lineLength) / 2));
|
|
1407
|
+
gradient.setAttribute("y2", round3(height / 2 + (dy * lineLength) / 2));
|
|
1408
|
+
return appendGradientStops(gradient, stopParts);
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
function clipPathPixels(raw: string | undefined, side: number) {
|
|
1412
|
+
if (!raw) return undefined;
|
|
1413
|
+
const value = Number.parseFloat(raw);
|
|
1414
|
+
if (!Number.isFinite(value)) return undefined;
|
|
1415
|
+
return raw.endsWith("%") ? (value / 100) * side : value;
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
export function materializeClipPathShapes(root: HTMLElement) {
|
|
1419
|
+
for (const element of Array.from(root.querySelectorAll<HTMLElement>("*"))) {
|
|
1420
|
+
const style = window.getComputedStyle(element);
|
|
1421
|
+
const width = computedLength(style.width, 0);
|
|
1422
|
+
const height = computedLength(style.height, 0);
|
|
1423
|
+
if (!(width > 0) || !(height > 0)) continue;
|
|
1424
|
+
const outline = clipPathOutline(style.clipPath, width, height);
|
|
1425
|
+
if (!outline) continue;
|
|
1426
|
+
const overlay = element.firstElementChild;
|
|
1427
|
+
if (
|
|
1428
|
+
element.childElementCount > (overlay instanceof SVGSVGElement ? 1 : 0)
|
|
1429
|
+
) {
|
|
1430
|
+
continue;
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
const svg = document.createElementNS(SVG_NAMESPACE, "svg");
|
|
1434
|
+
svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
|
|
1435
|
+
svg.setAttribute("preserveAspectRatio", "none");
|
|
1436
|
+
svg.style.cssText = element.style.cssText;
|
|
1437
|
+
Object.assign(svg.style, {
|
|
1438
|
+
background: "none",
|
|
1439
|
+
border: "0",
|
|
1440
|
+
clipPath: "none",
|
|
1441
|
+
height: `${height}px`,
|
|
1442
|
+
overflow: "visible",
|
|
1443
|
+
width: `${width}px`,
|
|
1444
|
+
});
|
|
1445
|
+
|
|
1446
|
+
const path = document.createElementNS(SVG_NAMESPACE, "path");
|
|
1447
|
+
path.setAttribute("d", outline);
|
|
1448
|
+
const gradient = gradientPaint(
|
|
1449
|
+
style.backgroundImage,
|
|
1450
|
+
width,
|
|
1451
|
+
height,
|
|
1452
|
+
`fmd-grad-${gradientId++}`,
|
|
1453
|
+
);
|
|
1454
|
+
if (gradient) {
|
|
1455
|
+
const defs = document.createElementNS(SVG_NAMESPACE, "defs");
|
|
1456
|
+
defs.appendChild(gradient);
|
|
1457
|
+
svg.appendChild(defs);
|
|
1458
|
+
path.setAttribute("fill", `url(#${gradient.id})`);
|
|
1459
|
+
} else {
|
|
1460
|
+
path.setAttribute("fill", style.backgroundColor);
|
|
1461
|
+
}
|
|
1462
|
+
const strokeWidth = computedLength(style.borderTopWidth, 0);
|
|
1463
|
+
if (strokeWidth > 0) {
|
|
1464
|
+
path.setAttribute("stroke", style.borderTopColor);
|
|
1465
|
+
path.setAttribute("stroke-width", `${strokeWidth}`);
|
|
1466
|
+
}
|
|
1467
|
+
svg.appendChild(path);
|
|
1468
|
+
if (overlay instanceof SVGSVGElement) {
|
|
1469
|
+
svg.append(...Array.from(overlay.childNodes));
|
|
1470
|
+
}
|
|
1471
|
+
element.replaceWith(svg);
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
const allElements = (root: HTMLElement) => [
|
|
1476
|
+
root,
|
|
1477
|
+
...Array.from(root.querySelectorAll<HTMLElement>("*")),
|
|
1478
|
+
];
|
|
1479
|
+
|
|
1480
|
+
// dom-to-pptx only paints linear gradients and drops a radial one without a
|
|
1481
|
+
// trace, which leaves a radial slide background white under light text.
|
|
1482
|
+
export function materializeRadialGradients(root: HTMLElement) {
|
|
1483
|
+
for (const element of allElements(root)) {
|
|
1484
|
+
const style = window.getComputedStyle(element);
|
|
1485
|
+
if (!/^radial-gradient\(/i.test(style.backgroundImage)) continue;
|
|
1486
|
+
// Clipped to text, solidifyGradientText takes the first stop instead.
|
|
1487
|
+
if ((style.webkitBackgroundClip || style.backgroundClip) === "text") {
|
|
1488
|
+
continue;
|
|
1489
|
+
}
|
|
1490
|
+
const width = element.offsetWidth || computedLength(style.width, 0);
|
|
1491
|
+
const height = element.offsetHeight || computedLength(style.height, 0);
|
|
1492
|
+
// One bitmap cannot tile a dot grid (`background-size: 24px 24px`).
|
|
1493
|
+
const tiled = !["", "initial", "auto", "cover", "100% 100%"].includes(
|
|
1494
|
+
style.backgroundSize,
|
|
1495
|
+
);
|
|
1496
|
+
const gradient =
|
|
1497
|
+
width > 0 && height > 0 && !tiled
|
|
1498
|
+
? gradientPaint(
|
|
1499
|
+
style.backgroundImage,
|
|
1500
|
+
width,
|
|
1501
|
+
height,
|
|
1502
|
+
`fmd-grad-${gradientId++}`,
|
|
1503
|
+
)
|
|
1504
|
+
: undefined;
|
|
1505
|
+
if (!gradient) {
|
|
1506
|
+
console.warn(
|
|
1507
|
+
`[export-pptx] radial-gradient background is not exported: ${style.backgroundImage}`,
|
|
1508
|
+
);
|
|
1509
|
+
continue;
|
|
1510
|
+
}
|
|
1511
|
+
const svg = document.createElementNS(SVG_NAMESPACE, "svg");
|
|
1512
|
+
svg.setAttribute("width", `${width}`);
|
|
1513
|
+
svg.setAttribute("height", `${height}`);
|
|
1514
|
+
const defs = document.createElementNS(SVG_NAMESPACE, "defs");
|
|
1515
|
+
defs.appendChild(gradient);
|
|
1516
|
+
const rect = document.createElementNS(SVG_NAMESPACE, "rect");
|
|
1517
|
+
rect.setAttribute("width", `${width}`);
|
|
1518
|
+
rect.setAttribute("height", `${height}`);
|
|
1519
|
+
rect.setAttribute("fill", `url(#${gradient.id})`);
|
|
1520
|
+
svg.append(defs, rect);
|
|
1521
|
+
// dom-to-pptx cuts the url() at its first ")", so none may survive inside.
|
|
1522
|
+
const url = svgDataUrl(svg).replace(/\(/g, "%28").replace(/\)/g, "%29");
|
|
1523
|
+
element.style.backgroundImage = `url("${url}")`;
|
|
1524
|
+
element.style.backgroundSize = "cover";
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
const GRADIENT_STOP_COLOR = /#[\da-f]{3,8}\b|rgba?\([^)]*\)/gi;
|
|
1529
|
+
|
|
1530
|
+
// dom-to-pptx reads the first stop of a background-clip:text gradient but
|
|
1531
|
+
// keeps the text colour's alpha, so `color: transparent` exports invisible.
|
|
1532
|
+
export function solidifyGradientText(root: HTMLElement) {
|
|
1533
|
+
for (const element of allElements(root)) {
|
|
1534
|
+
const style = window.getComputedStyle(element);
|
|
1535
|
+
if ((style.webkitBackgroundClip || style.backgroundClip) !== "text") {
|
|
1536
|
+
continue;
|
|
1537
|
+
}
|
|
1538
|
+
if (!TRANSPARENT_COLOR.test(style.color)) continue;
|
|
1539
|
+
const stops = style.backgroundImage.match(GRADIENT_STOP_COLOR) ?? [];
|
|
1540
|
+
const visible = stops.find((stop) => !TRANSPARENT_COLOR.test(stop));
|
|
1541
|
+
if (visible) element.style.color = visible;
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
function isDropShadow(layer: string) {
|
|
1546
|
+
const tokens: string[] = layer.match(/rgba?\([^)]*\)|\S+/g) ?? [];
|
|
1547
|
+
if (tokens.includes("inset")) return false;
|
|
1548
|
+
const [x = 0, y = 0, blur = 0] = tokens
|
|
1549
|
+
.filter((token) => /^-?[\d.]+(?:px)?$/.test(token))
|
|
1550
|
+
.map(Number.parseFloat);
|
|
1551
|
+
return x !== 0 || y !== 0 || blur !== 0;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
// dom-to-pptx draws only the first layer and as an outer shadow: an inset
|
|
1555
|
+
// layer becomes a glow outside the box and a spread-only ring a blurred halo.
|
|
1556
|
+
export function simplifyBoxShadows(root: HTMLElement) {
|
|
1557
|
+
for (const element of allElements(root)) {
|
|
1558
|
+
const shadow = window.getComputedStyle(element).boxShadow;
|
|
1559
|
+
if (!shadow || shadow === "none") continue;
|
|
1560
|
+
const drop = splitTopLevel(shadow)?.find(isDropShadow);
|
|
1561
|
+
if (drop !== shadow) element.style.boxShadow = drop ?? "none";
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
const BORDER_SIDES = ["top", "right", "bottom", "left"] as const;
|
|
1566
|
+
const BORDER_CORNERS = [
|
|
1567
|
+
"top-left",
|
|
1568
|
+
"top-right",
|
|
1569
|
+
"bottom-right",
|
|
1570
|
+
"bottom-left",
|
|
1571
|
+
] as const;
|
|
1572
|
+
const TRANSPARENT_COLOR = /^(?:transparent|rgba\([^)]*,\s*0(?:\.0+)?\))$/;
|
|
1573
|
+
|
|
1574
|
+
export function materializeCompositeBorders(root: HTMLElement) {
|
|
1575
|
+
for (const element of [
|
|
1576
|
+
root,
|
|
1577
|
+
...Array.from(root.querySelectorAll<HTMLElement>("*")),
|
|
1578
|
+
]) {
|
|
1579
|
+
const style = window.getComputedStyle(element);
|
|
1580
|
+
const edges = BORDER_SIDES.map((side) => ({
|
|
1581
|
+
color: style.getPropertyValue(`border-${side}-color`),
|
|
1582
|
+
side,
|
|
1583
|
+
stroke: style.getPropertyValue(`border-${side}-style`),
|
|
1584
|
+
width: computedLength(style.getPropertyValue(`border-${side}-width`), 0),
|
|
1585
|
+
}));
|
|
1586
|
+
const [first] = edges;
|
|
1587
|
+
if (!edges.some((edge) => edge.width > 0)) continue;
|
|
1588
|
+
if (
|
|
1589
|
+
edges.every(
|
|
1590
|
+
(edge) =>
|
|
1591
|
+
edge.width === first.width &&
|
|
1592
|
+
edge.stroke === first.stroke &&
|
|
1593
|
+
edge.color === first.color,
|
|
1594
|
+
)
|
|
1595
|
+
) {
|
|
1596
|
+
continue;
|
|
1597
|
+
}
|
|
1598
|
+
if (edges.some((edge) => edge.width > 0 && edge.stroke !== "solid")) {
|
|
1599
|
+
continue;
|
|
1600
|
+
}
|
|
1601
|
+
if (
|
|
1602
|
+
BORDER_CORNERS.some(
|
|
1603
|
+
(corner) =>
|
|
1604
|
+
computedLength(style.getPropertyValue(`border-${corner}-radius`), 0) >
|
|
1605
|
+
0,
|
|
1606
|
+
)
|
|
1607
|
+
) {
|
|
1608
|
+
continue;
|
|
1609
|
+
}
|
|
1610
|
+
if (
|
|
1611
|
+
edges.some((edge, index) => {
|
|
1612
|
+
const next = edges[(index + 1) % edges.length];
|
|
1613
|
+
return (
|
|
1614
|
+
edge.width > 0 &&
|
|
1615
|
+
next.width > 0 &&
|
|
1616
|
+
(edge.width !== next.width || edge.color !== next.color)
|
|
1617
|
+
);
|
|
1618
|
+
})
|
|
1619
|
+
) {
|
|
1620
|
+
continue;
|
|
1621
|
+
}
|
|
1622
|
+
const positioned = Array.from(
|
|
1623
|
+
element.querySelectorAll<HTMLElement>("*"),
|
|
1624
|
+
).some((child) => {
|
|
1625
|
+
const position = window.getComputedStyle(child).position;
|
|
1626
|
+
return position === "absolute" || position === "fixed";
|
|
1627
|
+
});
|
|
1628
|
+
if (positioned) continue;
|
|
1629
|
+
if (style.position === "static") element.style.position = "relative";
|
|
1630
|
+
|
|
1631
|
+
for (const edge of edges) {
|
|
1632
|
+
if (!(edge.width > 0)) continue;
|
|
1633
|
+
const padding = computedLength(
|
|
1634
|
+
style.getPropertyValue(`padding-${edge.side}`),
|
|
1635
|
+
0,
|
|
1636
|
+
);
|
|
1637
|
+
element.style.setProperty(
|
|
1638
|
+
`padding-${edge.side}`,
|
|
1639
|
+
`${padding + edge.width}px`,
|
|
1640
|
+
);
|
|
1641
|
+
element.style.setProperty(`border-${edge.side}-width`, "0");
|
|
1642
|
+
if (TRANSPARENT_COLOR.test(edge.color)) continue;
|
|
1643
|
+
const bar = element.ownerDocument.createElement("div");
|
|
1644
|
+
bar.style.position = "absolute";
|
|
1645
|
+
bar.style.backgroundColor = edge.color;
|
|
1646
|
+
bar.style.setProperty(edge.side, "0");
|
|
1647
|
+
if (edge.side === "top" || edge.side === "bottom") {
|
|
1648
|
+
bar.style.left = "0";
|
|
1649
|
+
bar.style.right = "0";
|
|
1650
|
+
bar.style.height = `${edge.width}px`;
|
|
1651
|
+
} else {
|
|
1652
|
+
bar.style.top = "0";
|
|
1653
|
+
bar.style.bottom = "0";
|
|
1654
|
+
bar.style.width = `${edge.width}px`;
|
|
1655
|
+
}
|
|
1656
|
+
element.append(bar);
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
export async function replaceInlineSvgsWithImages(
|
|
1662
|
+
root: HTMLElement,
|
|
1663
|
+
slideNumber = 1,
|
|
1664
|
+
): Promise<number> {
|
|
1665
|
+
const svgs = Array.from(root.querySelectorAll<SVGSVGElement>("svg"));
|
|
1666
|
+
let blankCount = 0;
|
|
1667
|
+
for (const [index, svg] of svgs.entries()) {
|
|
1668
|
+
const rect = svg.getBoundingClientRect();
|
|
1669
|
+
const viewBox = svg.viewBox?.baseVal;
|
|
1670
|
+
const style = window.getComputedStyle(svg);
|
|
1671
|
+
const width =
|
|
1672
|
+
computedLength(style.width, rect.width) ||
|
|
1673
|
+
Number(svg.getAttribute("width")) ||
|
|
1674
|
+
viewBox?.width ||
|
|
1675
|
+
1;
|
|
1676
|
+
const height =
|
|
1677
|
+
computedLength(style.height, rect.height) ||
|
|
1678
|
+
Number(svg.getAttribute("height")) ||
|
|
1679
|
+
viewBox?.height ||
|
|
1680
|
+
1;
|
|
1681
|
+
const { dataUrl, blank } = await rasterizeSvgElement(svg, width, height);
|
|
1682
|
+
if (blank) {
|
|
1683
|
+
blankCount++;
|
|
1684
|
+
const outline =
|
|
1685
|
+
svg.querySelector("path")?.getAttribute("d")?.slice(0, 48) ?? "no path";
|
|
1686
|
+
console.warn(
|
|
1687
|
+
`[export-pptx] slide ${slideNumber} shape ${index + 1} rasterized empty and will be missing from the export (${Math.round(width)}x${Math.round(height)}, ${outline})`,
|
|
1688
|
+
);
|
|
1689
|
+
}
|
|
1690
|
+
const img = document.createElement("img");
|
|
1691
|
+
img.src = dataUrl;
|
|
1692
|
+
img.alt = svg.getAttribute("aria-label") ?? "";
|
|
1693
|
+
Object.assign(img.style, {
|
|
1694
|
+
alignSelf: style.alignSelf,
|
|
1695
|
+
display: style.display === "inline" ? "inline-block" : style.display,
|
|
1696
|
+
flex: style.flex,
|
|
1697
|
+
height: `${height}px`,
|
|
1698
|
+
justifySelf: style.justifySelf,
|
|
1699
|
+
left: style.left,
|
|
1700
|
+
marginBottom: style.marginBottom,
|
|
1701
|
+
marginLeft: style.marginLeft,
|
|
1702
|
+
marginRight: style.marginRight,
|
|
1703
|
+
marginTop: style.marginTop,
|
|
1704
|
+
objectFit: "contain",
|
|
1705
|
+
opacity: style.opacity,
|
|
1706
|
+
position: style.position,
|
|
1707
|
+
right: style.right,
|
|
1708
|
+
top: style.top,
|
|
1709
|
+
transform: style.transform === "none" ? "" : style.transform,
|
|
1710
|
+
width: `${width}px`,
|
|
1711
|
+
zIndex: style.zIndex,
|
|
1712
|
+
});
|
|
1713
|
+
svg.replaceWith(img);
|
|
1714
|
+
}
|
|
1715
|
+
return blankCount;
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
async function flattenCroppedImages(root: HTMLElement) {
|
|
1719
|
+
for (const image of Array.from(root.querySelectorAll("img"))) {
|
|
1720
|
+
const clip = image.parentElement;
|
|
1721
|
+
if (!clip) continue;
|
|
1722
|
+
const clipStyle = window.getComputedStyle(clip);
|
|
1723
|
+
if (
|
|
1724
|
+
clipStyle.overflowX === "visible" ||
|
|
1725
|
+
clipStyle.overflowY === "visible"
|
|
1726
|
+
) {
|
|
1727
|
+
continue;
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
const imageRect = image.getBoundingClientRect();
|
|
1731
|
+
const clipRect = clip.getBoundingClientRect();
|
|
1732
|
+
const left = Math.max(imageRect.left, clipRect.left);
|
|
1733
|
+
const top = Math.max(imageRect.top, clipRect.top);
|
|
1734
|
+
const width = Math.min(imageRect.right, clipRect.right) - left;
|
|
1735
|
+
const height = Math.min(imageRect.bottom, clipRect.bottom) - top;
|
|
1736
|
+
if (width <= 0 || height <= 0) continue;
|
|
1737
|
+
if (
|
|
1738
|
+
width >= imageRect.width - 0.5 &&
|
|
1739
|
+
height >= imageRect.height - 0.5 &&
|
|
1740
|
+
left <= imageRect.left + 0.5 &&
|
|
1741
|
+
top <= imageRect.top + 0.5
|
|
1742
|
+
) {
|
|
1743
|
+
continue;
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
if ((window.getComputedStyle(image).objectFit || "fill") !== "fill") {
|
|
1747
|
+
console.warn(
|
|
1748
|
+
`[export-pptx] cropped image uses object-fit and exports uncropped: ${image.src}`,
|
|
1749
|
+
);
|
|
1750
|
+
continue;
|
|
1751
|
+
}
|
|
1752
|
+
await waitForImageToSettle(image);
|
|
1753
|
+
if (!image.complete || image.naturalWidth <= 0) {
|
|
1754
|
+
console.warn(
|
|
1755
|
+
`[export-pptx] cropped image is not decoded and exports uncropped: ${image.src}`,
|
|
1756
|
+
);
|
|
1757
|
+
continue;
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
const scaleX = image.naturalWidth / imageRect.width;
|
|
1761
|
+
const scaleY = image.naturalHeight / imageRect.height;
|
|
1762
|
+
const canvas = document.createElement("canvas");
|
|
1763
|
+
canvas.width = Math.max(1, Math.round(width * scaleX));
|
|
1764
|
+
canvas.height = Math.max(1, Math.round(height * scaleY));
|
|
1765
|
+
const context = canvas.getContext("2d");
|
|
1766
|
+
if (!context) {
|
|
1767
|
+
console.warn(
|
|
1768
|
+
`[export-pptx] no 2d canvas to crop with; image exports uncropped: ${image.src}`,
|
|
1769
|
+
);
|
|
1770
|
+
continue;
|
|
1771
|
+
}
|
|
1772
|
+
context.drawImage(
|
|
1773
|
+
image,
|
|
1774
|
+
(left - imageRect.left) * scaleX,
|
|
1775
|
+
(top - imageRect.top) * scaleY,
|
|
1776
|
+
canvas.width,
|
|
1777
|
+
canvas.height,
|
|
1778
|
+
0,
|
|
1779
|
+
0,
|
|
1780
|
+
canvas.width,
|
|
1781
|
+
canvas.height,
|
|
1782
|
+
);
|
|
1783
|
+
|
|
1784
|
+
let cropped: string;
|
|
1785
|
+
try {
|
|
1786
|
+
cropped = canvas.toDataURL("image/png");
|
|
1787
|
+
} catch (error) {
|
|
1788
|
+
console.warn(
|
|
1789
|
+
`[export-pptx] cropped image could not be rasterized and exports uncropped: ${image.src}`,
|
|
1790
|
+
error,
|
|
1791
|
+
);
|
|
1792
|
+
continue;
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
image.src = cropped;
|
|
1796
|
+
image.style.height = `${height}px`;
|
|
1797
|
+
image.style.maxHeight = "none";
|
|
1798
|
+
image.style.maxWidth = "none";
|
|
1799
|
+
image.style.width = `${width}px`;
|
|
1800
|
+
|
|
1801
|
+
const shrunkRect = image.getBoundingClientRect();
|
|
1802
|
+
const deltaX = left - shrunkRect.left;
|
|
1803
|
+
const deltaY = top - shrunkRect.top;
|
|
1804
|
+
const imageStyle = window.getComputedStyle(image);
|
|
1805
|
+
if (imageStyle.position === "absolute" || imageStyle.position === "fixed") {
|
|
1806
|
+
const cssLeft = Number.parseFloat(imageStyle.left);
|
|
1807
|
+
const cssTop = Number.parseFloat(imageStyle.top);
|
|
1808
|
+
image.style.bottom = "auto";
|
|
1809
|
+
image.style.right = "auto";
|
|
1810
|
+
if (Number.isFinite(cssLeft)) {
|
|
1811
|
+
image.style.left = `${(cssLeft + deltaX).toFixed(3)}px`;
|
|
1812
|
+
}
|
|
1813
|
+
if (Number.isFinite(cssTop)) {
|
|
1814
|
+
image.style.top = `${(cssTop + deltaY).toFixed(3)}px`;
|
|
1815
|
+
}
|
|
1816
|
+
continue;
|
|
1817
|
+
}
|
|
1818
|
+
image.style.transform = `translate(${deltaX.toFixed(3)}px, ${deltaY.toFixed(3)}px)`;
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
function widenNoWrapTextElements(root: HTMLElement) {
|
|
1823
|
+
const elements = Array.from(root.querySelectorAll<HTMLElement>("*"));
|
|
1824
|
+
for (const element of elements) {
|
|
1825
|
+
if (!element.textContent?.trim()) continue;
|
|
1826
|
+
if (element.querySelector("img,svg,video,canvas")) continue;
|
|
1827
|
+
if (element.dataset.exportSingleLineText === "true") continue;
|
|
1828
|
+
const style = window.getComputedStyle(element);
|
|
1829
|
+
if (style.whiteSpace !== "nowrap" && style.whiteSpace !== "pre") continue;
|
|
1830
|
+
const rect = element.getBoundingClientRect();
|
|
1831
|
+
if (!rect.width || !rect.height) continue;
|
|
1832
|
+
const buffer = Math.max(24, rect.width * 0.25);
|
|
1833
|
+
if (style.display === "inline") {
|
|
1834
|
+
element.style.display = "inline-block";
|
|
1835
|
+
}
|
|
1836
|
+
widenInPlace(element, Math.ceil(rect.width + buffer));
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
function materializeImportedBackgroundGrid(root: HTMLElement) {
|
|
1841
|
+
const slideRoot = root.matches(".fmd-imported-pptx")
|
|
1842
|
+
? root
|
|
1843
|
+
: root.querySelector<HTMLElement>(".fmd-imported-pptx");
|
|
1844
|
+
if (!slideRoot) return;
|
|
1845
|
+
const computed = window.getComputedStyle(slideRoot);
|
|
1846
|
+
if (!computed.backgroundImage.includes("linear-gradient")) return;
|
|
1847
|
+
|
|
1848
|
+
const color = computed.backgroundImage.match(/rgb\([^)]*\)/)?.[0];
|
|
1849
|
+
const size = computed.backgroundSize
|
|
1850
|
+
.split(",")[0]
|
|
1851
|
+
?.trim()
|
|
1852
|
+
.split(/\s+/)
|
|
1853
|
+
.map((value) => Number.parseFloat(value));
|
|
1854
|
+
const position = computed.backgroundPosition
|
|
1855
|
+
.split(",")[0]
|
|
1856
|
+
?.trim()
|
|
1857
|
+
.split(/\s+/)
|
|
1858
|
+
.map((value) => Number.parseFloat(value));
|
|
1859
|
+
const declaredLineWidth = computed.backgroundImage.match(
|
|
1860
|
+
/\b0(?:px)?\s+([\d.]+)px\b/i,
|
|
1861
|
+
)?.[1];
|
|
1862
|
+
const lineWidth = declaredLineWidth
|
|
1863
|
+
? Number.parseFloat(declaredLineWidth)
|
|
1864
|
+
: Number.NaN;
|
|
1865
|
+
if (
|
|
1866
|
+
!color ||
|
|
1867
|
+
!size ||
|
|
1868
|
+
size.length < 2 ||
|
|
1869
|
+
!Number.isFinite(size[0]) ||
|
|
1870
|
+
!Number.isFinite(size[1]) ||
|
|
1871
|
+
size[0] <= 0 ||
|
|
1872
|
+
size[1] <= 0 ||
|
|
1873
|
+
!position ||
|
|
1874
|
+
position.length < 2 ||
|
|
1875
|
+
!Number.isFinite(position[0]) ||
|
|
1876
|
+
!Number.isFinite(position[1]) ||
|
|
1877
|
+
!Number.isFinite(lineWidth)
|
|
1878
|
+
) {
|
|
1879
|
+
return;
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
const canvas = document.createElement("canvas");
|
|
1883
|
+
canvas.width = Math.max(1, Math.round(slideRoot.clientWidth));
|
|
1884
|
+
canvas.height = Math.max(1, Math.round(slideRoot.clientHeight));
|
|
1885
|
+
const context = canvas.getContext("2d");
|
|
1886
|
+
if (!context) return;
|
|
1887
|
+
context.strokeStyle = color;
|
|
1888
|
+
context.lineWidth = Math.max(0.5, lineWidth);
|
|
1889
|
+
|
|
1890
|
+
for (let x = position[0]; x < canvas.width; x += size[0]) {
|
|
1891
|
+
context.beginPath();
|
|
1892
|
+
context.moveTo(x + context.lineWidth / 2, 0);
|
|
1893
|
+
context.lineTo(x + context.lineWidth / 2, canvas.height);
|
|
1894
|
+
context.stroke();
|
|
1895
|
+
}
|
|
1896
|
+
for (let y = position[1]; y < canvas.height; y += size[1]) {
|
|
1897
|
+
context.beginPath();
|
|
1898
|
+
context.moveTo(0, y + context.lineWidth / 2);
|
|
1899
|
+
context.lineTo(canvas.width, y + context.lineWidth / 2);
|
|
1900
|
+
context.stroke();
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
const gridImage = document.createElement("img");
|
|
1904
|
+
gridImage.alt = "";
|
|
1905
|
+
gridImage.src = canvas.toDataURL("image/png");
|
|
1906
|
+
Object.assign(gridImage.style, {
|
|
1907
|
+
height: "100%",
|
|
1908
|
+
left: "0",
|
|
1909
|
+
pointerEvents: "none",
|
|
1910
|
+
position: "absolute",
|
|
1911
|
+
top: "0",
|
|
1912
|
+
width: "100%",
|
|
1913
|
+
zIndex: "0",
|
|
1914
|
+
});
|
|
1915
|
+
slideRoot.insertBefore(gridImage, slideRoot.firstChild);
|
|
1916
|
+
slideRoot.style.backgroundImage = "none";
|
|
1917
|
+
slideRoot.style.backgroundSize = "auto";
|
|
1918
|
+
slideRoot.style.backgroundPosition = "0 0";
|
|
1919
|
+
slideRoot.style.backgroundRepeat = "no-repeat";
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
export type PptxExportTarget = "powerpoint" | "google-slides";
|
|
1923
|
+
|
|
1924
|
+
function measureFontMetrics(roots: HTMLElement[]): Record<string, FontMetrics> {
|
|
1925
|
+
const context = document.createElement("canvas").getContext?.("2d");
|
|
1926
|
+
if (!context || typeof context.measureText !== "function") return {};
|
|
1927
|
+
const metrics: Record<string, FontMetrics> = {};
|
|
1928
|
+
for (const family of usedFontFamilies(roots)) {
|
|
1929
|
+
context.font = `100px "${family.replace(/["\\]/g, "\\$&")}"`;
|
|
1930
|
+
const { fontBoundingBoxAscent, fontBoundingBoxDescent } =
|
|
1931
|
+
context.measureText("Hg");
|
|
1932
|
+
if (fontBoundingBoxAscent > 0 && fontBoundingBoxDescent >= 0) {
|
|
1933
|
+
metrics[family] = {
|
|
1934
|
+
ascent: fontBoundingBoxAscent / 100,
|
|
1935
|
+
descent: fontBoundingBoxDescent / 100,
|
|
1936
|
+
};
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
return metrics;
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
const FONT_PROBE_TEXT = "mmmmmmmmmmlli 0123 WwQq";
|
|
1943
|
+
|
|
1944
|
+
const GENERIC_EXPORT_FACES: Record<string, string> = {
|
|
1945
|
+
"sans-serif": "Arial",
|
|
1946
|
+
"system-ui": "Arial",
|
|
1947
|
+
"ui-sans-serif": "Arial",
|
|
1948
|
+
"ui-rounded": "Arial",
|
|
1949
|
+
"-apple-system": "Arial",
|
|
1950
|
+
blinkmacsystemfont: "Arial",
|
|
1951
|
+
serif: "Times New Roman",
|
|
1952
|
+
"ui-serif": "Times New Roman",
|
|
1953
|
+
monospace: "Courier New",
|
|
1954
|
+
"ui-monospace": "Courier New",
|
|
1955
|
+
};
|
|
1956
|
+
|
|
1957
|
+
const GOOGLE_SLIDES_FACE_EQUIVALENTS: Record<string, string> = {
|
|
1958
|
+
helvetica: "Arial",
|
|
1959
|
+
"helvetica neue": "Arial",
|
|
1960
|
+
"segoe ui": "Arial",
|
|
1961
|
+
"sf pro": "Arial",
|
|
1962
|
+
"sf pro text": "Arial",
|
|
1963
|
+
"sf pro display": "Arial",
|
|
1964
|
+
times: "Times New Roman",
|
|
1965
|
+
courier: "Courier New",
|
|
1966
|
+
menlo: "Courier New",
|
|
1967
|
+
monaco: "Courier New",
|
|
1968
|
+
consolas: "Courier New",
|
|
1969
|
+
"sf mono": "Courier New",
|
|
1970
|
+
};
|
|
1971
|
+
|
|
1972
|
+
function createFontRenderProbe(): ((family: string) => boolean) | undefined {
|
|
1973
|
+
const context = document.createElement("canvas").getContext?.("2d");
|
|
1974
|
+
if (!context || typeof context.measureText !== "function") return undefined;
|
|
1975
|
+
const width = (font: string) => {
|
|
1976
|
+
context.font = font;
|
|
1977
|
+
return context.measureText(FONT_PROBE_TEXT).width;
|
|
1978
|
+
};
|
|
1979
|
+
if (width("72px monospace") === width("72px serif")) return undefined;
|
|
1980
|
+
const cache = new Map<string, boolean>();
|
|
1981
|
+
return (family) => {
|
|
1982
|
+
const key = family.toLowerCase();
|
|
1983
|
+
if (key in GENERIC_EXPORT_FACES) return true;
|
|
1984
|
+
let rendered = cache.get(key);
|
|
1985
|
+
if (rendered === undefined) {
|
|
1986
|
+
const quoted = `"${family.replace(/["\\]/g, "\\$&")}"`;
|
|
1987
|
+
rendered = ["monospace", "serif"].some(
|
|
1988
|
+
(generic) =>
|
|
1989
|
+
width(`72px ${quoted}, ${generic}`) !== width(`72px ${generic}`),
|
|
1990
|
+
);
|
|
1991
|
+
cache.set(key, rendered);
|
|
1992
|
+
}
|
|
1993
|
+
return rendered;
|
|
1994
|
+
};
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
export function pinRenderedFontFamilies(
|
|
1998
|
+
root: HTMLElement,
|
|
1999
|
+
target: PptxExportTarget,
|
|
2000
|
+
) {
|
|
2001
|
+
const isRendered = createFontRenderProbe();
|
|
2002
|
+
if (!isRendered) return;
|
|
2003
|
+
for (const element of [root, ...Array.from(root.querySelectorAll("*"))]) {
|
|
2004
|
+
if (!(element instanceof HTMLElement)) continue;
|
|
2005
|
+
if (NON_RENDERING_TAGS.has(element.tagName)) continue;
|
|
2006
|
+
const ownText = Array.from(element.childNodes).some(
|
|
2007
|
+
(child) => child.nodeType === Node.TEXT_NODE && child.nodeValue?.trim(),
|
|
2008
|
+
);
|
|
2009
|
+
if (!ownText) continue;
|
|
2010
|
+
const stack = window
|
|
2011
|
+
.getComputedStyle(element)
|
|
2012
|
+
.fontFamily.split(",")
|
|
2013
|
+
.map((family) => family.trim().replace(/^["']|["']$/g, ""))
|
|
2014
|
+
.filter(Boolean);
|
|
2015
|
+
const painted = stack.find((family) => isRendered(family));
|
|
2016
|
+
if (!painted) continue;
|
|
2017
|
+
const key = painted.toLowerCase();
|
|
2018
|
+
const face =
|
|
2019
|
+
GENERIC_EXPORT_FACES[key] ??
|
|
2020
|
+
(target === "google-slides"
|
|
2021
|
+
? GOOGLE_SLIDES_FACE_EQUIVALENTS[key]
|
|
2022
|
+
: undefined) ??
|
|
2023
|
+
painted;
|
|
2024
|
+
if (face !== stack[0]) element.style.fontFamily = `"${face}"`;
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
function hasRotatedAncestor(
|
|
2029
|
+
element: Element,
|
|
2030
|
+
root: HTMLElement,
|
|
2031
|
+
cache: Map<Element, boolean>,
|
|
2032
|
+
): boolean {
|
|
2033
|
+
const cached = cache.get(element);
|
|
2034
|
+
if (cached !== undefined) return cached;
|
|
2035
|
+
const transform = window.getComputedStyle(element).transform;
|
|
2036
|
+
const matrix = transform.match(/^matrix\(([^)]*)\)$/)?.[1].split(",");
|
|
2037
|
+
const rotated =
|
|
2038
|
+
(matrix !== undefined &&
|
|
2039
|
+
(Math.abs(Number(matrix[1])) > 1e-6 ||
|
|
2040
|
+
Math.abs(Number(matrix[2])) > 1e-6)) ||
|
|
2041
|
+
transform.startsWith("matrix3d") ||
|
|
2042
|
+
(element !== root &&
|
|
2043
|
+
element.parentElement !== null &&
|
|
2044
|
+
hasRotatedAncestor(element.parentElement, root, cache));
|
|
2045
|
+
cache.set(element, rotated);
|
|
2046
|
+
return rotated;
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
const PRESERVED_NEWLINE_WHITE_SPACE = /^(pre|pre-wrap|pre-line|break-spaces)$/;
|
|
2050
|
+
|
|
2051
|
+
export function markWrappedLines(root: HTMLElement): number {
|
|
2052
|
+
const displays = new Map<Element, string>();
|
|
2053
|
+
const display = (element: Element) => {
|
|
2054
|
+
let value = displays.get(element);
|
|
2055
|
+
if (value === undefined) {
|
|
2056
|
+
value = window.getComputedStyle(element).display;
|
|
2057
|
+
displays.set(element, value);
|
|
2058
|
+
}
|
|
2059
|
+
return value;
|
|
2060
|
+
};
|
|
2061
|
+
const containerOf = (node: Node): Element => {
|
|
2062
|
+
let element = node.parentElement;
|
|
2063
|
+
while (
|
|
2064
|
+
element &&
|
|
2065
|
+
element !== root &&
|
|
2066
|
+
(display(element) === "inline" || display(element) === "contents")
|
|
2067
|
+
) {
|
|
2068
|
+
element = element.parentElement;
|
|
2069
|
+
}
|
|
2070
|
+
return element ?? root;
|
|
2071
|
+
};
|
|
2072
|
+
|
|
2073
|
+
const rotation = new Map<Element, boolean>();
|
|
2074
|
+
const lineBottoms = new Map<Element, number>();
|
|
2075
|
+
const previousGlyphs = new Map<Element, DOMRect>();
|
|
2076
|
+
const marks: Array<{ node: Text; offset: number }> = [];
|
|
2077
|
+
const range = document.createRange();
|
|
2078
|
+
const walker = document.createTreeWalker(
|
|
2079
|
+
root,
|
|
2080
|
+
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT,
|
|
2081
|
+
);
|
|
2082
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
2083
|
+
if (node instanceof Element) {
|
|
2084
|
+
const value = display(node);
|
|
2085
|
+
if (
|
|
2086
|
+
node.tagName === "BR" ||
|
|
2087
|
+
(value !== "inline" && value !== "contents")
|
|
2088
|
+
) {
|
|
2089
|
+
const container = containerOf(node);
|
|
2090
|
+
lineBottoms.delete(container);
|
|
2091
|
+
previousGlyphs.delete(container);
|
|
2092
|
+
}
|
|
2093
|
+
continue;
|
|
2094
|
+
}
|
|
2095
|
+
if (!(node instanceof Text)) continue;
|
|
2096
|
+
const parent = node.parentElement;
|
|
2097
|
+
if (!parent || NON_RENDERING_TAGS.has(parent.tagName)) continue;
|
|
2098
|
+
const hidden = parent.closest('[aria-hidden="true"]');
|
|
2099
|
+
if (hidden && hidden !== root && root.contains(hidden)) continue;
|
|
2100
|
+
const container = containerOf(node);
|
|
2101
|
+
if (hasRotatedAncestor(container, root, rotation)) continue;
|
|
2102
|
+
const keepsNewlines = PRESERVED_NEWLINE_WHITE_SPACE.test(
|
|
2103
|
+
window.getComputedStyle(parent).whiteSpace,
|
|
2104
|
+
);
|
|
2105
|
+
const rightToLeft = window.getComputedStyle(container).direction === "rtl";
|
|
2106
|
+
const text = node.data;
|
|
2107
|
+
for (let offset = 0; offset < text.length; offset++) {
|
|
2108
|
+
const character = text[offset];
|
|
2109
|
+
if (character === "\n" && keepsNewlines) {
|
|
2110
|
+
lineBottoms.delete(container);
|
|
2111
|
+
previousGlyphs.delete(container);
|
|
2112
|
+
continue;
|
|
2113
|
+
}
|
|
2114
|
+
if (/\s/.test(character)) continue;
|
|
2115
|
+
range.setStart(node, offset);
|
|
2116
|
+
range.setEnd(node, offset + 1);
|
|
2117
|
+
const rect = range.getClientRects()[0];
|
|
2118
|
+
if (!rect || (!rect.width && !rect.height)) continue;
|
|
2119
|
+
const bottom = lineBottoms.get(container);
|
|
2120
|
+
const previous = previousGlyphs.get(container);
|
|
2121
|
+
const wrapped =
|
|
2122
|
+
bottom !== undefined &&
|
|
2123
|
+
(rect.top + rect.height / 2 > bottom ||
|
|
2124
|
+
(previous !== undefined &&
|
|
2125
|
+
rect.top > previous.top + 0.5 &&
|
|
2126
|
+
(rightToLeft
|
|
2127
|
+
? rect.right > previous.right + 0.5
|
|
2128
|
+
: rect.left < previous.left - 0.5)));
|
|
2129
|
+
if (wrapped) {
|
|
2130
|
+
marks.push({ node, offset });
|
|
2131
|
+
lineBottoms.set(container, rect.bottom);
|
|
2132
|
+
} else {
|
|
2133
|
+
lineBottoms.set(
|
|
2134
|
+
container,
|
|
2135
|
+
Math.max(bottom ?? rect.bottom, rect.bottom),
|
|
2136
|
+
);
|
|
2137
|
+
}
|
|
2138
|
+
previousGlyphs.set(container, rect);
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
for (const { node, offset } of marks.reverse()) {
|
|
2142
|
+
node.insertData(offset, WRAP_MARK);
|
|
2143
|
+
}
|
|
2144
|
+
return marks.length;
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
export async function buildDeckPptxBlob(
|
|
2148
|
+
deckTitle: string,
|
|
2149
|
+
slides: PptxExportSlide[],
|
|
2150
|
+
aspectRatio?: AspectRatio,
|
|
2151
|
+
{ target = "powerpoint" }: { target?: PptxExportTarget } = {},
|
|
2152
|
+
): Promise<{ blob: Blob; filename: string; blankShapes: number }> {
|
|
2153
|
+
const { exportToPptx } = await importExportModule(
|
|
2154
|
+
() => import("dom-to-pptx"),
|
|
2155
|
+
);
|
|
2156
|
+
|
|
2157
|
+
if (typeof document !== "undefined" && document.fonts?.ready) {
|
|
2158
|
+
await document.fonts.ready;
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
const dims = getAspectRatioDims(aspectRatio);
|
|
2162
|
+
const exportClones: Array<{
|
|
2163
|
+
element: HTMLElement;
|
|
2164
|
+
cleanup: () => void;
|
|
2165
|
+
}> = [];
|
|
2166
|
+
const slideBulletIndents: number[][] = [];
|
|
2167
|
+
let blankShapes = 0;
|
|
2168
|
+
|
|
2169
|
+
try {
|
|
2170
|
+
for (let i = 0; i < slides.length; i++) {
|
|
2171
|
+
const exportSlide = slides[i];
|
|
2172
|
+
const source = findSlideExportSource(exportSlide.id, i, slides.length);
|
|
2173
|
+
await waitForImagesToSettle(source);
|
|
2174
|
+
const clone = createUnscaledExportClone(source, {
|
|
2175
|
+
width: dims.width,
|
|
2176
|
+
height: dims.height,
|
|
2177
|
+
});
|
|
2178
|
+
exportClones.push(clone);
|
|
2179
|
+
// dom-to-pptx reads DOM text, not the ::before counters the tokens use.
|
|
2180
|
+
materializeSlideNumberTokens(clone.element);
|
|
2181
|
+
// With the attributes gone the ::before counter rule stops matching;
|
|
2182
|
+
// dom-to-pptx would otherwise append its unresolved `counter(...)` text.
|
|
2183
|
+
for (const name of Object.keys(
|
|
2184
|
+
slideNumberRootAttrs({ number: 1, count: 1 }),
|
|
2185
|
+
)) {
|
|
2186
|
+
clone.element.removeAttribute(name);
|
|
2187
|
+
}
|
|
2188
|
+
await preloadImagesWithCors(clone.element);
|
|
2189
|
+
resetAutofitTransforms(clone.element);
|
|
2190
|
+
slideBulletIndents.push(normalizeListsForPptx(clone.element, dims));
|
|
2191
|
+
ensureBulletMarkerSpacing(clone.element);
|
|
2192
|
+
restorePositionedGeometry(
|
|
2193
|
+
clone.element,
|
|
2194
|
+
clone.sourceRect,
|
|
2195
|
+
clone.positionedGeometry,
|
|
2196
|
+
dims,
|
|
2197
|
+
);
|
|
2198
|
+
restoreTextGeometry(
|
|
2199
|
+
clone.element,
|
|
2200
|
+
clone.sourceRect,
|
|
2201
|
+
clone.textGeometry,
|
|
2202
|
+
dims,
|
|
2203
|
+
);
|
|
2204
|
+
normalizeSingleLineText(clone.element, clone.textGeometry);
|
|
2205
|
+
widenNoWrapTextElements(clone.element);
|
|
2206
|
+
materializeClipPathShapes(clone.element);
|
|
2207
|
+
materializeRadialGradients(clone.element);
|
|
2208
|
+
solidifyGradientText(clone.element);
|
|
2209
|
+
simplifyBoxShadows(clone.element);
|
|
2210
|
+
blankShapes += await replaceInlineSvgsWithImages(clone.element, i + 1);
|
|
2211
|
+
await preloadImagesWithCors(clone.element);
|
|
2212
|
+
restoreImageGeometry(
|
|
2213
|
+
clone.element,
|
|
2214
|
+
clone.sourceRect,
|
|
2215
|
+
clone.imageGeometry,
|
|
2216
|
+
dims,
|
|
2217
|
+
);
|
|
2218
|
+
await flattenCroppedImages(clone.element);
|
|
2219
|
+
materializeCompositeBorders(clone.element);
|
|
2220
|
+
materializeImportedBackgroundGrid(clone.element);
|
|
2221
|
+
pinRenderedFontFamilies(clone.element, target);
|
|
2222
|
+
if (target === "google-slides") markWrappedLines(clone.element);
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
const cloneElements = exportClones.map((clone) => clone.element);
|
|
2226
|
+
const [dominantFamily] = usedFontFamilies(cloneElements);
|
|
2227
|
+
const fonts = await resolveExportFonts(cloneElements);
|
|
2228
|
+
const initialBlob = await exportToPptx(cloneElements, {
|
|
2229
|
+
autoEmbedFonts: false,
|
|
2230
|
+
fonts,
|
|
2231
|
+
fileName: safePptxName(deckTitle),
|
|
2232
|
+
height: dims.pptxInches.h,
|
|
2233
|
+
skipDownload: true,
|
|
2234
|
+
svgAsVector: false,
|
|
2235
|
+
width: dims.pptxInches.w,
|
|
2236
|
+
});
|
|
2237
|
+
|
|
2238
|
+
const pinnedBlob = await pinTextBoxesForImport(initialBlob, dominantFamily);
|
|
2239
|
+
const bulletPatchedBlob = await patchBulletIndentsInPptxBlob(
|
|
2240
|
+
pinnedBlob,
|
|
2241
|
+
slideBulletIndents,
|
|
2242
|
+
);
|
|
2243
|
+
const notedBlob = await addSpeakerNotesToPptxBlob(
|
|
2244
|
+
bulletPatchedBlob,
|
|
2245
|
+
slides,
|
|
2246
|
+
dims.pptxInches,
|
|
2247
|
+
);
|
|
2248
|
+
const blob =
|
|
2249
|
+
target === "google-slides"
|
|
2250
|
+
? await retargetPptxForGoogleSlides(
|
|
2251
|
+
notedBlob,
|
|
2252
|
+
measureFontMetrics(cloneElements),
|
|
2253
|
+
)
|
|
2254
|
+
: notedBlob;
|
|
2255
|
+
if (blankShapes > 0) {
|
|
2256
|
+
console.warn(
|
|
2257
|
+
`[export-pptx] ${blankShapes} shape(s) rendered empty and are missing from ${deckTitle}`,
|
|
2258
|
+
);
|
|
2259
|
+
}
|
|
2260
|
+
return { blankShapes, blob, filename: safePptxName(deckTitle) };
|
|
2261
|
+
} finally {
|
|
2262
|
+
for (const clone of exportClones) {
|
|
2263
|
+
clone.cleanup();
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2268
|
+
export async function exportDeckAsPptx(
|
|
2269
|
+
deckTitle: string,
|
|
2270
|
+
slides: PptxExportSlide[],
|
|
2271
|
+
aspectRatio?: AspectRatio,
|
|
2272
|
+
analytics?: BrowserDeckExportFacts,
|
|
2273
|
+
): Promise<{ blankShapes: number }> {
|
|
2274
|
+
let built: Awaited<ReturnType<typeof buildDeckPptxBlob>>;
|
|
2275
|
+
try {
|
|
2276
|
+
built = await buildDeckPptxBlob(deckTitle, slides, aspectRatio);
|
|
2277
|
+
triggerBlobDownload(built.blob, built.filename);
|
|
2278
|
+
} catch (error) {
|
|
2279
|
+
if (analytics) {
|
|
2280
|
+
trackBrowserDeckExported("pptx", {
|
|
2281
|
+
...analytics,
|
|
2282
|
+
slideCount: slides.length,
|
|
2283
|
+
status: "failed",
|
|
2284
|
+
errorType: browserExportErrorType(error),
|
|
2285
|
+
});
|
|
2286
|
+
}
|
|
2287
|
+
throw error;
|
|
2288
|
+
}
|
|
2289
|
+
if (analytics) {
|
|
2290
|
+
trackBrowserDeckExported("pptx", {
|
|
2291
|
+
...analytics,
|
|
2292
|
+
slideCount: slides.length,
|
|
2293
|
+
status: "completed",
|
|
2294
|
+
});
|
|
2295
|
+
}
|
|
2296
|
+
return { blankShapes: built.blankShapes };
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
export async function exportDeckAsImagePptx(
|
|
2300
|
+
deckTitle: string,
|
|
2301
|
+
slides: PptxExportSlide[],
|
|
2302
|
+
aspectRatio?: AspectRatio,
|
|
2303
|
+
analytics?: BrowserDeckExportFacts,
|
|
2304
|
+
renderRoot: ParentNode = document,
|
|
2305
|
+
): Promise<void> {
|
|
2306
|
+
try {
|
|
2307
|
+
const [{ domToJpeg }, { exportToPptx }] = await Promise.all([
|
|
2308
|
+
importExportModule(() => import("modern-screenshot")),
|
|
2309
|
+
importExportModule(() => import("dom-to-pptx")),
|
|
2310
|
+
]);
|
|
2311
|
+
const dims =
|
|
2312
|
+
getAspectRatioDims(aspectRatio) ?? getAspectRatioDims(undefined);
|
|
2313
|
+
const imageSlides: HTMLElement[] = [];
|
|
2314
|
+
const restoreFontStyles = await exposeGoogleFontStylesheetsForExport();
|
|
2315
|
+
try {
|
|
2316
|
+
if (typeof document !== "undefined" && document.fonts?.ready) {
|
|
2317
|
+
await document.fonts.ready;
|
|
2318
|
+
}
|
|
2319
|
+
for (let i = 0; i < slides.length; i++) {
|
|
2320
|
+
const source = findSlideExportSource(
|
|
2321
|
+
slides[i].id,
|
|
2322
|
+
i,
|
|
2323
|
+
slides.length,
|
|
2324
|
+
renderRoot,
|
|
2325
|
+
);
|
|
2326
|
+
const restoreImages = await preloadImagesWithCors(source);
|
|
2327
|
+
let dataUrl: string;
|
|
2328
|
+
try {
|
|
2329
|
+
dataUrl = await domToJpeg(source, {
|
|
2330
|
+
width: dims.width,
|
|
2331
|
+
height: dims.height,
|
|
2332
|
+
scale: 2,
|
|
2333
|
+
// guard:allow-raw-color — slide exports need opaque image pixels.
|
|
2334
|
+
backgroundColor: "#000000",
|
|
2335
|
+
quality: 0.92,
|
|
2336
|
+
onCloneNode: (cloned) => {
|
|
2337
|
+
if (cloned instanceof HTMLElement) {
|
|
2338
|
+
materializeSlideNumberTokens(cloned);
|
|
2339
|
+
}
|
|
2340
|
+
},
|
|
2341
|
+
fetch: {
|
|
2342
|
+
requestInit: {
|
|
2343
|
+
cache: "no-cache",
|
|
2344
|
+
mode: "cors",
|
|
2345
|
+
credentials: "same-origin",
|
|
2346
|
+
},
|
|
2347
|
+
},
|
|
2348
|
+
});
|
|
2349
|
+
} finally {
|
|
2350
|
+
restoreImages();
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2353
|
+
const imageSlide = document.createElement("div");
|
|
2354
|
+
imageSlide.style.width = `${dims.width}px`;
|
|
2355
|
+
imageSlide.style.height = `${dims.height}px`;
|
|
2356
|
+
imageSlide.style.overflow = "hidden";
|
|
2357
|
+
const image = document.createElement("img");
|
|
2358
|
+
image.alt = `Slide ${i + 1}`;
|
|
2359
|
+
image.src = dataUrl;
|
|
2360
|
+
image.style.display = "block";
|
|
2361
|
+
image.style.width = "100%";
|
|
2362
|
+
image.style.height = "100%";
|
|
2363
|
+
imageSlide.append(image);
|
|
2364
|
+
await waitForImagesToSettle(imageSlide);
|
|
2365
|
+
imageSlides.push(imageSlide);
|
|
2366
|
+
}
|
|
2367
|
+
} finally {
|
|
2368
|
+
restoreFontStyles();
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
const stage = document.createElement("div");
|
|
2372
|
+
stage.dataset.imagePptxExportStage = "true";
|
|
2373
|
+
stage.setAttribute("aria-hidden", "true");
|
|
2374
|
+
Object.assign(stage.style, {
|
|
2375
|
+
position: "fixed",
|
|
2376
|
+
left: "-20000px",
|
|
2377
|
+
width: `${dims.width}px`,
|
|
2378
|
+
height: `${dims.height}px`,
|
|
2379
|
+
overflow: "hidden",
|
|
2380
|
+
top: "0",
|
|
2381
|
+
pointerEvents: "none",
|
|
2382
|
+
zIndex: "-1",
|
|
2383
|
+
});
|
|
2384
|
+
stage.append(...imageSlides);
|
|
2385
|
+
document.body.append(stage);
|
|
2386
|
+
try {
|
|
2387
|
+
const initialBlob = await exportToPptx(imageSlides, {
|
|
2388
|
+
fileName: safePptxName(deckTitle),
|
|
2389
|
+
height: dims.pptxInches.h,
|
|
2390
|
+
skipDownload: true,
|
|
2391
|
+
width: dims.pptxInches.w,
|
|
2392
|
+
});
|
|
2393
|
+
const blob = await addSpeakerNotesToPptxBlob(
|
|
2394
|
+
initialBlob,
|
|
2395
|
+
slides,
|
|
2396
|
+
dims.pptxInches,
|
|
2397
|
+
);
|
|
2398
|
+
triggerBlobDownload(blob, safePptxName(deckTitle));
|
|
2399
|
+
} finally {
|
|
2400
|
+
stage.remove();
|
|
2401
|
+
}
|
|
2402
|
+
} catch (error) {
|
|
2403
|
+
if (analytics) {
|
|
2404
|
+
trackBrowserDeckExported("pptx", {
|
|
2405
|
+
...analytics,
|
|
2406
|
+
slideCount: slides.length,
|
|
2407
|
+
status: "failed",
|
|
2408
|
+
errorType: browserExportErrorType(error),
|
|
2409
|
+
});
|
|
2410
|
+
}
|
|
2411
|
+
throw error;
|
|
2412
|
+
}
|
|
2413
|
+
if (analytics) {
|
|
2414
|
+
trackBrowserDeckExported("pptx", {
|
|
2415
|
+
...analytics,
|
|
2416
|
+
slideCount: slides.length,
|
|
2417
|
+
status: "completed",
|
|
2418
|
+
});
|
|
2419
|
+
}
|
|
2420
|
+
}
|