@formicoidea/labre-core 0.31.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_pkgs/affine-block-callout/callout-block.d.ts +6 -0
- package/dist/_pkgs/affine-block-callout/callout-block.js +25 -3
- package/dist/_pkgs/affine-block-callout/callout-keymap.js +59 -19
- package/dist/_pkgs/affine-block-callout/commands/callout-to-paragraph.d.ts +20 -0
- package/dist/_pkgs/affine-block-callout/commands/callout-to-paragraph.js +60 -0
- package/dist/_pkgs/affine-block-callout/commands/split-callout.d.ts +17 -0
- package/dist/_pkgs/affine-block-callout/commands/split-callout.js +42 -0
- package/dist/_pkgs/affine-block-callout/configs/slash-menu.js +9 -6
- package/dist/_pkgs/affine-block-callout/emoji-margin.d.ts +9 -0
- package/dist/_pkgs/affine-block-callout/emoji-margin.js +36 -0
- package/dist/_pkgs/affine-block-callout/emoji-menu.d.ts +5 -1
- package/dist/_pkgs/affine-block-callout/emoji-menu.js +5 -0
- package/dist/_pkgs/affine-block-code/code-block.d.ts +14 -0
- package/dist/_pkgs/affine-block-code/code-block.js +44 -6
- package/dist/_pkgs/affine-block-code/code-toolbar/components/code-toolbar.d.ts +2 -0
- package/dist/_pkgs/affine-block-code/code-toolbar/components/code-toolbar.js +23 -14
- package/dist/_pkgs/affine-block-code/code-toolbar/components/more-menu.d.ts +16 -0
- package/dist/_pkgs/affine-block-code/code-toolbar/components/more-menu.js +93 -0
- package/dist/_pkgs/affine-block-code/code-toolbar/config.js +52 -5
- package/dist/_pkgs/affine-block-code/effects.d.ts +2 -0
- package/dist/_pkgs/affine-block-code/effects.js +2 -0
- package/dist/_pkgs/affine-block-code/highlight/affine-code-unit.js +6 -1
- package/dist/_pkgs/affine-block-code/index.d.ts +1 -0
- package/dist/_pkgs/affine-block-code/index.js +1 -0
- package/dist/_pkgs/affine-block-code/line-numbers.d.ts +25 -0
- package/dist/_pkgs/affine-block-code/line-numbers.js +27 -0
- package/dist/_pkgs/affine-block-code/styles.js +31 -0
- package/dist/_pkgs/affine-block-data-view/data-view-block.js +1 -0
- package/dist/_pkgs/affine-block-database/components/title/index.js +4 -1
- package/dist/_pkgs/affine-block-database/configs/slash-menu.js +28 -1
- package/dist/_pkgs/affine-block-database/database-block.js +13 -0
- package/dist/_pkgs/affine-block-database/properties/paste-url.d.ts +24 -0
- package/dist/_pkgs/affine-block-database/properties/paste-url.js +98 -0
- package/dist/_pkgs/affine-block-database/properties/rich-text/cell-renderer.js +9 -19
- package/dist/_pkgs/affine-block-database/properties/title/text.js +20 -25
- package/dist/_pkgs/affine-block-database/views/index.js +1 -0
- package/dist/_pkgs/affine-block-edgeless-text/edgeless-text-block.js +10 -0
- package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/config.d.ts +3 -0
- package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/config.js +48 -1
- package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/font-size.d.ts +17 -0
- package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/font-size.js +24 -0
- package/dist/_pkgs/affine-block-embed-doc/common/doc-trashed.d.ts +9 -0
- package/dist/_pkgs/affine-block-embed-doc/common/doc-trashed.js +10 -0
- package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-linked-doc-block.js +8 -4
- package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-synced-doc-block.d.ts +4 -0
- package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-synced-doc-block.js +22 -3
- package/dist/_pkgs/affine-block-frame/frame-manager.d.ts +13 -0
- package/dist/_pkgs/affine-block-frame/frame-manager.js +32 -2
- package/dist/_pkgs/affine-block-latex/styles.js +6 -1
- package/dist/_pkgs/affine-block-note/note-edgeless-block.d.ts +9 -0
- package/dist/_pkgs/affine-block-note/note-edgeless-block.js +29 -1
- package/dist/_pkgs/affine-block-root/commands/pivot-commands.d.ts +37 -0
- package/dist/_pkgs/affine-block-root/commands/pivot-commands.js +168 -0
- package/dist/_pkgs/affine-block-root/commands/reading-commands.d.ts +23 -0
- package/dist/_pkgs/affine-block-root/commands/reading-commands.js +107 -0
- package/dist/_pkgs/affine-block-root/commands/tag-commands.d.ts +47 -0
- package/dist/_pkgs/affine-block-root/commands/tag-commands.js +159 -0
- package/dist/_pkgs/affine-block-root/configs/toolbar.d.ts +1 -0
- package/dist/_pkgs/affine-block-root/edgeless/configs/toolbar/more.js +9 -2
- package/dist/_pkgs/affine-block-root/edgeless/configs/toolbar/render-linked-doc.js +1 -1
- package/dist/_pkgs/affine-block-root/edgeless/edgeless-keyboard.js +26 -1
- package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.js +11 -2
- package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-service.js +14 -0
- package/dist/_pkgs/affine-block-root/edgeless/index.d.ts +1 -0
- package/dist/_pkgs/affine-block-root/edgeless/index.js +1 -0
- package/dist/_pkgs/affine-block-root/edgeless/reserved-keys.d.ts +21 -0
- package/dist/_pkgs/affine-block-root/edgeless/reserved-keys.js +34 -0
- package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.d.ts +7 -1
- package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.js +11 -2
- package/dist/_pkgs/affine-block-root/index.d.ts +4 -1
- package/dist/_pkgs/affine-block-root/index.js +4 -1
- package/dist/_pkgs/affine-block-root/keyboard/commands.d.ts +2 -0
- package/dist/_pkgs/affine-block-root/keyboard/commands.js +147 -0
- package/dist/_pkgs/affine-block-root/view.js +13 -4
- package/dist/_pkgs/affine-block-surface/commands/reassociate-connectors.js +0 -1
- package/dist/_pkgs/affine-block-surface/effects.js +6 -0
- package/dist/_pkgs/affine-block-surface/element-model/index.d.ts +5 -2
- package/dist/_pkgs/affine-block-surface/element-model/index.js +4 -2
- package/dist/_pkgs/affine-block-surface/extensions/audit.d.ts +107 -0
- package/dist/_pkgs/affine-block-surface/extensions/audit.js +472 -0
- package/dist/_pkgs/affine-block-surface/extensions/crud-extension.d.ts +14 -0
- package/dist/_pkgs/affine-block-surface/extensions/crud-extension.js +27 -0
- package/dist/_pkgs/affine-block-surface/extensions/editor-anchored-panel.d.ts +133 -0
- package/dist/_pkgs/affine-block-surface/extensions/editor-anchored-panel.js +326 -0
- package/dist/_pkgs/affine-block-surface/extensions/index.d.ts +13 -0
- package/dist/_pkgs/affine-block-surface/extensions/index.js +13 -0
- package/dist/_pkgs/affine-block-surface/extensions/map-quality-widget.d.ts +146 -0
- package/dist/_pkgs/affine-block-surface/extensions/map-quality-widget.js +528 -0
- package/dist/_pkgs/affine-block-surface/extensions/map-quality.d.ts +109 -0
- package/dist/_pkgs/affine-block-surface/extensions/map-quality.js +84 -0
- package/dist/_pkgs/affine-block-surface/extensions/reading-toolbar.d.ts +15 -0
- package/dist/_pkgs/affine-block-surface/extensions/reading-toolbar.js +158 -0
- package/dist/_pkgs/affine-block-surface/extensions/reading-widget.d.ts +145 -0
- package/dist/_pkgs/affine-block-surface/extensions/reading-widget.js +590 -0
- package/dist/_pkgs/affine-block-surface/extensions/reading.d.ts +494 -0
- package/dist/_pkgs/affine-block-surface/extensions/reading.js +767 -0
- package/dist/_pkgs/affine-block-surface/extensions/spotlight.d.ts +45 -0
- package/dist/_pkgs/affine-block-surface/extensions/spotlight.js +177 -0
- package/dist/_pkgs/affine-block-surface/extensions/tags-toolbar.d.ts +10 -0
- package/dist/_pkgs/affine-block-surface/extensions/tags-toolbar.js +295 -0
- package/dist/_pkgs/affine-block-surface/extensions/validation-toolbar.d.ts +27 -0
- package/dist/_pkgs/affine-block-surface/extensions/validation-toolbar.js +361 -0
- package/dist/_pkgs/affine-block-surface/extensions/validation.d.ts +1340 -0
- package/dist/_pkgs/affine-block-surface/extensions/validation.js +3009 -0
- package/dist/_pkgs/affine-block-surface/extensions/violation-detail-widget.d.ts +286 -0
- package/dist/_pkgs/affine-block-surface/extensions/violation-detail-widget.js +907 -0
- package/dist/_pkgs/affine-block-surface/extensions/violation-timeline.d.ts +80 -0
- package/dist/_pkgs/affine-block-surface/extensions/violation-timeline.js +123 -0
- package/dist/_pkgs/affine-block-surface/framework-background/def.d.ts +321 -0
- package/dist/_pkgs/affine-block-surface/framework-background/def.js +81 -0
- package/dist/_pkgs/affine-block-surface/framework-background/facts.d.ts +188 -0
- package/dist/_pkgs/affine-block-surface/framework-background/facts.js +284 -0
- package/dist/_pkgs/affine-block-surface/framework-background/index.d.ts +5 -0
- package/dist/_pkgs/affine-block-surface/framework-background/index.js +5 -0
- package/dist/_pkgs/affine-block-surface/framework-background/interaction.d.ts +12 -0
- package/dist/_pkgs/affine-block-surface/framework-background/interaction.js +24 -0
- package/dist/_pkgs/affine-block-surface/framework-background/labels.d.ts +59 -0
- package/dist/_pkgs/affine-block-surface/framework-background/labels.js +117 -0
- package/dist/_pkgs/affine-block-surface/framework-background/renderer.d.ts +8 -0
- package/dist/_pkgs/affine-block-surface/framework-background/renderer.js +238 -0
- package/dist/_pkgs/affine-block-surface/index.d.ts +1 -0
- package/dist/_pkgs/affine-block-surface/index.js +1 -0
- package/dist/_pkgs/affine-block-surface/renderer/canvas-renderer.d.ts +69 -3
- package/dist/_pkgs/affine-block-surface/renderer/canvas-renderer.js +333 -44
- package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.js +18 -2
- package/dist/_pkgs/affine-block-surface/tool/default-tool.js +8 -0
- package/dist/_pkgs/affine-block-surface/utils/font.js +9 -3
- package/dist/_pkgs/affine-block-surface/view.d.ts +17 -0
- package/dist/_pkgs/affine-block-surface/view.js +57 -2
- package/dist/_pkgs/affine-block-table/selection-controller.d.ts +6 -0
- package/dist/_pkgs/affine-block-table/selection-controller.js +24 -1
- package/dist/_pkgs/affine-block-table/table-block.js +8 -2
- package/dist/_pkgs/affine-block-table/table-cell.js +5 -6
- package/dist/_pkgs/affine-block-table/table-keymap.d.ts +18 -0
- package/dist/_pkgs/affine-block-table/table-keymap.js +41 -0
- package/dist/_pkgs/affine-block-table/utils.d.ts +7 -0
- package/dist/_pkgs/affine-block-table/utils.js +12 -0
- package/dist/_pkgs/affine-block-table/view.js +2 -0
- package/dist/_pkgs/affine-components/caption/captioned-block-component.js +2 -1
- package/dist/_pkgs/affine-components/context-menu/button.d.ts +7 -0
- package/dist/_pkgs/affine-components/context-menu/button.js +7 -2
- package/dist/_pkgs/affine-components/context-menu/input.d.ts +4 -0
- package/dist/_pkgs/affine-components/context-menu/input.js +12 -0
- package/dist/_pkgs/affine-components/context-menu/menu-all.d.ts +2 -0
- package/dist/_pkgs/affine-components/context-menu/menu-renderer.js +8 -1
- package/dist/_pkgs/affine-components/context-menu/sub-menu.js +3 -0
- package/dist/_pkgs/affine-components/highlight-dropdown-menu/highlight-duotone-icon.js +8 -8
- package/dist/_pkgs/affine-components/highlight-dropdown-menu/text-duotone-icon.js +11 -11
- package/dist/_pkgs/affine-components/icon-picker/affine-icon-picker-panel.d.ts +28 -0
- package/dist/_pkgs/affine-components/icon-picker/affine-icon-picker-panel.js +231 -0
- package/dist/_pkgs/affine-components/icon-picker/emoji-data.d.ts +40 -0
- package/dist/_pkgs/affine-components/icon-picker/emoji-data.js +99 -0
- package/dist/_pkgs/affine-components/icon-picker/emoji-picker-panel.d.ts +32 -0
- package/dist/_pkgs/affine-components/icon-picker/emoji-picker-panel.js +276 -0
- package/dist/_pkgs/affine-components/icon-picker/icon-data.d.ts +34 -0
- package/dist/_pkgs/affine-components/icon-picker/icon-data.js +83 -0
- package/dist/_pkgs/affine-components/icon-picker/icon-picker.d.ts +39 -0
- package/dist/_pkgs/affine-components/icon-picker/icon-picker.js +233 -0
- package/dist/_pkgs/affine-components/icon-picker/index.d.ts +8 -0
- package/dist/_pkgs/affine-components/icon-picker/index.js +15 -0
- package/dist/_pkgs/affine-components/icon-picker/recent-store.d.ts +8 -0
- package/dist/_pkgs/affine-components/icon-picker/recent-store.js +41 -0
- package/dist/_pkgs/affine-components/icon-picker/styles.d.ts +5 -0
- package/dist/_pkgs/affine-components/icon-picker/styles.js +166 -0
- package/dist/_pkgs/affine-components/icon-picker/types.d.ts +22 -0
- package/dist/_pkgs/affine-components/icon-picker/types.js +10 -0
- package/dist/_pkgs/affine-components/icons/text.js +426 -426
- package/dist/_pkgs/affine-components/open-doc-dropdown-menu/dropdown-menu.d.ts +1 -0
- package/dist/_pkgs/affine-components/portal/portal.d.ts +1 -1
- package/dist/_pkgs/affine-components/toolbar/menu-button.js +1 -0
- package/dist/_pkgs/affine-components/toolbar/toolbar.js +11 -10
- package/dist/_pkgs/affine-foundation/view.js +11 -2
- package/dist/_pkgs/affine-gfx-brush/index.d.ts +1 -0
- package/dist/_pkgs/affine-gfx-brush/index.js +1 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/dom/brush.d.ts +1 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/dom/brush.js +11 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/dom/highlighter.d.ts +1 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/dom/highlighter.js +11 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/dom/index.d.ts +2 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/dom/index.js +2 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/dom/shared.d.ts +14 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/dom/shared.js +54 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/index.d.ts +1 -0
- package/dist/_pkgs/affine-gfx-brush/renderer/index.js +4 -0
- package/dist/_pkgs/affine-gfx-brush/view.d.ts +14 -0
- package/dist/_pkgs/affine-gfx-brush/view.js +29 -3
- package/dist/_pkgs/affine-gfx-connector/connector-manager.js +32 -6
- package/dist/_pkgs/affine-gfx-connector/connector-tool.d.ts +7 -0
- package/dist/_pkgs/affine-gfx-connector/connector-tool.js +2 -1
- package/dist/_pkgs/affine-gfx-connector/direction/direction-reveal.d.ts +123 -0
- package/dist/_pkgs/affine-gfx-connector/direction/direction-reveal.js +281 -0
- package/dist/_pkgs/affine-gfx-connector/direction/direction-widget.d.ts +65 -0
- package/dist/_pkgs/affine-gfx-connector/direction/direction-widget.js +395 -0
- package/dist/_pkgs/affine-gfx-connector/direction/index.d.ts +4 -0
- package/dist/_pkgs/affine-gfx-connector/direction/index.js +4 -0
- package/dist/_pkgs/affine-gfx-connector/direction/invert-direction.d.ts +72 -0
- package/dist/_pkgs/affine-gfx-connector/direction/invert-direction.js +187 -0
- package/dist/_pkgs/affine-gfx-connector/direction/typed-edge.d.ts +69 -0
- package/dist/_pkgs/affine-gfx-connector/direction/typed-edge.js +66 -0
- package/dist/_pkgs/affine-gfx-connector/effects.d.ts +2 -0
- package/dist/_pkgs/affine-gfx-connector/effects.js +2 -0
- package/dist/_pkgs/affine-gfx-connector/element-renderer/connector-dom/index.js +78 -41
- package/dist/_pkgs/affine-gfx-connector/index.d.ts +1 -0
- package/dist/_pkgs/affine-gfx-connector/index.js +1 -0
- package/dist/_pkgs/affine-gfx-connector/toolbar/config.d.ts +50 -0
- package/dist/_pkgs/affine-gfx-connector/toolbar/config.js +67 -1
- package/dist/_pkgs/affine-gfx-connector/view.js +16 -0
- package/dist/_pkgs/affine-gfx-group/command/group-api.js +150 -62
- package/dist/_pkgs/affine-gfx-group/text/edgeless-group-title-editor.js +4 -1
- package/dist/_pkgs/affine-gfx-pointer/tools/pan-tool.d.ts +16 -0
- package/dist/_pkgs/affine-gfx-pointer/tools/pan-tool.js +102 -32
- package/dist/_pkgs/affine-gfx-shape/commands.d.ts +2 -0
- package/dist/_pkgs/affine-gfx-shape/commands.js +33 -0
- package/dist/_pkgs/affine-gfx-shape/element-renderer/shape-dom/index.js +48 -19
- package/dist/_pkgs/affine-gfx-shape/index.d.ts +1 -1
- package/dist/_pkgs/affine-gfx-shape/index.js +1 -1
- package/dist/_pkgs/affine-gfx-shape/text/edgeless-shape-text-editor.d.ts +26 -0
- package/dist/_pkgs/affine-gfx-shape/text/edgeless-shape-text-editor.js +124 -13
- package/dist/_pkgs/affine-gfx-shape/view.js +3 -3
- package/dist/_pkgs/affine-gfx-template/toolbar/template-tool-button.d.ts +2 -0
- package/dist/_pkgs/affine-gfx-template/toolbar/template-tool-button.js +18 -1
- package/dist/_pkgs/affine-gfx-text/edgeless-text-editor.js +9 -5
- package/dist/_pkgs/affine-inline-latex/command.js +46 -26
- package/dist/_pkgs/affine-inline-latex/latex-node/latex-node.d.ts +10 -0
- package/dist/_pkgs/affine-inline-latex/latex-node/latex-node.js +23 -0
- package/dist/_pkgs/affine-inline-link/link-node/affine-link.js +4 -1
- package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.d.ts +3 -0
- package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.js +29 -1
- package/dist/_pkgs/affine-model/blocks/code/code-model.d.ts +1 -0
- package/dist/_pkgs/affine-model/blocks/code/code-model.js +1 -0
- package/dist/_pkgs/affine-model/elements/connector/connector.js +24 -0
- package/dist/_pkgs/affine-model/elements/edgy/board.d.ts +32 -0
- package/dist/_pkgs/affine-model/elements/edgy/board.js +112 -0
- package/dist/_pkgs/affine-model/elements/edgy/facets.d.ts +12 -0
- package/dist/_pkgs/affine-model/elements/edgy/facets.js +25 -1
- package/dist/_pkgs/affine-model/elements/edgy/index.d.ts +1 -0
- package/dist/_pkgs/affine-model/elements/edgy/index.js +1 -0
- package/dist/_pkgs/affine-model/elements/framework-background/background.d.ts +42 -0
- package/dist/_pkgs/affine-model/elements/framework-background/background.js +42 -0
- package/dist/_pkgs/affine-model/elements/framework-background/index.d.ts +1 -0
- package/dist/_pkgs/affine-model/elements/framework-background/index.js +1 -0
- package/dist/_pkgs/affine-model/elements/index.d.ts +3 -1
- package/dist/_pkgs/affine-model/elements/index.js +1 -0
- package/dist/_pkgs/affine-model/elements/mindmap/mindmap.js +8 -3
- package/dist/_pkgs/affine-model/elements/mindmap/style.d.ts +10 -0
- package/dist/_pkgs/affine-model/elements/mindmap/style.js +8 -0
- package/dist/_pkgs/affine-model/elements/wardley/wardley.d.ts +21 -29
- package/dist/_pkgs/affine-model/elements/wardley/wardley.js +41 -48
- package/dist/_pkgs/affine-shared/adapters/markdown/delta-converter.d.ts +6 -1
- package/dist/_pkgs/affine-shared/adapters/markdown/delta-converter.js +160 -2
- package/dist/_pkgs/affine-shared/adapters/markdown/markdown.js +5 -1
- package/dist/_pkgs/affine-shared/adapters/types/delta-converter.d.ts +1 -0
- package/dist/_pkgs/affine-shared/adapters/utils/color.d.ts +24 -0
- package/dist/_pkgs/affine-shared/adapters/utils/color.js +280 -0
- package/dist/_pkgs/affine-shared/adapters/utils/index.d.ts +1 -0
- package/dist/_pkgs/affine-shared/adapters/utils/index.js +1 -0
- package/dist/_pkgs/affine-shared/commands/block-crud/get-selected-blocks.js +10 -2
- package/dist/_pkgs/affine-shared/services/audit-service.d.ts +300 -0
- package/dist/_pkgs/affine-shared/services/audit-service.js +228 -0
- package/dist/_pkgs/affine-shared/services/edit-props-store.d.ts +7 -0
- package/dist/_pkgs/affine-shared/services/edit-props-store.js +11 -0
- package/dist/_pkgs/affine-shared/services/font-loader/font-loader-service.d.ts +26 -1
- package/dist/_pkgs/affine-shared/services/font-loader/font-loader-service.js +124 -7
- package/dist/_pkgs/affine-shared/services/index.d.ts +5 -0
- package/dist/_pkgs/affine-shared/services/index.js +5 -0
- package/dist/_pkgs/affine-shared/services/pivot-materiality-publisher.d.ts +129 -0
- package/dist/_pkgs/affine-shared/services/pivot-materiality-publisher.js +311 -0
- package/dist/_pkgs/affine-shared/services/pivot-properties-service.d.ts +217 -0
- package/dist/_pkgs/affine-shared/services/pivot-properties-service.js +114 -0
- package/dist/_pkgs/affine-shared/services/telemetry-service/code-block.d.ts +1 -1
- package/dist/_pkgs/affine-shared/services/telemetry-service/lifecycle.d.ts +182 -0
- package/dist/_pkgs/affine-shared/services/telemetry-service/telemetry-service.d.ts +2 -2
- package/dist/_pkgs/affine-shared/services/telemetry-service/types.d.ts +6 -1
- package/dist/_pkgs/affine-shared/services/toolbar-service/action.d.ts +10 -0
- package/dist/_pkgs/affine-shared/services/toolbar-service/index.d.ts +1 -0
- package/dist/_pkgs/affine-shared/services/toolbar-service/index.js +1 -0
- package/dist/_pkgs/affine-shared/services/toolbar-service/layout.d.ts +134 -0
- package/dist/_pkgs/affine-shared/services/toolbar-service/layout.js +146 -0
- package/dist/_pkgs/affine-shared/services/translation-service/index.d.ts +68 -0
- package/dist/_pkgs/affine-shared/services/translation-service/index.js +39 -0
- package/dist/_pkgs/affine-shared/services/universe-tag-defs-service.d.ts +155 -0
- package/dist/_pkgs/affine-shared/services/universe-tag-defs-service.js +254 -0
- package/dist/_pkgs/affine-shared/utils/dom/point-to-range.d.ts +4 -0
- package/dist/_pkgs/affine-shared/utils/dom/point-to-range.js +58 -2
- package/dist/_pkgs/affine-shared/utils/dom/viewport.d.ts +60 -0
- package/dist/_pkgs/affine-shared/utils/dom/viewport.js +58 -0
- package/dist/_pkgs/affine-shared/utils/print-to-pdf.d.ts +21 -0
- package/dist/_pkgs/affine-shared/utils/print-to-pdf.js +166 -32
- package/dist/_pkgs/affine-shared/utils/zod-schema.d.ts +7 -0
- package/dist/_pkgs/affine-shared/utils/zod-schema.js +27 -1
- package/dist/_pkgs/affine-widget-drag-handle/watchers/edgeless-watcher.d.ts +19 -10
- package/dist/_pkgs/affine-widget-drag-handle/watchers/edgeless-watcher.js +122 -23
- package/dist/_pkgs/affine-widget-drag-handle/watchers/pointer-event-watcher.d.ts +2 -0
- package/dist/_pkgs/affine-widget-drag-handle/watchers/pointer-event-watcher.js +25 -4
- package/dist/_pkgs/affine-widget-edgeless-selected-rect/auto-complete-panel.js +10 -5
- package/dist/_pkgs/affine-widget-edgeless-selected-rect/edgeless-auto-complete.d.ts +15 -1
- package/dist/_pkgs/affine-widget-edgeless-selected-rect/edgeless-auto-complete.js +37 -32
- package/dist/_pkgs/affine-widget-edgeless-selected-rect/edgeless-element-link.js +5 -4
- package/dist/_pkgs/affine-widget-edgeless-selected-rect/edgeless-selected-rect.js +19 -9
- package/dist/_pkgs/affine-widget-edgeless-selected-rect/utils.d.ts +16 -2
- package/dist/_pkgs/affine-widget-edgeless-selected-rect/utils.js +19 -2
- package/dist/_pkgs/affine-widget-edgeless-toolbar/index.d.ts +1 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/index.js +1 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/menu/command-menu.d.ts +38 -0
- package/dist/_pkgs/affine-widget-edgeless-toolbar/menu/command-menu.js +99 -0
- package/dist/_pkgs/affine-widget-frame-title/edgeless-frame-title-editor.js +4 -1
- package/dist/_pkgs/affine-widget-keyboard-toolbar/icons.js +98 -98
- package/dist/_pkgs/affine-widget-linked-doc/linked-doc-popover.js +2 -15
- package/dist/_pkgs/affine-widget-linked-doc/transformers/markdown.d.ts +10 -1
- package/dist/_pkgs/affine-widget-linked-doc/transformers/markdown.js +133 -6
- package/dist/_pkgs/affine-widget-linked-doc/transformers/utils.d.ts +10 -0
- package/dist/_pkgs/affine-widget-linked-doc/transformers/utils.js +120 -3
- package/dist/_pkgs/affine-widget-linked-doc/utils.d.ts +12 -0
- package/dist/_pkgs/affine-widget-linked-doc/utils.js +33 -0
- package/dist/_pkgs/affine-widget-remote-selection/edgeless/index.js +6 -4
- package/dist/_pkgs/affine-widget-slash-menu/slash-menu-popover.js +8 -4
- package/dist/_pkgs/affine-widget-slash-menu/utils.d.ts +9 -0
- package/dist/_pkgs/affine-widget-slash-menu/utils.js +24 -0
- package/dist/_pkgs/affine-widget-toolbar/toolbar.d.ts +6 -0
- package/dist/_pkgs/affine-widget-toolbar/toolbar.js +34 -6
- package/dist/_pkgs/affine-widget-toolbar/utils.d.ts +146 -3
- package/dist/_pkgs/affine-widget-toolbar/utils.js +738 -56
- package/dist/_pkgs/data-view/core/common/property-menu.js +3 -16
- package/dist/_pkgs/data-view/core/component/tags/multi-tag-select.d.ts +4 -0
- package/dist/_pkgs/data-view/core/component/tags/multi-tag-select.js +28 -1
- package/dist/_pkgs/data-view/core/data-view.d.ts +3 -1
- package/dist/_pkgs/data-view/core/data-view.js +25 -3
- package/dist/_pkgs/data-view/core/detail/field.js +2 -2
- package/dist/_pkgs/data-view/core/detail/selection.d.ts +4 -2
- package/dist/_pkgs/data-view/core/detail/selection.js +23 -7
- package/dist/_pkgs/data-view/core/effect.js +2 -0
- package/dist/_pkgs/data-view/core/filter/eval.js +36 -23
- package/dist/_pkgs/data-view/core/filter/filter-fn/matcher.d.ts +7 -0
- package/dist/_pkgs/data-view/core/filter/filter-fn/matcher.js +12 -0
- package/dist/_pkgs/data-view/core/group-by/compare-date-keys.d.ts +11 -0
- package/dist/_pkgs/data-view/core/group-by/compare-date-keys.js +55 -0
- package/dist/_pkgs/data-view/core/group-by/define.d.ts +6 -0
- package/dist/_pkgs/data-view/core/group-by/define.js +114 -0
- package/dist/_pkgs/data-view/core/group-by/matcher.d.ts +7 -0
- package/dist/_pkgs/data-view/core/group-by/matcher.js +13 -0
- package/dist/_pkgs/data-view/core/group-by/renderer/boolean-group.js +11 -11
- package/dist/_pkgs/data-view/core/group-by/renderer/date-group.d.ts +9 -0
- package/dist/_pkgs/data-view/core/group-by/renderer/date-group.js +97 -0
- package/dist/_pkgs/data-view/core/group-by/setting.js +86 -7
- package/dist/_pkgs/data-view/core/group-by/trait.d.ts +34 -0
- package/dist/_pkgs/data-view/core/group-by/trait.js +106 -10
- package/dist/_pkgs/data-view/core/utils/menu-title.js +17 -17
- package/dist/_pkgs/data-view/property-presets/multi-select/cell-renderer.js +3 -1
- package/dist/_pkgs/data-view/property-presets/number/define.js +2 -1
- package/dist/_pkgs/data-view/property-presets/select/cell-renderer.js +3 -1
- package/dist/_pkgs/data-view/view-presets/calendar/calendar-view-manager.d.ts +70 -0
- package/dist/_pkgs/data-view/view-presets/calendar/calendar-view-manager.js +449 -0
- package/dist/_pkgs/data-view/view-presets/calendar/define.d.ts +10 -0
- package/dist/_pkgs/data-view/view-presets/calendar/define.js +27 -0
- package/dist/_pkgs/data-view/view-presets/calendar/effect.d.ts +1 -0
- package/dist/_pkgs/data-view/view-presets/calendar/effect.js +4 -0
- package/dist/_pkgs/data-view/view-presets/calendar/index.d.ts +6 -0
- package/dist/_pkgs/data-view/view-presets/calendar/index.js +6 -0
- package/dist/_pkgs/data-view/view-presets/calendar/layout.d.ts +37 -0
- package/dist/_pkgs/data-view/view-presets/calendar/layout.js +138 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/actions.d.ts +7 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/actions.js +68 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/dnd.d.ts +32 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/dnd.js +159 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/effect.d.ts +1 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/effect.js +7 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/hit-test.d.ts +1 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/hit-test.js +28 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/styles.d.ts +1 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/styles.js +707 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/view.d.ts +89 -0
- package/dist/_pkgs/data-view/view-presets/calendar/pc/view.js +837 -0
- package/dist/_pkgs/data-view/view-presets/calendar/renderer.d.ts +2 -0
- package/dist/_pkgs/data-view/view-presets/calendar/renderer.js +8 -0
- package/dist/_pkgs/data-view/view-presets/calendar/source.d.ts +8 -0
- package/dist/_pkgs/data-view/view-presets/calendar/source.js +3 -0
- package/dist/_pkgs/data-view/view-presets/calendar/types.d.ts +79 -0
- package/dist/_pkgs/data-view/view-presets/calendar/types.js +1 -0
- package/dist/_pkgs/data-view/view-presets/convert.js +28 -0
- package/dist/_pkgs/data-view/view-presets/effect.js +2 -0
- package/dist/_pkgs/data-view/view-presets/index.d.ts +2 -0
- package/dist/_pkgs/data-view/view-presets/index.js +3 -0
- package/dist/_pkgs/data-view/view-presets/kanban/kanban-view-manager.js +3 -1
- package/dist/_pkgs/data-view/view-presets/kanban/mobile/cell.js +2 -2
- package/dist/_pkgs/data-view/view-presets/table/collapsed-state.d.ts +18 -0
- package/dist/_pkgs/data-view/view-presets/table/collapsed-state.js +36 -0
- package/dist/_pkgs/data-view/view-presets/table/mobile/cell.js +2 -2
- package/dist/_pkgs/data-view/view-presets/table/mobile/group.d.ts +11 -0
- package/dist/_pkgs/data-view/view-presets/table/mobile/group.js +87 -4
- package/dist/_pkgs/data-view/view-presets/table/pc/cell.d.ts +3 -0
- package/dist/_pkgs/data-view/view-presets/table/pc/cell.js +11 -2
- package/dist/_pkgs/data-view/view-presets/table/pc/controller/hotkeys.d.ts +1 -0
- package/dist/_pkgs/data-view/view-presets/table/pc/controller/hotkeys.js +39 -33
- package/dist/_pkgs/data-view/view-presets/table/pc/group.d.ts +10 -0
- package/dist/_pkgs/data-view/view-presets/table/pc/group.js +84 -5
- package/dist/_pkgs/data-view/view-presets/table/pc-virtual/controller/hotkeys.d.ts +1 -0
- package/dist/_pkgs/data-view/view-presets/table/pc-virtual/controller/hotkeys.js +39 -33
- package/dist/_pkgs/data-view/view-presets/table/pc-virtual/group/top/group-title.js +18 -18
- package/dist/_pkgs/data-view/view-presets/table/pc-virtual/row/cell.d.ts +3 -0
- package/dist/_pkgs/data-view/view-presets/table/pc-virtual/row/cell.js +8 -0
- package/dist/_pkgs/data-view/view-presets/table/table-view-manager.js +3 -1
- package/dist/_pkgs/data-view/view-presets/table/utils.d.ts +3 -0
- package/dist/_pkgs/data-view/view-presets/table/utils.js +16 -1
- package/dist/_pkgs/data-view/widget-presets/tools/presets/view-options/view-options.js +3 -1
- package/dist/_pkgs/global/gfx/curve.js +4 -3
- package/dist/_pkgs/std/clipboard/clipboard.js +13 -3
- package/dist/_pkgs/std/clipboard/utils.d.ts +5 -0
- package/dist/_pkgs/std/clipboard/utils.js +7 -0
- package/dist/_pkgs/std/event/dispatcher.js +27 -1
- package/dist/_pkgs/std/event/keymap.js +16 -6
- package/dist/_pkgs/std/extension/command-registry.d.ts +321 -0
- package/dist/_pkgs/std/extension/command-registry.js +233 -0
- package/dist/_pkgs/std/extension/dnd/index.d.ts +1 -1
- package/dist/_pkgs/std/extension/index.d.ts +2 -0
- package/dist/_pkgs/std/extension/index.js +2 -0
- package/dist/_pkgs/std/extension/translation-manifest.d.ts +49 -0
- package/dist/_pkgs/std/extension/translation-manifest.js +71 -0
- package/dist/_pkgs/std/gfx/index.d.ts +7 -3
- package/dist/_pkgs/std/gfx/index.js +6 -2
- package/dist/_pkgs/std/gfx/interactivity/gfx-view-event-handler.js +6 -1
- package/dist/_pkgs/std/gfx/interactivity/manager.d.ts +8 -0
- package/dist/_pkgs/std/gfx/interactivity/manager.js +18 -0
- package/dist/_pkgs/std/gfx/layer.d.ts +1 -1
- package/dist/_pkgs/std/gfx/layer.js +1 -2
- package/dist/_pkgs/std/gfx/model/surface/decorators/field.js +9 -0
- package/dist/_pkgs/std/gfx/model/surface/decorators/index.d.ts +2 -2
- package/dist/_pkgs/std/gfx/model/surface/decorators/index.js +2 -2
- package/dist/_pkgs/std/gfx/model/surface/decorators/local.d.ts +14 -0
- package/dist/_pkgs/std/gfx/model/surface/decorators/local.js +22 -0
- package/dist/_pkgs/std/gfx/model/surface/decorators/observer.d.ts +2 -0
- package/dist/_pkgs/std/gfx/model/surface/decorators/observer.js +40 -1
- package/dist/_pkgs/std/gfx/model/surface/element-model.d.ts +282 -0
- package/dist/_pkgs/std/gfx/model/surface/element-model.js +436 -25
- package/dist/_pkgs/std/gfx/model/surface/pivot.d.ts +48 -0
- package/dist/_pkgs/std/gfx/model/surface/pivot.js +34 -0
- package/dist/_pkgs/std/gfx/model/surface/role.d.ts +153 -0
- package/dist/_pkgs/std/gfx/model/surface/role.js +115 -0
- package/dist/_pkgs/std/gfx/model/surface/surface-model.d.ts +70 -0
- package/dist/_pkgs/std/gfx/model/surface/surface-model.js +304 -17
- package/dist/_pkgs/std/gfx/model/surface/tags.d.ts +77 -0
- package/dist/_pkgs/std/gfx/model/surface/tags.js +246 -0
- package/dist/_pkgs/std/gfx/perf.d.ts +10 -0
- package/dist/_pkgs/std/gfx/perf.js +30 -0
- package/dist/_pkgs/std/gfx/tool/tool-controller.d.ts +13 -0
- package/dist/_pkgs/std/gfx/tool/tool-controller.js +26 -0
- package/dist/_pkgs/std/gfx/viewport.d.ts +12 -0
- package/dist/_pkgs/std/gfx/viewport.js +19 -1
- package/dist/_pkgs/std/inline/services/event.d.ts +2 -0
- package/dist/_pkgs/std/inline/services/event.js +96 -21
- package/dist/_pkgs/std/utils/layer.js +2 -6
- package/dist/_pkgs/std/utils/tree.d.ts +14 -0
- package/dist/_pkgs/std/utils/tree.js +59 -8
- package/dist/_pkgs/std/view/element/gfx-block-component.js +23 -13
- package/dist/_pkgs/store/extension/workspace/workspace-meta.d.ts +10 -0
- package/dist/_pkgs/store/model/block/flat-sync-controller.js +2 -12
- package/dist/_pkgs/store/model/store/crud.js +7 -4
- package/dist/_pkgs/store/reactive/flat-native-y/index.d.ts +1 -1
- package/dist/_pkgs/store/reactive/flat-native-y/index.js +24 -2
- package/dist/commands.d.ts +58 -0
- package/dist/commands.js +66 -0
- package/dist/extensions/command-telemetry.d.ts +21 -0
- package/dist/extensions/command-telemetry.js +89 -0
- package/dist/extensions/store.d.ts +9 -4
- package/dist/extensions/store.js +27 -24
- package/dist/extensions/view.d.ts +9 -4
- package/dist/extensions/view.js +23 -8
- package/dist/flags.d.ts +98 -21
- package/dist/flags.js +103 -22
- package/dist/frameworks.d.ts +45 -0
- package/dist/frameworks.js +154 -0
- package/dist/schemas.d.ts +8 -5
- package/dist/schemas.js +28 -32
- package/dist/shortcuts.d.ts +16 -16
- package/dist/shortcuts.js +8 -36
- package/dist/translations.d.ts +56 -0
- package/dist/translations.js +112 -0
- package/package.json +16 -4
- package/dist/_pkgs/affine-block-root/keyboard/shortcuts.d.ts +0 -8
- package/dist/_pkgs/affine-block-root/keyboard/shortcuts.js +0 -48
- package/dist/_pkgs/affine-gfx-shape/shortcuts.d.ts +0 -6
- package/dist/_pkgs/affine-gfx-shape/shortcuts.js +0 -28
- package/dist/_pkgs/data-view/core/utils/cache.d.ts +0 -5
- package/dist/_pkgs/data-view/core/utils/cache.js +0 -28
|
@@ -0,0 +1,837 @@
|
|
|
1
|
+
import { menu, popFilterableSimpleMenu, popupTargetFromElement, } from '../../../../affine-components/context-menu/index.js';
|
|
2
|
+
import { ArrowLeftSmallIcon, ArrowRightSmallIcon, CloseIcon, DateTimeIcon, IntegrationsIcon, LinkedPageIcon, PlusIcon, TodayIcon, } from '@blocksuite/icons/lit';
|
|
3
|
+
import { html, nothing } from 'lit';
|
|
4
|
+
import { ref } from 'lit/directives/ref.js';
|
|
5
|
+
import { repeat } from 'lit/directives/repeat.js';
|
|
6
|
+
import { createUniComponentFromWebComponent, renderUniLit, } from '../../../core/index.js';
|
|
7
|
+
import { DataViewUIBase, DataViewUILogicBase, } from '../../../core/view/data-view-base.js';
|
|
8
|
+
import { createCalendarMonthLayout, getCalendarDayContentSlots, getCalendarDaySegmentSlots, getCalendarVisibleMonthRange, } from '../layout.js';
|
|
9
|
+
import { openCalendarEntry } from './actions.js';
|
|
10
|
+
import { CalendarDnd } from './dnd.js';
|
|
11
|
+
import { getCalendarDateFromPoint } from './hit-test.js';
|
|
12
|
+
import { calendarViewStyles } from './styles.js';
|
|
13
|
+
const dateFormatter = new Intl.DateTimeFormat(undefined, { day: 'numeric' });
|
|
14
|
+
const monthFormatter = new Intl.DateTimeFormat(undefined, {
|
|
15
|
+
month: 'long',
|
|
16
|
+
year: 'numeric',
|
|
17
|
+
});
|
|
18
|
+
const weekdayFormatter = new Intl.DateTimeFormat(undefined, {
|
|
19
|
+
weekday: 'short',
|
|
20
|
+
});
|
|
21
|
+
const startOfDay = (time) => {
|
|
22
|
+
const date = time instanceof Date ? time : new Date(time);
|
|
23
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
|
|
24
|
+
};
|
|
25
|
+
const getDefaultCreateDate = (month) => {
|
|
26
|
+
const today = startOfDay(Date.now());
|
|
27
|
+
const monthDate = new Date(month);
|
|
28
|
+
const todayDate = new Date(today);
|
|
29
|
+
if (monthDate.getFullYear() === todayDate.getFullYear() &&
|
|
30
|
+
monthDate.getMonth() === todayDate.getMonth()) {
|
|
31
|
+
return today;
|
|
32
|
+
}
|
|
33
|
+
return new Date(monthDate.getFullYear(), monthDate.getMonth(), 1).getTime();
|
|
34
|
+
};
|
|
35
|
+
export class CalendarViewUILogic extends DataViewUILogicBase {
|
|
36
|
+
constructor() {
|
|
37
|
+
super(...arguments);
|
|
38
|
+
this.dnd = new CalendarDnd(this.root.config.dnd, {
|
|
39
|
+
getEntry: entryId => this.view.entries$.value.find(entry => entry.id === entryId),
|
|
40
|
+
canDragEntry: () => !this.view.readonly$.value,
|
|
41
|
+
canDrop: entity => this.canDropDndEntity(entity),
|
|
42
|
+
onEntryDragStart: entry => {
|
|
43
|
+
this.interactionState = { type: 'drag', entry };
|
|
44
|
+
this.ui?.requestUpdate();
|
|
45
|
+
},
|
|
46
|
+
onEntryDragEnd: () => {
|
|
47
|
+
this.endInteraction();
|
|
48
|
+
},
|
|
49
|
+
onDropTargetChange: (day, entity) => {
|
|
50
|
+
this.setInteractionTarget(day, entity);
|
|
51
|
+
},
|
|
52
|
+
onDrop: (entity, date) => {
|
|
53
|
+
this.dropDndEntity(entity, date);
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
this.suppressNextClick = false;
|
|
57
|
+
this.currentMonth = startOfDay(Date.now());
|
|
58
|
+
this.clearSelection = () => {
|
|
59
|
+
this.setSelection(undefined);
|
|
60
|
+
};
|
|
61
|
+
this.addRow = (position) => {
|
|
62
|
+
if (this.view.readonly$.value)
|
|
63
|
+
return;
|
|
64
|
+
const rowId = this.view.rowAdd(position);
|
|
65
|
+
if (rowId) {
|
|
66
|
+
this.root.openDetailPanel({
|
|
67
|
+
view: this.view,
|
|
68
|
+
rowId,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return rowId;
|
|
72
|
+
};
|
|
73
|
+
this.focusFirstCell = () => { };
|
|
74
|
+
this.onWheel = (event) => {
|
|
75
|
+
if (event.metaKey || event.ctrlKey) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const ele = event.currentTarget;
|
|
79
|
+
if (ele instanceof HTMLElement) {
|
|
80
|
+
if (ele.scrollWidth === ele.clientWidth) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
event.stopPropagation();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
this.showIndicator = () => false;
|
|
87
|
+
this.hideIndicator = () => { };
|
|
88
|
+
this.moveTo = () => { };
|
|
89
|
+
this.renderer = createUniComponentFromWebComponent(CalendarViewUI);
|
|
90
|
+
}
|
|
91
|
+
getPreviewRange() {
|
|
92
|
+
const state = this.interactionState;
|
|
93
|
+
const target = state?.targetDay;
|
|
94
|
+
if (!state || target === undefined)
|
|
95
|
+
return undefined;
|
|
96
|
+
if (state.type === 'doc') {
|
|
97
|
+
return { start: target, end: target };
|
|
98
|
+
}
|
|
99
|
+
if (state.type === 'drag') {
|
|
100
|
+
const entry = state.entry;
|
|
101
|
+
const duration = entry.endAt !== undefined ? entry.endAt - entry.startAt : 0;
|
|
102
|
+
return { start: target, end: startOfDay(target + duration) };
|
|
103
|
+
}
|
|
104
|
+
const entry = state.entry;
|
|
105
|
+
const entryStart = startOfDay(entry.startAt);
|
|
106
|
+
const entryEnd = entry.endAt !== undefined ? startOfDay(entry.endAt) : entryStart;
|
|
107
|
+
if (state.edge === 'start') {
|
|
108
|
+
return {
|
|
109
|
+
start: Math.min(target, entryEnd),
|
|
110
|
+
end: Math.max(target, entryEnd),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
start: Math.min(entryStart, target),
|
|
115
|
+
end: Math.max(entryStart, target),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
isDayInPreview(day) {
|
|
119
|
+
const range = this.getPreviewRange();
|
|
120
|
+
if (!range)
|
|
121
|
+
return false;
|
|
122
|
+
return day >= range.start && day <= range.end;
|
|
123
|
+
}
|
|
124
|
+
isEntryBeingMoved(entryId) {
|
|
125
|
+
const state = this.interactionState;
|
|
126
|
+
return (state !== undefined && state.type !== 'doc' && state.entry.id === entryId);
|
|
127
|
+
}
|
|
128
|
+
attach(ui) {
|
|
129
|
+
this.ui = ui;
|
|
130
|
+
this.loadExternalEntries();
|
|
131
|
+
}
|
|
132
|
+
detach(ui) {
|
|
133
|
+
if (this.ui !== ui)
|
|
134
|
+
return;
|
|
135
|
+
this.cleanupResizeInteraction();
|
|
136
|
+
this.dnd.cleanup();
|
|
137
|
+
this.endInteraction();
|
|
138
|
+
this.ui = undefined;
|
|
139
|
+
}
|
|
140
|
+
moveMonth(offset) {
|
|
141
|
+
const date = new Date(this.currentMonth);
|
|
142
|
+
this.currentMonth = startOfDay(new Date(date.getFullYear(), date.getMonth() + offset, 1));
|
|
143
|
+
this.ui?.requestUpdate();
|
|
144
|
+
this.loadExternalEntries();
|
|
145
|
+
}
|
|
146
|
+
goToday() {
|
|
147
|
+
this.currentMonth = startOfDay(Date.now());
|
|
148
|
+
this.ui?.requestUpdate();
|
|
149
|
+
this.loadExternalEntries();
|
|
150
|
+
}
|
|
151
|
+
isCurrentMonth() {
|
|
152
|
+
const cursor = new Date(this.currentMonth);
|
|
153
|
+
const today = new Date();
|
|
154
|
+
return (cursor.getFullYear() === today.getFullYear() &&
|
|
155
|
+
cursor.getMonth() === today.getMonth());
|
|
156
|
+
}
|
|
157
|
+
createRowOnDate(date) {
|
|
158
|
+
if (this.view.readonly$.value)
|
|
159
|
+
return;
|
|
160
|
+
const rowId = this.view.createRowOnDate(date);
|
|
161
|
+
if (rowId) {
|
|
162
|
+
this.root.openDetailPanel({
|
|
163
|
+
view: this.view,
|
|
164
|
+
rowId,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
openSetupMenu(target) {
|
|
169
|
+
const items = this.view.dateProperties$.value.map(property => menu.action({
|
|
170
|
+
name: property.name$.value || 'Date',
|
|
171
|
+
select: () => {
|
|
172
|
+
this.view.setDateColumn(property.id);
|
|
173
|
+
},
|
|
174
|
+
}));
|
|
175
|
+
if (!this.view.readonly$.value) {
|
|
176
|
+
items.push(menu.action({
|
|
177
|
+
name: 'Create date property',
|
|
178
|
+
select: () => {
|
|
179
|
+
this.view.createDateColumn();
|
|
180
|
+
},
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
183
|
+
popFilterableSimpleMenu(popupTargetFromElement(target), items);
|
|
184
|
+
}
|
|
185
|
+
getWorkspaceCalendarConfig() {
|
|
186
|
+
return (this.view.data$.value?.sources.workspaceCalendar ?? {
|
|
187
|
+
enabled: true,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
createSourceControlItems() {
|
|
191
|
+
const workspaceCalendar = this.getWorkspaceCalendarConfig();
|
|
192
|
+
const selectedIds = workspaceCalendar.subscriptionIds
|
|
193
|
+
? new Set(workspaceCalendar.subscriptionIds)
|
|
194
|
+
: undefined;
|
|
195
|
+
const hasSubscriptionOptions = this.view.externalSources$.value.some(source => (source.getSubscriptionOptions?.().length ?? 0) > 0);
|
|
196
|
+
const subscriptionItems = this.view.externalSources$.value.flatMap(source => source.getSubscriptionOptions?.().map(subscription => menu.action({
|
|
197
|
+
name: `${selectedIds && !selectedIds.has(subscription.id) ? 'Show' : 'Hide'} ${subscription.name}`,
|
|
198
|
+
closeOnSelect: false,
|
|
199
|
+
select: () => {
|
|
200
|
+
const allIds = source
|
|
201
|
+
.getSubscriptionOptions?.()
|
|
202
|
+
.map(subscription => subscription.id);
|
|
203
|
+
if (!allIds?.length) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
const next = new Set(selectedIds ?? allIds);
|
|
207
|
+
if (next.has(subscription.id)) {
|
|
208
|
+
next.delete(subscription.id);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
next.add(subscription.id);
|
|
212
|
+
}
|
|
213
|
+
this.view.setWorkspaceCalendarSubscriptionIds([...next]);
|
|
214
|
+
this.loadExternalEntries();
|
|
215
|
+
},
|
|
216
|
+
})) ?? []);
|
|
217
|
+
const connectItems = this.view.externalSources$.value.flatMap(source => source.openConnectSettings
|
|
218
|
+
? [
|
|
219
|
+
menu.action({
|
|
220
|
+
name: 'Connect calendar',
|
|
221
|
+
closeOnSelect: false,
|
|
222
|
+
select: () => {
|
|
223
|
+
source.openConnectSettings?.();
|
|
224
|
+
},
|
|
225
|
+
}),
|
|
226
|
+
]
|
|
227
|
+
: []);
|
|
228
|
+
const toggleItems = hasSubscriptionOptions
|
|
229
|
+
? [
|
|
230
|
+
menu.action({
|
|
231
|
+
name: workspaceCalendar.enabled
|
|
232
|
+
? 'Hide workspace calendar'
|
|
233
|
+
: 'Show workspace calendar',
|
|
234
|
+
closeOnSelect: false,
|
|
235
|
+
select: () => {
|
|
236
|
+
this.view.setWorkspaceCalendarEnabled(!workspaceCalendar.enabled);
|
|
237
|
+
this.loadExternalEntries();
|
|
238
|
+
},
|
|
239
|
+
}),
|
|
240
|
+
menu.action({
|
|
241
|
+
name: 'Show all workspace calendars',
|
|
242
|
+
closeOnSelect: false,
|
|
243
|
+
select: () => {
|
|
244
|
+
this.view.setWorkspaceCalendarSubscriptionIds(undefined);
|
|
245
|
+
this.loadExternalEntries();
|
|
246
|
+
},
|
|
247
|
+
}),
|
|
248
|
+
]
|
|
249
|
+
: [];
|
|
250
|
+
return [...toggleItems, ...subscriptionItems, ...connectItems];
|
|
251
|
+
}
|
|
252
|
+
openSourceMenu(target) {
|
|
253
|
+
popFilterableSimpleMenu(popupTargetFromElement(target), this.createSourceControlItems());
|
|
254
|
+
}
|
|
255
|
+
getDatePropertyMenuItems(selectedPropertyId, onSelect, create, options) {
|
|
256
|
+
const closeOnSelect = options?.closeOnSelect;
|
|
257
|
+
const items = [];
|
|
258
|
+
if (options?.includeNone) {
|
|
259
|
+
items.push(menu.action({
|
|
260
|
+
name: 'None',
|
|
261
|
+
isSelected: !selectedPropertyId,
|
|
262
|
+
closeOnSelect,
|
|
263
|
+
select: () => onSelect(undefined),
|
|
264
|
+
}));
|
|
265
|
+
}
|
|
266
|
+
items.push(...this.view.dateProperties$.value.map(property => menu.action({
|
|
267
|
+
name: property.name$.value || 'Date',
|
|
268
|
+
isSelected: property.id === selectedPropertyId,
|
|
269
|
+
closeOnSelect,
|
|
270
|
+
select: () => onSelect(property.id),
|
|
271
|
+
})));
|
|
272
|
+
if (!this.view.readonly$.value && create) {
|
|
273
|
+
items.push(menu.action({
|
|
274
|
+
name: options?.createLabel ?? 'Create date property',
|
|
275
|
+
closeOnSelect,
|
|
276
|
+
select: create,
|
|
277
|
+
}));
|
|
278
|
+
}
|
|
279
|
+
return items;
|
|
280
|
+
}
|
|
281
|
+
getViewOptionsSettingItems(navigateToSubPage, goBack) {
|
|
282
|
+
const selectedStart = this.view.startDateMapping$.value.propertyId;
|
|
283
|
+
const selectedEnd = this.view.endDateMapping$.value.propertyId;
|
|
284
|
+
return [
|
|
285
|
+
menu.group({
|
|
286
|
+
name: 'Date range',
|
|
287
|
+
items: [
|
|
288
|
+
menu.action({
|
|
289
|
+
name: 'Calendar by',
|
|
290
|
+
prefix: TodayIcon(),
|
|
291
|
+
closeOnSelect: false,
|
|
292
|
+
postfix: html `<div
|
|
293
|
+
style="font-size:14px;color:var(--affine-text-secondary-color);"
|
|
294
|
+
>
|
|
295
|
+
${this.view.startDateMapping$.value.status === 'ready'
|
|
296
|
+
? this.view.propertyGetOrCreate(selectedStart ?? '').name$
|
|
297
|
+
.value
|
|
298
|
+
: ''}
|
|
299
|
+
</div>
|
|
300
|
+
${ArrowRightSmallIcon()}`,
|
|
301
|
+
select: () => {
|
|
302
|
+
navigateToSubPage('Calendar by', () => this.getDatePropertyMenuItems(this.view.startDateMapping$.value.propertyId, propertyId => {
|
|
303
|
+
if (propertyId) {
|
|
304
|
+
this.view.setStartDateColumn(propertyId);
|
|
305
|
+
goBack();
|
|
306
|
+
}
|
|
307
|
+
}, () => {
|
|
308
|
+
this.view.createStartDateColumn();
|
|
309
|
+
goBack();
|
|
310
|
+
}, { closeOnSelect: false }));
|
|
311
|
+
},
|
|
312
|
+
}),
|
|
313
|
+
menu.action({
|
|
314
|
+
name: 'End date',
|
|
315
|
+
prefix: DateTimeIcon(),
|
|
316
|
+
closeOnSelect: false,
|
|
317
|
+
postfix: html `<div
|
|
318
|
+
style="font-size:14px;color:var(--affine-text-secondary-color);"
|
|
319
|
+
>
|
|
320
|
+
${selectedEnd
|
|
321
|
+
? this.view.propertyGetOrCreate(selectedEnd).name$.value
|
|
322
|
+
: 'None'}
|
|
323
|
+
</div>
|
|
324
|
+
${ArrowRightSmallIcon()}`,
|
|
325
|
+
select: () => {
|
|
326
|
+
navigateToSubPage('End date', () => this.getDatePropertyMenuItems(this.view.endDateMapping$.value.propertyId, propertyId => {
|
|
327
|
+
this.view.setEndDateColumn(propertyId);
|
|
328
|
+
goBack();
|
|
329
|
+
}, () => {
|
|
330
|
+
this.view.createEndDateColumn();
|
|
331
|
+
goBack();
|
|
332
|
+
}, {
|
|
333
|
+
includeNone: true,
|
|
334
|
+
createLabel: 'Create end date property',
|
|
335
|
+
closeOnSelect: false,
|
|
336
|
+
}));
|
|
337
|
+
},
|
|
338
|
+
}),
|
|
339
|
+
menu.action({
|
|
340
|
+
name: 'External calendars',
|
|
341
|
+
prefix: IntegrationsIcon(),
|
|
342
|
+
closeOnSelect: false,
|
|
343
|
+
postfix: html `${ArrowRightSmallIcon()}`,
|
|
344
|
+
select: () => {
|
|
345
|
+
navigateToSubPage('External calendars', () => this.createSourceControlItems());
|
|
346
|
+
},
|
|
347
|
+
}),
|
|
348
|
+
],
|
|
349
|
+
}),
|
|
350
|
+
];
|
|
351
|
+
}
|
|
352
|
+
openEntry(entry, target) {
|
|
353
|
+
openCalendarEntry(this.root, this.view, entry, target, {
|
|
354
|
+
selectEntry: entryId => {
|
|
355
|
+
this.selectedEntryId = entryId;
|
|
356
|
+
this.ui?.requestUpdate();
|
|
357
|
+
},
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
get isInteracting() {
|
|
361
|
+
return this.interactionState !== undefined;
|
|
362
|
+
}
|
|
363
|
+
setInteractionTarget(day, entity) {
|
|
364
|
+
if (day !== undefined && entity?.type === 'doc') {
|
|
365
|
+
const current = this.interactionState;
|
|
366
|
+
if (current?.type === 'doc' &&
|
|
367
|
+
current.docId === entity.docId &&
|
|
368
|
+
current.targetDay === day) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
this.interactionState = {
|
|
372
|
+
type: 'doc',
|
|
373
|
+
docId: entity.docId,
|
|
374
|
+
targetDay: day,
|
|
375
|
+
};
|
|
376
|
+
this.ui?.requestUpdate();
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
if (this.interactionState?.type === 'doc') {
|
|
380
|
+
this.interactionState = undefined;
|
|
381
|
+
this.ui?.requestUpdate();
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
if (this.interactionState?.targetDay !== day) {
|
|
385
|
+
if (this.interactionState) {
|
|
386
|
+
this.interactionState = {
|
|
387
|
+
...this.interactionState,
|
|
388
|
+
targetDay: day,
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
this.ui?.requestUpdate();
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
endInteraction() {
|
|
395
|
+
this.interactionState = undefined;
|
|
396
|
+
this.ui?.requestUpdate();
|
|
397
|
+
}
|
|
398
|
+
bindCalendarDropTarget(element) {
|
|
399
|
+
this.dnd.bindRoot(element);
|
|
400
|
+
}
|
|
401
|
+
bindEntryDraggable(key, entry, element) {
|
|
402
|
+
this.dnd.bindEntry(key, entry, element, this.view.readonly$.value);
|
|
403
|
+
}
|
|
404
|
+
canDropDndEntity(entity) {
|
|
405
|
+
if (this.view.readonly$.value) {
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
if (entity.type === 'calendar-entry') {
|
|
409
|
+
const entry = this.view.entries$.value.find(entry => entry.id === entity.entryId);
|
|
410
|
+
return entry?.kind === 'row';
|
|
411
|
+
}
|
|
412
|
+
if (entity.type === 'doc') {
|
|
413
|
+
return this.view.startDateMapping$.value.status === 'ready';
|
|
414
|
+
}
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
417
|
+
dropDndEntity(entity, day) {
|
|
418
|
+
try {
|
|
419
|
+
if (entity.type === 'calendar-entry') {
|
|
420
|
+
const entry = this.view.entries$.value.find(entry => entry.id === entity.entryId);
|
|
421
|
+
if (entry?.kind === 'row') {
|
|
422
|
+
this.view.moveRowToDate(entry.rowId, day);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
if (entity.type === 'doc') {
|
|
426
|
+
this.view.createLinkedDocRowOnDate(day, entity.docId);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
finally {
|
|
430
|
+
this.endInteraction();
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
startResize(entry, edge, event) {
|
|
434
|
+
if (entry.kind !== 'row' || !entry.canResizeRange) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
event.preventDefault();
|
|
438
|
+
event.stopPropagation();
|
|
439
|
+
this.cleanupResizeInteraction();
|
|
440
|
+
this.interactionState = {
|
|
441
|
+
type: 'resize',
|
|
442
|
+
entry: entry,
|
|
443
|
+
edge,
|
|
444
|
+
};
|
|
445
|
+
this.ui?.requestUpdate();
|
|
446
|
+
const root = event.currentTarget.closest('.calendar-grid');
|
|
447
|
+
const doc = event.currentTarget.ownerDocument;
|
|
448
|
+
const dayFromPointer = (pointerEvent) => {
|
|
449
|
+
if (!root) {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
return getCalendarDateFromPoint(root, pointerEvent.clientX, pointerEvent.clientY);
|
|
453
|
+
};
|
|
454
|
+
const onPointerMove = (pointerEvent) => {
|
|
455
|
+
this.setInteractionTarget(dayFromPointer(pointerEvent));
|
|
456
|
+
};
|
|
457
|
+
const onPointerUp = (pointerEvent) => {
|
|
458
|
+
cleanup();
|
|
459
|
+
const date = dayFromPointer(pointerEvent);
|
|
460
|
+
if (date !== undefined) {
|
|
461
|
+
this.view.resizeRowRange(entry.rowId, edge, date);
|
|
462
|
+
}
|
|
463
|
+
this.endInteraction();
|
|
464
|
+
// Suppress the click event that the browser fires after pointerup
|
|
465
|
+
// when the pointer is released on top of the entry element.
|
|
466
|
+
this.suppressNextClick = true;
|
|
467
|
+
requestAnimationFrame(() => {
|
|
468
|
+
this.suppressNextClick = false;
|
|
469
|
+
});
|
|
470
|
+
};
|
|
471
|
+
const cleanup = () => {
|
|
472
|
+
doc.removeEventListener('pointermove', onPointerMove);
|
|
473
|
+
doc.removeEventListener('pointerup', onPointerUp);
|
|
474
|
+
if (this.cleanupResize === cleanup) {
|
|
475
|
+
this.cleanupResize = undefined;
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
this.cleanupResize = cleanup;
|
|
479
|
+
doc.addEventListener('pointermove', onPointerMove);
|
|
480
|
+
doc.addEventListener('pointerup', onPointerUp);
|
|
481
|
+
}
|
|
482
|
+
cleanupResizeInteraction() {
|
|
483
|
+
this.cleanupResize?.();
|
|
484
|
+
this.cleanupResize = undefined;
|
|
485
|
+
}
|
|
486
|
+
handleEntryClick(entry, target) {
|
|
487
|
+
if (this.suppressNextClick) {
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
this.openEntry(entry, target);
|
|
491
|
+
}
|
|
492
|
+
handleEntryKeydown(entry, event) {
|
|
493
|
+
if (event.key !== 'Enter' && event.key !== ' ') {
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
event.preventDefault();
|
|
497
|
+
this.handleEntryClick(entry, event.currentTarget);
|
|
498
|
+
}
|
|
499
|
+
loadExternalEntries() {
|
|
500
|
+
const range = getCalendarVisibleMonthRange(this.currentMonth);
|
|
501
|
+
this.view
|
|
502
|
+
.loadExternalEntries({ from: range.from, to: range.to })
|
|
503
|
+
.catch(() => {
|
|
504
|
+
this.root.config.notification.toast('Failed to load calendar entries');
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
export class CalendarViewUI extends DataViewUIBase {
|
|
509
|
+
static { this.styles = calendarViewStyles; }
|
|
510
|
+
connectedCallback() {
|
|
511
|
+
super.connectedCallback();
|
|
512
|
+
this.logic.attach(this);
|
|
513
|
+
this.dataset['testid'] = 'dv-calendar-view';
|
|
514
|
+
}
|
|
515
|
+
disconnectedCallback() {
|
|
516
|
+
this.logic.detach(this);
|
|
517
|
+
super.disconnectedCallback();
|
|
518
|
+
}
|
|
519
|
+
renderEntry(entry, extraStyle = '', segment) {
|
|
520
|
+
const dndKey = segment
|
|
521
|
+
? `${entry.id}:${segment.weekIndex}:${segment.startIndex}`
|
|
522
|
+
: `${entry.id}:day`;
|
|
523
|
+
const colorStyle = entry.kind === 'external' && entry.color
|
|
524
|
+
? `--calendar-external-color:${entry.color};`
|
|
525
|
+
: '';
|
|
526
|
+
const segmentClass = segment
|
|
527
|
+
? `${segment.startsBeforeWeek ? 'continues-left' : ''} ${segment.endsAfterWeek ? 'continues-right' : ''}`
|
|
528
|
+
: '';
|
|
529
|
+
const canResize = entry.kind === 'row' && entry.canResizeRange;
|
|
530
|
+
const showLeftHandle = canResize && segment && !segment.startsBeforeWeek;
|
|
531
|
+
const showRightHandle = canResize && segment && !segment.endsAfterWeek;
|
|
532
|
+
return html `
|
|
533
|
+
<div
|
|
534
|
+
${ref(element => this.logic.bindEntryDraggable(dndKey, entry, element))}
|
|
535
|
+
class="calendar-entry ${entry.kind} ${segmentClass} ${this.logic.selectedEntryId === entry.id ? 'selected' : ''}"
|
|
536
|
+
role="button"
|
|
537
|
+
tabindex="0"
|
|
538
|
+
aria-label=${entry.title || 'Untitled'}
|
|
539
|
+
style=${`${colorStyle}${extraStyle}`}
|
|
540
|
+
@click=${(event) => {
|
|
541
|
+
this.logic.handleEntryClick(entry, event.currentTarget);
|
|
542
|
+
}}
|
|
543
|
+
@keydown=${(event) => {
|
|
544
|
+
this.logic.handleEntryKeydown(entry, event);
|
|
545
|
+
}}
|
|
546
|
+
>
|
|
547
|
+
${showLeftHandle
|
|
548
|
+
? html `<span
|
|
549
|
+
class="calendar-resize-handle left"
|
|
550
|
+
@pointerdown=${(event) => this.logic.startResize(entry, 'start', event)}
|
|
551
|
+
></span>`
|
|
552
|
+
: nothing}
|
|
553
|
+
${this.renderEntryTitle(entry)}
|
|
554
|
+
${entry.kind === 'row' && entry.cardProperties.length
|
|
555
|
+
? html `<span class="calendar-entry-properties">
|
|
556
|
+
${entry.cardProperties.map(property => html `<span class="calendar-entry-property"
|
|
557
|
+
>${property.value}</span
|
|
558
|
+
>`)}
|
|
559
|
+
</span>`
|
|
560
|
+
: nothing}
|
|
561
|
+
${showRightHandle
|
|
562
|
+
? html `<span
|
|
563
|
+
class="calendar-resize-handle right"
|
|
564
|
+
@pointerdown=${(event) => this.logic.startResize(entry, 'end', event)}
|
|
565
|
+
></span>`
|
|
566
|
+
: nothing}
|
|
567
|
+
</div>
|
|
568
|
+
`;
|
|
569
|
+
}
|
|
570
|
+
renderEntryTitle(entry) {
|
|
571
|
+
if (entry.kind !== 'row') {
|
|
572
|
+
return html `<span
|
|
573
|
+
class="calendar-entry-title ${entry.title ? '' : 'is-empty'}"
|
|
574
|
+
>${entry.title || 'Untitled'}</span
|
|
575
|
+
>`;
|
|
576
|
+
}
|
|
577
|
+
if (entry.titleSegments?.length) {
|
|
578
|
+
return html `<span class="calendar-entry-title title-segments">
|
|
579
|
+
${entry.titleSegments.map(segment => html `<span
|
|
580
|
+
class="calendar-entry-title-segment ${segment.linkedDoc ? 'linked-doc-segment' : ''}"
|
|
581
|
+
>
|
|
582
|
+
${segment.linkedDoc ? LinkedPageIcon() : nothing}
|
|
583
|
+
${segment.text
|
|
584
|
+
? html `<span class="calendar-entry-title-text"
|
|
585
|
+
>${segment.text}</span
|
|
586
|
+
>`
|
|
587
|
+
: nothing}
|
|
588
|
+
</span>`)}
|
|
589
|
+
</span>`;
|
|
590
|
+
}
|
|
591
|
+
return html `<span
|
|
592
|
+
class="calendar-entry-title ${entry.title ? '' : 'is-empty'}"
|
|
593
|
+
>${entry.title || 'Untitled'}</span
|
|
594
|
+
>`;
|
|
595
|
+
}
|
|
596
|
+
getMovingEntryId() {
|
|
597
|
+
const state = this.logic.interactionState;
|
|
598
|
+
return state?.type !== 'doc' ? state?.entry.id : undefined;
|
|
599
|
+
}
|
|
600
|
+
renderDayPreview(dayDate) {
|
|
601
|
+
const range = this.logic.getPreviewRange();
|
|
602
|
+
if (!range || range.start !== range.end)
|
|
603
|
+
return nothing;
|
|
604
|
+
if (dayDate !== range.start)
|
|
605
|
+
return nothing;
|
|
606
|
+
const state = this.logic.interactionState;
|
|
607
|
+
if (!state)
|
|
608
|
+
return nothing;
|
|
609
|
+
if (state.type === 'doc') {
|
|
610
|
+
return html `<div class="calendar-entry-preview doc">
|
|
611
|
+
${LinkedPageIcon()}
|
|
612
|
+
<span class="calendar-entry-title-text"
|
|
613
|
+
>${this.logic.view.getDocDisplayTitle(state.docId)}</span
|
|
614
|
+
>
|
|
615
|
+
</div>`;
|
|
616
|
+
}
|
|
617
|
+
const title = state.entry.title || 'Untitled';
|
|
618
|
+
return html `<div class="calendar-entry-preview">${title}</div>`;
|
|
619
|
+
}
|
|
620
|
+
getSegmentPreviewLayout(week) {
|
|
621
|
+
const range = this.logic.getPreviewRange();
|
|
622
|
+
if (!range || range.start === range.end)
|
|
623
|
+
return;
|
|
624
|
+
const state = this.logic.interactionState;
|
|
625
|
+
if (!state || state.type === 'doc')
|
|
626
|
+
return;
|
|
627
|
+
const weekStart = week[0]?.date;
|
|
628
|
+
const weekEnd = week[6]?.date;
|
|
629
|
+
if (weekStart === undefined || weekEnd === undefined)
|
|
630
|
+
return;
|
|
631
|
+
if (range.start > weekEnd || range.end < weekStart)
|
|
632
|
+
return;
|
|
633
|
+
const segStart = Math.max(range.start, weekStart);
|
|
634
|
+
const segEnd = Math.min(range.end, weekEnd);
|
|
635
|
+
const sIdx = week.findIndex(d => d.date === segStart);
|
|
636
|
+
const eIdx = week.findIndex(d => d.date === segEnd);
|
|
637
|
+
if (sIdx < 0 || eIdx < 0)
|
|
638
|
+
return;
|
|
639
|
+
const slot = Math.max(0, ...week
|
|
640
|
+
.slice(sIdx, eIdx + 1)
|
|
641
|
+
.map(day => getCalendarDayContentSlots(day, state.entry.id)));
|
|
642
|
+
return {
|
|
643
|
+
sIdx,
|
|
644
|
+
eIdx,
|
|
645
|
+
span: eIdx - sIdx + 1,
|
|
646
|
+
slot,
|
|
647
|
+
continuesLeft: range.start < weekStart,
|
|
648
|
+
continuesRight: range.end > weekEnd,
|
|
649
|
+
title: range.start < weekStart ? '' : state.entry.title || 'Untitled',
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
renderPreviewSpacer(day, preview, dayIndex) {
|
|
653
|
+
const movingEntryId = this.getMovingEntryId();
|
|
654
|
+
if (!preview || dayIndex < preview.sIdx || dayIndex > preview.eIdx) {
|
|
655
|
+
return nothing;
|
|
656
|
+
}
|
|
657
|
+
const spacerSlots = preview.slot + 1 - getCalendarDayContentSlots(day, movingEntryId);
|
|
658
|
+
if (spacerSlots <= 0) {
|
|
659
|
+
return nothing;
|
|
660
|
+
}
|
|
661
|
+
return html `<div
|
|
662
|
+
class="calendar-preview-spacer"
|
|
663
|
+
style="height:calc(${spacerSlots} * var(--calendar-entry-slot-height));"
|
|
664
|
+
></div>`;
|
|
665
|
+
}
|
|
666
|
+
renderSegmentPreview(preview) {
|
|
667
|
+
if (!preview)
|
|
668
|
+
return nothing;
|
|
669
|
+
return html `<div
|
|
670
|
+
class="calendar-entry-preview ${preview.continuesLeft ? 'continues-left' : ''} ${preview.continuesRight ? 'continues-right' : ''}"
|
|
671
|
+
style="grid-column:${preview.sIdx + 1} / span ${preview.span};grid-row:${preview.slot + 1};"
|
|
672
|
+
>
|
|
673
|
+
${preview.title}
|
|
674
|
+
</div>`;
|
|
675
|
+
}
|
|
676
|
+
renderEmptyMonthHint(showHint) {
|
|
677
|
+
if (!showHint) {
|
|
678
|
+
return nothing;
|
|
679
|
+
}
|
|
680
|
+
return html `<div class="calendar-empty-month-hint">
|
|
681
|
+
<div class="calendar-empty-month-hint-copy">
|
|
682
|
+
<span class="calendar-empty-month-hint-title">Nothing here yet</span>
|
|
683
|
+
<span class="calendar-empty-month-hint-body">
|
|
684
|
+
Add a row to any date, it'll appear here on the calendar.
|
|
685
|
+
</span>
|
|
686
|
+
</div>
|
|
687
|
+
<div class="calendar-empty-month-hint-actions">
|
|
688
|
+
${this.logic.view.readonly$.value
|
|
689
|
+
? nothing
|
|
690
|
+
: html `<button
|
|
691
|
+
class="calendar-empty-month-hint-action"
|
|
692
|
+
@click=${() => this.logic.createRowOnDate(getDefaultCreateDate(this.logic.currentMonth))}
|
|
693
|
+
>
|
|
694
|
+
${PlusIcon()}<span>New row</span>
|
|
695
|
+
</button>`}
|
|
696
|
+
<button
|
|
697
|
+
class="calendar-empty-month-hint-close"
|
|
698
|
+
aria-label="Dismiss"
|
|
699
|
+
@click=${() => this.logic.view.dismissEmptyMonthHint()}
|
|
700
|
+
>
|
|
701
|
+
${CloseIcon()}
|
|
702
|
+
</button>
|
|
703
|
+
</div>
|
|
704
|
+
</div>`;
|
|
705
|
+
}
|
|
706
|
+
renderCalendar(skeleton = false) {
|
|
707
|
+
const entries = skeleton ? [] : this.logic.view.entries$.value;
|
|
708
|
+
const layout = createCalendarMonthLayout({
|
|
709
|
+
month: this.logic.currentMonth,
|
|
710
|
+
entries,
|
|
711
|
+
});
|
|
712
|
+
const weekdays = layout.weeks[0] ?? [];
|
|
713
|
+
const today = startOfDay(Date.now());
|
|
714
|
+
const currentMonthEmpty = layout.days
|
|
715
|
+
.filter(day => day.inMonth)
|
|
716
|
+
.every(day => day.entries.length === 0 && day.segments.length === 0);
|
|
717
|
+
const showEmptyMonthHint = currentMonthEmpty &&
|
|
718
|
+
!skeleton &&
|
|
719
|
+
!this.logic.view.emptyMonthHintDismissed$.value;
|
|
720
|
+
return html `
|
|
721
|
+
<div class="calendar-shell">
|
|
722
|
+
<div class="calendar-toolbar">
|
|
723
|
+
<div class="calendar-title">
|
|
724
|
+
${monthFormatter.format(new Date(this.logic.currentMonth))}
|
|
725
|
+
</div>
|
|
726
|
+
<div class="calendar-nav">
|
|
727
|
+
${this.logic.isCurrentMonth()
|
|
728
|
+
? nothing
|
|
729
|
+
: html `<button
|
|
730
|
+
class="calendar-today-button"
|
|
731
|
+
@click=${() => this.logic.goToday()}
|
|
732
|
+
>
|
|
733
|
+
<span>Today</span>
|
|
734
|
+
</button>`}
|
|
735
|
+
<button
|
|
736
|
+
class="calendar-icon-button"
|
|
737
|
+
aria-label="Previous month"
|
|
738
|
+
@click=${() => this.logic.moveMonth(-1)}
|
|
739
|
+
>
|
|
740
|
+
${ArrowLeftSmallIcon()}
|
|
741
|
+
</button>
|
|
742
|
+
<button
|
|
743
|
+
class="calendar-icon-button"
|
|
744
|
+
aria-label="Next month"
|
|
745
|
+
@click=${() => this.logic.moveMonth(1)}
|
|
746
|
+
>
|
|
747
|
+
${ArrowRightSmallIcon()}
|
|
748
|
+
</button>
|
|
749
|
+
</div>
|
|
750
|
+
</div>
|
|
751
|
+
${this.renderEmptyMonthHint(showEmptyMonthHint)}
|
|
752
|
+
<div class="calendar-weekdays">
|
|
753
|
+
${repeat(weekdays, day => day.date, day => html `<div class="calendar-weekday">
|
|
754
|
+
${weekdayFormatter.format(new Date(day.date))}
|
|
755
|
+
</div>`)}
|
|
756
|
+
</div>
|
|
757
|
+
<div
|
|
758
|
+
${ref(element => this.logic.bindCalendarDropTarget(element))}
|
|
759
|
+
class="calendar-grid"
|
|
760
|
+
>
|
|
761
|
+
${repeat(layout.weeks, week => week[0]?.date ?? 0, week => {
|
|
762
|
+
const weekSegments = layout.segments.filter(segment => segment.weekIndex === layout.weeks.indexOf(week));
|
|
763
|
+
const preview = this.getSegmentPreviewLayout(week);
|
|
764
|
+
const movingEntryId = this.getMovingEntryId();
|
|
765
|
+
return html `
|
|
766
|
+
<div class="calendar-week">
|
|
767
|
+
${repeat(week, day => day.date, (day, dayIndex) => {
|
|
768
|
+
const canReserveNewRow = !this.logic.view.readonly$.value && day.inMonth;
|
|
769
|
+
return html `
|
|
770
|
+
<div
|
|
771
|
+
data-date=${day.date}
|
|
772
|
+
class="calendar-day ${day.inMonth ? '' : 'is-outside'} ${day.date === today ? 'is-today' : ''} ${this.logic.isDayInPreview(day.date)
|
|
773
|
+
? 'is-drop-target'
|
|
774
|
+
: ''}"
|
|
775
|
+
style="--calendar-segment-slots:${getCalendarDaySegmentSlots(day, movingEntryId)};"
|
|
776
|
+
>
|
|
777
|
+
<div class="calendar-day-number">
|
|
778
|
+
${dateFormatter.format(new Date(day.date))}
|
|
779
|
+
</div>
|
|
780
|
+
<div class="calendar-day-entries">
|
|
781
|
+
${day.entries
|
|
782
|
+
.filter(e => !this.logic.isEntryBeingMoved(e.id))
|
|
783
|
+
.map(entry => this.renderEntry(entry))}
|
|
784
|
+
${this.renderDayPreview(day.date)}
|
|
785
|
+
${this.renderPreviewSpacer(day, preview, dayIndex)}
|
|
786
|
+
</div>
|
|
787
|
+
${canReserveNewRow
|
|
788
|
+
? html `<button
|
|
789
|
+
class="calendar-new-row"
|
|
790
|
+
aria-label="+ New row"
|
|
791
|
+
?disabled=${this.logic.isInteracting}
|
|
792
|
+
@click=${() => this.logic.createRowOnDate(day.date)}
|
|
793
|
+
>
|
|
794
|
+
${PlusIcon()}<span>New row</span>
|
|
795
|
+
</button>`
|
|
796
|
+
: nothing}
|
|
797
|
+
</div>
|
|
798
|
+
`;
|
|
799
|
+
})}
|
|
800
|
+
<div class="calendar-segments">
|
|
801
|
+
${weekSegments
|
|
802
|
+
.filter(s => !this.logic.isEntryBeingMoved(s.entry.id))
|
|
803
|
+
.map(segment => this.renderEntry(segment.entry, `grid-column:${segment.startIndex + 1} / span ${segment.span};grid-row:${segment.slot + 1};`, segment))}
|
|
804
|
+
${this.renderSegmentPreview(preview)}
|
|
805
|
+
</div>
|
|
806
|
+
</div>
|
|
807
|
+
`;
|
|
808
|
+
})}
|
|
809
|
+
</div>
|
|
810
|
+
</div>
|
|
811
|
+
`;
|
|
812
|
+
}
|
|
813
|
+
render() {
|
|
814
|
+
const setup = this.logic.view.dateMapping$.value.status === 'setup';
|
|
815
|
+
return html `
|
|
816
|
+
${this.logic.headerWidget
|
|
817
|
+
? renderUniLit(this.logic.headerWidget, {
|
|
818
|
+
dataViewLogic: this.logic,
|
|
819
|
+
})
|
|
820
|
+
: nothing}
|
|
821
|
+
<div class=${setup ? 'calendar-setup-wrap' : ''}>
|
|
822
|
+
<div class="calendar-scroll" @wheel="${this.logic.onWheel}">
|
|
823
|
+
${this.renderCalendar(setup)}
|
|
824
|
+
</div>
|
|
825
|
+
${setup
|
|
826
|
+
? html `<div class="calendar-setup">
|
|
827
|
+
<button
|
|
828
|
+
@click=${(event) => this.logic.openSetupMenu(event.currentTarget)}
|
|
829
|
+
>
|
|
830
|
+
${TodayIcon()}<span>Select or create date property</span>
|
|
831
|
+
</button>
|
|
832
|
+
</div>`
|
|
833
|
+
: nothing}
|
|
834
|
+
</div>
|
|
835
|
+
`;
|
|
836
|
+
}
|
|
837
|
+
}
|