There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(editor): database block create new row when group by rich-text (#10564)
zzj37203711e13e0e4b
diff --git a/blocksuite/affine/data-view/src/core/group-by/define.ts b/blocksuite/affine/data-view/src/core/group-by/define.tsindex d2f23edc0b..60a8d01383 100644--- a/blocksuite/affine/data-view/src/core/group-by/define.ts+++ b/blocksuite/affine/data-view/src/core/group-by/define.ts@@ -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(), {diff --git a/blocksuite/affine/data-view/src/core/group-by/trait.ts b/blocksuite/affine/data-view/src/core/group-by/trait.tsindex 5547541f27..f758d9dc23 100644--- a/blocksuite/affine/data-view/src/core/group-by/trait.ts+++ b/blocksuite/affine/data-view/src/core/group-by/trait.ts@@ -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);diff --git a/blocksuite/affine/data-view/src/core/group-by/types.ts b/blocksuite/affine/data-view/src/core/group-by/types.tsindex 032b8a601a..bb2a80c4c5 100644--- a/blocksuite/affine/data-view/src/core/group-by/types.ts+++ b/blocksuite/affine/data-view/src/core/group-by/types.ts@@ -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>;};diff --git a/blocksuite/affine/data-view/src/core/view-manager/single-view.ts b/blocksuite/affine/data-view/src/core/view-manager/single-view.tsindex 56b39681dc..37f88d10d5 100644--- a/blocksuite/affine/data-view/src/core/view-manager/single-view.ts+++ b/blocksuite/affine/data-view/src/core/view-manager/single-view.ts@@ -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),