Problem: EditorStore manages CRDT data, schema lookup, transactions, rich-text editors, selection, and update subscriptions.
Improve: split responsibilities.
class DocumentRepository {
getNode(key: Key): FlatNode
saveNode(node: FlatNode): void
}
class TransactionManager {
update(fn: (tx: Transaction) => void): void
}
class RichTextManager {
getEditor(key: Key, schema: RichTextSchema): Editor
destroyEditor(key: Key): void
}
class SelectionStore {
getSelection(): EditorSelection | null
setSelection(selection: EditorSelection | null): void
}
class EditorRuntime {
constructor(
readonly document: DocumentRepository,
readonly transactions: TransactionManager,
readonly richText: RichTextManager,
readonly selection: SelectionStore,
) {}
}
This improves testing and makes each layer simpler.
Problem:
EditorStoremanages CRDT data, schema lookup, transactions, rich-text editors, selection, and update subscriptions.Improve: split responsibilities.
This improves testing and makes each layer simpler.