mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-19 19:11:35 +08:00
1858947e0c
Flat block data.
A new block type to flatten the block data
```typescript
// For developers
type Model = {
blocks: Record<string, {
flavour: string;
cells: Record<string, {
rowId: string;
colId: string;
text: Text;
}>;
cols: Record<string, {
align: string;
}>
rows: Record<string, {
backgroundColor: string;
}>
}>
}
// How it's saved in yjs
const yData = {
blocks: {
'blockId1': {
flavour: 'affine:table',
'prop:rows:row1:backgroundColor': 'white',
'prop:cols:col1:align': 'left',
'prop:cells:cell1:rowId': 'row1',
'prop:cells:cell1:colId': 'col1',
'prop:cells:cell1:text': YText,
prop:children: []
},
}
}
```
18 lines
634 B
TypeScript
18 lines
634 B
TypeScript
import type { Array as YArray, Map as YMap } from 'yjs';
|
|
|
|
import { proxies } from './memory';
|
|
|
|
export function stashProp(yMap: YMap<unknown>, prop: string): void;
|
|
export function stashProp(yMap: YArray<unknown>, prop: number): void;
|
|
export function stashProp(yAbstract: unknown, prop: string | number) {
|
|
const proxy = proxies.get(yAbstract);
|
|
proxy?.stash(prop);
|
|
}
|
|
|
|
export function popProp(yMap: YMap<unknown>, prop: string): void;
|
|
export function popProp(yMap: YArray<unknown>, prop: number): void;
|
|
export function popProp(yAbstract: unknown, prop: string | number) {
|
|
const proxy = proxies.get(yAbstract);
|
|
proxy?.pop(prop);
|
|
}
|