fix(editor): database block create new row when group by rich-text (#10564)

This commit is contained in:
zzj3720
2025-03-03 05:58:07 +00:00
parent 18bdf830b4
commit 3711e13e0e
4 changed files with 16 additions and 16 deletions

View File

@@ -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(), {

View File

@@ -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);

View File

@@ -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>;
};

View File

@@ -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),