Skip to content

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.

fix:shapaes

DiamondThree2eaf26c40f59
diff --git a/libs/components/affine-board/src/Board.tsx b/libs/components/affine-board/src/Board.tsx
index 5150feb919..db969d29da 100644
--- a/libs/components/affine-board/src/Board.tsx
+++ b/libs/components/affine-board/src/Board.tsx
@@ -45,8 +45,6 @@ const AffineBoard = ({ workspace, rootBlockId }: AffineBoardProps) => {
});
const { shapes, bindings } = useShapes(workspace, rootBlockId);
-
- // const bindings = useBindings(workspace, rootBlockId);
useEffect(() => {
if (app) {
app.replacePageContent(shapes || {}, bindings, {});
@@ -124,7 +122,7 @@ const AffineBoard = ({ workspace, rootBlockId }: AffineBoardProps) => {
workspace: workspace,
ids: [rootBlockId],
})
- )?.[0].properties.bindings.value;
+ )?.[0].properties.bindings?.value;
let pageBindings = JSON.parse(pageBindingsString ?? '{}');
Object.keys(bindings).forEach(bindingsKey => {
if (bindings[bindingsKey] === undefined) {
@@ -133,7 +131,6 @@ const AffineBoard = ({ workspace, rootBlockId }: AffineBoardProps) => {
Object.assign(pageBindings, bindings);
}
});
- console.log(pageBindings);
services.api.editorBlock.update({
workspace: workspace,
id: rootBlockId,
diff --git a/libs/components/affine-board/src/hooks/use-shapes.ts b/libs/components/affine-board/src/hooks/use-shapes.ts
index 5167ed5ccb..beb8c50efa 100644
--- a/libs/components/affine-board/src/hooks/use-shapes.ts
+++ b/libs/components/affine-board/src/hooks/use-shapes.ts
@@ -5,6 +5,17 @@ import { services } from '@toeverything/datasource/db-service';
import { usePageClientWidth } from '@toeverything/datasource/state';
import { useEffect, useState } from 'react';
+const getBindings = (workspace: string, rootBlockId: string) => {
+ return services.api.editorBlock
+ .get({
+ workspace: workspace,
+ ids: [rootBlockId],
+ })
+ .then(blcoks => {
+ return blcoks[0].properties.bindings?.value;
+ });
+};
+
export const useShapes = (workspace: string, rootBlockId: string) => {
const { pageClientWidth } = usePageClientWidth();
// page padding left and right total 300px
@@ -30,28 +41,20 @@ export const useShapes = (workspace: string, rootBlockId: string) => {
})
);
return shapes;
- // setBlocks(shapes);
}),
]).then(shapes => {
- console.log(shapes);
- services.api.editorBlock
- .get({
- workspace: workspace,
- ids: [rootBlockId],
- })
- .then(blcoks => {
- setBlocks({
- shapes,
- bindings: blcoks[0].properties.bindings?.value,
- });
- // setBindings(blcoks[0].properties.bindings?.value);
+ getBindings(workspace, rootBlockId).then(bindings => {
+ setBlocks({
+ shapes,
+ bindings: bindings,
});
+ });
});
let unobserve: () => void;
services.api.editorBlock
.observe({ workspace, id: rootBlockId }, async blockData => {
- const shapes = await Promise.all(
+ Promise.all(
(blockData?.children || []).map(async childId => {
const childBlock = (
await services.api.editorBlock.get({
@@ -62,22 +65,13 @@ export const useShapes = (workspace: string, rootBlockId: string) => {
return childBlock;
})
).then(shapes => {
- console.log(shapes);
- services.api.editorBlock
- .get({
- workspace: workspace,
- ids: [rootBlockId],
- })
- .then(blcoks => {
- setBlocks({
- shapes: [shapes],
- bindings: blcoks[0].properties.bindings?.value,
- });
- // setBindings(blcoks[0].properties.bindings?.value);
+ getBindings(workspace, rootBlockId).then(bindings => {
+ setBlocks({
+ shapes: [shapes],
+ bindings: bindings,
});
+ });
});
- return shapes;
- // setBlocks(shapes);
})
.then(cb => {
unobserve = cb;