From 8b6c81f76d370b94d952f7fbeb78ffcd3d53147c Mon Sep 17 00:00:00 2001 From: Saul-Mirone Date: Fri, 3 Jan 2025 01:59:25 +0000 Subject: [PATCH] refactor(editor): reduce dependency to doc collection (#9492) --- blocksuite/affine/block-database/package.json | 1 + .../src/detail-panel/note-renderer.ts | 2 +- blocksuite/affine/block-embed/package.json | 1 + .../embed-linked-doc-block.ts | 4 +-- .../embed-synced-doc-block.ts | 4 +-- blocksuite/affine/block-surface/package.json | 1 + .../src/renderer/elements/text/utils.ts | 2 +- .../affine/block-surface/src/surface-model.ts | 5 +-- .../block-surface/src/surface-transformer.ts | 16 +++++----- .../block-surface/src/utils/mindmap/utils.ts | 4 +-- blocksuite/affine/components/package.json | 1 + .../src/rich-text/extension/inline-manager.ts | 2 +- .../src/rich-text/extension/type.ts | 2 +- .../nodes/latex-node/latex-editor-menu.ts | 5 ++- .../components/src/rich-text/rich-text.ts | 6 ++-- blocksuite/affine/data-view/package.json | 1 + .../table/pc/controller/drag-to-fill.ts | 5 +-- blocksuite/affine/model/package.json | 1 + .../model/src/blocks/root/root-block-model.ts | 2 +- .../model/src/elements/connector/connector.ts | 6 ++-- .../affine/model/src/elements/group/group.ts | 15 ++++----- .../model/src/elements/mindmap/mindmap.ts | 16 ++++------ .../affine/model/src/elements/shape/shape.ts | 6 ++-- .../affine/model/src/elements/text/text.ts | 8 ++--- blocksuite/affine/shared/package.json | 1 + .../shared/src/adapters/middlewares/paste.ts | 4 +-- .../shared/src/services/edit-props-store.ts | 8 ++--- .../affine/shared/src/utils/model/doc.ts | 2 +- blocksuite/blocks/package.json | 1 + .../edgeless/clipboard/clipboard.ts | 8 ++--- .../auto-complete/auto-complete-panel.ts | 6 ++-- .../components/auto-complete/utils.ts | 6 ++-- .../text/edgeless-connector-label-editor.ts | 4 +-- .../text/edgeless-shape-text-editor.ts | 4 +-- .../toolbar/mindmap/basket-elements.ts | 4 +-- .../src/root-block/edgeless/frame-manager.ts | 7 ++-- .../edgeless/gfx-tool/frame-tool.ts | 7 ++-- .../root-block/edgeless/gfx-tool/text-tool.ts | 4 +-- .../root-block/edgeless/services/template.ts | 3 +- .../src/root-block/edgeless/utils/text.ts | 8 ++--- .../embed-card-toolbar/embed-card-toolbar.ts | 5 +-- blocksuite/framework/block-std/package.json | 1 + .../gfx/model/surface/decorators/observer.ts | 2 +- .../src/gfx/model/surface/element-model.ts | 6 ++-- .../src/gfx/model/surface/surface-model.ts | 7 ++-- blocksuite/framework/inline/package.json | 10 ++---- blocksuite/framework/store/package.json | 10 ++---- .../src/__tests__/collection.unit.spec.ts | 2 +- blocksuite/framework/store/src/index.ts | 3 -- .../framework/store/src/store/collection.ts | 14 +------- .../apps/default/utils/collection.ts | 3 +- blocksuite/playground/apps/env.d.ts | 3 +- .../apps/starter/data/pending-structs.ts | 13 ++++---- .../apps/starter/data/version-mismatch.ts | 8 ++--- .../apps/starter/utils/collection.ts | 3 +- blocksuite/presets/package.json | 1 + .../src/__tests__/edgeless/group.spec.ts | 12 +++---- .../src/__tests__/edgeless/layer.spec.ts | 7 ++-- .../src/fragments/comment/comment-input.ts | 6 ++-- .../src/fragments/comment/comment-manager.ts | 29 +++++++---------- .../src/fragments/doc-title/doc-title.ts | 2 +- .../frame-panel/card/frame-card-title.ts | 2 +- .../presets/ai/actions/page-response.ts | 5 +-- .../block-suite-editor/blocksuite-editor.tsx | 2 +- .../src/desktop/pages/workspace/index.tsx | 5 +++ .../core/src/modules/doc/stores/docs.ts | 2 +- .../modules/favorite/services/old/adapter.ts | 3 +- .../core/src/modules/tag/stores/tag.ts | 2 +- tests/affine-cloud/e2e/page-history.spec.ts | 2 +- yarn.lock | 32 ++++++------------- 70 files changed, 185 insertions(+), 210 deletions(-) diff --git a/blocksuite/affine/block-database/package.json b/blocksuite/affine/block-database/package.json index 9e1d20766b..a4b341aa6a 100644 --- a/blocksuite/affine/block-database/package.json +++ b/blocksuite/affine/block-database/package.json @@ -30,6 +30,7 @@ "date-fns": "^4.0.0", "lit": "^3.2.0", "minimatch": "^10.0.1", + "yjs": "^13.6.21", "zod": "^3.23.8" }, "exports": { diff --git a/blocksuite/affine/block-database/src/detail-panel/note-renderer.ts b/blocksuite/affine/block-database/src/detail-panel/note-renderer.ts index e1de4afb9d..8f284af540 100644 --- a/blocksuite/affine/block-database/src/detail-panel/note-renderer.ts +++ b/blocksuite/affine/block-database/src/detail-panel/note-renderer.ts @@ -66,7 +66,7 @@ export class NoteRenderer }, } satisfies AffineTextAttributes as BaseTextAttributes ); - collection.setDocMeta(note.id, { title: rowContent }); + collection.meta.setDocMeta(note.id, { title: rowContent }); if (note.root) { (note.root as RootBlockModel).title.insert(rowContent ?? '', 0); note.root.children diff --git a/blocksuite/affine/block-embed/package.json b/blocksuite/affine/block-embed/package.json index fd02ab7a25..97e11ba46b 100644 --- a/blocksuite/affine/block-embed/package.json +++ b/blocksuite/affine/block-embed/package.json @@ -28,6 +28,7 @@ "@toeverything/theme": "^1.1.3", "lit": "^3.2.0", "minimatch": "^10.0.1", + "yjs": "^13.6.21", "zod": "^3.23.8" }, "exports": { diff --git a/blocksuite/affine/block-embed/src/embed-linked-doc-block/embed-linked-doc-block.ts b/blocksuite/affine/block-embed/src/embed-linked-doc-block/embed-linked-doc-block.ts index 638a473c6b..7847f5b0d8 100644 --- a/blocksuite/affine/block-embed/src/embed-linked-doc-block/embed-linked-doc-block.ts +++ b/blocksuite/affine/block-embed/src/embed-linked-doc-block/embed-linked-doc-block.ts @@ -22,13 +22,13 @@ import { referenceToNode, } from '@blocksuite/affine-shared/utils'; import { Bound, throttle } from '@blocksuite/global/utils'; -import { DocCollection } from '@blocksuite/store'; import { computed } from '@preact/signals-core'; import { html, nothing } from 'lit'; import { property, queryAsync, state } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { styleMap } from 'lit/directives/style-map.js'; import { when } from 'lit/directives/when.js'; +import * as Y from 'yjs'; import { EmbedBlockComponent } from '../common/embed-block-element.js'; import { @@ -163,7 +163,7 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent ({ - elements: internalPrimitives.Boxed(new DocCollection.Y.Map()), + elements: internalPrimitives.Boxed(new Y.Map()), }), metadata: { version: 5, diff --git a/blocksuite/affine/block-surface/src/surface-transformer.ts b/blocksuite/affine/block-surface/src/surface-transformer.ts index d63f1d5f1a..aa50b1acab 100644 --- a/blocksuite/affine/block-surface/src/surface-transformer.ts +++ b/blocksuite/affine/block-surface/src/surface-transformer.ts @@ -3,9 +3,9 @@ import type { FromSnapshotPayload, SnapshotNode, ToSnapshotPayload, - Y, } from '@blocksuite/store'; -import { BaseBlockTransformer, DocCollection } from '@blocksuite/store'; +import { BaseBlockTransformer } from '@blocksuite/store'; +import * as Y from 'yjs'; const SURFACE_TEXT_UNIQ_IDENTIFIER = 'affine:surface:text'; // Used for group children field @@ -24,11 +24,11 @@ export class SurfaceBlockTransformer extends BaseBlockTransformer; Object.entries(json).forEach(([key, value]) => { yMap.set(key, value); @@ -40,12 +40,12 @@ export class SurfaceBlockTransformer extends BaseBlockTransformer) { - const yMap = new DocCollection.Y.Map(); + const yMap = new Y.Map(); Object.entries(element).forEach(([key, value]) => { yMap.set(key, this._fromJSON(value)); }); @@ -71,7 +71,7 @@ export class SurfaceBlockTransformer extends BaseBlockTransformer; - const yMap = new DocCollection.Y.Map>(); + const yMap = new Y.Map>(); Object.entries(elementsJSON).forEach(([key, value]) => { const element = this.elementFromJSON(value as Record); diff --git a/blocksuite/affine/block-surface/src/utils/mindmap/utils.ts b/blocksuite/affine/block-surface/src/utils/mindmap/utils.ts index 451752daca..a96b047835 100644 --- a/blocksuite/affine/block-surface/src/utils/mindmap/utils.ts +++ b/blocksuite/affine/block-surface/src/utils/mindmap/utils.ts @@ -14,7 +14,7 @@ import { type SurfaceBlockModel, } from '@blocksuite/block-std/gfx'; import { assertType, isEqual, type IVec, last } from '@blocksuite/global/utils'; -import { DocCollection } from '@blocksuite/store'; +import * as Y from 'yjs'; import { fitContent } from '../../renderer/elements/shape/utils.js'; import { layout } from './layout.js'; @@ -360,7 +360,7 @@ export function createFromTree( layoutType: LayoutType, surface: SurfaceBlockModel ) { - const children = new DocCollection.Y.Map(); + const children = new Y.Map(); const traverse = (subtree: MindmapNode, parent?: string) => { const value: NodeDetail = { ...subtree.detail, diff --git a/blocksuite/affine/components/package.json b/blocksuite/affine/components/package.json index d5ba4c9cb8..5203e6e3fa 100644 --- a/blocksuite/affine/components/package.json +++ b/blocksuite/affine/components/package.json @@ -31,6 +31,7 @@ "lit-html": "^3.2.1", "lodash.clonedeep": "^4.5.0", "shiki": "^1.12.0", + "yjs": "^13.6.21", "zod": "^3.23.8" }, "exports": { diff --git a/blocksuite/affine/components/src/rich-text/extension/inline-manager.ts b/blocksuite/affine/components/src/rich-text/extension/inline-manager.ts index 5351c10cb0..4785a77246 100644 --- a/blocksuite/affine/components/src/rich-text/extension/inline-manager.ts +++ b/blocksuite/affine/components/src/rich-text/extension/inline-manager.ts @@ -16,7 +16,7 @@ import { KEYBOARD_ALLOW_DEFAULT, type KeyboardBindingContext, } from '@blocksuite/inline'; -import type { Y } from '@blocksuite/store'; +import type * as Y from 'yjs'; import { z, type ZodObject, type ZodTypeAny } from 'zod'; import { MarkdownMatcherIdentifier } from './markdown-matcher.js'; diff --git a/blocksuite/affine/components/src/rich-text/extension/type.ts b/blocksuite/affine/components/src/rich-text/extension/type.ts index b667bcfc0e..79c265a145 100644 --- a/blocksuite/affine/components/src/rich-text/extension/type.ts +++ b/blocksuite/affine/components/src/rich-text/extension/type.ts @@ -6,7 +6,7 @@ import type { InlineRange, KeyboardBindingHandler, } from '@blocksuite/inline'; -import type { Y } from '@blocksuite/store'; +import type * as Y from 'yjs'; import type { ZodTypeAny } from 'zod'; export type InlineSpecs< diff --git a/blocksuite/affine/components/src/rich-text/inline/presets/nodes/latex-node/latex-editor-menu.ts b/blocksuite/affine/components/src/rich-text/inline/presets/nodes/latex-node/latex-editor-menu.ts index a2ddbe05b4..6adf3cbe6a 100644 --- a/blocksuite/affine/components/src/rich-text/inline/presets/nodes/latex-node/latex-editor-menu.ts +++ b/blocksuite/affine/components/src/rich-text/inline/presets/nodes/latex-node/latex-editor-menu.ts @@ -4,12 +4,11 @@ import { unsafeCSSVar } from '@blocksuite/affine-shared/theme'; import { type BlockStdScope, ShadowlessElement } from '@blocksuite/block-std'; import { noop, SignalWatcher, WithDisposable } from '@blocksuite/global/utils'; import { DoneIcon } from '@blocksuite/icons/lit'; -import type { Y } from '@blocksuite/store'; -import { DocCollection } from '@blocksuite/store'; import { effect, type Signal, signal } from '@preact/signals-core'; import { css, html } from 'lit'; import { property } from 'lit/decorators.js'; import { codeToTokensBase, type ThemedToken } from 'shiki'; +import * as Y from 'yjs'; import { InlineManagerExtension } from '../../../../extension/index.js'; import { LatexEditorUnitSpecExtension } from '../../affine-inline-specs.js'; @@ -111,7 +110,7 @@ export class LatexEditorMenu extends SignalWatcher( override connectedCallback(): void { super.connectedCallback(); - const doc = new DocCollection.Y.Doc(); + const doc = new Y.Doc(); this.yText = doc.getText('latex'); this.yText.insert(0, this.latexSignal.value); diff --git a/blocksuite/affine/components/src/rich-text/rich-text.ts b/blocksuite/affine/components/src/rich-text/rich-text.ts index de58c9e1f9..fedee0aa75 100644 --- a/blocksuite/affine/components/src/rich-text/rich-text.ts +++ b/blocksuite/affine/components/src/rich-text/rich-text.ts @@ -11,12 +11,12 @@ import { type KeyboardBindingContext, type VLine, } from '@blocksuite/inline'; -import type { Y } from '@blocksuite/store'; -import { DocCollection, Text } from '@blocksuite/store'; +import { Text } from '@blocksuite/store'; import { effect } from '@preact/signals-core'; import { css, html, type TemplateResult } from 'lit'; import { property, query } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; +import * as Y from 'yjs'; import { z } from 'zod'; import { onVBeforeinput, onVCompositionEnd } from './hooks.js'; @@ -289,7 +289,7 @@ export class RichText extends WithDisposable(ShadowlessElement) { } if (!this.undoManager) { - this.undoManager = new DocCollection.Y.UndoManager(this._yText, { + this.undoManager = new Y.UndoManager(this._yText, { trackedOrigins: new Set([this._yText.doc.clientID]), }); } diff --git a/blocksuite/affine/data-view/package.json b/blocksuite/affine/data-view/package.json index ed53a494f1..23722fa9f3 100644 --- a/blocksuite/affine/data-view/package.json +++ b/blocksuite/affine/data-view/package.json @@ -26,6 +26,7 @@ "@toeverything/theme": "^1.1.3", "date-fns": "^4.0.0", "lit": "^3.2.0", + "yjs": "^13.6.21", "zod": "^3.23.8" }, "exports": { diff --git a/blocksuite/affine/data-view/src/view-presets/table/pc/controller/drag-to-fill.ts b/blocksuite/affine/data-view/src/view-presets/table/pc/controller/drag-to-fill.ts index fee979f3de..2c8f9af16d 100644 --- a/blocksuite/affine/data-view/src/view-presets/table/pc/controller/drag-to-fill.ts +++ b/blocksuite/affine/data-view/src/view-presets/table/pc/controller/drag-to-fill.ts @@ -1,9 +1,10 @@ import { ShadowlessElement } from '@blocksuite/block-std'; import { assertEquals } from '@blocksuite/global/utils'; -import { DocCollection, type Text } from '@blocksuite/store'; +import { type Text } from '@blocksuite/store'; import { css, html } from 'lit'; import { state } from 'lit/decorators.js'; import { createRef, ref } from 'lit/directives/ref.js'; +import * as Y from 'yjs'; import { t } from '../../../../core/index.js'; import type { TableAreaSelection } from '../../types.js'; @@ -98,7 +99,7 @@ export function fillSelectionWithFocusCellData( curCellText.clear(); curCellText.applyDelta(delta); } else { - const newText = new DocCollection.Y.Text(); + const newText = new Y.Text(); newText.applyDelta(delta); curCell.valueSet(newText); } diff --git a/blocksuite/affine/model/package.json b/blocksuite/affine/model/package.json index de2fee59c8..c923f6c09d 100644 --- a/blocksuite/affine/model/package.json +++ b/blocksuite/affine/model/package.json @@ -18,6 +18,7 @@ "@blocksuite/inline": "workspace:*", "@blocksuite/store": "workspace:*", "fractional-indexing": "^3.2.0", + "yjs": "^13.6.21", "zod": "^3.23.8" }, "exports": { diff --git a/blocksuite/affine/model/src/blocks/root/root-block-model.ts b/blocksuite/affine/model/src/blocks/root/root-block-model.ts index ab52d9c55c..7a44df55c8 100644 --- a/blocksuite/affine/model/src/blocks/root/root-block-model.ts +++ b/blocksuite/affine/model/src/blocks/root/root-block-model.ts @@ -14,7 +14,7 @@ export class RootBlockModel extends BlockModel { if (model instanceof RootBlockModel) { const newDocMeta = this.doc.collection.meta.getDocMeta(model.doc.id); if (!newDocMeta || newDocMeta.title !== model.title.toString()) { - this.doc.collection.setDocMeta(model.doc.id, { + this.doc.collection.meta.setDocMeta(model.doc.id, { title: model.title.toString(), }); } diff --git a/blocksuite/affine/model/src/elements/connector/connector.ts b/blocksuite/affine/model/src/elements/connector/connector.ts index 6e33a27e69..8a64cfdebc 100644 --- a/blocksuite/affine/model/src/elements/connector/connector.ts +++ b/blocksuite/affine/model/src/elements/connector/connector.ts @@ -23,7 +23,7 @@ import { polyLineNearestPoint, Vec, } from '@blocksuite/global/utils'; -import { DocCollection, type Y } from '@blocksuite/store'; +import * as Y from 'yjs'; import { CONNECTOR_LABEL_MAX_WIDTH, @@ -126,8 +126,8 @@ export class ConnectorElementModel extends GfxPrimitiveElementModel; @@ -37,12 +36,12 @@ export class GroupElementModel extends GfxGroupLikeElementModel) { - if ('title' in props && !(props.title instanceof DocCollection.Y.Text)) { - props.title = new DocCollection.Y.Text(props.title as string); + if ('title' in props && !(props.title instanceof Y.Text)) { + props.title = new Y.Text(props.title as string); } - if (props.children && !(props.children instanceof DocCollection.Y.Map)) { - const children = new DocCollection.Y.Map() as Y.Map; + if (props.children && !(props.children instanceof Y.Map)) { + const children = new Y.Map() as Y.Map; keys(props.children).forEach(key => { children.set(key as string, true); @@ -112,13 +111,13 @@ export class GroupElementModel extends GfxGroupLikeElementModel = new DocCollection.Y.Map(); + accessor children: Y.Map = new Y.Map(); @local() accessor showTitle: boolean = true; @field() - accessor title: Y.Text = new DocCollection.Y.Text(); + accessor title: Y.Text = new Y.Text(); } declare global { diff --git a/blocksuite/affine/model/src/elements/mindmap/mindmap.ts b/blocksuite/affine/model/src/elements/mindmap/mindmap.ts index 0c05018c30..434a9df91e 100644 --- a/blocksuite/affine/model/src/elements/mindmap/mindmap.ts +++ b/blocksuite/affine/model/src/elements/mindmap/mindmap.ts @@ -20,8 +20,8 @@ import { noop, pick, } from '@blocksuite/global/utils'; -import { DocCollection, type Y } from '@blocksuite/store'; import { generateKeyBetween } from 'fractional-indexing'; +import * as Y from 'yjs'; import { z } from 'zod'; import { ConnectorMode } from '../../consts/connector.js'; @@ -183,9 +183,9 @@ export class MindmapElementModel extends GfxGroupLikeElementModel) && - !(props.children instanceof DocCollection.Y.Map) + !(props.children instanceof Y.Map) ) { - const children: Y.Map = new DocCollection.Y.Map(); + const children: Y.Map = new Y.Map(); keys(props.children).forEach(key => { const detail = pick, keyof NodeDetail>( @@ -284,9 +284,7 @@ export class MindmapElementModel extends GfxGroupLikeElementModel { - if (!(initialValue instanceof DocCollection.Y.Map)) { + if (!(initialValue instanceof Y.Map)) { nodeSchema.parse(initialValue); assertType(initialValue); - const map: Y.Map = new DocCollection.Y.Map(); + const map: Y.Map = new Y.Map(); const surface = instance.surface; const doc = surface.doc; const recursive = ( @@ -967,7 +965,7 @@ export class MindmapElementModel extends GfxGroupLikeElementModel = new DocCollection.Y.Map(); + accessor children: Y.Map = new Y.Map(); @watch(watchLayoutType) @field() diff --git a/blocksuite/affine/model/src/elements/shape/shape.ts b/blocksuite/affine/model/src/elements/shape/shape.ts index 36b216cf9f..e44345e88a 100644 --- a/blocksuite/affine/model/src/elements/shape/shape.ts +++ b/blocksuite/affine/model/src/elements/shape/shape.ts @@ -16,7 +16,7 @@ import type { PointLocation, SerializedXYWH, } from '@blocksuite/global/utils'; -import { DocCollection, type Y } from '@blocksuite/store'; +import * as Y from 'yjs'; import { DEFAULT_ROUGHNESS, @@ -68,8 +68,8 @@ export class ShapeElementModel extends GfxPrimitiveElementModel { } static override propsToY(props: ShapeProps) { - if (props.text && !(props.text instanceof DocCollection.Y.Text)) { - props.text = new DocCollection.Y.Text(props.text); + if (props.text && !(props.text instanceof Y.Text)) { + props.text = new Y.Text(props.text); } return props; diff --git a/blocksuite/affine/model/src/elements/text/text.ts b/blocksuite/affine/model/src/elements/text/text.ts index 548fd551eb..4403af9907 100644 --- a/blocksuite/affine/model/src/elements/text/text.ts +++ b/blocksuite/affine/model/src/elements/text/text.ts @@ -8,7 +8,7 @@ import { pointInPolygon, polygonNearestPoint, } from '@blocksuite/global/utils'; -import { DocCollection, type Y } from '@blocksuite/store'; +import * as Y from 'yjs'; import { FontFamily, @@ -31,8 +31,8 @@ export class TextElementModel extends GfxPrimitiveElementModel } static override propsToY(props: Record) { - if (props.text && !(props.text instanceof DocCollection.Y.Text)) { - props.text = new DocCollection.Y.Text(props.text as string); + if (props.text && !(props.text instanceof Y.Text)) { + props.text = new Y.Text(props.text as string); } return props; @@ -82,7 +82,7 @@ export class TextElementModel extends GfxPrimitiveElementModel accessor rotate: number = 0; @field() - accessor text: Y.Text = new DocCollection.Y.Text(); + accessor text: Y.Text = new Y.Text(); @field() accessor textAlign: TextAlign = TextAlign.Center; diff --git a/blocksuite/affine/shared/package.json b/blocksuite/affine/shared/package.json index 0509bff19a..6cc40175a9 100644 --- a/blocksuite/affine/shared/package.json +++ b/blocksuite/affine/shared/package.json @@ -44,6 +44,7 @@ "remark-parse": "^11.0.0", "remark-stringify": "^11.0.0", "unified": "^11.0.5", + "yjs": "^13.6.21", "zod": "^3.23.8" }, "exports": { diff --git a/blocksuite/affine/shared/src/adapters/middlewares/paste.ts b/blocksuite/affine/shared/src/adapters/middlewares/paste.ts index 1950a5c0ee..2c67f6da7c 100644 --- a/blocksuite/affine/shared/src/adapters/middlewares/paste.ts +++ b/blocksuite/affine/shared/src/adapters/middlewares/paste.ts @@ -17,12 +17,12 @@ import { type BlockModel, type BlockSnapshot, type DeltaOperation, - DocCollection, fromJSON, type JobMiddleware, type SliceSnapshot, type Text, } from '@blocksuite/store'; +import * as Y from 'yjs'; import { REFERENCE_NODE } from '../../consts'; import { @@ -357,7 +357,7 @@ class PasteTr { !matchFlavours(this.pointState.model, ['affine:code']) ) { const text = fromJSON(this.lastSnapshot.props.text) as Text; - const doc = new DocCollection.Y.Doc(); + const doc = new Y.Doc(); const temp = doc.getMap('temp'); temp.set('text', text.yText); this.lastIndex = text.length; diff --git a/blocksuite/affine/shared/src/services/edit-props-store.ts b/blocksuite/affine/shared/src/services/edit-props-store.ts index 11f8d58013..7c89fe64de 100644 --- a/blocksuite/affine/shared/src/services/edit-props-store.ts +++ b/blocksuite/affine/shared/src/services/edit-props-store.ts @@ -6,10 +6,10 @@ import { DisposableGroup, Slot, } from '@blocksuite/global/utils'; -import { DocCollection } from '@blocksuite/store'; import { computed, type Signal, signal } from '@preact/signals-core'; import clonedeep from 'lodash.clonedeep'; import mergeWith from 'lodash.mergewith'; +import * as Y from 'yjs'; import { z } from 'zod'; import { makeDeepOptional, NodePropsSchema } from '../utils/index.js'; @@ -63,9 +63,9 @@ function isSessionProp(key: string): key is keyof SessionProps { function customizer(_target: unknown, source: unknown) { if ( ColorSchema.safeParse(source).success || - source instanceof DocCollection.Y.Text || - source instanceof DocCollection.Y.Array || - source instanceof DocCollection.Y.Map + source instanceof Y.Text || + source instanceof Y.Array || + source instanceof Y.Map ) { return source; } diff --git a/blocksuite/affine/shared/src/utils/model/doc.ts b/blocksuite/affine/shared/src/utils/model/doc.ts index 663d11ebb5..78f2fb37c0 100644 --- a/blocksuite/affine/shared/src/utils/model/doc.ts +++ b/blocksuite/affine/shared/src/utils/model/doc.ts @@ -11,7 +11,7 @@ export function createDefaultDoc( const rootId = doc.addBlock('affine:page', { title: new doc.Text(title), }); - collection.setDocMeta(doc.id, { + collection.meta.setDocMeta(doc.id, { title, }); diff --git a/blocksuite/blocks/package.json b/blocksuite/blocks/package.json index c96ee78989..878a6b9e48 100644 --- a/blocksuite/blocks/package.json +++ b/blocksuite/blocks/package.json @@ -80,6 +80,7 @@ "shiki": "^1.14.1", "simple-xml-to-json": "^1.2.2", "unified": "^11.0.5", + "yjs": "^13.6.21", "zod": "^3.23.8" }, "exports": { diff --git a/blocksuite/blocks/src/root-block/edgeless/clipboard/clipboard.ts b/blocksuite/blocks/src/root-block/edgeless/clipboard/clipboard.ts index 78cadd84fa..ee3c54cfcc 100644 --- a/blocksuite/blocks/src/root-block/edgeless/clipboard/clipboard.ts +++ b/blocksuite/blocks/src/root-block/edgeless/clipboard/clipboard.ts @@ -57,12 +57,12 @@ import { import { type BlockSnapshot, BlockSnapshotSchema, - DocCollection, fromJSON, Job, type SliceSnapshot, } from '@blocksuite/store'; import DOMPurify from 'dompurify'; +import * as Y from 'yjs'; import { ExportManager } from '../../../_common/export-manager/export-manager.js'; import { getRootByEditorHost } from '../../../_common/utils/query.js'; @@ -522,7 +522,7 @@ export class EdgelessClipboardController extends PageClipboard { newXYWH: SerializedXYWH ) { if (clipboardData.type === GROUP) { - const yMap = new DocCollection.Y.Map(); + const yMap = new Y.Map(); const children = clipboardData.children ?? {}; for (const [key, value] of Object.entries(children)) { @@ -536,7 +536,7 @@ export class EdgelessClipboardController extends PageClipboard { clipboardData.children = yMap; clipboardData.xywh = newXYWH; } else if (clipboardData.type === MINDMAP) { - const yMap = new DocCollection.Y.Map(); + const yMap = new Y.Map(); const children = clipboardData.children ?? {}; for (const [oldKey, oldValue] of Object.entries(children)) { @@ -1112,7 +1112,7 @@ export class EdgelessClipboardController extends PageClipboard { TextUtils.splitIntoLines(content).forEach((line, idx) => { this.crud.addBlock( 'affine:paragraph', - { text: new DocCollection.Y.Text(line) }, + { text: new Y.Text(line) }, noteId, idx ); diff --git a/blocksuite/blocks/src/root-block/edgeless/components/auto-complete/auto-complete-panel.ts b/blocksuite/blocks/src/root-block/edgeless/components/auto-complete/auto-complete-panel.ts index 71d5c4deaa..a1d69b4df2 100644 --- a/blocksuite/blocks/src/root-block/edgeless/components/auto-complete/auto-complete-panel.ts +++ b/blocksuite/blocks/src/root-block/edgeless/components/auto-complete/auto-complete-panel.ts @@ -40,13 +40,13 @@ import { Vec, WithDisposable, } from '@blocksuite/global/utils'; -import { DocCollection } from '@blocksuite/store'; import { consume } from '@lit/context'; import { baseTheme } from '@toeverything/theme'; import { css, html, LitElement, nothing, unsafeCSS } from 'lit'; import { property } from 'lit/decorators.js'; import { repeat } from 'lit/directives/repeat.js'; import { styleMap } from 'lit/directives/style-map.js'; +import * as Y from 'yjs'; import type { EdgelessRootBlockComponent } from '../../edgeless-root-block.js'; import { @@ -157,7 +157,7 @@ export class EdgelessAutoCompletePanel extends WithDisposable(LitElement) { const id = this.crud.addBlock( 'affine:frame', { - title: new DocCollection.Y.Text(`Frame ${frameIndex}`), + title: new Y.Text(`Frame ${frameIndex}`), xywh: serializeXYWH(...xywh), presentationIndex: frameMgr.generatePresentationIndex(), }, @@ -275,7 +275,7 @@ export class EdgelessAutoCompletePanel extends WithDisposable(LitElement) { } else { const textId = this.crud.addElement(CanvasElementType.TEXT, { xywh: bound.serialize(), - text: new DocCollection.Y.Text(), + text: new Y.Text(), textAlign: 'left', fontSize: 24, fontFamily: FontFamily.Inter, diff --git a/blocksuite/blocks/src/root-block/edgeless/components/auto-complete/utils.ts b/blocksuite/blocks/src/root-block/edgeless/components/auto-complete/utils.ts index 0a0ab17265..e9b0ae18a9 100644 --- a/blocksuite/blocks/src/root-block/edgeless/components/auto-complete/utils.ts +++ b/blocksuite/blocks/src/root-block/edgeless/components/auto-complete/utils.ts @@ -18,7 +18,7 @@ import type { GfxController, GfxModel } from '@blocksuite/block-std/gfx'; import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions'; import type { XYWH } from '@blocksuite/global/utils'; import { assertType, Bound } from '@blocksuite/global/utils'; -import { DocCollection } from '@blocksuite/store'; +import * as Y from 'yjs'; import type { EdgelessRootBlockComponent } from '../../edgeless-root-block.js'; import { type Shape, ShapeFactory } from '../../utils/tool-overlay.js'; @@ -284,7 +284,7 @@ export function createEdgelessElement( if (isShape(current)) { id = crud.addElement(current.type, { ...current.serialize(), - text: new DocCollection.Y.Text(), + text: new Y.Text(), xywh: bound.serialize(), }); if (!id) return null; @@ -340,7 +340,7 @@ export function createShapeElement( const id = crud.addElement('shape', { shapeType: getShapeType(targetType), radius: getShapeRadius(targetType), - text: new DocCollection.Y.Text(), + text: new Y.Text(), }); if (!id) return null; const element = crud.getElementById(id); diff --git a/blocksuite/blocks/src/root-block/edgeless/components/text/edgeless-connector-label-editor.ts b/blocksuite/blocks/src/root-block/edgeless/components/text/edgeless-connector-label-editor.ts index ddffe9c80d..b4b7bf3308 100644 --- a/blocksuite/blocks/src/root-block/edgeless/components/text/edgeless-connector-label-editor.ts +++ b/blocksuite/blocks/src/root-block/edgeless/components/text/edgeless-connector-label-editor.ts @@ -16,10 +16,10 @@ import { Vec, WithDisposable, } from '@blocksuite/global/utils'; -import { DocCollection } from '@blocksuite/store'; import { css, html, nothing } from 'lit'; import { property, query } from 'lit/decorators.js'; import { styleMap } from 'lit/directives/style-map.js'; +import * as Y from 'yjs'; import type { EdgelessRootBlockComponent } from '../../edgeless-root-block.js'; @@ -187,7 +187,7 @@ export class EdgelessConnectorLabelEditor extends WithDisposable( } else if (len < text.length) { this.crud.updateElement(connector.id, { // @TODO: trim in Y.Text? - text: new DocCollection.Y.Text(trimed), + text: new Y.Text(trimed), }); } } diff --git a/blocksuite/blocks/src/root-block/edgeless/components/text/edgeless-shape-text-editor.ts b/blocksuite/blocks/src/root-block/edgeless/components/text/edgeless-shape-text-editor.ts index 1fb63c0670..2a15c9afe9 100644 --- a/blocksuite/blocks/src/root-block/edgeless/components/text/edgeless-shape-text-editor.ts +++ b/blocksuite/blocks/src/root-block/edgeless/components/text/edgeless-shape-text-editor.ts @@ -18,10 +18,10 @@ import { Vec, WithDisposable, } from '@blocksuite/global/utils'; -import { DocCollection } from '@blocksuite/store'; import { html, nothing } from 'lit'; import { property, query } from 'lit/decorators.js'; import { styleMap } from 'lit/directives/style-map.js'; +import * as Y from 'yjs'; import type { EdgelessRootBlockComponent } from '../../edgeless-root-block.js'; @@ -110,7 +110,7 @@ export class EdgelessShapeTextEditor extends WithDisposable(ShadowlessElement) { if (len === 0) { this.element.text = undefined; } else if (len < text.length) { - this.element.text = new DocCollection.Y.Text(trimed); + this.element.text = new Y.Text(trimed); } } diff --git a/blocksuite/blocks/src/root-block/edgeless/components/toolbar/mindmap/basket-elements.ts b/blocksuite/blocks/src/root-block/edgeless/components/toolbar/mindmap/basket-elements.ts index b2c8445cc8..4842c1c8d4 100644 --- a/blocksuite/blocks/src/root-block/edgeless/components/toolbar/mindmap/basket-elements.ts +++ b/blocksuite/blocks/src/root-block/edgeless/components/toolbar/mindmap/basket-elements.ts @@ -2,8 +2,8 @@ import { CanvasElementType } from '@blocksuite/affine-block-surface'; import { type MindmapStyle, TextElementModel } from '@blocksuite/affine-model'; import { TelemetryProvider } from '@blocksuite/affine-shared/services'; import { assertInstanceOf, Bound } from '@blocksuite/global/utils'; -import { DocCollection } from '@blocksuite/store'; import type { TemplateResult } from 'lit'; +import * as Y from 'yjs'; import type { EdgelessRootBlockComponent } from '../../../edgeless-root-block.js'; import type { EdgelessRootService } from '../../../edgeless-root-service.js'; @@ -114,7 +114,7 @@ export const textRender: DraggableTool['render'] = ( } else { id = service.crud.addElement(CanvasElementType.TEXT, { xywh: new Bound(bound.x, vCenter - h / 2, w, h).serialize(), - text: new DocCollection.Y.Text(), + text: new Y.Text(), }) as string; edgeless.doc.captureSync(); diff --git a/blocksuite/blocks/src/root-block/edgeless/frame-manager.ts b/blocksuite/blocks/src/root-block/edgeless/frame-manager.ts index e95b14a5d6..b0c2599b7f 100644 --- a/blocksuite/blocks/src/root-block/edgeless/frame-manager.ts +++ b/blocksuite/blocks/src/root-block/edgeless/frame-manager.ts @@ -20,7 +20,8 @@ import { type SerializedXYWH, } from '@blocksuite/global/utils'; import type { Doc } from '@blocksuite/store'; -import { DocCollection, Text } from '@blocksuite/store'; +import { Text } from '@blocksuite/store'; +import * as Y from 'yjs'; import type { FrameBlockModel, NoteBlockModel } from '../../index.js'; import { areSetsEqual } from './utils/misc.js'; @@ -196,9 +197,7 @@ export class EdgelessFrameManager extends GfxExtension { const id = this.gfx.doc.addBlock( 'affine:frame', { - title: new Text( - new DocCollection.Y.Text(`Frame ${this.frames.length + 1}`) - ), + title: new Text(new Y.Text(`Frame ${this.frames.length + 1}`)), xywh: bound.serialize(), index: this.gfx.layer.generateIndex(true), presentationIndex: this.generatePresentationIndex(), diff --git a/blocksuite/blocks/src/root-block/edgeless/gfx-tool/frame-tool.ts b/blocksuite/blocks/src/root-block/edgeless/gfx-tool/frame-tool.ts index a16a54a91e..9c801f89d1 100644 --- a/blocksuite/blocks/src/root-block/edgeless/gfx-tool/frame-tool.ts +++ b/blocksuite/blocks/src/root-block/edgeless/gfx-tool/frame-tool.ts @@ -9,7 +9,8 @@ import { } from '@blocksuite/block-std/gfx'; import type { IPoint, IVec } from '@blocksuite/global/utils'; import { Bound, Vec } from '@blocksuite/global/utils'; -import { DocCollection, Text } from '@blocksuite/store'; +import { Text } from '@blocksuite/store'; +import * as Y from 'yjs'; import type { EdgelessFrameManager, FrameOverlay } from '../frame-manager.js'; @@ -72,9 +73,7 @@ export class FrameTool extends BaseTool { const id = this.doc.addBlock( 'affine:frame', { - title: new Text( - new DocCollection.Y.Text(`Frame ${frames.length + 1}`) - ), + title: new Text(new Y.Text(`Frame ${frames.length + 1}`)), xywh: Bound.fromPoints([this._startPoint, currentPoint]).serialize(), index: this.gfx.layer.generateIndex(true), presentationIndex: this.frameManager.generatePresentationIndex(), diff --git a/blocksuite/blocks/src/root-block/edgeless/gfx-tool/text-tool.ts b/blocksuite/blocks/src/root-block/edgeless/gfx-tool/text-tool.ts index 7abbeec403..c750c7ee24 100644 --- a/blocksuite/blocks/src/root-block/edgeless/gfx-tool/text-tool.ts +++ b/blocksuite/blocks/src/root-block/edgeless/gfx-tool/text-tool.ts @@ -3,7 +3,7 @@ import { TelemetryProvider } from '@blocksuite/affine-shared/services'; import type { PointerEventState } from '@blocksuite/block-std'; import { BaseTool, type GfxController } from '@blocksuite/block-std/gfx'; import { Bound } from '@blocksuite/global/utils'; -import { DocCollection } from '@blocksuite/store'; +import * as Y from 'yjs'; import type { EdgelessRootBlockComponent } from '../edgeless-root-block.js'; import { mountTextElementEditor } from '../utils/text.js'; @@ -22,7 +22,7 @@ export function addText(gfx: GfxController, event: PointerEventState) { const id = gfx.surface.addElement({ type: 'text', xywh: new Bound(modelX, modelY, 32, 32).serialize(), - text: new DocCollection.Y.Text(), + text: new Y.Text(), }); gfx.doc.captureSync(); const textElement = gfx.getElementById(id) as TextElementModel; diff --git a/blocksuite/blocks/src/root-block/edgeless/services/template.ts b/blocksuite/blocks/src/root-block/edgeless/services/template.ts index d4332a9abc..c39a95a05f 100644 --- a/blocksuite/blocks/src/root-block/edgeless/services/template.ts +++ b/blocksuite/blocks/src/root-block/edgeless/services/template.ts @@ -17,9 +17,8 @@ import { DocSnapshotSchema, Job, type SnapshotNode, - type Y, } from '@blocksuite/store'; - +import type * as Y from 'yjs'; /** * Those block contains other block's id * should defer the loading diff --git a/blocksuite/blocks/src/root-block/edgeless/utils/text.ts b/blocksuite/blocks/src/root-block/edgeless/utils/text.ts index cd6b1c8fca..a3063295fc 100644 --- a/blocksuite/blocks/src/root-block/edgeless/utils/text.ts +++ b/blocksuite/blocks/src/root-block/edgeless/utils/text.ts @@ -14,7 +14,7 @@ import type { PointerEventState } from '@blocksuite/block-std'; import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions'; import type { IVec } from '@blocksuite/global/utils'; import { assertInstanceOf, Bound } from '@blocksuite/global/utils'; -import { DocCollection } from '@blocksuite/store'; +import * as Y from 'yjs'; import { EdgelessConnectorLabelEditor } from '../components/text/edgeless-connector-label-editor.js'; import { EdgelessFrameTitleEditor } from '../components/text/edgeless-frame-title-editor.js'; @@ -73,7 +73,7 @@ export function mountShapeTextEditor( } if (!shapeElement.text) { - const text = new DocCollection.Y.Text(); + const text = new Y.Text(); edgeless.std .get(EdgelessCRUDIdentifier) .updateElement(shapeElement.id, { text }); @@ -167,7 +167,7 @@ export function addText( .get(EdgelessCRUDIdentifier) .addElement(CanvasElementType.TEXT, { xywh: new Bound(modelX, modelY, 32, 32).serialize(), - text: new DocCollection.Y.Text(), + text: new Y.Text(), }); if (!id) return; edgeless.doc.captureSync(); @@ -192,7 +192,7 @@ export function mountConnectorLabelEditor( } if (!connector.text) { - const text = new DocCollection.Y.Text(); + const text = new Y.Text(); const labelOffset = connector.labelOffset; let labelXYWH = connector.labelXYWH ?? [0, 0, 16, 16]; diff --git a/blocksuite/blocks/src/root-block/widgets/embed-card-toolbar/embed-card-toolbar.ts b/blocksuite/blocks/src/root-block/widgets/embed-card-toolbar/embed-card-toolbar.ts index c85b4e2a10..f604b4e7c0 100644 --- a/blocksuite/blocks/src/root-block/widgets/embed-card-toolbar/embed-card-toolbar.ts +++ b/blocksuite/blocks/src/root-block/widgets/embed-card-toolbar/embed-card-toolbar.ts @@ -53,7 +53,7 @@ import { } from '@blocksuite/affine-shared/services'; import { getHostName, referenceToNode } from '@blocksuite/affine-shared/utils'; import { type BlockStdScope, WidgetComponent } from '@blocksuite/block-std'; -import { type BlockModel, DocCollection } from '@blocksuite/store'; +import { type BlockModel } from '@blocksuite/store'; import { autoUpdate, computePosition, flip, offset } from '@floating-ui/dom'; import { html, nothing, type TemplateResult } from 'lit'; import { query, state } from 'lit/decorators.js'; @@ -61,6 +61,7 @@ import { classMap } from 'lit/directives/class-map.js'; import { ifDefined } from 'lit/directives/if-defined.js'; import { join } from 'lit/directives/join.js'; import { repeat } from 'lit/directives/repeat.js'; +import * as Y from 'yjs'; import { isBookmarkBlock, @@ -614,7 +615,7 @@ export class EmbedCardToolbar extends WidgetComponent< const parent = doc.getParent(targetModel); const index = parent?.children.indexOf(targetModel); - const yText = new DocCollection.Y.Text(); + const yText = new Y.Text(); const insert = title || caption || url; yText.insert(0, insert); yText.format(0, insert.length, { link: url }); diff --git a/blocksuite/framework/block-std/package.json b/blocksuite/framework/block-std/package.json index bbcf66b541..60df9164bb 100644 --- a/blocksuite/framework/block-std/package.json +++ b/blocksuite/framework/block-std/package.json @@ -28,6 +28,7 @@ "rehype-parse": "^9.0.0", "unified": "^11.0.5", "w3c-keyname": "^2.2.8", + "yjs": "^13.6.21", "zod": "^3.23.8" }, "exports": { diff --git a/blocksuite/framework/block-std/src/gfx/model/surface/decorators/observer.ts b/blocksuite/framework/block-std/src/gfx/model/surface/decorators/observer.ts index f2d9e9a641..a9bf37e4c1 100644 --- a/blocksuite/framework/block-std/src/gfx/model/surface/decorators/observer.ts +++ b/blocksuite/framework/block-std/src/gfx/model/surface/decorators/observer.ts @@ -1,4 +1,4 @@ -import type { Y } from '@blocksuite/store'; +import type * as Y from 'yjs'; import type { GfxPrimitiveElementModel } from '../element-model.js'; import { getObjectPropMeta, setObjectPropMeta } from './common.js'; diff --git a/blocksuite/framework/block-std/src/gfx/model/surface/element-model.ts b/blocksuite/framework/block-std/src/gfx/model/surface/element-model.ts index 3841819170..f3f1404afe 100644 --- a/blocksuite/framework/block-std/src/gfx/model/surface/element-model.ts +++ b/blocksuite/framework/block-std/src/gfx/model/surface/element-model.ts @@ -16,8 +16,8 @@ import { Slot, type XYWH, } from '@blocksuite/global/utils'; -import { DocCollection, type Y } from '@blocksuite/store'; import { createMutex } from 'lib0/mutex'; +import * as Y from 'yjs'; import { descendantElementsImpl, @@ -538,7 +538,7 @@ export function syncElementFromY( if (type.action === 'update' || type.action === 'add') { const value = model.yMap.get(key); - if (value instanceof DocCollection.Y.Text) { + if (value instanceof Y.Text) { disposables[key]?.(); disposables[key] = watchText(key, value, callback); } @@ -560,7 +560,7 @@ export function syncElementFromY( }; Array.from(model.yMap.entries()).forEach(([key, value]) => { - if (value instanceof DocCollection.Y.Text) { + if (value instanceof Y.Text) { disposables[key] = watchText(key, value, callback); } diff --git a/blocksuite/framework/block-std/src/gfx/model/surface/surface-model.ts b/blocksuite/framework/block-std/src/gfx/model/surface/surface-model.ts index 4a147ce67f..ef7126d15f 100644 --- a/blocksuite/framework/block-std/src/gfx/model/surface/surface-model.ts +++ b/blocksuite/framework/block-std/src/gfx/model/surface/surface-model.ts @@ -1,6 +1,7 @@ import { assertType, type Constructor, Slot } from '@blocksuite/global/utils'; -import type { Boxed, Y } from '@blocksuite/store'; -import { BlockModel, DocCollection, nanoid } from '@blocksuite/store'; +import type { Boxed } from '@blocksuite/store'; +import { BlockModel, nanoid } from '@blocksuite/store'; +import * as Y from 'yjs'; import { type GfxGroupCompatibleInterface, @@ -124,7 +125,7 @@ export class SurfaceBlockModel extends BlockModel { throw new Error('Cannot find id in props'); } - const yMap = new DocCollection.Y.Map(); + const yMap = new Y.Map(); const elementModel = this._createElementFromYMap( type as string, id as string, diff --git a/blocksuite/framework/inline/package.json b/blocksuite/framework/inline/package.json index 67e1bf5634..85a3ba4251 100644 --- a/blocksuite/framework/inline/package.json +++ b/blocksuite/framework/inline/package.json @@ -18,14 +18,6 @@ ], "author": "toeverything", "license": "MIT", - "devDependencies": { - "lit": "^3.2.0", - "yjs": "^13.6.21" - }, - "peerDependencies": { - "lit": "^3.2.0", - "yjs": "*" - }, "exports": { ".": "./src/index.ts", "./consts": "./src/consts.ts", @@ -35,6 +27,8 @@ "dependencies": { "@blocksuite/global": "workspace:*", "@preact/signals-core": "^1.8.0", + "lit": "^3.2.0", + "yjs": "^13.6.21", "zod": "^3.23.8" }, "version": "0.19.0" diff --git a/blocksuite/framework/store/package.json b/blocksuite/framework/store/package.json index 71363a7a1e..bf432b5b95 100644 --- a/blocksuite/framework/store/package.json +++ b/blocksuite/framework/store/package.json @@ -18,10 +18,8 @@ "@blocksuite/inline": "workspace:*", "@blocksuite/sync": "workspace:*", "@preact/signals-core": "^1.8.0", - "@types/flexsearch": "^0.7.6", "@types/lodash.ismatch": "^4.4.9", "file-type": "^19.5.0", - "flexsearch": "0.7.43", "lib0": "^0.2.97", "lodash.clonedeep": "^4.5.0", "lodash.ismatch": "^4.4.0", @@ -29,16 +27,12 @@ "minimatch": "^10.0.1", "nanoid": "^5.0.7", "y-protocols": "^1.0.6", + "yjs": "^13.6.21", "zod": "^3.23.8" }, "devDependencies": { "@types/lodash.clonedeep": "^4.5.9", - "@types/lodash.merge": "^4.6.9", - "lit": "^3.2.0", - "yjs": "^13.6.21" - }, - "peerDependencies": { - "yjs": "*" + "@types/lodash.merge": "^4.6.9" }, "exports": { ".": "./src/index.ts" diff --git a/blocksuite/framework/store/src/__tests__/collection.unit.spec.ts b/blocksuite/framework/store/src/__tests__/collection.unit.spec.ts index 9104fe690d..5e76e37d5a 100644 --- a/blocksuite/framework/store/src/__tests__/collection.unit.spec.ts +++ b/blocksuite/framework/store/src/__tests__/collection.unit.spec.ts @@ -436,7 +436,7 @@ describe('addBlock', () => { called = true; }); - collection.setDocMeta('doc:home', { favorite: true }); + collection.meta.setDocMeta('doc:home', { favorite: true }); assert.deepEqual( collection.meta.docMetas.map(({ id, title, favorite }) => ({ id, diff --git a/blocksuite/framework/store/src/index.ts b/blocksuite/framework/store/src/index.ts index 9047b1e4b7..0ad17ed650 100644 --- a/blocksuite/framework/store/src/index.ts +++ b/blocksuite/framework/store/src/index.ts @@ -1,7 +1,6 @@ // oxlint-disable-next-line @typescript-eslint/triple-slash-reference /// -export type { Y }; export * from './adapter/index.js'; export * from './reactive/index.js'; export * from './schema/index.js'; @@ -11,8 +10,6 @@ export { type IdGenerator, nanoid, uuidv4 } from './utils/id-generator.js'; export * as Utils from './utils/utils.js'; export * from './yjs/index.js'; -import type * as Y from 'yjs'; - const env = typeof globalThis !== 'undefined' ? globalThis diff --git a/blocksuite/framework/store/src/store/collection.ts b/blocksuite/framework/store/src/store/collection.ts index e412a0dca4..6162f6e14d 100644 --- a/blocksuite/framework/store/src/store/collection.ts +++ b/blocksuite/framework/store/src/store/collection.ts @@ -14,7 +14,6 @@ import { import clonedeep from 'lodash.clonedeep'; import merge from 'lodash.merge'; import { Awareness } from 'y-protocols/awareness.js'; -import * as Y from 'yjs'; import type { Schema } from '../schema/index.js'; import type { IdGenerator } from '../utils/id-generator.js'; @@ -27,7 +26,7 @@ import { BlockCollection, type GetDocOptions } from './doc/block-collection.js'; import type { Doc, Query } from './doc/index.js'; import type { IdGeneratorType } from './id.js'; import { pickIdGenerator } from './id.js'; -import { DocCollectionMeta, type DocMeta } from './meta.js'; +import { DocCollectionMeta } from './meta.js'; export type DocCollectionOptions = { schema: Schema; @@ -71,8 +70,6 @@ export interface StackItem { } export class DocCollection { - static Y = Y; - protected readonly _schema: Schema; readonly awarenessStore: AwarenessStore; @@ -252,15 +249,6 @@ export class DocCollection { this.blockCollections.delete(docId); } - /** Update doc meta state. Note that this intentionally does not mutate doc state. */ - setDocMeta( - docId: string, - // You should not update subDocIds directly. - props: Partial - ) { - this.meta.setDocMeta(docId, props); - } - /** * Start the data sync process */ diff --git a/blocksuite/playground/apps/default/utils/collection.ts b/blocksuite/playground/apps/default/utils/collection.ts index 9fce813425..a8dbbae847 100644 --- a/blocksuite/playground/apps/default/utils/collection.ts +++ b/blocksuite/playground/apps/default/utils/collection.ts @@ -14,6 +14,7 @@ import { IndexedDBBlobSource, IndexedDBDocSource, } from '@blocksuite/sync'; +import * as Y from 'yjs'; import { WebSocketAwarenessSource } from '../../_common/sync/websocket/awareness'; import { WebSocketDocSource } from '../../_common/sync/websocket/doc'; @@ -93,7 +94,7 @@ export async function createDefaultDocCollection() { delete: (id: string) => collection.removeDoc(id), }, }); - window.Y = DocCollection.Y; + window.Y = Y; return collection; } diff --git a/blocksuite/playground/apps/env.d.ts b/blocksuite/playground/apps/env.d.ts index cb9cda53dd..e7b01efa55 100644 --- a/blocksuite/playground/apps/env.d.ts +++ b/blocksuite/playground/apps/env.d.ts @@ -3,6 +3,7 @@ import type { TestUtils } from '@blocksuite/blocks'; import type { AffineEditorContainer } from '@blocksuite/presets'; import type { BlockSchema, Doc, DocCollection, Job } from '@blocksuite/store'; import type { z } from 'zod'; +import type * as Y from 'yjs'; declare global { type HTMLTemplate = [ @@ -17,7 +18,7 @@ declare global { collection: DocCollection; blockSchemas: z.infer[]; job: Job; - Y: typeof DocCollection.Y; + Y: typeof Y; std: typeof std; testUtils: TestUtils; host: EditorHost; diff --git a/blocksuite/playground/apps/starter/data/pending-structs.ts b/blocksuite/playground/apps/starter/data/pending-structs.ts index d5c7bd7dd5..f01e1d2db5 100644 --- a/blocksuite/playground/apps/starter/data/pending-structs.ts +++ b/blocksuite/playground/apps/starter/data/pending-structs.ts @@ -1,4 +1,5 @@ -import { DocCollection, Text } from '@blocksuite/store'; +import { type DocCollection, Text } from '@blocksuite/store'; +import * as Y from 'yjs'; import type { InitFn } from './utils.js'; @@ -13,10 +14,10 @@ export const pendingStructs: InitFn = ( const rootId = tempDoc.addBlock('affine:page', { title: new Text('Pending Structs'), }); - const vec = DocCollection.Y.encodeStateVector(tempDoc.spaceDoc); + const vec = Y.encodeStateVector(tempDoc.spaceDoc); // To avoid pending structs, uncomment the following line - // const update = DocCollection.Y.encodeStateAsUpdate(tempDoc.spaceDoc); + // const update = Y.encodeStateAsUpdate(tempDoc.spaceDoc); tempDoc.addBlock('affine:surface', {}, rootId); // Add note block inside root block @@ -28,11 +29,11 @@ export const pendingStructs: InitFn = ( }, noteId ); - const diff = DocCollection.Y.encodeStateAsUpdate(tempDoc.spaceDoc, vec); + const diff = Y.encodeStateAsUpdate(tempDoc.spaceDoc, vec); // To avoid pending structs, uncomment the following line - // DocCollection.Y.applyUpdate(doc.spaceDoc, update); + // Y.applyUpdate(doc.spaceDoc, update); - DocCollection.Y.applyUpdate(doc.spaceDoc, diff); + Y.applyUpdate(doc.spaceDoc, diff); }); }; diff --git a/blocksuite/playground/apps/starter/data/version-mismatch.ts b/blocksuite/playground/apps/starter/data/version-mismatch.ts index 9926a1ecb5..50a5629a5a 100644 --- a/blocksuite/playground/apps/starter/data/version-mismatch.ts +++ b/blocksuite/playground/apps/starter/data/version-mismatch.ts @@ -1,5 +1,5 @@ -import type { Y } from '@blocksuite/store'; -import { DocCollection } from '@blocksuite/store'; +import type { DocCollection } from '@blocksuite/store'; +import * as Y from 'yjs'; import type { InitFn } from './utils.js'; @@ -24,9 +24,9 @@ export const versionMismatch: InitFn = ( const paragraph = blocks.get(paragraphId) as Y.Map; paragraph.set('sys:version', (paragraph.get('sys:version') as number) + 1); - const update = DocCollection.Y.encodeStateAsUpdate(tempDoc.spaceDoc); + const update = Y.encodeStateAsUpdate(tempDoc.spaceDoc); - DocCollection.Y.applyUpdate(doc.spaceDoc, update); + Y.applyUpdate(doc.spaceDoc, update); doc.addBlock('affine:paragraph', {}, noteId); }); diff --git a/blocksuite/playground/apps/starter/utils/collection.ts b/blocksuite/playground/apps/starter/utils/collection.ts index 5d801622b4..e1dd74bc5c 100644 --- a/blocksuite/playground/apps/starter/utils/collection.ts +++ b/blocksuite/playground/apps/starter/utils/collection.ts @@ -16,6 +16,7 @@ import { IndexedDBBlobSource, MemoryBlobSource, } from '@blocksuite/sync'; +import * as Y from 'yjs'; import { MockServerBlobSource } from '../../_common/sync/blob/mock-server.js'; import type { InitFn } from '../data/utils.js'; @@ -92,7 +93,7 @@ export function createStarterDocCollection() { delete: (id: string) => collection.removeDoc(id), }, }); - window.Y = DocCollection.Y; + window.Y = Y; window.testUtils = new TestUtils(); return collection; diff --git a/blocksuite/presets/package.json b/blocksuite/presets/package.json index 99b87feb23..c557d0a9ab 100644 --- a/blocksuite/presets/package.json +++ b/blocksuite/presets/package.json @@ -25,6 +25,7 @@ "@preact/signals-core": "^1.8.0", "@toeverything/theme": "^1.1.3", "lit": "^3.2.0", + "yjs": "^13.6.21", "zod": "^3.23.8" }, "exports": { diff --git a/blocksuite/presets/src/__tests__/edgeless/group.spec.ts b/blocksuite/presets/src/__tests__/edgeless/group.spec.ts index e3e256e36e..72f8a57db4 100644 --- a/blocksuite/presets/src/__tests__/edgeless/group.spec.ts +++ b/blocksuite/presets/src/__tests__/edgeless/group.spec.ts @@ -6,8 +6,8 @@ import { NoteDisplayMode, } from '@blocksuite/blocks'; import { assertExists } from '@blocksuite/global/utils'; -import { DocCollection } from '@blocksuite/store'; import { beforeEach, describe, expect, test } from 'vitest'; +import * as Y from 'yjs'; import { wait } from '../utils/common.js'; import { addNote, getDocRootBlock } from '../utils/edgeless.js'; @@ -24,7 +24,7 @@ describe('group', () => { }); test('group with no children will be removed automatically', () => { - const map = new DocCollection.Y.Map(); + const map = new Y.Map(); const ids = Array.from({ length: 2 }) .map(() => { const id = service.crud.addElement('shape', { @@ -62,7 +62,7 @@ describe('group', () => { }); test('remove group should remove its children at the same time', () => { - const map = new DocCollection.Y.Map(); + const map = new Y.Map(); const doc = service.doc; const noteId = addNote(doc); const shapeId = service.crud.addElement('shape', { @@ -112,7 +112,7 @@ describe('group', () => { collapsedHeight: 100, }, }); - const children = new DocCollection.Y.Map(); + const children = new Y.Map(); children.set(shape1, true); children.set(shape2, true); @@ -187,7 +187,7 @@ describe('group', () => { }); test('empty group should have all zero xywh', () => { - const map = new DocCollection.Y.Map(); + const map = new Y.Map(); const groupId = service.crud.addElement('group', { children: map }); assertExists(groupId); const group = service.crud.getElementById(groupId) as GroupElementModel; @@ -201,7 +201,7 @@ describe('group', () => { test('descendant of group should not contain itself', () => { const groupIds = [1, 2, 3].map(_ => { return service.crud.addElement('group', { - children: new DocCollection.Y.Map(), + children: new Y.Map(), }) as string; }); const groups = groupIds.map( diff --git a/blocksuite/presets/src/__tests__/edgeless/layer.spec.ts b/blocksuite/presets/src/__tests__/edgeless/layer.spec.ts index c250fb4a77..13dbee64fb 100644 --- a/blocksuite/presets/src/__tests__/edgeless/layer.spec.ts +++ b/blocksuite/presets/src/__tests__/edgeless/layer.spec.ts @@ -5,8 +5,9 @@ import type { GroupElementModel, NoteBlockModel, } from '@blocksuite/blocks'; -import { type BlockModel, type Doc, DocCollection } from '@blocksuite/store'; +import { type BlockModel, type Doc } from '@blocksuite/store'; import { beforeEach, describe, expect, test } from 'vitest'; +import * as Y from 'yjs'; import { wait } from '../utils/common.js'; import { @@ -409,7 +410,7 @@ describe('group related functionality', () => { service: EdgelessRootBlockComponent['service'], childIds: string[] ) => { - const children = new DocCollection.Y.Map(); + const children = new Y.Map(); childIds.forEach(id => children.set(id, true)); return service.crud.addElement('group', { @@ -574,7 +575,7 @@ describe('compare function', () => { childIds: string[] // eslint-disable-next-line sonarjs/no-identical-functions ) => { - const children = new DocCollection.Y.Map(); + const children = new Y.Map(); childIds.forEach(id => children.set(id, true)); return service.crud.addElement('group', { diff --git a/blocksuite/presets/src/fragments/comment/comment-input.ts b/blocksuite/presets/src/fragments/comment/comment-input.ts index 65073ee81f..aa72746254 100644 --- a/blocksuite/presets/src/fragments/comment/comment-input.ts +++ b/blocksuite/presets/src/fragments/comment/comment-input.ts @@ -2,9 +2,9 @@ import type { TextSelection } from '@blocksuite/block-std'; import { ShadowlessElement } from '@blocksuite/block-std'; import type { RichText } from '@blocksuite/blocks'; import { WithDisposable } from '@blocksuite/global/utils'; -import { DocCollection } from '@blocksuite/store'; import { css, html, nothing } from 'lit'; import { property, query } from 'lit/decorators.js'; +import * as Y from 'yjs'; import type { Comment, CommentManager } from './comment-manager.js'; @@ -52,7 +52,7 @@ export class CommentInput extends WithDisposable(ShadowlessElement) { return; } - const yText = new DocCollection.Y.Text(); + const yText = new Y.Text(); yText.applyDelta(deltas); const comment = this.manager.addComment(textSelection, { author: 'Anonymous', @@ -82,7 +82,7 @@ export class CommentInput extends WithDisposable(ShadowlessElement) { const { quote } = parseResult; - const tmpYDoc = new DocCollection.Y.Doc(); + const tmpYDoc = new Y.Doc(); const tmpYText = tmpYDoc.getText('comment'); return html`
diff --git a/blocksuite/presets/src/fragments/comment/comment-manager.ts b/blocksuite/presets/src/fragments/comment/comment-manager.ts index 0a3e3aec29..3c53565d97 100644 --- a/blocksuite/presets/src/fragments/comment/comment-manager.ts +++ b/blocksuite/presets/src/fragments/comment/comment-manager.ts @@ -1,5 +1,5 @@ import type { EditorHost, TextSelection } from '@blocksuite/block-std'; -import { DocCollection, type Y } from '@blocksuite/store'; +import * as Y from 'yjs'; export interface CommentMeta { id: string; @@ -53,10 +53,7 @@ export class CommentManager { quote, ...payload, }; - this.commentsMap.set( - id, - new DocCollection.Y.Map(Object.entries(comment)) - ); + this.commentsMap.set(id, new Y.Map(Object.entries(comment))); return comment; } @@ -66,17 +63,15 @@ export class CommentManager { const start = comment.get('start') as Comment['start']; const end = comment.get('end') as Comment['end']; - const startIndex = - DocCollection.Y.createAbsolutePositionFromRelativePosition( - start.index, - this.host.doc.spaceDoc - ); + const startIndex = Y.createAbsolutePositionFromRelativePosition( + start.index, + this.host.doc.spaceDoc + ); const startBlock = this.host.view.getBlock(start.id); - const endIndex = - DocCollection.Y.createAbsolutePositionFromRelativePosition( - end.index, - this.host.doc.spaceDoc - ); + const endIndex = Y.createAbsolutePositionFromRelativePosition( + end.index, + this.host.doc.spaceDoc + ); const endBlock = this.host.view.getBlock(end.id); if (!startIndex || !startBlock || !endIndex || !endBlock) { @@ -122,11 +117,11 @@ export class CommentManager { const toBlockId = toBlock.model.id; if (!fromBlockText || !toBlockText) return null; - const startIndex = DocCollection.Y.createRelativePositionFromTypeIndex( + const startIndex = Y.createRelativePositionFromTypeIndex( fromBlockText.yText, from.index ); - const endIndex = DocCollection.Y.createRelativePositionFromTypeIndex( + const endIndex = Y.createRelativePositionFromTypeIndex( toBlockText.yText, to ? to.index + to.length : from.index + from.length ); diff --git a/blocksuite/presets/src/fragments/doc-title/doc-title.ts b/blocksuite/presets/src/fragments/doc-title/doc-title.ts index 88b9aa1f28..6864705f79 100644 --- a/blocksuite/presets/src/fragments/doc-title/doc-title.ts +++ b/blocksuite/presets/src/fragments/doc-title/doc-title.ts @@ -84,7 +84,7 @@ export class DocTitle extends WithDisposable(ShadowlessElement) { }; private readonly _updateTitleInMeta = () => { - this.doc.collection.setDocMeta(this.doc.id, { + this.doc.collection.meta.setDocMeta(this.doc.id, { title: this._rootModel.title.toString(), }); }; diff --git a/blocksuite/presets/src/fragments/frame-panel/card/frame-card-title.ts b/blocksuite/presets/src/fragments/frame-panel/card/frame-card-title.ts index bdf619fd64..3f01925c93 100644 --- a/blocksuite/presets/src/fragments/frame-panel/card/frame-card-title.ts +++ b/blocksuite/presets/src/fragments/frame-panel/card/frame-card-title.ts @@ -1,9 +1,9 @@ import { ShadowlessElement } from '@blocksuite/block-std'; import type { FrameBlockModel } from '@blocksuite/blocks'; import { DisposableGroup, WithDisposable } from '@blocksuite/global/utils'; -import type { Y } from '@blocksuite/store'; import { css, html, type PropertyValues } from 'lit'; import { property, query } from 'lit/decorators.js'; +import type * as Y from 'yjs'; import { FrameCardTitleEditor } from './frame-card-title-editor.js'; diff --git a/packages/frontend/core/src/blocksuite/presets/ai/actions/page-response.ts b/packages/frontend/core/src/blocksuite/presets/ai/actions/page-response.ts index 36bb750358..48b81f4dc7 100644 --- a/packages/frontend/core/src/blocksuite/presets/ai/actions/page-response.ts +++ b/packages/frontend/core/src/blocksuite/presets/ai/actions/page-response.ts @@ -16,7 +16,8 @@ import { uploadBlobForImage, } from '@blocksuite/affine/blocks'; import { Bound, getCommonBound } from '@blocksuite/affine/global/utils'; -import { type BlockProps, DocCollection, Text } from '@blocksuite/affine/store'; +import { type BlockProps, Text } from '@blocksuite/affine/store'; +import * as Y from 'yjs'; import { getAIPanelWidget } from '../utils/ai-widgets'; import type { AffineNode, AIContext } from '../utils/context'; @@ -262,7 +263,7 @@ function addSurfaceRefBlock(host: EditorHost, bound: Bound, place: Place) { const frame = host.doc.addBlock( 'affine:frame', { - title: new Text(new DocCollection.Y.Text('Frame')), + title: new Text(new Y.Text('Frame')), xywh: bound.serialize(), index: LayerManager.INITIAL_INDEX, }, diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor.tsx index 514fab8155..f1bee9bc21 100644 --- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor.tsx +++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor.tsx @@ -41,7 +41,7 @@ const BlockSuiteEditorImpl = ({ }: EditorProps) => { useEffect(() => { const disposable = page.slots.blockUpdated.once(() => { - page.collection.setDocMeta(page.id, { + page.collection.meta.setDocMeta(page.id, { updatedDate: Date.now(), }); }); diff --git a/packages/frontend/core/src/desktop/pages/workspace/index.tsx b/packages/frontend/core/src/desktop/pages/workspace/index.tsx index bfe0cf6311..36e084cba1 100644 --- a/packages/frontend/core/src/desktop/pages/workspace/index.tsx +++ b/packages/frontend/core/src/desktop/pages/workspace/index.tsx @@ -28,6 +28,7 @@ import { useParams, useSearchParams, } from 'react-router-dom'; +import * as _Y from 'yjs'; import { AffineErrorBoundary } from '../../../components/affine/affine-error-boundary'; import { WorkbenchRoot } from '../../../modules/workbench'; @@ -46,11 +47,15 @@ declare global { var exportWorkspaceSnapshot: (docs?: string[]) => Promise; // oxlint-disable-next-line no-var var importWorkspaceSnapshot: () => Promise; + // oxlint-disable-next-line no-var + var Y: typeof _Y; interface WindowEventMap { 'affine:workspace:change': CustomEvent<{ id: string }>; } } +globalThis.Y = _Y; + export const Component = (): ReactElement => { const { workspacesService, diff --git a/packages/frontend/core/src/modules/doc/stores/docs.ts b/packages/frontend/core/src/modules/doc/stores/docs.ts index 8e0cbe9690..af2cd720db 100644 --- a/packages/frontend/core/src/modules/doc/stores/docs.ts +++ b/packages/frontend/core/src/modules/doc/stores/docs.ts @@ -128,7 +128,7 @@ export class DocsStore extends Store { } setDocMeta(id: string, meta: Partial) { - this.workspaceService.workspace.docCollection.setDocMeta(id, meta); + this.workspaceService.workspace.docCollection.meta.setDocMeta(id, meta); } setDocPrimaryModeSetting(id: string, mode: DocMode) { diff --git a/packages/frontend/core/src/modules/favorite/services/old/adapter.ts b/packages/frontend/core/src/modules/favorite/services/old/adapter.ts index 3bcf5fcc63..e5d305901f 100644 --- a/packages/frontend/core/src/modules/favorite/services/old/adapter.ts +++ b/packages/frontend/core/src/modules/favorite/services/old/adapter.ts @@ -1,9 +1,10 @@ // the adapter is to bridge the workspace rootdoc & native js bindings import type { WorkspaceService } from '@affine/core/modules/workspace'; -import { createYProxy, type Y } from '@blocksuite/affine/store'; +import { createYProxy } from '@blocksuite/affine/store'; import { LiveData, Service } from '@toeverything/infra'; import { defaultsDeep } from 'lodash-es'; import { Observable } from 'rxjs'; +import type * as Y from 'yjs'; import type { FavoriteSupportTypeUnion } from '../../constant'; import type { FavoriteService } from '../favorite'; diff --git a/packages/frontend/core/src/modules/tag/stores/tag.ts b/packages/frontend/core/src/modules/tag/stores/tag.ts index 5f8e20a666..c122a9fcb6 100644 --- a/packages/frontend/core/src/modules/tag/stores/tag.ts +++ b/packages/frontend/core/src/modules/tag/stores/tag.ts @@ -86,7 +86,7 @@ export class TagStore extends Store { }; updatePageTags = (pageId: string, tags: string[]) => { - this.workspaceService.workspace.docCollection.setDocMeta(pageId, { + this.workspaceService.workspace.docCollection.meta.setDocMeta(pageId, { tags, }); }; diff --git a/tests/affine-cloud/e2e/page-history.spec.ts b/tests/affine-cloud/e2e/page-history.spec.ts index 3f811e3ff6..f5fdf769a2 100644 --- a/tests/affine-cloud/e2e/page-history.spec.ts +++ b/tests/affine-cloud/e2e/page-history.spec.ts @@ -58,7 +58,7 @@ test('newly created page shows empty history', async ({ page }) => { const pushCurrentPageUpdates = async (page: Page) => { const [workspaceId, guid, updates, state] = await page.evaluate(() => { // @ts-expect-error - const Y = window.currentWorkspace.docCollection.constructor.Y; + const Y = window.Y; // @ts-expect-error const spaceDoc = window.currentEditor.page.spaceDoc; // @ts-expect-error diff --git a/yarn.lock b/yarn.lock index bd2d39500a..e0c7958276 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3379,6 +3379,7 @@ __metadata: date-fns: "npm:^4.0.0" lit: "npm:^3.2.0" minimatch: "npm:^10.0.1" + yjs: "npm:^13.6.21" zod: "npm:^3.23.8" languageName: unknown linkType: soft @@ -3447,6 +3448,7 @@ __metadata: "@toeverything/theme": "npm:^1.1.3" lit: "npm:^3.2.0" minimatch: "npm:^10.0.1" + yjs: "npm:^13.6.21" zod: "npm:^3.23.8" languageName: unknown linkType: soft @@ -3633,6 +3635,7 @@ __metadata: lit: "npm:^3.2.0" lodash.chunk: "npm:^4.2.0" nanoid: "npm:^5.0.7" + yjs: "npm:^13.6.21" zod: "npm:^3.23.8" languageName: unknown linkType: soft @@ -3661,6 +3664,7 @@ __metadata: lit-html: "npm:^3.2.1" lodash.clonedeep: "npm:^4.5.0" shiki: "npm:^1.12.0" + yjs: "npm:^13.6.21" zod: "npm:^3.23.8" languageName: unknown linkType: soft @@ -3674,6 +3678,7 @@ __metadata: "@blocksuite/inline": "workspace:*" "@blocksuite/store": "workspace:*" fractional-indexing: "npm:^3.2.0" + yjs: "npm:^13.6.21" zod: "npm:^3.23.8" languageName: unknown linkType: soft @@ -3715,6 +3720,7 @@ __metadata: remark-parse: "npm:^11.0.0" remark-stringify: "npm:^11.0.0" unified: "npm:^11.0.5" + yjs: "npm:^13.6.21" zod: "npm:^3.23.8" languageName: unknown linkType: soft @@ -3819,6 +3825,7 @@ __metadata: rehype-parse: "npm:^9.0.0" unified: "npm:^11.0.5" w3c-keyname: "npm:^2.2.8" + yjs: "npm:^13.6.21" zod: "npm:^3.23.8" languageName: unknown linkType: soft @@ -3895,6 +3902,7 @@ __metadata: shiki: "npm:^1.14.1" simple-xml-to-json: "npm:^1.2.2" unified: "npm:^11.0.5" + yjs: "npm:^13.6.21" zod: "npm:^3.23.8" languageName: unknown linkType: soft @@ -3916,6 +3924,7 @@ __metadata: "@toeverything/theme": "npm:^1.1.3" date-fns: "npm:^4.0.0" lit: "npm:^3.2.0" + yjs: "npm:^13.6.21" zod: "npm:^3.23.8" languageName: unknown linkType: soft @@ -3956,9 +3965,6 @@ __metadata: lit: "npm:^3.2.0" yjs: "npm:^13.6.21" zod: "npm:^3.23.8" - peerDependencies: - lit: ^3.2.0 - yjs: "*" languageName: unknown linkType: soft @@ -4033,6 +4039,7 @@ __metadata: "@toeverything/theme": "npm:^1.1.3" lit: "npm:^3.2.0" vitest: "npm:^2.1.8" + yjs: "npm:^13.6.21" zod: "npm:^3.23.8" languageName: unknown linkType: soft @@ -4045,14 +4052,11 @@ __metadata: "@blocksuite/inline": "workspace:*" "@blocksuite/sync": "workspace:*" "@preact/signals-core": "npm:^1.8.0" - "@types/flexsearch": "npm:^0.7.6" "@types/lodash.clonedeep": "npm:^4.5.9" "@types/lodash.ismatch": "npm:^4.4.9" "@types/lodash.merge": "npm:^4.6.9" file-type: "npm:^19.5.0" - flexsearch: "npm:0.7.43" lib0: "npm:^0.2.97" - lit: "npm:^3.2.0" lodash.clonedeep: "npm:^4.5.0" lodash.ismatch: "npm:^4.4.0" lodash.merge: "npm:^4.6.2" @@ -4061,8 +4065,6 @@ __metadata: y-protocols: "npm:^1.0.6" yjs: "npm:^13.6.21" zod: "npm:^3.23.8" - peerDependencies: - yjs: "*" languageName: unknown linkType: soft @@ -14300,13 +14302,6 @@ __metadata: languageName: node linkType: hard -"@types/flexsearch@npm:^0.7.6": - version: 0.7.6 - resolution: "@types/flexsearch@npm:0.7.6" - checksum: 10/93aaed91f5847a0c85e19b339147067897c92385de842071c959bf3f1efb8c7095acce460385aa285c75c67022d78979b4cae6ecb754bdb74348bf4976160ae3 - languageName: node - linkType: hard - "@types/fs-extra@npm:9.0.13, @types/fs-extra@npm:^9.0.1, @types/fs-extra@npm:^9.0.11": version: 9.0.13 resolution: "@types/fs-extra@npm:9.0.13" @@ -21563,13 +21558,6 @@ __metadata: languageName: node linkType: hard -"flexsearch@npm:0.7.43": - version: 0.7.43 - resolution: "flexsearch@npm:0.7.43" - checksum: 10/79c0bceee435bd40fd0a0d8ba72f1bd07f622374a73bd3ceb874f7c7dd9a0fe9863b5c66a4037c2fa534e726f718d010ac99377d1924e347823b51ce641180e5 - languageName: node - linkType: hard - "flora-colossus@npm:^2.0.0": version: 2.0.0 resolution: "flora-colossus@npm:2.0.0"