mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-24 09:52:49 +08:00
fix(editor): database block create new row when group by rich-text (#10564)
This commit is contained in:
@@ -134,7 +134,7 @@ export const groupByMatchers = [
|
||||
},
|
||||
];
|
||||
},
|
||||
addToGroup: value => (typeof value === 'number' ? value * 10 : undefined),
|
||||
addToGroup: value => (typeof value === 'number' ? value * 10 : null),
|
||||
view: createUniComponentFromWebComponent(NumberGroupView),
|
||||
}),
|
||||
groupByMatcherCreator.createMatcher(t.boolean.instance(), {
|
||||
|
||||
@@ -168,11 +168,11 @@ export class GroupTrait {
|
||||
return;
|
||||
}
|
||||
const addTo = this.config$.value?.addToGroup ?? (value => value);
|
||||
const newValue = addTo(
|
||||
groupMap[key]?.value,
|
||||
this.view.cellJsonValueGet(rowId, propertyId)
|
||||
);
|
||||
this.view.cellValueSet(rowId, propertyId, newValue);
|
||||
const v = groupMap[key]?.value;
|
||||
if (v != null) {
|
||||
const newValue = addTo(v, this.view.cellJsonValueGet(rowId, propertyId));
|
||||
this.view.cellJsonValueSet(rowId, propertyId, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
changeCardSort(groupKey: string, cardIds: string[]) {
|
||||
@@ -233,9 +233,9 @@ export class GroupTrait {
|
||||
if (!propertyId) {
|
||||
return;
|
||||
}
|
||||
const remove = this.config$.value?.removeFromGroup ?? (() => undefined);
|
||||
const remove = this.config$.value?.removeFromGroup ?? (() => null);
|
||||
const group = fromGroupKey != null ? groupMap[fromGroupKey] : undefined;
|
||||
let newValue: unknown = undefined;
|
||||
let newValue: DVJSON = null;
|
||||
if (group) {
|
||||
newValue = remove(
|
||||
group.value,
|
||||
@@ -243,8 +243,8 @@ export class GroupTrait {
|
||||
);
|
||||
}
|
||||
const addTo = this.config$.value?.addToGroup ?? (value => value);
|
||||
newValue = addTo(groupMap[toGroupKey]?.value, newValue);
|
||||
this.view.cellValueSet(rowId, propertyId, newValue);
|
||||
newValue = addTo(groupMap[toGroupKey]?.value ?? null, newValue);
|
||||
this.view.cellJsonValueSet(rowId, propertyId, newValue);
|
||||
}
|
||||
const rows = groupMap[toGroupKey]?.rows.filter(id => id !== rowId) ?? [];
|
||||
const index = insertPositionToIndex(position, rows, id => id);
|
||||
@@ -278,7 +278,7 @@ export class GroupTrait {
|
||||
}
|
||||
const remove = this.config$.value?.removeFromGroup ?? (() => undefined);
|
||||
const newValue = remove(
|
||||
groupMap[key]?.value,
|
||||
groupMap[key]?.value ?? null,
|
||||
this.view.cellJsonValueGet(rowId, propertyId)
|
||||
);
|
||||
this.view.cellValueSet(rowId, propertyId, newValue);
|
||||
|
||||
@@ -27,7 +27,7 @@ export type GroupByConfig = {
|
||||
key: string;
|
||||
value: DVJSON;
|
||||
}[];
|
||||
addToGroup?: (value: unknown, oldValue: unknown) => unknown;
|
||||
removeFromGroup?: (value: unknown, oldValue: unknown) => unknown;
|
||||
addToGroup?: (value: DVJSON, oldValue: DVJSON) => DVJSON;
|
||||
removeFromGroup?: (value: DVJSON, oldValue: DVJSON) => DVJSON;
|
||||
view: UniComponent<GroupRenderProps>;
|
||||
};
|
||||
|
||||
@@ -50,7 +50,7 @@ export interface SingleView {
|
||||
|
||||
cellValueSet(rowId: string, propertyId: string, value: unknown): void;
|
||||
|
||||
cellJsonValueGet(rowId: string, propertyId: string): unknown;
|
||||
cellJsonValueGet(rowId: string, propertyId: string): DVJSON;
|
||||
|
||||
cellJsonValueSet(rowId: string, propertyId: string, value: DVJSON): void;
|
||||
|
||||
@@ -264,10 +264,10 @@ export abstract class SingleViewBase<
|
||||
return new CellBase(this, propertyId, rowId);
|
||||
}
|
||||
|
||||
cellJsonValueGet(rowId: string, propertyId: string): unknown {
|
||||
cellJsonValueGet(rowId: string, propertyId: string): DVJSON {
|
||||
const type = this.propertyTypeGet(propertyId);
|
||||
if (!type) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
return this.dataSource.propertyMetaGet(type).config.cellToJson({
|
||||
value: this.dataSource.cellValueGet(rowId, propertyId),
|
||||
|
||||
Reference in New Issue
Block a user