@formicoidea/labre-core 0.43.1 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_pkgs/affine-block-attachment/utils.js +4 -0
- package/dist/_pkgs/affine-block-bookmark/configs/toolbar.js +17 -4
- package/dist/_pkgs/affine-block-callout/commands/turn-into-callout.d.ts +29 -0
- package/dist/_pkgs/affine-block-callout/commands/turn-into-callout.js +81 -0
- package/dist/_pkgs/affine-block-callout/configs/slash-menu.js +6 -4
- package/dist/_pkgs/affine-block-callout/configs/turn-into.d.ts +8 -0
- package/dist/_pkgs/affine-block-callout/configs/turn-into.js +19 -0
- package/dist/_pkgs/affine-block-callout/translations.d.ts +4 -2
- package/dist/_pkgs/affine-block-callout/translations.js +4 -2
- package/dist/_pkgs/affine-block-callout/view.js +3 -0
- package/dist/_pkgs/affine-block-code/code-block-service.d.ts +13 -0
- package/dist/_pkgs/affine-block-code/code-block-service.js +26 -0
- package/dist/_pkgs/affine-block-code/code-block.d.ts +6 -0
- package/dist/_pkgs/affine-block-code/code-block.js +11 -2
- package/dist/_pkgs/affine-block-code/code-toolbar/components/lang-button.js +31 -8
- package/dist/_pkgs/affine-block-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/frame-manager.d.ts +5 -0
- package/dist/_pkgs/affine-block-frame/frame-manager.js +48 -17
- package/dist/_pkgs/affine-block-frame/frame-tool.js +3 -1
- package/dist/_pkgs/affine-block-image/utils.js +4 -1
- package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.d.ts +8 -0
- package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.js +9 -5
- package/dist/_pkgs/affine-block-note/translations.d.ts +0 -1
- package/dist/_pkgs/affine-block-note/translations.js +0 -5
- package/dist/_pkgs/affine-block-root/configs/toolbar.js +17 -1
- package/dist/_pkgs/affine-block-root/edgeless/clipboard/clipboard.js +2 -1
- package/dist/_pkgs/affine-block-root/edgeless/clipboard/command.js +161 -83
- package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.d.ts +21 -0
- package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.js +85 -0
- package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.d.ts +6 -0
- package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.js +18 -1
- package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.d.ts +9 -0
- package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.js +28 -0
- package/dist/_pkgs/affine-block-root/keyboard/commands.js +9 -6
- package/dist/_pkgs/affine-block-root/preview/edgeless-root-preview-block.js +15 -2
- 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 +80 -0
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.js +248 -0
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.d.ts +82 -0
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.js +342 -0
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.d.ts +3 -0
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.js +3 -0
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.d.ts +137 -0
- package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.js +323 -0
- package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.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-fragment-adapter-panel/adapter-panel.d.ts +2 -2
- package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card.js +2 -2
- package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.d.ts +1 -1
- package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.js +8 -27
- package/dist/_pkgs/affine-fragment-frame-panel/index.d.ts +1 -0
- package/dist/_pkgs/affine-fragment-frame-panel/index.js +1 -0
- package/dist/_pkgs/affine-gfx-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-rich-text/conversion.d.ts +25 -0
- package/dist/_pkgs/affine-rich-text/conversion.js +9 -0
- package/dist/_pkgs/affine-rich-text/index.d.ts +1 -1
- package/dist/_pkgs/affine-rich-text/index.js +1 -1
- package/dist/_pkgs/affine-shared/commands/model-crud/replace-selected-text-with-blocks.d.ts +1 -1
- package/dist/_pkgs/affine-shared/services/canvas-grid.d.ts +63 -0
- package/dist/_pkgs/affine-shared/services/canvas-grid.js +109 -0
- package/dist/_pkgs/affine-shared/services/canvas-local-visibility.d.ts +64 -0
- package/dist/_pkgs/affine-shared/services/canvas-local-visibility.js +192 -0
- package/dist/_pkgs/affine-shared/services/edit-props-store.d.ts +27 -0
- package/dist/_pkgs/affine-shared/services/edit-props-store.js +34 -0
- package/dist/_pkgs/affine-shared/services/editor-setting-service.d.ts +3 -0
- package/dist/_pkgs/affine-shared/services/editor-setting-service.js +7 -0
- package/dist/_pkgs/affine-shared/services/feature-flag-service.d.ts +4 -0
- package/dist/_pkgs/affine-shared/services/index.d.ts +3 -0
- package/dist/_pkgs/affine-shared/services/index.js +3 -0
- package/dist/_pkgs/affine-shared/services/selection-pane-service.d.ts +44 -0
- package/dist/_pkgs/affine-shared/services/selection-pane-service.js +28 -0
- package/dist/_pkgs/affine-shared/services/telemetry-service/lifecycle.d.ts +69 -0
- package/dist/_pkgs/affine-shared/services/telemetry-service/telemetry-service.d.ts +2 -2
- package/dist/_pkgs/affine-shared/services/translation-service/chrome.d.ts +5 -0
- package/dist/_pkgs/affine-shared/services/translation-service/chrome.js +9 -0
- package/dist/_pkgs/affine-shared/styles/index.d.ts +1 -0
- package/dist/_pkgs/affine-shared/styles/index.js +1 -0
- package/dist/_pkgs/affine-shared/styles/panel-header.d.ts +31 -0
- package/dist/_pkgs/affine-shared/styles/panel-header.js +61 -0
- package/dist/_pkgs/affine-shared/styles/text.js +7 -7
- package/dist/_pkgs/affine-shared/types/index.d.ts +6 -0
- package/dist/_pkgs/affine-shared/utils/canvas-export-colors.d.ts +26 -0
- package/dist/_pkgs/affine-shared/utils/canvas-export-colors.js +127 -0
- package/dist/_pkgs/affine-shared/utils/file/filesys.d.ts +8 -11
- package/dist/_pkgs/affine-shared/utils/file/filesys.js +8 -11
- package/dist/_pkgs/affine-shared/utils/index.d.ts +2 -0
- package/dist/_pkgs/affine-shared/utils/index.js +2 -0
- package/dist/_pkgs/affine-shared/utils/label-mode.d.ts +47 -0
- package/dist/_pkgs/affine-shared/utils/label-mode.js +55 -0
- package/dist/_pkgs/affine-shared/utils/model/merge-to-code-model.js +7 -1
- package/dist/_pkgs/affine-shared/utils/model/transform-model.js +5 -0
- package/dist/_pkgs/affine-widget-edgeless-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 +61 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.js +91 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.d.ts +17 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.js +95 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.d.ts +10 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.js +31 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.d.ts +26 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.js +82 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.d.ts +170 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.js +1381 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.d.ts +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/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 +4 -1
- package/dist/translations.js +10 -6
- package/package.json +9 -2
- package/dist/_pkgs/affine-components/icons/file-icons-rc.d.ts +0 -1
- package/dist/_pkgs/affine-components/icons/file-icons-rc.js +0 -130
- package/dist/_pkgs/affine-shared/test-utils/affine-template.d.ts +0 -6
- package/dist/_pkgs/affine-shared/test-utils/affine-template.js +0 -258
- package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.d.ts +0 -8
- package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.js +0 -81
- package/dist/_pkgs/affine-shared/test-utils/create-test-host.d.ts +0 -23
- package/dist/_pkgs/affine-shared/test-utils/create-test-host.js +0 -187
- package/dist/_pkgs/affine-shared/test-utils/index.d.ts +0 -3
- package/dist/_pkgs/affine-shared/test-utils/index.js +0 -3
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { BlockStdScope } from '../../../std/index.js';
|
|
2
|
+
import { type SurfaceMiddleware, SurfaceMiddlewareBuilder } from '../../../std/gfx/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* The layer to REQUEST for a model derived from `source` — the note an
|
|
5
|
+
* auto-complete arrow clones, the note the slicer splits off, the block that
|
|
6
|
+
* replaces another when its view changes — so it lands beside its source
|
|
7
|
+
* once {@link resolveCreationLayer} has read it. A source in the default
|
|
8
|
+
* layer asks for {@link DEFAULT_LAYER_ID} explicitly: "absent" would hand the
|
|
9
|
+
* derived model to the viewer's active layer instead.
|
|
10
|
+
*/
|
|
11
|
+
export declare function sourceLayerOf(source: unknown): string;
|
|
12
|
+
/**
|
|
13
|
+
* The layer a model being CREATED is stored in (ADR 0031 §6), as the value
|
|
14
|
+
* to write: a layer id, or `undefined` for the default layer.
|
|
15
|
+
*
|
|
16
|
+
* - `requested` names a layer of THIS surface → kept (a duplicate, an
|
|
17
|
+
* alt-drag clone, a paste within the document stays beside its source);
|
|
18
|
+
* - `requested` is {@link DEFAULT_LAYER_ID} → the default layer, explicitly:
|
|
19
|
+
* a caller that computed "default" (a new group whose highest member is in
|
|
20
|
+
* it) is not overridden by the active layer;
|
|
21
|
+
* - anything else — absent, or an id with no record here (a paste from
|
|
22
|
+
* another document, a template, an import) → the viewer's active layer.
|
|
23
|
+
*
|
|
24
|
+
* A surface with no layer at all writes nothing, whatever was asked.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveCreationLayer(std: BlockStdScope, requested: unknown): string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Stamp the creation layer on `props` in place: set it, or remove the key so
|
|
29
|
+
* a default-layer model writes no `layer` at all.
|
|
30
|
+
*/
|
|
31
|
+
export declare function applyCreationLayer(std: BlockStdScope, props: Record<string, unknown>): void;
|
|
32
|
+
/**
|
|
33
|
+
* Every `surface.addElement` goes through this `beforeAdd` middleware, beside
|
|
34
|
+
* `EditPropsMiddlewareBuilder` (ADR 0031 §6): a framework command adding an
|
|
35
|
+
* element directly gets the same rule as the canvas tools.
|
|
36
|
+
*/
|
|
37
|
+
export declare class UserLayerMiddlewareBuilder extends SurfaceMiddlewareBuilder {
|
|
38
|
+
static key: string;
|
|
39
|
+
middleware: SurfaceMiddleware;
|
|
40
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { DEFAULT_LAYER_ID, GfxControllerIdentifier, ownLayerOf, SurfaceMiddlewareBuilder, } from '../../../std/gfx/index.js';
|
|
2
|
+
import { CanvasActiveLayer } from './active-layer.js';
|
|
3
|
+
/**
|
|
4
|
+
* The layer to REQUEST for a model derived from `source` — the note an
|
|
5
|
+
* auto-complete arrow clones, the note the slicer splits off, the block that
|
|
6
|
+
* replaces another when its view changes — so it lands beside its source
|
|
7
|
+
* once {@link resolveCreationLayer} has read it. A source in the default
|
|
8
|
+
* layer asks for {@link DEFAULT_LAYER_ID} explicitly: "absent" would hand the
|
|
9
|
+
* derived model to the viewer's active layer instead.
|
|
10
|
+
*/
|
|
11
|
+
export function sourceLayerOf(source) {
|
|
12
|
+
return ownLayerOf(source) ?? DEFAULT_LAYER_ID;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The layer a model being CREATED is stored in (ADR 0031 §6), as the value
|
|
16
|
+
* to write: a layer id, or `undefined` for the default layer.
|
|
17
|
+
*
|
|
18
|
+
* - `requested` names a layer of THIS surface → kept (a duplicate, an
|
|
19
|
+
* alt-drag clone, a paste within the document stays beside its source);
|
|
20
|
+
* - `requested` is {@link DEFAULT_LAYER_ID} → the default layer, explicitly:
|
|
21
|
+
* a caller that computed "default" (a new group whose highest member is in
|
|
22
|
+
* it) is not overridden by the active layer;
|
|
23
|
+
* - anything else — absent, or an id with no record here (a paste from
|
|
24
|
+
* another document, a template, an import) → the viewer's active layer.
|
|
25
|
+
*
|
|
26
|
+
* A surface with no layer at all writes nothing, whatever was asked.
|
|
27
|
+
*/
|
|
28
|
+
export function resolveCreationLayer(std, requested) {
|
|
29
|
+
const layers = std.get(GfxControllerIdentifier).surface?.props.layers;
|
|
30
|
+
if (!layers)
|
|
31
|
+
return undefined;
|
|
32
|
+
if (requested === DEFAULT_LAYER_ID)
|
|
33
|
+
return undefined;
|
|
34
|
+
if (typeof requested === 'string' && layers[requested])
|
|
35
|
+
return requested;
|
|
36
|
+
const active = std.getOptional(CanvasActiveLayer)?.resolve() ?? DEFAULT_LAYER_ID;
|
|
37
|
+
return active === DEFAULT_LAYER_ID ? undefined : active;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Stamp the creation layer on `props` in place: set it, or remove the key so
|
|
41
|
+
* a default-layer model writes no `layer` at all.
|
|
42
|
+
*/
|
|
43
|
+
export function applyCreationLayer(std, props) {
|
|
44
|
+
const layer = resolveCreationLayer(std, props.layer);
|
|
45
|
+
if (layer === undefined) {
|
|
46
|
+
delete props.layer;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
props.layer = layer;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Every `surface.addElement` goes through this `beforeAdd` middleware, beside
|
|
54
|
+
* `EditPropsMiddlewareBuilder` (ADR 0031 §6): a framework command adding an
|
|
55
|
+
* element directly gets the same rule as the canvas tools.
|
|
56
|
+
*/
|
|
57
|
+
export class UserLayerMiddlewareBuilder extends SurfaceMiddlewareBuilder {
|
|
58
|
+
constructor() {
|
|
59
|
+
super(...arguments);
|
|
60
|
+
this.middleware = ctx => {
|
|
61
|
+
if (ctx.type !== 'beforeAdd')
|
|
62
|
+
return;
|
|
63
|
+
const props = { ...ctx.payload.props };
|
|
64
|
+
applyCreationLayer(this.std, props);
|
|
65
|
+
ctx.payload.props = props;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
static { this.key = 'userLayer'; }
|
|
69
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { CanvasActiveLayer } from './active-layer.js';
|
|
2
|
+
export { createUserLayer, deleteUserLayer, moveModelsToUserLayer, renameUserLayer, reorderUserLayer, setUserLayersHiddenForEveryone, userLayerName, userLayersBottomUp, writeModelLayer, } from './actions.js';
|
|
3
|
+
export { type CanvasLayerAction, type CreateLayerParams, createLayerParams, type DeleteLayerParams, deleteLayerParams, type MoveElementsToLayerParams, moveElementsToLayerParams, type RenameLayerParams, renameLayerParams, type ReorderLayerParams, reorderLayerParams, reportLayerChange, userLayerCommands, } from './commands.js';
|
|
4
|
+
export { applyCreationLayer, resolveCreationLayer, sourceLayerOf, UserLayerMiddlewareBuilder, } from './creation.js';
|
|
5
|
+
export { LAYER_SEED_NAME, USER_LAYER_SEED_WORDINGS } from './translations.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { CanvasActiveLayer } from './active-layer.js';
|
|
2
|
+
export { createUserLayer, deleteUserLayer, moveModelsToUserLayer, renameUserLayer, reorderUserLayer, setUserLayersHiddenForEveryone, userLayerName, userLayersBottomUp, writeModelLayer, } from './actions.js';
|
|
3
|
+
export { createLayerParams, deleteLayerParams, moveElementsToLayerParams, renameLayerParams, reorderLayerParams, reportLayerChange, userLayerCommands, } from './commands.js';
|
|
4
|
+
export { applyCreationLayer, resolveCreationLayer, sourceLayerOf, UserLayerMiddlewareBuilder, } from './creation.js';
|
|
5
|
+
export { LAYER_SEED_NAME, USER_LAYER_SEED_WORDINGS } from './translations.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ChromeWording } from '../../../affine-shared/services/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The name a new user layer is created with (ADR 0031 §2). A SEED: the
|
|
4
|
+
* creation site resolves it through the translation seam once and writes
|
|
5
|
+
* the result into the document, where it is content from then on — a layer
|
|
6
|
+
* renamed, or opened under another locale, keeps its name.
|
|
7
|
+
*/
|
|
8
|
+
export declare const LAYER_SEED_NAME: ChromeWording;
|
|
9
|
+
/** The seeds this package writes into a document for user layers. */
|
|
10
|
+
export declare const USER_LAYER_SEED_WORDINGS: readonly ChromeWording[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The name a new user layer is created with (ADR 0031 §2). A SEED: the
|
|
3
|
+
* creation site resolves it through the translation seam once and writes
|
|
4
|
+
* the result into the document, where it is content from then on — a layer
|
|
5
|
+
* renamed, or opened under another locale, keeps its name.
|
|
6
|
+
*/
|
|
7
|
+
export const LAYER_SEED_NAME = [
|
|
8
|
+
'com.labre.layer.seed.name',
|
|
9
|
+
'Layer {{n}}',
|
|
10
|
+
];
|
|
11
|
+
/** The seeds this package writes into a document for user layers. */
|
|
12
|
+
export const USER_LAYER_SEED_WORDINGS = [
|
|
13
|
+
LAYER_SEED_NAME,
|
|
14
|
+
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Bound } from '../../global/gfx/index.js';
|
|
2
|
-
import { type FrameworkBackgroundDef, type Ratio } from './def.js';
|
|
3
|
-
import type
|
|
2
|
+
import { type BackgroundTextDef, type FrameworkBackgroundDef, type Ratio } from './def.js';
|
|
3
|
+
import { type BackgroundModelLike } from './labels.js';
|
|
4
4
|
/**
|
|
5
5
|
* The framework-background declaration read as EVALUATION FACTS (PF5.15/PF5.16).
|
|
6
6
|
*
|
|
@@ -85,6 +85,59 @@ export interface BackgroundAxisFact {
|
|
|
85
85
|
export declare function containingFrame<T extends {
|
|
86
86
|
id: string;
|
|
87
87
|
}>(bound: Bound, candidates: Iterable<T>, boundOf: (candidate: T) => Bound): T | null;
|
|
88
|
+
/**
|
|
89
|
+
* One zone of ONE instance, as a reader sees it: a framework zone the instance
|
|
90
|
+
* shows, or a zone the instance declares for itself.
|
|
91
|
+
*/
|
|
92
|
+
export interface BackgroundZoneFact {
|
|
93
|
+
/** The declared id, or `${idPrefix}:${item.id}` for an instance zone. */
|
|
94
|
+
id: string;
|
|
95
|
+
rect: {
|
|
96
|
+
x: Ratio;
|
|
97
|
+
y: Ratio;
|
|
98
|
+
w: Ratio;
|
|
99
|
+
h: Ratio;
|
|
100
|
+
};
|
|
101
|
+
/** A framework zone's name, as declared — key, fallback and stored prop. */
|
|
102
|
+
label?: BackgroundTextDef;
|
|
103
|
+
/** An instance zone's name, as the user wrote it. */
|
|
104
|
+
name?: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Every zone ONE instance actually has: the framework's zones in the variant
|
|
108
|
+
* the instance is turned to, then the zones it declares for itself — a BPMN
|
|
109
|
+
* pool's lanes.
|
|
110
|
+
*
|
|
111
|
+
* THE answer to "which zones are on this frame", shared by the reading and the
|
|
112
|
+
* audit so they cannot disagree. Before it existed the audit concatenated every
|
|
113
|
+
* declared zone whatever the instance's variant, and could place a sub-domain
|
|
114
|
+
* on a migration chart in a classic quadrant nobody can see — the same gate
|
|
115
|
+
* the renderer and the validation engine already passed through
|
|
116
|
+
* (`backgroundInVariant`), forgotten in one reader out of three.
|
|
117
|
+
*
|
|
118
|
+
* Framework zones first, so a framework zone still wins a genuine overlap: the
|
|
119
|
+
* order the audit has always reported them in.
|
|
120
|
+
*/
|
|
121
|
+
export declare function backgroundZones(def: FrameworkBackgroundDef, model: BackgroundModelLike): BackgroundZoneFact[];
|
|
122
|
+
/**
|
|
123
|
+
* Where the centre of `bound` sits inside the PLOT of the instance occupying
|
|
124
|
+
* `frame`, as ratios.
|
|
125
|
+
*
|
|
126
|
+
* Ratios of the plot and not of the element box: a Wardley transition drawn at
|
|
127
|
+
* `0.4` is 40 % of the PLOT, and the margin between the two is exactly where the
|
|
128
|
+
* axis titles live. Not clamped — an element just off the left edge reads as
|
|
129
|
+
* `-0.03`, which is a true and useful thing to say. `null` for a degenerate
|
|
130
|
+
* plot.
|
|
131
|
+
*/
|
|
132
|
+
export declare function backgroundPlotRatios(def: FrameworkBackgroundDef, frame: Bound, bound: Bound): readonly [number, number] | null;
|
|
133
|
+
/**
|
|
134
|
+
* The first zone whose rectangle holds a plot-ratio point, in the order given.
|
|
135
|
+
*
|
|
136
|
+
* Inclusive on all four edges and first match wins, so a point exactly on a
|
|
137
|
+
* divider belongs to the zone declared first — the tie the audit and
|
|
138
|
+
* `bpmnLaneOf` have always broken that way.
|
|
139
|
+
*/
|
|
140
|
+
export declare function backgroundZoneAt<T extends Pick<BackgroundZoneFact, 'rect'>>(zones: readonly T[], at: readonly [number, number]): T | undefined;
|
|
88
141
|
/** The declared axes, as facts. Empty for a background that declares none. */
|
|
89
142
|
export declare function backgroundAxisFacts(def: FrameworkBackgroundDef): readonly BackgroundAxisFact[];
|
|
90
143
|
/** The declared axis with this id, as a fact. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { backgroundPlot, } from './def.js';
|
|
1
|
+
import { backgroundInstanceZones, backgroundPlot, } from './def.js';
|
|
2
|
+
import { backgroundInVariant } from './labels.js';
|
|
2
3
|
const FORWARD = {
|
|
3
4
|
horizontal: [1, 0],
|
|
4
5
|
vertical: [0, -1],
|
|
@@ -60,6 +61,67 @@ export function containingFrame(bound, candidates, boundOf) {
|
|
|
60
61
|
}
|
|
61
62
|
return found;
|
|
62
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Every zone ONE instance actually has: the framework's zones in the variant
|
|
66
|
+
* the instance is turned to, then the zones it declares for itself — a BPMN
|
|
67
|
+
* pool's lanes.
|
|
68
|
+
*
|
|
69
|
+
* THE answer to "which zones are on this frame", shared by the reading and the
|
|
70
|
+
* audit so they cannot disagree. Before it existed the audit concatenated every
|
|
71
|
+
* declared zone whatever the instance's variant, and could place a sub-domain
|
|
72
|
+
* on a migration chart in a classic quadrant nobody can see — the same gate
|
|
73
|
+
* the renderer and the validation engine already passed through
|
|
74
|
+
* (`backgroundInVariant`), forgotten in one reader out of three.
|
|
75
|
+
*
|
|
76
|
+
* Framework zones first, so a framework zone still wins a genuine overlap: the
|
|
77
|
+
* order the audit has always reported them in.
|
|
78
|
+
*/
|
|
79
|
+
export function backgroundZones(def, model) {
|
|
80
|
+
const zones = [];
|
|
81
|
+
for (const zone of def.zones ?? []) {
|
|
82
|
+
if (!backgroundInVariant(def, zone.variants, model))
|
|
83
|
+
continue;
|
|
84
|
+
zones.push({
|
|
85
|
+
id: zone.id,
|
|
86
|
+
rect: zone.rect,
|
|
87
|
+
...(zone.label !== undefined ? { label: zone.label } : {}),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
zones.push(...backgroundInstanceZones(def, model));
|
|
91
|
+
return zones;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Where the centre of `bound` sits inside the PLOT of the instance occupying
|
|
95
|
+
* `frame`, as ratios.
|
|
96
|
+
*
|
|
97
|
+
* Ratios of the plot and not of the element box: a Wardley transition drawn at
|
|
98
|
+
* `0.4` is 40 % of the PLOT, and the margin between the two is exactly where the
|
|
99
|
+
* axis titles live. Not clamped — an element just off the left edge reads as
|
|
100
|
+
* `-0.03`, which is a true and useful thing to say. `null` for a degenerate
|
|
101
|
+
* plot.
|
|
102
|
+
*/
|
|
103
|
+
export function backgroundPlotRatios(def, frame, bound) {
|
|
104
|
+
const plot = backgroundPlot(def, frame.w, frame.h);
|
|
105
|
+
if (!(plot.width > 0) || !(plot.height > 0))
|
|
106
|
+
return null;
|
|
107
|
+
return [
|
|
108
|
+
(bound.x + bound.w / 2 - frame.x - plot.x0) / plot.width,
|
|
109
|
+
(bound.y + bound.h / 2 - frame.y - plot.y0) / plot.height,
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The first zone whose rectangle holds a plot-ratio point, in the order given.
|
|
114
|
+
*
|
|
115
|
+
* Inclusive on all four edges and first match wins, so a point exactly on a
|
|
116
|
+
* divider belongs to the zone declared first — the tie the audit and
|
|
117
|
+
* `bpmnLaneOf` have always broken that way.
|
|
118
|
+
*/
|
|
119
|
+
export function backgroundZoneAt(zones, at) {
|
|
120
|
+
return zones.find(({ rect }) => at[0] >= rect.x &&
|
|
121
|
+
at[0] <= rect.x + rect.w &&
|
|
122
|
+
at[1] >= rect.y &&
|
|
123
|
+
at[1] <= rect.y + rect.h);
|
|
124
|
+
}
|
|
63
125
|
/** The declared axes, as facts. Empty for a background that declares none. */
|
|
64
126
|
export function backgroundAxisFacts(def) {
|
|
65
127
|
return (def.axes ?? []).map(axis => ({
|
|
@@ -64,10 +64,16 @@ export declare function indexOverBackgrounds(siblings: readonly StackedElement[]
|
|
|
64
64
|
* it, the same raise applies — superposed boards stack in the order they
|
|
65
65
|
* were placed, each still under its own artefacts — unless it ENCLOSES that
|
|
66
66
|
* background, in which case it is the sheet the other is drawn on and stays
|
|
67
|
-
* under it ({@link encloses}). Otherwise, if it
|
|
68
|
-
* overlaps, it is acting as a lid: lower it to just above
|
|
69
|
-
* on, or to the back of the surface when it lies on bare
|
|
70
|
-
* nothing.
|
|
67
|
+
* under it ({@link encloses}). Otherwise, if it was just PLACED and covers
|
|
68
|
+
* an artefact it overlaps, it is acting as a lid: lower it to just above
|
|
69
|
+
* the floor it lies on, or to the back of the surface when it lies on bare
|
|
70
|
+
* canvas. Otherwise nothing.
|
|
71
|
+
*
|
|
72
|
+
* `gesture` says which: `'placed'` (created, pasted, duplicated, inserted from
|
|
73
|
+
* a template or an import) or `'moved'`. A move never lowers a board (ADR
|
|
74
|
+
* 0033): the user may have put it above an artefact on purpose, from the
|
|
75
|
+
* selection pane or with "bring forward", and their own drag of that board
|
|
76
|
+
* must not undo it. Moved over free elements, a board now covers them.
|
|
71
77
|
*
|
|
72
78
|
* `siblings` are the OTHER top-level elements of the surface — canvas elements
|
|
73
79
|
* and blocks alike, since the surface paints both by index — with `element`
|
|
@@ -89,7 +95,7 @@ export declare function indexOverBackgrounds(siblings: readonly StackedElement[]
|
|
|
89
95
|
* state writes nothing — no corrupted depth, and no extra entry pushed onto
|
|
90
96
|
* the history stack.
|
|
91
97
|
*/
|
|
92
|
-
export declare function stackingIndexFor(element: StackedElement, siblings: readonly StackedElement[]): string | null;
|
|
98
|
+
export declare function stackingIndexFor(element: StackedElement, siblings: readonly StackedElement[], gesture?: 'placed' | 'moved'): string | null;
|
|
93
99
|
/**
|
|
94
100
|
* The top-level elements of a surface as {@link StackedElement}s — blocks as
|
|
95
101
|
* well as canvas elements, since the surface paints both by index — minus the
|
|
@@ -111,9 +117,11 @@ export declare function stackedElementsOf(gfx: GfxController, exclude?: GfxModel
|
|
|
111
117
|
*
|
|
112
118
|
* Two gestures produce a wrong depth, and they are the two this listens for:
|
|
113
119
|
* an element CREATED (every creation site mints the top of the stack, so a
|
|
114
|
-
* board drawn last covers what it was drawn around) and an element MOVED
|
|
115
|
-
* a board that is above it
|
|
116
|
-
*
|
|
120
|
+
* board drawn last covers what it was drawn around) and an element MOVED onto
|
|
121
|
+
* a board that is above it. A board moved over free elements it then hides is
|
|
122
|
+
* deliberately NOT one of them (ADR 0033): a board's depth after it is placed
|
|
123
|
+
* is the user's. Anything else — a resize, a colour, a rename — cannot change
|
|
124
|
+
* who covers whom.
|
|
117
125
|
*
|
|
118
126
|
* Frames are BLOCKS: their own two gestures are already handled, at creation
|
|
119
127
|
* by `frameIndexAt` and on a move by `_watchFrameMoved` (#223), so this never
|
|
@@ -63,10 +63,16 @@ export function indexOverBackgrounds(siblings, box) {
|
|
|
63
63
|
* it, the same raise applies — superposed boards stack in the order they
|
|
64
64
|
* were placed, each still under its own artefacts — unless it ENCLOSES that
|
|
65
65
|
* background, in which case it is the sheet the other is drawn on and stays
|
|
66
|
-
* under it ({@link encloses}). Otherwise, if it
|
|
67
|
-
* overlaps, it is acting as a lid: lower it to just above
|
|
68
|
-
* on, or to the back of the surface when it lies on bare
|
|
69
|
-
* nothing.
|
|
66
|
+
* under it ({@link encloses}). Otherwise, if it was just PLACED and covers
|
|
67
|
+
* an artefact it overlaps, it is acting as a lid: lower it to just above
|
|
68
|
+
* the floor it lies on, or to the back of the surface when it lies on bare
|
|
69
|
+
* canvas. Otherwise nothing.
|
|
70
|
+
*
|
|
71
|
+
* `gesture` says which: `'placed'` (created, pasted, duplicated, inserted from
|
|
72
|
+
* a template or an import) or `'moved'`. A move never lowers a board (ADR
|
|
73
|
+
* 0033): the user may have put it above an artefact on purpose, from the
|
|
74
|
+
* selection pane or with "bring forward", and their own drag of that board
|
|
75
|
+
* must not undo it. Moved over free elements, a board now covers them.
|
|
70
76
|
*
|
|
71
77
|
* `siblings` are the OTHER top-level elements of the surface — canvas elements
|
|
72
78
|
* and blocks alike, since the surface paints both by index — with `element`
|
|
@@ -88,7 +94,7 @@ export function indexOverBackgrounds(siblings, box) {
|
|
|
88
94
|
* state writes nothing — no corrupted depth, and no extra entry pushed onto
|
|
89
95
|
* the history stack.
|
|
90
96
|
*/
|
|
91
|
-
export function stackingIndexFor(element, siblings) {
|
|
97
|
+
export function stackingIndexFor(element, siblings, gesture = 'placed') {
|
|
92
98
|
const box = Bound.deserialize(element.xywh);
|
|
93
99
|
const overlapping = siblings.filter(sibling => Bound.deserialize(sibling.xywh).isOverlapWithBound(box));
|
|
94
100
|
// The stack {@link indexOverBackgrounds} is allowed to land ON, which is the
|
|
@@ -109,7 +115,10 @@ export function stackingIndexFor(element, siblings) {
|
|
|
109
115
|
const buried = overlapping.some(sibling => sibling.isBackground &&
|
|
110
116
|
sibling.index > element.index &&
|
|
111
117
|
!encloses(element, box, sibling));
|
|
112
|
-
|
|
118
|
+
// Only where it is PLACED (ADR 0033): a board lowered by its own move would
|
|
119
|
+
// undo the depth a user gave it by hand, so a move never lowers one.
|
|
120
|
+
const lidding = gesture === 'placed' &&
|
|
121
|
+
element.isBackground &&
|
|
113
122
|
overlapping.some(sibling => !sibling.isBackground && sibling.index < element.index);
|
|
114
123
|
const next = buried
|
|
115
124
|
? indexOverBackgrounds(floors, box)
|
|
@@ -183,9 +192,11 @@ export function stackedElementsOf(gfx, exclude) {
|
|
|
183
192
|
*
|
|
184
193
|
* Two gestures produce a wrong depth, and they are the two this listens for:
|
|
185
194
|
* an element CREATED (every creation site mints the top of the stack, so a
|
|
186
|
-
* board drawn last covers what it was drawn around) and an element MOVED
|
|
187
|
-
* a board that is above it
|
|
188
|
-
*
|
|
195
|
+
* board drawn last covers what it was drawn around) and an element MOVED onto
|
|
196
|
+
* a board that is above it. A board moved over free elements it then hides is
|
|
197
|
+
* deliberately NOT one of them (ADR 0033): a board's depth after it is placed
|
|
198
|
+
* is the user's. Anything else — a resize, a colour, a rename — cannot change
|
|
199
|
+
* who covers whom.
|
|
189
200
|
*
|
|
190
201
|
* Frames are BLOCKS: their own two gestures are already handled, at creation
|
|
191
202
|
* by `frameIndexAt` and on a move by `_watchFrameMoved` (#223), so this never
|
|
@@ -206,14 +217,15 @@ export class BackgroundStackingExtension extends GfxExtension {
|
|
|
206
217
|
return;
|
|
207
218
|
this._disposable.add(surface.elementAdded.subscribe(({ id, local }) => {
|
|
208
219
|
if (local)
|
|
209
|
-
this._restack(surface.getElementById(id));
|
|
220
|
+
this._restack(surface.getElementById(id), 'placed');
|
|
210
221
|
}));
|
|
211
222
|
this._disposable.add(surface.elementUpdated.subscribe(({ id, props, local }) => {
|
|
212
|
-
if (local && props['xywh'])
|
|
213
|
-
this._restack(surface.getElementById(id));
|
|
223
|
+
if (local && props['xywh']) {
|
|
224
|
+
this._restack(surface.getElementById(id), 'moved');
|
|
225
|
+
}
|
|
214
226
|
}));
|
|
215
227
|
}
|
|
216
|
-
_restack(model) {
|
|
228
|
+
_restack(model, gesture) {
|
|
217
229
|
// A nested element is ordered by its ancestor's index — `compare` reads
|
|
218
230
|
// that and ignores the child's own, so restacking it would change nothing.
|
|
219
231
|
if (!model || model.group !== null)
|
|
@@ -222,7 +234,7 @@ export class BackgroundStackingExtension extends GfxExtension {
|
|
|
222
234
|
index: model.index,
|
|
223
235
|
xywh: model.xywh,
|
|
224
236
|
isBackground: model instanceof FrameworkBackgroundElementModel,
|
|
225
|
-
}, stackedElementsOf(this.gfx, model));
|
|
237
|
+
}, stackedElementsOf(this.gfx, model), gesture);
|
|
226
238
|
if (index !== null)
|
|
227
239
|
this.gfx.updateElement(model, { index });
|
|
228
240
|
}
|
|
@@ -4,11 +4,12 @@ import { requestConnectedFrame } from '../../affine-shared/utils/index.js';
|
|
|
4
4
|
import { DisposableGroup } from '../../global/disposable/index.js';
|
|
5
5
|
import { Bound, getBoundWithRotation, intersects, } from '../../global/gfx/index.js';
|
|
6
6
|
import { GfxControllerIdentifier } from '../../std/gfx/index.js';
|
|
7
|
-
import { effect } from '@preact/signals-core';
|
|
7
|
+
import { effect, untracked } from '@preact/signals-core';
|
|
8
8
|
import last from 'lodash-es/last.js';
|
|
9
9
|
import { Subject } from 'rxjs';
|
|
10
10
|
import { ElementRendererIdentifier } from '../extensions/element-renderer.js';
|
|
11
11
|
import { RoughCanvas } from '../utils/rough/canvas.js';
|
|
12
|
+
import { isPainted } from './paint-predicate.js';
|
|
12
13
|
const STACKING_CANVAS_PADDING = 32;
|
|
13
14
|
export class CanvasRenderer {
|
|
14
15
|
get stackingCanvas() {
|
|
@@ -188,7 +189,7 @@ export class CanvasRenderer {
|
|
|
188
189
|
_getLayerRenderBound(elements, viewportBounds) {
|
|
189
190
|
let layerBound = null;
|
|
190
191
|
for (const element of elements) {
|
|
191
|
-
const display = (element.
|
|
192
|
+
const display = isPainted(element, this._gfx.localVisibility);
|
|
192
193
|
if (!display) {
|
|
193
194
|
continue;
|
|
194
195
|
}
|
|
@@ -310,6 +311,19 @@ export class CanvasRenderer {
|
|
|
310
311
|
this.refresh({ type: 'all' });
|
|
311
312
|
}
|
|
312
313
|
}));
|
|
314
|
+
// A local hide or show changes what is painted without touching any
|
|
315
|
+
// element: repaint everything once (ADR 0031 §8). The first run only
|
|
316
|
+
// subscribes.
|
|
317
|
+
let visibilityRead = false;
|
|
318
|
+
this._disposables.add(effect(() => {
|
|
319
|
+
this._gfx.localVisibility.hiddenIds$.value;
|
|
320
|
+
this._gfx.localVisibility.hiddenLayerIds$.value;
|
|
321
|
+
if (!visibilityRead) {
|
|
322
|
+
visibilityRead = true;
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
untracked(() => this.refresh({ type: 'all' }));
|
|
326
|
+
}));
|
|
313
327
|
let wasDragging = false;
|
|
314
328
|
this._disposables.add(effect(() => {
|
|
315
329
|
const isDragging = this._gfx.tool.dragging$.value;
|
|
@@ -427,7 +441,7 @@ export class CanvasRenderer {
|
|
|
427
441
|
filter: ['canvas', 'local'],
|
|
428
442
|
});
|
|
429
443
|
for (const element of elements) {
|
|
430
|
-
const display = (element.
|
|
444
|
+
const display = isPainted(element, this._gfx.localVisibility);
|
|
431
445
|
if (display && intersects(getBoundWithRotation(element), bound)) {
|
|
432
446
|
renderStats && (renderStats.visibleElementCount += 1);
|
|
433
447
|
if (this.usePlaceholder &&
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Color, ColorScheme } from '../../affine-model/index.js';
|
|
2
2
|
import type { BlockStdScope } from '../../std/index.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type GridManager, type LayerManager, type SurfaceBlockModel, type Viewport } from '../../std/gfx/index.js';
|
|
4
4
|
import { Subject } from 'rxjs';
|
|
5
5
|
import type { Overlay } from './overlay.js';
|
|
6
6
|
type EnvProvider = {
|
|
@@ -99,6 +99,8 @@ export declare class DomRenderer {
|
|
|
99
99
|
removed: HTMLElement[];
|
|
100
100
|
}>;
|
|
101
101
|
constructor(options: RendererOptions);
|
|
102
|
+
/** The viewer's local hide (ADR 0031 §8), read by the paint predicate. */
|
|
103
|
+
private readonly _localVisibility;
|
|
102
104
|
private _initViewport;
|
|
103
105
|
private _resetSize;
|
|
104
106
|
private _renderElement;
|
|
@@ -3,8 +3,11 @@ import { FeatureFlagService } from '../../affine-shared/services/index.js';
|
|
|
3
3
|
import { requestConnectedFrame } from '../../affine-shared/utils/index.js';
|
|
4
4
|
import { DisposableGroup } from '../../global/disposable/index.js';
|
|
5
5
|
import { getBoundWithRotation, intersects, } from '../../global/gfx/index.js';
|
|
6
|
+
import { GfxControllerIdentifier, } from '../../std/gfx/index.js';
|
|
7
|
+
import { effect, untracked } from '@preact/signals-core';
|
|
6
8
|
import { Subject } from 'rxjs';
|
|
7
9
|
import { DomElementRendererIdentifier } from './dom-elements/index.js';
|
|
10
|
+
import { isPainted } from './paint-predicate.js';
|
|
8
11
|
const UpdateType = {
|
|
9
12
|
ELEMENT_ADDED: 'element-added',
|
|
10
13
|
ELEMENT_REMOVED: 'element-removed',
|
|
@@ -185,10 +188,27 @@ export class DomRenderer {
|
|
|
185
188
|
const featureFlagService = options.std.get(FeatureFlagService);
|
|
186
189
|
return featureFlagService.getFlag('enable_turbo_renderer');
|
|
187
190
|
};
|
|
191
|
+
this._localVisibility = this.std.get(GfxControllerIdentifier).localVisibility;
|
|
188
192
|
this._initViewport();
|
|
189
193
|
this._watchSurface(options.surfaceModel);
|
|
190
194
|
}
|
|
191
195
|
_initViewport() {
|
|
196
|
+
// A local hide or show changes what is painted without touching any
|
|
197
|
+
// element: the whole viewport is dirty once. The first run only
|
|
198
|
+
// subscribes.
|
|
199
|
+
let visibilityRead = false;
|
|
200
|
+
this._disposables.add(effect(() => {
|
|
201
|
+
this._localVisibility.hiddenIds$.value;
|
|
202
|
+
this._localVisibility.hiddenLayerIds$.value;
|
|
203
|
+
if (!visibilityRead) {
|
|
204
|
+
visibilityRead = true;
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
untracked(() => {
|
|
208
|
+
this._markViewportDirty();
|
|
209
|
+
this.refresh();
|
|
210
|
+
});
|
|
211
|
+
}));
|
|
192
212
|
this._disposables.add(this.viewport.viewportUpdated.subscribe(() => {
|
|
193
213
|
this._markViewportDirty();
|
|
194
214
|
this.refresh();
|
|
@@ -386,7 +406,7 @@ export class DomRenderer {
|
|
|
386
406
|
const visibleElementIds = new Set();
|
|
387
407
|
// 1. Update dirty elements
|
|
388
408
|
for (const elementModel of elementsFromGrid) {
|
|
389
|
-
const display = (elementModel.
|
|
409
|
+
const display = isPainted(elementModel, this._localVisibility);
|
|
390
410
|
if (display &&
|
|
391
411
|
intersects(getBoundWithRotation(elementModel), viewportBounds)) {
|
|
392
412
|
visibleElementIds.add(elementModel.id);
|
|
@@ -449,7 +469,7 @@ export class DomRenderer {
|
|
|
449
469
|
});
|
|
450
470
|
const visibleElementIds = new Set();
|
|
451
471
|
for (const elementModel of elementsFromGrid) {
|
|
452
|
-
const display = (elementModel.
|
|
472
|
+
const display = isPainted(elementModel, this._localVisibility);
|
|
453
473
|
if (display &&
|
|
454
474
|
intersects(getBoundWithRotation(elementModel), viewportBounds)) {
|
|
455
475
|
visibleElementIds.add(elementModel.id);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one question every renderer site asks before it paints an element:
|
|
3
|
+
* "is this painted?".
|
|
4
|
+
*
|
|
5
|
+
* Four sites asked it inline, with the same expression copied four times — the
|
|
6
|
+
* canvas renderer's layer bound and its bound pass, the DOM renderer's full
|
|
7
|
+
* and incremental passes. ADR 0031 adds two more visibilities beside the two
|
|
8
|
+
* this reads (a viewer's local hide, a stored "hide for everyone"), and a
|
|
9
|
+
* fifth copy of a three-term conjunction is how one site ends up painting
|
|
10
|
+
* what the others skip. So the expression lives here, once.
|
|
11
|
+
*
|
|
12
|
+
* - `display` is the text editor's session flag (`edgeless-text-editor.ts`
|
|
13
|
+
* sets it to `false` while it edits); `undefined` means painted.
|
|
14
|
+
* - `hidden` is stored, and owned by mindmap collapse alone (ADR 0031 §1).
|
|
15
|
+
* - `visibility` is what this viewer does not see (`gfx.localVisibility`, ADR
|
|
16
|
+
* 0031 §8): their own local hide, and the stored "hide for everyone" that
|
|
17
|
+
* `GfxController` registers into the same hook (§7). The exports paint
|
|
18
|
+
* through the same renderer, so both are left out of an SVG or PNG too:
|
|
19
|
+
* what you see is what you export.
|
|
20
|
+
*
|
|
21
|
+
* Painting only. Picking does not read this: the stored `hidden` is already
|
|
22
|
+
* skipped by `grid.search`, the local hide by `getElementByPoint`, and
|
|
23
|
+
* `display` is deliberately still clickable.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isPainted<T extends {
|
|
26
|
+
display?: boolean;
|
|
27
|
+
hidden?: boolean;
|
|
28
|
+
}>(element: T, visibility?: {
|
|
29
|
+
isHidden(element: NoInfer<T>): boolean;
|
|
30
|
+
}): boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one question every renderer site asks before it paints an element:
|
|
3
|
+
* "is this painted?".
|
|
4
|
+
*
|
|
5
|
+
* Four sites asked it inline, with the same expression copied four times — the
|
|
6
|
+
* canvas renderer's layer bound and its bound pass, the DOM renderer's full
|
|
7
|
+
* and incremental passes. ADR 0031 adds two more visibilities beside the two
|
|
8
|
+
* this reads (a viewer's local hide, a stored "hide for everyone"), and a
|
|
9
|
+
* fifth copy of a three-term conjunction is how one site ends up painting
|
|
10
|
+
* what the others skip. So the expression lives here, once.
|
|
11
|
+
*
|
|
12
|
+
* - `display` is the text editor's session flag (`edgeless-text-editor.ts`
|
|
13
|
+
* sets it to `false` while it edits); `undefined` means painted.
|
|
14
|
+
* - `hidden` is stored, and owned by mindmap collapse alone (ADR 0031 §1).
|
|
15
|
+
* - `visibility` is what this viewer does not see (`gfx.localVisibility`, ADR
|
|
16
|
+
* 0031 §8): their own local hide, and the stored "hide for everyone" that
|
|
17
|
+
* `GfxController` registers into the same hook (§7). The exports paint
|
|
18
|
+
* through the same renderer, so both are left out of an SVG or PNG too:
|
|
19
|
+
* what you see is what you export.
|
|
20
|
+
*
|
|
21
|
+
* Painting only. Picking does not read this: the stored `hidden` is already
|
|
22
|
+
* skipped by `grid.search`, the local hide by `getElementByPoint`, and
|
|
23
|
+
* `display` is deliberately still clickable.
|
|
24
|
+
*/
|
|
25
|
+
export function isPainted(element, visibility) {
|
|
26
|
+
return ((element.display ?? true) &&
|
|
27
|
+
!element.hidden &&
|
|
28
|
+
!(visibility?.isHidden(element) ?? false));
|
|
29
|
+
}
|
|
@@ -108,6 +108,12 @@ let SurfaceBlockComponent = (() => {
|
|
|
108
108
|
z-index: 0;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
/* ADR 0031 §11: off removes the grid here too (CanvasGrid.visible$). */
|
|
112
|
+
affine-edgeless-root[data-grid-hidden]
|
|
113
|
+
.affine-block-children-container.edgeless {
|
|
114
|
+
background-image: none;
|
|
115
|
+
}
|
|
116
|
+
|
|
111
117
|
.affine-edgeless-block-child {
|
|
112
118
|
position: absolute;
|
|
113
119
|
transform-origin: center;
|
|
@@ -9,6 +9,11 @@ export const SurfaceBlockSchema = defineBlockSchema({
|
|
|
9
9
|
flavour: 'affine:surface',
|
|
10
10
|
props: (internalPrimitives) => ({
|
|
11
11
|
elements: internalPrimitives.Boxed(new Y.Map()),
|
|
12
|
+
// ADR 0031 §2: optional, `undefined` default, so the load pass writes
|
|
13
|
+
// nothing and the schema version stays 5.
|
|
14
|
+
showGrid: undefined,
|
|
15
|
+
// ADR 0031 §2: user layers, absent until the first one is created.
|
|
16
|
+
layers: undefined,
|
|
12
17
|
}),
|
|
13
18
|
metadata: {
|
|
14
19
|
version: 5,
|