refactor(editor): reduce dependency to doc collection (#9492)

This commit is contained in:
Saul-Mirone
2025-01-03 01:59:25 +00:00
parent eb15b3cb39
commit 8b6c81f76d
70 changed files with 185 additions and 210 deletions
@@ -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,
-3
View File
@@ -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'
? globalThis
@@ -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
*/