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
feat(editor): add block meta for table block (#10915)
Saul-Mirone808c053c3cd9
diff --git a/blocksuite/affine/model/src/blocks/table/table-model.ts b/blocksuite/affine/model/src/blocks/table/table-model.tsindex 6d1d0c45c0..b044426443 100644--- a/blocksuite/affine/model/src/blocks/table/table-model.ts+++ b/blocksuite/affine/model/src/blocks/table/table-model.ts@@ -6,6 +6,8 @@ import {defineBlockSchema,} from '@blocksuite/store';+import type { BlockMeta } from '../../utils/types';+export type TableCell = {text: Text;};@@ -23,7 +25,7 @@ export interface TableColumn {width?: number;}-export interface TableBlockProps {+export interface TableBlockProps extends BlockMeta {rows: Record<string, TableRow>;columns: Record<string, TableColumn>;// key = `${rowId}:${columnId}`@@ -50,6 +52,10 @@ export const TableBlockSchema = defineBlockSchema({rows: {},columns: {},cells: {},+ 'meta:createdAt': undefined,+ 'meta:createdBy': undefined,+ 'meta:updatedAt': undefined,+ 'meta:updatedBy': undefined,}),metadata: {isFlatData: true,diff --git a/blocksuite/framework/store/src/reactive/flat-native-y/proxy.ts b/blocksuite/framework/store/src/reactive/flat-native-y/proxy.tsindex 43d0d9074f..addeb4383f 100644--- a/blocksuite/framework/store/src/reactive/flat-native-y/proxy.ts+++ b/blocksuite/framework/store/src/reactive/flat-native-y/proxy.ts@@ -61,6 +61,7 @@ function updateSignal(basePath,initialized,onDispose,+ shouldByPassYjs,} = options;const fullPath = basePath ? `${basePath}.${prop}` : prop;@@ -69,6 +70,7 @@ function updateSignal(root,firstKey,shouldByPassSignal,+ shouldByPassYjs,byPassSignalUpdate,onChange,basePath,diff --git a/blocksuite/framework/store/src/reactive/flat-native-y/signal-updater.ts b/blocksuite/framework/store/src/reactive/flat-native-y/signal-updater.tsindex 114ff8f47c..74deb2888c 100644--- a/blocksuite/framework/store/src/reactive/flat-native-y/signal-updater.ts+++ b/blocksuite/framework/store/src/reactive/flat-native-y/signal-updater.ts@@ -3,7 +3,12 @@ import type { CreateProxyOptions } from './types';type UpdateSignalOptions = Pick<CreateProxyOptions,- 'shouldByPassSignal' | 'root' | 'onChange' | 'byPassSignalUpdate' | 'basePath'+ | 'shouldByPassSignal'+ | 'root'+ | 'onChange'+ | 'byPassSignalUpdate'+ | 'basePath'+ | 'shouldByPassYjs'> & {firstKey: string;value: unknown;@@ -19,6 +24,7 @@ export function signalUpdater({basePath,value,handleNestedUpdate,+ shouldByPassYjs,}: UpdateSignalOptions): void {const isRoot = !basePath;if (shouldByPassSignal()) {@@ -44,6 +50,9 @@ export function signalUpdater({: prev;// @ts-expect-error allow magic propsroot[signalKey].value = next;- onChange?.(firstKey, true);+ // If the update is from yjs, it's already called from y-event-handler+ if (!shouldByPassYjs()) {+ onChange?.(firstKey, true);+ }});}