@formicoidea/labre-core 0.41.0 → 0.42.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/LICENSE +384 -0
- package/dist/_pkgs/affine-block-bookmark/bookmark-block.js +2 -2
- package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/config.js +7 -1
- package/dist/_pkgs/affine-block-embed/embed-figma-block/embed-figma-block.js +2 -1
- package/dist/_pkgs/affine-block-embed/embed-github-block/embed-github-block.js +2 -1
- package/dist/_pkgs/affine-block-embed/embed-iframe-block/consts.d.ts +2 -0
- package/dist/_pkgs/affine-block-embed/embed-iframe-block/consts.js +5 -0
- package/dist/_pkgs/affine-block-embed/embed-iframe-block/embed-iframe-block.d.ts +1 -0
- package/dist/_pkgs/affine-block-embed/embed-iframe-block/embed-iframe-block.js +30 -8
- package/dist/_pkgs/affine-block-embed/embed-iframe-block/utils.d.ts +8 -0
- package/dist/_pkgs/affine-block-embed/embed-iframe-block/utils.js +19 -0
- package/dist/_pkgs/affine-block-embed/embed-loom-block/embed-loom-block.js +2 -1
- package/dist/_pkgs/affine-block-embed/embed-youtube-block/embed-youtube-block.js +2 -1
- package/dist/_pkgs/affine-block-frame/frame-manager.js +1 -1
- package/dist/_pkgs/affine-block-frame/frame-tool.js +1 -1
- package/dist/_pkgs/affine-block-frame/frame-toolbar.js +6 -1
- package/dist/_pkgs/affine-block-list/list-keymap.js +7 -0
- package/dist/_pkgs/affine-block-note/note-keymap.js +7 -1
- package/dist/_pkgs/affine-block-paragraph/paragraph-keymap.js +7 -1
- package/dist/_pkgs/affine-block-root/commands/pivot-commands.js +1 -8
- package/dist/_pkgs/affine-block-root/commands/tag-commands.js +1 -8
- package/dist/_pkgs/affine-block-root/edgeless/edgeless-keyboard.d.ts +9 -0
- package/dist/_pkgs/affine-block-root/edgeless/edgeless-keyboard.js +51 -0
- package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.d.ts +22 -0
- package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.js +46 -0
- package/dist/_pkgs/affine-block-root/edgeless/utils/pinch-zoom.d.ts +21 -0
- package/dist/_pkgs/affine-block-root/edgeless/utils/pinch-zoom.js +24 -0
- package/dist/_pkgs/affine-block-root/edgeless/utils/query.js +8 -0
- package/dist/_pkgs/affine-block-root/keyboard/keymap.js +1 -16
- package/dist/_pkgs/affine-block-surface/element-model/index.d.ts +21 -3
- package/dist/_pkgs/affine-block-surface/element-model/index.js +14 -2
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.d.ts +23 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.js +89 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.d.ts +7 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.js +5 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.d.ts +41 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.js +70 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.d.ts +49 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.js +257 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/tagged-path.d.ts +16 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/tagged-path.js +24 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.d.ts +24 -0
- package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.js +66 -0
- package/dist/_pkgs/affine-block-surface/extensions/index.d.ts +4 -0
- package/dist/_pkgs/affine-block-surface/extensions/index.js +4 -0
- package/dist/_pkgs/affine-block-surface/extensions/interchange-import.d.ts +66 -4
- package/dist/_pkgs/affine-block-surface/extensions/interchange-import.js +241 -11
- package/dist/_pkgs/affine-block-surface/extensions/interchange.d.ts +18 -0
- package/dist/_pkgs/affine-block-surface/extensions/legend-toolbar.d.ts +81 -0
- package/dist/_pkgs/affine-block-surface/extensions/legend-toolbar.js +81 -0
- package/dist/_pkgs/affine-block-surface/extensions/legend.d.ts +136 -0
- package/dist/_pkgs/affine-block-surface/extensions/legend.js +439 -0
- package/dist/_pkgs/affine-block-surface/extensions/reading-widget.d.ts +17 -3
- package/dist/_pkgs/affine-block-surface/extensions/reading-widget.js +35 -13
- package/dist/_pkgs/affine-block-surface/extensions/reading.d.ts +61 -1
- package/dist/_pkgs/affine-block-surface/extensions/reading.js +85 -39
- package/dist/_pkgs/affine-block-surface/extensions/record-action.d.ts +66 -0
- package/dist/_pkgs/affine-block-surface/extensions/record-action.js +145 -0
- package/dist/_pkgs/affine-block-surface/extensions/validation.d.ts +253 -28
- package/dist/_pkgs/affine-block-surface/extensions/validation.js +489 -41
- package/dist/_pkgs/affine-block-surface/framework-background/background-view.d.ts +115 -0
- package/dist/_pkgs/affine-block-surface/framework-background/background-view.js +185 -0
- package/dist/_pkgs/affine-block-surface/framework-background/index.d.ts +1 -0
- package/dist/_pkgs/affine-block-surface/framework-background/index.js +1 -0
- package/dist/_pkgs/affine-block-surface/framework-background/labels.d.ts +16 -1
- package/dist/_pkgs/affine-block-surface/framework-background/labels.js +31 -21
- package/dist/_pkgs/affine-block-surface/framework-background/renderer.js +29 -5
- package/dist/_pkgs/affine-block-surface/framework-background/stacking.d.ts +6 -4
- package/dist/_pkgs/affine-block-surface/framework-background/stacking.js +56 -8
- package/dist/_pkgs/affine-block-surface/renderer/canvas-renderer.d.ts +12 -0
- package/dist/_pkgs/affine-block-surface/renderer/canvas-renderer.js +15 -0
- package/dist/_pkgs/affine-block-surface/view.js +8 -1
- package/dist/_pkgs/affine-block-surface-ref/configs/slash-menu.js +1 -1
- package/dist/_pkgs/affine-components/color-picker/button.d.ts +56 -1
- package/dist/_pkgs/affine-components/color-picker/button.js +168 -23
- package/dist/_pkgs/affine-components/color-picker/framework-palette.d.ts +106 -0
- package/dist/_pkgs/affine-components/color-picker/framework-palette.js +177 -0
- package/dist/_pkgs/affine-components/color-picker/index.d.ts +2 -0
- package/dist/_pkgs/affine-components/color-picker/index.js +2 -0
- package/dist/_pkgs/affine-components/color-picker/palette-carousel.d.ts +85 -0
- package/dist/_pkgs/affine-components/color-picker/palette-carousel.js +440 -0
- package/dist/_pkgs/affine-components/edgeless-shape-color-picker/color-picker.d.ts +31 -1
- package/dist/_pkgs/affine-components/edgeless-shape-color-picker/color-picker.js +189 -63
- package/dist/_pkgs/affine-components/resource/resource.js +29 -16
- package/dist/_pkgs/affine-components/translations.d.ts +8 -0
- package/dist/_pkgs/affine-components/translations.js +17 -0
- package/dist/_pkgs/affine-foundation/view.js +2 -1
- package/dist/_pkgs/affine-gfx-brush/element-renderer.js +2 -2
- package/dist/_pkgs/affine-gfx-brush/toolbar/configs/brush.js +6 -1
- package/dist/_pkgs/affine-gfx-brush/toolbar/configs/highlighter.js +6 -1
- package/dist/_pkgs/affine-gfx-connector/connector-manager.d.ts +9 -1
- package/dist/_pkgs/affine-gfx-connector/connector-manager.js +61 -0
- package/dist/_pkgs/affine-gfx-connector/element-renderer/connector-dom/index.d.ts +7 -1
- package/dist/_pkgs/affine-gfx-connector/element-renderer/connector-dom/index.js +87 -17
- package/dist/_pkgs/affine-gfx-connector/element-renderer/index.js +78 -17
- package/dist/_pkgs/affine-gfx-connector/element-renderer/utils.d.ts +24 -2
- package/dist/_pkgs/affine-gfx-connector/element-renderer/utils.js +31 -8
- package/dist/_pkgs/affine-gfx-connector/text/edgeless-connector-label-editor.d.ts +124 -3
- package/dist/_pkgs/affine-gfx-connector/text/edgeless-connector-label-editor.js +216 -54
- package/dist/_pkgs/affine-gfx-connector/text/text.d.ts +13 -4
- package/dist/_pkgs/affine-gfx-connector/text/text.js +13 -44
- package/dist/_pkgs/affine-gfx-connector/toolbar/config.d.ts +56 -0
- package/dist/_pkgs/affine-gfx-connector/toolbar/config.js +72 -4
- package/dist/_pkgs/affine-gfx-connector/toolbar/hollow-endpoint-icons.d.ts +8 -0
- package/dist/_pkgs/affine-gfx-connector/toolbar/hollow-endpoint-icons.js +118 -0
- package/dist/_pkgs/affine-gfx-connector/view/view.d.ts +37 -1
- package/dist/_pkgs/affine-gfx-connector/view/view.js +97 -8
- package/dist/_pkgs/affine-gfx-group/command/group-api.js +1 -1
- package/dist/_pkgs/affine-gfx-group/store.js +0 -2
- package/dist/_pkgs/affine-gfx-group/translations.d.ts +9 -10
- package/dist/_pkgs/affine-gfx-group/translations.js +9 -13
- package/dist/_pkgs/affine-gfx-mindmap/templates/index.js +1 -1
- package/dist/_pkgs/affine-gfx-mindmap/toolbar/basket-elements.js +1 -1
- package/dist/_pkgs/affine-gfx-mindmap/toolbar/utils/import-mindmap.js +2 -2
- package/dist/_pkgs/affine-gfx-mindmap/translations.d.ts +1 -1
- package/dist/_pkgs/affine-gfx-mindmap/translations.js +1 -1
- package/dist/_pkgs/affine-gfx-shape/element-renderer/highlighter.js +2 -2
- package/dist/_pkgs/affine-gfx-shape/overlay/polygon-drawing-overlay.d.ts +6 -0
- package/dist/_pkgs/affine-gfx-shape/overlay/polygon-drawing-overlay.js +30 -1
- package/dist/_pkgs/affine-gfx-shape/polygon-tool.d.ts +20 -1
- package/dist/_pkgs/affine-gfx-shape/polygon-tool.js +9 -1
- package/dist/_pkgs/affine-gfx-shape/toolbar/config.js +6 -1
- package/dist/_pkgs/affine-gfx-shape/toolbar/palette-color-action.js +11 -1
- package/dist/_pkgs/affine-gfx-template/builtin/other.js +1 -1
- package/dist/_pkgs/affine-gfx-template/snapshot-from-action.js +32 -119
- package/dist/_pkgs/affine-gfx-template/toolbar/template-type.d.ts +1 -1
- package/dist/_pkgs/affine-gfx-text/dblclick-add-edgeless-text.d.ts +13 -1
- package/dist/_pkgs/affine-gfx-text/dblclick-add-edgeless-text.js +19 -4
- package/dist/_pkgs/affine-gfx-text/edgeless-text-editor.d.ts +41 -0
- package/dist/_pkgs/affine-gfx-text/edgeless-text-editor.js +57 -2
- package/dist/_pkgs/affine-gfx-text/toolbar/actions.d.ts +8 -1
- package/dist/_pkgs/affine-gfx-text/toolbar/actions.js +12 -2
- package/dist/_pkgs/affine-gfx-text/translations.d.ts +1 -0
- package/dist/_pkgs/affine-gfx-text/translations.js +2 -1
- package/dist/_pkgs/affine-inline-preset/markdown.js +5 -1
- package/dist/_pkgs/affine-model/consts/connector.d.ts +28 -2
- package/dist/_pkgs/affine-model/consts/connector.js +26 -0
- package/dist/_pkgs/affine-model/elements/bpmn/pool.js +1 -1
- package/dist/_pkgs/affine-model/elements/brush/brush.js +1 -1
- package/dist/_pkgs/affine-model/elements/c4/board.js +1 -1
- package/dist/_pkgs/affine-model/elements/c4/boundary.js +1 -1
- package/dist/_pkgs/affine-model/elements/connector/connector.d.ts +135 -0
- package/dist/_pkgs/affine-model/elements/connector/connector.js +246 -5
- package/dist/_pkgs/affine-model/elements/connector/end-label.d.ts +83 -0
- package/dist/_pkgs/affine-model/elements/connector/end-label.js +119 -0
- package/dist/_pkgs/affine-model/elements/connector/index.d.ts +1 -0
- package/dist/_pkgs/affine-model/elements/connector/index.js +1 -0
- package/dist/_pkgs/affine-model/elements/context-map/context-map.js +1 -1
- package/dist/_pkgs/affine-model/elements/core-domain/core-domain.d.ts +28 -0
- package/dist/_pkgs/affine-model/elements/core-domain/core-domain.js +129 -2
- package/dist/_pkgs/affine-model/elements/cynefin/cynefin.d.ts +8 -0
- package/dist/_pkgs/affine-model/elements/cynefin/cynefin.js +45 -2
- package/dist/_pkgs/affine-model/elements/edgy/board.js +1 -1
- package/dist/_pkgs/affine-model/elements/edgy/facets.js +1 -1
- package/dist/_pkgs/affine-model/elements/estuarine/estuarine.d.ts +6 -0
- package/dist/_pkgs/affine-model/elements/estuarine/estuarine.js +36 -2
- package/dist/_pkgs/affine-model/elements/event-storming/event-storming.d.ts +18 -7
- package/dist/_pkgs/affine-model/elements/event-storming/event-storming.js +23 -8
- package/dist/_pkgs/affine-model/elements/framework-background/background.d.ts +16 -0
- package/dist/_pkgs/affine-model/elements/framework-background/background.js +18 -0
- package/dist/_pkgs/affine-model/elements/highlighter/highlighter.js +1 -1
- package/dist/_pkgs/affine-model/elements/index.d.ts +8 -0
- package/dist/_pkgs/affine-model/elements/index.js +1 -0
- package/dist/_pkgs/affine-model/elements/shape/shape.js +1 -1
- package/dist/_pkgs/affine-model/elements/text/text.js +1 -1
- package/dist/_pkgs/affine-model/elements/uml/band.d.ts +39 -0
- package/dist/_pkgs/affine-model/elements/uml/band.js +31 -0
- package/dist/_pkgs/affine-model/elements/uml/diagram.d.ts +158 -0
- package/dist/_pkgs/affine-model/elements/uml/diagram.js +229 -0
- package/dist/_pkgs/affine-model/elements/uml/fragment.d.ts +161 -0
- package/dist/_pkgs/affine-model/elements/uml/fragment.js +205 -0
- package/dist/_pkgs/affine-model/elements/uml/index.d.ts +8 -0
- package/dist/_pkgs/affine-model/elements/uml/index.js +8 -0
- package/dist/_pkgs/affine-model/elements/uml/lifeline.d.ts +77 -0
- package/dist/_pkgs/affine-model/elements/uml/lifeline.js +89 -0
- package/dist/_pkgs/affine-model/elements/uml/node.d.ts +142 -0
- package/dist/_pkgs/affine-model/elements/uml/node.js +190 -0
- package/dist/_pkgs/affine-model/elements/uml/partition.d.ts +106 -0
- package/dist/_pkgs/affine-model/elements/uml/partition.js +172 -0
- package/dist/_pkgs/affine-model/elements/uml/region.d.ts +75 -0
- package/dist/_pkgs/affine-model/elements/uml/region.js +150 -0
- package/dist/_pkgs/affine-model/elements/uml/subject.d.ts +37 -0
- package/dist/_pkgs/affine-model/elements/uml/subject.js +108 -0
- package/dist/_pkgs/affine-model/elements/wardley/wardley.js +1 -1
- package/dist/_pkgs/affine-shared/services/embed-iframe/embed-iframe-config.d.ts +1 -0
- package/dist/_pkgs/affine-shared/services/font-loader/config.d.ts +7 -0
- package/dist/_pkgs/affine-shared/services/font-loader/config.js +43 -0
- package/dist/_pkgs/affine-shared/services/pivot-materiality-publisher.js +1 -9
- package/dist/_pkgs/affine-shared/services/telemetry-service/document-damage-watcher.d.ts +53 -0
- package/dist/_pkgs/affine-shared/services/telemetry-service/document-damage-watcher.js +95 -0
- package/dist/_pkgs/affine-shared/services/telemetry-service/index.d.ts +1 -0
- package/dist/_pkgs/affine-shared/services/telemetry-service/index.js +1 -0
- package/dist/_pkgs/affine-shared/services/telemetry-service/lifecycle.d.ts +26 -1
- package/dist/_pkgs/affine-shared/services/telemetry-service/telemetry-service.d.ts +2 -2
- package/dist/_pkgs/affine-shared/services/toolbar-service/command-action.d.ts +34 -0
- package/dist/_pkgs/affine-shared/services/toolbar-service/command-action.js +63 -0
- package/dist/_pkgs/affine-shared/services/toolbar-service/index.d.ts +1 -0
- package/dist/_pkgs/affine-shared/services/toolbar-service/index.js +1 -0
- package/dist/_pkgs/affine-shared/services/translation-service/chrome.d.ts +77 -7
- package/dist/_pkgs/affine-shared/services/translation-service/chrome.js +97 -7
- 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/motion.d.ts +14 -0
- package/dist/_pkgs/affine-shared/styles/motion.js +38 -0
- package/dist/_pkgs/affine-shared/utils/event.d.ts +10 -0
- package/dist/_pkgs/affine-shared/utils/event.js +20 -0
- package/dist/_pkgs/affine-shared/utils/file/filesys.d.ts +16 -0
- package/dist/_pkgs/affine-shared/utils/file/filesys.js +25 -0
- package/dist/_pkgs/affine-shared/utils/index.d.ts +1 -0
- package/dist/_pkgs/affine-shared/utils/index.js +1 -0
- package/dist/_pkgs/affine-shared/utils/link-preview-refresh.d.ts +12 -0
- package/dist/_pkgs/affine-shared/utils/link-preview-refresh.js +13 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/catalogue/artefact-catalogue-widget.d.ts +12 -4
- package/dist/_pkgs/affine-widget-edgeless-toolbar/catalogue/artefact-catalogue-widget.js +27 -4
- package/dist/_pkgs/affine-widget-edgeless-toolbar/create-popper.js +13 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/index.d.ts +2 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/index.js +2 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/menu/command-menu.d.ts +80 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/menu/command-menu.js +270 -81
- package/dist/_pkgs/affine-widget-edgeless-toolbar/menu/senior-menu-selection.d.ts +15 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/menu/senior-menu-selection.js +15 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/panel/font-weight-and-style-panel.js +8 -1
- package/dist/_pkgs/affine-widget-edgeless-toolbar/placement/artefact-ghost-overlay.d.ts +42 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/placement/artefact-ghost-overlay.js +100 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/placement/artefact-placement-tool.d.ts +100 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/placement/artefact-placement-tool.js +274 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/placement/index.d.ts +3 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/placement/index.js +3 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/placement/translate-created.d.ts +25 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/placement/translate-created.js +67 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/view.js +5 -0
- package/dist/_pkgs/global/gfx/xywh.js +7 -0
- package/dist/_pkgs/std/extension/command-registry.d.ts +158 -1
- package/dist/_pkgs/std/extension/command-registry.js +22 -0
- package/dist/_pkgs/std/gfx/index.d.ts +1 -1
- package/dist/_pkgs/std/gfx/interactivity/gfx-view-event-handler.d.ts +12 -0
- package/dist/_pkgs/std/gfx/interactivity/gfx-view-event-handler.js +20 -1
- package/dist/_pkgs/std/gfx/interactivity/manager.d.ts +10 -0
- package/dist/_pkgs/std/gfx/interactivity/manager.js +12 -0
- package/dist/_pkgs/std/gfx/model/surface/element-model.js +12 -7
- package/dist/_pkgs/std/gfx/model/surface/surface-model.d.ts +56 -0
- package/dist/_pkgs/std/gfx/model/surface/surface-model.js +84 -3
- package/dist/_pkgs/std/gfx/view/view.d.ts +11 -2
- package/dist/_pkgs/std/gfx/view/view.js +16 -2
- package/dist/commands.d.ts +6 -0
- package/dist/commands.js +8 -1
- package/dist/frameworks.d.ts +9 -0
- package/dist/frameworks.js +19 -0
- package/dist/translations.js +16 -0
- package/package.json +9 -4
- package/dist/_pkgs/affine-gfx-group/group-watcher.d.ts +0 -1
- package/dist/_pkgs/affine-gfx-group/group-watcher.js +0 -20
|
@@ -34,6 +34,7 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
34
34
|
};
|
|
35
35
|
import { DefaultTool, EdgelessCRUDIdentifier, } from '../../affine-block-surface/index.js';
|
|
36
36
|
import { getLineHeight } from '../../affine-gfx-text/index.js';
|
|
37
|
+
import { connectorEndLabelBox, } from '../../affine-model/index.js';
|
|
37
38
|
import { ThemeProvider, translateKey } from '../../affine-shared/services/index.js';
|
|
38
39
|
import { almostEqual } from '../../affine-shared/utils/index.js';
|
|
39
40
|
import { BlockSuiteError, ErrorCode } from '../../global/exceptions/index.js';
|
|
@@ -51,37 +52,155 @@ import { CONNECTOR_ADD_TEXT } from '../translations.js';
|
|
|
51
52
|
const HORIZONTAL_PADDING = 2;
|
|
52
53
|
const VERTICAL_PADDING = 2;
|
|
53
54
|
const BORDER_WIDTH = 1;
|
|
54
|
-
|
|
55
|
+
/** The box a label is seeded with, before the first character is typed. */
|
|
56
|
+
const DEFAULT_LABEL_SIZE = { w: 16, h: 16 };
|
|
57
|
+
/**
|
|
58
|
+
* The model fields each label lives in.
|
|
59
|
+
*
|
|
60
|
+
* Declared once, as data, because THREE places need the same answer — the
|
|
61
|
+
* editor's read, its resize write and its empty-commit delete — and three
|
|
62
|
+
* `which === 'center' ? … : …` chains is how one of them ends up writing the
|
|
63
|
+
* centre label's box under an end label's text.
|
|
64
|
+
*/
|
|
65
|
+
export const CONNECTOR_LABEL_FIELDS = {
|
|
66
|
+
center: { text: 'text', xywh: 'labelXYWH' },
|
|
67
|
+
source: { text: 'sourceLabel', xywh: 'sourceLabelXYWH' },
|
|
68
|
+
target: { text: 'targetLabel', xywh: 'targetLabelXYWH' },
|
|
69
|
+
};
|
|
70
|
+
/** {@link CONNECTOR_LABEL_FIELDS}, defaulting to the centre label. */
|
|
71
|
+
export function connectorLabelFields(which = 'center') {
|
|
72
|
+
return CONNECTOR_LABEL_FIELDS[which];
|
|
73
|
+
}
|
|
74
|
+
/** The `Y.Text` of `which`, or `undefined` when that label does not exist. */
|
|
75
|
+
export function connectorLabelText(connector, which = 'center') {
|
|
76
|
+
return which === 'center' ? connector.text : connector.endLabelText(which);
|
|
77
|
+
}
|
|
78
|
+
/** The box of `which`, or `undefined` when that label does not exist. */
|
|
79
|
+
export function connectorLabelXYWH(connector, which = 'center') {
|
|
80
|
+
return which === 'center'
|
|
81
|
+
? connector.labelXYWH
|
|
82
|
+
: connector.endLabelXYWH(which);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The box an end label of `size` takes on the current path — the one geometry
|
|
86
|
+
* helper the model owns, so the renderer, the editor and the hit test all place
|
|
87
|
+
* an end label in the same spot.
|
|
88
|
+
*/
|
|
89
|
+
export function connectorEndLabelBoxFor(connector, which, size = DEFAULT_LABEL_SIZE) {
|
|
90
|
+
return connectorEndLabelBox(connector.absolutePath, which, size);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* What to write so that `which` EXISTS, or `null` when it already does.
|
|
94
|
+
*
|
|
95
|
+
* The centre label is seeded where the pointer is, riding the path by an offset
|
|
96
|
+
* distance — it has always been a caption the author places. An end label is
|
|
97
|
+
* seeded at its ENDPOINT and ignores the pointer: the whole value of one is
|
|
98
|
+
* that it follows the end when the node moves (`docs/adr/0018`, "Alternatives
|
|
99
|
+
* rejected"), so where the double-click landed says nothing about where it
|
|
100
|
+
* belongs.
|
|
101
|
+
*/
|
|
102
|
+
export function connectorLabelSeedProps(connector, which = 'center', point) {
|
|
103
|
+
if (connectorLabelText(connector, which))
|
|
104
|
+
return null;
|
|
105
|
+
const fields = connectorLabelFields(which);
|
|
106
|
+
const text = new Y.Text();
|
|
107
|
+
if (which !== 'center') {
|
|
108
|
+
return {
|
|
109
|
+
[fields.text]: text,
|
|
110
|
+
[fields.xywh]: connectorEndLabelBoxFor(connector, which),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
let labelXYWH = connector.labelXYWH ?? [
|
|
114
|
+
0,
|
|
115
|
+
0,
|
|
116
|
+
DEFAULT_LABEL_SIZE.w,
|
|
117
|
+
DEFAULT_LABEL_SIZE.h,
|
|
118
|
+
];
|
|
119
|
+
const labelOffset = { ...connector.labelOffset };
|
|
120
|
+
if (point) {
|
|
121
|
+
const center = connector.getNearestPoint(point);
|
|
122
|
+
const distance = connector.getOffsetDistanceByPoint(center);
|
|
123
|
+
const bounds = Bound.fromXYWH(labelXYWH);
|
|
124
|
+
bounds.center = center;
|
|
125
|
+
labelOffset.distance = distance;
|
|
126
|
+
labelXYWH = bounds.toXYWH();
|
|
127
|
+
}
|
|
128
|
+
return { text, labelXYWH, labelOffset };
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* What to write when an editing session ENDS, or `null` when the text is
|
|
132
|
+
* already exactly what the model holds.
|
|
133
|
+
*
|
|
134
|
+
* A label committed empty clears both of its fields, so the connector reads
|
|
135
|
+
* as one that has none (`hasEndLabel` false, nothing painted, nothing
|
|
136
|
+
* exported). The KEYS stay in the Y.Map as `undefined` — the field setter
|
|
137
|
+
* writes what it is given — so only a connector that never carried an end
|
|
138
|
+
* label is byte-identical to a pre-0020 one; `docs/adr/0020`'s "no migration"
|
|
139
|
+
* promise is about that connector, not about this reset.
|
|
140
|
+
*
|
|
141
|
+
* Pure and exported: it is the one rule with three outcomes (delete, trim,
|
|
142
|
+
* nothing) times three labels, and a spec should be able to ask it directly.
|
|
143
|
+
*/
|
|
144
|
+
export function connectorLabelCommitProps(raw, which = 'center') {
|
|
145
|
+
const fields = connectorLabelFields(which);
|
|
146
|
+
const trimed = raw.trim();
|
|
147
|
+
if (trimed.length === 0) {
|
|
148
|
+
return {
|
|
149
|
+
[fields.text]: undefined,
|
|
150
|
+
[fields.xywh]: undefined,
|
|
151
|
+
// The centre label's placement along the path goes with it; an end label
|
|
152
|
+
// has no offset of its own — its place is its endpoint.
|
|
153
|
+
...(which === 'center' ? { labelOffset: undefined } : null),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
if (trimed.length < raw.length) {
|
|
157
|
+
// @TODO: trim in Y.Text?
|
|
158
|
+
return { [fields.text]: new Y.Text(trimed) };
|
|
159
|
+
}
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The box an END label takes after a measurement: a label that already has a
|
|
164
|
+
* box keeps its CENTRE and takes the new size — the author's or the importer's
|
|
165
|
+
* placement survives an edit — and a label that has none yet is seeded beside
|
|
166
|
+
* its endpoint by `connectorEndLabelBox`.
|
|
167
|
+
*/
|
|
168
|
+
function endLabelRect(connector, which, w, h) {
|
|
169
|
+
const current = connectorLabelXYWH(connector, which);
|
|
170
|
+
if (current) {
|
|
171
|
+
const [cx, cy] = Bound.fromXYWH(current).center;
|
|
172
|
+
return [cx - w / 2, cy - h / 2, w, h];
|
|
173
|
+
}
|
|
174
|
+
return connectorEndLabelBoxFor(connector, which, { w, h });
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Opens the label editor on ONE of a connector's three labels.
|
|
178
|
+
*
|
|
179
|
+
* This function used to exist twice — here and byte-alike in `text.ts`, which
|
|
180
|
+
* was the copy the package barrel re-exported — so the toolbar and the keyboard
|
|
181
|
+
* reached one body and the view's double-click the other. `docs/adr/0018`
|
|
182
|
+
* phase 2 makes the difference visible (a selector only one copy would have
|
|
183
|
+
* carried), so the duplicate is gone and `text.ts` re-exports this one.
|
|
184
|
+
*/
|
|
185
|
+
export function mountConnectorLabelEditor(connector, edgeless, point, options) {
|
|
55
186
|
const mountElm = edgeless.querySelector('.edgeless-mount-point');
|
|
56
187
|
if (!mountElm) {
|
|
57
188
|
throw new BlockSuiteError(ErrorCode.ValueNotExists, "edgeless block's mount point does not exist");
|
|
58
189
|
}
|
|
190
|
+
const which = options?.which ?? 'center';
|
|
59
191
|
const gfx = edgeless.std.get(GfxControllerIdentifier);
|
|
60
192
|
gfx.tool.setTool(DefaultTool);
|
|
61
193
|
gfx.selection.set({
|
|
62
194
|
elements: [connector.id],
|
|
63
195
|
editing: true,
|
|
64
196
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
let labelXYWH = connector.labelXYWH ?? [0, 0, 16, 16];
|
|
69
|
-
if (point) {
|
|
70
|
-
const center = connector.getNearestPoint(point);
|
|
71
|
-
const distance = connector.getOffsetDistanceByPoint(center);
|
|
72
|
-
const bounds = Bound.fromXYWH(labelXYWH);
|
|
73
|
-
bounds.center = center;
|
|
74
|
-
labelOffset.distance = distance;
|
|
75
|
-
labelXYWH = bounds.toXYWH();
|
|
76
|
-
}
|
|
77
|
-
edgeless.std.get(EdgelessCRUDIdentifier).updateElement(connector.id, {
|
|
78
|
-
text,
|
|
79
|
-
labelXYWH,
|
|
80
|
-
labelOffset: { ...labelOffset },
|
|
81
|
-
});
|
|
197
|
+
const seed = connectorLabelSeedProps(connector, which, point);
|
|
198
|
+
if (seed) {
|
|
199
|
+
edgeless.std.get(EdgelessCRUDIdentifier).updateElement(connector.id, seed);
|
|
82
200
|
}
|
|
83
201
|
const editor = new EdgelessConnectorLabelEditor();
|
|
84
202
|
editor.connector = connector;
|
|
203
|
+
editor.which = which;
|
|
85
204
|
mountElm.append(editor);
|
|
86
205
|
editor.updateComplete
|
|
87
206
|
.then(() => {
|
|
@@ -94,6 +213,9 @@ let EdgelessConnectorLabelEditor = (() => {
|
|
|
94
213
|
let _connector_decorators;
|
|
95
214
|
let _connector_initializers = [];
|
|
96
215
|
let _connector_extraInitializers = [];
|
|
216
|
+
let _which_decorators;
|
|
217
|
+
let _which_initializers = [];
|
|
218
|
+
let _which_extraInitializers = [];
|
|
97
219
|
let _std_decorators;
|
|
98
220
|
let _std_initializers = [];
|
|
99
221
|
let _std_extraInitializers = [];
|
|
@@ -104,11 +226,13 @@ let EdgelessConnectorLabelEditor = (() => {
|
|
|
104
226
|
static {
|
|
105
227
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
106
228
|
_connector_decorators = [property({ attribute: false })];
|
|
229
|
+
_which_decorators = [property({ attribute: false })];
|
|
107
230
|
_std_decorators = [consume({
|
|
108
231
|
context: stdContext,
|
|
109
232
|
})];
|
|
110
233
|
_richText_decorators = [query('rich-text')];
|
|
111
234
|
__esDecorate(this, null, _connector_decorators, { kind: "accessor", name: "connector", static: false, private: false, access: { has: obj => "connector" in obj, get: obj => obj.connector, set: (obj, value) => { obj.connector = value; } }, metadata: _metadata }, _connector_initializers, _connector_extraInitializers);
|
|
235
|
+
__esDecorate(this, null, _which_decorators, { kind: "accessor", name: "which", static: false, private: false, access: { has: obj => "which" in obj, get: obj => obj.which, set: (obj, value) => { obj.which = value; } }, metadata: _metadata }, _which_initializers, _which_extraInitializers);
|
|
112
236
|
__esDecorate(this, null, _std_decorators, { kind: "accessor", name: "std", static: false, private: false, access: { has: obj => "std" in obj, get: obj => obj.std, set: (obj, value) => { obj.std = value; } }, metadata: _metadata }, _std_initializers, _std_extraInitializers);
|
|
113
237
|
__esDecorate(this, null, _richText_decorators, { kind: "accessor", name: "richText", static: false, private: false, access: { has: obj => "richText" in obj, get: obj => obj.richText, set: (obj, value) => { obj.richText = value; } }, metadata: _metadata }, _richText_initializers, _richText_extraInitializers);
|
|
114
238
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
@@ -154,6 +278,30 @@ let EdgelessConnectorLabelEditor = (() => {
|
|
|
154
278
|
get selection() {
|
|
155
279
|
return this.gfx.selection;
|
|
156
280
|
}
|
|
281
|
+
/** The two model fields this editor reads and writes. */
|
|
282
|
+
get fields() {
|
|
283
|
+
return connectorLabelFields(this.which);
|
|
284
|
+
}
|
|
285
|
+
/** The `Y.Text` this editor is bound to. */
|
|
286
|
+
get yText() {
|
|
287
|
+
return connectorLabelText(this.connector, this.which);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Where the editor sits, in MODEL coordinates.
|
|
291
|
+
*
|
|
292
|
+
* The centre label rides the path by its offset distance, so its anchor is
|
|
293
|
+
* recomputed from the connector; an end label's box is the anchor, and it is
|
|
294
|
+
* the box that follows the endpoint (see `connectorEndLabelBox`).
|
|
295
|
+
*/
|
|
296
|
+
get _labelCenter() {
|
|
297
|
+
const { connector, which } = this;
|
|
298
|
+
if (which === 'center') {
|
|
299
|
+
return connector.getPointByOffsetDistance(connector.labelOffset.distance);
|
|
300
|
+
}
|
|
301
|
+
const box = connectorLabelXYWH(connector, which) ??
|
|
302
|
+
connectorEndLabelBoxFor(connector, which);
|
|
303
|
+
return Bound.fromXYWH(box).center;
|
|
304
|
+
}
|
|
157
305
|
get inlineEditor() {
|
|
158
306
|
return this.richText.inlineEditor;
|
|
159
307
|
}
|
|
@@ -170,14 +318,15 @@ let EdgelessConnectorLabelEditor = (() => {
|
|
|
170
318
|
this._resizeObserver = null;
|
|
171
319
|
}
|
|
172
320
|
firstUpdated() {
|
|
173
|
-
const { connector, selection, std } = this;
|
|
321
|
+
const { connector, selection, std, which } = this;
|
|
322
|
+
const fields = this.fields;
|
|
174
323
|
const dispatcher = std.event;
|
|
175
324
|
this._resizeObserver = new ResizeObserver(() => {
|
|
176
325
|
this._updateLabelRect();
|
|
177
326
|
this.requestUpdate();
|
|
178
327
|
});
|
|
179
328
|
this._resizeObserver.observe(this.richText);
|
|
180
|
-
this.connector.stash(
|
|
329
|
+
this.connector.stash(fields.xywh);
|
|
181
330
|
this.updateComplete
|
|
182
331
|
.then(() => {
|
|
183
332
|
if (!this.inlineEditor)
|
|
@@ -215,27 +364,19 @@ let EdgelessConnectorLabelEditor = (() => {
|
|
|
215
364
|
this.disposables.add(dispatcher.add('click', () => true));
|
|
216
365
|
this.disposables.add(dispatcher.add('doubleClick', () => true));
|
|
217
366
|
this.disposables.add(() => {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
else if (len < text.length) {
|
|
231
|
-
this.crud.updateElement(connector.id, {
|
|
232
|
-
// @TODO: trim in Y.Text?
|
|
233
|
-
text: new Y.Text(trimed),
|
|
234
|
-
});
|
|
235
|
-
}
|
|
367
|
+
const yText = connectorLabelText(connector, which);
|
|
368
|
+
if (yText) {
|
|
369
|
+
const props = connectorLabelCommitProps(yText.toString(), which);
|
|
370
|
+
if (props)
|
|
371
|
+
this.crud.updateElement(connector.id, props);
|
|
372
|
+
}
|
|
373
|
+
if (which === 'center') {
|
|
374
|
+
connector.labelEditing = false;
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
connector.endLabelEditing = null;
|
|
236
378
|
}
|
|
237
|
-
connector.
|
|
238
|
-
connector.pop('labelXYWH');
|
|
379
|
+
connector.pop(fields.xywh);
|
|
239
380
|
selection.set({
|
|
240
381
|
elements: [],
|
|
241
382
|
editing: false,
|
|
@@ -244,8 +385,13 @@ let EdgelessConnectorLabelEditor = (() => {
|
|
|
244
385
|
if (!this.inlineEditorContainer)
|
|
245
386
|
return;
|
|
246
387
|
this.disposables.addFromEvent(this.inlineEditorContainer, 'blur', () => {
|
|
247
|
-
|
|
388
|
+
// Re-entrant: Chrome fires the focused child's blur SYNCHRONOUSLY
|
|
389
|
+
// inside `remove()`, before the node is detached, and the commit
|
|
390
|
+
// in `disconnectedCallback` moves the focus again. Without the
|
|
391
|
+
// flag the handler removes a node whose removal is in progress.
|
|
392
|
+
if (this._keeping || this._removing)
|
|
248
393
|
return;
|
|
394
|
+
this._removing = true;
|
|
249
395
|
this.remove();
|
|
250
396
|
});
|
|
251
397
|
this.disposables.addFromEvent(this.inlineEditorContainer, 'compositionstart', () => {
|
|
@@ -256,7 +402,16 @@ let EdgelessConnectorLabelEditor = (() => {
|
|
|
256
402
|
this._isComposition = false;
|
|
257
403
|
this.requestUpdate();
|
|
258
404
|
});
|
|
259
|
-
|
|
405
|
+
// The canvas must not paint the label the overlay is showing, and only
|
|
406
|
+
// THAT one: `hasEndLabel` is gated on `endLabelEditing`, `hasLabel()`
|
|
407
|
+
// on `labelEditing`, so editing one end leaves the caption and the
|
|
408
|
+
// other end drawn (`ConnectorElementModel.hasEndLabel`).
|
|
409
|
+
if (which === 'center') {
|
|
410
|
+
connector.labelEditing = true;
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
connector.endLabelEditing = which;
|
|
414
|
+
}
|
|
260
415
|
})
|
|
261
416
|
.catch(console.error);
|
|
262
417
|
}
|
|
@@ -267,17 +422,18 @@ let EdgelessConnectorLabelEditor = (() => {
|
|
|
267
422
|
}
|
|
268
423
|
render() {
|
|
269
424
|
const { connector } = this;
|
|
270
|
-
const {
|
|
425
|
+
const { labelStyle: { fontFamily, fontSize, fontStyle, fontWeight, textAlign, color: labelColor, }, labelConstraints: { hasMaxWidth, maxWidth }, } = connector;
|
|
271
426
|
const lineHeight = getLineHeight(fontFamily, fontSize, fontWeight);
|
|
272
427
|
const { translateX, translateY, zoom } = this.gfx.viewport;
|
|
273
|
-
const [x, y] = Vec.mul(
|
|
428
|
+
const [x, y] = Vec.mul(this._labelCenter, zoom);
|
|
274
429
|
const transformOperation = [
|
|
275
430
|
'translate(-50%, -50%)',
|
|
276
431
|
`translate(${translateX}px, ${translateY}px)`,
|
|
277
432
|
`translate(${x}px, ${y}px)`,
|
|
278
433
|
`scale(${zoom})`,
|
|
279
434
|
];
|
|
280
|
-
const
|
|
435
|
+
const yText = this.yText;
|
|
436
|
+
const isEmpty = !yText?.length && !this._isComposition;
|
|
281
437
|
const color = this.std
|
|
282
438
|
.get(ThemeProvider)
|
|
283
439
|
.generateColorProperty(labelColor, '#000000');
|
|
@@ -299,7 +455,7 @@ let EdgelessConnectorLabelEditor = (() => {
|
|
|
299
455
|
})}
|
|
300
456
|
>
|
|
301
457
|
<rich-text
|
|
302
|
-
.yText=${
|
|
458
|
+
.yText=${yText}
|
|
303
459
|
.enableFormat=${false}
|
|
304
460
|
style=${isEmpty
|
|
305
461
|
? styleMap({
|
|
@@ -326,6 +482,10 @@ let EdgelessConnectorLabelEditor = (() => {
|
|
|
326
482
|
#connector_accessor_storage;
|
|
327
483
|
get connector() { return this.#connector_accessor_storage; }
|
|
328
484
|
set connector(value) { this.#connector_accessor_storage = value; }
|
|
485
|
+
#which_accessor_storage;
|
|
486
|
+
/** Which of the connector's three labels is being edited. */
|
|
487
|
+
get which() { return this.#which_accessor_storage; }
|
|
488
|
+
set which(value) { this.#which_accessor_storage = value; }
|
|
329
489
|
#std_accessor_storage;
|
|
330
490
|
get std() { return this.#std_accessor_storage; }
|
|
331
491
|
set std(value) { this.#std_accessor_storage = value; }
|
|
@@ -336,27 +496,29 @@ let EdgelessConnectorLabelEditor = (() => {
|
|
|
336
496
|
super(...arguments);
|
|
337
497
|
this._isComposition = false;
|
|
338
498
|
this._keeping = false;
|
|
499
|
+
this._removing = false;
|
|
339
500
|
this._resizeObserver = null;
|
|
340
501
|
this._updateLabelRect = () => {
|
|
341
|
-
const { connector, isConnected } = this;
|
|
502
|
+
const { connector, isConnected, which } = this;
|
|
342
503
|
if (!connector || !isConnected)
|
|
343
504
|
return;
|
|
344
505
|
if (!this.inlineEditorContainer)
|
|
345
506
|
return;
|
|
346
507
|
const newWidth = this.inlineEditorContainer.scrollWidth;
|
|
347
508
|
const newHeight = this.inlineEditorContainer.scrollHeight;
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
509
|
+
const labelXYWH = which === 'center'
|
|
510
|
+
? Bound.fromCenter(connector.getPointByOffsetDistance(connector.labelOffset.distance), newWidth, newHeight).toXYWH()
|
|
511
|
+
: endLabelRect(connector, which, newWidth, newHeight);
|
|
512
|
+
const current = connectorLabelXYWH(connector, which);
|
|
513
|
+
if (!current || labelXYWH.some((p, i) => !almostEqual(p, current[i]))) {
|
|
353
514
|
this.crud.updateElement(connector.id, {
|
|
354
|
-
labelXYWH,
|
|
515
|
+
[this.fields.xywh]: labelXYWH,
|
|
355
516
|
});
|
|
356
517
|
}
|
|
357
518
|
};
|
|
358
519
|
this.#connector_accessor_storage = __runInitializers(this, _connector_initializers, void 0);
|
|
359
|
-
this.#
|
|
520
|
+
this.#which_accessor_storage = (__runInitializers(this, _connector_extraInitializers), __runInitializers(this, _which_initializers, 'center'));
|
|
521
|
+
this.#std_accessor_storage = (__runInitializers(this, _which_extraInitializers), __runInitializers(this, _std_initializers, void 0));
|
|
360
522
|
this.#richText_accessor_storage = (__runInitializers(this, _std_extraInitializers), __runInitializers(this, _richText_initializers, void 0));
|
|
361
523
|
__runInitializers(this, _richText_extraInitializers);
|
|
362
524
|
}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The barrel's door onto the label editor.
|
|
3
|
+
*
|
|
4
|
+
* It used to carry a SECOND copy of `mountConnectorLabelEditor`, byte-alike
|
|
5
|
+
* with the one in `edgeless-connector-label-editor.ts` — and since this file is
|
|
6
|
+
* what `text/index.ts` re-exports, the toolbar and the keyboard reached this
|
|
7
|
+
* copy while the connector view's double-click imported the other one directly.
|
|
8
|
+
* Two bodies, one behaviour, and no way to add the per-end selector
|
|
9
|
+
* (`docs/adr/0018` phase 2) to both at once without adding it twice.
|
|
10
|
+
*
|
|
11
|
+
* One body now lives next door; this file only forwards it.
|
|
12
|
+
*/
|
|
13
|
+
export * from './edgeless-connector-label-editor.js';
|
|
@@ -1,44 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
gfx.selection.set({
|
|
15
|
-
elements: [connector.id],
|
|
16
|
-
editing: true,
|
|
17
|
-
});
|
|
18
|
-
if (!connector.text) {
|
|
19
|
-
const text = new Y.Text();
|
|
20
|
-
const labelOffset = connector.labelOffset;
|
|
21
|
-
let labelXYWH = connector.labelXYWH ?? [0, 0, 16, 16];
|
|
22
|
-
if (point) {
|
|
23
|
-
const center = connector.getNearestPoint(point);
|
|
24
|
-
const distance = connector.getOffsetDistanceByPoint(center);
|
|
25
|
-
const bounds = Bound.fromXYWH(labelXYWH);
|
|
26
|
-
bounds.center = center;
|
|
27
|
-
labelOffset.distance = distance;
|
|
28
|
-
labelXYWH = bounds.toXYWH();
|
|
29
|
-
}
|
|
30
|
-
edgeless.std.get(EdgelessCRUDIdentifier).updateElement(connector.id, {
|
|
31
|
-
text,
|
|
32
|
-
labelXYWH,
|
|
33
|
-
labelOffset: { ...labelOffset },
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
const editor = new EdgelessConnectorLabelEditor();
|
|
37
|
-
editor.connector = connector;
|
|
38
|
-
mountElm.append(editor);
|
|
39
|
-
editor.updateComplete
|
|
40
|
-
.then(() => {
|
|
41
|
-
editor.inlineEditor?.focusEnd();
|
|
42
|
-
})
|
|
43
|
-
.catch(console.error);
|
|
44
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* The barrel's door onto the label editor.
|
|
3
|
+
*
|
|
4
|
+
* It used to carry a SECOND copy of `mountConnectorLabelEditor`, byte-alike
|
|
5
|
+
* with the one in `edgeless-connector-label-editor.ts` — and since this file is
|
|
6
|
+
* what `text/index.ts` re-exports, the toolbar and the keyboard reached this
|
|
7
|
+
* copy while the connector view's double-click imported the other one directly.
|
|
8
|
+
* Two bodies, one behaviour, and no way to add the per-end selector
|
|
9
|
+
* (`docs/adr/0018` phase 2) to both at once without adding it twice.
|
|
10
|
+
*
|
|
11
|
+
* One body now lives next door; this file only forwards it.
|
|
12
|
+
*/
|
|
13
|
+
export * from './edgeless-connector-label-editor.js';
|
|
@@ -1,4 +1,60 @@
|
|
|
1
|
+
import { PointStyle } from '../../affine-model/index.js';
|
|
1
2
|
import { type ToolbarContext, type ToolbarGenericAction } from '../../affine-shared/services/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Every `PointStyle` must appear in BOTH lists.
|
|
5
|
+
*
|
|
6
|
+
* `renderMenu` paints the menu's trigger with
|
|
7
|
+
* `renderCurrentMenuItemWith(items, currentValue, 'icon')`, which returns
|
|
8
|
+
* `undefined` for a value the list does not carry — an unlisted style gives a
|
|
9
|
+
* blank button, so a connector created by a framework (or imported) with that
|
|
10
|
+
* head shows an empty endpoint control. There is no test that can catch a
|
|
11
|
+
* forgotten entry at the type level; `endpoint-style.unit.spec.ts` asserts the
|
|
12
|
+
* coverage instead.
|
|
13
|
+
*/
|
|
14
|
+
export declare const FRONT_ENDPOINT_STYLE_LIST: [{
|
|
15
|
+
readonly value: PointStyle.None;
|
|
16
|
+
readonly icon: import("lit-html").TemplateResult<1>;
|
|
17
|
+
}, {
|
|
18
|
+
readonly value: PointStyle.Arrow;
|
|
19
|
+
readonly icon: import("lit-html").TemplateResult<1>;
|
|
20
|
+
}, {
|
|
21
|
+
readonly value: PointStyle.Triangle;
|
|
22
|
+
readonly icon: import("lit-html").TemplateResult<1>;
|
|
23
|
+
}, {
|
|
24
|
+
readonly value: PointStyle.TriangleHollow;
|
|
25
|
+
readonly icon: import("lit-html").TemplateResult<1>;
|
|
26
|
+
}, {
|
|
27
|
+
readonly value: PointStyle.Circle;
|
|
28
|
+
readonly icon: import("lit-html").TemplateResult<1>;
|
|
29
|
+
}, {
|
|
30
|
+
readonly value: PointStyle.Diamond;
|
|
31
|
+
readonly icon: import("lit-html").TemplateResult<1>;
|
|
32
|
+
}, {
|
|
33
|
+
readonly value: PointStyle.DiamondHollow;
|
|
34
|
+
readonly icon: import("lit-html").TemplateResult<1>;
|
|
35
|
+
}];
|
|
36
|
+
export declare const REAR_ENDPOINT_STYLE_LIST: [{
|
|
37
|
+
readonly value: PointStyle.Diamond;
|
|
38
|
+
readonly icon: import("lit-html").TemplateResult<1>;
|
|
39
|
+
}, {
|
|
40
|
+
readonly value: PointStyle.DiamondHollow;
|
|
41
|
+
readonly icon: import("lit-html").TemplateResult<1>;
|
|
42
|
+
}, {
|
|
43
|
+
readonly value: PointStyle.Circle;
|
|
44
|
+
readonly icon: import("lit-html").TemplateResult<1>;
|
|
45
|
+
}, {
|
|
46
|
+
readonly value: PointStyle.Triangle;
|
|
47
|
+
readonly icon: import("lit-html").TemplateResult<1>;
|
|
48
|
+
}, {
|
|
49
|
+
readonly value: PointStyle.TriangleHollow;
|
|
50
|
+
readonly icon: import("lit-html").TemplateResult<1>;
|
|
51
|
+
}, {
|
|
52
|
+
readonly value: PointStyle.Arrow;
|
|
53
|
+
readonly icon: import("lit-html").TemplateResult<1>;
|
|
54
|
+
}, {
|
|
55
|
+
readonly value: PointStyle.None;
|
|
56
|
+
readonly icon: import("lit-html").TemplateResult<1>;
|
|
57
|
+
}];
|
|
2
58
|
export declare const connectorToolbarConfig: {
|
|
3
59
|
readonly actions: [{
|
|
4
60
|
readonly id: "a.stroke-color";
|