@formicoidea/labre-core 0.31.0 → 0.32.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-callout/callout-block.d.ts +6 -0
- package/dist/_pkgs/affine-block-callout/callout-block.js +25 -3
- package/dist/_pkgs/affine-block-callout/callout-keymap.js +59 -19
- package/dist/_pkgs/affine-block-callout/commands/callout-to-paragraph.d.ts +20 -0
- package/dist/_pkgs/affine-block-callout/commands/callout-to-paragraph.js +60 -0
- package/dist/_pkgs/affine-block-callout/commands/split-callout.d.ts +17 -0
- package/dist/_pkgs/affine-block-callout/commands/split-callout.js +42 -0
- package/dist/_pkgs/affine-block-callout/configs/slash-menu.js +9 -6
- package/dist/_pkgs/affine-block-callout/emoji-margin.d.ts +9 -0
- package/dist/_pkgs/affine-block-callout/emoji-margin.js +36 -0
- package/dist/_pkgs/affine-block-callout/emoji-menu.d.ts +5 -1
- package/dist/_pkgs/affine-block-callout/emoji-menu.js +5 -0
- package/dist/_pkgs/affine-block-code/code-block.d.ts +14 -0
- package/dist/_pkgs/affine-block-code/code-block.js +44 -6
- package/dist/_pkgs/affine-block-code/code-toolbar/components/code-toolbar.d.ts +2 -0
- package/dist/_pkgs/affine-block-code/code-toolbar/components/code-toolbar.js +23 -14
- package/dist/_pkgs/affine-block-code/code-toolbar/components/more-menu.d.ts +16 -0
- package/dist/_pkgs/affine-block-code/code-toolbar/components/more-menu.js +93 -0
- package/dist/_pkgs/affine-block-code/code-toolbar/config.js +52 -5
- package/dist/_pkgs/affine-block-code/effects.d.ts +2 -0
- package/dist/_pkgs/affine-block-code/effects.js +2 -0
- package/dist/_pkgs/affine-block-code/highlight/affine-code-unit.js +6 -1
- package/dist/_pkgs/affine-block-code/index.d.ts +1 -0
- package/dist/_pkgs/affine-block-code/index.js +1 -0
- package/dist/_pkgs/affine-block-code/line-numbers.d.ts +25 -0
- package/dist/_pkgs/affine-block-code/line-numbers.js +27 -0
- package/dist/_pkgs/affine-block-code/styles.js +31 -0
- package/dist/_pkgs/affine-block-data-view/data-view-block.js +1 -0
- package/dist/_pkgs/affine-block-database/components/title/index.js +4 -1
- package/dist/_pkgs/affine-block-database/configs/slash-menu.js +28 -1
- package/dist/_pkgs/affine-block-database/database-block.js +13 -0
- package/dist/_pkgs/affine-block-database/properties/paste-url.d.ts +24 -0
- package/dist/_pkgs/affine-block-database/properties/paste-url.js +98 -0
- package/dist/_pkgs/affine-block-database/properties/rich-text/cell-renderer.js +9 -19
- package/dist/_pkgs/affine-block-database/properties/title/text.js +20 -25
- package/dist/_pkgs/affine-block-database/views/index.js +1 -0
- package/dist/_pkgs/affine-block-edgeless-text/edgeless-text-block.js +10 -0
- package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/config.d.ts +3 -0
- package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/config.js +48 -1
- package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/font-size.d.ts +17 -0
- package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/font-size.js +24 -0
- package/dist/_pkgs/affine-block-embed-doc/common/doc-trashed.d.ts +9 -0
- package/dist/_pkgs/affine-block-embed-doc/common/doc-trashed.js +10 -0
- package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-linked-doc-block.js +8 -4
- package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-synced-doc-block.d.ts +4 -0
- package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-synced-doc-block.js +22 -3
- package/dist/_pkgs/affine-block-frame/frame-manager.d.ts +13 -0
- package/dist/_pkgs/affine-block-frame/frame-manager.js +32 -2
- package/dist/_pkgs/affine-block-latex/styles.js +6 -1
- package/dist/_pkgs/affine-block-note/note-edgeless-block.d.ts +9 -0
- package/dist/_pkgs/affine-block-note/note-edgeless-block.js +29 -1
- package/dist/_pkgs/affine-block-root/commands/pivot-commands.d.ts +37 -0
- package/dist/_pkgs/affine-block-root/commands/pivot-commands.js +168 -0
- package/dist/_pkgs/affine-block-root/commands/reading-commands.d.ts +23 -0
- package/dist/_pkgs/affine-block-root/commands/reading-commands.js +107 -0
- package/dist/_pkgs/affine-block-root/commands/tag-commands.d.ts +47 -0
- package/dist/_pkgs/affine-block-root/commands/tag-commands.js +159 -0
- package/dist/_pkgs/affine-block-root/configs/toolbar.d.ts +1 -0
- package/dist/_pkgs/affine-block-root/edgeless/configs/toolbar/more.js +9 -2
- package/dist/_pkgs/affine-block-root/edgeless/configs/toolbar/render-linked-doc.js +1 -1
- package/dist/_pkgs/affine-block-root/edgeless/edgeless-keyboard.js +26 -1
- package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.js +11 -2
- package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-service.js +14 -0
- package/dist/_pkgs/affine-block-root/edgeless/index.d.ts +1 -0
- package/dist/_pkgs/affine-block-root/edgeless/index.js +1 -0
- package/dist/_pkgs/affine-block-root/edgeless/reserved-keys.d.ts +21 -0
- package/dist/_pkgs/affine-block-root/edgeless/reserved-keys.js +34 -0
- package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.d.ts +7 -1
- package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.js +11 -2
- package/dist/_pkgs/affine-block-root/index.d.ts +4 -1
- package/dist/_pkgs/affine-block-root/index.js +4 -1
- package/dist/_pkgs/affine-block-root/keyboard/commands.d.ts +2 -0
- package/dist/_pkgs/affine-block-root/keyboard/commands.js +147 -0
- package/dist/_pkgs/affine-block-root/view.js +13 -4
- package/dist/_pkgs/affine-block-surface/commands/reassociate-connectors.js +0 -1
- package/dist/_pkgs/affine-block-surface/effects.js +6 -0
- package/dist/_pkgs/affine-block-surface/element-model/index.d.ts +5 -2
- package/dist/_pkgs/affine-block-surface/element-model/index.js +4 -2
- package/dist/_pkgs/affine-block-surface/extensions/audit.d.ts +107 -0
- package/dist/_pkgs/affine-block-surface/extensions/audit.js +472 -0
- package/dist/_pkgs/affine-block-surface/extensions/crud-extension.d.ts +14 -0
- package/dist/_pkgs/affine-block-surface/extensions/crud-extension.js +27 -0
- package/dist/_pkgs/affine-block-surface/extensions/editor-anchored-panel.d.ts +133 -0
- package/dist/_pkgs/affine-block-surface/extensions/editor-anchored-panel.js +326 -0
- package/dist/_pkgs/affine-block-surface/extensions/index.d.ts +13 -0
- package/dist/_pkgs/affine-block-surface/extensions/index.js +13 -0
- package/dist/_pkgs/affine-block-surface/extensions/map-quality-widget.d.ts +146 -0
- package/dist/_pkgs/affine-block-surface/extensions/map-quality-widget.js +528 -0
- package/dist/_pkgs/affine-block-surface/extensions/map-quality.d.ts +109 -0
- package/dist/_pkgs/affine-block-surface/extensions/map-quality.js +84 -0
- package/dist/_pkgs/affine-block-surface/extensions/reading-toolbar.d.ts +15 -0
- package/dist/_pkgs/affine-block-surface/extensions/reading-toolbar.js +158 -0
- package/dist/_pkgs/affine-block-surface/extensions/reading-widget.d.ts +145 -0
- package/dist/_pkgs/affine-block-surface/extensions/reading-widget.js +590 -0
- package/dist/_pkgs/affine-block-surface/extensions/reading.d.ts +494 -0
- package/dist/_pkgs/affine-block-surface/extensions/reading.js +767 -0
- package/dist/_pkgs/affine-block-surface/extensions/spotlight.d.ts +45 -0
- package/dist/_pkgs/affine-block-surface/extensions/spotlight.js +177 -0
- package/dist/_pkgs/affine-block-surface/extensions/tags-toolbar.d.ts +10 -0
- package/dist/_pkgs/affine-block-surface/extensions/tags-toolbar.js +295 -0
- package/dist/_pkgs/affine-block-surface/extensions/validation-toolbar.d.ts +27 -0
- package/dist/_pkgs/affine-block-surface/extensions/validation-toolbar.js +361 -0
- package/dist/_pkgs/affine-block-surface/extensions/validation.d.ts +1340 -0
- package/dist/_pkgs/affine-block-surface/extensions/validation.js +3009 -0
- package/dist/_pkgs/affine-block-surface/extensions/violation-detail-widget.d.ts +286 -0
- package/dist/_pkgs/affine-block-surface/extensions/violation-detail-widget.js +907 -0
- package/dist/_pkgs/affine-block-surface/extensions/violation-timeline.d.ts +80 -0
- package/dist/_pkgs/affine-block-surface/extensions/violation-timeline.js +123 -0
- package/dist/_pkgs/affine-block-surface/framework-background/def.d.ts +321 -0
- package/dist/_pkgs/affine-block-surface/framework-background/def.js +81 -0
- package/dist/_pkgs/affine-block-surface/framework-background/facts.d.ts +188 -0
- package/dist/_pkgs/affine-block-surface/framework-background/facts.js +284 -0
- package/dist/_pkgs/affine-block-surface/framework-background/index.d.ts +5 -0
- package/dist/_pkgs/affine-block-surface/framework-background/index.js +5 -0
- package/dist/_pkgs/affine-block-surface/framework-background/interaction.d.ts +12 -0
- package/dist/_pkgs/affine-block-surface/framework-background/interaction.js +24 -0
- package/dist/_pkgs/affine-block-surface/framework-background/labels.d.ts +59 -0
- package/dist/_pkgs/affine-block-surface/framework-background/labels.js +117 -0
- package/dist/_pkgs/affine-block-surface/framework-background/renderer.d.ts +8 -0
- package/dist/_pkgs/affine-block-surface/framework-background/renderer.js +238 -0
- package/dist/_pkgs/affine-block-surface/index.d.ts +1 -0
- package/dist/_pkgs/affine-block-surface/index.js +1 -0
- package/dist/_pkgs/affine-block-surface/renderer/canvas-renderer.d.ts +69 -3
- package/dist/_pkgs/affine-block-surface/renderer/canvas-renderer.js +333 -44
- package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.js +18 -2
- package/dist/_pkgs/affine-block-surface/tool/default-tool.js +8 -0
- package/dist/_pkgs/affine-block-surface/utils/font.js +9 -3
- package/dist/_pkgs/affine-block-surface/view.d.ts +17 -0
- package/dist/_pkgs/affine-block-surface/view.js +57 -2
- package/dist/_pkgs/affine-block-table/selection-controller.d.ts +6 -0
- package/dist/_pkgs/affine-block-table/selection-controller.js +24 -1
- package/dist/_pkgs/affine-block-table/table-block.js +8 -2
- package/dist/_pkgs/affine-block-table/table-cell.js +5 -6
- package/dist/_pkgs/affine-block-table/table-keymap.d.ts +18 -0
- package/dist/_pkgs/affine-block-table/table-keymap.js +41 -0
- package/dist/_pkgs/affine-block-table/utils.d.ts +7 -0
- package/dist/_pkgs/affine-block-table/utils.js +12 -0
- package/dist/_pkgs/affine-block-table/view.js +2 -0
- package/dist/_pkgs/affine-components/caption/captioned-block-component.js +2 -1
- package/dist/_pkgs/affine-components/context-menu/button.d.ts +7 -0
- package/dist/_pkgs/affine-components/context-menu/button.js +7 -2
- package/dist/_pkgs/affine-components/context-menu/input.d.ts +4 -0
- package/dist/_pkgs/affine-components/context-menu/input.js +12 -0
- package/dist/_pkgs/affine-components/context-menu/menu-all.d.ts +2 -0
- package/dist/_pkgs/affine-components/context-menu/menu-renderer.js +8 -1
- package/dist/_pkgs/affine-components/context-menu/sub-menu.js +3 -0
- package/dist/_pkgs/affine-components/highlight-dropdown-menu/highlight-duotone-icon.js +8 -8
- package/dist/_pkgs/affine-components/highlight-dropdown-menu/text-duotone-icon.js +11 -11
- package/dist/_pkgs/affine-components/icon-picker/affine-icon-picker-panel.d.ts +28 -0
- package/dist/_pkgs/affine-components/icon-picker/affine-icon-picker-panel.js +231 -0
- package/dist/_pkgs/affine-components/icon-picker/emoji-data.d.ts +40 -0
- package/dist/_pkgs/affine-components/icon-picker/emoji-data.js +99 -0
- package/dist/_pkgs/affine-components/icon-picker/emoji-picker-panel.d.ts +32 -0
- package/dist/_pkgs/affine-components/icon-picker/emoji-picker-panel.js +276 -0
- package/dist/_pkgs/affine-components/icon-picker/icon-data.d.ts +34 -0
- package/dist/_pkgs/affine-components/icon-picker/icon-data.js +83 -0
- package/dist/_pkgs/affine-components/icon-picker/icon-picker.d.ts +39 -0
- package/dist/_pkgs/affine-components/icon-picker/icon-picker.js +233 -0
- package/dist/_pkgs/affine-components/icon-picker/index.d.ts +8 -0
- package/dist/_pkgs/affine-components/icon-picker/index.js +15 -0
- package/dist/_pkgs/affine-components/icon-picker/recent-store.d.ts +8 -0
- package/dist/_pkgs/affine-components/icon-picker/recent-store.js +41 -0
- package/dist/_pkgs/affine-components/icon-picker/styles.d.ts +5 -0
- package/dist/_pkgs/affine-components/icon-picker/styles.js +166 -0
- package/dist/_pkgs/affine-components/icon-picker/types.d.ts +22 -0
- package/dist/_pkgs/affine-components/icon-picker/types.js +10 -0
- package/dist/_pkgs/affine-components/icons/text.js +426 -426
- package/dist/_pkgs/affine-components/open-doc-dropdown-menu/dropdown-menu.d.ts +1 -0
- package/dist/_pkgs/affine-components/portal/portal.d.ts +1 -1
- package/dist/_pkgs/affine-components/toolbar/menu-button.js +1 -0
- package/dist/_pkgs/affine-components/toolbar/toolbar.js +11 -10
- package/dist/_pkgs/affine-foundation/view.js +11 -2
- package/dist/_pkgs/affine-gfx-brush/index.d.ts +1 -0
- package/dist/_pkgs/affine-gfx-brush/index.js +1 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/dom/brush.d.ts +1 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/dom/brush.js +11 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/dom/highlighter.d.ts +1 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/dom/highlighter.js +11 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/dom/index.d.ts +2 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/dom/index.js +2 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/dom/shared.d.ts +14 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/dom/shared.js +54 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/index.d.ts +1 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/index.js +4 -0
- package/dist/_pkgs/affine-gfx-brush/view.d.ts +14 -0
- package/dist/_pkgs/affine-gfx-brush/view.js +29 -3
- package/dist/_pkgs/affine-gfx-connector/connector-manager.js +32 -6
- package/dist/_pkgs/affine-gfx-connector/connector-tool.d.ts +7 -0
- package/dist/_pkgs/affine-gfx-connector/connector-tool.js +2 -1
- package/dist/_pkgs/affine-gfx-connector/direction/direction-reveal.d.ts +123 -0
- package/dist/_pkgs/affine-gfx-connector/direction/direction-reveal.js +281 -0
- package/dist/_pkgs/affine-gfx-connector/direction/direction-widget.d.ts +65 -0
- package/dist/_pkgs/affine-gfx-connector/direction/direction-widget.js +395 -0
- package/dist/_pkgs/affine-gfx-connector/direction/index.d.ts +4 -0
- package/dist/_pkgs/affine-gfx-connector/direction/index.js +4 -0
- package/dist/_pkgs/affine-gfx-connector/direction/invert-direction.d.ts +72 -0
- package/dist/_pkgs/affine-gfx-connector/direction/invert-direction.js +187 -0
- package/dist/_pkgs/affine-gfx-connector/direction/typed-edge.d.ts +69 -0
- package/dist/_pkgs/affine-gfx-connector/direction/typed-edge.js +66 -0
- package/dist/_pkgs/affine-gfx-connector/effects.d.ts +2 -0
- package/dist/_pkgs/affine-gfx-connector/effects.js +2 -0
- package/dist/_pkgs/affine-gfx-connector/element-renderer/connector-dom/index.js +78 -41
- package/dist/_pkgs/affine-gfx-connector/index.d.ts +1 -0
- package/dist/_pkgs/affine-gfx-connector/index.js +1 -0
- package/dist/_pkgs/affine-gfx-connector/toolbar/config.d.ts +50 -0
- package/dist/_pkgs/affine-gfx-connector/toolbar/config.js +67 -1
- package/dist/_pkgs/affine-gfx-connector/view.js +16 -0
- package/dist/_pkgs/affine-gfx-group/command/group-api.js +150 -62
- package/dist/_pkgs/affine-gfx-group/text/edgeless-group-title-editor.js +4 -1
- package/dist/_pkgs/affine-gfx-pointer/tools/pan-tool.d.ts +16 -0
- package/dist/_pkgs/affine-gfx-pointer/tools/pan-tool.js +102 -32
- package/dist/_pkgs/affine-gfx-shape/commands.d.ts +2 -0
- package/dist/_pkgs/affine-gfx-shape/commands.js +33 -0
- package/dist/_pkgs/affine-gfx-shape/element-renderer/shape-dom/index.js +48 -19
- package/dist/_pkgs/affine-gfx-shape/index.d.ts +1 -1
- package/dist/_pkgs/affine-gfx-shape/index.js +1 -1
- package/dist/_pkgs/affine-gfx-shape/text/edgeless-shape-text-editor.d.ts +26 -0
- package/dist/_pkgs/affine-gfx-shape/text/edgeless-shape-text-editor.js +124 -13
- package/dist/_pkgs/affine-gfx-shape/view.js +3 -3
- package/dist/_pkgs/affine-gfx-template/toolbar/template-tool-button.d.ts +2 -0
- package/dist/_pkgs/affine-gfx-template/toolbar/template-tool-button.js +18 -1
- package/dist/_pkgs/affine-gfx-text/edgeless-text-editor.js +9 -5
- package/dist/_pkgs/affine-inline-latex/command.js +46 -26
- package/dist/_pkgs/affine-inline-latex/latex-node/latex-node.d.ts +10 -0
- package/dist/_pkgs/affine-inline-latex/latex-node/latex-node.js +23 -0
- package/dist/_pkgs/affine-inline-link/link-node/affine-link.js +4 -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 +29 -1
- package/dist/_pkgs/affine-model/blocks/code/code-model.d.ts +1 -0
- package/dist/_pkgs/affine-model/blocks/code/code-model.js +1 -0
- package/dist/_pkgs/affine-model/elements/connector/connector.js +24 -0
- package/dist/_pkgs/affine-model/elements/edgy/board.d.ts +32 -0
- package/dist/_pkgs/affine-model/elements/edgy/board.js +112 -0
- package/dist/_pkgs/affine-model/elements/edgy/facets.d.ts +12 -0
- package/dist/_pkgs/affine-model/elements/edgy/facets.js +25 -1
- package/dist/_pkgs/affine-model/elements/edgy/index.d.ts +1 -0
- package/dist/_pkgs/affine-model/elements/edgy/index.js +1 -0
- package/dist/_pkgs/affine-model/elements/framework-background/background.d.ts +42 -0
- package/dist/_pkgs/affine-model/elements/framework-background/background.js +42 -0
- package/dist/_pkgs/affine-model/elements/framework-background/index.d.ts +1 -0
- package/dist/_pkgs/affine-model/elements/framework-background/index.js +1 -0
- package/dist/_pkgs/affine-model/elements/index.d.ts +3 -1
- package/dist/_pkgs/affine-model/elements/index.js +1 -0
- package/dist/_pkgs/affine-model/elements/mindmap/mindmap.js +8 -3
- package/dist/_pkgs/affine-model/elements/mindmap/style.d.ts +10 -0
- package/dist/_pkgs/affine-model/elements/mindmap/style.js +8 -0
- package/dist/_pkgs/affine-model/elements/wardley/wardley.d.ts +21 -29
- package/dist/_pkgs/affine-model/elements/wardley/wardley.js +41 -48
- package/dist/_pkgs/affine-shared/adapters/markdown/delta-converter.d.ts +6 -1
- package/dist/_pkgs/affine-shared/adapters/markdown/delta-converter.js +160 -2
- package/dist/_pkgs/affine-shared/adapters/markdown/markdown.js +5 -1
- package/dist/_pkgs/affine-shared/adapters/types/delta-converter.d.ts +1 -0
- package/dist/_pkgs/affine-shared/adapters/utils/color.d.ts +24 -0
- package/dist/_pkgs/affine-shared/adapters/utils/color.js +280 -0
- package/dist/_pkgs/affine-shared/adapters/utils/index.d.ts +1 -0
- package/dist/_pkgs/affine-shared/adapters/utils/index.js +1 -0
- package/dist/_pkgs/affine-shared/commands/block-crud/get-selected-blocks.js +10 -2
- package/dist/_pkgs/affine-shared/services/audit-service.d.ts +300 -0
- package/dist/_pkgs/affine-shared/services/audit-service.js +228 -0
- package/dist/_pkgs/affine-shared/services/edit-props-store.d.ts +7 -0
- package/dist/_pkgs/affine-shared/services/edit-props-store.js +11 -0
- package/dist/_pkgs/affine-shared/services/font-loader/font-loader-service.d.ts +26 -1
- package/dist/_pkgs/affine-shared/services/font-loader/font-loader-service.js +124 -7
- package/dist/_pkgs/affine-shared/services/index.d.ts +5 -0
- package/dist/_pkgs/affine-shared/services/index.js +5 -0
- package/dist/_pkgs/affine-shared/services/pivot-materiality-publisher.d.ts +129 -0
- package/dist/_pkgs/affine-shared/services/pivot-materiality-publisher.js +311 -0
- package/dist/_pkgs/affine-shared/services/pivot-properties-service.d.ts +217 -0
- package/dist/_pkgs/affine-shared/services/pivot-properties-service.js +114 -0
- package/dist/_pkgs/affine-shared/services/telemetry-service/code-block.d.ts +1 -1
- package/dist/_pkgs/affine-shared/services/telemetry-service/lifecycle.d.ts +182 -0
- package/dist/_pkgs/affine-shared/services/telemetry-service/telemetry-service.d.ts +2 -2
- package/dist/_pkgs/affine-shared/services/telemetry-service/types.d.ts +6 -1
- package/dist/_pkgs/affine-shared/services/toolbar-service/action.d.ts +10 -0
- package/dist/_pkgs/affine-shared/services/toolbar-service/index.d.ts +1 -0
- package/dist/_pkgs/affine-shared/services/toolbar-service/index.js +1 -0
- package/dist/_pkgs/affine-shared/services/toolbar-service/layout.d.ts +134 -0
- package/dist/_pkgs/affine-shared/services/toolbar-service/layout.js +146 -0
- package/dist/_pkgs/affine-shared/services/translation-service/index.d.ts +68 -0
- package/dist/_pkgs/affine-shared/services/translation-service/index.js +39 -0
- package/dist/_pkgs/affine-shared/services/universe-tag-defs-service.d.ts +155 -0
- package/dist/_pkgs/affine-shared/services/universe-tag-defs-service.js +254 -0
- package/dist/_pkgs/affine-shared/utils/dom/point-to-range.d.ts +4 -0
- package/dist/_pkgs/affine-shared/utils/dom/point-to-range.js +58 -2
- package/dist/_pkgs/affine-shared/utils/dom/viewport.d.ts +60 -0
- package/dist/_pkgs/affine-shared/utils/dom/viewport.js +58 -0
- package/dist/_pkgs/affine-shared/utils/print-to-pdf.d.ts +21 -0
- package/dist/_pkgs/affine-shared/utils/print-to-pdf.js +166 -32
- package/dist/_pkgs/affine-shared/utils/zod-schema.d.ts +7 -0
- package/dist/_pkgs/affine-shared/utils/zod-schema.js +27 -1
- package/dist/_pkgs/affine-widget-drag-handle/watchers/edgeless-watcher.d.ts +19 -10
- package/dist/_pkgs/affine-widget-drag-handle/watchers/edgeless-watcher.js +122 -23
- package/dist/_pkgs/affine-widget-drag-handle/watchers/pointer-event-watcher.d.ts +2 -0
- package/dist/_pkgs/affine-widget-drag-handle/watchers/pointer-event-watcher.js +25 -4
- package/dist/_pkgs/affine-widget-edgeless-selected-rect/auto-complete-panel.js +10 -5
- package/dist/_pkgs/affine-widget-edgeless-selected-rect/edgeless-auto-complete.d.ts +15 -1
- package/dist/_pkgs/affine-widget-edgeless-selected-rect/edgeless-auto-complete.js +37 -32
- package/dist/_pkgs/affine-widget-edgeless-selected-rect/edgeless-element-link.js +5 -4
- package/dist/_pkgs/affine-widget-edgeless-selected-rect/edgeless-selected-rect.js +19 -9
- package/dist/_pkgs/affine-widget-edgeless-selected-rect/utils.d.ts +16 -2
- package/dist/_pkgs/affine-widget-edgeless-selected-rect/utils.js +19 -2
- package/dist/_pkgs/affine-widget-edgeless-toolbar/index.d.ts +1 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/index.js +1 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/menu/command-menu.d.ts +38 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/menu/command-menu.js +99 -0
- package/dist/_pkgs/affine-widget-frame-title/edgeless-frame-title-editor.js +4 -1
- package/dist/_pkgs/affine-widget-keyboard-toolbar/icons.js +98 -98
- package/dist/_pkgs/affine-widget-linked-doc/linked-doc-popover.js +2 -15
- package/dist/_pkgs/affine-widget-linked-doc/transformers/markdown.d.ts +10 -1
- package/dist/_pkgs/affine-widget-linked-doc/transformers/markdown.js +133 -6
- package/dist/_pkgs/affine-widget-linked-doc/transformers/utils.d.ts +10 -0
- package/dist/_pkgs/affine-widget-linked-doc/transformers/utils.js +120 -3
- package/dist/_pkgs/affine-widget-linked-doc/utils.d.ts +12 -0
- package/dist/_pkgs/affine-widget-linked-doc/utils.js +33 -0
- package/dist/_pkgs/affine-widget-remote-selection/edgeless/index.js +6 -4
- package/dist/_pkgs/affine-widget-slash-menu/slash-menu-popover.js +8 -4
- package/dist/_pkgs/affine-widget-slash-menu/utils.d.ts +9 -0
- package/dist/_pkgs/affine-widget-slash-menu/utils.js +24 -0
- package/dist/_pkgs/affine-widget-toolbar/toolbar.d.ts +6 -0
- package/dist/_pkgs/affine-widget-toolbar/toolbar.js +34 -6
- package/dist/_pkgs/affine-widget-toolbar/utils.d.ts +146 -3
- package/dist/_pkgs/affine-widget-toolbar/utils.js +738 -56
- package/dist/_pkgs/data-view/core/common/property-menu.js +3 -16
- package/dist/_pkgs/data-view/core/component/tags/multi-tag-select.d.ts +4 -0
- package/dist/_pkgs/data-view/core/component/tags/multi-tag-select.js +28 -1
- package/dist/_pkgs/data-view/core/data-view.d.ts +3 -1
- package/dist/_pkgs/data-view/core/data-view.js +25 -3
- package/dist/_pkgs/data-view/core/detail/field.js +2 -2
- package/dist/_pkgs/data-view/core/detail/selection.d.ts +4 -2
- package/dist/_pkgs/data-view/core/detail/selection.js +23 -7
- package/dist/_pkgs/data-view/core/effect.js +2 -0
- package/dist/_pkgs/data-view/core/filter/eval.js +36 -23
- package/dist/_pkgs/data-view/core/filter/filter-fn/matcher.d.ts +7 -0
- package/dist/_pkgs/data-view/core/filter/filter-fn/matcher.js +12 -0
- package/dist/_pkgs/data-view/core/group-by/compare-date-keys.d.ts +11 -0
- package/dist/_pkgs/data-view/core/group-by/compare-date-keys.js +55 -0
- package/dist/_pkgs/data-view/core/group-by/define.d.ts +6 -0
- package/dist/_pkgs/data-view/core/group-by/define.js +114 -0
- package/dist/_pkgs/data-view/core/group-by/matcher.d.ts +7 -0
- package/dist/_pkgs/data-view/core/group-by/matcher.js +13 -0
- package/dist/_pkgs/data-view/core/group-by/renderer/boolean-group.js +11 -11
- package/dist/_pkgs/data-view/core/group-by/renderer/date-group.d.ts +9 -0
- package/dist/_pkgs/data-view/core/group-by/renderer/date-group.js +97 -0
- package/dist/_pkgs/data-view/core/group-by/setting.js +86 -7
- package/dist/_pkgs/data-view/core/group-by/trait.d.ts +34 -0
- package/dist/_pkgs/data-view/core/group-by/trait.js +106 -10
- package/dist/_pkgs/data-view/core/utils/menu-title.js +17 -17
- package/dist/_pkgs/data-view/property-presets/multi-select/cell-renderer.js +3 -1
- package/dist/_pkgs/data-view/property-presets/number/define.js +2 -1
- package/dist/_pkgs/data-view/property-presets/select/cell-renderer.js +3 -1
- package/dist/_pkgs/data-view/view-presets/calendar/calendar-view-manager.d.ts +70 -0
- package/dist/_pkgs/data-view/view-presets/calendar/calendar-view-manager.js +449 -0
- package/dist/_pkgs/data-view/view-presets/calendar/define.d.ts +10 -0
- package/dist/_pkgs/data-view/view-presets/calendar/define.js +27 -0
- package/dist/_pkgs/data-view/view-presets/calendar/effect.d.ts +1 -0
- package/dist/_pkgs/data-view/view-presets/calendar/effect.js +4 -0
- package/dist/_pkgs/data-view/view-presets/calendar/index.d.ts +6 -0
- package/dist/_pkgs/data-view/view-presets/calendar/index.js +6 -0
- package/dist/_pkgs/data-view/view-presets/calendar/layout.d.ts +37 -0
- package/dist/_pkgs/data-view/view-presets/calendar/layout.js +138 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/actions.d.ts +7 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/actions.js +68 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/dnd.d.ts +32 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/dnd.js +159 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/effect.d.ts +1 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/effect.js +7 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/hit-test.d.ts +1 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/hit-test.js +28 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/styles.d.ts +1 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/styles.js +707 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/view.d.ts +89 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/view.js +837 -0
- package/dist/_pkgs/data-view/view-presets/calendar/renderer.d.ts +2 -0
- package/dist/_pkgs/data-view/view-presets/calendar/renderer.js +8 -0
- package/dist/_pkgs/data-view/view-presets/calendar/source.d.ts +8 -0
- package/dist/_pkgs/data-view/view-presets/calendar/source.js +3 -0
- package/dist/_pkgs/data-view/view-presets/calendar/types.d.ts +79 -0
- package/dist/_pkgs/data-view/view-presets/calendar/types.js +1 -0
- package/dist/_pkgs/data-view/view-presets/convert.js +28 -0
- package/dist/_pkgs/data-view/view-presets/effect.js +2 -0
- package/dist/_pkgs/data-view/view-presets/index.d.ts +2 -0
- package/dist/_pkgs/data-view/view-presets/index.js +3 -0
- package/dist/_pkgs/data-view/view-presets/kanban/kanban-view-manager.js +3 -1
- package/dist/_pkgs/data-view/view-presets/kanban/mobile/cell.js +2 -2
- package/dist/_pkgs/data-view/view-presets/table/collapsed-state.d.ts +18 -0
- package/dist/_pkgs/data-view/view-presets/table/collapsed-state.js +36 -0
- package/dist/_pkgs/data-view/view-presets/table/mobile/cell.js +2 -2
- package/dist/_pkgs/data-view/view-presets/table/mobile/group.d.ts +11 -0
- package/dist/_pkgs/data-view/view-presets/table/mobile/group.js +87 -4
- package/dist/_pkgs/data-view/view-presets/table/pc/cell.d.ts +3 -0
- package/dist/_pkgs/data-view/view-presets/table/pc/cell.js +11 -2
- package/dist/_pkgs/data-view/view-presets/table/pc/controller/hotkeys.d.ts +1 -0
- package/dist/_pkgs/data-view/view-presets/table/pc/controller/hotkeys.js +39 -33
- package/dist/_pkgs/data-view/view-presets/table/pc/group.d.ts +10 -0
- package/dist/_pkgs/data-view/view-presets/table/pc/group.js +84 -5
- package/dist/_pkgs/data-view/view-presets/table/pc-virtual/controller/hotkeys.d.ts +1 -0
- package/dist/_pkgs/data-view/view-presets/table/pc-virtual/controller/hotkeys.js +39 -33
- package/dist/_pkgs/data-view/view-presets/table/pc-virtual/group/top/group-title.js +18 -18
- package/dist/_pkgs/data-view/view-presets/table/pc-virtual/row/cell.d.ts +3 -0
- package/dist/_pkgs/data-view/view-presets/table/pc-virtual/row/cell.js +8 -0
- package/dist/_pkgs/data-view/view-presets/table/table-view-manager.js +3 -1
- package/dist/_pkgs/data-view/view-presets/table/utils.d.ts +3 -0
- package/dist/_pkgs/data-view/view-presets/table/utils.js +16 -1
- package/dist/_pkgs/data-view/widget-presets/tools/presets/view-options/view-options.js +3 -1
- package/dist/_pkgs/global/gfx/curve.js +4 -3
- package/dist/_pkgs/std/clipboard/clipboard.js +13 -3
- package/dist/_pkgs/std/clipboard/utils.d.ts +5 -0
- package/dist/_pkgs/std/clipboard/utils.js +7 -0
- package/dist/_pkgs/std/event/dispatcher.js +27 -1
- package/dist/_pkgs/std/event/keymap.js +16 -6
- package/dist/_pkgs/std/extension/command-registry.d.ts +321 -0
- package/dist/_pkgs/std/extension/command-registry.js +233 -0
- package/dist/_pkgs/std/extension/dnd/index.d.ts +1 -1
- package/dist/_pkgs/std/extension/index.d.ts +2 -0
- package/dist/_pkgs/std/extension/index.js +2 -0
- package/dist/_pkgs/std/extension/translation-manifest.d.ts +49 -0
- package/dist/_pkgs/std/extension/translation-manifest.js +71 -0
- package/dist/_pkgs/std/gfx/index.d.ts +7 -3
- package/dist/_pkgs/std/gfx/index.js +6 -2
- package/dist/_pkgs/std/gfx/interactivity/gfx-view-event-handler.js +6 -1
- package/dist/_pkgs/std/gfx/interactivity/manager.d.ts +8 -0
- package/dist/_pkgs/std/gfx/interactivity/manager.js +18 -0
- package/dist/_pkgs/std/gfx/layer.d.ts +1 -1
- package/dist/_pkgs/std/gfx/layer.js +1 -2
- package/dist/_pkgs/std/gfx/model/surface/decorators/field.js +9 -0
- package/dist/_pkgs/std/gfx/model/surface/decorators/index.d.ts +2 -2
- package/dist/_pkgs/std/gfx/model/surface/decorators/index.js +2 -2
- package/dist/_pkgs/std/gfx/model/surface/decorators/local.d.ts +14 -0
- package/dist/_pkgs/std/gfx/model/surface/decorators/local.js +22 -0
- package/dist/_pkgs/std/gfx/model/surface/decorators/observer.d.ts +2 -0
- package/dist/_pkgs/std/gfx/model/surface/decorators/observer.js +40 -1
- package/dist/_pkgs/std/gfx/model/surface/element-model.d.ts +282 -0
- package/dist/_pkgs/std/gfx/model/surface/element-model.js +436 -25
- package/dist/_pkgs/std/gfx/model/surface/pivot.d.ts +48 -0
- package/dist/_pkgs/std/gfx/model/surface/pivot.js +34 -0
- package/dist/_pkgs/std/gfx/model/surface/role.d.ts +153 -0
- package/dist/_pkgs/std/gfx/model/surface/role.js +115 -0
- package/dist/_pkgs/std/gfx/model/surface/surface-model.d.ts +70 -0
- package/dist/_pkgs/std/gfx/model/surface/surface-model.js +304 -17
- package/dist/_pkgs/std/gfx/model/surface/tags.d.ts +77 -0
- package/dist/_pkgs/std/gfx/model/surface/tags.js +246 -0
- package/dist/_pkgs/std/gfx/perf.d.ts +10 -0
- package/dist/_pkgs/std/gfx/perf.js +30 -0
- package/dist/_pkgs/std/gfx/tool/tool-controller.d.ts +13 -0
- package/dist/_pkgs/std/gfx/tool/tool-controller.js +26 -0
- package/dist/_pkgs/std/gfx/viewport.d.ts +12 -0
- package/dist/_pkgs/std/gfx/viewport.js +19 -1
- package/dist/_pkgs/std/inline/services/event.d.ts +2 -0
- package/dist/_pkgs/std/inline/services/event.js +96 -21
- package/dist/_pkgs/std/utils/layer.js +2 -6
- package/dist/_pkgs/std/utils/tree.d.ts +14 -0
- package/dist/_pkgs/std/utils/tree.js +59 -8
- package/dist/_pkgs/std/view/element/gfx-block-component.js +23 -13
- package/dist/_pkgs/store/extension/workspace/workspace-meta.d.ts +10 -0
- package/dist/_pkgs/store/model/block/flat-sync-controller.js +2 -12
- package/dist/_pkgs/store/model/store/crud.js +7 -4
- package/dist/_pkgs/store/reactive/flat-native-y/index.d.ts +1 -1
- package/dist/_pkgs/store/reactive/flat-native-y/index.js +24 -2
- package/dist/commands.d.ts +58 -0
- package/dist/commands.js +66 -0
- package/dist/extensions/command-telemetry.d.ts +21 -0
- package/dist/extensions/command-telemetry.js +89 -0
- package/dist/extensions/store.d.ts +9 -4
- package/dist/extensions/store.js +27 -24
- package/dist/extensions/view.d.ts +9 -4
- package/dist/extensions/view.js +23 -8
- package/dist/flags.d.ts +98 -21
- package/dist/flags.js +103 -22
- package/dist/frameworks.d.ts +45 -0
- package/dist/frameworks.js +154 -0
- package/dist/schemas.d.ts +8 -5
- package/dist/schemas.js +28 -32
- package/dist/shortcuts.d.ts +16 -16
- package/dist/shortcuts.js +8 -36
- package/dist/translations.d.ts +56 -0
- package/dist/translations.js +112 -0
- package/package.json +16 -4
- package/dist/_pkgs/affine-block-root/keyboard/shortcuts.d.ts +0 -8
- package/dist/_pkgs/affine-block-root/keyboard/shortcuts.js +0 -48
- package/dist/_pkgs/affine-gfx-shape/shortcuts.d.ts +0 -6
- package/dist/_pkgs/affine-gfx-shape/shortcuts.js +0 -28
- package/dist/_pkgs/data-view/core/utils/cache.d.ts +0 -5
- package/dist/_pkgs/data-view/core/utils/cache.js +0 -28
|
@@ -1,8 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Styles injected into the print iframe.
|
|
3
|
+
*
|
|
4
|
+
* The printed document is always rendered on white paper, so the whole
|
|
5
|
+
* palette is pinned to a light one: a document read in the dark theme would
|
|
6
|
+
* otherwise print light text on a background the printer leaves white, and
|
|
7
|
+
* every one of those elements would come out invisible.
|
|
8
|
+
*
|
|
9
|
+
* Exported so the print-fidelity rules can be asserted in unit tests.
|
|
10
|
+
*/
|
|
11
|
+
export const printToPdfStyles = `@media print {
|
|
12
|
+
html, body {
|
|
13
|
+
height: initial !important;
|
|
14
|
+
overflow: initial !important;
|
|
15
|
+
print-color-adjust: exact;
|
|
16
|
+
-webkit-print-color-adjust: exact;
|
|
17
|
+
color: #000 !important;
|
|
18
|
+
background: #fff !important;
|
|
19
|
+
color-scheme: light !important;
|
|
20
|
+
}
|
|
21
|
+
::-webkit-scrollbar {
|
|
22
|
+
display: none;
|
|
23
|
+
}
|
|
24
|
+
:root, body {
|
|
25
|
+
--affine-text-primary: #000 !important;
|
|
26
|
+
--affine-text-secondary: #111 !important;
|
|
27
|
+
--affine-text-tertiary: #333 !important;
|
|
28
|
+
--affine-background-primary: #fff !important;
|
|
29
|
+
--affine-background-secondary: #fff !important;
|
|
30
|
+
--affine-background-tertiary: #fff !important;
|
|
31
|
+
--affine-background-code-block: #f5f5f5 !important;
|
|
32
|
+
--affine-quote-color: #e3e3e3 !important;
|
|
33
|
+
--affine-border-color: #e3e3e3 !important;
|
|
34
|
+
}
|
|
35
|
+
body, [data-theme='dark'] {
|
|
36
|
+
color: #000 !important;
|
|
37
|
+
background: #fff !important;
|
|
38
|
+
}
|
|
39
|
+
body * {
|
|
40
|
+
color: #000 !important;
|
|
41
|
+
-webkit-text-fill-color: #000 !important;
|
|
42
|
+
}
|
|
43
|
+
:root {
|
|
44
|
+
--affine-note-shadow-box: none !important;
|
|
45
|
+
--affine-note-shadow-sticker: none !important;
|
|
46
|
+
}
|
|
47
|
+
}`;
|
|
48
|
+
/**
|
|
49
|
+
* Waits until every image inside `container` — shadow roots included — has
|
|
50
|
+
* either decoded or given up.
|
|
51
|
+
*
|
|
52
|
+
* A print dialog opened while images are still in flight prints their empty
|
|
53
|
+
* frames, so this is awaited before handing the document to the printer. An
|
|
54
|
+
* image that fails to load resolves too: a broken picture must not hang the
|
|
55
|
+
* print for ever.
|
|
56
|
+
*/
|
|
57
|
+
export async function waitForImages(container) {
|
|
58
|
+
const images = [];
|
|
59
|
+
const view = container.ownerDocument.defaultView;
|
|
60
|
+
if (!view)
|
|
61
|
+
return;
|
|
62
|
+
const findImages = (root) => {
|
|
63
|
+
if (root instanceof view.HTMLImageElement) {
|
|
64
|
+
images.push(root);
|
|
65
|
+
}
|
|
66
|
+
if (root instanceof view.HTMLElement || root instanceof view.ShadowRoot) {
|
|
67
|
+
root.childNodes.forEach(findImages);
|
|
68
|
+
}
|
|
69
|
+
if (root instanceof view.HTMLElement && root.shadowRoot) {
|
|
70
|
+
findImages(root.shadowRoot);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
findImages(container);
|
|
74
|
+
await Promise.all(images.map(img => {
|
|
75
|
+
if (img.complete) {
|
|
76
|
+
if (img.naturalWidth === 0) {
|
|
77
|
+
console.warn('Image failed to load:', img.src);
|
|
78
|
+
}
|
|
79
|
+
return Promise.resolve();
|
|
80
|
+
}
|
|
81
|
+
return new Promise(resolve => {
|
|
82
|
+
img.onload = resolve;
|
|
83
|
+
img.onerror = resolve;
|
|
84
|
+
});
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
1
87
|
export async function printToPdf(rootElement = document.querySelector('.affine-page-viewport'), options = {}) {
|
|
2
88
|
return new Promise((resolve, reject) => {
|
|
3
89
|
const iframe = document.createElement('iframe');
|
|
4
90
|
document.body.append(iframe);
|
|
5
|
-
|
|
91
|
+
// hidden, but still laid out and painted: a `display: none` iframe never
|
|
92
|
+
// loads the images it contains, so they would be missing from the print
|
|
93
|
+
Object.assign(iframe.style, {
|
|
94
|
+
visibility: 'hidden',
|
|
95
|
+
position: 'absolute',
|
|
96
|
+
width: '0',
|
|
97
|
+
height: '0',
|
|
98
|
+
border: 'none',
|
|
99
|
+
});
|
|
6
100
|
iframe.srcdoc = '<!DOCTYPE html>';
|
|
7
101
|
iframe.onload = async () => {
|
|
8
102
|
if (!iframe.contentWindow) {
|
|
@@ -13,27 +107,14 @@ export async function printToPdf(rootElement = document.querySelector('.affine-p
|
|
|
13
107
|
reject(new Error('Root element not defined, unable to print pdf'));
|
|
14
108
|
return;
|
|
15
109
|
}
|
|
16
|
-
iframe.contentWindow.document
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
height: initial !important;
|
|
20
|
-
overflow: initial !important;
|
|
21
|
-
print-color-adjust: exact;
|
|
22
|
-
-webkit-print-color-adjust: exact;
|
|
23
|
-
}
|
|
24
|
-
::-webkit-scrollbar {
|
|
25
|
-
display: none;
|
|
26
|
-
}
|
|
27
|
-
:root {
|
|
28
|
-
--affine-note-shadow-box: none !important;
|
|
29
|
-
--affine-note-shadow-sticker: none !important;
|
|
30
|
-
}
|
|
31
|
-
}</style></head><body></body></html>`);
|
|
110
|
+
const doc = iframe.contentWindow.document;
|
|
111
|
+
doc.write(`<!DOCTYPE html><html><head><style>${printToPdfStyles}</style></head><body></body></html>`);
|
|
112
|
+
doc.close();
|
|
32
113
|
// copy all styles to iframe
|
|
33
114
|
for (const element of document.styleSheets) {
|
|
34
115
|
try {
|
|
35
116
|
for (const cssRule of element.cssRules) {
|
|
36
|
-
const target =
|
|
117
|
+
const target = doc.styleSheets[0];
|
|
37
118
|
target.insertRule(cssRule.cssText, target.cssRules.length);
|
|
38
119
|
}
|
|
39
120
|
}
|
|
@@ -46,12 +127,31 @@ export async function printToPdf(rootElement = document.querySelector('.affine-p
|
|
|
46
127
|
}
|
|
47
128
|
}
|
|
48
129
|
}
|
|
130
|
+
// find every canvas, including the ones sitting inside a shadow root
|
|
131
|
+
const findAllCanvases = (root) => {
|
|
132
|
+
const canvases = [];
|
|
133
|
+
const traverse = (node) => {
|
|
134
|
+
if (node instanceof HTMLCanvasElement) {
|
|
135
|
+
canvases.push(node);
|
|
136
|
+
}
|
|
137
|
+
if (node instanceof HTMLElement || node instanceof ShadowRoot) {
|
|
138
|
+
node.childNodes.forEach(traverse);
|
|
139
|
+
}
|
|
140
|
+
if (node instanceof HTMLElement && node.shadowRoot) {
|
|
141
|
+
traverse(node.shadowRoot);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
traverse(root);
|
|
145
|
+
return canvases;
|
|
146
|
+
};
|
|
49
147
|
// convert all canvas to image
|
|
50
148
|
const canvasImgObjectUrlMap = new Map();
|
|
51
|
-
const allCanvas = rootElement
|
|
149
|
+
const allCanvas = findAllCanvases(rootElement);
|
|
150
|
+
const canvasToKeyMap = new Map();
|
|
52
151
|
let canvasKey = 1;
|
|
53
152
|
for (const canvas of allCanvas) {
|
|
54
|
-
|
|
153
|
+
const key = canvasKey.toString();
|
|
154
|
+
canvasToKeyMap.set(canvas, key);
|
|
55
155
|
canvasKey++;
|
|
56
156
|
const canvasImgObjectUrl = await new Promise(resolve => {
|
|
57
157
|
try {
|
|
@@ -65,9 +165,35 @@ export async function printToPdf(rootElement = document.querySelector('.affine-p
|
|
|
65
165
|
console.warn('canvas cannot be converted to image when printing pdf, this may be because of CORS policy');
|
|
66
166
|
continue;
|
|
67
167
|
}
|
|
68
|
-
canvasImgObjectUrlMap.set(
|
|
168
|
+
canvasImgObjectUrlMap.set(key, URL.createObjectURL(canvasImgObjectUrl));
|
|
69
169
|
}
|
|
70
|
-
|
|
170
|
+
// deep clone that flattens shadow DOM into light DOM, so what the
|
|
171
|
+
// printer sees is what the reader sees
|
|
172
|
+
const deepCloneWithShadows = (node) => {
|
|
173
|
+
const clone = doc.importNode(node, false);
|
|
174
|
+
if (clone instanceof HTMLCanvasElement &&
|
|
175
|
+
node instanceof HTMLCanvasElement) {
|
|
176
|
+
const key = canvasToKeyMap.get(node);
|
|
177
|
+
if (key) {
|
|
178
|
+
clone.dataset['printToPdfCanvasKey'] = key;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const appendChildren = (source) => {
|
|
182
|
+
source.childNodes.forEach(child => {
|
|
183
|
+
clone.append(deepCloneWithShadows(child));
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
if (node instanceof HTMLElement && node.shadowRoot) {
|
|
187
|
+
appendChildren(node.shadowRoot);
|
|
188
|
+
}
|
|
189
|
+
appendChildren(node);
|
|
190
|
+
return clone;
|
|
191
|
+
};
|
|
192
|
+
const importedRoot = deepCloneWithShadows(rootElement);
|
|
193
|
+
// force light theme in print iframe
|
|
194
|
+
doc.documentElement.dataset.theme = 'light';
|
|
195
|
+
doc.body.dataset.theme = 'light';
|
|
196
|
+
importedRoot.dataset.theme = 'light';
|
|
71
197
|
// draw saved canvas image to canvas
|
|
72
198
|
const allImportedCanvas = importedRoot.getElementsByTagName('canvas');
|
|
73
199
|
for (const importedCanvas of allImportedCanvas) {
|
|
@@ -83,21 +209,29 @@ export async function printToPdf(rootElement = document.querySelector('.affine-p
|
|
|
83
209
|
}
|
|
84
210
|
}
|
|
85
211
|
}
|
|
212
|
+
// a lazily loaded image would still be waiting for a scroll that never
|
|
213
|
+
// happens in the print iframe: ask for it now
|
|
214
|
+
const allImages = importedRoot.querySelectorAll('img');
|
|
215
|
+
allImages.forEach(img => {
|
|
216
|
+
img.removeAttribute('loading');
|
|
217
|
+
const src = img.getAttribute('src');
|
|
218
|
+
if (src)
|
|
219
|
+
img.setAttribute('src', src);
|
|
220
|
+
});
|
|
86
221
|
// append to iframe and print
|
|
87
|
-
|
|
222
|
+
doc.body.append(importedRoot);
|
|
88
223
|
await options.beforeprint?.(iframe);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
224
|
+
await waitForImages(importedRoot);
|
|
225
|
+
// browser may take some time to load font or other resources
|
|
226
|
+
await (doc.fonts?.ready ??
|
|
227
|
+
new Promise(resolve => {
|
|
228
|
+
setTimeout(() => {
|
|
229
|
+
resolve();
|
|
230
|
+
}, 1000);
|
|
231
|
+
}));
|
|
95
232
|
iframe.contentWindow.onafterprint = async () => {
|
|
96
233
|
iframe.remove();
|
|
97
234
|
// clean up
|
|
98
|
-
for (const canvas of allCanvas) {
|
|
99
|
-
delete canvas.dataset['printToPdfCanvasKey'];
|
|
100
|
-
}
|
|
101
235
|
for (const [_, url] of canvasImgObjectUrlMap) {
|
|
102
236
|
URL.revokeObjectURL(url);
|
|
103
237
|
}
|
|
@@ -2275,3 +2275,10 @@ export declare const NodePropsSchema: z.ZodObject<{
|
|
|
2275
2275
|
}>;
|
|
2276
2276
|
export type NodeProps = z.infer<typeof NodePropsSchema>;
|
|
2277
2277
|
export declare function makeDeepOptional(schema: ZodTypeAny): ZodTypeAny;
|
|
2278
|
+
/**
|
|
2279
|
+
* Pick, from an arbitrary bag of style props, the subset that is valid for
|
|
2280
|
+
* the given node-props key. Filtering is per prop, so a prop foreign to the
|
|
2281
|
+
* target type (e.g. a connector `mode` offered to a shape) never discards
|
|
2282
|
+
* the rest of the bag. Returns null when nothing applies.
|
|
2283
|
+
*/
|
|
2284
|
+
export declare function pickStylePropsForKey<K extends keyof NodeProps>(key: K, props: Record<string, unknown>): Partial<NodeProps[K]> | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ColorSchema, ConnectorMode, DEFAULT_CONNECTOR_MODE, DEFAULT_FRONT_ENDPOINT_STYLE, DEFAULT_HIGHLIGHTER_LINE_WIDTH, DEFAULT_REAR_ENDPOINT_STYLE, DEFAULT_ROUGHNESS, DefaultTheme, EdgelessTextZodSchema, FontFamily, FontFamilySchema, FontStyle, FontStyleSchema, FontWeight, FontWeightSchema, FrameZodSchema, HIGHLIGHTER_LINE_WIDTHS, LayoutType, LineWidth, MindmapStyle, NoteZodSchema, PointStyle, ShapeStyle, StrokeStyle, StrokeStyleSchema, TextAlign, TextAlignSchema, TextVerticalAlign, } from '../../affine-model/index.js';
|
|
2
|
-
import { z, ZodDefault, ZodIntersection, ZodObject, ZodUnion, } from 'zod';
|
|
2
|
+
import { z, ZodDefault, ZodIntersection, ZodObject, ZodOptional, ZodUnion, } from 'zod';
|
|
3
3
|
const ConnectorEndpointSchema = z.nativeEnum(PointStyle);
|
|
4
4
|
const LineWidthSchema = z.nativeEnum(LineWidth);
|
|
5
5
|
const ShapeStyleSchema = z.nativeEnum(ShapeStyle);
|
|
@@ -165,3 +165,29 @@ export function makeDeepOptional(schema) {
|
|
|
165
165
|
return schema.optional();
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
+
const OptionalNodePropsSchema = makeDeepOptional(NodePropsSchema);
|
|
169
|
+
/**
|
|
170
|
+
* Pick, from an arbitrary bag of style props, the subset that is valid for
|
|
171
|
+
* the given node-props key. Filtering is per prop, so a prop foreign to the
|
|
172
|
+
* target type (e.g. a connector `mode` offered to a shape) never discards
|
|
173
|
+
* the rest of the bag. Returns null when nothing applies.
|
|
174
|
+
*/
|
|
175
|
+
export function pickStylePropsForKey(key, props) {
|
|
176
|
+
const keySchema = OptionalNodePropsSchema._def.innerType.shape[key];
|
|
177
|
+
const inner = keySchema instanceof ZodOptional ? keySchema.unwrap() : keySchema;
|
|
178
|
+
if (!(inner instanceof ZodObject))
|
|
179
|
+
return null;
|
|
180
|
+
const picked = {};
|
|
181
|
+
for (const [prop, value] of Object.entries(props)) {
|
|
182
|
+
const propSchema = inner.shape[prop];
|
|
183
|
+
if (!propSchema || value === undefined)
|
|
184
|
+
continue;
|
|
185
|
+
const parsed = propSchema.safeParse(value);
|
|
186
|
+
if (parsed.success && parsed.data !== undefined) {
|
|
187
|
+
picked[prop] = parsed.data;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return Object.keys(picked).length
|
|
191
|
+
? picked
|
|
192
|
+
: null;
|
|
193
|
+
}
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { Rect } from '../../global/gfx/index.js';
|
|
2
2
|
import type { AffineDragHandleWidget } from '../drag-handle.js';
|
|
3
|
+
type HoveredElemArea = {
|
|
4
|
+
left: number;
|
|
5
|
+
top: number;
|
|
6
|
+
right: number;
|
|
7
|
+
bottom: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
padding: number;
|
|
11
|
+
containerWidth: number;
|
|
12
|
+
};
|
|
3
13
|
/**
|
|
4
14
|
* Used to control the drag handle visibility in edgeless mode
|
|
5
15
|
*
|
|
@@ -8,23 +18,22 @@ import type { AffineDragHandleWidget } from '../drag-handle.js';
|
|
|
8
18
|
*/
|
|
9
19
|
export declare class EdgelessWatcher {
|
|
10
20
|
readonly widget: AffineDragHandleWidget;
|
|
21
|
+
private _pendingHoveredElemArea;
|
|
22
|
+
private _lastAppliedHoveredElemArea;
|
|
23
|
+
private _showDragHandleRafId;
|
|
24
|
+
private _surfaceElementUpdatedRafId;
|
|
25
|
+
private readonly _isAreaEqual;
|
|
26
|
+
private readonly _scheduleShowDragHandleFromSurfaceUpdate;
|
|
11
27
|
private readonly _handleEdgelessToolUpdated;
|
|
12
28
|
private readonly _handleEdgelessViewPortUpdated;
|
|
29
|
+
private readonly _flushShowDragHandle;
|
|
13
30
|
private readonly _showDragHandle;
|
|
14
31
|
private readonly _updateDragHoverRectTopLevelBlock;
|
|
15
32
|
get gfx(): import("../../std/gfx/controller.js").GfxController;
|
|
16
33
|
updateAnchorElement: () => void;
|
|
17
34
|
get hoveredElemAreaRect(): Rect | null;
|
|
18
|
-
get hoveredElemArea():
|
|
19
|
-
left: number;
|
|
20
|
-
top: number;
|
|
21
|
-
right: number;
|
|
22
|
-
bottom: number;
|
|
23
|
-
width: number;
|
|
24
|
-
height: number;
|
|
25
|
-
padding: number;
|
|
26
|
-
containerWidth: number;
|
|
27
|
-
} | null;
|
|
35
|
+
get hoveredElemArea(): HoveredElemArea | null;
|
|
28
36
|
constructor(widget: AffineDragHandleWidget);
|
|
29
37
|
watch(): void;
|
|
30
38
|
}
|
|
39
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EdgelessLegacySlotIdentifier } from '../../affine-block-surface/index.js';
|
|
2
|
-
import { getSelectedRect } from '../../affine-shared/utils/index.js';
|
|
2
|
+
import { getSelectedRect, toOverlayCoord } from '../../affine-shared/utils/index.js';
|
|
3
3
|
import { Rect } from '../../global/gfx/index.js';
|
|
4
4
|
import { GfxControllerIdentifier, } from '../../std/gfx/index.js';
|
|
5
5
|
import { effect } from '@preact/signals-core';
|
|
@@ -26,14 +26,21 @@ export class EdgelessWatcher {
|
|
|
26
26
|
return null;
|
|
27
27
|
const { viewport } = this.gfx;
|
|
28
28
|
const rect = getSelectedRect([edgelessElement]);
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
// The handle is drawn inside the container the host may have scaled, so
|
|
30
|
+
// the area it hugs is stated in that container's space, the way a gfx
|
|
31
|
+
// block states its own placement.
|
|
32
|
+
const { viewScale } = viewport;
|
|
33
|
+
let [left, top] = toOverlayCoord(viewport, rect.left, rect.top);
|
|
34
|
+
// The widget's scale tracks the viewport zoom
|
|
35
|
+
// (see `_handleEdgelessViewPortUpdated`); dividing it by `viewScale` is
|
|
36
|
+
// what `overlayScale` does for every other overlay.
|
|
37
|
+
const scale = this.widget.scale.peek() / viewScale;
|
|
31
38
|
const width = rect.width * scale;
|
|
32
39
|
const height = rect.height * scale;
|
|
33
40
|
let [right, bottom] = [left + width, top + height];
|
|
34
41
|
const padding = HOVER_AREA_RECT_PADDING_TOP_LEVEL * scale;
|
|
35
42
|
const containerWidth = DRAG_HANDLE_CONTAINER_WIDTH_TOP_LEVEL * scale;
|
|
36
|
-
const offsetLeft = DRAG_HANDLE_CONTAINER_OFFSET_LEFT_TOP_LEVEL;
|
|
43
|
+
const offsetLeft = DRAG_HANDLE_CONTAINER_OFFSET_LEFT_TOP_LEVEL / viewScale;
|
|
37
44
|
left -= containerWidth + offsetLeft;
|
|
38
45
|
right += padding;
|
|
39
46
|
bottom += padding;
|
|
@@ -50,6 +57,32 @@ export class EdgelessWatcher {
|
|
|
50
57
|
}
|
|
51
58
|
constructor(widget) {
|
|
52
59
|
this.widget = widget;
|
|
60
|
+
this._pendingHoveredElemArea = null;
|
|
61
|
+
this._lastAppliedHoveredElemArea = null;
|
|
62
|
+
this._showDragHandleRafId = null;
|
|
63
|
+
this._surfaceElementUpdatedRafId = null;
|
|
64
|
+
this._isAreaEqual = (left, right) => {
|
|
65
|
+
if (!left || !right)
|
|
66
|
+
return false;
|
|
67
|
+
return (left.left === right.left &&
|
|
68
|
+
left.top === right.top &&
|
|
69
|
+
left.right === right.right &&
|
|
70
|
+
left.bottom === right.bottom &&
|
|
71
|
+
left.width === right.width &&
|
|
72
|
+
left.height === right.height &&
|
|
73
|
+
left.padding === right.padding &&
|
|
74
|
+
left.containerWidth === right.containerWidth);
|
|
75
|
+
};
|
|
76
|
+
this._scheduleShowDragHandleFromSurfaceUpdate = () => {
|
|
77
|
+
if (this._surfaceElementUpdatedRafId !== null)
|
|
78
|
+
return;
|
|
79
|
+
this._surfaceElementUpdatedRafId = requestAnimationFrame(() => {
|
|
80
|
+
this._surfaceElementUpdatedRafId = null;
|
|
81
|
+
if (!this.widget.isGfxDragHandleVisible)
|
|
82
|
+
return;
|
|
83
|
+
this._showDragHandle();
|
|
84
|
+
});
|
|
85
|
+
};
|
|
53
86
|
this._handleEdgelessToolUpdated = (newTool) => {
|
|
54
87
|
if (newTool.toolType?.toolName === 'default') {
|
|
55
88
|
this.updateAnchorElement();
|
|
@@ -62,41 +95,99 @@ export class EdgelessWatcher {
|
|
|
62
95
|
if (this.widget.scale.peek() !== zoom) {
|
|
63
96
|
this.widget.scale.value = zoom;
|
|
64
97
|
}
|
|
65
|
-
|
|
98
|
+
// `||`, not `&&`: a pan along a single axis moves the centre just as much
|
|
99
|
+
// as a diagonal one does.
|
|
100
|
+
if (this.widget.center[0] !== center[0] ||
|
|
66
101
|
this.widget.center[1] !== center[1]) {
|
|
67
102
|
this.widget.center = [...center];
|
|
68
103
|
}
|
|
69
104
|
if (this.widget.isGfxDragHandleVisible) {
|
|
70
|
-
this
|
|
71
|
-
|
|
105
|
+
// Measured once and read twice: this runs on every frame of a pan or a
|
|
106
|
+
// zoom, and measuring means a layout read per selected element.
|
|
107
|
+
const area = this.hoveredElemArea;
|
|
108
|
+
this._showDragHandle(area);
|
|
109
|
+
this._updateDragHoverRectTopLevelBlock(area);
|
|
72
110
|
}
|
|
73
111
|
else if (this.widget.activeDragHandle) {
|
|
74
112
|
this.widget.hide();
|
|
75
113
|
}
|
|
76
114
|
};
|
|
77
|
-
this.
|
|
78
|
-
|
|
115
|
+
this._flushShowDragHandle = () => {
|
|
116
|
+
this._showDragHandleRafId = null;
|
|
117
|
+
// `anchorBlockId` is a signal, so the object itself is always truthy: its
|
|
118
|
+
// value is what says whether anything is anchored.
|
|
119
|
+
if (!this.widget.anchorBlockId.peek())
|
|
79
120
|
return;
|
|
80
121
|
const container = this.widget.dragHandleContainer;
|
|
81
122
|
const grabber = this.widget.dragHandleGrabber;
|
|
82
123
|
if (!container || !grabber)
|
|
83
124
|
return;
|
|
84
|
-
const area = this.hoveredElemArea;
|
|
125
|
+
const area = this._pendingHoveredElemArea ?? this.hoveredElemArea;
|
|
126
|
+
this._pendingHoveredElemArea = null;
|
|
85
127
|
if (!area)
|
|
86
128
|
return;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
129
|
+
if (this.widget.isGfxDragHandleVisible &&
|
|
130
|
+
this._isAreaEqual(this._lastAppliedHoveredElemArea, area)) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
// Every write below invalidates style, so each one happens only when it
|
|
134
|
+
// actually changes something.
|
|
135
|
+
if (container.style.transition !== 'none') {
|
|
136
|
+
container.style.transition = 'none';
|
|
137
|
+
}
|
|
138
|
+
if (container.style.paddingTop !== '0px') {
|
|
139
|
+
container.style.paddingTop = '0px';
|
|
140
|
+
}
|
|
141
|
+
if (container.style.paddingBottom !== '0px') {
|
|
142
|
+
container.style.paddingBottom = '0px';
|
|
143
|
+
}
|
|
144
|
+
const nextLeft = `${area.left}px`;
|
|
145
|
+
if (container.style.left !== nextLeft) {
|
|
146
|
+
container.style.left = nextLeft;
|
|
147
|
+
}
|
|
148
|
+
const nextTop = `${area.top}px`;
|
|
149
|
+
if (container.style.top !== nextTop) {
|
|
150
|
+
container.style.top = nextTop;
|
|
151
|
+
}
|
|
152
|
+
if (container.style.display !== 'flex') {
|
|
153
|
+
container.style.display = 'flex';
|
|
154
|
+
}
|
|
93
155
|
this.widget.handleAnchorModelDisposables();
|
|
94
156
|
this.widget.activeDragHandle = 'gfx';
|
|
157
|
+
this._lastAppliedHoveredElemArea = { ...area };
|
|
158
|
+
};
|
|
159
|
+
this._showDragHandle = (area) => {
|
|
160
|
+
this._pendingHoveredElemArea = area ?? this.hoveredElemArea;
|
|
161
|
+
if (!this._pendingHoveredElemArea) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (this.widget.isGfxDragHandleVisible &&
|
|
165
|
+
this._showDragHandleRafId === null &&
|
|
166
|
+
this._isAreaEqual(this._lastAppliedHoveredElemArea, this._pendingHoveredElemArea)) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (this._showDragHandleRafId !== null) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
this._showDragHandleRafId = requestAnimationFrame(this._flushShowDragHandle);
|
|
95
173
|
};
|
|
96
|
-
this._updateDragHoverRectTopLevelBlock = () => {
|
|
174
|
+
this._updateDragHoverRectTopLevelBlock = (area) => {
|
|
97
175
|
if (!this.widget.dragHoverRect)
|
|
98
176
|
return;
|
|
99
|
-
|
|
177
|
+
const nextArea = area ?? this.hoveredElemArea;
|
|
178
|
+
if (!nextArea) {
|
|
179
|
+
this.widget.dragHoverRect = null;
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const nextRect = new Rect(nextArea.left, nextArea.top, nextArea.right, nextArea.bottom);
|
|
183
|
+
const prevRect = this.widget.dragHoverRect;
|
|
184
|
+
if (prevRect.left === nextRect.left &&
|
|
185
|
+
prevRect.top === nextRect.top &&
|
|
186
|
+
prevRect.width === nextRect.width &&
|
|
187
|
+
prevRect.height === nextRect.height) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
this.widget.dragHoverRect = nextRect;
|
|
100
191
|
};
|
|
101
192
|
this.updateAnchorElement = () => {
|
|
102
193
|
if (!this.widget.isConnected)
|
|
@@ -128,6 +219,18 @@ export class EdgelessWatcher {
|
|
|
128
219
|
const { viewport, selection, tool, surface } = gfx;
|
|
129
220
|
const edgelessSlots = std.get(EdgelessLegacySlotIdentifier);
|
|
130
221
|
disposables.add(viewport.viewportUpdated.subscribe(this._handleEdgelessViewPortUpdated));
|
|
222
|
+
disposables.add(() => {
|
|
223
|
+
if (this._showDragHandleRafId !== null) {
|
|
224
|
+
cancelAnimationFrame(this._showDragHandleRafId);
|
|
225
|
+
this._showDragHandleRafId = null;
|
|
226
|
+
}
|
|
227
|
+
if (this._surfaceElementUpdatedRafId !== null) {
|
|
228
|
+
cancelAnimationFrame(this._surfaceElementUpdatedRafId);
|
|
229
|
+
this._surfaceElementUpdatedRafId = null;
|
|
230
|
+
}
|
|
231
|
+
this._pendingHoveredElemArea = null;
|
|
232
|
+
this._lastAppliedHoveredElemArea = null;
|
|
233
|
+
});
|
|
131
234
|
disposables.add(selection.slots.updated.subscribe(() => {
|
|
132
235
|
this.updateAnchorElement();
|
|
133
236
|
}));
|
|
@@ -156,11 +259,7 @@ export class EdgelessWatcher {
|
|
|
156
259
|
}
|
|
157
260
|
}));
|
|
158
261
|
if (surface) {
|
|
159
|
-
disposables.add(surface.elementUpdated.subscribe(
|
|
160
|
-
if (this.widget.isGfxDragHandleVisible) {
|
|
161
|
-
this._showDragHandle();
|
|
162
|
-
}
|
|
163
|
-
}));
|
|
262
|
+
disposables.add(surface.elementUpdated.subscribe(this._scheduleShowDragHandleFromSurfaceUpdate));
|
|
164
263
|
}
|
|
165
264
|
}
|
|
166
265
|
}
|
|
@@ -18,6 +18,8 @@ export declare class PointerEventWatcher {
|
|
|
18
18
|
private readonly _grabberStyle;
|
|
19
19
|
private _lastHoveredBlockId;
|
|
20
20
|
private _lastShowedBlock;
|
|
21
|
+
private _lastPointerHitBlockId;
|
|
22
|
+
private _lastPointerHitBlockElement;
|
|
21
23
|
/**
|
|
22
24
|
* When pointer move on block, should show drag handle
|
|
23
25
|
* And update hover block id and path
|
|
@@ -106,6 +106,8 @@ export class PointerEventWatcher {
|
|
|
106
106
|
});
|
|
107
107
|
this._lastHoveredBlockId = null;
|
|
108
108
|
this._lastShowedBlock = null;
|
|
109
|
+
this._lastPointerHitBlockId = null;
|
|
110
|
+
this._lastPointerHitBlockElement = null;
|
|
109
111
|
/**
|
|
110
112
|
* When pointer move on block, should show drag handle
|
|
111
113
|
* And update hover block id and path
|
|
@@ -118,6 +120,7 @@ export class PointerEventWatcher {
|
|
|
118
120
|
return;
|
|
119
121
|
const closestBlock = getClosestBlockByPoint(this.widget.host, this.widget.rootComponent, point);
|
|
120
122
|
if (!closestBlock) {
|
|
123
|
+
this._lastPointerHitBlockId = null;
|
|
121
124
|
this.widget.anchorBlockId.value = null;
|
|
122
125
|
return;
|
|
123
126
|
}
|
|
@@ -169,19 +172,35 @@ export class PointerEventWatcher {
|
|
|
169
172
|
if (this.widget.isGfxDragHandleVisible)
|
|
170
173
|
return;
|
|
171
174
|
const state = ctx.get('pointerState');
|
|
172
|
-
// When pointer is moving, should do nothing
|
|
173
|
-
if (state.delta.x !== 0 && state.delta.y !== 0)
|
|
174
|
-
return;
|
|
175
175
|
const { target } = state.raw;
|
|
176
176
|
const element = captureEventTarget(target);
|
|
177
177
|
// When pointer not on block or on dragging, should do nothing
|
|
178
|
-
if (!element)
|
|
178
|
+
if (!element) {
|
|
179
|
+
this._lastPointerHitBlockId = null;
|
|
180
|
+
this._lastPointerHitBlockElement = null;
|
|
179
181
|
return;
|
|
182
|
+
}
|
|
180
183
|
// When pointer on drag handle, should do nothing
|
|
181
184
|
if (element.closest('.affine-drag-handle-container'))
|
|
182
185
|
return;
|
|
183
186
|
if (!this.widget.rootComponent)
|
|
184
187
|
return;
|
|
188
|
+
const hitBlock = element.closest(`[${BLOCK_ID_ATTR}]`);
|
|
189
|
+
const hitBlockId = hitBlock?.getAttribute(BLOCK_ID_ATTR) ?? null;
|
|
190
|
+
// Pointer moves arrive by the hundred. The note lookup below walks the
|
|
191
|
+
// tree and measures, so it is worth doing only when the pointer has
|
|
192
|
+
// actually left the block it was already on. This replaces a guard that
|
|
193
|
+
// skipped diagonal moves only, which cost the same work on every
|
|
194
|
+
// straight move and skipped the update on every diagonal one.
|
|
195
|
+
if (hitBlockId &&
|
|
196
|
+
this.widget.isBlockDragHandleVisible &&
|
|
197
|
+
hitBlockId === this._lastPointerHitBlockId &&
|
|
198
|
+
hitBlock === this._lastPointerHitBlockElement &&
|
|
199
|
+
isBlockIdEqual(this.widget.anchorBlockId.peek(), hitBlockId)) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
this._lastPointerHitBlockId = hitBlockId;
|
|
203
|
+
this._lastPointerHitBlockElement = hitBlock;
|
|
185
204
|
// When pointer out of note block hover area or inside database, should hide drag handle
|
|
186
205
|
const point = new Point(state.raw.x, state.raw.y);
|
|
187
206
|
const closestNoteBlock = getClosestNoteBlock(this.widget.host, this.widget.rootComponent, point);
|
|
@@ -257,6 +276,8 @@ export class PointerEventWatcher {
|
|
|
257
276
|
reset() {
|
|
258
277
|
this._lastHoveredBlockId = null;
|
|
259
278
|
this._lastShowedBlock = null;
|
|
279
|
+
this._lastPointerHitBlockId = null;
|
|
280
|
+
this._lastPointerHitBlockElement = null;
|
|
260
281
|
}
|
|
261
282
|
watch() {
|
|
262
283
|
this.widget.handleEvent('click', this._clickHandler);
|
|
@@ -39,7 +39,7 @@ import { mountShapeTextEditor, SHAPE_OVERLAY_HEIGHT, SHAPE_OVERLAY_WIDTH, ShapeC
|
|
|
39
39
|
import { insertEdgelessTextCommand, mountTextElementEditor, } from '../affine-gfx-text/index.js';
|
|
40
40
|
import { DEFAULT_NOTE_WIDTH, DefaultTheme, FontFamily, FontStyle, FontWeight, getShapeName, GroupElementModel, NoteBlockModel, ShapeStyle, TextElementModel, } from '../affine-model/index.js';
|
|
41
41
|
import { EditPropsStore, FeatureFlagService, ThemeProvider, } from '../affine-shared/services/index.js';
|
|
42
|
-
import { captureEventTarget, matchModels, } from '../affine-shared/utils/index.js';
|
|
42
|
+
import { captureEventTarget, matchModels, overlayScale, overlayViewportSize, toOverlayCoord, } from '../affine-shared/utils/index.js';
|
|
43
43
|
import { Bound, clamp, normalizeDegAngle, serializeXYWH, toDegree, Vec, } from '../global/gfx/index.js';
|
|
44
44
|
import { WithDisposable } from '../global/lit/index.js';
|
|
45
45
|
import { FrameIcon, PageIcon } from '@blocksuite/icons/lit';
|
|
@@ -369,11 +369,16 @@ let EdgelessAutoCompletePanel = (() => {
|
|
|
369
369
|
}
|
|
370
370
|
_getPanelPosition() {
|
|
371
371
|
const { viewport } = this.gfx;
|
|
372
|
-
|
|
373
|
-
|
|
372
|
+
// The panel is appended to the edgeless container, so its `left`/`top`
|
|
373
|
+
// live in that container's space — already scaled by the host, the way a
|
|
374
|
+
// gfx block's placement is. Both the panel's own size and the edges it is
|
|
375
|
+
// kept away from have to be stated there too, or the clamp fires against
|
|
376
|
+
// screen pixels the panel is not measured in.
|
|
377
|
+
const scale = overlayScale(viewport);
|
|
378
|
+
const result = this._getTargetXYWH(PANEL_WIDTH / scale, PANEL_HEIGHT / scale);
|
|
374
379
|
const pos = result ? result.xywh.slice(0, 2) : this.position;
|
|
375
|
-
const coord = viewport
|
|
376
|
-
const
|
|
380
|
+
const coord = toOverlayCoord(viewport, pos[0], pos[1]);
|
|
381
|
+
const [width, height] = overlayViewportSize(viewport);
|
|
377
382
|
coord[0] = clamp(coord[0], 20, width - 20 - PANEL_WIDTH);
|
|
378
383
|
coord[1] = clamp(coord[1], 20, height - 20 - PANEL_HEIGHT);
|
|
379
384
|
return coord;
|