mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-18 14:56:59 +08:00
feat(editor): type safe draft model and transformer (#10486)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 }) => {
|
||||
|
||||
Reference in New Issue
Block a user