feat(editor): type safe draft model and transformer (#10486)

This commit is contained in:
Saul-Mirone
2025-02-27 09:19:49 +00:00
parent 272d41e32d
commit 4c736bc190
15 changed files with 125 additions and 48 deletions

View File

@@ -24,7 +24,7 @@ import type {
Store,
TransformerMiddleware,
} from '@blocksuite/affine/store';
import { Transformer } from '@blocksuite/affine/store';
import { toDraftModel, Transformer } from '@blocksuite/affine/store';
const updateSnapshotText = (
point: TextRangePoint,
@@ -51,10 +51,10 @@ function processSnapshot(
const modelId = model.id;
if (text.from.blockId === modelId) {
updateSnapshotText(text.from, snapshot, model);
updateSnapshotText(text.from, snapshot, toDraftModel(model));
}
if (text.to && text.to.blockId === modelId) {
updateSnapshotText(text.to, snapshot, model);
updateSnapshotText(text.to, snapshot, toDraftModel(model));
}
// If the snapshot has children, handle them recursively

View File

@@ -147,7 +147,7 @@ function generateMarkdownPreviewBuilder(
keys: Array.from(yblock.keys())
.filter(key => key.startsWith('prop:'))
.map(key => key.substring(5)),
};
} as DraftModel;
}
const titleMiddleware: TransformerMiddleware = ({ adapterConfigs }) => {