mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 01:09:54 +08:00
feat(editor): unify block props api (#10888)
Closes: [BS-2707](https://linear.app/affine-design/issue/BS-2707/统一使用props获取和更新block-prop)
This commit is contained in:
@@ -27,7 +27,7 @@ export const newIdCrossDoc =
|
||||
payload.type === 'block' &&
|
||||
matchModels(payload.model, [DatabaseBlockModel])
|
||||
) {
|
||||
const originalCells = payload.model.cells;
|
||||
const originalCells = payload.model.props.cells;
|
||||
const newCells = {
|
||||
...originalCells,
|
||||
};
|
||||
@@ -38,7 +38,7 @@ export const newIdCrossDoc =
|
||||
}
|
||||
});
|
||||
|
||||
payload.model.cells$.value = newCells;
|
||||
payload.model.props.cells$.value = newCells;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -10,7 +10,10 @@ export const reorderList =
|
||||
slots.afterImport.subscribe(payload => {
|
||||
if (payload.type === 'block') {
|
||||
const model = payload.model;
|
||||
if (matchModels(model, [ListBlockModel]) && model.type === 'numbered') {
|
||||
if (
|
||||
matchModels(model, [ListBlockModel]) &&
|
||||
model.props.type === 'numbered'
|
||||
) {
|
||||
const next = std.store.getNext(model);
|
||||
correctNumberedListsOrderToPrev(std.store, model);
|
||||
if (next) {
|
||||
|
||||
@@ -59,8 +59,8 @@ export const getDragHandleContainerHeight = (model: BlockModel) => {
|
||||
const flavour = model.flavour;
|
||||
const index = flavour.indexOf(':');
|
||||
let key = flavour.slice(index + 1);
|
||||
if (key === 'paragraph' && (model as ParagraphBlockModel).type) {
|
||||
key = (model as ParagraphBlockModel).type;
|
||||
if (key === 'paragraph' && (model as ParagraphBlockModel).props.type) {
|
||||
key = (model as ParagraphBlockModel).props.type;
|
||||
}
|
||||
|
||||
const height = heightMap[key] ?? DRAG_HANDLE_CONTAINER_HEIGHT;
|
||||
@@ -253,7 +253,7 @@ export function getDragHandleLeftPadding(blocks: BlockComponent[]) {
|
||||
(matchModels(block.model, [ListBlockModel]) &&
|
||||
block.model.children.length > 0) ||
|
||||
(block instanceof ParagraphBlockComponent &&
|
||||
block.model.type.startsWith('h') &&
|
||||
block.model.props.type.startsWith('h') &&
|
||||
block.collapsedSiblings.length > 0)
|
||||
);
|
||||
const offsetLeft = hasToggleList
|
||||
|
||||
@@ -454,8 +454,8 @@ export class DragEventWatcher {
|
||||
// if block is toggled heading, should select all siblings
|
||||
if (
|
||||
block instanceof ParagraphBlockComponent &&
|
||||
block.model.type.startsWith('h') &&
|
||||
block.model.collapsed
|
||||
block.model.props.type.startsWith('h') &&
|
||||
block.model.props.collapsed
|
||||
) {
|
||||
const collapsedSiblings = block.collapsedSiblings.flatMap(
|
||||
sibling => this.widget.host.view.getBlock(sibling.id) ?? []
|
||||
|
||||
@@ -258,7 +258,7 @@ export class PointerEventWatcher {
|
||||
this.widget.noteScale.value =
|
||||
this.widget.mode === 'page'
|
||||
? 1
|
||||
: (closestNoteBlock?.model.edgeless.scale ?? 1);
|
||||
: (closestNoteBlock?.model.props.edgeless.scale ?? 1);
|
||||
|
||||
if (
|
||||
closestNoteBlock &&
|
||||
|
||||
Reference in New Issue
Block a user