@formicoidea/labre-core 0.23.0 → 0.23.2
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/package.json +1 -1
- package/src/_pkgs/affine-block-attachment/adapters/extension.ts +9 -9
- package/src/_pkgs/affine-block-attachment/adapters/markdown.ts +85 -85
- package/src/_pkgs/affine-block-attachment/adapters/notion-html.ts +115 -115
- package/src/_pkgs/affine-block-attachment/attachment-block.ts +533 -533
- package/src/_pkgs/affine-block-attachment/attachment-edgeless-block.ts +72 -72
- package/src/_pkgs/affine-block-attachment/attachment-service.ts +51 -51
- package/src/_pkgs/affine-block-attachment/components/rename-model.ts +95 -95
- package/src/_pkgs/affine-block-attachment/components/styles.ts +64 -64
- package/src/_pkgs/affine-block-attachment/configs/slash-menu.ts +58 -58
- package/src/_pkgs/affine-block-attachment/configs/toolbar.ts +411 -411
- package/src/_pkgs/affine-block-attachment/edgeless-clipboard-config.ts +34 -34
- package/src/_pkgs/affine-block-attachment/embed.ts +305 -305
- package/src/_pkgs/affine-block-attachment/store.ts +17 -17
- package/src/_pkgs/affine-block-attachment/styles.ts +160 -160
- package/src/_pkgs/affine-block-attachment/utils.ts +216 -216
- package/src/_pkgs/affine-block-attachment/view.ts +51 -51
- package/src/_pkgs/affine-block-bookmark/adapters/extension.ts +13 -13
- package/src/_pkgs/affine-block-bookmark/adapters/html.ts +10 -10
- package/src/_pkgs/affine-block-bookmark/adapters/markdown/index.ts +12 -12
- package/src/_pkgs/affine-block-bookmark/adapters/markdown/markdown.ts +93 -93
- package/src/_pkgs/affine-block-bookmark/adapters/markdown/preprocessor.ts +263 -263
- package/src/_pkgs/affine-block-bookmark/adapters/notion-html.ts +71 -71
- package/src/_pkgs/affine-block-bookmark/adapters/plain-text.ts +9 -9
- package/src/_pkgs/affine-block-bookmark/bookmark-block.ts +291 -291
- package/src/_pkgs/affine-block-bookmark/bookmark-edgeless-block.ts +88 -88
- package/src/_pkgs/affine-block-bookmark/commands/insert-bookmark.ts +23 -23
- package/src/_pkgs/affine-block-bookmark/commands/insert-link-by-quick-search.ts +79 -79
- package/src/_pkgs/affine-block-bookmark/components/bookmark-card.ts +131 -131
- package/src/_pkgs/affine-block-bookmark/configs/slash-menu.ts +65 -65
- package/src/_pkgs/affine-block-bookmark/configs/toolbar.ts +625 -625
- package/src/_pkgs/affine-block-bookmark/edgeless-clipboard-config.ts +29 -29
- package/src/_pkgs/affine-block-bookmark/store.ts +17 -17
- package/src/_pkgs/affine-block-bookmark/styles.ts +282 -282
- package/src/_pkgs/affine-block-bookmark/utils.ts +47 -47
- package/src/_pkgs/affine-block-bookmark/view.ts +43 -43
- package/src/_pkgs/affine-block-callout/adapters/markdown.ts +207 -207
- package/src/_pkgs/affine-block-callout/callout-block.ts +132 -132
- package/src/_pkgs/affine-block-callout/callout-keymap.ts +34 -34
- package/src/_pkgs/affine-block-callout/configs/slash-menu.ts +67 -67
- package/src/_pkgs/affine-block-callout/emoji-menu.ts +34 -34
- package/src/_pkgs/affine-block-callout/store.ts +17 -17
- package/src/_pkgs/affine-block-callout/view.ts +30 -30
- package/src/_pkgs/affine-block-code/adapters/extension.ts +13 -13
- package/src/_pkgs/affine-block-code/adapters/html.ts +109 -109
- package/src/_pkgs/affine-block-code/adapters/markdown/index.ts +12 -12
- package/src/_pkgs/affine-block-code/adapters/markdown/markdown.ts +99 -99
- package/src/_pkgs/affine-block-code/adapters/markdown/preprocessor.ts +76 -76
- package/src/_pkgs/affine-block-code/adapters/notion-html.ts +59 -59
- package/src/_pkgs/affine-block-code/adapters/plain-text.ts +26 -26
- package/src/_pkgs/affine-block-code/clipboard/index.ts +173 -173
- package/src/_pkgs/affine-block-code/code-block-config.ts +19 -19
- package/src/_pkgs/affine-block-code/code-block-inline.ts +50 -50
- package/src/_pkgs/affine-block-code/code-block-service.ts +69 -69
- package/src/_pkgs/affine-block-code/code-block.ts +498 -498
- package/src/_pkgs/affine-block-code/code-keymap.ts +7 -7
- package/src/_pkgs/affine-block-code/code-preview-extension.ts +27 -27
- package/src/_pkgs/affine-block-code/code-toolbar/components/code-toolbar.ts +159 -159
- package/src/_pkgs/affine-block-code/code-toolbar/components/lang-button.ts +168 -168
- package/src/_pkgs/affine-block-code/code-toolbar/components/preview-button.ts +112 -112
- package/src/_pkgs/affine-block-code/code-toolbar/config.ts +284 -284
- package/src/_pkgs/affine-block-code/code-toolbar/context.ts +46 -46
- package/src/_pkgs/affine-block-code/code-toolbar/index.ts +173 -173
- package/src/_pkgs/affine-block-code/code-toolbar/utils.ts +16 -16
- package/src/_pkgs/affine-block-code/configs/slash-menu.ts +8 -8
- package/src/_pkgs/affine-block-code/highlight/affine-code-unit.ts +122 -122
- package/src/_pkgs/affine-block-code/markdown.ts +61 -61
- package/src/_pkgs/affine-block-code/store.ts +19 -19
- package/src/_pkgs/affine-block-code/styles.ts +73 -73
- package/src/_pkgs/affine-block-code/turbo/code-layout-handler.ts +73 -73
- package/src/_pkgs/affine-block-code/turbo/code-painter.worker.ts +53 -53
- package/src/_pkgs/affine-block-code/view.ts +65 -65
- package/src/_pkgs/affine-block-data-view/block-meta/base.ts +37 -37
- package/src/_pkgs/affine-block-data-view/block-meta/todo.ts +13 -13
- package/src/_pkgs/affine-block-data-view/columns/index.ts +22 -22
- package/src/_pkgs/affine-block-data-view/configs/slash-menu.ts +51 -51
- package/src/_pkgs/affine-block-data-view/data-source.ts +326 -326
- package/src/_pkgs/affine-block-data-view/data-view-block.ts +318 -318
- package/src/_pkgs/affine-block-data-view/data-view-model.ts +102 -102
- package/src/_pkgs/affine-block-data-view/data-view-spec.ts +8 -8
- package/src/_pkgs/affine-block-data-view/store.ts +15 -15
- package/src/_pkgs/affine-block-data-view/view.ts +28 -28
- package/src/_pkgs/affine-block-data-view/views/index.ts +11 -11
- package/src/_pkgs/affine-block-database/adapters/extension.ts +13 -13
- package/src/_pkgs/affine-block-database/adapters/html.ts +105 -105
- package/src/_pkgs/affine-block-database/adapters/markdown.ts +67 -67
- package/src/_pkgs/affine-block-database/adapters/notion-html.ts +358 -358
- package/src/_pkgs/affine-block-database/adapters/plain-text.ts +48 -48
- package/src/_pkgs/affine-block-database/adapters/utils.ts +109 -109
- package/src/_pkgs/affine-block-database/block-icons.ts +45 -45
- package/src/_pkgs/affine-block-database/commands.ts +69 -69
- package/src/_pkgs/affine-block-database/components/layout.ts +69 -69
- package/src/_pkgs/affine-block-database/components/title/index.ts +199 -199
- package/src/_pkgs/affine-block-database/config.ts +6 -6
- package/src/_pkgs/affine-block-database/configs/slash-menu.ts +83 -83
- package/src/_pkgs/affine-block-database/context/host-context.ts +4 -4
- package/src/_pkgs/affine-block-database/data-source.ts +667 -667
- package/src/_pkgs/affine-block-database/database-block.ts +468 -468
- package/src/_pkgs/affine-block-database/database-dnd-preview-block.ts +58 -58
- package/src/_pkgs/affine-block-database/detail-panel/block-renderer.ts +158 -158
- package/src/_pkgs/affine-block-database/detail-panel/note-renderer.ts +129 -129
- package/src/_pkgs/affine-block-database/index.ts +14 -14
- package/src/_pkgs/affine-block-database/properties/converts.ts +176 -176
- package/src/_pkgs/affine-block-database/properties/created-time/cell-renderer.ts +54 -54
- package/src/_pkgs/affine-block-database/properties/created-time/define.ts +30 -30
- package/src/_pkgs/affine-block-database/properties/index.ts +29 -29
- package/src/_pkgs/affine-block-database/properties/link/cell-renderer-css.ts +99 -99
- package/src/_pkgs/affine-block-database/properties/link/cell-renderer.ts +186 -186
- package/src/_pkgs/affine-block-database/properties/link/define.ts +25 -25
- package/src/_pkgs/affine-block-database/properties/model.ts +20 -20
- package/src/_pkgs/affine-block-database/properties/rich-text/cell-renderer.ts +430 -430
- package/src/_pkgs/affine-block-database/properties/rich-text/define.ts +77 -77
- package/src/_pkgs/affine-block-database/properties/title/cell-renderer-css.ts +31 -31
- package/src/_pkgs/affine-block-database/properties/title/cell-renderer.ts +23 -23
- package/src/_pkgs/affine-block-database/properties/title/define.ts +83 -83
- package/src/_pkgs/affine-block-database/properties/title/icon.ts +21 -21
- package/src/_pkgs/affine-block-database/properties/title/text.ts +319 -319
- package/src/_pkgs/affine-block-database/selection.ts +68 -68
- package/src/_pkgs/affine-block-database/service/index.ts +11 -11
- package/src/_pkgs/affine-block-database/store.ts +19 -19
- package/src/_pkgs/affine-block-database/utils/block-utils.ts +240 -240
- package/src/_pkgs/affine-block-database/utils/title-doc.ts +30 -30
- package/src/_pkgs/affine-block-database/view.ts +51 -51
- package/src/_pkgs/affine-block-database/views/index.ts +12 -12
- package/src/_pkgs/affine-block-divider/adapters/extension.ts +13 -13
- package/src/_pkgs/affine-block-divider/adapters/html.ts +53 -53
- package/src/_pkgs/affine-block-divider/adapters/markdown.ts +50 -50
- package/src/_pkgs/affine-block-divider/adapters/notion-html.ts +38 -38
- package/src/_pkgs/affine-block-divider/adapters/plain-text.ts +21 -21
- package/src/_pkgs/affine-block-divider/divider-block.ts +50 -50
- package/src/_pkgs/affine-block-divider/markdown.ts +63 -63
- package/src/_pkgs/affine-block-divider/store.ts +17 -17
- package/src/_pkgs/affine-block-divider/view.ts +26 -26
- package/src/_pkgs/affine-block-edgeless-text/edgeless-clipboard-config.ts +33 -33
- package/src/_pkgs/affine-block-edgeless-text/edgeless-text-block.ts +512 -512
- package/src/_pkgs/affine-block-edgeless-text/edgeless-toolbar/config.ts +19 -19
- package/src/_pkgs/affine-block-edgeless-text/store.ts +14 -14
- package/src/_pkgs/affine-block-edgeless-text/view.ts +37 -37
- package/src/_pkgs/affine-block-embed/common/adapters/html.ts +66 -66
- package/src/_pkgs/affine-block-embed/common/adapters/markdown.ts +58 -58
- package/src/_pkgs/affine-block-embed/common/adapters/notion-html.ts +89 -89
- package/src/_pkgs/affine-block-embed/common/adapters/plain-text.ts +40 -40
- package/src/_pkgs/affine-block-embed/common/embed-block-element.ts +207 -207
- package/src/_pkgs/affine-block-embed/common/insert-embed-card.ts +94 -94
- package/src/_pkgs/affine-block-embed/common/render-linked-doc.ts +205 -205
- package/src/_pkgs/affine-block-embed/common/to-edgeless-embed-block.ts +78 -78
- package/src/_pkgs/affine-block-embed/common/utils.ts +49 -49
- package/src/_pkgs/affine-block-embed/configs/toolbar.ts +686 -686
- package/src/_pkgs/affine-block-embed/embed-figma-block/adapters/extension.ts +13 -13
- package/src/_pkgs/affine-block-embed/embed-figma-block/adapters/html.ts +11 -11
- package/src/_pkgs/affine-block-embed/embed-figma-block/adapters/markdown.ts +11 -11
- package/src/_pkgs/affine-block-embed/embed-figma-block/adapters/notion-html.ts +14 -14
- package/src/_pkgs/affine-block-embed/embed-figma-block/adapters/plain-text.ts +10 -10
- package/src/_pkgs/affine-block-embed/embed-figma-block/configs/slash-menu.ts +47 -47
- package/src/_pkgs/affine-block-embed/embed-figma-block/edgeless-clipboard-config.ts +25 -25
- package/src/_pkgs/affine-block-embed/embed-figma-block/embed-edgeless-figma-block.ts +13 -13
- package/src/_pkgs/affine-block-embed/embed-figma-block/embed-figma-block.ts +126 -126
- package/src/_pkgs/affine-block-embed/embed-figma-block/embed-figma-service.ts +14 -14
- package/src/_pkgs/affine-block-embed/embed-figma-block/embed-figma-spec.ts +26 -26
- package/src/_pkgs/affine-block-embed/embed-figma-block/styles.ts +218 -218
- package/src/_pkgs/affine-block-embed/embed-github-block/adapters/extension.ts +13 -13
- package/src/_pkgs/affine-block-embed/embed-github-block/adapters/html.ts +11 -11
- package/src/_pkgs/affine-block-embed/embed-github-block/adapters/markdown.ts +10 -10
- package/src/_pkgs/affine-block-embed/embed-github-block/adapters/notion-html.ts +14 -14
- package/src/_pkgs/affine-block-embed/embed-github-block/adapters/plain-text.ts +10 -10
- package/src/_pkgs/affine-block-embed/embed-github-block/configs/slash-menu.ts +47 -47
- package/src/_pkgs/affine-block-embed/embed-github-block/edgeless-clipboard-config.ts +51 -51
- package/src/_pkgs/affine-block-embed/embed-github-block/embed-edgeless-github-block.ts +13 -13
- package/src/_pkgs/affine-block-embed/embed-github-block/embed-github-block.ts +271 -271
- package/src/_pkgs/affine-block-embed/embed-github-block/embed-github-service.ts +36 -36
- package/src/_pkgs/affine-block-embed/embed-github-block/embed-github-spec.ts +30 -30
- package/src/_pkgs/affine-block-embed/embed-github-block/utils.ts +182 -182
- package/src/_pkgs/affine-block-embed/embed-html-block/components/fullscreen-toolbar.ts +171 -171
- package/src/_pkgs/affine-block-embed/embed-html-block/configs/toolbar.ts +193 -193
- package/src/_pkgs/affine-block-embed/embed-html-block/edgeless-clipboard-config.ts +24 -24
- package/src/_pkgs/affine-block-embed/embed-html-block/embed-edgeless-html-block.ts +19 -19
- package/src/_pkgs/affine-block-embed/embed-html-block/embed-html-block.ts +114 -114
- package/src/_pkgs/affine-block-embed/embed-html-block/embed-html-spec.ts +19 -19
- package/src/_pkgs/affine-block-embed/embed-iframe-block/adapters/html.ts +55 -55
- package/src/_pkgs/affine-block-embed/embed-iframe-block/adapters/index.ts +15 -15
- package/src/_pkgs/affine-block-embed/embed-iframe-block/adapters/markdown.ts +46 -46
- package/src/_pkgs/affine-block-embed/embed-iframe-block/adapters/plain-text.ts +31 -31
- package/src/_pkgs/affine-block-embed/embed-iframe-block/commands/insert-embed-iframe-with-url.ts +107 -107
- package/src/_pkgs/affine-block-embed/embed-iframe-block/commands/insert-empty-embed-iframe.ts +55 -55
- package/src/_pkgs/affine-block-embed/embed-iframe-block/components/embed-iframe-error-card.ts +343 -343
- package/src/_pkgs/affine-block-embed/embed-iframe-block/components/embed-iframe-idle-card.ts +132 -132
- package/src/_pkgs/affine-block-embed/embed-iframe-block/components/embed-iframe-link-edit-popup.ts +122 -122
- package/src/_pkgs/affine-block-embed/embed-iframe-block/components/embed-iframe-link-input-base.ts +160 -160
- package/src/_pkgs/affine-block-embed/embed-iframe-block/components/embed-iframe-link-input-popup.ts +292 -292
- package/src/_pkgs/affine-block-embed/embed-iframe-block/components/embed-iframe-loading-card.ts +193 -193
- package/src/_pkgs/affine-block-embed/embed-iframe-block/configs/providers/excalidraw.ts +42 -42
- package/src/_pkgs/affine-block-embed/embed-iframe-block/configs/providers/generic.ts +75 -75
- package/src/_pkgs/affine-block-embed/embed-iframe-block/configs/providers/google-docs.ts +81 -81
- package/src/_pkgs/affine-block-embed/embed-iframe-block/configs/providers/google-drive.ts +197 -197
- package/src/_pkgs/affine-block-embed/embed-iframe-block/configs/providers/miro.ts +46 -46
- package/src/_pkgs/affine-block-embed/embed-iframe-block/configs/providers/spotify.ts +47 -47
- package/src/_pkgs/affine-block-embed/embed-iframe-block/configs/slash-menu/slash-menu.ts +37 -37
- package/src/_pkgs/affine-block-embed/embed-iframe-block/configs/toolbar.ts +492 -492
- package/src/_pkgs/affine-block-embed/embed-iframe-block/edgeless-clipboard-config.ts +37 -37
- package/src/_pkgs/affine-block-embed/embed-iframe-block/embed-edgeless-iframe-block.ts +119 -119
- package/src/_pkgs/affine-block-embed/embed-iframe-block/embed-iframe-block.ts +470 -470
- package/src/_pkgs/affine-block-embed/embed-iframe-block/embed-iframe-spec.ts +23 -23
- package/src/_pkgs/affine-block-embed/embed-iframe-block/utils.ts +75 -75
- package/src/_pkgs/affine-block-embed/embed-loom-block/adapters/extension.ts +13 -13
- package/src/_pkgs/affine-block-embed/embed-loom-block/adapters/html.ts +11 -11
- package/src/_pkgs/affine-block-embed/embed-loom-block/adapters/markdown.ts +11 -11
- package/src/_pkgs/affine-block-embed/embed-loom-block/adapters/notion-html.ts +14 -14
- package/src/_pkgs/affine-block-embed/embed-loom-block/adapters/plain-text.ts +10 -10
- package/src/_pkgs/affine-block-embed/embed-loom-block/configs/slash-menu.ts +47 -47
- package/src/_pkgs/affine-block-embed/embed-loom-block/edgeless-clipboard-config.ts +28 -28
- package/src/_pkgs/affine-block-embed/embed-loom-block/embed-edgeless-loom-bock.ts +13 -13
- package/src/_pkgs/affine-block-embed/embed-loom-block/embed-loom-block.ts +171 -171
- package/src/_pkgs/affine-block-embed/embed-loom-block/embed-loom-service.ts +25 -25
- package/src/_pkgs/affine-block-embed/embed-loom-block/embed-loom-spec.ts +30 -30
- package/src/_pkgs/affine-block-embed/embed-loom-block/utils.ts +75 -75
- package/src/_pkgs/affine-block-embed/embed-youtube-block/adapters/extension.ts +13 -13
- package/src/_pkgs/affine-block-embed/embed-youtube-block/adapters/html.ts +51 -51
- package/src/_pkgs/affine-block-embed/embed-youtube-block/adapters/markdown.ts +10 -10
- package/src/_pkgs/affine-block-embed/embed-youtube-block/adapters/notion-html.ts +14 -14
- package/src/_pkgs/affine-block-embed/embed-youtube-block/adapters/plain-text.ts +12 -12
- package/src/_pkgs/affine-block-embed/embed-youtube-block/configs/slash-menu.ts +47 -47
- package/src/_pkgs/affine-block-embed/embed-youtube-block/edgeless-clipboard-config.ts +42 -42
- package/src/_pkgs/affine-block-embed/embed-youtube-block/embed-edgeless-youtube-block.ts +13 -13
- package/src/_pkgs/affine-block-embed/embed-youtube-block/embed-youtube-block.ts +225 -225
- package/src/_pkgs/affine-block-embed/embed-youtube-block/embed-youtube-service.ts +35 -35
- package/src/_pkgs/affine-block-embed/embed-youtube-block/embed-youtube-spec.ts +30 -30
- package/src/_pkgs/affine-block-embed/embed-youtube-block/styles.ts +241 -241
- package/src/_pkgs/affine-block-embed/embed-youtube-block/utils.ts +114 -114
- package/src/_pkgs/affine-block-embed/store.ts +48 -48
- package/src/_pkgs/affine-block-embed/types.ts +23 -23
- package/src/_pkgs/affine-block-embed/view.ts +72 -72
- package/src/_pkgs/affine-block-embed-doc/common/render-linked-doc.ts +213 -213
- package/src/_pkgs/affine-block-embed-doc/embed-linked-doc-block/adapters/extension.ts +11 -11
- package/src/_pkgs/affine-block-embed-doc/embed-linked-doc-block/adapters/html.ts +63 -63
- package/src/_pkgs/affine-block-embed-doc/embed-linked-doc-block/adapters/markdown.ts +122 -122
- package/src/_pkgs/affine-block-embed-doc/embed-linked-doc-block/adapters/plain-text.ts +33 -33
- package/src/_pkgs/affine-block-embed-doc/embed-linked-doc-block/commands/insert-embed-linked-doc.ts +34 -34
- package/src/_pkgs/affine-block-embed-doc/embed-linked-doc-block/configs/slash-menu.ts +84 -84
- package/src/_pkgs/affine-block-embed-doc/embed-linked-doc-block/configs/toolbar.ts +513 -513
- package/src/_pkgs/affine-block-embed-doc/embed-linked-doc-block/edgeless-clipboard-config.ts +31 -31
- package/src/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-edgeless-linked-doc-block.ts +71 -71
- package/src/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-linked-doc-block.ts +628 -628
- package/src/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-linked-doc-spec.ts +21 -21
- package/src/_pkgs/affine-block-embed-doc/embed-linked-doc-block/styles.ts +2232 -2232
- package/src/_pkgs/affine-block-embed-doc/embed-linked-doc-block/utils.ts +102 -102
- package/src/_pkgs/affine-block-embed-doc/embed-synced-doc-block/adapters/extension.ts +11 -11
- package/src/_pkgs/affine-block-embed-doc/embed-synced-doc-block/adapters/html.ts +88 -88
- package/src/_pkgs/affine-block-embed-doc/embed-synced-doc-block/adapters/markdown.ts +64 -64
- package/src/_pkgs/affine-block-embed-doc/embed-synced-doc-block/adapters/plain-text.ts +62 -62
- package/src/_pkgs/affine-block-embed-doc/embed-synced-doc-block/commands/insert-embed-synced-doc.ts +20 -20
- package/src/_pkgs/affine-block-embed-doc/embed-synced-doc-block/components/embed-synced-doc-card.ts +262 -262
- package/src/_pkgs/affine-block-embed-doc/embed-synced-doc-block/configs/edgeless-interaction.ts +87 -87
- package/src/_pkgs/affine-block-embed-doc/embed-synced-doc-block/configs/index.ts +18 -18
- package/src/_pkgs/affine-block-embed-doc/embed-synced-doc-block/configs/toolbar.ts +500 -500
- package/src/_pkgs/affine-block-embed-doc/embed-synced-doc-block/edgeless-clipboard-config.ts +27 -27
- package/src/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-edgeless-synced-doc-block.ts +196 -196
- package/src/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-synced-doc-block.ts +627 -627
- package/src/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-synced-doc-spec.ts +20 -20
- package/src/_pkgs/affine-block-embed-doc/embed-synced-doc-block/index.ts +8 -8
- package/src/_pkgs/affine-block-embed-doc/embed-synced-doc-block/init-height-extension.ts +65 -65
- package/src/_pkgs/affine-block-embed-doc/embed-synced-doc-block/styles.ts +1122 -1122
- package/src/_pkgs/affine-block-embed-doc/embed-synced-doc-block/utils.ts +74 -74
- package/src/_pkgs/affine-block-embed-doc/store.ts +25 -25
- package/src/_pkgs/affine-block-embed-doc/view.ts +40 -40
- package/src/_pkgs/affine-block-frame/edgeless-clipboard-config.ts +43 -43
- package/src/_pkgs/affine-block-frame/edgeless-toolbar/frame-dense-menu.ts +34 -34
- package/src/_pkgs/affine-block-frame/edgeless-toolbar/frame-menu.ts +104 -104
- package/src/_pkgs/affine-block-frame/edgeless-toolbar/frame-tool-button.ts +49 -49
- package/src/_pkgs/affine-block-frame/edgeless-toolbar/presentation-toolbar.ts +560 -560
- package/src/_pkgs/affine-block-frame/edgeless-toolbar/quick-tool.ts +16 -16
- package/src/_pkgs/affine-block-frame/frame-block.ts +208 -208
- package/src/_pkgs/affine-block-frame/frame-highlight-manager.ts +96 -96
- package/src/_pkgs/affine-block-frame/frame-manager.ts +503 -503
- package/src/_pkgs/affine-block-frame/frame-spec.ts +16 -16
- package/src/_pkgs/affine-block-frame/frame-tool.ts +108 -108
- package/src/_pkgs/affine-block-frame/frame-toolbar.ts +218 -218
- package/src/_pkgs/affine-block-frame/present/frame-order-button.ts +82 -82
- package/src/_pkgs/affine-block-frame/present/frame-order-menu.ts +265 -265
- package/src/_pkgs/affine-block-frame/present/navigator-bg-widget.ts +126 -126
- package/src/_pkgs/affine-block-frame/present/navigator-setting-button.ts +195 -195
- package/src/_pkgs/affine-block-frame/present/present-button.ts +40 -40
- package/src/_pkgs/affine-block-frame/present-tool.ts +12 -12
- package/src/_pkgs/affine-block-frame/store.ts +14 -14
- package/src/_pkgs/affine-block-frame/view.ts +39 -39
- package/src/_pkgs/affine-block-image/adapters/extension.ts +11 -11
- package/src/_pkgs/affine-block-image/adapters/html.ts +90 -90
- package/src/_pkgs/affine-block-image/adapters/markdown.ts +66 -66
- package/src/_pkgs/affine-block-image/adapters/notion-html.ts +82 -82
- package/src/_pkgs/affine-block-image/adapters/utils.ts +89 -89
- package/src/_pkgs/affine-block-image/commands/insert-images.ts +40 -40
- package/src/_pkgs/affine-block-image/components/image-block-fallback.ts +126 -126
- package/src/_pkgs/affine-block-image/components/page-image-block.ts +422 -422
- package/src/_pkgs/affine-block-image/configs/slash-menu.ts +32 -32
- package/src/_pkgs/affine-block-image/configs/toolbar.ts +174 -174
- package/src/_pkgs/affine-block-image/edgeless-clipboard-config.ts +30 -30
- package/src/_pkgs/affine-block-image/image-block.ts +194 -194
- package/src/_pkgs/affine-block-image/image-edgeless-block.ts +205 -205
- package/src/_pkgs/affine-block-image/image-resize-manager.ts +105 -105
- package/src/_pkgs/affine-block-image/image-service.ts +46 -46
- package/src/_pkgs/affine-block-image/image-spec.ts +29 -29
- package/src/_pkgs/affine-block-image/index.ts +11 -11
- package/src/_pkgs/affine-block-image/preview-image/edgeless.ts +25 -25
- package/src/_pkgs/affine-block-image/preview-image/page.ts +58 -58
- package/src/_pkgs/affine-block-image/store.ts +18 -18
- package/src/_pkgs/affine-block-image/turbo/image-layout-handler.ts +71 -71
- package/src/_pkgs/affine-block-image/turbo/image-painter.worker.ts +56 -56
- package/src/_pkgs/affine-block-image/utils.ts +433 -433
- package/src/_pkgs/affine-block-image/view.ts +27 -27
- package/src/_pkgs/affine-block-latex/adapters/extension.ts +11 -11
- package/src/_pkgs/affine-block-latex/adapters/markdown/index.ts +12 -12
- package/src/_pkgs/affine-block-latex/adapters/markdown/markdown.ts +55 -55
- package/src/_pkgs/affine-block-latex/adapters/markdown/preprocessor.ts +88 -88
- package/src/_pkgs/affine-block-latex/adapters/notion-html.ts +50 -50
- package/src/_pkgs/affine-block-latex/adapters/plain-text.ts +29 -29
- package/src/_pkgs/affine-block-latex/commands.ts +75 -75
- package/src/_pkgs/affine-block-latex/configs/slash-menu.ts +62 -62
- package/src/_pkgs/affine-block-latex/configs/tooltips.ts +41 -41
- package/src/_pkgs/affine-block-latex/latex-block.ts +158 -158
- package/src/_pkgs/affine-block-latex/store.ts +19 -19
- package/src/_pkgs/affine-block-latex/styles.ts +40 -40
- package/src/_pkgs/affine-block-latex/view.ts +27 -27
- package/src/_pkgs/affine-block-list/adapters/extension.ts +13 -13
- package/src/_pkgs/affine-block-list/adapters/html.ts +203 -203
- package/src/_pkgs/affine-block-list/adapters/markdown.ts +156 -156
- package/src/_pkgs/affine-block-list/adapters/notion-html.ts +116 -116
- package/src/_pkgs/affine-block-list/adapters/plain-text.ts +27 -27
- package/src/_pkgs/affine-block-list/commands/convert-to-numbered-list.ts +28 -28
- package/src/_pkgs/affine-block-list/commands/dedent-list.ts +165 -165
- package/src/_pkgs/affine-block-list/commands/indent-list.ts +147 -147
- package/src/_pkgs/affine-block-list/commands/list-to-paragraph.ts +44 -44
- package/src/_pkgs/affine-block-list/commands/split-list.ts +250 -250
- package/src/_pkgs/affine-block-list/commands/utils.ts +70 -70
- package/src/_pkgs/affine-block-list/list-block.ts +216 -216
- package/src/_pkgs/affine-block-list/list-keymap.ts +136 -136
- package/src/_pkgs/affine-block-list/markdown.ts +91 -91
- package/src/_pkgs/affine-block-list/store.ts +17 -17
- package/src/_pkgs/affine-block-list/turbo/list-layout-handler.ts +151 -151
- package/src/_pkgs/affine-block-list/turbo/list-painter.worker.ts +119 -119
- package/src/_pkgs/affine-block-list/utils/forward-delete.ts +75 -75
- package/src/_pkgs/affine-block-list/utils/get-list-icon.ts +78 -78
- package/src/_pkgs/affine-block-list/view.ts +30 -30
- package/src/_pkgs/affine-block-note/adapters/html.ts +44 -44
- package/src/_pkgs/affine-block-note/adapters/index.ts +30 -30
- package/src/_pkgs/affine-block-note/adapters/markdown.ts +131 -131
- package/src/_pkgs/affine-block-note/adapters/plain-text.ts +41 -41
- package/src/_pkgs/affine-block-note/commands/block-type.ts +247 -247
- package/src/_pkgs/affine-block-note/commands/change-note-display-mode.ts +60 -60
- package/src/_pkgs/affine-block-note/commands/dedent-block-to-root.ts +38 -38
- package/src/_pkgs/affine-block-note/commands/dedent-block.ts +67 -67
- package/src/_pkgs/affine-block-note/commands/dedent-blocks-to-root.ts +43 -43
- package/src/_pkgs/affine-block-note/commands/dedent-blocks.ts +87 -87
- package/src/_pkgs/affine-block-note/commands/indent-block.ts +74 -74
- package/src/_pkgs/affine-block-note/commands/indent-blocks.ts +125 -125
- package/src/_pkgs/affine-block-note/commands/select-block.ts +22 -22
- package/src/_pkgs/affine-block-note/commands/select-blocks-between.ts +53 -53
- package/src/_pkgs/affine-block-note/components/edgeless-note-background.ts +182 -182
- package/src/_pkgs/affine-block-note/components/edgeless-note-border-dropdown-menu.ts +42 -42
- package/src/_pkgs/affine-block-note/components/edgeless-note-display-mode-dropdown-menu.ts +58 -58
- package/src/_pkgs/affine-block-note/components/edgeless-note-mask.ts +84 -84
- package/src/_pkgs/affine-block-note/components/edgeless-note-shadow-menu.ts +206 -206
- package/src/_pkgs/affine-block-note/components/edgeless-note-style-panel.ts +434 -434
- package/src/_pkgs/affine-block-note/components/edgeless-page-block-title.ts +46 -46
- package/src/_pkgs/affine-block-note/config.ts +20 -20
- package/src/_pkgs/affine-block-note/configs/slash-menu.ts +125 -125
- package/src/_pkgs/affine-block-note/configs/toolbar.ts +350 -350
- package/src/_pkgs/affine-block-note/configs/tooltips.ts +330 -330
- package/src/_pkgs/affine-block-note/edgeless-clipboard-config.ts +28 -28
- package/src/_pkgs/affine-block-note/move-block.ts +129 -129
- package/src/_pkgs/affine-block-note/note-block.ts +34 -34
- package/src/_pkgs/affine-block-note/note-edgeless-block.css.ts +74 -74
- package/src/_pkgs/affine-block-note/note-edgeless-block.ts +499 -499
- package/src/_pkgs/affine-block-note/note-keymap.ts +611 -611
- package/src/_pkgs/affine-block-note/quick-action.ts +66 -66
- package/src/_pkgs/affine-block-note/store.ts +36 -36
- package/src/_pkgs/affine-block-note/turbo/note-layout-handler.ts +83 -83
- package/src/_pkgs/affine-block-note/turbo/note-painter.worker.ts +49 -49
- package/src/_pkgs/affine-block-note/view.ts +47 -47
- package/src/_pkgs/affine-block-paragraph/adapters/extension.ts +13 -13
- package/src/_pkgs/affine-block-paragraph/adapters/html.ts +359 -359
- package/src/_pkgs/affine-block-paragraph/adapters/markdown.ts +200 -200
- package/src/_pkgs/affine-block-paragraph/adapters/notion-html.ts +239 -239
- package/src/_pkgs/affine-block-paragraph/adapters/plain-text.ts +28 -28
- package/src/_pkgs/affine-block-paragraph/commands/add-paragraph.ts +56 -56
- package/src/_pkgs/affine-block-paragraph/commands/append-paragraph.ts +30 -30
- package/src/_pkgs/affine-block-paragraph/commands/dedent-paragraph.ts +114 -114
- package/src/_pkgs/affine-block-paragraph/commands/indent-paragraph.ts +156 -156
- package/src/_pkgs/affine-block-paragraph/commands/split-paragraph.ts +81 -81
- package/src/_pkgs/affine-block-paragraph/heading-icon.ts +92 -92
- package/src/_pkgs/affine-block-paragraph/markdown.ts +74 -74
- package/src/_pkgs/affine-block-paragraph/paragraph-block-config.ts +9 -9
- package/src/_pkgs/affine-block-paragraph/paragraph-block.ts +369 -369
- package/src/_pkgs/affine-block-paragraph/paragraph-keymap.ts +230 -230
- package/src/_pkgs/affine-block-paragraph/store.ts +17 -17
- package/src/_pkgs/affine-block-paragraph/styles.ts +158 -158
- package/src/_pkgs/affine-block-paragraph/turbo/paragraph-layout-handler.ts +106 -106
- package/src/_pkgs/affine-block-paragraph/turbo/paragraph-painter.worker.ts +115 -115
- package/src/_pkgs/affine-block-paragraph/utils/forward-delete.ts +94 -94
- package/src/_pkgs/affine-block-paragraph/utils/merge-with-prev.ts +184 -184
- package/src/_pkgs/affine-block-paragraph/view.ts +66 -66
- package/src/_pkgs/affine-block-root/adapters/extension.ts +11 -11
- package/src/_pkgs/affine-block-root/adapters/html.ts +135 -135
- package/src/_pkgs/affine-block-root/adapters/markdown.ts +36 -36
- package/src/_pkgs/affine-block-root/adapters/notion-html.ts +28 -28
- package/src/_pkgs/affine-block-root/clipboard/page-clipboard.ts +176 -176
- package/src/_pkgs/affine-block-root/clipboard/readonly-clipboard.ts +71 -71
- package/src/_pkgs/affine-block-root/configs/toolbar.ts +398 -398
- package/src/_pkgs/affine-block-root/edgeless/clipboard/canvas.ts +117 -117
- package/src/_pkgs/affine-block-root/edgeless/clipboard/clipboard.ts +715 -715
- package/src/_pkgs/affine-block-root/edgeless/clipboard/command.ts +218 -218
- package/src/_pkgs/affine-block-root/edgeless/clipboard/utils.ts +140 -140
- package/src/_pkgs/affine-block-root/edgeless/configs/toolbar/alignment.ts +293 -293
- package/src/_pkgs/affine-block-root/edgeless/configs/toolbar/index.ts +19 -19
- package/src/_pkgs/affine-block-root/edgeless/configs/toolbar/misc.ts +369 -369
- package/src/_pkgs/affine-block-root/edgeless/configs/toolbar/more.ts +435 -435
- package/src/_pkgs/affine-block-root/edgeless/configs/toolbar/render-linked-doc.ts +103 -96
- package/src/_pkgs/affine-block-root/edgeless/configs/toolbar/utils.ts +17 -17
- package/src/_pkgs/affine-block-root/edgeless/edgeless-keyboard.ts +753 -753
- package/src/_pkgs/affine-block-root/edgeless/edgeless-root-block.ts +524 -524
- package/src/_pkgs/affine-block-root/edgeless/edgeless-root-service.ts +231 -231
- package/src/_pkgs/affine-block-root/edgeless/edgeless-root-spec.ts +11 -11
- package/src/_pkgs/affine-block-root/edgeless/index.ts +9 -9
- package/src/_pkgs/affine-block-root/edgeless/interact-extensions/clone-ext.ts +32 -32
- package/src/_pkgs/affine-block-root/edgeless/utils/clipboard-utils.ts +97 -97
- package/src/_pkgs/affine-block-root/edgeless/utils/clone-utils.ts +237 -237
- package/src/_pkgs/affine-block-root/edgeless/utils/connector.ts +34 -34
- package/src/_pkgs/affine-block-root/edgeless/utils/crud.ts +37 -37
- package/src/_pkgs/affine-block-root/edgeless/utils/query.ts +104 -104
- package/src/_pkgs/affine-block-root/keyboard/keyboard-manager.ts +163 -163
- package/src/_pkgs/affine-block-root/keyboard/keymap.ts +16 -16
- package/src/_pkgs/affine-block-root/page/page-root-block.ts +422 -422
- package/src/_pkgs/affine-block-root/preview/edgeless-root-preview-block.ts +262 -262
- package/src/_pkgs/affine-block-root/preview/preview-root-block.ts +41 -41
- package/src/_pkgs/affine-block-root/store.ts +17 -17
- package/src/_pkgs/affine-block-root/view.ts +93 -93
- package/src/_pkgs/affine-block-surface/adapters/html-adapter/html.ts +20 -20
- package/src/_pkgs/affine-block-surface/adapters/markdown/element-adapter/index.ts +33 -33
- package/src/_pkgs/affine-block-surface/adapters/markdown/element-adapter/type.ts +29 -29
- package/src/_pkgs/affine-block-surface/adapters/markdown/markdown.ts +76 -76
- package/src/_pkgs/affine-block-surface/adapters/plain-text/element-adapter/index.ts +32 -32
- package/src/_pkgs/affine-block-surface/adapters/plain-text/element-adapter/type.ts +29 -29
- package/src/_pkgs/affine-block-surface/adapters/plain-text/plain-text.ts +77 -77
- package/src/_pkgs/affine-block-surface/adapters/type.ts +30 -30
- package/src/_pkgs/affine-block-surface/commands/auto-align.ts +157 -157
- package/src/_pkgs/affine-block-surface/commands/reassociate-connectors.ts +46 -46
- package/src/_pkgs/affine-block-surface/element-model/base.ts +4 -4
- package/src/_pkgs/affine-block-surface/element-model/index.ts +96 -96
- package/src/_pkgs/affine-block-surface/extensions/clipboard-config.ts +80 -80
- package/src/_pkgs/affine-block-surface/extensions/crud-extension.ts +181 -181
- package/src/_pkgs/affine-block-surface/extensions/dom-element-renderer.ts +30 -30
- package/src/_pkgs/affine-block-surface/extensions/edit-props-middleware-builder.ts +26 -26
- package/src/_pkgs/affine-block-surface/extensions/element-renderer.ts +31 -31
- package/src/_pkgs/affine-block-surface/extensions/export-manager/export-manager.ts +559 -559
- package/src/_pkgs/affine-block-surface/extensions/legacy-slot-extension.ts +39 -39
- package/src/_pkgs/affine-block-surface/extensions/query.ts +15 -15
- package/src/_pkgs/affine-block-surface/extensions/surface-middleware.ts +23 -23
- package/src/_pkgs/affine-block-surface/renderer/canvas-renderer.ts +472 -472
- package/src/_pkgs/affine-block-surface/renderer/dom-elements/index.ts +31 -31
- package/src/_pkgs/affine-block-surface/renderer/dom-renderer.ts +710 -710
- package/src/_pkgs/affine-block-surface/renderer/elements/index.ts +23 -23
- package/src/_pkgs/affine-block-surface/renderer/elements/type.ts +6 -6
- package/src/_pkgs/affine-block-surface/renderer/overlay.ts +57 -57
- package/src/_pkgs/affine-block-surface/renderer/tool-overlay.ts +44 -44
- package/src/_pkgs/affine-block-surface/store.ts +17 -17
- package/src/_pkgs/affine-block-surface/surface-block-void.ts +16 -16
- package/src/_pkgs/affine-block-surface/surface-block.ts +255 -255
- package/src/_pkgs/affine-block-surface/surface-model.ts +69 -69
- package/src/_pkgs/affine-block-surface/surface-transformer.ts +115 -115
- package/src/_pkgs/affine-block-surface/tool/default-tool.ts +374 -374
- package/src/_pkgs/affine-block-surface/tool/panning-utils.ts +46 -46
- package/src/_pkgs/affine-block-surface/utils/a-star.ts +299 -299
- package/src/_pkgs/affine-block-surface/utils/font.ts +47 -47
- package/src/_pkgs/affine-block-surface/utils/get-bg-grip-gap.ts +10 -10
- package/src/_pkgs/affine-block-surface/utils/get-last-props-key.ts +29 -29
- package/src/_pkgs/affine-block-surface/utils/get-surface-block.ts +16 -16
- package/src/_pkgs/affine-block-surface/utils/graph.ts +151 -151
- package/src/_pkgs/affine-block-surface/utils/update-xywh.ts +82 -82
- package/src/_pkgs/affine-block-surface/view.ts +45 -45
- package/src/_pkgs/affine-block-surface-ref/commands.ts +60 -60
- package/src/_pkgs/affine-block-surface-ref/components/placeholder.ts +131 -131
- package/src/_pkgs/affine-block-surface-ref/components/surface-ref-toolbar-title.ts +76 -76
- package/src/_pkgs/affine-block-surface-ref/configs/slash-menu.ts +164 -164
- package/src/_pkgs/affine-block-surface-ref/configs/toolbar.ts +100 -100
- package/src/_pkgs/affine-block-surface-ref/portal/generic-block.ts +82 -82
- package/src/_pkgs/affine-block-surface-ref/portal/note.ts +169 -169
- package/src/_pkgs/affine-block-surface-ref/store.ts +14 -14
- package/src/_pkgs/affine-block-surface-ref/surface-ref-block-edgeless.ts +80 -80
- package/src/_pkgs/affine-block-surface-ref/surface-ref-block.ts +511 -511
- package/src/_pkgs/affine-block-surface-ref/utils.ts +152 -152
- package/src/_pkgs/affine-block-surface-ref/view.ts +49 -49
- package/src/_pkgs/affine-block-table/adapters/extension.ts +13 -13
- package/src/_pkgs/affine-block-table/adapters/html.ts +129 -129
- package/src/_pkgs/affine-block-table/adapters/markdown.ts +82 -82
- package/src/_pkgs/affine-block-table/adapters/notion-html.ts +21 -21
- package/src/_pkgs/affine-block-table/adapters/plain-text.ts +79 -79
- package/src/_pkgs/affine-block-table/adapters/utils.ts +212 -212
- package/src/_pkgs/affine-block-table/add-button-css.ts +99 -99
- package/src/_pkgs/affine-block-table/add-button.ts +330 -330
- package/src/_pkgs/affine-block-table/color.ts +45 -45
- package/src/_pkgs/affine-block-table/commands.ts +52 -52
- package/src/_pkgs/affine-block-table/configs/slash-menu.ts +44 -44
- package/src/_pkgs/affine-block-table/selection-controller.ts +527 -527
- package/src/_pkgs/affine-block-table/selection-layer.ts +112 -112
- package/src/_pkgs/affine-block-table/selection-schema.ts +112 -112
- package/src/_pkgs/affine-block-table/store.ts +19 -19
- package/src/_pkgs/affine-block-table/table-block.ts +209 -209
- package/src/_pkgs/affine-block-table/table-cell-css.ts +154 -154
- package/src/_pkgs/affine-block-table/table-cell.ts +866 -866
- package/src/_pkgs/affine-block-table/table-data-manager.ts +382 -382
- package/src/_pkgs/affine-block-table/view.ts +29 -29
- package/src/_pkgs/affine-components/block-selection/index.ts +69 -69
- package/src/_pkgs/affine-components/block-zero-width/index.ts +59 -59
- package/src/_pkgs/affine-components/caption/block-caption.ts +188 -188
- package/src/_pkgs/affine-components/caption/captioned-block-component.ts +82 -82
- package/src/_pkgs/affine-components/card-style-dropdown-menu/dropdown-menu.ts +118 -118
- package/src/_pkgs/affine-components/citation/citation.ts +167 -167
- package/src/_pkgs/affine-components/color-picker/button.ts +207 -207
- package/src/_pkgs/affine-components/color-picker/color-panel.ts +260 -260
- package/src/_pkgs/affine-components/color-picker/color-picker.ts +677 -677
- package/src/_pkgs/affine-components/color-picker/icons.ts +71 -71
- package/src/_pkgs/affine-components/color-picker/styles.ts +308 -308
- package/src/_pkgs/affine-components/color-picker/types.ts +53 -53
- package/src/_pkgs/affine-components/color-picker/utils.ts +368 -368
- package/src/_pkgs/affine-components/context-menu/button.ts +302 -302
- package/src/_pkgs/affine-components/context-menu/group.ts +35 -35
- package/src/_pkgs/affine-components/context-menu/input.ts +254 -254
- package/src/_pkgs/affine-components/context-menu/item.ts +12 -12
- package/src/_pkgs/affine-components/context-menu/menu-renderer.ts +574 -574
- package/src/_pkgs/affine-components/context-menu/menu.ts +170 -170
- package/src/_pkgs/affine-components/context-menu/sub-menu.ts +194 -194
- package/src/_pkgs/affine-components/date-picker/date-picker.ts +626 -626
- package/src/_pkgs/affine-components/drop-indicator/drop-indicator.ts +51 -51
- package/src/_pkgs/affine-components/drop-indicator/file-drop-manager.ts +300 -300
- package/src/_pkgs/affine-components/edgeless-line-styles-panel/line-styles-panel.ts +113 -113
- package/src/_pkgs/affine-components/edgeless-line-width-panel/line-width-panel.ts +50 -50
- package/src/_pkgs/affine-components/edgeless-shape-color-picker/color-picker.ts +318 -318
- package/src/_pkgs/affine-components/embed-card-modal/embed-card-create-modal.ts +218 -218
- package/src/_pkgs/affine-components/embed-card-modal/embed-card-edit-modal.ts +468 -468
- package/src/_pkgs/affine-components/embed-card-modal/styles.ts +131 -131
- package/src/_pkgs/affine-components/filterable-list/index.ts +259 -259
- package/src/_pkgs/affine-components/filterable-list/styles.ts +109 -109
- package/src/_pkgs/affine-components/highlight-dropdown-menu/dropdown-menu.ts +123 -123
- package/src/_pkgs/affine-components/hover/controller.ts +201 -201
- package/src/_pkgs/affine-components/hover/middlewares/basic.ts +79 -79
- package/src/_pkgs/affine-components/link-preview/link.ts +65 -65
- package/src/_pkgs/affine-components/linked-doc-title/doc-title.ts +61 -61
- package/src/_pkgs/affine-components/notification/linked-doc.ts +45 -45
- package/src/_pkgs/affine-components/open-doc-dropdown-menu/dropdown-menu.ts +131 -131
- package/src/_pkgs/affine-components/peek/commands.ts +47 -47
- package/src/_pkgs/affine-components/peek/peekable.ts +137 -137
- package/src/_pkgs/affine-components/peek/service.ts +16 -16
- package/src/_pkgs/affine-components/peek/type.ts +70 -70
- package/src/_pkgs/affine-components/portal/helper.ts +225 -225
- package/src/_pkgs/affine-components/resource/resource.ts +230 -230
- package/src/_pkgs/affine-components/resource/status.ts +165 -165
- package/src/_pkgs/affine-components/size-dropdown-menu/dropdown-menu.ts +211 -211
- package/src/_pkgs/affine-components/slider/slider.ts +159 -159
- package/src/_pkgs/affine-components/slider/styles.ts +79 -79
- package/src/_pkgs/affine-components/smooth-corner/index.ts +184 -184
- package/src/_pkgs/affine-components/toast/create.ts +39 -39
- package/src/_pkgs/affine-components/toast/toast.ts +80 -80
- package/src/_pkgs/affine-components/toggle-button/toggle-button.ts +97 -97
- package/src/_pkgs/affine-components/toggle-switch/index.ts +88 -88
- package/src/_pkgs/affine-components/toolbar/config.ts +7 -7
- package/src/_pkgs/affine-components/toolbar/icon-button.ts +220 -220
- package/src/_pkgs/affine-components/toolbar/menu-button.ts +242 -242
- package/src/_pkgs/affine-components/toolbar/menu-context.ts +30 -30
- package/src/_pkgs/affine-components/toolbar/toolbar.ts +52 -52
- package/src/_pkgs/affine-components/toolbar/tooltip.ts +328 -328
- package/src/_pkgs/affine-components/toolbar/utils.ts +120 -120
- package/src/_pkgs/affine-components/view-dropdown-menu/dropdown-menu.ts +86 -86
- package/src/_pkgs/affine-ext-loader/base-provider.ts +69 -69
- package/src/_pkgs/affine-ext-loader/manager.ts +146 -146
- package/src/_pkgs/affine-ext-loader/store-manager.ts +47 -47
- package/src/_pkgs/affine-ext-loader/view-manager.ts +49 -49
- package/src/_pkgs/affine-foundation/clipboard.ts +65 -65
- package/src/_pkgs/affine-foundation/effects.ts +70 -70
- package/src/_pkgs/affine-foundation/store.ts +54 -54
- package/src/_pkgs/affine-foundation/view.ts +108 -108
- package/src/_pkgs/affine-fragment-adapter-panel/adapter-panel.ts +177 -177
- package/src/_pkgs/affine-fragment-adapter-panel/body/adapter-panel-body.ts +216 -216
- package/src/_pkgs/affine-fragment-adapter-panel/config.ts +28 -28
- package/src/_pkgs/affine-fragment-adapter-panel/header/adapter-menu.ts +86 -86
- package/src/_pkgs/affine-fragment-adapter-panel/header/adapter-panel-header.ts +119 -119
- package/src/_pkgs/affine-fragment-adapter-panel/view.ts +12 -12
- package/src/_pkgs/affine-fragment-doc-title/doc-title.ts +241 -241
- package/src/_pkgs/affine-fragment-doc-title/utils.ts +11 -11
- package/src/_pkgs/affine-fragment-doc-title/view.ts +12 -12
- package/src/_pkgs/affine-fragment-frame-panel/body/frame-panel-body.ts +436 -436
- package/src/_pkgs/affine-fragment-frame-panel/card/frame-card-title-editor.ts +126 -126
- package/src/_pkgs/affine-fragment-frame-panel/card/frame-card-title.ts +151 -151
- package/src/_pkgs/affine-fragment-frame-panel/card/frame-card.ts +254 -254
- package/src/_pkgs/affine-fragment-frame-panel/card/frame-preview.ts +263 -263
- package/src/_pkgs/affine-fragment-frame-panel/frame-panel.ts +92 -92
- package/src/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.ts +248 -248
- package/src/_pkgs/affine-fragment-frame-panel/header/frames-setting-menu.ts +219 -219
- package/src/_pkgs/affine-fragment-frame-panel/utils/drag.ts +156 -156
- package/src/_pkgs/affine-fragment-frame-panel/view.ts +12 -12
- package/src/_pkgs/affine-fragment-outline/body/outline-notice.ts +94 -94
- package/src/_pkgs/affine-fragment-outline/body/outline-panel-body.ts +481 -481
- package/src/_pkgs/affine-fragment-outline/card/outline-card.ts +278 -278
- package/src/_pkgs/affine-fragment-outline/card/outline-preview.ts +228 -228
- package/src/_pkgs/affine-fragment-outline/config.ts +97 -97
- package/src/_pkgs/affine-fragment-outline/header/outline-panel-header.ts +90 -90
- package/src/_pkgs/affine-fragment-outline/header/outline-setting-menu.ts +47 -47
- package/src/_pkgs/affine-fragment-outline/mobile-outline-panel.ts +197 -197
- package/src/_pkgs/affine-fragment-outline/outline-panel.ts +118 -118
- package/src/_pkgs/affine-fragment-outline/outline-viewer.ts +325 -325
- package/src/_pkgs/affine-fragment-outline/utils/custom-events.ts +27 -27
- package/src/_pkgs/affine-fragment-outline/utils/query.ts +72 -72
- package/src/_pkgs/affine-fragment-outline/utils/scroll.ts +201 -201
- package/src/_pkgs/affine-fragment-outline/view.ts +12 -12
- package/src/_pkgs/affine-gfx-brush/adapter/markdown/index.ts +18 -18
- package/src/_pkgs/affine-gfx-brush/adapter/plain-text/index.ts +11 -11
- package/src/_pkgs/affine-gfx-brush/brush-tool.ts +200 -200
- package/src/_pkgs/affine-gfx-brush/element-renderer.ts +32 -32
- package/src/_pkgs/affine-gfx-brush/eraser-tool.ts +158 -158
- package/src/_pkgs/affine-gfx-brush/highlighter-tool.ts +179 -179
- package/src/_pkgs/affine-gfx-brush/store.ts +19 -19
- package/src/_pkgs/affine-gfx-brush/toolbar/components/eraser/eraser-tool-button.ts +75 -75
- package/src/_pkgs/affine-gfx-brush/toolbar/components/pen/pen-menu.ts +215 -215
- package/src/_pkgs/affine-gfx-brush/toolbar/components/pen/pen-tool-button.ts +195 -195
- package/src/_pkgs/affine-gfx-brush/toolbar/configs/brush.ts +120 -120
- package/src/_pkgs/affine-gfx-brush/toolbar/configs/highlighter.ts +139 -139
- package/src/_pkgs/affine-gfx-brush/toolbar/senior-tool.ts +15 -15
- package/src/_pkgs/affine-gfx-brush/view.ts +39 -39
- package/src/_pkgs/affine-gfx-connector/adapter/markdown/index.ts +26 -26
- package/src/_pkgs/affine-gfx-connector/adapter/plain-text/index.ts +14 -14
- package/src/_pkgs/affine-gfx-connector/adapter/text.ts +23 -23
- package/src/_pkgs/affine-gfx-connector/components/connector-handle.ts +263 -263
- package/src/_pkgs/affine-gfx-connector/connector-manager.ts +1858 -1858
- package/src/_pkgs/affine-gfx-connector/connector-tool.ts +279 -279
- package/src/_pkgs/affine-gfx-connector/connector-watcher.ts +190 -190
- package/src/_pkgs/affine-gfx-connector/element-renderer/connector-dom/index.ts +367 -367
- package/src/_pkgs/affine-gfx-connector/element-renderer/connector-dom.ts +11 -11
- package/src/_pkgs/affine-gfx-connector/element-renderer/index.ts +315 -315
- package/src/_pkgs/affine-gfx-connector/element-renderer/utils.ts +327 -327
- package/src/_pkgs/affine-gfx-connector/element-transform/connector-filter.ts +44 -44
- package/src/_pkgs/affine-gfx-connector/store.ts +21 -21
- package/src/_pkgs/affine-gfx-connector/text/edgeless-connector-label-editor.ts +394 -394
- package/src/_pkgs/affine-gfx-connector/text/text.ts +66 -66
- package/src/_pkgs/affine-gfx-connector/toolbar/config.ts +436 -436
- package/src/_pkgs/affine-gfx-connector/toolbar/connector-dense-menu.ts +58 -58
- package/src/_pkgs/affine-gfx-connector/toolbar/connector-menu.ts +153 -153
- package/src/_pkgs/affine-gfx-connector/toolbar/connector-tool-button.ts +79 -79
- package/src/_pkgs/affine-gfx-connector/toolbar/quick-tool.ts +15 -15
- package/src/_pkgs/affine-gfx-connector/view/view.ts +256 -256
- package/src/_pkgs/affine-gfx-connector/view.ts +38 -38
- package/src/_pkgs/affine-gfx-group/adapter/markdown/index.ts +25 -25
- package/src/_pkgs/affine-gfx-group/adapter/plain-text/index.ts +14 -14
- package/src/_pkgs/affine-gfx-group/adapter/text.ts +21 -21
- package/src/_pkgs/affine-gfx-group/command/group-api.ts +134 -134
- package/src/_pkgs/affine-gfx-group/element-renderer/consts.ts +6 -6
- package/src/_pkgs/affine-gfx-group/element-renderer/index.ts +67 -67
- package/src/_pkgs/affine-gfx-group/element-renderer/utils.ts +77 -77
- package/src/_pkgs/affine-gfx-group/element-view.ts +57 -57
- package/src/_pkgs/affine-gfx-group/group-watcher.ts +36 -36
- package/src/_pkgs/affine-gfx-group/interaction-ext.ts +45 -45
- package/src/_pkgs/affine-gfx-group/store.ts +21 -21
- package/src/_pkgs/affine-gfx-group/text/edgeless-group-title-editor.ts +189 -189
- package/src/_pkgs/affine-gfx-group/text/text.ts +33 -33
- package/src/_pkgs/affine-gfx-group/toolbar/config.ts +106 -106
- package/src/_pkgs/affine-gfx-group/view.ts +30 -30
- package/src/_pkgs/affine-gfx-link/link-tool.ts +13 -13
- package/src/_pkgs/affine-gfx-link/toolbar/link-dense-menu.ts +32 -32
- package/src/_pkgs/affine-gfx-link/toolbar/link-tool-button.ts +96 -96
- package/src/_pkgs/affine-gfx-link/view.ts +23 -23
- package/src/_pkgs/affine-gfx-mindmap/adapter/markdown/index.ts +69 -69
- package/src/_pkgs/affine-gfx-mindmap/adapter/plain-text/index.ts +13 -13
- package/src/_pkgs/affine-gfx-mindmap/adapter/utils.ts +65 -65
- package/src/_pkgs/affine-gfx-mindmap/element-renderer.ts +81 -81
- package/src/_pkgs/affine-gfx-mindmap/indicator-overlay/index.ts +301 -301
- package/src/_pkgs/affine-gfx-mindmap/interactivity/drag-utils.ts +190 -190
- package/src/_pkgs/affine-gfx-mindmap/interactivity/mind-map-drag.ts +465 -465
- package/src/_pkgs/affine-gfx-mindmap/store.ts +19 -19
- package/src/_pkgs/affine-gfx-mindmap/toolbar/assets.ts +46 -46
- package/src/_pkgs/affine-gfx-mindmap/toolbar/basket-elements.ts +206 -206
- package/src/_pkgs/affine-gfx-mindmap/toolbar/config.ts +199 -199
- package/src/_pkgs/affine-gfx-mindmap/toolbar/mindmap-importing-placeholder.ts +54 -54
- package/src/_pkgs/affine-gfx-mindmap/toolbar/mindmap-menu.ts +415 -415
- package/src/_pkgs/affine-gfx-mindmap/toolbar/mindmap-tool-button.ts +466 -466
- package/src/_pkgs/affine-gfx-mindmap/toolbar/senior-tool.ts +15 -15
- package/src/_pkgs/affine-gfx-mindmap/toolbar/utils/import-mindmap.ts +143 -143
- package/src/_pkgs/affine-gfx-mindmap/utils/index.ts +70 -70
- package/src/_pkgs/affine-gfx-mindmap/view/layout.ts +201 -201
- package/src/_pkgs/affine-gfx-mindmap/view/utils.ts +692 -692
- package/src/_pkgs/affine-gfx-mindmap/view/view.ts +378 -378
- package/src/_pkgs/affine-gfx-mindmap/view.ts +36 -36
- package/src/_pkgs/affine-gfx-note/components/note-display-mode-panel.ts +104 -104
- package/src/_pkgs/affine-gfx-note/components/note-shadow-panel.ts +144 -144
- package/src/_pkgs/affine-gfx-note/note-tool.ts +330 -330
- package/src/_pkgs/affine-gfx-note/overlay/overlay.ts +161 -161
- package/src/_pkgs/affine-gfx-note/toolbar/note-menu-config.ts +151 -151
- package/src/_pkgs/affine-gfx-note/toolbar/note-menu.ts +210 -210
- package/src/_pkgs/affine-gfx-note/toolbar/note-senior-button.ts +218 -218
- package/src/_pkgs/affine-gfx-note/toolbar/note-tool-button.ts +120 -120
- package/src/_pkgs/affine-gfx-note/toolbar/senior-tool.ts +11 -11
- package/src/_pkgs/affine-gfx-note/view.ts +23 -23
- package/src/_pkgs/affine-gfx-pointer/quick-tool/default-tool-button.ts +105 -105
- package/src/_pkgs/affine-gfx-pointer/quick-tool/quick-tool.ts +12 -12
- package/src/_pkgs/affine-gfx-pointer/snap/snap-manager.ts +139 -139
- package/src/_pkgs/affine-gfx-pointer/snap/snap-overlay.ts +816 -816
- package/src/_pkgs/affine-gfx-pointer/tools/empty-tool.ts +8 -8
- package/src/_pkgs/affine-gfx-pointer/tools/pan-tool.ts +110 -110
- package/src/_pkgs/affine-gfx-pointer/view.ts +30 -30
- package/src/_pkgs/affine-gfx-shape/adapter/markdown/index.ts +46 -46
- package/src/_pkgs/affine-gfx-shape/adapter/plain-text/index.ts +35 -35
- package/src/_pkgs/affine-gfx-shape/adapter/utils.ts +36 -36
- package/src/_pkgs/affine-gfx-shape/components/shape-panel.ts +65 -65
- package/src/_pkgs/affine-gfx-shape/components/shape-style-panel.ts +59 -59
- package/src/_pkgs/affine-gfx-shape/consts.ts +19 -19
- package/src/_pkgs/affine-gfx-shape/draggable/shape-draggable.ts +367 -367
- package/src/_pkgs/affine-gfx-shape/draggable/shape-menu.ts +212 -212
- package/src/_pkgs/affine-gfx-shape/draggable/shape-tool-button.ts +99 -99
- package/src/_pkgs/affine-gfx-shape/draggable/shape-tool-element.ts +326 -326
- package/src/_pkgs/affine-gfx-shape/draggable/utils.ts +150 -150
- package/src/_pkgs/affine-gfx-shape/element-renderer/highlighter.ts +41 -41
- package/src/_pkgs/affine-gfx-shape/element-renderer/shape/diamond.ts +66 -66
- package/src/_pkgs/affine-gfx-shape/element-renderer/shape/ellipse.ts +59 -59
- package/src/_pkgs/affine-gfx-shape/element-renderer/shape/index.ts +185 -185
- package/src/_pkgs/affine-gfx-shape/element-renderer/shape/polygon.ts +134 -134
- package/src/_pkgs/affine-gfx-shape/element-renderer/shape/rect.ts +98 -98
- package/src/_pkgs/affine-gfx-shape/element-renderer/shape/triangle.ts +65 -65
- package/src/_pkgs/affine-gfx-shape/element-renderer/shape/utils.ts +362 -362
- package/src/_pkgs/affine-gfx-shape/element-renderer/shape-dom/index.ts +228 -228
- package/src/_pkgs/affine-gfx-shape/element-renderer/shape-dom/utils.ts +59 -59
- package/src/_pkgs/affine-gfx-shape/element-renderer/shape-dom.ts +11 -11
- package/src/_pkgs/affine-gfx-shape/element-view.ts +612 -612
- package/src/_pkgs/affine-gfx-shape/overlay/diamond.ts +23 -23
- package/src/_pkgs/affine-gfx-shape/overlay/ellipse.ts +15 -15
- package/src/_pkgs/affine-gfx-shape/overlay/factory.ts +37 -37
- package/src/_pkgs/affine-gfx-shape/overlay/polygon-drawing-overlay.ts +195 -195
- package/src/_pkgs/affine-gfx-shape/overlay/polygon-vertex-editing-overlay.ts +1213 -1213
- package/src/_pkgs/affine-gfx-shape/overlay/polygon.ts +28 -28
- package/src/_pkgs/affine-gfx-shape/overlay/rect.ts +15 -15
- package/src/_pkgs/affine-gfx-shape/overlay/rounded-rect.ts +32 -32
- package/src/_pkgs/affine-gfx-shape/overlay/shape-overlay.ts +110 -110
- package/src/_pkgs/affine-gfx-shape/overlay/shape.ts +27 -27
- package/src/_pkgs/affine-gfx-shape/overlay/triangle.ts +22 -22
- package/src/_pkgs/affine-gfx-shape/overlay/utils.ts +59 -59
- package/src/_pkgs/affine-gfx-shape/polygon-tool.ts +430 -430
- package/src/_pkgs/affine-gfx-shape/shape-tool.ts +368 -368
- package/src/_pkgs/affine-gfx-shape/store.ts +19 -19
- package/src/_pkgs/affine-gfx-shape/text/edgeless-shape-text-editor.ts +411 -411
- package/src/_pkgs/affine-gfx-shape/toolbar/config.ts +361 -361
- package/src/_pkgs/affine-gfx-shape/toolbar/senior-tool.ts +15 -15
- package/src/_pkgs/affine-gfx-shape/toolbar/shape-menu-config.ts +81 -81
- package/src/_pkgs/affine-gfx-shape/view.ts +39 -39
- package/src/_pkgs/affine-gfx-template/services/template-middlewares.ts +344 -344
- package/src/_pkgs/affine-gfx-template/services/template.ts +432 -432
- package/src/_pkgs/affine-gfx-template/template-tool.ts +5 -5
- package/src/_pkgs/affine-gfx-template/toolbar/overlay-scrollbar.ts +174 -174
- package/src/_pkgs/affine-gfx-template/toolbar/template-panel.ts +517 -517
- package/src/_pkgs/affine-gfx-template/toolbar/template-tool-button.ts +225 -225
- package/src/_pkgs/affine-gfx-template/toolbar/utils.ts +33 -33
- package/src/_pkgs/affine-gfx-template/view.ts +25 -25
- package/src/_pkgs/affine-gfx-text/adapter/markdown/index.ts +24 -24
- package/src/_pkgs/affine-gfx-text/adapter/plain-text/index.ts +14 -14
- package/src/_pkgs/affine-gfx-text/adapter/text.ts +22 -22
- package/src/_pkgs/affine-gfx-text/commands/insert-edgeless-text.ts +114 -114
- package/src/_pkgs/affine-gfx-text/dblclick-add-edgeless-text.ts +52 -52
- package/src/_pkgs/affine-gfx-text/edgeless-text-editor.ts +487 -487
- package/src/_pkgs/affine-gfx-text/element-renderer/index.ts +94 -94
- package/src/_pkgs/affine-gfx-text/element-renderer/utils.ts +559 -559
- package/src/_pkgs/affine-gfx-text/element-view.ts +95 -95
- package/src/_pkgs/affine-gfx-text/store.ts +19 -19
- package/src/_pkgs/affine-gfx-text/tool.ts +66 -66
- package/src/_pkgs/affine-gfx-text/toolbar/actions.ts +396 -396
- package/src/_pkgs/affine-gfx-text/toolbar/config.ts +56 -56
- package/src/_pkgs/affine-gfx-text/toolbar/text-menu.ts +49 -49
- package/src/_pkgs/affine-gfx-text/view.ts +32 -32
- package/src/_pkgs/affine-gfx-turbo-renderer/layout/block-layout-provider.ts +29 -29
- package/src/_pkgs/affine-gfx-turbo-renderer/painter/painter.worker.ts +129 -129
- package/src/_pkgs/affine-gfx-turbo-renderer/renderer-utils.ts +222 -222
- package/src/_pkgs/affine-gfx-turbo-renderer/turbo-renderer.ts +431 -431
- package/src/_pkgs/affine-inline-comment/inline-comment-manager.ts +218 -218
- package/src/_pkgs/affine-inline-comment/inline-comment.ts +97 -97
- package/src/_pkgs/affine-inline-comment/inline-spec.ts +38 -38
- package/src/_pkgs/affine-inline-comment/utils.ts +64 -64
- package/src/_pkgs/affine-inline-comment/view.ts +22 -22
- package/src/_pkgs/affine-inline-footnote/adapters/markdown/inline-delta.ts +50 -50
- package/src/_pkgs/affine-inline-footnote/adapters/markdown/markdown-inline.ts +57 -57
- package/src/_pkgs/affine-inline-footnote/adapters/markdown/preprocessor.ts +54 -54
- package/src/_pkgs/affine-inline-footnote/footnote-node/footnote-config.ts +120 -120
- package/src/_pkgs/affine-inline-footnote/footnote-node/footnote-node.ts +279 -279
- package/src/_pkgs/affine-inline-footnote/footnote-node/footnote-popup-chip.ts +74 -74
- package/src/_pkgs/affine-inline-footnote/footnote-node/footnote-popup.ts +223 -223
- package/src/_pkgs/affine-inline-footnote/inline-spec.ts +32 -32
- package/src/_pkgs/affine-inline-footnote/store.ts +21 -21
- package/src/_pkgs/affine-inline-footnote/view.ts +21 -21
- package/src/_pkgs/affine-inline-latex/adapters/markdown/inline-delta.ts +21 -21
- package/src/_pkgs/affine-inline-latex/adapters/markdown/markdown-inline.ts +12 -12
- package/src/_pkgs/affine-inline-latex/adapters/plain-text/inline-delta.ts +21 -21
- package/src/_pkgs/affine-inline-latex/command.ts +74 -74
- package/src/_pkgs/affine-inline-latex/index.ts +9 -9
- package/src/_pkgs/affine-inline-latex/inline-spec.ts +40 -40
- package/src/_pkgs/affine-inline-latex/latex-node/latex-editor-menu.ts +210 -210
- package/src/_pkgs/affine-inline-latex/latex-node/latex-editor-unit.ts +55 -55
- package/src/_pkgs/affine-inline-latex/latex-node/latex-node.ts +265 -265
- package/src/_pkgs/affine-inline-latex/markdown.ts +180 -180
- package/src/_pkgs/affine-inline-latex/store.ts +21 -21
- package/src/_pkgs/affine-inline-latex/view.ts +29 -29
- package/src/_pkgs/affine-inline-link/adapters/html/html-inline.ts +70 -70
- package/src/_pkgs/affine-inline-link/adapters/html/inline-delta.ts +25 -25
- package/src/_pkgs/affine-inline-link/adapters/markdown/inline-delta.ts +36 -36
- package/src/_pkgs/affine-inline-link/adapters/markdown/markdown-inline.ts +52 -52
- package/src/_pkgs/affine-inline-link/adapters/notion-html/html-inline.ts +52 -52
- package/src/_pkgs/affine-inline-link/adapters/plain-text/inline-delta.ts +25 -25
- package/src/_pkgs/affine-inline-link/command.ts +42 -42
- package/src/_pkgs/affine-inline-link/inline-spec.ts +22 -22
- package/src/_pkgs/affine-inline-link/link-node/affine-link.ts +188 -188
- package/src/_pkgs/affine-inline-link/link-node/configs/toolbar.ts +365 -365
- package/src/_pkgs/affine-inline-link/link-node/link-popup/link-popup.ts +335 -335
- package/src/_pkgs/affine-inline-link/link-node/link-popup/styles.ts +162 -162
- package/src/_pkgs/affine-inline-link/link-node/link-popup/toggle-link-popup.ts +27 -27
- package/src/_pkgs/affine-inline-link/markdown.ts +53 -53
- package/src/_pkgs/affine-inline-link/store.ts +27 -27
- package/src/_pkgs/affine-inline-link/toolbar.ts +9 -9
- package/src/_pkgs/affine-inline-link/view.ts +23 -23
- package/src/_pkgs/affine-inline-mention/affine-mention.ts +150 -150
- package/src/_pkgs/affine-inline-mention/inline-spec.ts +34 -34
- package/src/_pkgs/affine-inline-mention/view.ts +21 -21
- package/src/_pkgs/affine-inline-preset/adapters/extensions.ts +21 -21
- package/src/_pkgs/affine-inline-preset/adapters/html/html-inline.ts +311 -311
- package/src/_pkgs/affine-inline-preset/adapters/html/inline-delta.ts +154 -154
- package/src/_pkgs/affine-inline-preset/adapters/markdown/inline-delta.ts +57 -57
- package/src/_pkgs/affine-inline-preset/adapters/markdown/markdown-inline.ts +98 -98
- package/src/_pkgs/affine-inline-preset/adapters/notion-html/html-inline.ts +256 -256
- package/src/_pkgs/affine-inline-preset/command/config.ts +138 -138
- package/src/_pkgs/affine-inline-preset/command/consts.ts +19 -19
- package/src/_pkgs/affine-inline-preset/command/delete-text.ts +81 -81
- package/src/_pkgs/affine-inline-preset/command/format-block.ts +75 -75
- package/src/_pkgs/affine-inline-preset/command/format-native.ts +53 -53
- package/src/_pkgs/affine-inline-preset/command/format-text.ts +94 -94
- package/src/_pkgs/affine-inline-preset/command/text-style.ts +110 -110
- package/src/_pkgs/affine-inline-preset/command/utils.ts +226 -226
- package/src/_pkgs/affine-inline-preset/default-inline-manager.ts +38 -38
- package/src/_pkgs/affine-inline-preset/index.ts +10 -10
- package/src/_pkgs/affine-inline-preset/inline-spec.ts +118 -118
- package/src/_pkgs/affine-inline-preset/keymap/basic.ts +78 -78
- package/src/_pkgs/affine-inline-preset/keymap/bracket.ts +162 -162
- package/src/_pkgs/affine-inline-preset/keymap/format.ts +36 -36
- package/src/_pkgs/affine-inline-preset/keymap/index.ts +15 -15
- package/src/_pkgs/affine-inline-preset/markdown.ts +284 -284
- package/src/_pkgs/affine-inline-preset/nodes/affine-text.ts +35 -35
- package/src/_pkgs/affine-inline-preset/store.ts +15 -15
- package/src/_pkgs/affine-inline-preset/view.ts +25 -25
- package/src/_pkgs/affine-inline-reference/adapters/html/inline-delta.ts +42 -42
- package/src/_pkgs/affine-inline-reference/adapters/markdown/inline-delta.ts +42 -42
- package/src/_pkgs/affine-inline-reference/adapters/plain-text/inline-delta.ts +33 -33
- package/src/_pkgs/affine-inline-reference/inline-spec.ts +57 -57
- package/src/_pkgs/affine-inline-reference/reference-node/configs/toolbar.ts +247 -247
- package/src/_pkgs/affine-inline-reference/reference-node/reference-config.ts +53 -53
- package/src/_pkgs/affine-inline-reference/reference-node/reference-node-slots.ts +30 -30
- package/src/_pkgs/affine-inline-reference/reference-node/reference-node.ts +318 -318
- package/src/_pkgs/affine-inline-reference/reference-node/reference-popup/reference-popup.ts +282 -282
- package/src/_pkgs/affine-inline-reference/reference-node/reference-popup/toggle-reference-popup.ts +27 -27
- package/src/_pkgs/affine-inline-reference/reference-node/types.ts +15 -15
- package/src/_pkgs/affine-inline-reference/store.ts +21 -21
- package/src/_pkgs/affine-inline-reference/toolbar.ts +9 -9
- package/src/_pkgs/affine-inline-reference/utils.ts +21 -21
- package/src/_pkgs/affine-inline-reference/view.ts +25 -25
- package/src/_pkgs/affine-model/blocks/attachment/attachment-model.ts +112 -112
- package/src/_pkgs/affine-model/blocks/attachment/attachment-transformer.ts +34 -34
- package/src/_pkgs/affine-model/blocks/bookmark/bookmark-model.ts +81 -81
- package/src/_pkgs/affine-model/blocks/callout/callout-model.ts +44 -44
- package/src/_pkgs/affine-model/blocks/code/code-model.ts +52 -52
- package/src/_pkgs/affine-model/blocks/database/database-model.ts +43 -43
- package/src/_pkgs/affine-model/blocks/divider/divider-model.ts +24 -24
- package/src/_pkgs/affine-model/blocks/edgeless-text/edgeless-text-model.ts +94 -94
- package/src/_pkgs/affine-model/blocks/embed/figma/figma-model.ts +21 -21
- package/src/_pkgs/affine-model/blocks/embed/figma/figma-schema.ts +28 -28
- package/src/_pkgs/affine-model/blocks/embed/github/github-model.ts +35 -35
- package/src/_pkgs/affine-model/blocks/embed/github/github-schema.ts +37 -37
- package/src/_pkgs/affine-model/blocks/embed/html/html-model.ts +17 -17
- package/src/_pkgs/affine-model/blocks/embed/html/html-schema.ts +25 -25
- package/src/_pkgs/affine-model/blocks/embed/iframe/iframe-model.ts +38 -38
- package/src/_pkgs/affine-model/blocks/embed/iframe/iframe-schema.ts +17 -17
- package/src/_pkgs/affine-model/blocks/embed/linked-doc/linked-doc-model.ts +24 -24
- package/src/_pkgs/affine-model/blocks/embed/linked-doc/linked-doc-schema.ts +30 -30
- package/src/_pkgs/affine-model/blocks/embed/loom/loom-model.ts +23 -23
- package/src/_pkgs/affine-model/blocks/embed/loom/loom-schema.ts +29 -29
- package/src/_pkgs/affine-model/blocks/embed/synced-doc/synced-doc-model.ts +30 -30
- package/src/_pkgs/affine-model/blocks/embed/synced-doc/synced-doc-schema.ts +39 -39
- package/src/_pkgs/affine-model/blocks/embed/types.ts +58 -58
- package/src/_pkgs/affine-model/blocks/embed/youtube/youtube-model.ts +26 -26
- package/src/_pkgs/affine-model/blocks/embed/youtube/youtube-schema.ts +33 -33
- package/src/_pkgs/affine-model/blocks/frame/frame-model.ts +163 -163
- package/src/_pkgs/affine-model/blocks/image/image-model.ts +59 -59
- package/src/_pkgs/affine-model/blocks/image/image-transformer.ts +34 -34
- package/src/_pkgs/affine-model/blocks/latex/latex-model.ts +47 -47
- package/src/_pkgs/affine-model/blocks/list/list-model.ts +56 -56
- package/src/_pkgs/affine-model/blocks/note/note-model.ts +167 -167
- package/src/_pkgs/affine-model/blocks/paragraph/paragraph-model.ts +62 -62
- package/src/_pkgs/affine-model/blocks/root/root-block-model.ts +65 -65
- package/src/_pkgs/affine-model/blocks/surface-ref/surface-ref-model.ts +34 -34
- package/src/_pkgs/affine-model/blocks/table/table-model.ts +71 -71
- package/src/_pkgs/affine-model/consts/doc.ts +94 -94
- package/src/_pkgs/affine-model/elements/bpmn/index.ts +2 -2
- package/src/_pkgs/affine-model/elements/bpmn/node.ts +42 -42
- package/src/_pkgs/affine-model/elements/bpmn/pool.ts +66 -66
- package/src/_pkgs/affine-model/elements/brush/brush.ts +219 -219
- package/src/_pkgs/affine-model/elements/connector/connector.ts +539 -539
- package/src/_pkgs/affine-model/elements/connector/local-connector.ts +58 -58
- package/src/_pkgs/affine-model/elements/cynefin/cynefin.ts +78 -78
- package/src/_pkgs/affine-model/elements/edgy/facets.ts +87 -87
- package/src/_pkgs/affine-model/elements/edgy/node.ts +37 -37
- package/src/_pkgs/affine-model/elements/estuarine/estuarine.ts +79 -79
- package/src/_pkgs/affine-model/elements/group/group.ts +121 -121
- package/src/_pkgs/affine-model/elements/highlighter/highlighter.ts +220 -220
- package/src/_pkgs/affine-model/elements/mindmap/mindmap.ts +974 -974
- package/src/_pkgs/affine-model/elements/shape/api/diamond.ts +120 -120
- package/src/_pkgs/affine-model/elements/shape/api/ellipse.ts +202 -202
- package/src/_pkgs/affine-model/elements/shape/api/polygon.ts +424 -424
- package/src/_pkgs/affine-model/elements/shape/api/rect.ts +119 -119
- package/src/_pkgs/affine-model/elements/shape/api/triangle.ts +116 -116
- package/src/_pkgs/affine-model/elements/shape/shape.ts +367 -367
- package/src/_pkgs/affine-model/elements/text/text.ts +92 -92
- package/src/_pkgs/affine-model/elements/wardley/node.ts +52 -52
- package/src/_pkgs/affine-model/elements/wardley/wardley.ts +160 -160
- package/src/_pkgs/affine-model/utils/helper.ts +74 -74
- package/src/_pkgs/affine-model/utils/types.ts +43 -43
- package/src/_pkgs/affine-rich-text/conversion.ts +136 -136
- package/src/_pkgs/affine-rich-text/dom.ts +172 -172
- package/src/_pkgs/affine-rich-text/hooks.ts +116 -116
- package/src/_pkgs/affine-rich-text/rich-text.ts +480 -480
- package/src/_pkgs/affine-rich-text/utils.ts +68 -68
- package/src/_pkgs/affine-shared/adapters/attachment.ts +147 -147
- package/src/_pkgs/affine-shared/adapters/clipboard/clipboard.ts +107 -107
- package/src/_pkgs/affine-shared/adapters/html/block-adapter.ts +31 -31
- package/src/_pkgs/affine-shared/adapters/html/delta-converter.ts +135 -135
- package/src/_pkgs/affine-shared/adapters/html/html.ts +400 -400
- package/src/_pkgs/affine-shared/adapters/image.ts +137 -137
- package/src/_pkgs/affine-shared/adapters/markdown/block-adapter.ts +31 -31
- package/src/_pkgs/affine-shared/adapters/markdown/delta-converter.ts +124 -124
- package/src/_pkgs/affine-shared/adapters/markdown/markdown.ts +414 -414
- package/src/_pkgs/affine-shared/adapters/markdown/preprocessor.ts +40 -40
- package/src/_pkgs/affine-shared/adapters/middlewares/callout-export-options.ts +45 -45
- package/src/_pkgs/affine-shared/adapters/middlewares/code.ts +11 -11
- package/src/_pkgs/affine-shared/adapters/middlewares/copy.ts +66 -66
- package/src/_pkgs/affine-shared/adapters/middlewares/doc-link.ts +44 -44
- package/src/_pkgs/affine-shared/adapters/middlewares/file-name.ts +27 -27
- package/src/_pkgs/affine-shared/adapters/middlewares/file-path.ts +14 -14
- package/src/_pkgs/affine-shared/adapters/middlewares/paste.ts +596 -596
- package/src/_pkgs/affine-shared/adapters/middlewares/proxy.ts +53 -53
- package/src/_pkgs/affine-shared/adapters/middlewares/replace-id.ts +256 -256
- package/src/_pkgs/affine-shared/adapters/middlewares/surface-ref-to-embed.ts +46 -46
- package/src/_pkgs/affine-shared/adapters/middlewares/title.ts +15 -15
- package/src/_pkgs/affine-shared/adapters/middlewares/upload.ts +118 -118
- package/src/_pkgs/affine-shared/adapters/mix-text.ts +360 -360
- package/src/_pkgs/affine-shared/adapters/notion-html/block-adapter.ts +33 -33
- package/src/_pkgs/affine-shared/adapters/notion-html/delta-converter.ts +105 -105
- package/src/_pkgs/affine-shared/adapters/notion-html/notion-html.ts +300 -300
- package/src/_pkgs/affine-shared/adapters/notion-text.ts +191 -191
- package/src/_pkgs/affine-shared/adapters/plain-text/block-adapter.ts +28 -28
- package/src/_pkgs/affine-shared/adapters/plain-text/delta-converter.ts +81 -81
- package/src/_pkgs/affine-shared/adapters/plain-text/plain-text.ts +324 -324
- package/src/_pkgs/affine-shared/adapters/types/adapter.ts +124 -124
- package/src/_pkgs/affine-shared/adapters/types/delta-converter.ts +61 -61
- package/src/_pkgs/affine-shared/adapters/types/preprocessor.ts +88 -88
- package/src/_pkgs/affine-shared/adapters/utils/text.ts +96 -96
- package/src/_pkgs/affine-shared/commands/block-crud/get-block-index.ts +33 -33
- package/src/_pkgs/affine-shared/commands/block-crud/get-first-content-block.ts +65 -65
- package/src/_pkgs/affine-shared/commands/block-crud/get-last-content-block.ts +67 -67
- package/src/_pkgs/affine-shared/commands/block-crud/get-next-block.ts +36 -36
- package/src/_pkgs/affine-shared/commands/block-crud/get-prev-block.ts +37 -37
- package/src/_pkgs/affine-shared/commands/block-crud/get-selected-blocks.ts +164 -164
- package/src/_pkgs/affine-shared/commands/model-crud/clear-and-select-first-model.ts +33 -33
- package/src/_pkgs/affine-shared/commands/model-crud/copy-selected-models.ts +25 -25
- package/src/_pkgs/affine-shared/commands/model-crud/delete-selected-models.ts +21 -21
- package/src/_pkgs/affine-shared/commands/model-crud/draft-selected-models.ts +50 -50
- package/src/_pkgs/affine-shared/commands/model-crud/duplicate-selected-model.ts +55 -55
- package/src/_pkgs/affine-shared/commands/model-crud/get-selected-models.ts +67 -67
- package/src/_pkgs/affine-shared/commands/model-crud/replace-selected-text-with-blocks.ts +399 -399
- package/src/_pkgs/affine-shared/commands/model-crud/retain-first-model.ts +19 -19
- package/src/_pkgs/affine-shared/commands/selection/focus-block-end.ts +37 -37
- package/src/_pkgs/affine-shared/commands/selection/focus-block-start.ts +23 -23
- package/src/_pkgs/affine-shared/commands/selection/get-block-selections.ts +10 -10
- package/src/_pkgs/affine-shared/commands/selection/get-selection-rects.ts +184 -184
- package/src/_pkgs/affine-shared/commands/selection/get-surface-selection.ts +10 -10
- package/src/_pkgs/affine-shared/commands/selection/get-text-selection.ts +10 -10
- package/src/_pkgs/affine-shared/commands/selection/is-nothing-selected.ts +24 -24
- package/src/_pkgs/affine-shared/commands/selection/types.ts +18 -18
- package/src/_pkgs/affine-shared/consts/index.ts +90 -90
- package/src/_pkgs/affine-shared/selection/hightlight.ts +66 -66
- package/src/_pkgs/affine-shared/selection/image.ts +33 -33
- package/src/_pkgs/affine-shared/services/auto-clear-selection-service.ts +12 -12
- package/src/_pkgs/affine-shared/services/block-meta-service.ts +104 -104
- package/src/_pkgs/affine-shared/services/citation-service/citation-service.ts +84 -84
- package/src/_pkgs/affine-shared/services/comment-service/block-comment-manager.ts +118 -118
- package/src/_pkgs/affine-shared/services/comment-service/comment-provider.ts +44 -44
- package/src/_pkgs/affine-shared/services/comment-service/utils.ts +50 -50
- package/src/_pkgs/affine-shared/services/doc-display-meta-service.ts +197 -197
- package/src/_pkgs/affine-shared/services/doc-mode-service.ts +109 -109
- package/src/_pkgs/affine-shared/services/drag-handle-config.ts +65 -65
- package/src/_pkgs/affine-shared/services/edit-props-store.ts +217 -217
- package/src/_pkgs/affine-shared/services/editor-setting-service.ts +41 -41
- package/src/_pkgs/affine-shared/services/embed-iframe/embed-iframe-config.ts +93 -93
- package/src/_pkgs/affine-shared/services/embed-iframe/embed-iframe-service.ts +152 -152
- package/src/_pkgs/affine-shared/services/embed-option-service.ts +65 -65
- package/src/_pkgs/affine-shared/services/feature-flag-service.ts +65 -65
- package/src/_pkgs/affine-shared/services/file-size-limit-service.ts +23 -23
- package/src/_pkgs/affine-shared/services/font-loader/config.ts +379 -379
- package/src/_pkgs/affine-shared/services/font-loader/font-loader-service.ts +62 -62
- package/src/_pkgs/affine-shared/services/generate-url-service.ts +21 -21
- package/src/_pkgs/affine-shared/services/index.ts +1 -0
- package/src/_pkgs/affine-shared/services/link-preview-service/link-preview-cache.ts +240 -240
- package/src/_pkgs/affine-shared/services/link-preview-service/link-preview-service.ts +210 -210
- package/src/_pkgs/affine-shared/services/link-preview-service/link-preview-storage.ts +81 -81
- package/src/_pkgs/affine-shared/services/linked-doc-creation-service.ts +34 -0
- package/src/_pkgs/affine-shared/services/native-clipboard-service.ts +23 -23
- package/src/_pkgs/affine-shared/services/notification-service.ts +123 -123
- package/src/_pkgs/affine-shared/services/open-doc-config.ts +59 -59
- package/src/_pkgs/affine-shared/services/page-viewport-service.ts +15 -15
- package/src/_pkgs/affine-shared/services/parse-url-service.ts +22 -22
- package/src/_pkgs/affine-shared/services/quick-search-service.ts +31 -31
- package/src/_pkgs/affine-shared/services/sidebar-service.ts +18 -18
- package/src/_pkgs/affine-shared/services/telemetry-service/block-lifecycle-watcher.ts +148 -148
- package/src/_pkgs/affine-shared/services/telemetry-service/noop.ts +20 -20
- package/src/_pkgs/affine-shared/services/telemetry-service/telemetry-service.ts +78 -78
- package/src/_pkgs/affine-shared/services/theme-service.ts +195 -195
- package/src/_pkgs/affine-shared/services/toolbar-service/context.ts +297 -297
- package/src/_pkgs/affine-shared/services/toolbar-service/module.ts +9 -9
- package/src/_pkgs/affine-shared/services/toolbar-service/registry.ts +64 -64
- package/src/_pkgs/affine-shared/services/user-service/user-list-service.ts +28 -28
- package/src/_pkgs/affine-shared/services/user-service/user-service.ts +24 -24
- package/src/_pkgs/affine-shared/services/user-service/writer-info-service.ts +22 -22
- package/src/_pkgs/affine-shared/services/viewport-element-service.ts +62 -62
- package/src/_pkgs/affine-shared/services/virtual-keyboard-service.ts +23 -23
- package/src/_pkgs/affine-shared/test-utils/affine-template.ts +316 -316
- package/src/_pkgs/affine-shared/test-utils/affine-test-utils.ts +113 -113
- package/src/_pkgs/affine-shared/test-utils/create-test-host.ts +248 -248
- package/src/_pkgs/affine-shared/theme/css-variables.ts +132 -132
- package/src/_pkgs/affine-shared/types/index.ts +74 -74
- package/src/_pkgs/affine-shared/utils/button-popper.ts +161 -161
- package/src/_pkgs/affine-shared/utils/collapsed/paragraph.ts +57 -57
- package/src/_pkgs/affine-shared/utils/dnd/calc-drop-target.ts +208 -208
- package/src/_pkgs/affine-shared/utils/dnd/get-drop-rect-by-point.ts +160 -160
- package/src/_pkgs/affine-shared/utils/dnd/types.ts +29 -29
- package/src/_pkgs/affine-shared/utils/dom/checker.ts +18 -18
- package/src/_pkgs/affine-shared/utils/dom/point-to-block.ts +334 -334
- package/src/_pkgs/affine-shared/utils/dom/point-to-range.ts +98 -98
- package/src/_pkgs/affine-shared/utils/dom/query.ts +39 -39
- package/src/_pkgs/affine-shared/utils/dom/viewport.ts +19 -19
- package/src/_pkgs/affine-shared/utils/edgeless.ts +79 -79
- package/src/_pkgs/affine-shared/utils/event.ts +362 -362
- package/src/_pkgs/affine-shared/utils/file/filesys.ts +293 -293
- package/src/_pkgs/affine-shared/utils/model/block-props.ts +6 -6
- package/src/_pkgs/affine-shared/utils/model/checker.ts +34 -34
- package/src/_pkgs/affine-shared/utils/model/doc.ts +38 -38
- package/src/_pkgs/affine-shared/utils/model/get-content-block.ts +140 -140
- package/src/_pkgs/affine-shared/utils/model/getter.ts +75 -75
- package/src/_pkgs/affine-shared/utils/model/list.ts +103 -103
- package/src/_pkgs/affine-shared/utils/model/merge-to-code-model.ts +33 -33
- package/src/_pkgs/affine-shared/utils/model/transform-model.ts +31 -31
- package/src/_pkgs/affine-shared/utils/reference.ts +44 -44
- package/src/_pkgs/affine-shared/utils/title.ts +32 -32
- package/src/_pkgs/affine-shared/utils/virtual-padding.ts +35 -35
- package/src/_pkgs/affine-shared/utils/zod-schema.ts +219 -219
- package/src/_pkgs/affine-widget-drag-handle/components/edgeless-preview/preview.ts +133 -133
- package/src/_pkgs/affine-widget-drag-handle/drag-handle.ts +252 -252
- package/src/_pkgs/affine-widget-drag-handle/helpers/preview-helper.ts +207 -207
- package/src/_pkgs/affine-widget-drag-handle/helpers/rect-helper.ts +95 -95
- package/src/_pkgs/affine-widget-drag-handle/helpers/selection-helper.ts +67 -67
- package/src/_pkgs/affine-widget-drag-handle/index.ts +15 -15
- package/src/_pkgs/affine-widget-drag-handle/middleware/blocks-filter.ts +119 -119
- package/src/_pkgs/affine-widget-drag-handle/middleware/card-style-updater.ts +56 -56
- package/src/_pkgs/affine-widget-drag-handle/middleware/new-id-cross-doc.ts +53 -53
- package/src/_pkgs/affine-widget-drag-handle/middleware/reorder-list.ts +31 -31
- package/src/_pkgs/affine-widget-drag-handle/styles.ts +86 -86
- package/src/_pkgs/affine-widget-drag-handle/utils.ts +346 -346
- package/src/_pkgs/affine-widget-drag-handle/view.ts +21 -21
- package/src/_pkgs/affine-widget-drag-handle/watchers/drag-event-watcher.ts +1742 -1742
- package/src/_pkgs/affine-widget-drag-handle/watchers/edgeless-watcher.ts +235 -235
- package/src/_pkgs/affine-widget-drag-handle/watchers/keyboard-event-watcher.ts +24 -24
- package/src/_pkgs/affine-widget-drag-handle/watchers/page-watcher.ts +21 -21
- package/src/_pkgs/affine-widget-drag-handle/watchers/pointer-event-watcher.ts +366 -366
- package/src/_pkgs/affine-widget-edgeless-auto-connect/index.ts +634 -634
- package/src/_pkgs/affine-widget-edgeless-auto-connect/view.ts +23 -23
- package/src/_pkgs/affine-widget-edgeless-dragging-area/edgeless-dragging-area-rect.ts +68 -68
- package/src/_pkgs/affine-widget-edgeless-dragging-area/view.ts +23 -23
- package/src/_pkgs/affine-widget-edgeless-selected-rect/auto-complete-panel.ts +680 -680
- package/src/_pkgs/affine-widget-edgeless-selected-rect/edgeless-auto-complete.ts +787 -787
- package/src/_pkgs/affine-widget-edgeless-selected-rect/edgeless-selected-rect.ts +844 -844
- package/src/_pkgs/affine-widget-edgeless-selected-rect/resize-handles.ts +94 -94
- package/src/_pkgs/affine-widget-edgeless-selected-rect/spec.ts +10 -10
- package/src/_pkgs/affine-widget-edgeless-selected-rect/utils.ts +416 -416
- package/src/_pkgs/affine-widget-edgeless-selected-rect/view.ts +23 -23
- package/src/_pkgs/affine-widget-edgeless-toolbar/config/types.ts +28 -28
- package/src/_pkgs/affine-widget-edgeless-toolbar/config/utils.ts +72 -72
- package/src/_pkgs/affine-widget-edgeless-toolbar/context.ts +21 -21
- package/src/_pkgs/affine-widget-edgeless-toolbar/create-popper.ts +103 -103
- package/src/_pkgs/affine-widget-edgeless-toolbar/draggable/draggable-element.controller.ts +477 -477
- package/src/_pkgs/affine-widget-edgeless-toolbar/draggable/types.ts +97 -97
- package/src/_pkgs/affine-widget-edgeless-toolbar/menu/slide-menu.ts +184 -184
- package/src/_pkgs/affine-widget-edgeless-toolbar/menu/toolbar-arrow-up-icon.ts +17 -17
- package/src/_pkgs/affine-widget-edgeless-toolbar/mixins/quick-tool.mixin.ts +21 -21
- package/src/_pkgs/affine-widget-edgeless-toolbar/mixins/tool.mixin.ts +171 -171
- package/src/_pkgs/affine-widget-edgeless-toolbar/mixins/toolbar-button-with-menu.mixin.ts +20 -20
- package/src/_pkgs/affine-widget-edgeless-toolbar/panel/font-family-panel.ts +57 -57
- package/src/_pkgs/affine-widget-edgeless-toolbar/panel/font-weight-and-style-panel.ts +163 -163
- package/src/_pkgs/affine-widget-edgeless-toolbar/view.ts +23 -23
- package/src/_pkgs/affine-widget-edgeless-zoom-toolbar/index.ts +94 -94
- package/src/_pkgs/affine-widget-edgeless-zoom-toolbar/view.ts +23 -23
- package/src/_pkgs/affine-widget-edgeless-zoom-toolbar/zoom-bar-toggle-button.ts +113 -113
- package/src/_pkgs/affine-widget-edgeless-zoom-toolbar/zoom-toolbar.ts +213 -213
- package/src/_pkgs/affine-widget-frame-title/affine-frame-title-widget.ts +21 -21
- package/src/_pkgs/affine-widget-frame-title/edgeless-frame-title-editor.ts +185 -185
- package/src/_pkgs/affine-widget-frame-title/frame-title.ts +293 -293
- package/src/_pkgs/affine-widget-frame-title/mount-frame-title-editor.ts +34 -34
- package/src/_pkgs/affine-widget-frame-title/styles.ts +35 -35
- package/src/_pkgs/affine-widget-frame-title/view.ts +23 -23
- package/src/_pkgs/affine-widget-keyboard-toolbar/config.ts +1160 -1160
- package/src/_pkgs/affine-widget-keyboard-toolbar/keyboard-tool-panel.ts +100 -100
- package/src/_pkgs/affine-widget-keyboard-toolbar/keyboard-toolbar.ts +350 -350
- package/src/_pkgs/affine-widget-keyboard-toolbar/position-controller.ts +42 -42
- package/src/_pkgs/affine-widget-keyboard-toolbar/styles.ts +145 -145
- package/src/_pkgs/affine-widget-keyboard-toolbar/view.ts +28 -28
- package/src/_pkgs/affine-widget-keyboard-toolbar/widget.ts +148 -148
- package/src/_pkgs/affine-widget-linked-doc/config.ts +230 -230
- package/src/_pkgs/affine-widget-linked-doc/import-doc/import-doc.ts +297 -297
- package/src/_pkgs/affine-widget-linked-doc/import-doc/index.ts +38 -38
- package/src/_pkgs/affine-widget-linked-doc/import-doc/loader.ts +103 -103
- package/src/_pkgs/affine-widget-linked-doc/linked-doc-popover.ts +428 -428
- package/src/_pkgs/affine-widget-linked-doc/mobile-linked-doc-menu.ts +216 -216
- package/src/_pkgs/affine-widget-linked-doc/styles.ts +163 -163
- package/src/_pkgs/affine-widget-linked-doc/transformers/html.ts +218 -218
- package/src/_pkgs/affine-widget-linked-doc/transformers/markdown.ts +283 -283
- package/src/_pkgs/affine-widget-linked-doc/transformers/notion-html.ts +174 -174
- package/src/_pkgs/affine-widget-linked-doc/transformers/utils.ts +115 -115
- package/src/_pkgs/affine-widget-linked-doc/transformers/zip.ts +172 -172
- package/src/_pkgs/affine-widget-linked-doc/view.ts +83 -83
- package/src/_pkgs/affine-widget-linked-doc/widget.ts +344 -344
- package/src/_pkgs/affine-widget-note-slicer/note-slicer.ts +451 -451
- package/src/_pkgs/affine-widget-note-slicer/view.ts +23 -23
- package/src/_pkgs/affine-widget-page-dragging-area/index.ts +331 -331
- package/src/_pkgs/affine-widget-page-dragging-area/utils.ts +146 -146
- package/src/_pkgs/affine-widget-page-dragging-area/view.ts +24 -24
- package/src/_pkgs/affine-widget-remote-selection/doc/config.ts +5 -5
- package/src/_pkgs/affine-widget-remote-selection/doc/doc-remote-selection.ts +398 -398
- package/src/_pkgs/affine-widget-remote-selection/edgeless/index.ts +304 -304
- package/src/_pkgs/affine-widget-remote-selection/index.ts +20 -20
- package/src/_pkgs/affine-widget-remote-selection/manager/remote-color-manager.ts +42 -42
- package/src/_pkgs/affine-widget-remote-selection/view.ts +27 -27
- package/src/_pkgs/affine-widget-scroll-anchoring/index.ts +12 -12
- package/src/_pkgs/affine-widget-scroll-anchoring/scroll-anchoring.ts +267 -267
- package/src/_pkgs/affine-widget-scroll-anchoring/view.ts +21 -21
- package/src/_pkgs/affine-widget-slash-menu/config.ts +189 -189
- package/src/_pkgs/affine-widget-slash-menu/extensions.ts +51 -51
- package/src/_pkgs/affine-widget-slash-menu/slash-menu-popover.ts +668 -668
- package/src/_pkgs/affine-widget-slash-menu/styles.ts +109 -109
- package/src/_pkgs/affine-widget-slash-menu/types.ts +59 -59
- package/src/_pkgs/affine-widget-slash-menu/view.ts +22 -22
- package/src/_pkgs/affine-widget-slash-menu/widget.ts +184 -184
- package/src/_pkgs/affine-widget-toolbar/index.ts +12 -12
- package/src/_pkgs/affine-widget-toolbar/toolbar.ts +705 -705
- package/src/_pkgs/affine-widget-toolbar/utils.ts +432 -432
- package/src/_pkgs/affine-widget-toolbar/view.ts +22 -22
- package/src/_pkgs/affine-widget-viewport-overlay/index.ts +90 -90
- package/src/_pkgs/affine-widget-viewport-overlay/view.ts +21 -21
- package/src/_pkgs/data-view/core/common/properties.ts +283 -283
- package/src/_pkgs/data-view/core/common/property-menu.ts +76 -76
- package/src/_pkgs/data-view/core/component/button/button.ts +89 -89
- package/src/_pkgs/data-view/core/component/overflow/overflow.ts +109 -109
- package/src/_pkgs/data-view/core/component/tags/multi-tag-select.ts +606 -606
- package/src/_pkgs/data-view/core/component/tags/multi-tag-view.ts +88 -88
- package/src/_pkgs/data-view/core/data-source/base.ts +305 -305
- package/src/_pkgs/data-view/core/data-view.ts +211 -211
- package/src/_pkgs/data-view/core/detail/detail.ts +305 -305
- package/src/_pkgs/data-view/core/detail/field.ts +286 -286
- package/src/_pkgs/data-view/core/expression/ref/ref-view.ts +94 -94
- package/src/_pkgs/data-view/core/expression/types.ts +22 -22
- package/src/_pkgs/data-view/core/filter/add-filter.ts +67 -67
- package/src/_pkgs/data-view/core/filter/literal/define.ts +154 -154
- package/src/_pkgs/data-view/core/filter/literal/types.ts +19 -19
- package/src/_pkgs/data-view/core/filter/utils.ts +66 -66
- package/src/_pkgs/data-view/core/group-by/group-title.ts +231 -231
- package/src/_pkgs/data-view/core/group-by/matcher.ts +41 -41
- package/src/_pkgs/data-view/core/group-by/renderer/base.ts +40 -40
- package/src/_pkgs/data-view/core/group-by/renderer/number-group.ts +65 -65
- package/src/_pkgs/data-view/core/group-by/renderer/select-group.ts +119 -119
- package/src/_pkgs/data-view/core/group-by/renderer/string-group.ts +53 -53
- package/src/_pkgs/data-view/core/group-by/setting.ts +322 -322
- package/src/_pkgs/data-view/core/group-by/trait.ts +362 -362
- package/src/_pkgs/data-view/core/group-by/types.ts +41 -41
- package/src/_pkgs/data-view/core/logical/type-presets.ts +67 -67
- package/src/_pkgs/data-view/core/logical/type-variable.ts +76 -76
- package/src/_pkgs/data-view/core/property/base-cell.ts +134 -134
- package/src/_pkgs/data-view/core/property/manager.ts +44 -44
- package/src/_pkgs/data-view/core/property/renderer.ts +25 -25
- package/src/_pkgs/data-view/core/property/types.ts +99 -99
- package/src/_pkgs/data-view/core/sort/add-sort.ts +53 -53
- package/src/_pkgs/data-view/core/sort/utils.ts +108 -108
- package/src/_pkgs/data-view/core/utils/uni-component/operation.ts +16 -16
- package/src/_pkgs/data-view/core/utils/uni-component/render-template.ts +24 -24
- package/src/_pkgs/data-view/core/utils/uni-component/uni-component.ts +156 -156
- package/src/_pkgs/data-view/core/utils/uni-icon.ts +36 -36
- package/src/_pkgs/data-view/core/view/data-view-base.ts +106 -106
- package/src/_pkgs/data-view/core/view/data-view.ts +80 -80
- package/src/_pkgs/data-view/core/view/types.ts +43 -43
- package/src/_pkgs/data-view/core/view-manager/property.ts +270 -270
- package/src/_pkgs/data-view/core/view-manager/row.ts +65 -65
- package/src/_pkgs/data-view/core/view-manager/single-view.ts +286 -286
- package/src/_pkgs/data-view/core/view-manager/view-manager.ts +130 -130
- package/src/_pkgs/data-view/core/widget/types.ts +10 -10
- package/src/_pkgs/data-view/core/widget/widget-base.ts +28 -28
- package/src/_pkgs/data-view/property-presets/checkbox/cell-renderer.ts +121 -121
- package/src/_pkgs/data-view/property-presets/converts.ts +45 -45
- package/src/_pkgs/data-view/property-presets/date/cell-renderer.ts +167 -167
- package/src/_pkgs/data-view/property-presets/multi-select/cell-renderer.ts +89 -89
- package/src/_pkgs/data-view/property-presets/multi-select/define.ts +76 -76
- package/src/_pkgs/data-view/property-presets/number/cell-renderer.ts +133 -133
- package/src/_pkgs/data-view/property-presets/select/cell-renderer.ts +88 -88
- package/src/_pkgs/data-view/property-presets/select/define.ts +73 -73
- package/src/_pkgs/data-view/view-presets/kanban/define.ts +91 -91
- package/src/_pkgs/data-view/view-presets/kanban/kanban-view-manager.ts +328 -328
- package/src/_pkgs/data-view/view-presets/kanban/mobile/card.ts +225 -225
- package/src/_pkgs/data-view/view-presets/kanban/mobile/cell.ts +178 -178
- package/src/_pkgs/data-view/view-presets/kanban/mobile/group.ts +153 -153
- package/src/_pkgs/data-view/view-presets/kanban/mobile/kanban-view-ui-logic.ts +170 -170
- package/src/_pkgs/data-view/view-presets/kanban/mobile/menu.ts +122 -122
- package/src/_pkgs/data-view/view-presets/kanban/pc/card.ts +337 -337
- package/src/_pkgs/data-view/view-presets/kanban/pc/cell.ts +185 -185
- package/src/_pkgs/data-view/view-presets/kanban/pc/controller/clipboard.ts +53 -53
- package/src/_pkgs/data-view/view-presets/kanban/pc/controller/drag.ts +255 -255
- package/src/_pkgs/data-view/view-presets/kanban/pc/controller/selection.ts +801 -801
- package/src/_pkgs/data-view/view-presets/kanban/pc/group.ts +211 -211
- package/src/_pkgs/data-view/view-presets/kanban/pc/header.ts +76 -76
- package/src/_pkgs/data-view/view-presets/kanban/pc/kanban-view-ui-logic.ts +331 -331
- package/src/_pkgs/data-view/view-presets/kanban/pc/menu.ts +114 -114
- package/src/_pkgs/data-view/view-presets/table/mobile/cell.ts +170 -170
- package/src/_pkgs/data-view/view-presets/table/mobile/column-header.ts +272 -272
- package/src/_pkgs/data-view/view-presets/table/mobile/group.ts +166 -166
- package/src/_pkgs/data-view/view-presets/table/mobile/header.ts +90 -90
- package/src/_pkgs/data-view/view-presets/table/mobile/menu.ts +47 -47
- package/src/_pkgs/data-view/view-presets/table/mobile/row.ts +150 -150
- package/src/_pkgs/data-view/view-presets/table/mobile/table-view-ui-logic.ts +160 -160
- package/src/_pkgs/data-view/view-presets/table/pc/cell.ts +161 -161
- package/src/_pkgs/data-view/view-presets/table/pc/controller/clipboard.ts +323 -323
- package/src/_pkgs/data-view/view-presets/table/pc/controller/drag-to-fill.ts +112 -112
- package/src/_pkgs/data-view/view-presets/table/pc/controller/drag.ts +209 -209
- package/src/_pkgs/data-view/view-presets/table/pc/controller/hotkeys.ts +416 -416
- package/src/_pkgs/data-view/view-presets/table/pc/controller/selection.ts +1180 -1180
- package/src/_pkgs/data-view/view-presets/table/pc/group.ts +311 -311
- package/src/_pkgs/data-view/view-presets/table/pc/header/column-header.ts +143 -143
- package/src/_pkgs/data-view/view-presets/table/pc/header/column-renderer.ts +98 -98
- package/src/_pkgs/data-view/view-presets/table/pc/header/database-header-column.ts +500 -500
- package/src/_pkgs/data-view/view-presets/table/pc/header/number-format-bar.ts +145 -145
- package/src/_pkgs/data-view/view-presets/table/pc/header/styles.ts +349 -349
- package/src/_pkgs/data-view/view-presets/table/pc/header/vertical-indicator.ts +163 -163
- package/src/_pkgs/data-view/view-presets/table/pc/menu.ts +132 -132
- package/src/_pkgs/data-view/view-presets/table/pc/row/row-select-checkbox.ts +80 -80
- package/src/_pkgs/data-view/view-presets/table/pc/row/row.ts +306 -306
- package/src/_pkgs/data-view/view-presets/table/pc/table-view-ui-logic.ts +220 -220
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/controller/clipboard.ts +324 -324
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/controller/drag-to-fill.ts +117 -117
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/controller/drag.ts +212 -212
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/controller/hotkeys.ts +418 -418
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/controller/selection.ts +1110 -1110
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/group/bottom/group-footer.ts +105 -105
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/group/bottom/stats/column-stats-bar.ts +51 -51
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/group/bottom/stats/column-stats-column.ts +246 -246
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/group/top/group-header.ts +138 -138
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/group/top/group-title-css.ts +63 -63
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/group/top/header/column-header.ts +135 -135
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/group/top/header/column-move-preview.ts +98 -98
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/group/top/header/number-format-bar.ts +147 -147
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/group/top/header/single-column-header.ts +497 -497
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/group/top/header/vertical-indicator.ts +169 -169
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/row/cell.ts +225 -225
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/row/menu.ts +132 -132
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/row/row-header.ts +128 -128
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/row/row-last.ts +65 -65
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/table-view-ui-logic.ts +321 -321
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/types.ts +41 -41
- package/src/_pkgs/data-view/view-presets/table/pc-virtual/virtual/virtual-cell.ts +60 -60
- package/src/_pkgs/data-view/view-presets/table/stats/column-stats-bar.ts +55 -55
- package/src/_pkgs/data-view/view-presets/table/stats/column-stats-column.ts +246 -246
- package/src/_pkgs/data-view/view-presets/table/table-view-manager.ts +395 -395
- package/src/_pkgs/data-view/widget-presets/quick-setting-bar/context.ts +10 -10
- package/src/_pkgs/data-view/widget-presets/quick-setting-bar/filter/condition-view.ts +311 -311
- package/src/_pkgs/data-view/widget-presets/quick-setting-bar/filter/group-panel-view.ts +480 -480
- package/src/_pkgs/data-view/widget-presets/quick-setting-bar/filter/index.ts +21 -21
- package/src/_pkgs/data-view/widget-presets/quick-setting-bar/filter/list-view.ts +220 -220
- package/src/_pkgs/data-view/widget-presets/quick-setting-bar/filter/root-panel-view.ts +437 -437
- package/src/_pkgs/data-view/widget-presets/quick-setting-bar/index.ts +52 -52
- package/src/_pkgs/data-view/widget-presets/quick-setting-bar/sort/index.ts +32 -32
- package/src/_pkgs/data-view/widget-presets/quick-setting-bar/sort/root-panel.ts +240 -240
- package/src/_pkgs/data-view/widget-presets/tools/presets/filter/filter.ts +122 -122
- package/src/_pkgs/data-view/widget-presets/tools/presets/search/search.ts +189 -189
- package/src/_pkgs/data-view/widget-presets/tools/presets/sort/sort.ts +127 -127
- package/src/_pkgs/data-view/widget-presets/tools/presets/table-add-row/add-row.ts +51 -51
- package/src/_pkgs/data-view/widget-presets/tools/presets/table-add-row/new-record-preview.ts +44 -44
- package/src/_pkgs/data-view/widget-presets/tools/presets/view-options/view-options.ts +384 -384
- package/src/_pkgs/data-view/widget-presets/tools/tools-view.ts +83 -83
- package/src/_pkgs/data-view/widget-presets/views-bar/views-view.ts +319 -319
- package/src/_pkgs/std/clipboard/clipboard-adapter.ts +33 -33
- package/src/_pkgs/std/clipboard/clipboard.ts +323 -323
- package/src/_pkgs/std/event/base.ts +62 -62
- package/src/_pkgs/std/event/control/keyboard.ts +149 -149
- package/src/_pkgs/std/event/control/pointer.ts +626 -626
- package/src/_pkgs/std/event/dispatcher.ts +435 -435
- package/src/_pkgs/std/event/keymap.ts +127 -127
- package/src/_pkgs/std/event/utils.ts +17 -17
- package/src/_pkgs/std/extension/block-view.ts +33 -33
- package/src/_pkgs/std/extension/config.ts +44 -44
- package/src/_pkgs/std/extension/dnd/index.ts +373 -373
- package/src/_pkgs/std/extension/editor-life-cycle.ts +49 -49
- package/src/_pkgs/std/extension/flavour.ts +26 -26
- package/src/_pkgs/std/extension/keymap.ts +49 -49
- package/src/_pkgs/std/extension/lifecycle-watcher.ts +70 -70
- package/src/_pkgs/std/extension/service.ts +113 -113
- package/src/_pkgs/std/extension/widget-view-map.ts +40 -40
- package/src/_pkgs/std/gfx/controller.ts +284 -284
- package/src/_pkgs/std/gfx/extension.ts +53 -53
- package/src/_pkgs/std/gfx/grid.ts +513 -513
- package/src/_pkgs/std/gfx/identifiers.ts +10 -10
- package/src/_pkgs/std/gfx/interactivity/extension/base.ts +211 -211
- package/src/_pkgs/std/gfx/interactivity/extension/view.ts +134 -134
- package/src/_pkgs/std/gfx/interactivity/gfx-view-event-handler.ts +108 -108
- package/src/_pkgs/std/gfx/interactivity/manager.ts +1111 -1111
- package/src/_pkgs/std/gfx/interactivity/resize/manager.ts +657 -657
- package/src/_pkgs/std/gfx/interactivity/types/drag.ts +73 -73
- package/src/_pkgs/std/gfx/interactivity/types/resize.ts +41 -41
- package/src/_pkgs/std/gfx/interactivity/types/view.ts +173 -173
- package/src/_pkgs/std/gfx/keyboard.ts +51 -51
- package/src/_pkgs/std/gfx/layer.ts +909 -909
- package/src/_pkgs/std/gfx/model/base.ts +173 -173
- package/src/_pkgs/std/gfx/model/gfx-block-model.ts +315 -315
- package/src/_pkgs/std/gfx/model/surface/element-model.ts +598 -598
- package/src/_pkgs/std/gfx/model/surface/local-element-model.ts +254 -254
- package/src/_pkgs/std/gfx/model/surface/surface-model.ts +697 -697
- package/src/_pkgs/std/gfx/selection.ts +408 -408
- package/src/_pkgs/std/gfx/surface-middleware.ts +61 -61
- package/src/_pkgs/std/gfx/tool/tool-controller.ts +635 -635
- package/src/_pkgs/std/gfx/tool/tool.ts +125 -125
- package/src/_pkgs/std/gfx/view/view-manager.ts +139 -139
- package/src/_pkgs/std/gfx/view/view.ts +225 -225
- package/src/_pkgs/std/gfx/viewport-element.ts +230 -230
- package/src/_pkgs/std/gfx/viewport.ts +659 -659
- package/src/_pkgs/std/identifier.ts +34 -34
- package/src/_pkgs/std/inline/components/v-element.ts +113 -113
- package/src/_pkgs/std/inline/components/v-line.ts +156 -156
- package/src/_pkgs/std/inline/consts.ts +6 -6
- package/src/_pkgs/std/inline/extensions/inline-manager.ts +124 -124
- package/src/_pkgs/std/inline/extensions/inline-spec.ts +49 -49
- package/src/_pkgs/std/inline/extensions/markdown-matcher.ts +30 -30
- package/src/_pkgs/std/inline/extensions/type.ts +44 -44
- package/src/_pkgs/std/inline/inline-editor.ts +296 -296
- package/src/_pkgs/std/inline/range/inline-range-provider.ts +118 -118
- package/src/_pkgs/std/inline/range/range-binding.ts +392 -392
- package/src/_pkgs/std/inline/services/attribute.ts +106 -106
- package/src/_pkgs/std/inline/services/delta.ts +153 -153
- package/src/_pkgs/std/inline/services/event.ts +382 -382
- package/src/_pkgs/std/inline/services/hook.ts +35 -35
- package/src/_pkgs/std/inline/services/range.ts +394 -394
- package/src/_pkgs/std/inline/services/render.ts +185 -185
- package/src/_pkgs/std/inline/services/text.ts +140 -140
- package/src/_pkgs/std/inline/types.ts +37 -37
- package/src/_pkgs/std/inline/utils/attribute-renderer.ts +49 -49
- package/src/_pkgs/std/inline/utils/delta-convert.ts +63 -63
- package/src/_pkgs/std/inline/utils/embed.ts +47 -47
- package/src/_pkgs/std/inline/utils/point-conversion.ts +191 -191
- package/src/_pkgs/std/inline/utils/range-conversion.ts +368 -368
- package/src/_pkgs/std/inline/utils/renderer.ts +18 -18
- package/src/_pkgs/std/inline/utils/transform-input.ts +78 -78
- package/src/_pkgs/std/scope/std-scope.ts +169 -169
- package/src/_pkgs/std/selection/block.ts +33 -33
- package/src/_pkgs/std/selection/cursor.ts +45 -45
- package/src/_pkgs/std/selection/surface.ts +72 -72
- package/src/_pkgs/std/selection/text.ts +117 -117
- package/src/_pkgs/std/spec/type.ts +5 -5
- package/src/_pkgs/std/utils/gfx.ts +32 -32
- package/src/_pkgs/std/utils/layer.ts +175 -175
- package/src/_pkgs/std/utils/tree.ts +137 -137
- package/src/_pkgs/std/view/decorators/required.ts +58 -58
- package/src/_pkgs/std/view/element/block-component.ts +315 -315
- package/src/_pkgs/std/view/element/consts.ts +10 -10
- package/src/_pkgs/std/view/element/gfx-block-component.ts +303 -303
- package/src/_pkgs/std/view/element/lit-host.ts +197 -197
- package/src/_pkgs/std/view/element/shadowless-element.ts +97 -97
- package/src/_pkgs/std/view/element/widget-component.ts +98 -98
- package/src/_pkgs/store/adapter/assets.ts +159 -159
- package/src/_pkgs/store/adapter/base.ts +324 -324
- package/src/_pkgs/store/extension/extension.ts +134 -134
- package/src/_pkgs/store/extension/schema.ts +20 -20
- package/src/_pkgs/store/extension/selection/base.ts +46 -46
- package/src/_pkgs/store/extension/selection/identifier.ts +17 -17
- package/src/_pkgs/store/extension/selection/selection-extension.ts +189 -189
- package/src/_pkgs/store/extension/store-extension.ts +61 -61
- package/src/_pkgs/store/extension/workspace/doc.ts +38 -38
- package/src/_pkgs/store/extension/workspace/workspace.ts +30 -30
- package/src/_pkgs/store/index.ts +27 -27
- package/src/_pkgs/store/model/block/block-model.ts +158 -158
- package/src/_pkgs/store/model/block/flat-sync-controller.ts +173 -173
- package/src/_pkgs/store/model/block/sync-controller.ts +391 -391
- package/src/_pkgs/store/model/store/crud.ts +397 -397
- package/src/_pkgs/store/model/store/identifier.ts +5 -5
- package/src/_pkgs/store/model/store/store.ts +1298 -1298
- package/src/_pkgs/store/reactive/flat-native-y/initialize.ts +59 -59
- package/src/_pkgs/store/reactive/proxy.ts +390 -390
- package/src/_pkgs/store/reactive/text/text.ts +472 -472
- package/src/_pkgs/store/schema/error.ts +10 -10
- package/src/_pkgs/store/test/test-workspace.ts +231 -231
- package/src/_pkgs/store/transformer/assets.ts +105 -105
- package/src/_pkgs/store/transformer/transformer.ts +660 -660
- package/src/_pkgs/sync/blob/engine.ts +205 -205
- package/src/_pkgs/sync/doc/engine.ts +291 -291
- package/src/_pkgs/sync/doc/peer.ts +451 -451
- package/src/blocks/attachment/index.ts +1 -1
- package/src/blocks/attachment/store.ts +1 -1
- package/src/blocks/attachment/view.ts +1 -1
- package/src/blocks/bookmark/index.ts +1 -1
- package/src/blocks/bookmark/store.ts +1 -1
- package/src/blocks/bookmark/view.ts +1 -1
- package/src/blocks/callout/index.ts +1 -1
- package/src/blocks/callout/store.ts +1 -1
- package/src/blocks/callout/view.ts +1 -1
- package/src/blocks/code/index.ts +1 -1
- package/src/blocks/code/store.ts +1 -1
- package/src/blocks/code/view.ts +1 -1
- package/src/blocks/data-view/index.ts +1 -1
- package/src/blocks/data-view/store.ts +1 -1
- package/src/blocks/data-view/view.ts +1 -1
- package/src/blocks/database/index.ts +1 -1
- package/src/blocks/database/store.ts +1 -1
- package/src/blocks/database/view.ts +1 -1
- package/src/blocks/divider/index.ts +1 -1
- package/src/blocks/divider/store.ts +1 -1
- package/src/blocks/divider/view.ts +1 -1
- package/src/blocks/edgeless-text/index.ts +1 -1
- package/src/blocks/edgeless-text/store.ts +1 -1
- package/src/blocks/edgeless-text/view.ts +1 -1
- package/src/blocks/embed/index.ts +1 -1
- package/src/blocks/embed/store.ts +1 -1
- package/src/blocks/embed/view.ts +1 -1
- package/src/blocks/embed-doc/index.ts +1 -1
- package/src/blocks/embed-doc/store.ts +1 -1
- package/src/blocks/embed-doc/view.ts +1 -1
- package/src/blocks/frame/index.ts +1 -1
- package/src/blocks/frame/store.ts +1 -1
- package/src/blocks/frame/view.ts +1 -1
- package/src/blocks/image/index.ts +1 -1
- package/src/blocks/image/store.ts +1 -1
- package/src/blocks/image/view.ts +1 -1
- package/src/blocks/latex/index.ts +1 -1
- package/src/blocks/latex/store.ts +1 -1
- package/src/blocks/latex/view.ts +1 -1
- package/src/blocks/list/index.ts +1 -1
- package/src/blocks/list/store.ts +1 -1
- package/src/blocks/list/view.ts +1 -1
- package/src/blocks/note/index.ts +1 -1
- package/src/blocks/note/store.ts +1 -1
- package/src/blocks/note/view.ts +1 -1
- package/src/blocks/paragraph/index.ts +1 -1
- package/src/blocks/paragraph/store.ts +1 -1
- package/src/blocks/paragraph/view.ts +1 -1
- package/src/blocks/root/index.ts +1 -1
- package/src/blocks/root/store.ts +1 -1
- package/src/blocks/root/view.ts +1 -1
- package/src/blocks/surface/index.ts +1 -1
- package/src/blocks/surface/store.ts +1 -1
- package/src/blocks/surface/view.ts +1 -1
- package/src/blocks/surface-ref/index.ts +1 -1
- package/src/blocks/surface-ref/store.ts +1 -1
- package/src/blocks/surface-ref/view.ts +1 -1
- package/src/blocks/table/index.ts +1 -1
- package/src/blocks/table/store.ts +1 -1
- package/src/blocks/table/view.ts +1 -1
- package/src/components/block-selection.ts +1 -1
- package/src/components/block-zero-width.ts +1 -1
- package/src/components/caption.ts +1 -1
- package/src/components/card-style-dropdown-menu.ts +1 -1
- package/src/components/citation.ts +1 -1
- package/src/components/color-picker.ts +1 -1
- package/src/components/context-menu.ts +1 -1
- package/src/components/date-picker.ts +1 -1
- package/src/components/drop-indicator.ts +1 -1
- package/src/components/edgeless-line-styles-panel.ts +1 -1
- package/src/components/edgeless-line-width-panel.ts +1 -1
- package/src/components/edgeless-shape-color-picker.ts +1 -1
- package/src/components/embed-card-modal.ts +1 -1
- package/src/components/filterable-list.ts +1 -1
- package/src/components/highlight-dropdown-menu.ts +1 -1
- package/src/components/hover.ts +1 -1
- package/src/components/icon-button.ts +1 -1
- package/src/components/icons.ts +1 -1
- package/src/components/link-preview.ts +1 -1
- package/src/components/linked-doc-title.ts +1 -1
- package/src/components/notification.ts +1 -1
- package/src/components/open-doc-dropdown-menu.ts +1 -1
- package/src/components/peek.ts +1 -1
- package/src/components/portal.ts +1 -1
- package/src/components/resource.ts +1 -1
- package/src/components/size-dropdown-menu.ts +1 -1
- package/src/components/smooth-corner.ts +1 -1
- package/src/components/toast.ts +1 -1
- package/src/components/toggle-button.ts +1 -1
- package/src/components/toggle-switch.ts +1 -1
- package/src/components/toolbar.ts +1 -1
- package/src/components/tooltip-content-with-shortcut.ts +1 -1
- package/src/components/view-dropdown-menu.ts +1 -1
- package/src/data-view/effects.ts +1 -1
- package/src/data-view/index.ts +1 -1
- package/src/effects.ts +34 -34
- package/src/ext-loader/index.ts +1 -1
- package/src/extensions/store.ts +83 -83
- package/src/extensions/view.ts +143 -143
- package/src/foundation/clipboard.ts +1 -1
- package/src/foundation/store.ts +1 -1
- package/src/foundation/view.ts +1 -1
- package/src/fragments/adapter-panel/index.ts +1 -1
- package/src/fragments/adapter-panel/view.ts +1 -1
- package/src/fragments/doc-title/index.ts +1 -1
- package/src/fragments/doc-title/view.ts +1 -1
- package/src/fragments/frame-panel/index.ts +1 -1
- package/src/fragments/frame-panel/view.ts +1 -1
- package/src/fragments/outline/index.ts +1 -1
- package/src/fragments/outline/view.ts +1 -1
- package/src/gfx/brush/index.ts +1 -1
- package/src/gfx/brush/store.ts +1 -1
- package/src/gfx/brush/view.ts +1 -1
- package/src/gfx/connector/index.ts +1 -1
- package/src/gfx/connector/store.ts +1 -1
- package/src/gfx/connector/view.ts +1 -1
- package/src/gfx/group/index.ts +1 -1
- package/src/gfx/group/store.ts +1 -1
- package/src/gfx/group/view.ts +1 -1
- package/src/gfx/link/index.ts +1 -1
- package/src/gfx/link/view.ts +1 -1
- package/src/gfx/mindmap/index.ts +1 -1
- package/src/gfx/mindmap/store.ts +1 -1
- package/src/gfx/mindmap/view.ts +1 -1
- package/src/gfx/note/index.ts +1 -1
- package/src/gfx/note/view.ts +1 -1
- package/src/gfx/pointer/index.ts +1 -1
- package/src/gfx/pointer/view.ts +1 -1
- package/src/gfx/shape/index.ts +1 -1
- package/src/gfx/shape/store.ts +1 -1
- package/src/gfx/shape/view.ts +1 -1
- package/src/gfx/template/index.ts +1 -1
- package/src/gfx/template/view.ts +1 -1
- package/src/gfx/text/index.ts +1 -1
- package/src/gfx/text/store.ts +1 -1
- package/src/gfx/text/view.ts +1 -1
- package/src/gfx/turbo-renderer.ts +1 -1
- package/src/global/di.ts +1 -1
- package/src/global/disposable.ts +1 -1
- package/src/global/env.ts +1 -1
- package/src/global/exceptions.ts +1 -1
- package/src/global/gfx.ts +1 -1
- package/src/global/index.ts +1 -1
- package/src/global/lit.ts +1 -1
- package/src/global/types.ts +1 -1
- package/src/global/utils.ts +1 -1
- package/src/inlines/comment/index.ts +1 -1
- package/src/inlines/footnote/index.ts +1 -1
- package/src/inlines/footnote/store.ts +1 -1
- package/src/inlines/footnote/view.ts +1 -1
- package/src/inlines/latex/index.ts +1 -1
- package/src/inlines/latex/store.ts +1 -1
- package/src/inlines/latex/view.ts +1 -1
- package/src/inlines/link/index.ts +1 -1
- package/src/inlines/link/store.ts +1 -1
- package/src/inlines/link/view.ts +1 -1
- package/src/inlines/mention/index.ts +1 -1
- package/src/inlines/mention/view.ts +1 -1
- package/src/inlines/preset/index.ts +1 -1
- package/src/inlines/preset/store.ts +1 -1
- package/src/inlines/preset/view.ts +1 -1
- package/src/inlines/reference/index.ts +1 -1
- package/src/inlines/reference/store.ts +1 -1
- package/src/inlines/reference/view.ts +1 -1
- package/src/model/index.ts +1 -1
- package/src/rich-text/effects.ts +1 -1
- package/src/rich-text/index.ts +1 -1
- package/src/schemas.ts +78 -78
- package/src/shared/adapters.ts +1 -1
- package/src/shared/commands.ts +1 -1
- package/src/shared/consts.ts +1 -1
- package/src/shared/selection.ts +1 -1
- package/src/shared/services.ts +1 -1
- package/src/shared/styles.ts +1 -1
- package/src/shared/theme.ts +1 -1
- package/src/shared/types.ts +1 -1
- package/src/shared/utils.ts +1 -1
- package/src/std/effects.ts +1 -1
- package/src/std/gfx.ts +1 -1
- package/src/std/index.ts +1 -1
- package/src/std/inline.ts +1 -1
- package/src/store/index.ts +3 -3
- package/src/store/test.ts +1 -1
- package/src/sync/index.ts +1 -1
- package/src/widgets/drag-handle/index.ts +1 -1
- package/src/widgets/drag-handle/view.ts +1 -1
- package/src/widgets/edgeless-auto-connect/index.ts +1 -1
- package/src/widgets/edgeless-auto-connect/view.ts +1 -1
- package/src/widgets/edgeless-dragging-area/index.ts +1 -1
- package/src/widgets/edgeless-dragging-area/view.ts +1 -1
- package/src/widgets/edgeless-selected-rect/index.ts +1 -1
- package/src/widgets/edgeless-selected-rect/view.ts +1 -1
- package/src/widgets/edgeless-toolbar/index.ts +1 -1
- package/src/widgets/edgeless-toolbar/view.ts +1 -1
- package/src/widgets/edgeless-zoom-toolbar/index.ts +1 -1
- package/src/widgets/edgeless-zoom-toolbar/view.ts +1 -1
- package/src/widgets/frame-title/index.ts +1 -1
- package/src/widgets/frame-title/view.ts +1 -1
- package/src/widgets/keyboard-toolbar/index.ts +1 -1
- package/src/widgets/keyboard-toolbar/view.ts +1 -1
- package/src/widgets/linked-doc/index.ts +1 -1
- package/src/widgets/linked-doc/view.ts +1 -1
- package/src/widgets/note-slicer/index.ts +1 -1
- package/src/widgets/note-slicer/view.ts +1 -1
- package/src/widgets/page-dragging-area/index.ts +1 -1
- package/src/widgets/page-dragging-area/view.ts +1 -1
- package/src/widgets/remote-selection/index.ts +1 -1
- package/src/widgets/remote-selection/view.ts +1 -1
- package/src/widgets/scroll-anchoring/index.ts +1 -1
- package/src/widgets/scroll-anchoring/view.ts +1 -1
- package/src/widgets/slash-menu/index.ts +1 -1
- package/src/widgets/slash-menu/view.ts +1 -1
- package/src/widgets/toolbar/index.ts +1 -1
- package/src/widgets/toolbar/view.ts +1 -1
- package/src/widgets/viewport-overlay/index.ts +1 -1
- package/src/widgets/viewport-overlay/view.ts +1 -1
|
@@ -1,1298 +1,1298 @@
|
|
|
1
|
-
import { Container, type ServiceProvider } from '../../../global/di/index.js';
|
|
2
|
-
import { DisposableGroup } from '../../../global/disposable/index.js';
|
|
3
|
-
import { BlockSuiteError, ErrorCode } from '../../../global/exceptions/index.js';
|
|
4
|
-
import { computed, signal } from '@preact/signals-core';
|
|
5
|
-
import { Subject } from 'rxjs';
|
|
6
|
-
import * as Y from 'yjs';
|
|
7
|
-
|
|
8
|
-
import type { ExtensionType } from '../../extension/extension.js';
|
|
9
|
-
import {
|
|
10
|
-
BlockSchemaIdentifier,
|
|
11
|
-
type Doc,
|
|
12
|
-
HistoryExtension,
|
|
13
|
-
StoreExtensionIdentifier,
|
|
14
|
-
StoreSelectionExtension,
|
|
15
|
-
} from '../../extension/index.js';
|
|
16
|
-
import { DocIdentifier } from '../../extension/workspace/doc.js';
|
|
17
|
-
import { Schema } from '../../schema/index.js';
|
|
18
|
-
import type { TransformerMiddleware } from '../../transformer/middleware.js';
|
|
19
|
-
import { Transformer } from '../../transformer/transformer.js';
|
|
20
|
-
import {
|
|
21
|
-
Block,
|
|
22
|
-
type BlockModel,
|
|
23
|
-
type BlockOptions,
|
|
24
|
-
type BlockProps,
|
|
25
|
-
type BlockSysProps,
|
|
26
|
-
type PropsOfModel,
|
|
27
|
-
type YBlock,
|
|
28
|
-
} from '../block/index.js';
|
|
29
|
-
import { DocCRUD } from './crud.js';
|
|
30
|
-
import { StoreIdentifier } from './identifier.js';
|
|
31
|
-
import { type Query, runQuery } from './query.js';
|
|
32
|
-
import { syncBlockProps } from './utils.js';
|
|
33
|
-
|
|
34
|
-
export type StoreOptions = {
|
|
35
|
-
doc: Doc;
|
|
36
|
-
id?: string;
|
|
37
|
-
readonly?: boolean;
|
|
38
|
-
query?: Query;
|
|
39
|
-
provider?: ServiceProvider;
|
|
40
|
-
extensions?: ExtensionType[];
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
type StoreBlockAddedPayload = {
|
|
44
|
-
/**
|
|
45
|
-
* The type of the event.
|
|
46
|
-
*/
|
|
47
|
-
type: 'add';
|
|
48
|
-
/**
|
|
49
|
-
* The id of the block.
|
|
50
|
-
*/
|
|
51
|
-
id: string;
|
|
52
|
-
/**
|
|
53
|
-
* Whether the event is triggered by local changes.
|
|
54
|
-
*/
|
|
55
|
-
isLocal: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* The flavour of the block.
|
|
58
|
-
*/
|
|
59
|
-
flavour: string;
|
|
60
|
-
/**
|
|
61
|
-
* The model of the block.
|
|
62
|
-
*/
|
|
63
|
-
model: BlockModel;
|
|
64
|
-
/**
|
|
65
|
-
* @internal
|
|
66
|
-
* Whether the event is triggered by initialization.
|
|
67
|
-
* FIXME: This seems not working as expected now.
|
|
68
|
-
*/
|
|
69
|
-
init: boolean;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
type StoreBlockDeletedPayload = {
|
|
73
|
-
/**
|
|
74
|
-
* The type of the event.
|
|
75
|
-
*/
|
|
76
|
-
type: 'delete';
|
|
77
|
-
/**
|
|
78
|
-
* The id of the block.
|
|
79
|
-
*/
|
|
80
|
-
id: string;
|
|
81
|
-
/**
|
|
82
|
-
* Whether the event is triggered by local changes.
|
|
83
|
-
*/
|
|
84
|
-
isLocal: boolean;
|
|
85
|
-
/**
|
|
86
|
-
* The flavour of the block.
|
|
87
|
-
*/
|
|
88
|
-
flavour: string;
|
|
89
|
-
/**
|
|
90
|
-
* The parent id of the block.
|
|
91
|
-
*/
|
|
92
|
-
parent: string;
|
|
93
|
-
/**
|
|
94
|
-
* The model of the block.
|
|
95
|
-
*/
|
|
96
|
-
model: BlockModel;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
type StoreBlockUpdatedPayload = {
|
|
100
|
-
/**
|
|
101
|
-
* The type of the event.
|
|
102
|
-
*/
|
|
103
|
-
type: 'update';
|
|
104
|
-
/**
|
|
105
|
-
* The id of the block.
|
|
106
|
-
*/
|
|
107
|
-
id: string;
|
|
108
|
-
/**
|
|
109
|
-
* Whether the event is triggered by local changes.
|
|
110
|
-
*/
|
|
111
|
-
isLocal: boolean;
|
|
112
|
-
/**
|
|
113
|
-
* The flavour of the block.
|
|
114
|
-
*/
|
|
115
|
-
flavour: string;
|
|
116
|
-
/**
|
|
117
|
-
* The changed props of the block.
|
|
118
|
-
*/
|
|
119
|
-
props: { key: string };
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
type StoreBlockUpdatedPayloads =
|
|
123
|
-
| StoreBlockAddedPayload
|
|
124
|
-
| StoreBlockDeletedPayload
|
|
125
|
-
| StoreBlockUpdatedPayload;
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Slots for receiving events from the store.
|
|
129
|
-
* All events are rxjs Subjects, you can subscribe to them like this:
|
|
130
|
-
*
|
|
131
|
-
* ```ts
|
|
132
|
-
* store.slots.ready.subscribe(() => {
|
|
133
|
-
* console.log('store is ready');
|
|
134
|
-
* });
|
|
135
|
-
* ```
|
|
136
|
-
*
|
|
137
|
-
* You can also use rxjs operators to handle the events.
|
|
138
|
-
*
|
|
139
|
-
* @interface
|
|
140
|
-
* @category Store
|
|
141
|
-
*/
|
|
142
|
-
export type StoreSlots = {
|
|
143
|
-
/**
|
|
144
|
-
* This fires after `doc.load` is called.
|
|
145
|
-
* The Y.Doc is fully loaded and ready to use.
|
|
146
|
-
*/
|
|
147
|
-
ready: Subject<void>;
|
|
148
|
-
/**
|
|
149
|
-
* This fires when the root block is added via API call or has just been initialized from existing ydoc.
|
|
150
|
-
* useful for internal block UI components to start subscribing following up events.
|
|
151
|
-
* Note that at this moment, the whole block tree may not be fully initialized yet.
|
|
152
|
-
*/
|
|
153
|
-
rootAdded: Subject<string>;
|
|
154
|
-
/**
|
|
155
|
-
* This fires when the root block is deleted via API call or has just been removed from existing ydoc.
|
|
156
|
-
* In most cases, you don't need to subscribe to this event.
|
|
157
|
-
*/
|
|
158
|
-
rootDeleted: Subject<string>;
|
|
159
|
-
/**
|
|
160
|
-
* This fires when a block is updated via API call or has just been updated from existing ydoc.
|
|
161
|
-
*
|
|
162
|
-
* The payload can have three types:
|
|
163
|
-
* - add: When a new block is added
|
|
164
|
-
* - delete: When a block is removed
|
|
165
|
-
* - update: When a block's properties are modified
|
|
166
|
-
*
|
|
167
|
-
*/
|
|
168
|
-
blockUpdated: Subject<StoreBlockUpdatedPayloads>;
|
|
169
|
-
/** @internal */
|
|
170
|
-
yBlockUpdated: Subject<
|
|
171
|
-
| {
|
|
172
|
-
type: 'add';
|
|
173
|
-
id: string;
|
|
174
|
-
isLocal: boolean;
|
|
175
|
-
}
|
|
176
|
-
| {
|
|
177
|
-
type: 'delete';
|
|
178
|
-
id: string;
|
|
179
|
-
isLocal: boolean;
|
|
180
|
-
}
|
|
181
|
-
>;
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
const internalExtensions = [StoreSelectionExtension, HistoryExtension];
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Core store class that manages blocks and their lifecycle in BlockSuite
|
|
188
|
-
* @remarks
|
|
189
|
-
* The Store class is responsible for managing the lifecycle of blocks, handling transactions,
|
|
190
|
-
* and maintaining the block tree structure.
|
|
191
|
-
* A store is a piece of data created from one or a part of a Y.Doc.
|
|
192
|
-
*
|
|
193
|
-
* @category Store
|
|
194
|
-
*/
|
|
195
|
-
export class Store {
|
|
196
|
-
/** @internal */
|
|
197
|
-
readonly userExtensions: ExtensionType[];
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Group of disposable resources managed by the store
|
|
201
|
-
*
|
|
202
|
-
* @category Store Lifecycle
|
|
203
|
-
*/
|
|
204
|
-
disposableGroup = new DisposableGroup();
|
|
205
|
-
|
|
206
|
-
private readonly _provider: ServiceProvider;
|
|
207
|
-
|
|
208
|
-
private _shouldTransact = true;
|
|
209
|
-
|
|
210
|
-
private readonly _runQuery = (block: Block) => {
|
|
211
|
-
runQuery(this._query, block);
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
private readonly _doc: Doc;
|
|
215
|
-
|
|
216
|
-
private readonly _blocks = signal<Record<string, Block>>({});
|
|
217
|
-
|
|
218
|
-
private readonly _crud: DocCRUD;
|
|
219
|
-
|
|
220
|
-
private readonly _query: Query = {
|
|
221
|
-
match: [],
|
|
222
|
-
mode: 'loose',
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
private readonly _readonly = signal(false);
|
|
226
|
-
|
|
227
|
-
private readonly _isEmpty = computed(() => {
|
|
228
|
-
return this.root?.isEmpty() ?? true;
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
private readonly _schema: Schema;
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Get the id of the store.
|
|
235
|
-
*
|
|
236
|
-
* @category Store Lifecycle
|
|
237
|
-
*/
|
|
238
|
-
get id() {
|
|
239
|
-
return this._doc.id;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* {@inheritDoc StoreSlots}
|
|
244
|
-
*
|
|
245
|
-
* @category Store Lifecycle
|
|
246
|
-
*/
|
|
247
|
-
readonly slots: StoreSlots;
|
|
248
|
-
|
|
249
|
-
private get _yBlocks() {
|
|
250
|
-
return this._doc.yBlocks;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Get the {@link AwarenessStore} instance for current store
|
|
255
|
-
*/
|
|
256
|
-
get awarenessStore() {
|
|
257
|
-
return this._doc.awarenessStore;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Get the di provider for current store.
|
|
262
|
-
*
|
|
263
|
-
* @category Extension
|
|
264
|
-
*/
|
|
265
|
-
get provider() {
|
|
266
|
-
return this._provider;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* Get the {@link BlobEngine} instance for current store.
|
|
271
|
-
*/
|
|
272
|
-
get blobSync() {
|
|
273
|
-
return this.workspace.blobSync;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Get the {@link Doc} instance for current store.
|
|
278
|
-
*/
|
|
279
|
-
get doc() {
|
|
280
|
-
return this._doc;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* @internal
|
|
285
|
-
*/
|
|
286
|
-
get blocks() {
|
|
287
|
-
return this._blocks;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Get the number of blocks in the store
|
|
292
|
-
*
|
|
293
|
-
* @category Block CRUD
|
|
294
|
-
*/
|
|
295
|
-
get blockSize() {
|
|
296
|
-
return Object.values(this._blocks.peek()).length;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* Check if the store can redo
|
|
301
|
-
*
|
|
302
|
-
* @category History
|
|
303
|
-
*/
|
|
304
|
-
get canRedo() {
|
|
305
|
-
if (this.readonly) {
|
|
306
|
-
return false;
|
|
307
|
-
}
|
|
308
|
-
return this._history.canRedo;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Check if the store can undo
|
|
313
|
-
*
|
|
314
|
-
* @category History
|
|
315
|
-
*/
|
|
316
|
-
get canUndo() {
|
|
317
|
-
if (this.readonly) {
|
|
318
|
-
return false;
|
|
319
|
-
}
|
|
320
|
-
return this._history.canUndo;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Undo the last transaction.
|
|
325
|
-
*
|
|
326
|
-
* @category History
|
|
327
|
-
*/
|
|
328
|
-
undo = () => {
|
|
329
|
-
if (this.readonly) {
|
|
330
|
-
console.error('cannot undo in readonly mode');
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
this._history.undoManager.undo();
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Redo the last undone transaction.
|
|
338
|
-
*
|
|
339
|
-
* @category History
|
|
340
|
-
*/
|
|
341
|
-
redo = () => {
|
|
342
|
-
if (this.readonly) {
|
|
343
|
-
console.error('cannot undo in readonly mode');
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
this._history.undoManager.redo();
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Reset the history of the store.
|
|
351
|
-
*
|
|
352
|
-
* @category History
|
|
353
|
-
*/
|
|
354
|
-
resetHistory = () => {
|
|
355
|
-
return this._history.undoManager.clear();
|
|
356
|
-
};
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Execute a transaction.
|
|
360
|
-
*
|
|
361
|
-
* @example
|
|
362
|
-
* ```ts
|
|
363
|
-
* store.transact(() => {
|
|
364
|
-
* op1();
|
|
365
|
-
* op2();
|
|
366
|
-
* });
|
|
367
|
-
* ```
|
|
368
|
-
*
|
|
369
|
-
* @category History
|
|
370
|
-
*/
|
|
371
|
-
transact(fn: () => void, shouldTransact: boolean = this._shouldTransact) {
|
|
372
|
-
const spaceDoc = this._doc.spaceDoc;
|
|
373
|
-
spaceDoc.transact(
|
|
374
|
-
() => {
|
|
375
|
-
try {
|
|
376
|
-
fn();
|
|
377
|
-
} catch (e) {
|
|
378
|
-
console.error(
|
|
379
|
-
`An error occurred while Y.doc ${spaceDoc.guid} transacting:`
|
|
380
|
-
);
|
|
381
|
-
console.error(e);
|
|
382
|
-
}
|
|
383
|
-
},
|
|
384
|
-
shouldTransact ? this.spaceDoc.clientID : null
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* Execute a transaction without capturing the history.
|
|
390
|
-
*
|
|
391
|
-
* @example
|
|
392
|
-
* ```ts
|
|
393
|
-
* store.withoutTransact(() => {
|
|
394
|
-
* op1();
|
|
395
|
-
* op2();
|
|
396
|
-
* });
|
|
397
|
-
* ```
|
|
398
|
-
*
|
|
399
|
-
* @category History
|
|
400
|
-
*/
|
|
401
|
-
withoutTransact(fn: () => void) {
|
|
402
|
-
this._shouldTransact = false;
|
|
403
|
-
fn();
|
|
404
|
-
this._shouldTransact = true;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* Force the following history to be captured into a new stack.
|
|
409
|
-
*
|
|
410
|
-
* @example
|
|
411
|
-
* ```ts
|
|
412
|
-
* op1();
|
|
413
|
-
* op2();
|
|
414
|
-
* store.captureSync();
|
|
415
|
-
* op3();
|
|
416
|
-
*
|
|
417
|
-
* store.undo(); // undo op3
|
|
418
|
-
* store.undo(); // undo op1, op2
|
|
419
|
-
* ```
|
|
420
|
-
*
|
|
421
|
-
* @category History
|
|
422
|
-
*/
|
|
423
|
-
captureSync = () => {
|
|
424
|
-
this._history.undoManager.stopCapturing();
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* Get the {@link Workspace} instance for current store.
|
|
429
|
-
*/
|
|
430
|
-
get workspace() {
|
|
431
|
-
return this._doc.workspace;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
/**
|
|
435
|
-
* Get the {@link Y.UndoManager} instance for current store.
|
|
436
|
-
*
|
|
437
|
-
* @category History
|
|
438
|
-
*/
|
|
439
|
-
get history() {
|
|
440
|
-
return this._history;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* Check if there are no blocks in the store.
|
|
445
|
-
*
|
|
446
|
-
* @category Block CRUD
|
|
447
|
-
*/
|
|
448
|
-
get isEmpty() {
|
|
449
|
-
return this._isEmpty.peek();
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
/**
|
|
453
|
-
* Get the signal for the empty state of the store.
|
|
454
|
-
*
|
|
455
|
-
* @category Block CRUD
|
|
456
|
-
*/
|
|
457
|
-
get isEmpty$() {
|
|
458
|
-
return this._isEmpty;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* Check if the store is loaded.
|
|
463
|
-
*
|
|
464
|
-
* @category Store Lifecycle
|
|
465
|
-
*/
|
|
466
|
-
get loaded() {
|
|
467
|
-
return this._doc.loaded;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
/**
|
|
471
|
-
* Get the meta data of the store.
|
|
472
|
-
*
|
|
473
|
-
* @internal
|
|
474
|
-
*/
|
|
475
|
-
get meta() {
|
|
476
|
-
return this._doc.meta;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
* Check if the store is readonly.
|
|
481
|
-
*
|
|
482
|
-
* @category Block CRUD
|
|
483
|
-
*/
|
|
484
|
-
get readonly() {
|
|
485
|
-
return this._readonly.value === true;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* Get the signal for the readonly state of the store.
|
|
490
|
-
*
|
|
491
|
-
* @category Block CRUD
|
|
492
|
-
*/
|
|
493
|
-
get readonly$() {
|
|
494
|
-
return this._readonly;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
/**
|
|
498
|
-
* Set the readonly state of the store.
|
|
499
|
-
*
|
|
500
|
-
* @category Block CRUD
|
|
501
|
-
*/
|
|
502
|
-
set readonly(value: boolean) {
|
|
503
|
-
this._readonly.value = value;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* Check if the store is ready.
|
|
508
|
-
* Which means the Y.Doc is loaded and the root block is added.
|
|
509
|
-
*
|
|
510
|
-
* @category Store Lifecycle
|
|
511
|
-
*/
|
|
512
|
-
get ready() {
|
|
513
|
-
return this._doc.ready;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* Get the root block of the store.
|
|
518
|
-
*
|
|
519
|
-
* @category Block CRUD
|
|
520
|
-
*/
|
|
521
|
-
get root() {
|
|
522
|
-
const rootId = this._crud.root;
|
|
523
|
-
if (!rootId) return null;
|
|
524
|
-
return this.getBlock(rootId)?.model ?? null;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
/**
|
|
528
|
-
* @internal
|
|
529
|
-
* Get the root Y.Doc of sub Y.Doc.
|
|
530
|
-
* In the current design, store is on a sub Y.Doc, and all sub docs have the same root Y.Doc.
|
|
531
|
-
*/
|
|
532
|
-
get rootDoc() {
|
|
533
|
-
return this._doc.rootDoc;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
/**
|
|
537
|
-
* Get the {@link Schema} instance of the store.
|
|
538
|
-
*/
|
|
539
|
-
get schema() {
|
|
540
|
-
return this._schema;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
/**
|
|
544
|
-
* @internal
|
|
545
|
-
* Get the Y.Doc instance of the store.
|
|
546
|
-
*/
|
|
547
|
-
get spaceDoc() {
|
|
548
|
-
return this._doc.spaceDoc;
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
private _isDisposed = false;
|
|
552
|
-
|
|
553
|
-
private get _history() {
|
|
554
|
-
return this._provider.get(HistoryExtension);
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
/**
|
|
558
|
-
* @internal
|
|
559
|
-
* In most cases, you don't need to use the constructor directly.
|
|
560
|
-
* The store is created by the {@link Doc} instance.
|
|
561
|
-
*/
|
|
562
|
-
constructor({ readonly, query, provider, extensions }: StoreOptions) {
|
|
563
|
-
this.slots = {
|
|
564
|
-
ready: new Subject(),
|
|
565
|
-
rootAdded: new Subject(),
|
|
566
|
-
rootDeleted: new Subject(),
|
|
567
|
-
blockUpdated: new Subject(),
|
|
568
|
-
yBlockUpdated: new Subject(),
|
|
569
|
-
};
|
|
570
|
-
this._schema = new Schema();
|
|
571
|
-
|
|
572
|
-
const container = new Container();
|
|
573
|
-
container.addImpl(StoreIdentifier, () => this);
|
|
574
|
-
|
|
575
|
-
internalExtensions.forEach(ext => {
|
|
576
|
-
ext.setup(container);
|
|
577
|
-
});
|
|
578
|
-
|
|
579
|
-
const userExtensions = extensions ?? [];
|
|
580
|
-
this.userExtensions = userExtensions;
|
|
581
|
-
userExtensions.forEach(extension => {
|
|
582
|
-
extension.setup(container);
|
|
583
|
-
});
|
|
584
|
-
|
|
585
|
-
this._provider = container.provider(undefined, provider);
|
|
586
|
-
this._provider.getAll(BlockSchemaIdentifier).forEach(schema => {
|
|
587
|
-
this._schema.register([schema]);
|
|
588
|
-
});
|
|
589
|
-
this._doc = this._provider.get(DocIdentifier);
|
|
590
|
-
this._crud = new DocCRUD(this._yBlocks, this._schema);
|
|
591
|
-
if (readonly !== undefined) {
|
|
592
|
-
this._readonly.value = readonly;
|
|
593
|
-
}
|
|
594
|
-
if (query) {
|
|
595
|
-
this._query = query;
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
this._yBlocks.observeDeep(this._handleYEvents);
|
|
599
|
-
this._yBlocks.forEach((_, id) => {
|
|
600
|
-
this._handleYBlockAdd(id, false);
|
|
601
|
-
|
|
602
|
-
if (id in this._blocks.peek()) {
|
|
603
|
-
return;
|
|
604
|
-
}
|
|
605
|
-
this._onBlockAdded(id, false, true);
|
|
606
|
-
});
|
|
607
|
-
|
|
608
|
-
this._subscribeToSlots();
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
private readonly _subscribeToSlots = () => {
|
|
612
|
-
this.disposableGroup.add(
|
|
613
|
-
this.slots.yBlockUpdated.subscribe(({ type, id, isLocal }) => {
|
|
614
|
-
switch (type) {
|
|
615
|
-
case 'add': {
|
|
616
|
-
this._onBlockAdded(id, isLocal, false);
|
|
617
|
-
return;
|
|
618
|
-
}
|
|
619
|
-
case 'delete': {
|
|
620
|
-
this._onBlockRemoved(id, isLocal);
|
|
621
|
-
return;
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
})
|
|
625
|
-
);
|
|
626
|
-
this.disposableGroup.add(this.slots.ready);
|
|
627
|
-
this.disposableGroup.add(this.slots.blockUpdated);
|
|
628
|
-
this.disposableGroup.add(this.slots.rootAdded);
|
|
629
|
-
this.disposableGroup.add(this.slots.rootDeleted);
|
|
630
|
-
};
|
|
631
|
-
|
|
632
|
-
private _getSiblings<T>(
|
|
633
|
-
block: BlockModel | string,
|
|
634
|
-
fn: (parent: BlockModel, index: number) => T
|
|
635
|
-
) {
|
|
636
|
-
const parent = this.getParent(block);
|
|
637
|
-
if (!parent) return null;
|
|
638
|
-
|
|
639
|
-
const blockModel =
|
|
640
|
-
typeof block === 'string' ? this.getBlock(block)?.model : block;
|
|
641
|
-
if (!blockModel) return null;
|
|
642
|
-
|
|
643
|
-
const index = parent.children.indexOf(blockModel);
|
|
644
|
-
if (index === -1) return null;
|
|
645
|
-
|
|
646
|
-
return fn(parent, index);
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
private _onBlockAdded(id: string, isLocal: boolean, init: boolean) {
|
|
650
|
-
try {
|
|
651
|
-
if (id in this._blocks.peek()) {
|
|
652
|
-
return;
|
|
653
|
-
}
|
|
654
|
-
const yBlock = this._yBlocks.get(id);
|
|
655
|
-
if (!yBlock) {
|
|
656
|
-
console.warn(`Could not find block with id ${id}`);
|
|
657
|
-
return;
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
const options: BlockOptions = {
|
|
661
|
-
onChange: (block, key, isLocal) => {
|
|
662
|
-
if (key) {
|
|
663
|
-
block.model.propsUpdated.next({ key });
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
this.slots.blockUpdated.next({
|
|
667
|
-
type: 'update',
|
|
668
|
-
id,
|
|
669
|
-
flavour: block.flavour,
|
|
670
|
-
props: { key },
|
|
671
|
-
isLocal,
|
|
672
|
-
});
|
|
673
|
-
},
|
|
674
|
-
};
|
|
675
|
-
|
|
676
|
-
const block = new Block(this._schema, yBlock, this, options);
|
|
677
|
-
this._runQuery(block);
|
|
678
|
-
|
|
679
|
-
this._blocks.value = {
|
|
680
|
-
...this._blocks.value,
|
|
681
|
-
[id]: block,
|
|
682
|
-
};
|
|
683
|
-
block.model.created.next();
|
|
684
|
-
|
|
685
|
-
if (block.model.role === 'root') {
|
|
686
|
-
this.slots.rootAdded.next(id);
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
this.slots.blockUpdated.next({
|
|
690
|
-
type: 'add',
|
|
691
|
-
id,
|
|
692
|
-
init,
|
|
693
|
-
flavour: block.model.flavour,
|
|
694
|
-
model: block.model,
|
|
695
|
-
isLocal,
|
|
696
|
-
});
|
|
697
|
-
} catch (e) {
|
|
698
|
-
console.error('An error occurred while adding block:');
|
|
699
|
-
console.error(e);
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
private _onBlockRemoved(id: string, isLocal: boolean) {
|
|
704
|
-
try {
|
|
705
|
-
const block = this.getBlock(id);
|
|
706
|
-
if (!block) return;
|
|
707
|
-
|
|
708
|
-
if (block.model.role === 'root') {
|
|
709
|
-
this.slots.rootDeleted.next(id);
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
this.slots.blockUpdated.next({
|
|
713
|
-
type: 'delete',
|
|
714
|
-
id,
|
|
715
|
-
flavour: block.flavour,
|
|
716
|
-
parent: this.getParent(block.model)?.id ?? '',
|
|
717
|
-
model: block.model,
|
|
718
|
-
isLocal,
|
|
719
|
-
});
|
|
720
|
-
|
|
721
|
-
const { [id]: _, ...blocks } = this._blocks.peek();
|
|
722
|
-
this._blocks.value = blocks;
|
|
723
|
-
|
|
724
|
-
block.model.deleted.next();
|
|
725
|
-
block.model.dispose();
|
|
726
|
-
} catch (e) {
|
|
727
|
-
console.error('An error occurred while removing block:');
|
|
728
|
-
console.error(e);
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
/**
|
|
733
|
-
* Creates and adds a new block to the store
|
|
734
|
-
* @param flavour - The block's flavour (type)
|
|
735
|
-
* @param blockProps - Optional properties for the new block
|
|
736
|
-
* @param parent - Optional parent block or parent block ID
|
|
737
|
-
* @param parentIndex - Optional index position in parent's children
|
|
738
|
-
* @returns The ID of the newly created block
|
|
739
|
-
* @throws {BlockSuiteError} When store is in readonly mode
|
|
740
|
-
*
|
|
741
|
-
* @category Block CRUD
|
|
742
|
-
*/
|
|
743
|
-
addBlock<T extends BlockModel = BlockModel>(
|
|
744
|
-
flavour: string,
|
|
745
|
-
blockProps: Partial<(PropsOfModel<T> & BlockSysProps) | BlockProps> = {},
|
|
746
|
-
parent?: BlockModel | string | null,
|
|
747
|
-
parentIndex?: number
|
|
748
|
-
): string {
|
|
749
|
-
if (this.readonly) {
|
|
750
|
-
throw new BlockSuiteError(
|
|
751
|
-
ErrorCode.ModelCRUDError,
|
|
752
|
-
'cannot modify data in readonly mode'
|
|
753
|
-
);
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
const id = blockProps.id ?? this._doc.workspace.idGenerator();
|
|
757
|
-
|
|
758
|
-
this.transact(() => {
|
|
759
|
-
this._crud.addBlock(
|
|
760
|
-
id,
|
|
761
|
-
flavour,
|
|
762
|
-
{ ...blockProps },
|
|
763
|
-
typeof parent === 'string' ? parent : parent?.id,
|
|
764
|
-
parentIndex
|
|
765
|
-
);
|
|
766
|
-
});
|
|
767
|
-
|
|
768
|
-
return id;
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
/**
|
|
772
|
-
* Add multiple blocks to the store
|
|
773
|
-
* @param blocks - Array of blocks to add
|
|
774
|
-
* @param parent - Optional parent block or parent block ID
|
|
775
|
-
* @param parentIndex - Optional index position in parent's children
|
|
776
|
-
* @returns Array of IDs of the newly created blocks
|
|
777
|
-
*
|
|
778
|
-
* @category Block CRUD
|
|
779
|
-
*/
|
|
780
|
-
addBlocks(
|
|
781
|
-
blocks: Array<{
|
|
782
|
-
flavour: string;
|
|
783
|
-
blockProps?: Partial<BlockProps & Omit<BlockProps, 'flavour' | 'id'>>;
|
|
784
|
-
}>,
|
|
785
|
-
parent?: BlockModel | string | null,
|
|
786
|
-
parentIndex?: number
|
|
787
|
-
): string[] {
|
|
788
|
-
const ids: string[] = [];
|
|
789
|
-
blocks.forEach(block => {
|
|
790
|
-
const id = this.addBlock(
|
|
791
|
-
block.flavour as never,
|
|
792
|
-
block.blockProps ?? {},
|
|
793
|
-
parent,
|
|
794
|
-
parentIndex
|
|
795
|
-
);
|
|
796
|
-
ids.push(id);
|
|
797
|
-
typeof parentIndex === 'number' && parentIndex++;
|
|
798
|
-
});
|
|
799
|
-
|
|
800
|
-
return ids;
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
/**
|
|
804
|
-
* Add sibling blocks to the store
|
|
805
|
-
* @param targetModel - The target block model
|
|
806
|
-
* @param props - Array of block properties
|
|
807
|
-
* @param placement - Optional position to place the new blocks ('after' or 'before')
|
|
808
|
-
* @returns Array of IDs of the newly created blocks
|
|
809
|
-
*
|
|
810
|
-
* @category Block CRUD
|
|
811
|
-
*/
|
|
812
|
-
addSiblingBlocks(
|
|
813
|
-
targetModel: BlockModel,
|
|
814
|
-
props: Array<Partial<BlockProps>>,
|
|
815
|
-
placement: 'after' | 'before' = 'after'
|
|
816
|
-
): string[] {
|
|
817
|
-
if (!props.length) return [];
|
|
818
|
-
const parent = this.getParent(targetModel);
|
|
819
|
-
if (!parent) return [];
|
|
820
|
-
|
|
821
|
-
const targetIndex =
|
|
822
|
-
parent.children.findIndex(({ id }) => id === targetModel.id) ?? 0;
|
|
823
|
-
const insertIndex = placement === 'before' ? targetIndex : targetIndex + 1;
|
|
824
|
-
|
|
825
|
-
if (props.length <= 1) {
|
|
826
|
-
if (!props[0]?.flavour) return [];
|
|
827
|
-
const { flavour, ...blockProps } = props[0];
|
|
828
|
-
const id = this.addBlock(
|
|
829
|
-
flavour as never,
|
|
830
|
-
blockProps,
|
|
831
|
-
parent.id,
|
|
832
|
-
insertIndex
|
|
833
|
-
);
|
|
834
|
-
return [id];
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
const blocks: Array<{
|
|
838
|
-
flavour: string;
|
|
839
|
-
blockProps: Partial<BlockProps>;
|
|
840
|
-
}> = [];
|
|
841
|
-
props.forEach(prop => {
|
|
842
|
-
const { flavour, ...blockProps } = prop;
|
|
843
|
-
if (!flavour) return;
|
|
844
|
-
blocks.push({ flavour, blockProps });
|
|
845
|
-
});
|
|
846
|
-
return this.addBlocks(blocks, parent.id, insertIndex);
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
/**
|
|
850
|
-
* Updates a block's properties or executes a callback in a transaction
|
|
851
|
-
* @param modelOrId - The block model or block ID to update
|
|
852
|
-
* @param callBackOrProps - Either a callback function to execute or properties to update
|
|
853
|
-
* @throws {BlockSuiteError} When the block is not found or schema validation fails
|
|
854
|
-
*
|
|
855
|
-
* @category Block CRUD
|
|
856
|
-
*/
|
|
857
|
-
|
|
858
|
-
updateBlock<T extends BlockModel = BlockModel>(
|
|
859
|
-
modelOrId: T | string,
|
|
860
|
-
callBackOrProps:
|
|
861
|
-
| (() => void)
|
|
862
|
-
| Partial<(PropsOfModel<T> & BlockSysProps) | BlockProps>
|
|
863
|
-
) {
|
|
864
|
-
if (this.readonly) {
|
|
865
|
-
console.error('cannot modify data in readonly mode');
|
|
866
|
-
return;
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
const isCallback = typeof callBackOrProps === 'function';
|
|
870
|
-
|
|
871
|
-
const model =
|
|
872
|
-
typeof modelOrId === 'string'
|
|
873
|
-
? this.getBlock(modelOrId)?.model
|
|
874
|
-
: modelOrId;
|
|
875
|
-
if (!model) {
|
|
876
|
-
throw new BlockSuiteError(
|
|
877
|
-
ErrorCode.ModelCRUDError,
|
|
878
|
-
`updating block: ${modelOrId} not found`
|
|
879
|
-
);
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
if (!isCallback) {
|
|
883
|
-
const parent = this.getParent(model);
|
|
884
|
-
this.schema.validate(
|
|
885
|
-
model.flavour,
|
|
886
|
-
parent?.flavour,
|
|
887
|
-
callBackOrProps.children?.map(child => child.flavour)
|
|
888
|
-
);
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
const yBlock = this._yBlocks.get(model.id);
|
|
892
|
-
if (!yBlock) {
|
|
893
|
-
throw new BlockSuiteError(
|
|
894
|
-
ErrorCode.ModelCRUDError,
|
|
895
|
-
`updating block: ${model.id} not found`
|
|
896
|
-
);
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
const block = this.getBlock(model.id);
|
|
900
|
-
if (!block) return;
|
|
901
|
-
|
|
902
|
-
this.transact(() => {
|
|
903
|
-
if (isCallback) {
|
|
904
|
-
callBackOrProps();
|
|
905
|
-
this._runQuery(block);
|
|
906
|
-
return;
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
if (callBackOrProps.children) {
|
|
910
|
-
this._crud.updateBlockChildren(
|
|
911
|
-
model.id,
|
|
912
|
-
callBackOrProps.children.map(child => child.id)
|
|
913
|
-
);
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
const schema = this.schema.flavourSchemaMap.get(model.flavour);
|
|
917
|
-
if (!schema) {
|
|
918
|
-
throw new BlockSuiteError(
|
|
919
|
-
ErrorCode.ModelCRUDError,
|
|
920
|
-
`schema for flavour: ${model.flavour} not found`
|
|
921
|
-
);
|
|
922
|
-
}
|
|
923
|
-
syncBlockProps(schema, model, yBlock, callBackOrProps);
|
|
924
|
-
this._runQuery(block);
|
|
925
|
-
return;
|
|
926
|
-
});
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
/**
|
|
930
|
-
* Delete a block from the store
|
|
931
|
-
* @param model - The block model or block ID to delete
|
|
932
|
-
* @param options - Optional options for the deletion
|
|
933
|
-
* @param options.bringChildrenTo - Optional block model to bring children to
|
|
934
|
-
* @param options.deleteChildren - Optional flag to delete children
|
|
935
|
-
*
|
|
936
|
-
* @category Block CRUD
|
|
937
|
-
*/
|
|
938
|
-
deleteBlock(
|
|
939
|
-
model: BlockModel | string,
|
|
940
|
-
options: {
|
|
941
|
-
bringChildrenTo?: BlockModel;
|
|
942
|
-
deleteChildren?: boolean;
|
|
943
|
-
} = {
|
|
944
|
-
deleteChildren: true,
|
|
945
|
-
}
|
|
946
|
-
) {
|
|
947
|
-
if (this.readonly) {
|
|
948
|
-
console.error('cannot modify data in readonly mode');
|
|
949
|
-
return;
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
const opts = (
|
|
953
|
-
options && options.bringChildrenTo
|
|
954
|
-
? {
|
|
955
|
-
...options,
|
|
956
|
-
bringChildrenTo: options.bringChildrenTo.id,
|
|
957
|
-
}
|
|
958
|
-
: options
|
|
959
|
-
) as {
|
|
960
|
-
bringChildrenTo?: string;
|
|
961
|
-
deleteChildren?: boolean;
|
|
962
|
-
};
|
|
963
|
-
|
|
964
|
-
this.transact(() => {
|
|
965
|
-
this._crud.deleteBlock(
|
|
966
|
-
typeof model === 'string' ? model : model.id,
|
|
967
|
-
opts
|
|
968
|
-
);
|
|
969
|
-
});
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
/**
|
|
973
|
-
* Gets a block by its ID
|
|
974
|
-
* @param id - The block's ID
|
|
975
|
-
* @returns The block instance if found, undefined otherwise
|
|
976
|
-
*
|
|
977
|
-
* @category Block CRUD
|
|
978
|
-
*/
|
|
979
|
-
getBlock(id: string): Block | undefined {
|
|
980
|
-
return this._blocks.peek()[id];
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
/**
|
|
984
|
-
* Gets a block by its ID
|
|
985
|
-
* @param id - The block's ID
|
|
986
|
-
* @returns The block instance in signal if found, undefined otherwise
|
|
987
|
-
*
|
|
988
|
-
* @category Block CRUD
|
|
989
|
-
*/
|
|
990
|
-
getBlock$(id: string): Block | undefined {
|
|
991
|
-
return this._blocks.value[id];
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
/**
|
|
995
|
-
* Get a model by its ID
|
|
996
|
-
* @param id - The model's ID
|
|
997
|
-
* @returns The model instance if found, null otherwise
|
|
998
|
-
*
|
|
999
|
-
* @category Block CRUD
|
|
1000
|
-
*/
|
|
1001
|
-
getModelById<Model extends BlockModel = BlockModel>(
|
|
1002
|
-
id: string
|
|
1003
|
-
): Model | null {
|
|
1004
|
-
return (this.getBlock(id)?.model ?? null) as Model | null;
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
/**
|
|
1008
|
-
* Gets all blocks of specified flavour(s)
|
|
1009
|
-
* @param blockFlavour - Single flavour or array of flavours to filter by
|
|
1010
|
-
* @returns Array of matching blocks
|
|
1011
|
-
*
|
|
1012
|
-
* @category Block CRUD
|
|
1013
|
-
*/
|
|
1014
|
-
getBlocksByFlavour(blockFlavour: string | string[]): Block[] {
|
|
1015
|
-
const flavours =
|
|
1016
|
-
typeof blockFlavour === 'string' ? [blockFlavour] : blockFlavour;
|
|
1017
|
-
|
|
1018
|
-
return Object.values(this._blocks.peek()).filter(({ flavour }) =>
|
|
1019
|
-
flavours.includes(flavour)
|
|
1020
|
-
);
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
/**
|
|
1024
|
-
* Get all models in the store
|
|
1025
|
-
* @returns Array of all models
|
|
1026
|
-
*
|
|
1027
|
-
* @category Block CRUD
|
|
1028
|
-
*/
|
|
1029
|
-
getAllModels() {
|
|
1030
|
-
return Object.values(this._blocks.peek()).map(block => block.model);
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
/**
|
|
1034
|
-
* Get all models of specified flavour(s)
|
|
1035
|
-
* @param blockFlavour - Single flavour or array of flavours to filter by
|
|
1036
|
-
* @returns Array of matching models
|
|
1037
|
-
*
|
|
1038
|
-
* @category Block CRUD
|
|
1039
|
-
*/
|
|
1040
|
-
getModelsByFlavour(blockFlavour: string | string[]): BlockModel[] {
|
|
1041
|
-
return this.getBlocksByFlavour(blockFlavour).map(x => x.model);
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
/**
|
|
1045
|
-
* Gets the parent block of a given block
|
|
1046
|
-
* @param target - Block model or block ID to find parent for
|
|
1047
|
-
* @returns The parent block model if found, null otherwise
|
|
1048
|
-
*
|
|
1049
|
-
* @category Block CRUD
|
|
1050
|
-
*/
|
|
1051
|
-
getParent(target: BlockModel | string): BlockModel | null {
|
|
1052
|
-
const targetId = typeof target === 'string' ? target : target.id;
|
|
1053
|
-
const parentId = this._crud.getParent(targetId);
|
|
1054
|
-
if (!parentId) return null;
|
|
1055
|
-
|
|
1056
|
-
const parent = this._blocks.peek()[parentId];
|
|
1057
|
-
if (!parent) return null;
|
|
1058
|
-
|
|
1059
|
-
return parent.model;
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
/**
|
|
1063
|
-
* Get the previous sibling block of a given block
|
|
1064
|
-
* @param block - Block model or block ID to find previous sibling for
|
|
1065
|
-
* @returns The previous sibling block model if found, null otherwise
|
|
1066
|
-
*
|
|
1067
|
-
* @category Block CRUD
|
|
1068
|
-
*/
|
|
1069
|
-
getPrev(block: BlockModel | string) {
|
|
1070
|
-
return this._getSiblings(
|
|
1071
|
-
block,
|
|
1072
|
-
(parent, index) => parent.children[index - 1] ?? null
|
|
1073
|
-
);
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
/**
|
|
1077
|
-
* Get all previous sibling blocks of a given block
|
|
1078
|
-
* @param block - Block model or block ID to find previous siblings for
|
|
1079
|
-
* @returns Array of previous sibling blocks if found, empty array otherwise
|
|
1080
|
-
*
|
|
1081
|
-
* @category Block CRUD
|
|
1082
|
-
*/
|
|
1083
|
-
getPrevs(block: BlockModel | string) {
|
|
1084
|
-
return (
|
|
1085
|
-
this._getSiblings(block, (parent, index) =>
|
|
1086
|
-
parent.children.slice(0, index)
|
|
1087
|
-
) ?? []
|
|
1088
|
-
);
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
/**
|
|
1092
|
-
* Get the next sibling block of a given block
|
|
1093
|
-
* @param block - Block model or block ID to find next sibling for
|
|
1094
|
-
* @returns The next sibling block model if found, null otherwise
|
|
1095
|
-
*
|
|
1096
|
-
* @category Block CRUD
|
|
1097
|
-
*/
|
|
1098
|
-
getNext(block: BlockModel | string) {
|
|
1099
|
-
return this._getSiblings(
|
|
1100
|
-
block,
|
|
1101
|
-
(parent, index) => parent.children[index + 1] ?? null
|
|
1102
|
-
);
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
/**
|
|
1106
|
-
* Get all next sibling blocks of a given block
|
|
1107
|
-
* @param block - Block model or block ID to find next siblings for
|
|
1108
|
-
* @returns Array of next sibling blocks if found, empty array otherwise
|
|
1109
|
-
*
|
|
1110
|
-
* @category Block CRUD
|
|
1111
|
-
*/
|
|
1112
|
-
getNexts(block: BlockModel | string) {
|
|
1113
|
-
return (
|
|
1114
|
-
this._getSiblings(block, (parent, index) =>
|
|
1115
|
-
parent.children.slice(index + 1)
|
|
1116
|
-
) ?? []
|
|
1117
|
-
);
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
/**
|
|
1121
|
-
* Check if a block exists by its ID
|
|
1122
|
-
* @param id - The block's ID
|
|
1123
|
-
* @returns True if the block exists, false otherwise
|
|
1124
|
-
*
|
|
1125
|
-
* @category Block CRUD
|
|
1126
|
-
*/
|
|
1127
|
-
hasBlock(id: string) {
|
|
1128
|
-
return id in this._blocks.peek();
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
/**
|
|
1132
|
-
* Move blocks to a new parent block
|
|
1133
|
-
* @param blocksToMove - Array of block models to move
|
|
1134
|
-
* @param newParent - The new parent block model
|
|
1135
|
-
* @param targetSibling - Optional target sibling block model
|
|
1136
|
-
* @param shouldInsertBeforeSibling - Optional flag to insert before sibling
|
|
1137
|
-
*
|
|
1138
|
-
* @category Block CRUD
|
|
1139
|
-
*/
|
|
1140
|
-
moveBlocks(
|
|
1141
|
-
blocksToMove: BlockModel[],
|
|
1142
|
-
newParent: BlockModel,
|
|
1143
|
-
targetSibling: BlockModel | null = null,
|
|
1144
|
-
shouldInsertBeforeSibling = true
|
|
1145
|
-
) {
|
|
1146
|
-
if (this.readonly) {
|
|
1147
|
-
console.error('Cannot modify data in read-only mode');
|
|
1148
|
-
return;
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
this.transact(() => {
|
|
1152
|
-
this._crud.moveBlocks(
|
|
1153
|
-
blocksToMove.map(model => model.id),
|
|
1154
|
-
newParent.id,
|
|
1155
|
-
targetSibling?.id ?? null,
|
|
1156
|
-
shouldInsertBeforeSibling
|
|
1157
|
-
);
|
|
1158
|
-
});
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
/**
|
|
1162
|
-
* Creates a new transformer instance for the store
|
|
1163
|
-
* @param middlewares - Optional array of transformer middlewares
|
|
1164
|
-
* @returns A new Transformer instance
|
|
1165
|
-
*
|
|
1166
|
-
* @category Transformer
|
|
1167
|
-
*/
|
|
1168
|
-
getTransformer(middlewares: TransformerMiddleware[] = []) {
|
|
1169
|
-
return new Transformer({
|
|
1170
|
-
schema: this.schema,
|
|
1171
|
-
blobCRUD: this.workspace.blobSync,
|
|
1172
|
-
docCRUD: {
|
|
1173
|
-
create: (id: string) => this.workspace.createDoc(id).getStore({ id }),
|
|
1174
|
-
get: (id: string) =>
|
|
1175
|
-
this.workspace.getDoc(id)?.getStore({ id }) ?? null,
|
|
1176
|
-
delete: (id: string) => this.workspace.removeDoc(id),
|
|
1177
|
-
},
|
|
1178
|
-
middlewares,
|
|
1179
|
-
});
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
|
-
/**
|
|
1183
|
-
* Get an extension instance from the store
|
|
1184
|
-
* @returns The extension instance
|
|
1185
|
-
*
|
|
1186
|
-
* @example
|
|
1187
|
-
* ```ts
|
|
1188
|
-
* const extension = store.get(SomeExtension);
|
|
1189
|
-
* ```
|
|
1190
|
-
*
|
|
1191
|
-
* @category Extension
|
|
1192
|
-
*/
|
|
1193
|
-
get get() {
|
|
1194
|
-
return this.provider.get.bind(this.provider);
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1197
|
-
/**
|
|
1198
|
-
* Optional get an extension instance from the store.
|
|
1199
|
-
* The major difference between `get` and `getOptional` is that `getOptional` will not throw an error if the extension is not found.
|
|
1200
|
-
*
|
|
1201
|
-
* @returns The extension instance
|
|
1202
|
-
*
|
|
1203
|
-
* @example
|
|
1204
|
-
* ```ts
|
|
1205
|
-
* const extension = store.getOptional(SomeExtension);
|
|
1206
|
-
* ```
|
|
1207
|
-
*
|
|
1208
|
-
* @category Extension
|
|
1209
|
-
*/
|
|
1210
|
-
get getOptional() {
|
|
1211
|
-
return this.provider.getOptional.bind(this.provider);
|
|
1212
|
-
}
|
|
1213
|
-
|
|
1214
|
-
/**
|
|
1215
|
-
* Initializes and loads the store
|
|
1216
|
-
* @param initFn - Optional initialization function
|
|
1217
|
-
* @returns The store instance
|
|
1218
|
-
*
|
|
1219
|
-
* @category Store Lifecycle
|
|
1220
|
-
*/
|
|
1221
|
-
load(initFn?: () => void) {
|
|
1222
|
-
if (this._isDisposed) {
|
|
1223
|
-
this.disposableGroup = new DisposableGroup();
|
|
1224
|
-
this._subscribeToSlots();
|
|
1225
|
-
this._isDisposed = false;
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
this._doc.load(initFn);
|
|
1229
|
-
this._provider.getAll(StoreExtensionIdentifier).forEach(ext => {
|
|
1230
|
-
ext.loaded();
|
|
1231
|
-
});
|
|
1232
|
-
this.slots.ready.next();
|
|
1233
|
-
this.slots.rootAdded.next(this.root?.id ?? '');
|
|
1234
|
-
return this;
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
/**
|
|
1238
|
-
* Disposes the store and releases all resources
|
|
1239
|
-
*
|
|
1240
|
-
* @category Store Lifecycle
|
|
1241
|
-
*/
|
|
1242
|
-
dispose() {
|
|
1243
|
-
this._provider.getAll(StoreExtensionIdentifier).forEach(ext => {
|
|
1244
|
-
ext.disposed();
|
|
1245
|
-
});
|
|
1246
|
-
if (this._doc.ready) {
|
|
1247
|
-
this._yBlocks.unobserveDeep(this._handleYEvents);
|
|
1248
|
-
}
|
|
1249
|
-
this.slots.ready.complete();
|
|
1250
|
-
this.slots.rootAdded.complete();
|
|
1251
|
-
this.slots.rootDeleted.complete();
|
|
1252
|
-
this.slots.blockUpdated.complete();
|
|
1253
|
-
this.slots.yBlockUpdated.complete();
|
|
1254
|
-
this.disposableGroup.dispose();
|
|
1255
|
-
this._isDisposed = true;
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
private _handleYBlockAdd(id: string, isLocal: boolean) {
|
|
1259
|
-
this.slots.yBlockUpdated.next({ type: 'add', id, isLocal });
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
private _handleYBlockDelete(id: string, isLocal: boolean) {
|
|
1263
|
-
this.slots.yBlockUpdated.next({ type: 'delete', id, isLocal });
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1266
|
-
private _handleYEvent(event: Y.YEvent<YBlock | Y.Text | Y.Array<unknown>>) {
|
|
1267
|
-
// event on top-level block store
|
|
1268
|
-
if (event.target !== this._yBlocks) {
|
|
1269
|
-
return;
|
|
1270
|
-
}
|
|
1271
|
-
const isLocal =
|
|
1272
|
-
!event.transaction.origin ||
|
|
1273
|
-
!this._yBlocks.doc ||
|
|
1274
|
-
event.transaction.origin instanceof Y.UndoManager ||
|
|
1275
|
-
event.transaction.origin.proxy
|
|
1276
|
-
? true
|
|
1277
|
-
: event.transaction.origin === this._yBlocks.doc.clientID;
|
|
1278
|
-
event.keys.forEach((value, id) => {
|
|
1279
|
-
try {
|
|
1280
|
-
if (value.action === 'add') {
|
|
1281
|
-
this._handleYBlockAdd(id, isLocal);
|
|
1282
|
-
return;
|
|
1283
|
-
}
|
|
1284
|
-
if (value.action === 'delete') {
|
|
1285
|
-
this._handleYBlockDelete(id, isLocal);
|
|
1286
|
-
return;
|
|
1287
|
-
}
|
|
1288
|
-
} catch (e) {
|
|
1289
|
-
console.error('An error occurred while handling Yjs event:');
|
|
1290
|
-
console.error(e);
|
|
1291
|
-
}
|
|
1292
|
-
});
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
private readonly _handleYEvents = (events: Y.YEvent<YBlock | Y.Text>[]) => {
|
|
1296
|
-
events.forEach(event => this._handleYEvent(event));
|
|
1297
|
-
};
|
|
1298
|
-
}
|
|
1
|
+
import { Container, type ServiceProvider } from '../../../global/di/index.js';
|
|
2
|
+
import { DisposableGroup } from '../../../global/disposable/index.js';
|
|
3
|
+
import { BlockSuiteError, ErrorCode } from '../../../global/exceptions/index.js';
|
|
4
|
+
import { computed, signal } from '@preact/signals-core';
|
|
5
|
+
import { Subject } from 'rxjs';
|
|
6
|
+
import * as Y from 'yjs';
|
|
7
|
+
|
|
8
|
+
import type { ExtensionType } from '../../extension/extension.js';
|
|
9
|
+
import {
|
|
10
|
+
BlockSchemaIdentifier,
|
|
11
|
+
type Doc,
|
|
12
|
+
HistoryExtension,
|
|
13
|
+
StoreExtensionIdentifier,
|
|
14
|
+
StoreSelectionExtension,
|
|
15
|
+
} from '../../extension/index.js';
|
|
16
|
+
import { DocIdentifier } from '../../extension/workspace/doc.js';
|
|
17
|
+
import { Schema } from '../../schema/index.js';
|
|
18
|
+
import type { TransformerMiddleware } from '../../transformer/middleware.js';
|
|
19
|
+
import { Transformer } from '../../transformer/transformer.js';
|
|
20
|
+
import {
|
|
21
|
+
Block,
|
|
22
|
+
type BlockModel,
|
|
23
|
+
type BlockOptions,
|
|
24
|
+
type BlockProps,
|
|
25
|
+
type BlockSysProps,
|
|
26
|
+
type PropsOfModel,
|
|
27
|
+
type YBlock,
|
|
28
|
+
} from '../block/index.js';
|
|
29
|
+
import { DocCRUD } from './crud.js';
|
|
30
|
+
import { StoreIdentifier } from './identifier.js';
|
|
31
|
+
import { type Query, runQuery } from './query.js';
|
|
32
|
+
import { syncBlockProps } from './utils.js';
|
|
33
|
+
|
|
34
|
+
export type StoreOptions = {
|
|
35
|
+
doc: Doc;
|
|
36
|
+
id?: string;
|
|
37
|
+
readonly?: boolean;
|
|
38
|
+
query?: Query;
|
|
39
|
+
provider?: ServiceProvider;
|
|
40
|
+
extensions?: ExtensionType[];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
type StoreBlockAddedPayload = {
|
|
44
|
+
/**
|
|
45
|
+
* The type of the event.
|
|
46
|
+
*/
|
|
47
|
+
type: 'add';
|
|
48
|
+
/**
|
|
49
|
+
* The id of the block.
|
|
50
|
+
*/
|
|
51
|
+
id: string;
|
|
52
|
+
/**
|
|
53
|
+
* Whether the event is triggered by local changes.
|
|
54
|
+
*/
|
|
55
|
+
isLocal: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The flavour of the block.
|
|
58
|
+
*/
|
|
59
|
+
flavour: string;
|
|
60
|
+
/**
|
|
61
|
+
* The model of the block.
|
|
62
|
+
*/
|
|
63
|
+
model: BlockModel;
|
|
64
|
+
/**
|
|
65
|
+
* @internal
|
|
66
|
+
* Whether the event is triggered by initialization.
|
|
67
|
+
* FIXME: This seems not working as expected now.
|
|
68
|
+
*/
|
|
69
|
+
init: boolean;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
type StoreBlockDeletedPayload = {
|
|
73
|
+
/**
|
|
74
|
+
* The type of the event.
|
|
75
|
+
*/
|
|
76
|
+
type: 'delete';
|
|
77
|
+
/**
|
|
78
|
+
* The id of the block.
|
|
79
|
+
*/
|
|
80
|
+
id: string;
|
|
81
|
+
/**
|
|
82
|
+
* Whether the event is triggered by local changes.
|
|
83
|
+
*/
|
|
84
|
+
isLocal: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* The flavour of the block.
|
|
87
|
+
*/
|
|
88
|
+
flavour: string;
|
|
89
|
+
/**
|
|
90
|
+
* The parent id of the block.
|
|
91
|
+
*/
|
|
92
|
+
parent: string;
|
|
93
|
+
/**
|
|
94
|
+
* The model of the block.
|
|
95
|
+
*/
|
|
96
|
+
model: BlockModel;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
type StoreBlockUpdatedPayload = {
|
|
100
|
+
/**
|
|
101
|
+
* The type of the event.
|
|
102
|
+
*/
|
|
103
|
+
type: 'update';
|
|
104
|
+
/**
|
|
105
|
+
* The id of the block.
|
|
106
|
+
*/
|
|
107
|
+
id: string;
|
|
108
|
+
/**
|
|
109
|
+
* Whether the event is triggered by local changes.
|
|
110
|
+
*/
|
|
111
|
+
isLocal: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* The flavour of the block.
|
|
114
|
+
*/
|
|
115
|
+
flavour: string;
|
|
116
|
+
/**
|
|
117
|
+
* The changed props of the block.
|
|
118
|
+
*/
|
|
119
|
+
props: { key: string };
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
type StoreBlockUpdatedPayloads =
|
|
123
|
+
| StoreBlockAddedPayload
|
|
124
|
+
| StoreBlockDeletedPayload
|
|
125
|
+
| StoreBlockUpdatedPayload;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Slots for receiving events from the store.
|
|
129
|
+
* All events are rxjs Subjects, you can subscribe to them like this:
|
|
130
|
+
*
|
|
131
|
+
* ```ts
|
|
132
|
+
* store.slots.ready.subscribe(() => {
|
|
133
|
+
* console.log('store is ready');
|
|
134
|
+
* });
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* You can also use rxjs operators to handle the events.
|
|
138
|
+
*
|
|
139
|
+
* @interface
|
|
140
|
+
* @category Store
|
|
141
|
+
*/
|
|
142
|
+
export type StoreSlots = {
|
|
143
|
+
/**
|
|
144
|
+
* This fires after `doc.load` is called.
|
|
145
|
+
* The Y.Doc is fully loaded and ready to use.
|
|
146
|
+
*/
|
|
147
|
+
ready: Subject<void>;
|
|
148
|
+
/**
|
|
149
|
+
* This fires when the root block is added via API call or has just been initialized from existing ydoc.
|
|
150
|
+
* useful for internal block UI components to start subscribing following up events.
|
|
151
|
+
* Note that at this moment, the whole block tree may not be fully initialized yet.
|
|
152
|
+
*/
|
|
153
|
+
rootAdded: Subject<string>;
|
|
154
|
+
/**
|
|
155
|
+
* This fires when the root block is deleted via API call or has just been removed from existing ydoc.
|
|
156
|
+
* In most cases, you don't need to subscribe to this event.
|
|
157
|
+
*/
|
|
158
|
+
rootDeleted: Subject<string>;
|
|
159
|
+
/**
|
|
160
|
+
* This fires when a block is updated via API call or has just been updated from existing ydoc.
|
|
161
|
+
*
|
|
162
|
+
* The payload can have three types:
|
|
163
|
+
* - add: When a new block is added
|
|
164
|
+
* - delete: When a block is removed
|
|
165
|
+
* - update: When a block's properties are modified
|
|
166
|
+
*
|
|
167
|
+
*/
|
|
168
|
+
blockUpdated: Subject<StoreBlockUpdatedPayloads>;
|
|
169
|
+
/** @internal */
|
|
170
|
+
yBlockUpdated: Subject<
|
|
171
|
+
| {
|
|
172
|
+
type: 'add';
|
|
173
|
+
id: string;
|
|
174
|
+
isLocal: boolean;
|
|
175
|
+
}
|
|
176
|
+
| {
|
|
177
|
+
type: 'delete';
|
|
178
|
+
id: string;
|
|
179
|
+
isLocal: boolean;
|
|
180
|
+
}
|
|
181
|
+
>;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const internalExtensions = [StoreSelectionExtension, HistoryExtension];
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Core store class that manages blocks and their lifecycle in BlockSuite
|
|
188
|
+
* @remarks
|
|
189
|
+
* The Store class is responsible for managing the lifecycle of blocks, handling transactions,
|
|
190
|
+
* and maintaining the block tree structure.
|
|
191
|
+
* A store is a piece of data created from one or a part of a Y.Doc.
|
|
192
|
+
*
|
|
193
|
+
* @category Store
|
|
194
|
+
*/
|
|
195
|
+
export class Store {
|
|
196
|
+
/** @internal */
|
|
197
|
+
readonly userExtensions: ExtensionType[];
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Group of disposable resources managed by the store
|
|
201
|
+
*
|
|
202
|
+
* @category Store Lifecycle
|
|
203
|
+
*/
|
|
204
|
+
disposableGroup = new DisposableGroup();
|
|
205
|
+
|
|
206
|
+
private readonly _provider: ServiceProvider;
|
|
207
|
+
|
|
208
|
+
private _shouldTransact = true;
|
|
209
|
+
|
|
210
|
+
private readonly _runQuery = (block: Block) => {
|
|
211
|
+
runQuery(this._query, block);
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
private readonly _doc: Doc;
|
|
215
|
+
|
|
216
|
+
private readonly _blocks = signal<Record<string, Block>>({});
|
|
217
|
+
|
|
218
|
+
private readonly _crud: DocCRUD;
|
|
219
|
+
|
|
220
|
+
private readonly _query: Query = {
|
|
221
|
+
match: [],
|
|
222
|
+
mode: 'loose',
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
private readonly _readonly = signal(false);
|
|
226
|
+
|
|
227
|
+
private readonly _isEmpty = computed(() => {
|
|
228
|
+
return this.root?.isEmpty() ?? true;
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
private readonly _schema: Schema;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Get the id of the store.
|
|
235
|
+
*
|
|
236
|
+
* @category Store Lifecycle
|
|
237
|
+
*/
|
|
238
|
+
get id() {
|
|
239
|
+
return this._doc.id;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* {@inheritDoc StoreSlots}
|
|
244
|
+
*
|
|
245
|
+
* @category Store Lifecycle
|
|
246
|
+
*/
|
|
247
|
+
readonly slots: StoreSlots;
|
|
248
|
+
|
|
249
|
+
private get _yBlocks() {
|
|
250
|
+
return this._doc.yBlocks;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Get the {@link AwarenessStore} instance for current store
|
|
255
|
+
*/
|
|
256
|
+
get awarenessStore() {
|
|
257
|
+
return this._doc.awarenessStore;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Get the di provider for current store.
|
|
262
|
+
*
|
|
263
|
+
* @category Extension
|
|
264
|
+
*/
|
|
265
|
+
get provider() {
|
|
266
|
+
return this._provider;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Get the {@link BlobEngine} instance for current store.
|
|
271
|
+
*/
|
|
272
|
+
get blobSync() {
|
|
273
|
+
return this.workspace.blobSync;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Get the {@link Doc} instance for current store.
|
|
278
|
+
*/
|
|
279
|
+
get doc() {
|
|
280
|
+
return this._doc;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @internal
|
|
285
|
+
*/
|
|
286
|
+
get blocks() {
|
|
287
|
+
return this._blocks;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Get the number of blocks in the store
|
|
292
|
+
*
|
|
293
|
+
* @category Block CRUD
|
|
294
|
+
*/
|
|
295
|
+
get blockSize() {
|
|
296
|
+
return Object.values(this._blocks.peek()).length;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Check if the store can redo
|
|
301
|
+
*
|
|
302
|
+
* @category History
|
|
303
|
+
*/
|
|
304
|
+
get canRedo() {
|
|
305
|
+
if (this.readonly) {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
return this._history.canRedo;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Check if the store can undo
|
|
313
|
+
*
|
|
314
|
+
* @category History
|
|
315
|
+
*/
|
|
316
|
+
get canUndo() {
|
|
317
|
+
if (this.readonly) {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
return this._history.canUndo;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Undo the last transaction.
|
|
325
|
+
*
|
|
326
|
+
* @category History
|
|
327
|
+
*/
|
|
328
|
+
undo = () => {
|
|
329
|
+
if (this.readonly) {
|
|
330
|
+
console.error('cannot undo in readonly mode');
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
this._history.undoManager.undo();
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Redo the last undone transaction.
|
|
338
|
+
*
|
|
339
|
+
* @category History
|
|
340
|
+
*/
|
|
341
|
+
redo = () => {
|
|
342
|
+
if (this.readonly) {
|
|
343
|
+
console.error('cannot undo in readonly mode');
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
this._history.undoManager.redo();
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Reset the history of the store.
|
|
351
|
+
*
|
|
352
|
+
* @category History
|
|
353
|
+
*/
|
|
354
|
+
resetHistory = () => {
|
|
355
|
+
return this._history.undoManager.clear();
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Execute a transaction.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```ts
|
|
363
|
+
* store.transact(() => {
|
|
364
|
+
* op1();
|
|
365
|
+
* op2();
|
|
366
|
+
* });
|
|
367
|
+
* ```
|
|
368
|
+
*
|
|
369
|
+
* @category History
|
|
370
|
+
*/
|
|
371
|
+
transact(fn: () => void, shouldTransact: boolean = this._shouldTransact) {
|
|
372
|
+
const spaceDoc = this._doc.spaceDoc;
|
|
373
|
+
spaceDoc.transact(
|
|
374
|
+
() => {
|
|
375
|
+
try {
|
|
376
|
+
fn();
|
|
377
|
+
} catch (e) {
|
|
378
|
+
console.error(
|
|
379
|
+
`An error occurred while Y.doc ${spaceDoc.guid} transacting:`
|
|
380
|
+
);
|
|
381
|
+
console.error(e);
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
shouldTransact ? this.spaceDoc.clientID : null
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Execute a transaction without capturing the history.
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
* ```ts
|
|
393
|
+
* store.withoutTransact(() => {
|
|
394
|
+
* op1();
|
|
395
|
+
* op2();
|
|
396
|
+
* });
|
|
397
|
+
* ```
|
|
398
|
+
*
|
|
399
|
+
* @category History
|
|
400
|
+
*/
|
|
401
|
+
withoutTransact(fn: () => void) {
|
|
402
|
+
this._shouldTransact = false;
|
|
403
|
+
fn();
|
|
404
|
+
this._shouldTransact = true;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Force the following history to be captured into a new stack.
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* ```ts
|
|
412
|
+
* op1();
|
|
413
|
+
* op2();
|
|
414
|
+
* store.captureSync();
|
|
415
|
+
* op3();
|
|
416
|
+
*
|
|
417
|
+
* store.undo(); // undo op3
|
|
418
|
+
* store.undo(); // undo op1, op2
|
|
419
|
+
* ```
|
|
420
|
+
*
|
|
421
|
+
* @category History
|
|
422
|
+
*/
|
|
423
|
+
captureSync = () => {
|
|
424
|
+
this._history.undoManager.stopCapturing();
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Get the {@link Workspace} instance for current store.
|
|
429
|
+
*/
|
|
430
|
+
get workspace() {
|
|
431
|
+
return this._doc.workspace;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Get the {@link Y.UndoManager} instance for current store.
|
|
436
|
+
*
|
|
437
|
+
* @category History
|
|
438
|
+
*/
|
|
439
|
+
get history() {
|
|
440
|
+
return this._history;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Check if there are no blocks in the store.
|
|
445
|
+
*
|
|
446
|
+
* @category Block CRUD
|
|
447
|
+
*/
|
|
448
|
+
get isEmpty() {
|
|
449
|
+
return this._isEmpty.peek();
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Get the signal for the empty state of the store.
|
|
454
|
+
*
|
|
455
|
+
* @category Block CRUD
|
|
456
|
+
*/
|
|
457
|
+
get isEmpty$() {
|
|
458
|
+
return this._isEmpty;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Check if the store is loaded.
|
|
463
|
+
*
|
|
464
|
+
* @category Store Lifecycle
|
|
465
|
+
*/
|
|
466
|
+
get loaded() {
|
|
467
|
+
return this._doc.loaded;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Get the meta data of the store.
|
|
472
|
+
*
|
|
473
|
+
* @internal
|
|
474
|
+
*/
|
|
475
|
+
get meta() {
|
|
476
|
+
return this._doc.meta;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Check if the store is readonly.
|
|
481
|
+
*
|
|
482
|
+
* @category Block CRUD
|
|
483
|
+
*/
|
|
484
|
+
get readonly() {
|
|
485
|
+
return this._readonly.value === true;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Get the signal for the readonly state of the store.
|
|
490
|
+
*
|
|
491
|
+
* @category Block CRUD
|
|
492
|
+
*/
|
|
493
|
+
get readonly$() {
|
|
494
|
+
return this._readonly;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Set the readonly state of the store.
|
|
499
|
+
*
|
|
500
|
+
* @category Block CRUD
|
|
501
|
+
*/
|
|
502
|
+
set readonly(value: boolean) {
|
|
503
|
+
this._readonly.value = value;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Check if the store is ready.
|
|
508
|
+
* Which means the Y.Doc is loaded and the root block is added.
|
|
509
|
+
*
|
|
510
|
+
* @category Store Lifecycle
|
|
511
|
+
*/
|
|
512
|
+
get ready() {
|
|
513
|
+
return this._doc.ready;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Get the root block of the store.
|
|
518
|
+
*
|
|
519
|
+
* @category Block CRUD
|
|
520
|
+
*/
|
|
521
|
+
get root() {
|
|
522
|
+
const rootId = this._crud.root;
|
|
523
|
+
if (!rootId) return null;
|
|
524
|
+
return this.getBlock(rootId)?.model ?? null;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* @internal
|
|
529
|
+
* Get the root Y.Doc of sub Y.Doc.
|
|
530
|
+
* In the current design, store is on a sub Y.Doc, and all sub docs have the same root Y.Doc.
|
|
531
|
+
*/
|
|
532
|
+
get rootDoc() {
|
|
533
|
+
return this._doc.rootDoc;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Get the {@link Schema} instance of the store.
|
|
538
|
+
*/
|
|
539
|
+
get schema() {
|
|
540
|
+
return this._schema;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* @internal
|
|
545
|
+
* Get the Y.Doc instance of the store.
|
|
546
|
+
*/
|
|
547
|
+
get spaceDoc() {
|
|
548
|
+
return this._doc.spaceDoc;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
private _isDisposed = false;
|
|
552
|
+
|
|
553
|
+
private get _history() {
|
|
554
|
+
return this._provider.get(HistoryExtension);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* @internal
|
|
559
|
+
* In most cases, you don't need to use the constructor directly.
|
|
560
|
+
* The store is created by the {@link Doc} instance.
|
|
561
|
+
*/
|
|
562
|
+
constructor({ readonly, query, provider, extensions }: StoreOptions) {
|
|
563
|
+
this.slots = {
|
|
564
|
+
ready: new Subject(),
|
|
565
|
+
rootAdded: new Subject(),
|
|
566
|
+
rootDeleted: new Subject(),
|
|
567
|
+
blockUpdated: new Subject(),
|
|
568
|
+
yBlockUpdated: new Subject(),
|
|
569
|
+
};
|
|
570
|
+
this._schema = new Schema();
|
|
571
|
+
|
|
572
|
+
const container = new Container();
|
|
573
|
+
container.addImpl(StoreIdentifier, () => this);
|
|
574
|
+
|
|
575
|
+
internalExtensions.forEach(ext => {
|
|
576
|
+
ext.setup(container);
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
const userExtensions = extensions ?? [];
|
|
580
|
+
this.userExtensions = userExtensions;
|
|
581
|
+
userExtensions.forEach(extension => {
|
|
582
|
+
extension.setup(container);
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
this._provider = container.provider(undefined, provider);
|
|
586
|
+
this._provider.getAll(BlockSchemaIdentifier).forEach(schema => {
|
|
587
|
+
this._schema.register([schema]);
|
|
588
|
+
});
|
|
589
|
+
this._doc = this._provider.get(DocIdentifier);
|
|
590
|
+
this._crud = new DocCRUD(this._yBlocks, this._schema);
|
|
591
|
+
if (readonly !== undefined) {
|
|
592
|
+
this._readonly.value = readonly;
|
|
593
|
+
}
|
|
594
|
+
if (query) {
|
|
595
|
+
this._query = query;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
this._yBlocks.observeDeep(this._handleYEvents);
|
|
599
|
+
this._yBlocks.forEach((_, id) => {
|
|
600
|
+
this._handleYBlockAdd(id, false);
|
|
601
|
+
|
|
602
|
+
if (id in this._blocks.peek()) {
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
this._onBlockAdded(id, false, true);
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
this._subscribeToSlots();
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
private readonly _subscribeToSlots = () => {
|
|
612
|
+
this.disposableGroup.add(
|
|
613
|
+
this.slots.yBlockUpdated.subscribe(({ type, id, isLocal }) => {
|
|
614
|
+
switch (type) {
|
|
615
|
+
case 'add': {
|
|
616
|
+
this._onBlockAdded(id, isLocal, false);
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
case 'delete': {
|
|
620
|
+
this._onBlockRemoved(id, isLocal);
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
})
|
|
625
|
+
);
|
|
626
|
+
this.disposableGroup.add(this.slots.ready);
|
|
627
|
+
this.disposableGroup.add(this.slots.blockUpdated);
|
|
628
|
+
this.disposableGroup.add(this.slots.rootAdded);
|
|
629
|
+
this.disposableGroup.add(this.slots.rootDeleted);
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
private _getSiblings<T>(
|
|
633
|
+
block: BlockModel | string,
|
|
634
|
+
fn: (parent: BlockModel, index: number) => T
|
|
635
|
+
) {
|
|
636
|
+
const parent = this.getParent(block);
|
|
637
|
+
if (!parent) return null;
|
|
638
|
+
|
|
639
|
+
const blockModel =
|
|
640
|
+
typeof block === 'string' ? this.getBlock(block)?.model : block;
|
|
641
|
+
if (!blockModel) return null;
|
|
642
|
+
|
|
643
|
+
const index = parent.children.indexOf(blockModel);
|
|
644
|
+
if (index === -1) return null;
|
|
645
|
+
|
|
646
|
+
return fn(parent, index);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
private _onBlockAdded(id: string, isLocal: boolean, init: boolean) {
|
|
650
|
+
try {
|
|
651
|
+
if (id in this._blocks.peek()) {
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
const yBlock = this._yBlocks.get(id);
|
|
655
|
+
if (!yBlock) {
|
|
656
|
+
console.warn(`Could not find block with id ${id}`);
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
const options: BlockOptions = {
|
|
661
|
+
onChange: (block, key, isLocal) => {
|
|
662
|
+
if (key) {
|
|
663
|
+
block.model.propsUpdated.next({ key });
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
this.slots.blockUpdated.next({
|
|
667
|
+
type: 'update',
|
|
668
|
+
id,
|
|
669
|
+
flavour: block.flavour,
|
|
670
|
+
props: { key },
|
|
671
|
+
isLocal,
|
|
672
|
+
});
|
|
673
|
+
},
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
const block = new Block(this._schema, yBlock, this, options);
|
|
677
|
+
this._runQuery(block);
|
|
678
|
+
|
|
679
|
+
this._blocks.value = {
|
|
680
|
+
...this._blocks.value,
|
|
681
|
+
[id]: block,
|
|
682
|
+
};
|
|
683
|
+
block.model.created.next();
|
|
684
|
+
|
|
685
|
+
if (block.model.role === 'root') {
|
|
686
|
+
this.slots.rootAdded.next(id);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
this.slots.blockUpdated.next({
|
|
690
|
+
type: 'add',
|
|
691
|
+
id,
|
|
692
|
+
init,
|
|
693
|
+
flavour: block.model.flavour,
|
|
694
|
+
model: block.model,
|
|
695
|
+
isLocal,
|
|
696
|
+
});
|
|
697
|
+
} catch (e) {
|
|
698
|
+
console.error('An error occurred while adding block:');
|
|
699
|
+
console.error(e);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
private _onBlockRemoved(id: string, isLocal: boolean) {
|
|
704
|
+
try {
|
|
705
|
+
const block = this.getBlock(id);
|
|
706
|
+
if (!block) return;
|
|
707
|
+
|
|
708
|
+
if (block.model.role === 'root') {
|
|
709
|
+
this.slots.rootDeleted.next(id);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
this.slots.blockUpdated.next({
|
|
713
|
+
type: 'delete',
|
|
714
|
+
id,
|
|
715
|
+
flavour: block.flavour,
|
|
716
|
+
parent: this.getParent(block.model)?.id ?? '',
|
|
717
|
+
model: block.model,
|
|
718
|
+
isLocal,
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
const { [id]: _, ...blocks } = this._blocks.peek();
|
|
722
|
+
this._blocks.value = blocks;
|
|
723
|
+
|
|
724
|
+
block.model.deleted.next();
|
|
725
|
+
block.model.dispose();
|
|
726
|
+
} catch (e) {
|
|
727
|
+
console.error('An error occurred while removing block:');
|
|
728
|
+
console.error(e);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Creates and adds a new block to the store
|
|
734
|
+
* @param flavour - The block's flavour (type)
|
|
735
|
+
* @param blockProps - Optional properties for the new block
|
|
736
|
+
* @param parent - Optional parent block or parent block ID
|
|
737
|
+
* @param parentIndex - Optional index position in parent's children
|
|
738
|
+
* @returns The ID of the newly created block
|
|
739
|
+
* @throws {BlockSuiteError} When store is in readonly mode
|
|
740
|
+
*
|
|
741
|
+
* @category Block CRUD
|
|
742
|
+
*/
|
|
743
|
+
addBlock<T extends BlockModel = BlockModel>(
|
|
744
|
+
flavour: string,
|
|
745
|
+
blockProps: Partial<(PropsOfModel<T> & BlockSysProps) | BlockProps> = {},
|
|
746
|
+
parent?: BlockModel | string | null,
|
|
747
|
+
parentIndex?: number
|
|
748
|
+
): string {
|
|
749
|
+
if (this.readonly) {
|
|
750
|
+
throw new BlockSuiteError(
|
|
751
|
+
ErrorCode.ModelCRUDError,
|
|
752
|
+
'cannot modify data in readonly mode'
|
|
753
|
+
);
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
const id = blockProps.id ?? this._doc.workspace.idGenerator();
|
|
757
|
+
|
|
758
|
+
this.transact(() => {
|
|
759
|
+
this._crud.addBlock(
|
|
760
|
+
id,
|
|
761
|
+
flavour,
|
|
762
|
+
{ ...blockProps },
|
|
763
|
+
typeof parent === 'string' ? parent : parent?.id,
|
|
764
|
+
parentIndex
|
|
765
|
+
);
|
|
766
|
+
});
|
|
767
|
+
|
|
768
|
+
return id;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* Add multiple blocks to the store
|
|
773
|
+
* @param blocks - Array of blocks to add
|
|
774
|
+
* @param parent - Optional parent block or parent block ID
|
|
775
|
+
* @param parentIndex - Optional index position in parent's children
|
|
776
|
+
* @returns Array of IDs of the newly created blocks
|
|
777
|
+
*
|
|
778
|
+
* @category Block CRUD
|
|
779
|
+
*/
|
|
780
|
+
addBlocks(
|
|
781
|
+
blocks: Array<{
|
|
782
|
+
flavour: string;
|
|
783
|
+
blockProps?: Partial<BlockProps & Omit<BlockProps, 'flavour' | 'id'>>;
|
|
784
|
+
}>,
|
|
785
|
+
parent?: BlockModel | string | null,
|
|
786
|
+
parentIndex?: number
|
|
787
|
+
): string[] {
|
|
788
|
+
const ids: string[] = [];
|
|
789
|
+
blocks.forEach(block => {
|
|
790
|
+
const id = this.addBlock(
|
|
791
|
+
block.flavour as never,
|
|
792
|
+
block.blockProps ?? {},
|
|
793
|
+
parent,
|
|
794
|
+
parentIndex
|
|
795
|
+
);
|
|
796
|
+
ids.push(id);
|
|
797
|
+
typeof parentIndex === 'number' && parentIndex++;
|
|
798
|
+
});
|
|
799
|
+
|
|
800
|
+
return ids;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* Add sibling blocks to the store
|
|
805
|
+
* @param targetModel - The target block model
|
|
806
|
+
* @param props - Array of block properties
|
|
807
|
+
* @param placement - Optional position to place the new blocks ('after' or 'before')
|
|
808
|
+
* @returns Array of IDs of the newly created blocks
|
|
809
|
+
*
|
|
810
|
+
* @category Block CRUD
|
|
811
|
+
*/
|
|
812
|
+
addSiblingBlocks(
|
|
813
|
+
targetModel: BlockModel,
|
|
814
|
+
props: Array<Partial<BlockProps>>,
|
|
815
|
+
placement: 'after' | 'before' = 'after'
|
|
816
|
+
): string[] {
|
|
817
|
+
if (!props.length) return [];
|
|
818
|
+
const parent = this.getParent(targetModel);
|
|
819
|
+
if (!parent) return [];
|
|
820
|
+
|
|
821
|
+
const targetIndex =
|
|
822
|
+
parent.children.findIndex(({ id }) => id === targetModel.id) ?? 0;
|
|
823
|
+
const insertIndex = placement === 'before' ? targetIndex : targetIndex + 1;
|
|
824
|
+
|
|
825
|
+
if (props.length <= 1) {
|
|
826
|
+
if (!props[0]?.flavour) return [];
|
|
827
|
+
const { flavour, ...blockProps } = props[0];
|
|
828
|
+
const id = this.addBlock(
|
|
829
|
+
flavour as never,
|
|
830
|
+
blockProps,
|
|
831
|
+
parent.id,
|
|
832
|
+
insertIndex
|
|
833
|
+
);
|
|
834
|
+
return [id];
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
const blocks: Array<{
|
|
838
|
+
flavour: string;
|
|
839
|
+
blockProps: Partial<BlockProps>;
|
|
840
|
+
}> = [];
|
|
841
|
+
props.forEach(prop => {
|
|
842
|
+
const { flavour, ...blockProps } = prop;
|
|
843
|
+
if (!flavour) return;
|
|
844
|
+
blocks.push({ flavour, blockProps });
|
|
845
|
+
});
|
|
846
|
+
return this.addBlocks(blocks, parent.id, insertIndex);
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* Updates a block's properties or executes a callback in a transaction
|
|
851
|
+
* @param modelOrId - The block model or block ID to update
|
|
852
|
+
* @param callBackOrProps - Either a callback function to execute or properties to update
|
|
853
|
+
* @throws {BlockSuiteError} When the block is not found or schema validation fails
|
|
854
|
+
*
|
|
855
|
+
* @category Block CRUD
|
|
856
|
+
*/
|
|
857
|
+
|
|
858
|
+
updateBlock<T extends BlockModel = BlockModel>(
|
|
859
|
+
modelOrId: T | string,
|
|
860
|
+
callBackOrProps:
|
|
861
|
+
| (() => void)
|
|
862
|
+
| Partial<(PropsOfModel<T> & BlockSysProps) | BlockProps>
|
|
863
|
+
) {
|
|
864
|
+
if (this.readonly) {
|
|
865
|
+
console.error('cannot modify data in readonly mode');
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
const isCallback = typeof callBackOrProps === 'function';
|
|
870
|
+
|
|
871
|
+
const model =
|
|
872
|
+
typeof modelOrId === 'string'
|
|
873
|
+
? this.getBlock(modelOrId)?.model
|
|
874
|
+
: modelOrId;
|
|
875
|
+
if (!model) {
|
|
876
|
+
throw new BlockSuiteError(
|
|
877
|
+
ErrorCode.ModelCRUDError,
|
|
878
|
+
`updating block: ${modelOrId} not found`
|
|
879
|
+
);
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
if (!isCallback) {
|
|
883
|
+
const parent = this.getParent(model);
|
|
884
|
+
this.schema.validate(
|
|
885
|
+
model.flavour,
|
|
886
|
+
parent?.flavour,
|
|
887
|
+
callBackOrProps.children?.map(child => child.flavour)
|
|
888
|
+
);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
const yBlock = this._yBlocks.get(model.id);
|
|
892
|
+
if (!yBlock) {
|
|
893
|
+
throw new BlockSuiteError(
|
|
894
|
+
ErrorCode.ModelCRUDError,
|
|
895
|
+
`updating block: ${model.id} not found`
|
|
896
|
+
);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
const block = this.getBlock(model.id);
|
|
900
|
+
if (!block) return;
|
|
901
|
+
|
|
902
|
+
this.transact(() => {
|
|
903
|
+
if (isCallback) {
|
|
904
|
+
callBackOrProps();
|
|
905
|
+
this._runQuery(block);
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
if (callBackOrProps.children) {
|
|
910
|
+
this._crud.updateBlockChildren(
|
|
911
|
+
model.id,
|
|
912
|
+
callBackOrProps.children.map(child => child.id)
|
|
913
|
+
);
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
const schema = this.schema.flavourSchemaMap.get(model.flavour);
|
|
917
|
+
if (!schema) {
|
|
918
|
+
throw new BlockSuiteError(
|
|
919
|
+
ErrorCode.ModelCRUDError,
|
|
920
|
+
`schema for flavour: ${model.flavour} not found`
|
|
921
|
+
);
|
|
922
|
+
}
|
|
923
|
+
syncBlockProps(schema, model, yBlock, callBackOrProps);
|
|
924
|
+
this._runQuery(block);
|
|
925
|
+
return;
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* Delete a block from the store
|
|
931
|
+
* @param model - The block model or block ID to delete
|
|
932
|
+
* @param options - Optional options for the deletion
|
|
933
|
+
* @param options.bringChildrenTo - Optional block model to bring children to
|
|
934
|
+
* @param options.deleteChildren - Optional flag to delete children
|
|
935
|
+
*
|
|
936
|
+
* @category Block CRUD
|
|
937
|
+
*/
|
|
938
|
+
deleteBlock(
|
|
939
|
+
model: BlockModel | string,
|
|
940
|
+
options: {
|
|
941
|
+
bringChildrenTo?: BlockModel;
|
|
942
|
+
deleteChildren?: boolean;
|
|
943
|
+
} = {
|
|
944
|
+
deleteChildren: true,
|
|
945
|
+
}
|
|
946
|
+
) {
|
|
947
|
+
if (this.readonly) {
|
|
948
|
+
console.error('cannot modify data in readonly mode');
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
const opts = (
|
|
953
|
+
options && options.bringChildrenTo
|
|
954
|
+
? {
|
|
955
|
+
...options,
|
|
956
|
+
bringChildrenTo: options.bringChildrenTo.id,
|
|
957
|
+
}
|
|
958
|
+
: options
|
|
959
|
+
) as {
|
|
960
|
+
bringChildrenTo?: string;
|
|
961
|
+
deleteChildren?: boolean;
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
this.transact(() => {
|
|
965
|
+
this._crud.deleteBlock(
|
|
966
|
+
typeof model === 'string' ? model : model.id,
|
|
967
|
+
opts
|
|
968
|
+
);
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* Gets a block by its ID
|
|
974
|
+
* @param id - The block's ID
|
|
975
|
+
* @returns The block instance if found, undefined otherwise
|
|
976
|
+
*
|
|
977
|
+
* @category Block CRUD
|
|
978
|
+
*/
|
|
979
|
+
getBlock(id: string): Block | undefined {
|
|
980
|
+
return this._blocks.peek()[id];
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
/**
|
|
984
|
+
* Gets a block by its ID
|
|
985
|
+
* @param id - The block's ID
|
|
986
|
+
* @returns The block instance in signal if found, undefined otherwise
|
|
987
|
+
*
|
|
988
|
+
* @category Block CRUD
|
|
989
|
+
*/
|
|
990
|
+
getBlock$(id: string): Block | undefined {
|
|
991
|
+
return this._blocks.value[id];
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
/**
|
|
995
|
+
* Get a model by its ID
|
|
996
|
+
* @param id - The model's ID
|
|
997
|
+
* @returns The model instance if found, null otherwise
|
|
998
|
+
*
|
|
999
|
+
* @category Block CRUD
|
|
1000
|
+
*/
|
|
1001
|
+
getModelById<Model extends BlockModel = BlockModel>(
|
|
1002
|
+
id: string
|
|
1003
|
+
): Model | null {
|
|
1004
|
+
return (this.getBlock(id)?.model ?? null) as Model | null;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* Gets all blocks of specified flavour(s)
|
|
1009
|
+
* @param blockFlavour - Single flavour or array of flavours to filter by
|
|
1010
|
+
* @returns Array of matching blocks
|
|
1011
|
+
*
|
|
1012
|
+
* @category Block CRUD
|
|
1013
|
+
*/
|
|
1014
|
+
getBlocksByFlavour(blockFlavour: string | string[]): Block[] {
|
|
1015
|
+
const flavours =
|
|
1016
|
+
typeof blockFlavour === 'string' ? [blockFlavour] : blockFlavour;
|
|
1017
|
+
|
|
1018
|
+
return Object.values(this._blocks.peek()).filter(({ flavour }) =>
|
|
1019
|
+
flavours.includes(flavour)
|
|
1020
|
+
);
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* Get all models in the store
|
|
1025
|
+
* @returns Array of all models
|
|
1026
|
+
*
|
|
1027
|
+
* @category Block CRUD
|
|
1028
|
+
*/
|
|
1029
|
+
getAllModels() {
|
|
1030
|
+
return Object.values(this._blocks.peek()).map(block => block.model);
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* Get all models of specified flavour(s)
|
|
1035
|
+
* @param blockFlavour - Single flavour or array of flavours to filter by
|
|
1036
|
+
* @returns Array of matching models
|
|
1037
|
+
*
|
|
1038
|
+
* @category Block CRUD
|
|
1039
|
+
*/
|
|
1040
|
+
getModelsByFlavour(blockFlavour: string | string[]): BlockModel[] {
|
|
1041
|
+
return this.getBlocksByFlavour(blockFlavour).map(x => x.model);
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
/**
|
|
1045
|
+
* Gets the parent block of a given block
|
|
1046
|
+
* @param target - Block model or block ID to find parent for
|
|
1047
|
+
* @returns The parent block model if found, null otherwise
|
|
1048
|
+
*
|
|
1049
|
+
* @category Block CRUD
|
|
1050
|
+
*/
|
|
1051
|
+
getParent(target: BlockModel | string): BlockModel | null {
|
|
1052
|
+
const targetId = typeof target === 'string' ? target : target.id;
|
|
1053
|
+
const parentId = this._crud.getParent(targetId);
|
|
1054
|
+
if (!parentId) return null;
|
|
1055
|
+
|
|
1056
|
+
const parent = this._blocks.peek()[parentId];
|
|
1057
|
+
if (!parent) return null;
|
|
1058
|
+
|
|
1059
|
+
return parent.model;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
/**
|
|
1063
|
+
* Get the previous sibling block of a given block
|
|
1064
|
+
* @param block - Block model or block ID to find previous sibling for
|
|
1065
|
+
* @returns The previous sibling block model if found, null otherwise
|
|
1066
|
+
*
|
|
1067
|
+
* @category Block CRUD
|
|
1068
|
+
*/
|
|
1069
|
+
getPrev(block: BlockModel | string) {
|
|
1070
|
+
return this._getSiblings(
|
|
1071
|
+
block,
|
|
1072
|
+
(parent, index) => parent.children[index - 1] ?? null
|
|
1073
|
+
);
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Get all previous sibling blocks of a given block
|
|
1078
|
+
* @param block - Block model or block ID to find previous siblings for
|
|
1079
|
+
* @returns Array of previous sibling blocks if found, empty array otherwise
|
|
1080
|
+
*
|
|
1081
|
+
* @category Block CRUD
|
|
1082
|
+
*/
|
|
1083
|
+
getPrevs(block: BlockModel | string) {
|
|
1084
|
+
return (
|
|
1085
|
+
this._getSiblings(block, (parent, index) =>
|
|
1086
|
+
parent.children.slice(0, index)
|
|
1087
|
+
) ?? []
|
|
1088
|
+
);
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
/**
|
|
1092
|
+
* Get the next sibling block of a given block
|
|
1093
|
+
* @param block - Block model or block ID to find next sibling for
|
|
1094
|
+
* @returns The next sibling block model if found, null otherwise
|
|
1095
|
+
*
|
|
1096
|
+
* @category Block CRUD
|
|
1097
|
+
*/
|
|
1098
|
+
getNext(block: BlockModel | string) {
|
|
1099
|
+
return this._getSiblings(
|
|
1100
|
+
block,
|
|
1101
|
+
(parent, index) => parent.children[index + 1] ?? null
|
|
1102
|
+
);
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
/**
|
|
1106
|
+
* Get all next sibling blocks of a given block
|
|
1107
|
+
* @param block - Block model or block ID to find next siblings for
|
|
1108
|
+
* @returns Array of next sibling blocks if found, empty array otherwise
|
|
1109
|
+
*
|
|
1110
|
+
* @category Block CRUD
|
|
1111
|
+
*/
|
|
1112
|
+
getNexts(block: BlockModel | string) {
|
|
1113
|
+
return (
|
|
1114
|
+
this._getSiblings(block, (parent, index) =>
|
|
1115
|
+
parent.children.slice(index + 1)
|
|
1116
|
+
) ?? []
|
|
1117
|
+
);
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* Check if a block exists by its ID
|
|
1122
|
+
* @param id - The block's ID
|
|
1123
|
+
* @returns True if the block exists, false otherwise
|
|
1124
|
+
*
|
|
1125
|
+
* @category Block CRUD
|
|
1126
|
+
*/
|
|
1127
|
+
hasBlock(id: string) {
|
|
1128
|
+
return id in this._blocks.peek();
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* Move blocks to a new parent block
|
|
1133
|
+
* @param blocksToMove - Array of block models to move
|
|
1134
|
+
* @param newParent - The new parent block model
|
|
1135
|
+
* @param targetSibling - Optional target sibling block model
|
|
1136
|
+
* @param shouldInsertBeforeSibling - Optional flag to insert before sibling
|
|
1137
|
+
*
|
|
1138
|
+
* @category Block CRUD
|
|
1139
|
+
*/
|
|
1140
|
+
moveBlocks(
|
|
1141
|
+
blocksToMove: BlockModel[],
|
|
1142
|
+
newParent: BlockModel,
|
|
1143
|
+
targetSibling: BlockModel | null = null,
|
|
1144
|
+
shouldInsertBeforeSibling = true
|
|
1145
|
+
) {
|
|
1146
|
+
if (this.readonly) {
|
|
1147
|
+
console.error('Cannot modify data in read-only mode');
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
this.transact(() => {
|
|
1152
|
+
this._crud.moveBlocks(
|
|
1153
|
+
blocksToMove.map(model => model.id),
|
|
1154
|
+
newParent.id,
|
|
1155
|
+
targetSibling?.id ?? null,
|
|
1156
|
+
shouldInsertBeforeSibling
|
|
1157
|
+
);
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* Creates a new transformer instance for the store
|
|
1163
|
+
* @param middlewares - Optional array of transformer middlewares
|
|
1164
|
+
* @returns A new Transformer instance
|
|
1165
|
+
*
|
|
1166
|
+
* @category Transformer
|
|
1167
|
+
*/
|
|
1168
|
+
getTransformer(middlewares: TransformerMiddleware[] = []) {
|
|
1169
|
+
return new Transformer({
|
|
1170
|
+
schema: this.schema,
|
|
1171
|
+
blobCRUD: this.workspace.blobSync,
|
|
1172
|
+
docCRUD: {
|
|
1173
|
+
create: (id: string) => this.workspace.createDoc(id).getStore({ id }),
|
|
1174
|
+
get: (id: string) =>
|
|
1175
|
+
this.workspace.getDoc(id)?.getStore({ id }) ?? null,
|
|
1176
|
+
delete: (id: string) => this.workspace.removeDoc(id),
|
|
1177
|
+
},
|
|
1178
|
+
middlewares,
|
|
1179
|
+
});
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
/**
|
|
1183
|
+
* Get an extension instance from the store
|
|
1184
|
+
* @returns The extension instance
|
|
1185
|
+
*
|
|
1186
|
+
* @example
|
|
1187
|
+
* ```ts
|
|
1188
|
+
* const extension = store.get(SomeExtension);
|
|
1189
|
+
* ```
|
|
1190
|
+
*
|
|
1191
|
+
* @category Extension
|
|
1192
|
+
*/
|
|
1193
|
+
get get() {
|
|
1194
|
+
return this.provider.get.bind(this.provider);
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* Optional get an extension instance from the store.
|
|
1199
|
+
* The major difference between `get` and `getOptional` is that `getOptional` will not throw an error if the extension is not found.
|
|
1200
|
+
*
|
|
1201
|
+
* @returns The extension instance
|
|
1202
|
+
*
|
|
1203
|
+
* @example
|
|
1204
|
+
* ```ts
|
|
1205
|
+
* const extension = store.getOptional(SomeExtension);
|
|
1206
|
+
* ```
|
|
1207
|
+
*
|
|
1208
|
+
* @category Extension
|
|
1209
|
+
*/
|
|
1210
|
+
get getOptional() {
|
|
1211
|
+
return this.provider.getOptional.bind(this.provider);
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
/**
|
|
1215
|
+
* Initializes and loads the store
|
|
1216
|
+
* @param initFn - Optional initialization function
|
|
1217
|
+
* @returns The store instance
|
|
1218
|
+
*
|
|
1219
|
+
* @category Store Lifecycle
|
|
1220
|
+
*/
|
|
1221
|
+
load(initFn?: () => void) {
|
|
1222
|
+
if (this._isDisposed) {
|
|
1223
|
+
this.disposableGroup = new DisposableGroup();
|
|
1224
|
+
this._subscribeToSlots();
|
|
1225
|
+
this._isDisposed = false;
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
this._doc.load(initFn);
|
|
1229
|
+
this._provider.getAll(StoreExtensionIdentifier).forEach(ext => {
|
|
1230
|
+
ext.loaded();
|
|
1231
|
+
});
|
|
1232
|
+
this.slots.ready.next();
|
|
1233
|
+
this.slots.rootAdded.next(this.root?.id ?? '');
|
|
1234
|
+
return this;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* Disposes the store and releases all resources
|
|
1239
|
+
*
|
|
1240
|
+
* @category Store Lifecycle
|
|
1241
|
+
*/
|
|
1242
|
+
dispose() {
|
|
1243
|
+
this._provider.getAll(StoreExtensionIdentifier).forEach(ext => {
|
|
1244
|
+
ext.disposed();
|
|
1245
|
+
});
|
|
1246
|
+
if (this._doc.ready) {
|
|
1247
|
+
this._yBlocks.unobserveDeep(this._handleYEvents);
|
|
1248
|
+
}
|
|
1249
|
+
this.slots.ready.complete();
|
|
1250
|
+
this.slots.rootAdded.complete();
|
|
1251
|
+
this.slots.rootDeleted.complete();
|
|
1252
|
+
this.slots.blockUpdated.complete();
|
|
1253
|
+
this.slots.yBlockUpdated.complete();
|
|
1254
|
+
this.disposableGroup.dispose();
|
|
1255
|
+
this._isDisposed = true;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
private _handleYBlockAdd(id: string, isLocal: boolean) {
|
|
1259
|
+
this.slots.yBlockUpdated.next({ type: 'add', id, isLocal });
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
private _handleYBlockDelete(id: string, isLocal: boolean) {
|
|
1263
|
+
this.slots.yBlockUpdated.next({ type: 'delete', id, isLocal });
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
private _handleYEvent(event: Y.YEvent<YBlock | Y.Text | Y.Array<unknown>>) {
|
|
1267
|
+
// event on top-level block store
|
|
1268
|
+
if (event.target !== this._yBlocks) {
|
|
1269
|
+
return;
|
|
1270
|
+
}
|
|
1271
|
+
const isLocal =
|
|
1272
|
+
!event.transaction.origin ||
|
|
1273
|
+
!this._yBlocks.doc ||
|
|
1274
|
+
event.transaction.origin instanceof Y.UndoManager ||
|
|
1275
|
+
event.transaction.origin.proxy
|
|
1276
|
+
? true
|
|
1277
|
+
: event.transaction.origin === this._yBlocks.doc.clientID;
|
|
1278
|
+
event.keys.forEach((value, id) => {
|
|
1279
|
+
try {
|
|
1280
|
+
if (value.action === 'add') {
|
|
1281
|
+
this._handleYBlockAdd(id, isLocal);
|
|
1282
|
+
return;
|
|
1283
|
+
}
|
|
1284
|
+
if (value.action === 'delete') {
|
|
1285
|
+
this._handleYBlockDelete(id, isLocal);
|
|
1286
|
+
return;
|
|
1287
|
+
}
|
|
1288
|
+
} catch (e) {
|
|
1289
|
+
console.error('An error occurred while handling Yjs event:');
|
|
1290
|
+
console.error(e);
|
|
1291
|
+
}
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
private readonly _handleYEvents = (events: Y.YEvent<YBlock | Y.Text>[]) => {
|
|
1296
|
+
events.forEach(event => this._handleYEvent(event));
|
|
1297
|
+
};
|
|
1298
|
+
}
|