mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00: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:
@@ -16,10 +16,10 @@ export function calculateCollapsedSiblings(
|
||||
if (
|
||||
i > index &&
|
||||
matchModels(child, [ParagraphBlockModel]) &&
|
||||
child.type.startsWith('h')
|
||||
child.props.type.startsWith('h')
|
||||
) {
|
||||
const modelLevel = parseInt(model.type.slice(1));
|
||||
const childLevel = parseInt(child.type.slice(1));
|
||||
const modelLevel = parseInt(model.props.type.slice(1));
|
||||
const childLevel = parseInt(child.props.type.slice(1));
|
||||
return childLevel <= modelLevel;
|
||||
}
|
||||
return false;
|
||||
@@ -47,7 +47,7 @@ export function getNearestHeadingBefore(
|
||||
const sibling = parent.children[i];
|
||||
if (
|
||||
matchModels(sibling, [ParagraphBlockModel]) &&
|
||||
sibling.type.startsWith('h')
|
||||
sibling.props.type.startsWith('h')
|
||||
) {
|
||||
return sibling;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ export function getLastNoteBlock(doc: Store) {
|
||||
const child = children[i];
|
||||
if (
|
||||
matchModels(child, [NoteBlockModel]) &&
|
||||
child.displayMode !== NoteDisplayMode.EdgelessOnly
|
||||
child.props.displayMode !== NoteDisplayMode.EdgelessOnly
|
||||
) {
|
||||
note = child as NoteBlockModel;
|
||||
break;
|
||||
@@ -65,7 +65,7 @@ export function getFirstNoteBlock(doc: Store) {
|
||||
for (const child of children) {
|
||||
if (
|
||||
matchModels(child, [NoteBlockModel]) &&
|
||||
child.displayMode !== NoteDisplayMode.EdgelessOnly
|
||||
child.props.displayMode !== NoteDisplayMode.EdgelessOnly
|
||||
) {
|
||||
note = child as NoteBlockModel;
|
||||
break;
|
||||
|
||||
@@ -23,7 +23,7 @@ export function getNextContinuousNumberedLists(
|
||||
const firstNotNumberedListIndex = parent.children.findIndex(
|
||||
(model, i) =>
|
||||
i > modelIndex &&
|
||||
(!matchModels(model, [ListBlockModel]) || model.type !== 'numbered')
|
||||
(!matchModels(model, [ListBlockModel]) || model.props.type !== 'numbered')
|
||||
);
|
||||
const newContinuousLists = parent.children.slice(
|
||||
modelIndex + 1,
|
||||
@@ -31,7 +31,8 @@ export function getNextContinuousNumberedLists(
|
||||
);
|
||||
if (
|
||||
!newContinuousLists.every(
|
||||
model => matchModels(model, [ListBlockModel]) && model.type === 'numbered'
|
||||
model =>
|
||||
matchModels(model, [ListBlockModel]) && model.props.type === 'numbered'
|
||||
)
|
||||
)
|
||||
return [];
|
||||
@@ -56,11 +57,11 @@ export function toNumberedList(
|
||||
if (
|
||||
prevSibling &&
|
||||
matchModels(prevSibling, [ListBlockModel]) &&
|
||||
prevSibling.type === 'numbered'
|
||||
prevSibling.props.type === 'numbered'
|
||||
) {
|
||||
doc.transact(() => {
|
||||
if (!prevSibling.order) prevSibling.order = 1;
|
||||
realOrder = prevSibling.order + 1;
|
||||
if (!prevSibling.props.order) prevSibling.props.order = 1;
|
||||
realOrder = prevSibling.props.order + 1;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -93,7 +94,7 @@ export function toNumberedList(
|
||||
let base = realOrder + 1;
|
||||
nextContinuousNumberedLists.forEach(list => {
|
||||
doc.transact(() => {
|
||||
list.order = base;
|
||||
list.props.order = base;
|
||||
});
|
||||
base += 1;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user