refactor(editor): remove database-service (#9769)

close: BS-2426
This commit is contained in:
zzj3720
2025-01-18 05:36:15 +00:00
parent ad814a0f4f
commit 95c0f59d96
30 changed files with 448 additions and 427 deletions

View File

@@ -77,7 +77,7 @@ export function deleteColumn(
model: DatabaseBlockModel,
columnId: Column['id']
) {
const index = findPropertyIndex(model, columnId);
const index = model.columns.findIndex(v => v.id === columnId);
if (index < 0) return;
model.doc.transact(() => {
@@ -116,10 +116,6 @@ export function duplicateView(model: DatabaseBlockModel, id: string): string {
return newId;
}
export function findPropertyIndex(model: DatabaseBlockModel, id: Column['id']) {
return model.columns.findIndex(v => v.id === id);
}
export function getCell(
model: DatabaseBlockModel,
rowId: BlockModel['id'],
@@ -228,7 +224,8 @@ export function updateCells(
export function updateProperty(
model: DatabaseBlockModel,
id: string,
updater: ColumnUpdater
updater: ColumnUpdater,
defaultValue?: Record<string, unknown>
) {
const index = model.columns.findIndex(v => v.id === id);
if (index == null) {
@@ -240,7 +237,7 @@ export function updateProperty(
return;
}
const result = updater(column);
model.columns[index] = { ...column, ...result };
model.columns[index] = { ...defaultValue, ...column, ...result };
});
return id;
}