@formicoidea/labre-core 0.43.1 → 0.46.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-callout-into.d.ts +43 -0
- package/dist/_pkgs/affine-block-callout/commands/turn-callout-into.js +109 -0
- 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/toolbar.d.ts +65 -0
- package/dist/_pkgs/affine-block-callout/configs/toolbar.js +178 -0
- 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 +10 -1
- 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-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/configs/toolbar.js +11 -2
- package/dist/_pkgs/affine-block-embed/embed-iframe-block/configs/toolbar.js +11 -2
- 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-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-frame/commands.d.ts +27 -0
- package/dist/_pkgs/affine-block-frame/commands.js +49 -0
- package/dist/_pkgs/affine-block-frame/frame-manager.d.ts +16 -6
- package/dist/_pkgs/affine-block-frame/frame-manager.js +58 -22
- package/dist/_pkgs/affine-block-frame/frame-order.d.ts +43 -0
- package/dist/_pkgs/affine-block-frame/frame-order.js +93 -0
- package/dist/_pkgs/affine-block-frame/frame-tool.js +3 -1
- package/dist/_pkgs/affine-block-frame/index.d.ts +2 -0
- package/dist/_pkgs/affine-block-frame/index.js +2 -0
- package/dist/_pkgs/affine-block-frame/present/frame-order-menu.d.ts +10 -2
- package/dist/_pkgs/affine-block-frame/present/frame-order-menu.js +32 -18
- package/dist/_pkgs/affine-block-frame/view.js +6 -0
- 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-note/configs/toolbar.d.ts +19 -0
- package/dist/_pkgs/affine-block-note/configs/toolbar.js +38 -23
- package/dist/_pkgs/affine-block-note/translations.d.ts +2 -1
- package/dist/_pkgs/affine-block-note/translations.js +14 -6
- package/dist/_pkgs/affine-block-root/configs/toolbar.js +48 -3
- 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/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/translations.d.ts +7 -2
- package/dist/_pkgs/affine-block-root/translations.js +10 -13
- 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/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 +91 -0
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.js +285 -0
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.d.ts +80 -0
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.js +355 -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.d.ts +112 -4
- package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.js +86 -15
- 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/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/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/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/surface-ref-block.js +12 -2
- package/dist/_pkgs/affine-components/context-menu/button.js +14 -0
- package/dist/_pkgs/affine-components/filterable-list/index.js +30 -9
- 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/text.d.ts +1 -0
- package/dist/_pkgs/affine-components/icons/text.js +11 -0
- package/dist/_pkgs/affine-components/portal/portal.d.ts +1 -1
- package/dist/_pkgs/affine-foundation/view.d.ts +8 -8
- package/dist/_pkgs/affine-fragment-adapter-panel/adapter-panel.d.ts +2 -2
- package/dist/_pkgs/affine-fragment-frame-panel/body/frame-panel-body.d.ts +34 -2
- package/dist/_pkgs/affine-fragment-frame-panel/body/frame-panel-body.js +194 -81
- package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card.d.ts +7 -4
- package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card.js +9 -24
- 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 +2 -0
- package/dist/_pkgs/affine-fragment-frame-panel/index.js +2 -0
- 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 +3 -2
- package/dist/_pkgs/affine-gfx-connector/toolbar/config.js +1 -1
- package/dist/_pkgs/affine-gfx-group/command/group-api.js +52 -1
- 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 +1 -1
- 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-text/edgeless-text-editor.js +2 -1
- 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 +53 -2
- 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-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 +26 -0
- package/dist/_pkgs/affine-model/consts/text.js +25 -0
- 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-model/utils/types.d.ts +2 -2
- 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 +31 -4
- 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 +2 -2
- package/dist/_pkgs/affine-shared/services/font-loader/font-loader-service.d.ts +3 -3
- package/dist/_pkgs/affine-shared/services/index.d.ts +4 -1
- package/dist/_pkgs/affine-shared/services/index.js +4 -1
- package/dist/_pkgs/affine-shared/services/link-preview-service/link-preview-storage.d.ts +4 -4
- package/dist/_pkgs/affine-shared/services/outline-panel-service.d.ts +31 -0
- package/dist/_pkgs/affine-shared/services/outline-panel-service.js +17 -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/translation-service/chrome.d.ts +16 -0
- package/dist/_pkgs/affine-shared/services/translation-service/chrome.js +28 -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 +3 -0
- package/dist/_pkgs/affine-shared/utils/index.js +3 -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-shared/utils/panel-reorder-drag.d.ts +85 -0
- package/dist/_pkgs/affine-shared/utils/panel-reorder-drag.js +162 -0
- package/dist/_pkgs/affine-widget-edgeless-selected-rect/utils.js +10 -3
- package/dist/_pkgs/affine-widget-edgeless-toolbar/catalogue/artefact-catalogue-widget.js +25 -49
- 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/selection-pane/drop.d.ts +62 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.js +94 -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 +186 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.js +1417 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.d.ts +52 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.js +161 -1
- package/dist/_pkgs/affine-widget-edgeless-toolbar/view.js +10 -0
- package/dist/_pkgs/affine-widget-note-slicer/note-slicer.js +7 -3
- 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/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/scope/std-scope.d.ts +1 -1
- 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 -1
- package/dist/host-panels.d.ts +90 -0
- package/dist/host-panels.js +111 -0
- package/dist/translations.js +10 -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-fragment-frame-panel/utils/drag.d.ts +0 -27
- package/dist/_pkgs/affine-fragment-frame-panel/utils/drag.js +0 -96
- package/dist/_pkgs/affine-shared/services/sidebar-service.d.ts +0 -8
- package/dist/_pkgs/affine-shared/services/sidebar-service.js +0 -7
- 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
|
@@ -143,10 +143,6 @@ export const NOTE_DISPLAY_MODE_LABEL = [
|
|
|
143
143
|
'com.labre.note.display-mode.mode-label',
|
|
144
144
|
'Mode',
|
|
145
145
|
];
|
|
146
|
-
export const NOTE_DISPLAY_MODE_TOOLTIP = [
|
|
147
|
-
'com.labre.note.display-mode.tooltip',
|
|
148
|
-
'Display mode',
|
|
149
|
-
];
|
|
150
146
|
/** An alias (L7 dedupe): the same word as {@link DISPLAY_MODE_BOTH}, one key. */
|
|
151
147
|
export const NOTE_DISPLAY_MODE_BOTH = DISPLAY_MODE_BOTH;
|
|
152
148
|
/** An alias (L7 dedupe): the same word as {@link DISPLAY_MODE_EDGELESS}, one key. */
|
|
@@ -158,7 +154,10 @@ export const NOTE_DISPLAY_MODE_PAGE = DISPLAY_MODE_PAGE;
|
|
|
158
154
|
* `TOAST_NOTE_REMOVED_FROM_PAGE` (already in `chrome.ts`); its opposite gets
|
|
159
155
|
* its own key here. Each toast's BODY bakes in the trailing "Find it in the
|
|
160
156
|
* TOC…" sentence rather than composing it at the call site — one full
|
|
161
|
-
* sentence per key, never a fragment plus a suffix.
|
|
157
|
+
* sentence per key, never a fragment plus a suffix. That sentence promises the
|
|
158
|
+
* "View in TOC" link, which exists only when the host registers an outline
|
|
159
|
+
* panel (`OutlinePanelExtension`, ADR 0034); each body therefore has a
|
|
160
|
+
* `body-no-toc` twin without it, picked when no outline answers.
|
|
162
161
|
*/
|
|
163
162
|
export const NOTE_TOAST_DISPLAYED_IN_PAGE_MODE = [
|
|
164
163
|
'com.labre.note.toast.displayed-in-page-mode',
|
|
@@ -172,6 +171,14 @@ export const NOTE_TOAST_ADDED_TO_PAGE_BODY = [
|
|
|
172
171
|
'com.labre.note.toast.added-to-page.body',
|
|
173
172
|
'Content added to your document. Find it in the TOC for quick navigation.',
|
|
174
173
|
];
|
|
174
|
+
export const NOTE_TOAST_REMOVED_FROM_PAGE_BODY_NO_TOC = [
|
|
175
|
+
'com.labre.note.toast.removed-from-page.body-no-toc',
|
|
176
|
+
'Content removed from your document.',
|
|
177
|
+
];
|
|
178
|
+
export const NOTE_TOAST_ADDED_TO_PAGE_BODY_NO_TOC = [
|
|
179
|
+
'com.labre.note.toast.added-to-page.body-no-toc',
|
|
180
|
+
'Content added to your document.',
|
|
181
|
+
];
|
|
175
182
|
export const NOTE_TOAST_VIEW_IN_TOC = [
|
|
176
183
|
'com.labre.note.toast.view-in-toc',
|
|
177
184
|
'View in Toc',
|
|
@@ -237,10 +244,11 @@ export const NOTE_WORDINGS = [
|
|
|
237
244
|
NOTE_STYLE_CUSTOM_COLOR,
|
|
238
245
|
NOTE_STYLE_PANEL_LABEL,
|
|
239
246
|
NOTE_DISPLAY_MODE_LABEL,
|
|
240
|
-
NOTE_DISPLAY_MODE_TOOLTIP,
|
|
241
247
|
NOTE_TOAST_DISPLAYED_IN_PAGE_MODE,
|
|
242
248
|
NOTE_TOAST_REMOVED_FROM_PAGE_BODY,
|
|
243
249
|
NOTE_TOAST_ADDED_TO_PAGE_BODY,
|
|
250
|
+
NOTE_TOAST_REMOVED_FROM_PAGE_BODY_NO_TOC,
|
|
251
|
+
NOTE_TOAST_ADDED_TO_PAGE_BODY_NO_TOC,
|
|
244
252
|
NOTE_TOAST_VIEW_IN_TOC,
|
|
245
253
|
NOTE_TOOLBAR_DISPLAY_IN_PAGE,
|
|
246
254
|
NOTE_TOOLBAR_DISPLAYED_IN_PAGE,
|
|
@@ -5,7 +5,7 @@ import { toast } from '../../affine-components/toast/index.js';
|
|
|
5
5
|
import { EditorChevronDown } from '../../affine-components/toolbar/index.js';
|
|
6
6
|
import { deleteTextCommand, formatBlockCommand, formatNativeCommand, formatTextCommand, isFormatSupported, textFormatConfigs, } from '../../affine-inline-preset/index.js';
|
|
7
7
|
import { EmbedLinkedDocBlockSchema, EmbedSyncedDocBlockSchema, } from '../../affine-model/index.js';
|
|
8
|
-
import { textConversionConfigs } from '../../affine-rich-text/index.js';
|
|
8
|
+
import { textConversionConfigs, TextConversionEntryIdentifier, } from '../../affine-rich-text/index.js';
|
|
9
9
|
import { copySelectedModelsCommand, deleteSelectedModelsCommand, draftSelectedModelsCommand, duplicateSelectedModelsCommand, getBlockSelectionsCommand, getImageSelectionsCommand, getSelectedBlocksCommand, getSelectedModelsCommand, getTextSelectionCommand, } from '../../affine-shared/commands/index.js';
|
|
10
10
|
import { ActionPlacement, blockCommentToolbarButton, TOAST_COPIED_TO_CLIPBOARD, TOOLBAR_COPY, TOOLBAR_DELETE, TOOLBAR_DUPLICATE, translateKey, } from '../../affine-shared/services/index.js';
|
|
11
11
|
import { tableViewMeta } from '../../data-view/view-presets/index.js';
|
|
@@ -42,6 +42,11 @@ const conversionsActionGroup = {
|
|
|
42
42
|
})
|
|
43
43
|
.run();
|
|
44
44
|
};
|
|
45
|
+
// Conversions a gated block package registers from its own view extension
|
|
46
|
+
// (#418): absent when its flag is off, so never listed statically here.
|
|
47
|
+
const contributed = [
|
|
48
|
+
...std.provider.getAll(TextConversionEntryIdentifier).values(),
|
|
49
|
+
].filter(entry => entry.when(std, selectedModels));
|
|
45
50
|
return {
|
|
46
51
|
content: html `
|
|
47
52
|
<editor-menu-button
|
|
@@ -65,6 +70,17 @@ const conversionsActionGroup = {
|
|
|
65
70
|
${icon}<span class="label">${name}</span>
|
|
66
71
|
</editor-menu-action>
|
|
67
72
|
`)}
|
|
73
|
+
${repeat(contributed, entry => entry.flavour, entry => {
|
|
74
|
+
const label = translateKey(std, ...entry.nameWording);
|
|
75
|
+
return html `
|
|
76
|
+
<editor-menu-action
|
|
77
|
+
aria-label=${label}
|
|
78
|
+
@click=${() => entry.run(std, selectedModels)}
|
|
79
|
+
>
|
|
80
|
+
${entry.icon}<span class="label">${label}</span>
|
|
81
|
+
</editor-menu-action>
|
|
82
|
+
`;
|
|
83
|
+
})}
|
|
68
84
|
</div>
|
|
69
85
|
</editor-menu-button>
|
|
70
86
|
`,
|
|
@@ -255,12 +271,41 @@ export const builtinToolbarConfig = {
|
|
|
255
271
|
blockId: block.model.id,
|
|
256
272
|
})));
|
|
257
273
|
}
|
|
258
|
-
|
|
274
|
+
// The copy lands right after the last selected block that no other
|
|
275
|
+
// selected block contains. Said explicitly: the command's default
|
|
276
|
+
// anchors on the LAST selected model, which in `flat` mode below
|
|
277
|
+
// is a descendant — and `highest` keeps a block-selected child of
|
|
278
|
+
// a block-selected parent too, so with both selected the copy went
|
|
279
|
+
// INSIDE the parent, after the child.
|
|
280
|
+
const [, { selectedModels: highest = [] }] = chain
|
|
259
281
|
.pipe(getSelectedModelsCommand, {
|
|
260
282
|
types: ['block', 'image'],
|
|
261
283
|
mode: 'highest',
|
|
262
284
|
})
|
|
263
|
-
.
|
|
285
|
+
.run();
|
|
286
|
+
const selected = new Set(highest);
|
|
287
|
+
const hasSelectedAncestor = (model) => {
|
|
288
|
+
for (let at = store.getParent(model); at; at = store.getParent(at))
|
|
289
|
+
if (selected.has(at))
|
|
290
|
+
return true;
|
|
291
|
+
return false;
|
|
292
|
+
};
|
|
293
|
+
const last = highest.findLast(model => !hasSelectedAncestor(model));
|
|
294
|
+
const parentModel = last && store.getParent(last);
|
|
295
|
+
if (!last || !parentModel)
|
|
296
|
+
return;
|
|
297
|
+
// `flat`, not `highest`: `draftSelectedModelsCommand` keeps a
|
|
298
|
+
// drafted block's children only when they are selected too, so a
|
|
299
|
+
// paragraph duplicated alone lost its nested children.
|
|
300
|
+
chain
|
|
301
|
+
.pipe(getSelectedModelsCommand, {
|
|
302
|
+
types: ['block', 'image'],
|
|
303
|
+
mode: 'flat',
|
|
304
|
+
})
|
|
305
|
+
.pipe(duplicateSelectedModelsCommand, {
|
|
306
|
+
parentModel,
|
|
307
|
+
index: parentModel.children.indexOf(last) + 1,
|
|
308
|
+
})
|
|
264
309
|
.run();
|
|
265
310
|
},
|
|
266
311
|
},
|
|
@@ -7,7 +7,7 @@ import { BookmarkStyles, DEFAULT_NOTE_HEIGHT, DEFAULT_NOTE_WIDTH, FrameBlockMode
|
|
|
7
7
|
import { ClipboardAdapter, decodeClipboardBlobs, ImageProxyService, } from '../../../affine-shared/adapters/index.js';
|
|
8
8
|
import { CANVAS_EXPORT_IGNORE_TAGS, EMBED_CARD_HEIGHT, EMBED_CARD_WIDTH, } from '../../../affine-shared/consts/index.js';
|
|
9
9
|
import { EmbedOptionProvider, ParseDocUrlProvider, TelemetryProvider, } from '../../../affine-shared/services/index.js';
|
|
10
|
-
import { convertToPng, isInsidePageEditor, isTopLevelBlock, isUrlInClipboard, matchModels, referenceToNode, } from '../../../affine-shared/utils/index.js';
|
|
10
|
+
import { convertToPng, isInsidePageEditor, isTopLevelBlock, isUrlInClipboard, matchModels, normalizeCanvasExportColors, referenceToNode, } from '../../../affine-shared/utils/index.js';
|
|
11
11
|
import { DisposableGroup } from '../../../global/disposable/index.js';
|
|
12
12
|
import { BlockSuiteError, ErrorCode } from '../../../global/exceptions/index.js';
|
|
13
13
|
import { Bound, getCommonBound, Vec, } from '../../../global/gfx/index.js';
|
|
@@ -336,6 +336,7 @@ export class EdgelessClipboardController extends PageClipboard {
|
|
|
336
336
|
}
|
|
337
337
|
},
|
|
338
338
|
onclone: async function (documentClone, element) {
|
|
339
|
+
normalizeCanvasExportColors(documentClone, element);
|
|
339
340
|
// html2canvas can't support transform feature
|
|
340
341
|
element.style.setProperty('transform', 'none');
|
|
341
342
|
const layer = documentClone.querySelector('.affine-edgeless-layer');
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isFrameBlock } from '../../../affine-block-frame/index.js';
|
|
2
|
+
import { EdgelessClipboardConfigIdentifier, EdgelessCRUDIdentifier, resolveCreationLayer, writeModelLayer, } from '../../../affine-block-surface/index.js';
|
|
2
3
|
import { Bound } from '../../../global/gfx/index.js';
|
|
3
4
|
import { assertType } from '../../../global/utils/index.js';
|
|
4
|
-
import { GfxControllerIdentifier,
|
|
5
|
+
import { DEFAULT_LAYER_ID, GfxControllerIdentifier, ownLayerOf, } from '../../../std/gfx/index.js';
|
|
5
6
|
import { BlockSnapshotSchema } from '../../../store/index.js';
|
|
6
7
|
import { createCanvasElement } from './canvas.js';
|
|
8
|
+
import { pastedIndexes, pastedParentage } from './paste-order.js';
|
|
7
9
|
import { createNewPresentationIndexes, edgelessElementsBoundFromRawData, } from './utils.js';
|
|
8
10
|
export const createElementsFromClipboardDataCommand = (ctx, next) => {
|
|
9
11
|
const { std, elementsRawData } = ctx;
|
|
@@ -33,60 +35,116 @@ export const createElementsFromClipboardDataCommand = (ctx, next) => {
|
|
|
33
35
|
const blockModels = [];
|
|
34
36
|
const canvasElements = [];
|
|
35
37
|
const allElements = [];
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
blockModels.push(block.model);
|
|
63
|
-
allElements.push(block.model);
|
|
64
|
-
context.oldToNewIdMap.set(oldId, newId);
|
|
65
|
-
context.originalIndexes.set(oldId, originalIndex);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
assertType(data);
|
|
69
|
-
const oldId = data.id;
|
|
38
|
+
// Read before anything is created: `createCanvasElement` rewrites a
|
|
39
|
+
// group's `children` with the new ids.
|
|
40
|
+
const oldParents = pastedParentage(elementsRawData);
|
|
41
|
+
// Decided before anything is created too, so that a canvas element is
|
|
42
|
+
// born with its final index: written afterwards, each index moved an
|
|
43
|
+
// element already on the board, through the layer manager, one by one.
|
|
44
|
+
const newIndexes = pastedIndexes(std, elementsRawData, oldParents, context.originalIndexes);
|
|
45
|
+
const blockIndexes = new Map();
|
|
46
|
+
// What each block's snapshot asked for, read before its config creates
|
|
47
|
+
// it; applied in the final transaction (`keepSourceLayerAndHide`).
|
|
48
|
+
const blockRequests = new Map();
|
|
49
|
+
// Canvas elements are written in as few transactions as the blocks allow,
|
|
50
|
+
// so a peer receives one update for a run of them instead of one per
|
|
51
|
+
// element (plus one per index fix-up). A block cannot join: its config's
|
|
52
|
+
// `createBlock` may be async (notes, texts, images and attachments go
|
|
53
|
+
// through the transformer, which awaits), and a Yjs transaction cannot
|
|
54
|
+
// span an `await`. So the run of canvas elements before a block is written
|
|
55
|
+
// first — the block may reference them (a frame's `childElementIds`) —
|
|
56
|
+
// and the last run is written together with the final indexes.
|
|
57
|
+
// ponytail: a block still costs its own transactions; a two-phase config
|
|
58
|
+
// contract (async prepare, then a sync write) is the upgrade path.
|
|
59
|
+
const pendingCanvasElements = [];
|
|
60
|
+
const seen = new Set();
|
|
61
|
+
const createPendingCanvasElements = () => {
|
|
62
|
+
for (const data of pendingCanvasElements) {
|
|
63
|
+
data.index = newIndexes.get(data.id) ?? data.index;
|
|
70
64
|
const element = createCanvasElement(std, data, context, getNewXYWH(data.xywh));
|
|
71
65
|
if (!element)
|
|
72
66
|
continue;
|
|
73
67
|
canvasElements.push(element);
|
|
74
68
|
allElements.push(element);
|
|
75
|
-
context.oldToNewIdMap.set(
|
|
76
|
-
context.originalIndexes.set(oldId, element.index);
|
|
69
|
+
context.oldToNewIdMap.set(data.id, element.id);
|
|
77
70
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
71
|
+
pendingCanvasElements.length = 0;
|
|
72
|
+
};
|
|
73
|
+
// One gesture, one undo step: close whatever the previous gesture left
|
|
74
|
+
// open in the undo manager's capture window.
|
|
75
|
+
// ponytail: the paste's own transactions then merge only while each ends
|
|
76
|
+
// within that window (500 ms) of the one before, so a block whose creation
|
|
77
|
+
// takes longer splits the step; the two-phase contract above removes the
|
|
78
|
+
// ceiling (the budget spec measures it on 406 elements).
|
|
79
|
+
std.store.captureSync();
|
|
80
|
+
for (const data of elementsRawData) {
|
|
81
|
+
// Clipboard data written before `sortEdgelessElements` deduplicated can
|
|
82
|
+
// list one element twice; the first copy is the one its container maps.
|
|
83
|
+
if (seen.has(data.id))
|
|
84
|
+
continue;
|
|
85
|
+
seen.add(data.id);
|
|
86
|
+
const { data: blockSnapshot } = BlockSnapshotSchema.safeParse(data);
|
|
87
|
+
if (!blockSnapshot) {
|
|
88
|
+
assertType(data);
|
|
89
|
+
pendingCanvasElements.push(data);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (pendingCanvasElements.length > 0) {
|
|
93
|
+
std.store.transact(createPendingCanvasElements);
|
|
94
|
+
}
|
|
95
|
+
const oldId = blockSnapshot.id;
|
|
96
|
+
const config = std.getOptional(EdgelessClipboardConfigIdentifier(blockSnapshot.flavour));
|
|
97
|
+
if (!config)
|
|
98
|
+
continue;
|
|
99
|
+
if (typeof blockSnapshot.props.index !== 'string') {
|
|
100
|
+
console.error(`Block(id: ${oldId}) does not have index property`);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (typeof blockSnapshot.props.xywh !== 'string') {
|
|
104
|
+
console.error(`Block(id: ${oldId}) does not have xywh property`);
|
|
105
|
+
continue;
|
|
87
106
|
}
|
|
107
|
+
assertType(blockSnapshot.props);
|
|
108
|
+
blockSnapshot.props.xywh = getNewXYWH(blockSnapshot.props.xywh);
|
|
109
|
+
blockSnapshot.props.lockedBySelf = false;
|
|
110
|
+
const requested = {
|
|
111
|
+
layer: blockSnapshot.props.layer,
|
|
112
|
+
hiddenForEveryone: blockSnapshot.props.hiddenForEveryone,
|
|
113
|
+
};
|
|
114
|
+
const newId = await config.createBlock(blockSnapshot, context);
|
|
115
|
+
if (!newId)
|
|
116
|
+
continue;
|
|
117
|
+
const block = std.store.getBlock(newId);
|
|
118
|
+
if (!block)
|
|
119
|
+
continue;
|
|
120
|
+
assertType(block.model);
|
|
121
|
+
blockRequests.set(block.model, requested);
|
|
122
|
+
blockModels.push(block.model);
|
|
123
|
+
allElements.push(block.model);
|
|
124
|
+
context.oldToNewIdMap.set(oldId, newId);
|
|
125
|
+
const index = newIndexes.get(oldId);
|
|
126
|
+
if (index)
|
|
127
|
+
blockIndexes.set(block.model, index);
|
|
128
|
+
}
|
|
129
|
+
std.store.transact(() => {
|
|
130
|
+
createPendingCanvasElements();
|
|
131
|
+
const parents = new Map();
|
|
132
|
+
oldParents.forEach((oldParent, oldChild) => {
|
|
133
|
+
const child = context.oldToNewIdMap.get(oldChild);
|
|
134
|
+
const parent = context.oldToNewIdMap.get(oldParent);
|
|
135
|
+
if (child && parent)
|
|
136
|
+
parents.set(child, parent);
|
|
137
|
+
});
|
|
138
|
+
releaseChildrenFromAdoptingFrames(std, allElements, parents);
|
|
139
|
+
// A block config chooses its own index (a frame takes the top of the
|
|
140
|
+
// board, a note the transformer's): set the planned one afterwards.
|
|
141
|
+
const crud = std.get(EdgelessCRUDIdentifier);
|
|
142
|
+
blockIndexes.forEach((index, block) => {
|
|
143
|
+
if (block.index !== index)
|
|
144
|
+
crud.updateElement(block.id, { index });
|
|
145
|
+
});
|
|
146
|
+
blockRequests.forEach((requested, block) => keepSourceLayerAndHide(std, block, requested));
|
|
88
147
|
});
|
|
89
|
-
updatePastedElementsIndex(std, allElements, context.originalIndexes);
|
|
90
148
|
return {
|
|
91
149
|
canvasElements: canvasElements,
|
|
92
150
|
blockModels: blockModels,
|
|
@@ -96,42 +154,62 @@ export const createElementsFromClipboardDataCommand = (ctx, next) => {
|
|
|
96
154
|
createdElementsPromise: runner(),
|
|
97
155
|
});
|
|
98
156
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
157
|
+
/**
|
|
158
|
+
* A pasted or duplicated block gets what a pasted element gets from
|
|
159
|
+
* `crud.addElement`, which forwards every serialized prop (ADR 0031 §6 and
|
|
160
|
+
* "What stays loadable"): its `layer` when it names a layer of this surface,
|
|
161
|
+
* else the active one, and its `hiddenForEveryone`. Most
|
|
162
|
+
* `EdgelessClipboardConfig.createBlock` rebuild the block from a handful of
|
|
163
|
+
* the snapshot's props (frame, image, attachment, bookmark, the embeds…), so
|
|
164
|
+
* a duplicate fell in the active layer and came back visible. The rule is
|
|
165
|
+
* applied once here, for every config, rather than in each of them; nothing
|
|
166
|
+
* is written when the config already carried both.
|
|
167
|
+
*
|
|
168
|
+
* `requested` is read BEFORE `createBlock`: the snapshot-pasting configs
|
|
169
|
+
* stamp `snapshot.props` in place, and an explicit default-layer request from
|
|
170
|
+
* a clone gesture (`prepareCloneData`) is gone from it afterwards. Called
|
|
171
|
+
* inside the paste's final transaction, beside the index fix-ups, so it adds
|
|
172
|
+
* no update of its own.
|
|
173
|
+
*/
|
|
174
|
+
function keepSourceLayerAndHide(std, model, requested) {
|
|
175
|
+
const layer = resolveCreationLayer(std, requested.layer) ?? DEFAULT_LAYER_ID;
|
|
176
|
+
if (layer !== (ownLayerOf(model) ?? DEFAULT_LAYER_ID)) {
|
|
177
|
+
writeModelLayer(std, model, layer);
|
|
178
|
+
}
|
|
179
|
+
if (requested.hiddenForEveryone === true &&
|
|
180
|
+
model.props.hiddenForEveryone !== true) {
|
|
181
|
+
std.store.updateBlock(model, { hiddenForEveryone: true });
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The paste creates children before their container (post-order), and the
|
|
186
|
+
* frame manager adopts whatever is created inside a frame — a block at once on
|
|
187
|
+
* `blockUpdated`, a canvas element a microtask later, which an `await` between
|
|
188
|
+
* two creations lets run. So a child of a pasted group or frame can already sit
|
|
189
|
+
* in the frame under the paste point when its own container claims it, and a
|
|
190
|
+
* child claimed twice is copied twice by the next duplicate.
|
|
191
|
+
*
|
|
192
|
+
* The paste knows the parentage it is writing; the frame's guess does not
|
|
193
|
+
* survive it. Each pasted container's children leave any other frame. The
|
|
194
|
+
* container itself is untouched, so a pasted group still lands in the frame it
|
|
195
|
+
* was dropped on.
|
|
196
|
+
*/
|
|
197
|
+
function releaseChildrenFromAdoptingFrames(std, created, parents) {
|
|
198
|
+
if (parents.size === 0)
|
|
199
|
+
return;
|
|
200
|
+
const frames = std.store
|
|
201
|
+
.getModelsByFlavour('affine:frame')
|
|
202
|
+
.filter(isFrameBlock);
|
|
203
|
+
if (frames.length === 0)
|
|
204
|
+
return;
|
|
205
|
+
for (const child of created) {
|
|
206
|
+
const container = parents.get(child.id);
|
|
207
|
+
if (!container)
|
|
208
|
+
continue;
|
|
209
|
+
for (const frame of frames) {
|
|
210
|
+
if (frame.id !== container && frame.hasChild(child)) {
|
|
211
|
+
frame.removeChild(child);
|
|
119
212
|
}
|
|
120
|
-
aGroup = aGroup ?? a;
|
|
121
|
-
bGroup = bGroup ?? b;
|
|
122
|
-
return originalIndexes.get(aGroup.id) === originalIndexes.get(bGroup.id)
|
|
123
|
-
? SortOrder.SAME
|
|
124
|
-
: originalIndexes.get(aGroup.id) < originalIndexes.get(bGroup.id)
|
|
125
|
-
? SortOrder.BEFORE
|
|
126
|
-
: SortOrder.AFTER;
|
|
127
213
|
}
|
|
128
214
|
}
|
|
129
|
-
const idxGenerator = gfx.layer.createIndexGenerator();
|
|
130
|
-
const sortedElements = elements.sort(compare);
|
|
131
|
-
sortedElements.forEach(ele => {
|
|
132
|
-
const newIndex = idxGenerator();
|
|
133
|
-
crud.updateElement(ele.id, {
|
|
134
|
-
index: newIndex,
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
215
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BlockStdScope } from '../../../std/index.js';
|
|
2
|
+
import { type SerializedElement } from '../../../std/gfx/index.js';
|
|
3
|
+
import type { BlockSnapshot } from '../../../store/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Child id → container id, as the pasted data spells it: a group's or a mind
|
|
6
|
+
* map's `children`, a frame's `childElementIds`.
|
|
7
|
+
*
|
|
8
|
+
* The paste reads its parentage from here and not from the models: a canvas
|
|
9
|
+
* container written in the final transaction registers its children (its
|
|
10
|
+
* `childIds`, `getGroup`) only when that transaction ends, so inside it a
|
|
11
|
+
* model would answer "no parent".
|
|
12
|
+
*/
|
|
13
|
+
export declare function pastedParentage(elementsRawData: (SerializedElement | BlockSnapshot)[]): Map<string, string>;
|
|
14
|
+
/**
|
|
15
|
+
* The fresh indexes of the pasted elements, by their id in the pasted data: on
|
|
16
|
+
* top of the board, in the order they had where they were copied from — a
|
|
17
|
+
* container before its children, and otherwise by the original index of the
|
|
18
|
+
* topmost pasted ancestor (then of the next one down, then of the element
|
|
19
|
+
* itself). The original indexes are recorded in `originalIndexes`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function pastedIndexes(std: BlockStdScope, elementsRawData: (SerializedElement | BlockSnapshot)[], parents: Map<string, string>, originalIndexes: Map<string, string>): Map<string, string>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { GfxControllerIdentifier, SortOrder, } from '../../../std/gfx/index.js';
|
|
2
|
+
/*
|
|
3
|
+
* The paste's stacking order, decided on the PASTED DATA before any model
|
|
4
|
+
* exists. Its own module, which the package does not re-export, so that
|
|
5
|
+
* `paste-order-parity.unit.spec.ts` can hold its copy of the canvas'
|
|
6
|
+
* ancestor rule to `compareLayer` without making it API.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Child id → container id, as the pasted data spells it: a group's or a mind
|
|
10
|
+
* map's `children`, a frame's `childElementIds`.
|
|
11
|
+
*
|
|
12
|
+
* The paste reads its parentage from here and not from the models: a canvas
|
|
13
|
+
* container written in the final transaction registers its children (its
|
|
14
|
+
* `childIds`, `getGroup`) only when that transaction ends, so inside it a
|
|
15
|
+
* model would answer "no parent".
|
|
16
|
+
*/
|
|
17
|
+
export function pastedParentage(elementsRawData) {
|
|
18
|
+
const parents = new Map();
|
|
19
|
+
for (const data of elementsRawData) {
|
|
20
|
+
const children = 'flavour' in data ? data.props.childElementIds : data.children;
|
|
21
|
+
if (!children || typeof children !== 'object')
|
|
22
|
+
continue;
|
|
23
|
+
for (const childId of Object.keys(children)) {
|
|
24
|
+
parents.set(childId, data.id);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return parents;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The fresh indexes of the pasted elements, by their id in the pasted data: on
|
|
31
|
+
* top of the board, in the order they had where they were copied from — a
|
|
32
|
+
* container before its children, and otherwise by the original index of the
|
|
33
|
+
* topmost pasted ancestor (then of the next one down, then of the element
|
|
34
|
+
* itself). The original indexes are recorded in `originalIndexes`.
|
|
35
|
+
*/
|
|
36
|
+
export function pastedIndexes(std, elementsRawData, parents, originalIndexes) {
|
|
37
|
+
for (const data of elementsRawData) {
|
|
38
|
+
const index = 'flavour' in data ? data.props.index : data.index;
|
|
39
|
+
if (typeof index === 'string' && !originalIndexes.has(data.id)) {
|
|
40
|
+
originalIndexes.set(data.id, index);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// Pasted ancestors, nearest first — the order `GfxModel.groups` uses.
|
|
44
|
+
const ancestors = new Map();
|
|
45
|
+
for (const id of originalIndexes.keys()) {
|
|
46
|
+
const chain = [];
|
|
47
|
+
for (let parent = parents.get(id); parent && !chain.includes(parent); parent = parents.get(parent)) {
|
|
48
|
+
chain.push(parent);
|
|
49
|
+
}
|
|
50
|
+
ancestors.set(id, chain);
|
|
51
|
+
}
|
|
52
|
+
function compare(a, b) {
|
|
53
|
+
const aGroups = ancestors.get(a) ?? [];
|
|
54
|
+
const bGroups = ancestors.get(b) ?? [];
|
|
55
|
+
if (bGroups.includes(a)) {
|
|
56
|
+
return SortOrder.BEFORE;
|
|
57
|
+
}
|
|
58
|
+
else if (aGroups.includes(b)) {
|
|
59
|
+
return SortOrder.AFTER;
|
|
60
|
+
}
|
|
61
|
+
let i = 1;
|
|
62
|
+
let aGroup = aGroups.at(-i);
|
|
63
|
+
let bGroup = bGroups.at(-i);
|
|
64
|
+
while (aGroup === bGroup && aGroup) {
|
|
65
|
+
++i;
|
|
66
|
+
aGroup = aGroups.at(-i);
|
|
67
|
+
bGroup = bGroups.at(-i);
|
|
68
|
+
}
|
|
69
|
+
const aIndex = originalIndexes.get(aGroup ?? a);
|
|
70
|
+
const bIndex = originalIndexes.get(bGroup ?? b);
|
|
71
|
+
return aIndex === bIndex
|
|
72
|
+
? SortOrder.SAME
|
|
73
|
+
: aIndex < bIndex
|
|
74
|
+
? SortOrder.BEFORE
|
|
75
|
+
: SortOrder.AFTER;
|
|
76
|
+
}
|
|
77
|
+
const nextIndex = std
|
|
78
|
+
.get(GfxControllerIdentifier)
|
|
79
|
+
.layer.createIndexGenerator();
|
|
80
|
+
const newIndexes = new Map();
|
|
81
|
+
[...originalIndexes.keys()].sort(compare).forEach(id => {
|
|
82
|
+
newIndexes.set(id, nextIndex());
|
|
83
|
+
});
|
|
84
|
+
return newIndexes;
|
|
85
|
+
}
|
|
@@ -51,6 +51,12 @@ export declare class EdgelessRootBlockComponent extends BlockComponent<RootBlock
|
|
|
51
51
|
flavour?: boolean;
|
|
52
52
|
}): () => void;
|
|
53
53
|
connectedCallback(): void;
|
|
54
|
+
/**
|
|
55
|
+
* The grid follows `CanvasGrid` (ADR 0031 §11) through one attribute on
|
|
56
|
+
* the root, which both containers that paint it — this block's background
|
|
57
|
+
* and the surface container — key their `background-image: none` on.
|
|
58
|
+
*/
|
|
59
|
+
private _initGrid;
|
|
54
60
|
disconnectedCallback(): void;
|
|
55
61
|
firstUpdated(): void;
|
|
56
62
|
renderBlock(): import("lit-html").TemplateResult<1>;
|
|
@@ -38,7 +38,7 @@ import { isSingleMindMapNode } from '../../affine-gfx-mindmap/index.js';
|
|
|
38
38
|
import { PanTool } from '../../affine-gfx-pointer/index.js';
|
|
39
39
|
import { mountShapeTextEditor } from '../../affine-gfx-shape/index.js';
|
|
40
40
|
import { NoteBlockModel, } from '../../affine-model/index.js';
|
|
41
|
-
import { EditorSettingProvider, EditPropsStore, FontLoaderService, ThemeProvider, ViewportElementProvider, } from '../../affine-shared/services/index.js';
|
|
41
|
+
import { CanvasGrid, EditorSettingProvider, EditPropsStore, FontLoaderService, ThemeProvider, ViewportElementProvider, } from '../../affine-shared/services/index.js';
|
|
42
42
|
import { isTouchPadPinchEvent, matchModels, requestConnectedFrame, requestThrottledConnectedFrame, } from '../../affine-shared/utils/index.js';
|
|
43
43
|
import { IS_WINDOWS } from '../../global/env/index.js';
|
|
44
44
|
import { Bound, Point, Vec } from '../../global/gfx/index.js';
|
|
@@ -110,6 +110,11 @@ let EdgelessRootBlockComponent = (() => {
|
|
|
110
110
|
);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
/* ADR 0031 §11: the grid is a setting (CanvasGrid.visible$). */
|
|
114
|
+
affine-edgeless-root[data-grid-hidden] .edgeless-background {
|
|
115
|
+
background-image: none;
|
|
116
|
+
}
|
|
117
|
+
|
|
113
118
|
.edgeless-container {
|
|
114
119
|
color: var(--affine-text-primary-color);
|
|
115
120
|
position: relative;
|
|
@@ -347,6 +352,7 @@ let EdgelessRootBlockComponent = (() => {
|
|
|
347
352
|
connectedCallback() {
|
|
348
353
|
super.connectedCallback();
|
|
349
354
|
this._initViewport();
|
|
355
|
+
this._initGrid();
|
|
350
356
|
this.keyboardManager = new EdgelessPageKeyboardManager(this);
|
|
351
357
|
this.handleEvent('selectionChange', () => {
|
|
352
358
|
const surface = this.host.selection.value.find((sel) => sel.is(SurfaceSelection));
|
|
@@ -359,6 +365,17 @@ let EdgelessRootBlockComponent = (() => {
|
|
|
359
365
|
return;
|
|
360
366
|
});
|
|
361
367
|
}
|
|
368
|
+
/**
|
|
369
|
+
* The grid follows `CanvasGrid` (ADR 0031 §11) through one attribute on
|
|
370
|
+
* the root, which both containers that paint it — this block's background
|
|
371
|
+
* and the surface container — key their `background-image: none` on.
|
|
372
|
+
*/
|
|
373
|
+
_initGrid() {
|
|
374
|
+
this._disposables.add(effect(() => {
|
|
375
|
+
const visible = this.std.getOptional(CanvasGrid)?.visible$.value ?? true;
|
|
376
|
+
this.toggleAttribute('data-grid-hidden', !visible);
|
|
377
|
+
}));
|
|
378
|
+
}
|
|
362
379
|
disconnectedCallback() {
|
|
363
380
|
super.disconnectedCallback();
|
|
364
381
|
if (this._resizeObserver) {
|
|
@@ -7,6 +7,15 @@ import type { BlockSnapshot, Transformer } from '../../../store/index.js';
|
|
|
7
7
|
* return all elements in the tree of the elements
|
|
8
8
|
*/
|
|
9
9
|
export declare function getSortedCloneElements(elements: GfxModel[]): GfxModel[];
|
|
10
|
+
/**
|
|
11
|
+
* The data a clone gesture in the same document (duplicate, alt-drag)
|
|
12
|
+
* re-creates. Each model asks for its source's layer EXPLICITLY, the default
|
|
13
|
+
* layer included (ADR 0031, amendment "A duplicate stays in its source's
|
|
14
|
+
* layer, the default one included"): a default-layer model serializes no
|
|
15
|
+
* `layer`, and "absent" would hand its copy to the viewer's active layer. A
|
|
16
|
+
* paste goes through `prepareClipboardData` instead and keeps §6's rule — it
|
|
17
|
+
* cannot tell the default layer from another document.
|
|
18
|
+
*/
|
|
10
19
|
export declare function prepareCloneData(elements: GfxModel[], std: BlockStdScope): (BlockSnapshot | SerializedElement)[];
|
|
11
20
|
export declare function serializeElement(element: GfxModel, elements: GfxModel[], job: Transformer): SerializedElement | {
|
|
12
21
|
type: "block";
|