@formicoidea/labre-core 0.42.0 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_pkgs/affine-block-attachment/utils.js +4 -0
- package/dist/_pkgs/affine-block-bookmark/configs/toolbar.js +17 -4
- package/dist/_pkgs/affine-block-callout/commands/turn-into-callout.d.ts +29 -0
- package/dist/_pkgs/affine-block-callout/commands/turn-into-callout.js +81 -0
- package/dist/_pkgs/affine-block-callout/configs/slash-menu.js +6 -4
- package/dist/_pkgs/affine-block-callout/configs/turn-into.d.ts +8 -0
- package/dist/_pkgs/affine-block-callout/configs/turn-into.js +19 -0
- package/dist/_pkgs/affine-block-callout/translations.d.ts +4 -2
- package/dist/_pkgs/affine-block-callout/translations.js +4 -2
- package/dist/_pkgs/affine-block-callout/view.js +3 -0
- package/dist/_pkgs/affine-block-code/code-block-service.d.ts +13 -0
- package/dist/_pkgs/affine-block-code/code-block-service.js +26 -0
- package/dist/_pkgs/affine-block-code/code-block.d.ts +6 -0
- package/dist/_pkgs/affine-block-code/code-block.js +11 -2
- package/dist/_pkgs/affine-block-code/code-toolbar/components/lang-button.js +31 -8
- package/dist/_pkgs/affine-block-data-view/configs/tooltips.js +1 -1
- package/dist/_pkgs/affine-block-database/configs/tooltips.js +1 -1
- package/dist/_pkgs/affine-block-edgeless-text/edgeless-text-block.js +4 -2
- package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/config.d.ts +11 -0
- package/dist/_pkgs/affine-block-edgeless-text/svg-painter.d.ts +20 -0
- package/dist/_pkgs/affine-block-edgeless-text/svg-painter.js +76 -0
- package/dist/_pkgs/affine-block-edgeless-text/view.js +2 -0
- package/dist/_pkgs/affine-block-embed/common/iframe-sandbox.d.ts +39 -0
- package/dist/_pkgs/affine-block-embed/common/iframe-sandbox.js +39 -0
- package/dist/_pkgs/affine-block-embed/configs/toolbar.js +11 -2
- package/dist/_pkgs/affine-block-embed/embed-figma-block/embed-figma-block.js +2 -0
- package/dist/_pkgs/affine-block-embed/embed-iframe-block/components/embed-iframe-error-card.d.ts +14 -1
- package/dist/_pkgs/affine-block-embed/embed-iframe-block/components/embed-iframe-error-card.js +21 -2
- package/dist/_pkgs/affine-block-embed/embed-iframe-block/configs/toolbar.js +11 -2
- package/dist/_pkgs/affine-block-embed/embed-iframe-block/consts.d.ts +0 -2
- package/dist/_pkgs/affine-block-embed/embed-iframe-block/consts.js +2 -5
- package/dist/_pkgs/affine-block-embed/embed-iframe-block/embed-iframe-block.d.ts +1 -1
- package/dist/_pkgs/affine-block-embed/embed-iframe-block/embed-iframe-block.js +14 -6
- package/dist/_pkgs/affine-block-embed/embed-iframe-block/types.d.ts +16 -0
- package/dist/_pkgs/affine-block-embed/embed-iframe-block/types.js +17 -1
- package/dist/_pkgs/affine-block-embed/embed-loom-block/embed-loom-block.js +2 -0
- package/dist/_pkgs/affine-block-embed/embed-youtube-block/embed-youtube-block.js +2 -0
- package/dist/_pkgs/affine-block-embed/index.d.ts +1 -0
- package/dist/_pkgs/affine-block-embed/index.js +1 -0
- package/dist/_pkgs/affine-block-embed/translations.d.ts +8 -0
- package/dist/_pkgs/affine-block-embed/translations.js +28 -0
- package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-edgeless-linked-doc-block.js +3 -1
- package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-linked-doc-block.js +4 -2
- package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/configs/toolbar.js +7 -2
- package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-edgeless-synced-doc-block.js +3 -1
- package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-synced-doc-block.js +2 -2
- package/dist/_pkgs/affine-block-frame/frame-manager.d.ts +5 -0
- package/dist/_pkgs/affine-block-frame/frame-manager.js +53 -19
- package/dist/_pkgs/affine-block-frame/frame-tool.js +3 -1
- package/dist/_pkgs/affine-block-image/utils.js +4 -1
- package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.d.ts +8 -0
- package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.js +9 -5
- package/dist/_pkgs/affine-block-list/utils/get-list-icon.js +3 -1
- package/dist/_pkgs/affine-block-note/configs/tooltips.js +1 -1
- package/dist/_pkgs/affine-block-note/translations.d.ts +0 -1
- package/dist/_pkgs/affine-block-note/translations.js +0 -5
- package/dist/_pkgs/affine-block-root/adapters/html.js +2 -2
- package/dist/_pkgs/affine-block-root/commands/copy-link-commands.d.ts +2 -0
- package/dist/_pkgs/affine-block-root/commands/copy-link-commands.js +155 -0
- package/dist/_pkgs/affine-block-root/configs/toolbar.js +17 -1
- package/dist/_pkgs/affine-block-root/edgeless/clipboard/clipboard.js +2 -1
- package/dist/_pkgs/affine-block-root/edgeless/clipboard/command.js +161 -83
- package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.d.ts +21 -0
- package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.js +85 -0
- package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.d.ts +6 -0
- package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.js +18 -1
- package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.d.ts +9 -0
- package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.js +28 -0
- package/dist/_pkgs/affine-block-root/index.d.ts +1 -0
- package/dist/_pkgs/affine-block-root/index.js +1 -0
- package/dist/_pkgs/affine-block-root/keyboard/commands.js +9 -6
- package/dist/_pkgs/affine-block-root/preview/edgeless-root-preview-block.js +15 -2
- package/dist/_pkgs/affine-block-root/view.js +2 -0
- package/dist/_pkgs/affine-block-surface/adapters/markdown/element-adapter/type.d.ts +1 -1
- package/dist/_pkgs/affine-block-surface/element-model/index.d.ts +1 -1
- package/dist/_pkgs/affine-block-surface/element-model/index.js +1 -1
- package/dist/_pkgs/affine-block-surface/extensions/audit.js +13 -61
- package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.d.ts +2 -0
- package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.js +71 -0
- package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/index.d.ts +1 -0
- package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/index.js +1 -0
- package/dist/_pkgs/affine-block-surface/extensions/clipboard-config.js +4 -0
- package/dist/_pkgs/affine-block-surface/extensions/crud-extension.js +4 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.d.ts +12 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.js +27 -7
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.d.ts +2 -1
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.js +22 -3
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.d.ts +6 -3
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.js +4 -2
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/parts.d.ts +63 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/parts.js +67 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.d.ts +62 -5
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.js +98 -18
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.d.ts +14 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.js +82 -1
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.d.ts +2 -2
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.js +112 -10
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/translations.d.ts +13 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/translations.js +33 -0
- package/dist/_pkgs/affine-block-surface/extensions/index.d.ts +3 -0
- package/dist/_pkgs/affine-block-surface/extensions/index.js +3 -0
- package/dist/_pkgs/affine-block-surface/extensions/interchange-import.js +13 -1
- package/dist/_pkgs/affine-block-surface/extensions/legend.d.ts +8 -0
- package/dist/_pkgs/affine-block-surface/extensions/legend.js +59 -3
- package/dist/_pkgs/affine-block-surface/extensions/morph-toolbar.js +4 -0
- package/dist/_pkgs/affine-block-surface/extensions/reading-widget.d.ts +13 -6
- package/dist/_pkgs/affine-block-surface/extensions/reading-widget.js +26 -10
- package/dist/_pkgs/affine-block-surface/extensions/reading.d.ts +82 -6
- package/dist/_pkgs/affine-block-surface/extensions/reading.js +99 -21
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.d.ts +80 -0
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.js +248 -0
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.d.ts +82 -0
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.js +342 -0
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.d.ts +3 -0
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.js +3 -0
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.d.ts +137 -0
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.js +323 -0
- package/dist/_pkgs/affine-block-surface/extensions/svg-sketch-translations.d.ts +3 -0
- package/dist/_pkgs/affine-block-surface/extensions/svg-sketch-translations.js +23 -0
- package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.d.ts +112 -4
- package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.js +98 -19
- package/dist/_pkgs/affine-block-surface/extensions/user-layers/actions.d.ts +76 -0
- package/dist/_pkgs/affine-block-surface/extensions/user-layers/actions.js +299 -0
- package/dist/_pkgs/affine-block-surface/extensions/user-layers/active-layer.d.ts +20 -0
- package/dist/_pkgs/affine-block-surface/extensions/user-layers/active-layer.js +34 -0
- package/dist/_pkgs/affine-block-surface/extensions/user-layers/commands.d.ts +67 -0
- package/dist/_pkgs/affine-block-surface/extensions/user-layers/commands.js +172 -0
- package/dist/_pkgs/affine-block-surface/extensions/user-layers/creation.d.ts +40 -0
- package/dist/_pkgs/affine-block-surface/extensions/user-layers/creation.js +69 -0
- package/dist/_pkgs/affine-block-surface/extensions/user-layers/index.d.ts +5 -0
- package/dist/_pkgs/affine-block-surface/extensions/user-layers/index.js +5 -0
- package/dist/_pkgs/affine-block-surface/extensions/user-layers/translations.d.ts +10 -0
- package/dist/_pkgs/affine-block-surface/extensions/user-layers/translations.js +14 -0
- package/dist/_pkgs/affine-block-surface/framework-background/background-view.js +1 -1
- package/dist/_pkgs/affine-block-surface/framework-background/facts.d.ts +55 -2
- package/dist/_pkgs/affine-block-surface/framework-background/facts.js +63 -1
- package/dist/_pkgs/affine-block-surface/framework-background/fit.d.ts +36 -0
- package/dist/_pkgs/affine-block-surface/framework-background/fit.js +30 -0
- package/dist/_pkgs/affine-block-surface/framework-background/index.d.ts +1 -0
- package/dist/_pkgs/affine-block-surface/framework-background/index.js +1 -0
- package/dist/_pkgs/affine-block-surface/framework-background/stacking.d.ts +16 -8
- package/dist/_pkgs/affine-block-surface/framework-background/stacking.js +26 -14
- package/dist/_pkgs/affine-block-surface/renderer/canvas-renderer.js +17 -3
- package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.d.ts +3 -1
- package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.js +22 -2
- package/dist/_pkgs/affine-block-surface/renderer/element-highlight-overlay.js +2 -7
- package/dist/_pkgs/affine-block-surface/renderer/paint-predicate.d.ts +30 -0
- package/dist/_pkgs/affine-block-surface/renderer/paint-predicate.js +29 -0
- package/dist/_pkgs/affine-block-surface/surface-block.js +6 -0
- package/dist/_pkgs/affine-block-surface/surface-model.js +5 -0
- package/dist/_pkgs/affine-block-surface/surface-transformer.js +5 -0
- package/dist/_pkgs/affine-block-surface/tool/default-tool.js +28 -5
- package/dist/_pkgs/affine-block-surface/view.js +23 -1
- package/dist/_pkgs/affine-block-surface-ref/configs/tooltips.js +2 -2
- package/dist/_pkgs/affine-block-surface-ref/surface-ref-block.js +12 -2
- package/dist/_pkgs/affine-components/color-picker/palette-carousel.js +5 -0
- package/dist/_pkgs/affine-components/color-picker/styles.js +1 -1
- package/dist/_pkgs/affine-components/context-menu/button.js +17 -1
- package/dist/_pkgs/affine-components/filterable-list/index.js +30 -9
- package/dist/_pkgs/affine-components/icons/ai.js +3 -3
- package/dist/_pkgs/affine-components/icons/index.d.ts +0 -1
- package/dist/_pkgs/affine-components/icons/index.js +0 -1
- package/dist/_pkgs/affine-components/icons/list.js +7 -1
- package/dist/_pkgs/affine-components/icons/text.d.ts +1 -0
- package/dist/_pkgs/affine-components/icons/text.js +11 -0
- package/dist/_pkgs/affine-components/size-dropdown-menu/dropdown-menu.js +6 -1
- package/dist/_pkgs/affine-components/toolbar/index.d.ts +1 -1
- package/dist/_pkgs/affine-components/toolbar/index.js +1 -1
- package/dist/_pkgs/affine-components/toolbar/menu-button.d.ts +7 -0
- package/dist/_pkgs/affine-components/toolbar/menu-button.js +30 -0
- package/dist/_pkgs/affine-components/toolbar/picker-menu.d.ts +16 -1
- package/dist/_pkgs/affine-components/toolbar/picker-menu.js +2 -2
- package/dist/_pkgs/affine-components/toolbar/toolbar.d.ts +1 -0
- package/dist/_pkgs/affine-components/toolbar/toolbar.js +67 -0
- package/dist/_pkgs/affine-fragment-adapter-panel/adapter-panel.d.ts +2 -2
- package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card-title-editor.js +1 -1
- package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card.js +3 -3
- package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.d.ts +1 -1
- package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.js +8 -27
- package/dist/_pkgs/affine-fragment-frame-panel/index.d.ts +1 -0
- package/dist/_pkgs/affine-fragment-frame-panel/index.js +1 -0
- package/dist/_pkgs/affine-gfx-brush/toolbar/components/eraser/icons.js +1 -1
- package/dist/_pkgs/affine-gfx-connector/direction/direction-reveal.d.ts +11 -2
- package/dist/_pkgs/affine-gfx-connector/direction/direction-reveal.js +11 -2
- package/dist/_pkgs/affine-gfx-connector/element-renderer/connector-dom/index.js +3 -1
- package/dist/_pkgs/affine-gfx-connector/element-renderer/index.js +21 -4
- package/dist/_pkgs/affine-gfx-connector/text/edgeless-connector-label-editor.js +6 -4
- package/dist/_pkgs/affine-gfx-connector/toolbar/config.js +24 -8
- package/dist/_pkgs/affine-gfx-connector/translations.d.ts +3 -0
- package/dist/_pkgs/affine-gfx-connector/translations.js +23 -0
- package/dist/_pkgs/affine-gfx-group/command/group-api.js +52 -1
- package/dist/_pkgs/affine-gfx-mindmap/indicator-overlay/index.js +6 -2
- package/dist/_pkgs/affine-gfx-mindmap/toolbar/config.js +4 -2
- package/dist/_pkgs/affine-gfx-mindmap/translations.d.ts +6 -0
- package/dist/_pkgs/affine-gfx-mindmap/translations.js +10 -0
- package/dist/_pkgs/affine-gfx-shape/element-renderer/shape/index.js +21 -3
- package/dist/_pkgs/affine-gfx-shape/text/edgeless-shape-text-editor.js +2 -0
- package/dist/_pkgs/affine-gfx-shape/toolbar/config.js +5 -3
- package/dist/_pkgs/affine-gfx-shape/translations.d.ts +7 -0
- package/dist/_pkgs/affine-gfx-shape/translations.js +11 -0
- package/dist/_pkgs/affine-gfx-template/builtin/other.js +13 -7
- package/dist/_pkgs/affine-gfx-template/services/template-middlewares.d.ts +9 -0
- package/dist/_pkgs/affine-gfx-template/services/template-middlewares.js +23 -1
- package/dist/_pkgs/affine-gfx-template/services/template.js +2 -1
- package/dist/_pkgs/affine-gfx-template/toolbar/template-loading.js +1 -1
- package/dist/_pkgs/affine-gfx-template/translations.d.ts +5 -0
- package/dist/_pkgs/affine-gfx-template/translations.js +38 -0
- package/dist/_pkgs/affine-gfx-text/edgeless-text-editor.js +5 -3
- package/dist/_pkgs/affine-gfx-text/element-renderer/index.js +20 -3
- package/dist/_pkgs/affine-gfx-text/element-renderer/utils.d.ts +67 -1
- package/dist/_pkgs/affine-gfx-text/element-renderer/utils.js +101 -0
- package/dist/_pkgs/affine-gfx-text/toolbar/actions.d.ts +11 -0
- package/dist/_pkgs/affine-gfx-text/toolbar/actions.js +56 -3
- package/dist/_pkgs/affine-gfx-text/toolbar/config.d.ts +11 -0
- package/dist/_pkgs/affine-gfx-text/toolbar/config.js +1 -1
- package/dist/_pkgs/affine-gfx-text/translations.d.ts +8 -0
- package/dist/_pkgs/affine-gfx-text/translations.js +12 -0
- package/dist/_pkgs/affine-inline-latex/latex-node/latex-editor-menu.js +2 -1
- package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.d.ts +3 -0
- package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.js +31 -0
- package/dist/_pkgs/affine-inline-preset/adapters/html/inline-delta.d.ts +4 -0
- package/dist/_pkgs/affine-inline-preset/adapters/html/inline-delta.js +14 -0
- package/dist/_pkgs/affine-inline-preset/command/config.js +21 -3
- package/dist/_pkgs/affine-inline-preset/command/index.d.ts +1 -1
- package/dist/_pkgs/affine-inline-preset/command/index.js +1 -1
- package/dist/_pkgs/affine-inline-preset/command/text-style.d.ts +2 -1
- package/dist/_pkgs/affine-inline-preset/command/text-style.js +1 -0
- package/dist/_pkgs/affine-inline-preset/default-inline-manager.js +2 -1
- package/dist/_pkgs/affine-inline-preset/inline-spec.d.ts +4 -0
- package/dist/_pkgs/affine-inline-preset/inline-spec.js +14 -0
- package/dist/_pkgs/affine-inline-preset/translations.d.ts +2 -2
- package/dist/_pkgs/affine-inline-preset/translations.js +2 -2
- package/dist/_pkgs/affine-model/blocks/attachment/attachment-model.js +2 -0
- package/dist/_pkgs/affine-model/blocks/bookmark/bookmark-model.js +2 -0
- package/dist/_pkgs/affine-model/blocks/edgeless-text/edgeless-text-model.d.ts +1 -1
- package/dist/_pkgs/affine-model/blocks/edgeless-text/edgeless-text-model.js +2 -0
- package/dist/_pkgs/affine-model/blocks/embed/iframe/iframe-model.js +2 -0
- package/dist/_pkgs/affine-model/blocks/frame/frame-model.js +2 -0
- package/dist/_pkgs/affine-model/blocks/image/image-model.js +2 -0
- package/dist/_pkgs/affine-model/blocks/latex/latex-model.js +2 -0
- package/dist/_pkgs/affine-model/blocks/note/note-model.js +2 -0
- package/dist/_pkgs/affine-model/consts/text.d.ts +41 -2
- package/dist/_pkgs/affine-model/consts/text.js +50 -1
- package/dist/_pkgs/affine-model/elements/shape/shape.d.ts +6 -1
- package/dist/_pkgs/affine-model/elements/shape/shape.js +14 -1
- package/dist/_pkgs/affine-model/elements/text/text.d.ts +6 -1
- package/dist/_pkgs/affine-model/elements/text/text.js +13 -1
- package/dist/_pkgs/affine-model/utils/helper.js +2 -0
- package/dist/_pkgs/affine-rich-text/conversion.d.ts +25 -0
- package/dist/_pkgs/affine-rich-text/conversion.js +9 -0
- package/dist/_pkgs/affine-rich-text/index.d.ts +1 -1
- package/dist/_pkgs/affine-rich-text/index.js +1 -1
- package/dist/_pkgs/affine-shared/commands/model-crud/replace-selected-text-with-blocks.d.ts +1 -1
- package/dist/_pkgs/affine-shared/services/canvas-grid.d.ts +63 -0
- package/dist/_pkgs/affine-shared/services/canvas-grid.js +109 -0
- package/dist/_pkgs/affine-shared/services/canvas-local-visibility.d.ts +64 -0
- package/dist/_pkgs/affine-shared/services/canvas-local-visibility.js +192 -0
- package/dist/_pkgs/affine-shared/services/edit-props-store.d.ts +27 -0
- package/dist/_pkgs/affine-shared/services/edit-props-store.js +34 -0
- package/dist/_pkgs/affine-shared/services/editor-setting-service.d.ts +3 -0
- package/dist/_pkgs/affine-shared/services/editor-setting-service.js +7 -0
- package/dist/_pkgs/affine-shared/services/feature-flag-service.d.ts +4 -0
- package/dist/_pkgs/affine-shared/services/font-loader/config.d.ts +13 -2
- package/dist/_pkgs/affine-shared/services/font-loader/config.js +43 -54
- package/dist/_pkgs/affine-shared/services/index.d.ts +3 -0
- package/dist/_pkgs/affine-shared/services/index.js +3 -0
- package/dist/_pkgs/affine-shared/services/selection-pane-service.d.ts +44 -0
- package/dist/_pkgs/affine-shared/services/selection-pane-service.js +28 -0
- package/dist/_pkgs/affine-shared/services/telemetry-service/lifecycle.d.ts +69 -0
- package/dist/_pkgs/affine-shared/services/telemetry-service/telemetry-service.d.ts +2 -2
- package/dist/_pkgs/affine-shared/services/theme-service.d.ts +19 -0
- package/dist/_pkgs/affine-shared/services/theme-service.js +24 -0
- package/dist/_pkgs/affine-shared/services/translation-service/chrome.d.ts +25 -0
- package/dist/_pkgs/affine-shared/services/translation-service/chrome.js +90 -0
- package/dist/_pkgs/affine-shared/styles/index.d.ts +1 -0
- package/dist/_pkgs/affine-shared/styles/index.js +1 -0
- package/dist/_pkgs/affine-shared/styles/panel-header.d.ts +31 -0
- package/dist/_pkgs/affine-shared/styles/panel-header.js +61 -0
- package/dist/_pkgs/affine-shared/styles/text.js +7 -7
- package/dist/_pkgs/affine-shared/types/index.d.ts +6 -0
- package/dist/_pkgs/affine-shared/utils/canvas-export-colors.d.ts +26 -0
- package/dist/_pkgs/affine-shared/utils/canvas-export-colors.js +127 -0
- package/dist/_pkgs/affine-shared/utils/file/filesys.d.ts +8 -11
- package/dist/_pkgs/affine-shared/utils/file/filesys.js +8 -11
- package/dist/_pkgs/affine-shared/utils/index.d.ts +2 -0
- package/dist/_pkgs/affine-shared/utils/index.js +2 -0
- package/dist/_pkgs/affine-shared/utils/label-mode.d.ts +47 -0
- package/dist/_pkgs/affine-shared/utils/label-mode.js +55 -0
- package/dist/_pkgs/affine-shared/utils/model/merge-to-code-model.js +7 -1
- package/dist/_pkgs/affine-shared/utils/model/transform-model.js +5 -0
- package/dist/_pkgs/affine-widget-edgeless-dragging-area/edgeless-dragging-area-rect.js +2 -2
- package/dist/_pkgs/affine-widget-edgeless-selected-rect/utils.js +15 -4
- package/dist/_pkgs/affine-widget-edgeless-toolbar/catalogue/artefact-catalogue-widget.js +25 -49
- package/dist/_pkgs/affine-widget-edgeless-toolbar/config/types.d.ts +15 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/config/utils.d.ts +1 -1
- package/dist/_pkgs/affine-widget-edgeless-toolbar/config/utils.js +7 -2
- package/dist/_pkgs/affine-widget-edgeless-toolbar/effects.d.ts +4 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/effects.js +4 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/index.d.ts +4 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/index.js +4 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/panel/font-family-panel.d.ts +18 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/panel/font-family-panel.js +52 -6
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.d.ts +61 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.js +91 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.d.ts +17 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.js +95 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.d.ts +10 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.js +31 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.d.ts +26 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.js +82 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.d.ts +170 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.js +1381 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.d.ts +58 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.js +171 -1
- package/dist/_pkgs/affine-widget-edgeless-toolbar/view.js +10 -0
- package/dist/_pkgs/affine-widget-frame-title/edgeless-frame-title-editor.js +2 -1
- package/dist/_pkgs/affine-widget-note-slicer/note-slicer.js +7 -3
- package/dist/_pkgs/affine-widget-slash-menu/translations.d.ts +16 -0
- package/dist/_pkgs/affine-widget-slash-menu/translations.js +23 -1
- package/dist/_pkgs/affine-widget-toolbar/utils.js +57 -14
- package/dist/_pkgs/data-view/core/detail/field.js +2 -1
- package/dist/_pkgs/data-view/core/filter/literal/define.js +3 -1
- package/dist/_pkgs/data-view/core/group-by/renderer/boolean-group.js +1 -1
- package/dist/_pkgs/data-view/property-presets/checkbox/cell-renderer.js +8 -2
- package/dist/_pkgs/data-view/view-presets/kanban/pc/cell.js +1 -1
- package/dist/_pkgs/data-view/view-presets/kanban/pc/controller/drag.js +2 -1
- package/dist/_pkgs/data-view/view-presets/table/pc/controller/drag.js +2 -1
- package/dist/_pkgs/data-view/view-presets/table/pc/controller/selection.js +1 -1
- package/dist/_pkgs/data-view/view-presets/table/pc/header/vertical-indicator.js +2 -1
- package/dist/_pkgs/data-view/view-presets/table/pc/row/row-select-checkbox.js +3 -1
- package/dist/_pkgs/data-view/view-presets/table/pc-virtual/controller/drag.js +2 -1
- package/dist/_pkgs/data-view/view-presets/table/pc-virtual/controller/selection.js +1 -1
- package/dist/_pkgs/data-view/view-presets/table/pc-virtual/group/top/header/vertical-indicator.js +2 -1
- package/dist/_pkgs/data-view/view-presets/table/pc-virtual/row/row-header.js +3 -1
- package/dist/_pkgs/std/gfx/controller.d.ts +13 -0
- package/dist/_pkgs/std/gfx/controller.js +22 -2
- package/dist/_pkgs/std/gfx/grid.d.ts +31 -2
- package/dist/_pkgs/std/gfx/index.d.ts +3 -1
- package/dist/_pkgs/std/gfx/index.js +3 -1
- package/dist/_pkgs/std/gfx/interactivity/manager.js +7 -0
- package/dist/_pkgs/std/gfx/layer.js +73 -5
- package/dist/_pkgs/std/gfx/local-visibility.d.ts +88 -0
- package/dist/_pkgs/std/gfx/local-visibility.js +217 -0
- package/dist/_pkgs/std/gfx/model/gfx-block-model.d.ts +13 -0
- package/dist/_pkgs/std/gfx/model/surface/element-model.d.ts +34 -0
- package/dist/_pkgs/std/gfx/model/surface/element-model.js +65 -1
- package/dist/_pkgs/std/gfx/model/surface/role.d.ts +10 -5
- package/dist/_pkgs/std/gfx/model/surface/surface-model.d.ts +27 -0
- package/dist/_pkgs/std/gfx/model/surface/surface-model.js +43 -0
- package/dist/_pkgs/std/gfx/model/surface/user-layers.d.ts +68 -0
- package/dist/_pkgs/std/gfx/model/surface/user-layers.js +127 -0
- package/dist/_pkgs/std/utils/layer.d.ts +10 -0
- package/dist/_pkgs/std/utils/layer.js +64 -13
- package/dist/_pkgs/std/view/element/gfx-block-component.js +10 -2
- package/dist/commands.js +6 -2
- package/dist/translations.js +15 -6
- package/package.json +13 -2
- package/dist/_pkgs/affine-components/icons/file-icons-rc.d.ts +0 -1
- package/dist/_pkgs/affine-components/icons/file-icons-rc.js +0 -130
- package/dist/_pkgs/affine-shared/test-utils/affine-template.d.ts +0 -6
- package/dist/_pkgs/affine-shared/test-utils/affine-template.js +0 -258
- package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.d.ts +0 -8
- package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.js +0 -81
- package/dist/_pkgs/affine-shared/test-utils/create-test-host.d.ts +0 -23
- package/dist/_pkgs/affine-shared/test-utils/create-test-host.js +0 -187
- package/dist/_pkgs/affine-shared/test-utils/index.d.ts +0 -3
- package/dist/_pkgs/affine-shared/test-utils/index.js +0 -3
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
import { FrameworkBackgroundElementModel } from '../../../affine-model/index.js';
|
|
2
2
|
import { Bound } from '../../../global/gfx/index.js';
|
|
3
3
|
import type { BlockStdScope } from '../../../std/index.js';
|
|
4
|
-
import { type GfxPrimitiveElementModel } from '../../../std/gfx/index.js';
|
|
4
|
+
import { type GfxBlockElementModel, type GfxPrimitiveElementModel } from '../../../std/gfx/index.js';
|
|
5
|
+
import type { ExtensionType } from '../../../store/index.js';
|
|
6
|
+
import { CanvasRenderer } from '../../renderer/canvas-renderer.js';
|
|
7
|
+
import { type BoardSvgExportOptions } from './parts.js';
|
|
5
8
|
export interface BoardSvgExport {
|
|
6
9
|
/** A standalone SVG document. */
|
|
7
10
|
svg: string;
|
|
8
11
|
/** The world-space rectangle the document covers. */
|
|
9
12
|
bound: Bound;
|
|
10
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* How a BLOCK paints itself into the export's 2D context, in model units, the
|
|
16
|
+
* block's top-left at the origin of `matrix`.
|
|
17
|
+
*
|
|
18
|
+
* Blocks are DOM, so the canvas renderer never sees them (ADR 0025,
|
|
19
|
+
* Consequences). The one block the export draws anyway is the edgeless text —
|
|
20
|
+
* what the text tool creates by default — and its painter lives with it, in
|
|
21
|
+
* `@labre/affine-block-edgeless-text`, because the text metrics it needs
|
|
22
|
+
* (`@labre/affine-gfx-text`) sit ABOVE this package. Keyed by flavour; a block
|
|
23
|
+
* with no painter registered is simply not drawn.
|
|
24
|
+
*/
|
|
25
|
+
export type BlockSvgPainter<T extends GfxBlockElementModel = GfxBlockElementModel> = (model: T, ctx: CanvasRenderingContext2D, matrix: DOMMatrix, renderer: CanvasRenderer) => void;
|
|
26
|
+
export declare const BlockSvgPainterIdentifier: import("../../../global/di/types.js").ServiceIdentifier<BlockSvgPainter<GfxBlockElementModel<import("../../../std/gfx/index.js").GfxCompatibleProps>>> & (<U extends BlockSvgPainter<GfxBlockElementModel<import("../../../std/gfx/index.js").GfxCompatibleProps>> = BlockSvgPainter<GfxBlockElementModel<import("../../../std/gfx/index.js").GfxCompatibleProps>>>(variant: import("../../../global/di/types.js").ServiceVariant) => import("../../../global/di/types.js").ServiceIdentifier<U>);
|
|
27
|
+
export declare function BlockSvgPainterExtension<T extends GfxBlockElementModel>(flavour: string, painter: BlockSvgPainter<T>): ExtensionType;
|
|
11
28
|
/**
|
|
12
29
|
* The canvas elements that make up `board`'s picture, in paint order.
|
|
13
30
|
*
|
|
@@ -28,14 +45,54 @@ export interface BoardSvgExport {
|
|
|
28
45
|
*/
|
|
29
46
|
export declare function selectBoardElements<T extends GfxPrimitiveElementModel>(board: FrameworkBackgroundElementModel, candidates: readonly T[]): (FrameworkBackgroundElementModel | T)[];
|
|
30
47
|
/**
|
|
31
|
-
* The
|
|
32
|
-
*
|
|
33
|
-
*
|
|
48
|
+
* The frame, widened to the union of what is painted: a Wardley label
|
|
49
|
+
* overhanging the right edge, or a connector ending just outside, is part of
|
|
50
|
+
* the picture and must not be cut off. The frame is the board's — or, with
|
|
51
|
+
* "Framework elements" switched off, the first thing still drawn.
|
|
34
52
|
*/
|
|
35
|
-
export declare function exportBoundOf(
|
|
53
|
+
export declare function exportBoundOf(frame: {
|
|
54
|
+
readonly xywh: string;
|
|
55
|
+
}, elements: readonly {
|
|
56
|
+
readonly xywh: string;
|
|
57
|
+
}[]): Bound;
|
|
36
58
|
/**
|
|
37
59
|
* The selected board and everything painted within its frame, as an SVG
|
|
38
60
|
* document — a true vector export, produced by replaying the very element
|
|
39
61
|
* renderers the canvas uses into an SVG-emitting 2D context.
|
|
62
|
+
*
|
|
63
|
+
* `options` says which parts are drawn (`parts.ts`). `null` when they leave
|
|
64
|
+
* nothing to draw: an empty file is not a picture of anything.
|
|
65
|
+
*
|
|
66
|
+
* Without `options` every part is drawn, the board among them, so the 0.43
|
|
67
|
+
* call shape `renderBoardSvg(std, board).svg` keeps its non-null return
|
|
68
|
+
* (`render-board-svg-signature.unit.spec.ts`). Only the overload that takes
|
|
69
|
+
* options can answer `null`.
|
|
40
70
|
*/
|
|
41
71
|
export declare function renderBoardSvg(std: BlockStdScope, board: FrameworkBackgroundElementModel): BoardSvgExport;
|
|
72
|
+
export declare function renderBoardSvg(std: BlockStdScope, board: FrameworkBackgroundElementModel, options: Readonly<BoardSvgExportOptions>): BoardSvgExport | null;
|
|
73
|
+
/**
|
|
74
|
+
* What an element's group says about it in the file (ADR 0032 §6): its id, its
|
|
75
|
+
* type, its role, its stored bound in the FILE's coordinates, the two ends of
|
|
76
|
+
* a connector and the group it belongs to — base-class fields only, so every
|
|
77
|
+
* board's SVG carries them and no framework is named here.
|
|
78
|
+
*
|
|
79
|
+
* Ids and vocabulary, never prose: no `pivotDocId` (its contract forbids an
|
|
80
|
+
* exporter to read it), no `interchange`, no tag, no link, no text — a name is
|
|
81
|
+
* read back from the `<text>` the renderer already drew.
|
|
82
|
+
*/
|
|
83
|
+
export declare function boardSvgMarkers(element: {
|
|
84
|
+
id: string;
|
|
85
|
+
xywh: string;
|
|
86
|
+
type?: string;
|
|
87
|
+
flavour?: string;
|
|
88
|
+
role?: string;
|
|
89
|
+
group?: {
|
|
90
|
+
id: string;
|
|
91
|
+
} | null;
|
|
92
|
+
source?: {
|
|
93
|
+
id?: string;
|
|
94
|
+
} | null;
|
|
95
|
+
target?: {
|
|
96
|
+
id?: string;
|
|
97
|
+
} | null;
|
|
98
|
+
}, bound: Bound): Record<string, string>;
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { FrameworkBackgroundElementModel } from '../../../affine-model/index.js';
|
|
2
|
+
import { createIdentifier } from '../../../global/di/index.js';
|
|
2
3
|
import { Bound } from '../../../global/gfx/index.js';
|
|
3
4
|
import { GfxControllerIdentifier, } from '../../../std/gfx/index.js';
|
|
4
5
|
import { CanvasRenderer } from '../../renderer/canvas-renderer.js';
|
|
5
6
|
import { RoughCanvas } from '../../utils/rough/canvas.js';
|
|
7
|
+
import { DEFAULT_BOARD_SVG_EXPORT_OPTIONS, selectBoardSvgParts, } from './parts.js';
|
|
6
8
|
import { createSvgContext, runWithRecordingPath2D } from './svg-context.js';
|
|
9
|
+
export const BlockSvgPainterIdentifier = createIdentifier('block-svg-painter');
|
|
10
|
+
export function BlockSvgPainterExtension(flavour, painter) {
|
|
11
|
+
return {
|
|
12
|
+
setup: di => {
|
|
13
|
+
di.addImpl(BlockSvgPainterIdentifier(flavour), () => painter);
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** The blocks the export redraws, all of them "other texts" (`parts.ts`). */
|
|
18
|
+
const SVG_TEXT_BLOCK_FLAVOURS = ['affine:edgeless-text'];
|
|
7
19
|
/**
|
|
8
20
|
* The canvas elements that make up `board`'s picture, in paint order.
|
|
9
21
|
*
|
|
@@ -34,37 +46,105 @@ export function selectBoardElements(board, candidates) {
|
|
|
34
46
|
: [board, ...kept];
|
|
35
47
|
}
|
|
36
48
|
/**
|
|
37
|
-
* The
|
|
38
|
-
*
|
|
39
|
-
*
|
|
49
|
+
* The frame, widened to the union of what is painted: a Wardley label
|
|
50
|
+
* overhanging the right edge, or a connector ending just outside, is part of
|
|
51
|
+
* the picture and must not be cut off. The frame is the board's — or, with
|
|
52
|
+
* "Framework elements" switched off, the first thing still drawn.
|
|
40
53
|
*/
|
|
41
|
-
export function exportBoundOf(
|
|
42
|
-
let bound = Bound.deserialize(
|
|
54
|
+
export function exportBoundOf(frame, elements) {
|
|
55
|
+
let bound = Bound.deserialize(frame.xywh);
|
|
43
56
|
for (const element of elements) {
|
|
44
57
|
bound = bound.unite(Bound.deserialize(element.xywh));
|
|
45
58
|
}
|
|
46
59
|
return bound;
|
|
47
60
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
* document — a true vector export, produced by replaying the very element
|
|
51
|
-
* renderers the canvas uses into an SVG-emitting 2D context.
|
|
52
|
-
*/
|
|
53
|
-
export function renderBoardSvg(std, board) {
|
|
61
|
+
export function renderBoardSvg(std, board, given) {
|
|
62
|
+
const options = given ?? DEFAULT_BOARD_SVG_EXPORT_OPTIONS;
|
|
54
63
|
const gfx = std.get(GfxControllerIdentifier);
|
|
55
64
|
const renderer = gfx.surfaceComponent?.renderer;
|
|
56
65
|
if (!(renderer instanceof CanvasRenderer)) {
|
|
57
66
|
throw new Error('SVG export needs the surface to be painted by a CanvasRenderer.');
|
|
58
67
|
}
|
|
68
|
+
const frame = Bound.deserialize(board.xywh);
|
|
59
69
|
// Already sorted by `layer.compare`, which is the canvas' own z-order.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
70
|
+
// What you see is what you export (ADR 0031): what this viewer hid is
|
|
71
|
+
// neither painted nor allowed to widen the picture. The board itself stays,
|
|
72
|
+
// it is the sheet being exported.
|
|
73
|
+
const candidates = gfx
|
|
74
|
+
.getElementsByBound(frame, { type: 'canvas' })
|
|
75
|
+
.filter(element => element === board || !gfx.localVisibility.isHidden(element));
|
|
76
|
+
const textBlocks = gfx
|
|
77
|
+
.getElementsByBound(frame, { type: 'block' })
|
|
78
|
+
.filter(block => SVG_TEXT_BLOCK_FLAVOURS.includes(block.flavour) &&
|
|
79
|
+
!gfx.localVisibility.isHidden(block));
|
|
80
|
+
const { elements, textBlocks: texts } = selectBoardSvgParts(board, selectBoardElements(board, candidates), textBlocks, options, element => element.groups);
|
|
81
|
+
const drawn = [...elements, ...texts];
|
|
82
|
+
if (!drawn.length) {
|
|
83
|
+
// Unreachable without options: the board is always selected and answers
|
|
84
|
+
// to "Framework elements". Thrown rather than returned, so the overload
|
|
85
|
+
// that promises an export never hands back `null`.
|
|
86
|
+
if (given === undefined) {
|
|
87
|
+
throw new Error('SVG export drew nothing with every part on: the board itself was not selected.');
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const bound = exportBoundOf(options.framework ? board : drawn[0], drawn);
|
|
65
92
|
return runWithRecordingPath2D(() => {
|
|
66
|
-
const { ctx, canvas, serialize } = createSvgContext(bound.w, bound.h);
|
|
67
|
-
|
|
93
|
+
const { ctx, canvas, serialize, markRoot, markedGroup } = createSvgContext(bound.w, bound.h);
|
|
94
|
+
const rc = new RoughCanvas(canvas);
|
|
95
|
+
markRoot();
|
|
96
|
+
// One model per pass, each inside a group carrying its markers (ADR 0032
|
|
97
|
+
// §6), in the canvas' own z-order: a text block is painted at its layer
|
|
98
|
+
// index, between the elements it sits between on screen.
|
|
99
|
+
const blocks = new Set(texts);
|
|
100
|
+
for (const model of [...elements, ...texts].sort(gfx.layer.compare)) {
|
|
101
|
+
if (!blocks.has(model)) {
|
|
102
|
+
const element = model;
|
|
103
|
+
markedGroup(boardSvgMarkers(element, bound), () => renderer.renderBoundTo(ctx, rc, bound, [element]));
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const block = model;
|
|
107
|
+
const paint = std.getOptional(BlockSvgPainterIdentifier(block.flavour));
|
|
108
|
+
if (!paint)
|
|
109
|
+
continue;
|
|
110
|
+
markedGroup(boardSvgMarkers(block, bound), () => {
|
|
111
|
+
ctx.save();
|
|
112
|
+
paint(block, ctx, new DOMMatrix().translate(block.x - bound.x, block.y - bound.y), renderer);
|
|
113
|
+
ctx.restore();
|
|
114
|
+
});
|
|
115
|
+
}
|
|
68
116
|
return { svg: serialize(), bound };
|
|
69
117
|
});
|
|
70
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* What an element's group says about it in the file (ADR 0032 §6): its id, its
|
|
121
|
+
* type, its role, its stored bound in the FILE's coordinates, the two ends of
|
|
122
|
+
* a connector and the group it belongs to — base-class fields only, so every
|
|
123
|
+
* board's SVG carries them and no framework is named here.
|
|
124
|
+
*
|
|
125
|
+
* Ids and vocabulary, never prose: no `pivotDocId` (its contract forbids an
|
|
126
|
+
* exporter to read it), no `interchange`, no tag, no link, no text — a name is
|
|
127
|
+
* read back from the `<text>` the renderer already drew.
|
|
128
|
+
*/
|
|
129
|
+
export function boardSvgMarkers(element, bound) {
|
|
130
|
+
const own = Bound.deserialize(element.xywh);
|
|
131
|
+
const markers = {
|
|
132
|
+
'data-labre-id': element.id,
|
|
133
|
+
'data-labre-type': element.type ?? element.flavour ?? '',
|
|
134
|
+
'data-labre-xywh': JSON.stringify([
|
|
135
|
+
own.x - bound.x,
|
|
136
|
+
own.y - bound.y,
|
|
137
|
+
own.w,
|
|
138
|
+
own.h,
|
|
139
|
+
]),
|
|
140
|
+
};
|
|
141
|
+
if (element.role)
|
|
142
|
+
markers['data-labre-role'] = element.role;
|
|
143
|
+
if (element.source?.id)
|
|
144
|
+
markers['data-labre-source'] = element.source.id;
|
|
145
|
+
if (element.target?.id)
|
|
146
|
+
markers['data-labre-target'] = element.target.id;
|
|
147
|
+
if (element.group?.id)
|
|
148
|
+
markers['data-labre-group'] = element.group.id;
|
|
149
|
+
return markers;
|
|
150
|
+
}
|
|
@@ -9,6 +9,14 @@ export interface SvgContext {
|
|
|
9
9
|
canvas: HTMLCanvasElement;
|
|
10
10
|
/** The finished document, with `viewBox`, `width`/`height` in px and `xmlns`. */
|
|
11
11
|
serialize(): string;
|
|
12
|
+
/** Stamps the root `<svg>` with the marker version (ADR 0032 §6). */
|
|
13
|
+
markRoot(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Runs `draw` inside a new `<g>` carrying `attributes`, then closes it —
|
|
16
|
+
* however many groups `draw` left open (`renderBoundTo` restores one more
|
|
17
|
+
* time than it saves), so the next element starts beside this one.
|
|
18
|
+
*/
|
|
19
|
+
markedGroup(attributes: Record<string, string>, draw: () => void): void;
|
|
12
20
|
}
|
|
13
21
|
/** Marks a {@link RecordingPath2D} and carries what it recorded. */
|
|
14
22
|
declare const RECORDED_D: unique symbol;
|
|
@@ -46,4 +54,10 @@ export declare function readLineDash(lineDash: unknown): number[];
|
|
|
46
54
|
* handed to {@link CanvasRenderer.renderBoundTo}.
|
|
47
55
|
*/
|
|
48
56
|
export declare function createSvgContext(width: number, height: number): SvgContext;
|
|
57
|
+
/**
|
|
58
|
+
* The marker version an export writes on its root (`data-labre-svg`), and the
|
|
59
|
+
* one a reader of it must know (ADR 0032 §6). Bumped only when the meaning of
|
|
60
|
+
* a marker changes; adding one is not a new version.
|
|
61
|
+
*/
|
|
62
|
+
export declare const BOARD_SVG_MARKER_VERSION = "1";
|
|
49
63
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseCssColor } from '../../../affine-shared/adapters/index.js';
|
|
1
2
|
import { Context } from 'svgcanvas/dist/svgcanvas.esm.js';
|
|
2
3
|
const PATH_OPS = ['fill', 'stroke', 'clip'];
|
|
3
4
|
/** Marks a {@link RecordingPath2D} and carries what it recorded. */
|
|
@@ -203,6 +204,63 @@ export function readLineDash(lineDash) {
|
|
|
203
204
|
return [];
|
|
204
205
|
return lineDash.split(',').map(Number);
|
|
205
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* A colour with alpha, rewritten as the comma `rgba()` svgcanvas recognises;
|
|
209
|
+
* any other value comes back unchanged.
|
|
210
|
+
*
|
|
211
|
+
* svgcanvas splits only a value containing `rgba` into `rgb()` plus an
|
|
212
|
+
* `-opacity` attribute and writes everything else verbatim, so an 8-digit hex
|
|
213
|
+
* (`AREA_FILL`, `PIPELINE_FILL`, the DDD zones) or `transparent` reached the
|
|
214
|
+
* file as-is. Neither is an SVG 1.1 paint, and an importer that sticks to 1.1
|
|
215
|
+
* (PowerPoint's) replaces it with its own theme colour. The alpha is fixed to
|
|
216
|
+
* six decimals because svgcanvas' parser reads no exponent (`1e-7`).
|
|
217
|
+
*/
|
|
218
|
+
function toSvgColor(value) {
|
|
219
|
+
const parsed = parseCssColor(value);
|
|
220
|
+
if (!parsed || parsed.alpha === 1)
|
|
221
|
+
return value;
|
|
222
|
+
const { r, g, b, alpha } = parsed;
|
|
223
|
+
return `rgba(${r}, ${g}, ${b}, ${Number(alpha.toFixed(6))})`;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* {@link toSvgColor} for a `fill` or `stroke`, where a fully transparent colour
|
|
227
|
+
* is `none`: the one invisible paint every SVG reader honours. svgcanvas births
|
|
228
|
+
* every node with `fill="none" stroke="none"` and skips a stroke equal to that
|
|
229
|
+
* default, so an invisible second pass leaves an earlier paint in place — as
|
|
230
|
+
* painting it on a canvas would.
|
|
231
|
+
*/
|
|
232
|
+
function toSvgPaint(value) {
|
|
233
|
+
if (typeof value !== 'string')
|
|
234
|
+
return value;
|
|
235
|
+
return parseCssColor(value)?.alpha === 0 ? 'none' : toSvgColor(value);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Routes every `fillStyle` / `strokeStyle` write — including the ones
|
|
239
|
+
* svgcanvas' own `restore()` makes — and every gradient stop through the
|
|
240
|
+
* converters above. Gradients and patterns pass through untouched.
|
|
241
|
+
*/
|
|
242
|
+
function installStaticPaint(context) {
|
|
243
|
+
for (const key of ['fillStyle', 'strokeStyle']) {
|
|
244
|
+
let current = toSvgPaint(context[key]);
|
|
245
|
+
Object.defineProperty(context, key, {
|
|
246
|
+
configurable: true,
|
|
247
|
+
enumerable: true,
|
|
248
|
+
get: () => current,
|
|
249
|
+
set: (value) => {
|
|
250
|
+
current = toSvgPaint(value);
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
for (const key of ['createLinearGradient', 'createRadialGradient']) {
|
|
255
|
+
const create = context[key];
|
|
256
|
+
context[key] = (...args) => {
|
|
257
|
+
const gradient = create.apply(context, args);
|
|
258
|
+
const addColorStop = gradient.addColorStop;
|
|
259
|
+
gradient.addColorStop = (offset, color) => addColorStop.call(gradient, offset, toSvgColor(color));
|
|
260
|
+
return gradient;
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
}
|
|
206
264
|
/** Adds `viewBox` / `xmlns` / px units to the root `<svg>` if they are missing. */
|
|
207
265
|
function finishSvg(svg, width, height) {
|
|
208
266
|
return (svg
|
|
@@ -248,10 +306,33 @@ export function createSvgContext(width, height) {
|
|
|
248
306
|
// The one Canvas2D method a renderer calls that svgcanvas lacks — see
|
|
249
307
|
// `readLineDash`. Without it a single `getLineDash()` aborts the export.
|
|
250
308
|
context.getLineDash = () => readLineDash(context.lineDash);
|
|
251
|
-
|
|
309
|
+
const internals = context;
|
|
310
|
+
installPathOps(internals);
|
|
311
|
+
installStaticPaint(context);
|
|
252
312
|
return {
|
|
253
313
|
ctx,
|
|
254
314
|
canvas: ctx.canvas,
|
|
255
315
|
serialize: () => finishSvg(context.getSerializedSvg(true), width, height),
|
|
316
|
+
markRoot: () => internals
|
|
317
|
+
.getSvg()
|
|
318
|
+
.setAttribute('data-labre-svg', BOARD_SVG_MARKER_VERSION),
|
|
319
|
+
markedGroup: (attributes, draw) => {
|
|
320
|
+
const depth = internals.__groupStack.length;
|
|
321
|
+
// svgcanvas' `save()` IS a new `<g>`, and it becomes the current node.
|
|
322
|
+
internals.save();
|
|
323
|
+
const group = internals.__currentElement;
|
|
324
|
+
for (const [name, value] of Object.entries(attributes)) {
|
|
325
|
+
group.setAttribute(name, value);
|
|
326
|
+
}
|
|
327
|
+
draw();
|
|
328
|
+
while (internals.__groupStack.length > depth)
|
|
329
|
+
internals.restore();
|
|
330
|
+
},
|
|
256
331
|
};
|
|
257
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* The marker version an export writes on its root (`data-labre-svg`), and the
|
|
335
|
+
* one a reader of it must know (ADR 0032 §6). Bumped only when the meaning of
|
|
336
|
+
* a marker changes; adding one is not a new version.
|
|
337
|
+
*/
|
|
338
|
+
export const BOARD_SVG_MARKER_VERSION = '1';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type ToolbarContext } from '../../../affine-shared/services/index.js';
|
|
1
|
+
import { type ToolbarAction, type ToolbarContext } from '../../../affine-shared/services/index.js';
|
|
2
2
|
export declare const exportSvgToolbarConfig: {
|
|
3
|
-
readonly actions: [
|
|
3
|
+
readonly actions: [ToolbarAction];
|
|
4
4
|
readonly when: (ctx: ToolbarContext) => boolean;
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { menu, popMenu, popupTargetFromElement, } from '../../../affine-components/context-menu/index.js';
|
|
1
2
|
import { FrameworkBackgroundElementModel } from '../../../affine-model/index.js';
|
|
2
|
-
import {
|
|
3
|
-
import { BlockFlavourIdentifier } from '../../../std/index.js';
|
|
3
|
+
import { ActionPlacement, ToolbarModuleExtension, toolbarModuleKey, translateKey, } from '../../../affine-shared/services/index.js';
|
|
4
|
+
import { BlockFlavourIdentifier, getRegisteredCommands, runCommand, } from '../../../std/index.js';
|
|
5
|
+
import { signal } from '@preact/signals-core';
|
|
4
6
|
import { html } from 'lit';
|
|
7
|
+
import { DEFAULT_BOARD_SVG_EXPORT_OPTIONS, } from './parts.js';
|
|
8
|
+
import { EXPORT_SVG_CONFIRM, EXPORT_SVG_OPTION_FRAMEWORK, EXPORT_SVG_OPTION_SHAPES, EXPORT_SVG_OPTION_TEXTS, } from './translations.js';
|
|
5
9
|
/**
|
|
6
10
|
* A sheet with an arrow leaving it: the board, on its way out of the editor.
|
|
7
11
|
*
|
|
@@ -27,15 +31,113 @@ const ExportSvgIcon = html `<svg
|
|
|
27
31
|
const EXPORT_SVG_COMMAND_ID = 'export.svg';
|
|
28
32
|
const EXPORT_SVG_LABEL_KEY = 'com.labre.command.export.svg';
|
|
29
33
|
const EXPORT_SVG_LABEL_FALLBACK = 'Export SVG';
|
|
34
|
+
// `z.z-` and not `z.`: a framework's own export (`z.export-owm`,
|
|
35
|
+
// `z.export-xml`, `z.export-mermaid`) is the format that says what the board
|
|
36
|
+
// MEANS, and it reads first. The picture reads last, under everything, which
|
|
37
|
+
// is also where a reader looks for it.
|
|
38
|
+
const EXPORT_SVG_ACTION_ID = 'z.z-export-svg';
|
|
39
|
+
/** The same `source` the row's own entries report (`commandMoreAction`). */
|
|
40
|
+
const INVOCATION = {
|
|
41
|
+
surface: 'contextual-toolbar',
|
|
42
|
+
source: 'toolbar:general',
|
|
43
|
+
};
|
|
44
|
+
const findCommand = (std) => getRegisteredCommands(std).find(command => command.id === EXPORT_SVG_COMMAND_ID);
|
|
45
|
+
/**
|
|
46
|
+
* The reader's last choice, per editor and for the session only: it is a
|
|
47
|
+
* habit of the person exporting, not a property of the document, so it is
|
|
48
|
+
* neither stored in the document nor in the browser. Per editor rather than
|
|
49
|
+
* per module so two editors on one page do not answer for each other.
|
|
50
|
+
*/
|
|
51
|
+
const lastChoice = new WeakMap();
|
|
52
|
+
const SWITCHES = [
|
|
53
|
+
['framework', EXPORT_SVG_OPTION_FRAMEWORK],
|
|
54
|
+
['shapes', EXPORT_SVG_OPTION_SHAPES],
|
|
55
|
+
['texts', EXPORT_SVG_OPTION_TEXTS],
|
|
56
|
+
];
|
|
57
|
+
/**
|
|
58
|
+
* The options menu: three switches and Export, anchored on the "⋮" whose menu
|
|
59
|
+
* it replaces. Built from the library's menu primitives (`menu.toggleSwitch`,
|
|
60
|
+
* as the HTML embed's settings do) rather than a modal of its own.
|
|
61
|
+
*
|
|
62
|
+
* The choice lives in a signal read through `menu.dynamic`, so a row redrawn
|
|
63
|
+
* after a flip says the CURRENT value: `toggleSwitch` hands its row click the
|
|
64
|
+
* `on` it was built with, and a static `on` would undo a flip when the reader
|
|
65
|
+
* then clicked the row's words.
|
|
66
|
+
*/
|
|
67
|
+
function openExportSvgOptions(std, command, item) {
|
|
68
|
+
const more = item.closest('editor-menu-button');
|
|
69
|
+
more?.hide();
|
|
70
|
+
const choice = signal({
|
|
71
|
+
...(lastChoice.get(std) ?? DEFAULT_BOARD_SVG_EXPORT_OPTIONS),
|
|
72
|
+
});
|
|
73
|
+
popMenu(popupTargetFromElement(more ?? item), {
|
|
74
|
+
options: {
|
|
75
|
+
items: [
|
|
76
|
+
menu.group({
|
|
77
|
+
items: [
|
|
78
|
+
menu.dynamic(() => SWITCHES.map(([part, wording]) => menu.toggleSwitch({
|
|
79
|
+
name: translateKey(std, ...wording),
|
|
80
|
+
on: choice.value[part],
|
|
81
|
+
onChange: on => {
|
|
82
|
+
choice.value = { ...choice.peek(), [part]: on };
|
|
83
|
+
},
|
|
84
|
+
testId: `export-svg-option-${part}`,
|
|
85
|
+
}))),
|
|
86
|
+
],
|
|
87
|
+
}),
|
|
88
|
+
menu.group({
|
|
89
|
+
items: [
|
|
90
|
+
menu.action({
|
|
91
|
+
name: translateKey(std, ...EXPORT_SVG_CONFIRM),
|
|
92
|
+
prefix: ExportSvgIcon,
|
|
93
|
+
testId: 'export-svg-confirm',
|
|
94
|
+
select: () => {
|
|
95
|
+
const options = { ...choice.peek() };
|
|
96
|
+
lastChoice.set(std, options);
|
|
97
|
+
runCommand(std, command, INVOCATION, options);
|
|
98
|
+
},
|
|
99
|
+
}),
|
|
100
|
+
],
|
|
101
|
+
}),
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The "⋮" entry. It invokes the registered command like `commandMoreAction`
|
|
108
|
+
* does — one behaviour, one availability rule, one usage record per export —
|
|
109
|
+
* but asks for the options first, so it draws its own line: a menu line's
|
|
110
|
+
* `run` is handed no element to anchor a popup on.
|
|
111
|
+
*/
|
|
112
|
+
const exportSvgMoreAction = {
|
|
113
|
+
id: EXPORT_SVG_ACTION_ID,
|
|
114
|
+
placement: ActionPlacement.More,
|
|
115
|
+
when: (ctx) => {
|
|
116
|
+
const command = findCommand(ctx.std);
|
|
117
|
+
return command !== undefined && (command.when?.(ctx.std) ?? true);
|
|
118
|
+
},
|
|
119
|
+
content: (ctx) => {
|
|
120
|
+
const label = translateKey(ctx.std, EXPORT_SVG_LABEL_KEY, EXPORT_SVG_LABEL_FALLBACK);
|
|
121
|
+
return html `
|
|
122
|
+
<editor-menu-action
|
|
123
|
+
data-testid="z-export-svg"
|
|
124
|
+
data-toolbar-action-id=${EXPORT_SVG_ACTION_ID}
|
|
125
|
+
aria-label=${label}
|
|
126
|
+
@click=${(event) => {
|
|
127
|
+
const command = findCommand(ctx.std);
|
|
128
|
+
if (!command)
|
|
129
|
+
return;
|
|
130
|
+
openExportSvgOptions(ctx.std, command, event.currentTarget);
|
|
131
|
+
}}
|
|
132
|
+
>
|
|
133
|
+
${ExportSvgIcon}
|
|
134
|
+
<span class="label">${label}</span>
|
|
135
|
+
</editor-menu-action>
|
|
136
|
+
`;
|
|
137
|
+
},
|
|
138
|
+
};
|
|
30
139
|
export const exportSvgToolbarConfig = {
|
|
31
|
-
actions: [
|
|
32
|
-
commandMoreAction(
|
|
33
|
-
// `z.z-` and not `z.`: a framework's own export (`z.export-owm`,
|
|
34
|
-
// `z.export-xml`, `z.export-mermaid`) is the format that says what the
|
|
35
|
-
// board MEANS, and it reads first. The picture reads last, under
|
|
36
|
-
// everything, which is also where a reader looks for it.
|
|
37
|
-
'z.z-export-svg', EXPORT_SVG_COMMAND_ID, EXPORT_SVG_LABEL_KEY, EXPORT_SVG_LABEL_FALLBACK, ExportSvgIcon),
|
|
38
|
-
],
|
|
140
|
+
actions: [exportSvgMoreAction],
|
|
39
141
|
// The module says "a board is selected"; the command's own `when` says the
|
|
40
142
|
// same thing from the registry side, and the two are deliberately both there
|
|
41
143
|
// — the entry is drawn from the module and the behaviour is guarded by the
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ChromeWording } from '../../../affine-shared/services/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The words of the "Export SVG" options menu (ADR 0025, amendment of
|
|
4
|
+
* 2026-10-04), one switch per part of the picture, and the one sentence said
|
|
5
|
+
* when the switches leave nothing to draw. The command's own label and
|
|
6
|
+
* description are declared on its descriptor.
|
|
7
|
+
*/
|
|
8
|
+
export declare const EXPORT_SVG_OPTION_FRAMEWORK: ChromeWording;
|
|
9
|
+
export declare const EXPORT_SVG_OPTION_SHAPES: ChromeWording;
|
|
10
|
+
export declare const EXPORT_SVG_OPTION_TEXTS: ChromeWording;
|
|
11
|
+
export declare const EXPORT_SVG_CONFIRM: ChromeWording;
|
|
12
|
+
export declare const EXPORT_SVG_NOTHING_TO_EXPORT: ChromeWording;
|
|
13
|
+
export declare const EXPORT_SVG_WORDINGS: readonly ChromeWording[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words of the "Export SVG" options menu (ADR 0025, amendment of
|
|
3
|
+
* 2026-10-04), one switch per part of the picture, and the one sentence said
|
|
4
|
+
* when the switches leave nothing to draw. The command's own label and
|
|
5
|
+
* description are declared on its descriptor.
|
|
6
|
+
*/
|
|
7
|
+
export const EXPORT_SVG_OPTION_FRAMEWORK = [
|
|
8
|
+
'com.labre.export.svg.option.framework',
|
|
9
|
+
'Framework elements',
|
|
10
|
+
];
|
|
11
|
+
export const EXPORT_SVG_OPTION_SHAPES = [
|
|
12
|
+
'com.labre.export.svg.option.shapes',
|
|
13
|
+
'Other shapes and strokes',
|
|
14
|
+
];
|
|
15
|
+
export const EXPORT_SVG_OPTION_TEXTS = [
|
|
16
|
+
'com.labre.export.svg.option.texts',
|
|
17
|
+
'Other texts',
|
|
18
|
+
];
|
|
19
|
+
export const EXPORT_SVG_CONFIRM = [
|
|
20
|
+
'com.labre.export.svg.confirm',
|
|
21
|
+
'Export',
|
|
22
|
+
];
|
|
23
|
+
export const EXPORT_SVG_NOTHING_TO_EXPORT = [
|
|
24
|
+
'com.labre.export.svg.nothing',
|
|
25
|
+
'Nothing to export: the options leave nothing of this board to draw.',
|
|
26
|
+
];
|
|
27
|
+
export const EXPORT_SVG_WORDINGS = [
|
|
28
|
+
EXPORT_SVG_OPTION_FRAMEWORK,
|
|
29
|
+
EXPORT_SVG_OPTION_SHAPES,
|
|
30
|
+
EXPORT_SVG_OPTION_TEXTS,
|
|
31
|
+
EXPORT_SVG_CONFIRM,
|
|
32
|
+
EXPORT_SVG_NOTHING_TO_EXPORT,
|
|
33
|
+
];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './audit.js';
|
|
2
|
+
export * from './canvas-grid/index.js';
|
|
2
3
|
export * from './clipboard-config.js';
|
|
3
4
|
export * from './crud-extension.js';
|
|
4
5
|
export * from './dom-element-renderer.js';
|
|
@@ -20,11 +21,13 @@ export * from './reading.js';
|
|
|
20
21
|
export * from './reading-toolbar.js';
|
|
21
22
|
export * from './reading-widget.js';
|
|
22
23
|
export * from './record-action.js';
|
|
24
|
+
export * from './selection-pane/index.js';
|
|
23
25
|
export * from './spotlight.js';
|
|
24
26
|
export * from './surface-middleware.js';
|
|
25
27
|
export * from './svg-sketch.js';
|
|
26
28
|
export * from './svg-sketch-translations.js';
|
|
27
29
|
export * from './tags-toolbar.js';
|
|
30
|
+
export * from './user-layers/index.js';
|
|
28
31
|
export * from './validation.js';
|
|
29
32
|
export * from './validation-toolbar.js';
|
|
30
33
|
export * from './violation-detail-widget.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './audit.js';
|
|
2
|
+
export * from './canvas-grid/index.js';
|
|
2
3
|
export * from './clipboard-config.js';
|
|
3
4
|
export * from './crud-extension.js';
|
|
4
5
|
export * from './dom-element-renderer.js';
|
|
@@ -20,11 +21,13 @@ export * from './reading.js';
|
|
|
20
21
|
export * from './reading-toolbar.js';
|
|
21
22
|
export * from './reading-widget.js';
|
|
22
23
|
export * from './record-action.js';
|
|
24
|
+
export * from './selection-pane/index.js';
|
|
23
25
|
export * from './spotlight.js';
|
|
24
26
|
export * from './surface-middleware.js';
|
|
25
27
|
export * from './svg-sketch.js';
|
|
26
28
|
export * from './svg-sketch-translations.js';
|
|
27
29
|
export * from './tags-toolbar.js';
|
|
30
|
+
export * from './user-layers/index.js';
|
|
28
31
|
export * from './validation.js';
|
|
29
32
|
export * from './validation-toolbar.js';
|
|
30
33
|
export * from './violation-detail-widget.js';
|
|
@@ -276,6 +276,15 @@ const IMPORT_DONE_KEY = 'com.labre.interchange.import.done';
|
|
|
276
276
|
const IMPORT_DONE_FALLBACK = 'file imported';
|
|
277
277
|
const IMPORT_FAILED_KEY = 'com.labre.interchange.import.failed';
|
|
278
278
|
const IMPORT_FAILED_FALLBACK = 'This file could not be imported';
|
|
279
|
+
/**
|
|
280
|
+
* What an imported sheet is called when neither the file nor the source
|
|
281
|
+
* document names it — resolved HERE, at the creation site, because that is
|
|
282
|
+
* where `std` is (ADR 0023 §3: a seed is translated by whoever writes it, and
|
|
283
|
+
* a pure reader never can). The readers keep the same English text as their
|
|
284
|
+
* own last-resort default, so a headless call still produces a named sheet.
|
|
285
|
+
*/
|
|
286
|
+
const IMPORT_DEFAULT_NAME_KEY = 'com.labre.interchange.import.default-name';
|
|
287
|
+
const IMPORT_DEFAULT_NAME_FALLBACK = 'Imported diagram';
|
|
279
288
|
/**
|
|
280
289
|
* The document went read-only between the moment the file was accepted and the
|
|
281
290
|
* moment its board was about to be written — see the second guard in
|
|
@@ -531,7 +540,10 @@ export async function importInterchangeFile(std, capability, file, options = {})
|
|
|
531
540
|
// inflated" and "this is not a BPMN document" are the same event to the
|
|
532
541
|
// person who picked the file, and they take the same notification.
|
|
533
542
|
const source = options.decode ? await options.decode(text, file) : text;
|
|
534
|
-
result = capability.run(source, {
|
|
543
|
+
result = capability.run(source, {
|
|
544
|
+
name: file.name.trim() ||
|
|
545
|
+
translateKey(std, IMPORT_DEFAULT_NAME_KEY, IMPORT_DEFAULT_NAME_FALLBACK),
|
|
546
|
+
});
|
|
535
547
|
}
|
|
536
548
|
catch (error) {
|
|
537
549
|
// `InterchangeImportError` checked FIRST: a reader that throws it declared
|
|
@@ -128,6 +128,14 @@ export declare function legendFromCommands(std: BlockStdScope, owner: CommandOwn
|
|
|
128
128
|
* Build the legend of what is drawn inside `board` and drop it bottom-left of
|
|
129
129
|
* it, grouped and selected. THE gesture the shared toolbar button runs.
|
|
130
130
|
*
|
|
131
|
+
* REPLACES the board's own legend if it already has one, rather than stacking a
|
|
132
|
+
* second box on the first (issue #391): the placement is derived from the board
|
|
133
|
+
* alone, so every press landed at the same pixel and the copies were invisible
|
|
134
|
+
* — one box to the eye, N groups and N × ~15 elements in the document. The
|
|
135
|
+
* second press is therefore a REFRESH, which is what a user who has just added
|
|
136
|
+
* three artefacts is asking for; the cost is that hand retouching of the box is
|
|
137
|
+
* lost, and one undo brings it back (see {@link legendsOn} and ADR 0026).
|
|
138
|
+
*
|
|
131
139
|
* Returns the group id, or `undefined` when there is no surface to draw on.
|
|
132
140
|
*/
|
|
133
141
|
export declare function createBoardLegend(std: BlockStdScope, board: {
|