There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
refactor(editor): reduce dependency to doc collection (#9492)
Saul-Mirone8b6c81f76d37
diff --git a/blocksuite/affine/block-database/package.json b/blocksuite/affine/block-database/package.jsonindex 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.tsindex 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.childrendiff --git a/blocksuite/affine/block-embed/package.json b/blocksuite/affine/block-embed/package.jsonindex 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.tsindex 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<EmbedLinke}const index = parent.children.indexOf(this.model);- const yText = new DocCollection.Y.Text();+ const yText = new Y.Text();yText.insert(0, REFERENCE_NODE);yText.format(0, REFERENCE_NODE.length, {reference: {diff --git a/blocksuite/affine/block-embed/src/embed-synced-doc-block/embed-synced-doc-block.ts b/blocksuite/affine/block-embed/src/embed-synced-doc-block/embed-synced-doc-block.tsindex b13a0d3599..a54d25c817 100644--- a/blocksuite/affine/block-embed/src/embed-synced-doc-block/embed-synced-doc-block.ts+++ b/blocksuite/affine/block-embed/src/embed-synced-doc-block/embed-synced-doc-block.ts@@ -27,7 +27,6 @@ import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';import { assertExists, Bound, getCommonBound } from '@blocksuite/global/utils';import {BlockViewType,- DocCollection,type GetDocOptions,type Query,} from '@blocksuite/store';@@ -38,6 +37,7 @@ import { choose } from 'lit/directives/choose.js';import { classMap } from 'lit/directives/class-map.js';import { guard } from 'lit/directives/guard.js';import { type StyleInfo, styleMap } from 'lit/directives/style-map.js';+import * as Y from 'yjs';import { EmbedBlockComponent } from '../common/embed-block-element.js';import { isEmptyDoc } from '../common/render-linked-doc.js';@@ -272,7 +272,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynceassertExists(parent);const index = parent.children.indexOf(this.model);- const yText = new DocCollection.Y.Text();+ const yText = new Y.Text();yText.insert(0, REFERENCE_NODE);yText.format(0, REFERENCE_NODE.length, {reference: {diff --git a/blocksuite/affine/block-surface/package.json b/blocksuite/affine/block-surface/package.jsonindex cbdf09130e..01a729cac5 100644--- a/blocksuite/affine/block-surface/package.json+++ b/blocksuite/affine/block-surface/package.json@@ -27,6 +27,7 @@"lit": "^3.2.0","lodash.chunk": "^4.2.0","nanoid": "^5.0.7",+ "yjs": "^13.6.21","zod": "^3.23.8"},"devDependencies": {diff --git a/blocksuite/affine/block-surface/src/renderer/elements/text/utils.ts b/blocksuite/affine/block-surface/src/renderer/elements/text/utils.tsindex 475fea8d6c..623cc59236 100644--- a/blocksuite/affine/block-surface/src/renderer/elements/text/utils.ts+++ b/blocksuite/affine/block-surface/src/renderer/elements/text/utils.ts@@ -10,7 +10,7 @@ import {rotatePoints,} from '@blocksuite/global/utils';import { deltaInsertsToChunks } from '@blocksuite/inline';-import type { Y } from '@blocksuite/store';+import type * as Y from 'yjs';import {getFontFacesByFontFamily,diff --git a/blocksuite/affine/block-surface/src/surface-model.ts b/blocksuite/affine/block-surface/src/surface-model.tsindex 5869991324..cae84c6ca8 100644--- a/blocksuite/affine/block-surface/src/surface-model.ts+++ b/blocksuite/affine/block-surface/src/surface-model.ts@@ -2,7 +2,8 @@ import type { ConnectorElementModel } from '@blocksuite/affine-model';import type { SurfaceBlockProps } from '@blocksuite/block-std/gfx';import { SurfaceBlockModel as BaseSurfaceModel } from '@blocksuite/block-std/gfx';import { DisposableGroup } from '@blocksuite/global/utils';-import { defineBlockSchema, DocCollection } from '@blocksuite/store';+import { defineBlockSchema } from '@blocksuite/store';+import * as Y from 'yjs';import { elementsCtorMap } from './element-model/index.js';import { SurfaceBlockTransformer } from './surface-transformer.js';@@ -12,7 +13,7 @@ import { groupRelationWatcher } from './watchers/group.js';export const SurfaceBlockSchema = defineBlockSchema({flavour: 'affine:surface',props: (internalPrimitives): SurfaceBlockProps => ({- 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.tsindex 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<SurfaceBlockPrprivate _fromJSON(value: unknown): unknown {if (value instanceof Object) {if (Reflect.has(value, SURFACE_TEXT_UNIQ_IDENTIFIER)) {- const yText = new DocCollection.Y.Text();+ const yText = new Y.Text();yText.applyDelta(Reflect.get(value, 'delta'));return yText;} else if (Reflect.has(value, SURFACE_YMAP_UNIQ_IDENTIFIER)) {- const yMap = new DocCollection.Y.Map();+ const yMap = new Y.Map();const json = Reflect.get(value, 'json') as Record<string, unknown>;Object.entries(json).forEach(([key, value]) => {yMap.set(key, value);@@ -40,12 +40,12 @@ export class SurfaceBlockTransformer extends BaseBlockTransformer<SurfaceBlockPr}private _toJSON(value: unknown): unknown {- if (value instanceof DocCollection.Y.Text) {+ if (value instanceof Y.Text) {return {[SURFACE_TEXT_UNIQ_IDENTIFIER]: true,delta: value.toDelta(),};- } else if (value instanceof DocCollection.Y.Map) {+ } else if (value instanceof Y.Map) {return {[SURFACE_YMAP_UNIQ_IDENTIFIER]: true,json: value.toJSON(),@@ -55,7 +55,7 @@ export class SurfaceBlockTransformer extends BaseBlockTransformer<SurfaceBlockPr}elementFromJSON(element: Record<string, unknown>) {- 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<SurfaceBlockPrstring,unknown>;- const yMap = new DocCollection.Y.Map<Y.Map<unknown>>();+ const yMap = new Y.Map<Y.Map<unknown>>();Object.entries(elementsJSON).forEach(([key, value]) => {const element = this.elementFromJSON(value as Record<string, unknown>);diff --git a/blocksuite/affine/block-surface/src/utils/mindmap/utils.ts b/blocksuite/affine/block-surface/src/utils/mindmap/utils.tsindex 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.jsonindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.jsonindex 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.tsindex 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.jsonindex 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.tsindex 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<RootBlockProps> {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.tsindex 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<ConnectorEle}static override propsToY(props: ConnectorElementProps) {- 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/group/group.ts b/blocksuite/affine/model/src/elements/group/group.tsindex d43c1d03ff..ca866e499c 100644--- a/blocksuite/affine/model/src/elements/group/group.ts+++ b/blocksuite/affine/model/src/elements/group/group.ts@@ -12,8 +12,7 @@ import {} from '@blocksuite/block-std/gfx';import type { IVec, PointLocation } from '@blocksuite/global/utils';import { Bound, keys, linePolygonIntersects } from '@blocksuite/global/utils';-import type { Y } from '@blocksuite/store';-import { DocCollection } from '@blocksuite/store';+import * as Y from 'yjs';type GroupElementProps = BaseElementProps & {children: Y.Map<boolean>;@@ -37,12 +36,12 @@ export class GroupElementModel extends GfxGroupLikeElementModel<GroupElementProp}static override propsToY(props: Record<string, unknown>) {- 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<boolean>;+ if (props.children && !(props.children instanceof Y.Map)) {+ const children = new Y.Map() as Y.Map<boolean>;keys(props.children).forEach(key => {children.set(key as string, true);@@ -112,13 +111,13 @@ export class GroupElementModel extends GfxGroupLikeElementModel<GroupElementProp})@field()- accessor children: Y.Map<boolean> = new DocCollection.Y.Map<boolean>();+ accessor children: Y.Map<boolean> = new Y.Map<boolean>();@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.tsindex 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<MindmapElementif (props.children &&!isNodeType(props.children as Record<string, unknown>) &&- !(props.children instanceof DocCollection.Y.Map)+ !(props.children instanceof Y.Map)) {- const children: Y.Map<NodeDetail> = new DocCollection.Y.Map();+ const children: Y.Map<NodeDetail> = new Y.Map();keys(props.children).forEach(key => {const detail = pick<Record<string, unknown>, keyof NodeDetail>(@@ -284,9 +284,7 @@ export class MindmapElementModel extends GfxGroupLikeElementModel<MindmapElementthrow new Error(`Parent node ${parent} not found`);}- props['text'] = new DocCollection.Y.Text(- (props['text'] as string) ?? 'New node'- );+ props['text'] = new Y.Text((props['text'] as string) ?? 'New node');const type = (props.type as string) ?? 'shape';let id: string;@@ -919,12 +917,12 @@ export class MindmapElementModel extends GfxGroupLikeElementModel<MindmapElement}@convert((initialValue, instance) => {- if (!(initialValue instanceof DocCollection.Y.Map)) {+ if (!(initialValue instanceof Y.Map)) {nodeSchema.parse(initialValue);assertType<NodeType>(initialValue);- const map: Y.Map<NodeDetail> = new DocCollection.Y.Map();+ const map: Y.Map<NodeDetail> = new Y.Map();const surface = instance.surface;const doc = surface.doc;const recursive = (@@ -967,7 +965,7 @@ export class MindmapElementModel extends GfxGroupLikeElementModel<MindmapElement// since this model package is imported by playwright@observe(observeChildren)@field()- accessor children: Y.Map<NodeDetail> = new DocCollection.Y.Map();+ accessor children: Y.Map<NodeDetail> = 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.tsindex 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<ShapeProps> {}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.tsindex 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<TextElementProps>}static override propsToY(props: Record<string, unknown>) {- 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<TextElementProps>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.jsonindex 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.tsindex 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.tsindex 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.tsindex 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.jsonindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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 loadingdiff --git a/blocksuite/blocks/src/root-block/edgeless/utils/text.ts b/blocksuite/blocks/src/root-block/edgeless/utils/text.tsindex 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.tsindex 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.jsonindex 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.tsindex 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.tsindex 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.tsindex 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<SurfaceBlockProps> {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.jsonindex 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.jsonindex 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.tsindex 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.tsindex 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/// <reference path="../shim.d.ts" />-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'? globalThisdiff --git a/blocksuite/framework/store/src/store/collection.ts b/blocksuite/framework/store/src/store/collection.tsindex 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<DocMeta>- ) {- 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.tsindex 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.tsindex 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<typeof BlockSchema>[];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.tsindex 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.tsindex 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<unknown>;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.tsindex 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.jsonindex 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.tsindex 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<boolean>();+ const map = new Y.Map<boolean>();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<boolean>();+ const map = new Y.Map<boolean>();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<boolean>();+ const children = new Y.Map<boolean>();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<boolean>();+ const map = new Y.Map<boolean>();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<boolean>(),+ children: new Y.Map<boolean>(),}) 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.tsindex 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<boolean>();+ const children = new Y.Map<boolean>();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<boolean>();+ const children = new Y.Map<boolean>();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.tsindex 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`<div class="comment-input-container">diff --git a/blocksuite/presets/src/fragments/comment/comment-manager.ts b/blocksuite/presets/src/fragments/comment/comment-manager.tsindex 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<unknown>(Object.entries(comment))- );+ this.commentsMap.set(id, new Y.Map<unknown>(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.tsindex 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.tsindex 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.tsindex 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.tsxindex 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.tsxindex 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<void>;// oxlint-disable-next-line no-varvar importWorkspaceSnapshot: () => Promise<void>;+ // 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.tsindex 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<DocMeta>) {- 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.tsindex 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 bindingsimport 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.tsindex 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.tsindex 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-errorconst spaceDoc = window.currentEditor.page.spaceDoc;// @ts-expect-errordiff --git a/yarn.lock b/yarn.lockindex 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: unknownlinkType: 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: unknownlinkType: 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: unknownlinkType: 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: unknownlinkType: 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: unknownlinkType: 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: unknownlinkType: 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: unknownlinkType: 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: unknownlinkType: 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: unknownlinkType: 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: unknownlinkType: 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: unknownlinkType: 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: unknownlinkType: soft@@ -14300,13 +14302,6 @@ __metadata:languageName: nodelinkType: 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.13resolution: "@types/fs-extra@npm:9.0.13"@@ -21563,13 +21558,6 @@ __metadata:languageName: nodelinkType: 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.0resolution: "flora-colossus@npm:2.0.0"