mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-11 05:58:56 +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:
@@ -12,7 +12,7 @@ export const changeNoteDisplayMode: Command<{
|
||||
const noteBlockModel = std.store.getBlock(noteId)?.model;
|
||||
if (!noteBlockModel || !matchModels(noteBlockModel, [NoteBlockModel])) return;
|
||||
|
||||
const currentMode = noteBlockModel.displayMode;
|
||||
const currentMode = noteBlockModel.props.displayMode;
|
||||
if (currentMode === mode) return;
|
||||
|
||||
if (stopCapture) std.store.captureSync();
|
||||
@@ -29,10 +29,10 @@ export const changeNoteDisplayMode: Command<{
|
||||
matchModels(child, [NoteBlockModel])
|
||||
);
|
||||
const firstEdgelessOnlyNote = notes.find(
|
||||
note => note.displayMode === NoteDisplayMode.EdgelessOnly
|
||||
note => note.props.displayMode === NoteDisplayMode.EdgelessOnly
|
||||
);
|
||||
const lastPageVisibleNote = notes.findLast(
|
||||
note => note.displayMode !== NoteDisplayMode.EdgelessOnly
|
||||
note => note.props.displayMode !== NoteDisplayMode.EdgelessOnly
|
||||
);
|
||||
|
||||
if (currentMode === NoteDisplayMode.EdgelessOnly) {
|
||||
|
||||
@@ -47,8 +47,8 @@ export const dedentBlock: Command<{
|
||||
|
||||
if (
|
||||
matchModels(model, [ParagraphBlockModel]) &&
|
||||
model.type.startsWith('h') &&
|
||||
model.collapsed
|
||||
model.props.type.startsWith('h') &&
|
||||
model.props.collapsed
|
||||
) {
|
||||
const collapsedSiblings = calculateCollapsedSiblings(model);
|
||||
store.moveBlocks([model, ...collapsedSiblings], grandParent, parent, false);
|
||||
|
||||
@@ -59,8 +59,8 @@ export const dedentBlocks: Command<{
|
||||
if (!model) return;
|
||||
if (
|
||||
matchModels(model, [ParagraphBlockModel]) &&
|
||||
model.type.startsWith('h') &&
|
||||
model.collapsed
|
||||
model.props.type.startsWith('h') &&
|
||||
model.props.collapsed
|
||||
) {
|
||||
const collapsedSiblings = calculateCollapsedSiblings(model);
|
||||
collapsedIds.push(...collapsedSiblings.map(sibling => sibling.id));
|
||||
|
||||
@@ -51,8 +51,8 @@ export const indentBlock: Command<{
|
||||
|
||||
if (
|
||||
matchModels(model, [ParagraphBlockModel]) &&
|
||||
model.type.startsWith('h') &&
|
||||
model.collapsed
|
||||
model.props.type.startsWith('h') &&
|
||||
model.props.collapsed
|
||||
) {
|
||||
const collapsedSiblings = calculateCollapsedSiblings(model);
|
||||
store.moveBlocks([model, ...collapsedSiblings], previousSibling);
|
||||
@@ -63,7 +63,7 @@ export const indentBlock: Command<{
|
||||
// update collapsed state of affine list
|
||||
if (
|
||||
matchModels(previousSibling, [ListBlockModel]) &&
|
||||
previousSibling.collapsed
|
||||
previousSibling.props.collapsed
|
||||
) {
|
||||
store.updateBlock(previousSibling, {
|
||||
collapsed: false,
|
||||
|
||||
@@ -60,8 +60,8 @@ export const indentBlocks: Command<{
|
||||
if (!model) return;
|
||||
if (
|
||||
matchModels(model, [ParagraphBlockModel]) &&
|
||||
model.type.startsWith('h') &&
|
||||
model.collapsed
|
||||
model.props.type.startsWith('h') &&
|
||||
model.props.collapsed
|
||||
) {
|
||||
const collapsedSiblings = calculateCollapsedSiblings(model);
|
||||
collapsedIds.push(...collapsedSiblings.map(sibling => sibling.id));
|
||||
@@ -85,7 +85,7 @@ export const indentBlocks: Command<{
|
||||
if (
|
||||
nearestHeading &&
|
||||
matchModels(nearestHeading, [ParagraphBlockModel]) &&
|
||||
nearestHeading.collapsed
|
||||
nearestHeading.props.collapsed
|
||||
) {
|
||||
store.updateBlock(nearestHeading, { collapsed: false });
|
||||
}
|
||||
@@ -106,7 +106,7 @@ export const indentBlocks: Command<{
|
||||
if (
|
||||
nearestHeading &&
|
||||
matchModels(nearestHeading, [ParagraphBlockModel]) &&
|
||||
nearestHeading.collapsed
|
||||
nearestHeading.props.collapsed
|
||||
) {
|
||||
store.updateBlock(nearestHeading, { collapsed: false });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user