Bugfix/delete log (#315)

* fix delete log

* fix delete log
This commit is contained in:
DiamondThree
2022-08-24 13:47:47 +08:00
committed by GitHub
parent 15055bc7c6
commit 617e9a0612
5 changed files with 13 additions and 9 deletions

View File

@@ -52,6 +52,7 @@ const AffineBoard = ({
}); });
const { shapes, bindings } = useShapes(workspace, rootBlockId); const { shapes, bindings } = useShapes(workspace, rootBlockId);
useEffect(() => { useEffect(() => {
if (app) { if (app) {
app.replacePageContent(shapes || {}, bindings, {}); app.replacePageContent(shapes || {}, bindings, {});
@@ -109,7 +110,6 @@ const AffineBoard = ({
}); });
} }
shape.affineId = block.id; shape.affineId = block.id;
Object.keys(bindings).forEach(bilingKey => { Object.keys(bindings).forEach(bilingKey => {
if ( if (
bindings[bilingKey]?.fromId === shape.id bindings[bilingKey]?.fromId === shape.id
@@ -148,7 +148,8 @@ const AffineBoard = ({
Object.assign(pageBindings, bindings); Object.assign(pageBindings, bindings);
} }
}); });
services.api.editorBlock.update({
await services.api.editorBlock.update({
workspace: workspace, workspace: workspace,
id: rootBlockId, id: rootBlockId,
properties: { properties: {

View File

@@ -12,7 +12,7 @@ const getBindings = (workspace: string, rootBlockId: string) => {
ids: [rootBlockId], ids: [rootBlockId],
}) })
.then(blcoks => { .then(blcoks => {
return blcoks[0].properties.bindings?.value; return blcoks[0]?.properties.bindings?.value;
}); });
}; };
@@ -104,6 +104,7 @@ export const useShapes = (workspace: string, rootBlockId: string) => {
return acc; return acc;
}, {} as Record<string, TDShape>); }, {} as Record<string, TDShape>);
return { return {
shapes: blocksShapes, shapes: blocksShapes,
bindings: JSON.parse(blocks?.bindings ?? '{}'), bindings: JSON.parse(blocks?.bindings ?? '{}'),

View File

@@ -21,6 +21,9 @@ export const ArrowTo = ({ app, shapes }: GroupAndUnGroupProps) => {
let activeShape = shapes[0]; let activeShape = shapes[0];
let toNextShapBindings: ArrowBinding[] = []; let toNextShapBindings: ArrowBinding[] = [];
let bindingId = ''; let bindingId = '';
if (!activeShape) {
return;
}
Object.keys(bindings).forEach(key => { Object.keys(bindings).forEach(key => {
if (bindings[key].toId === activeShape.id) { if (bindings[key].toId === activeShape.id) {
bindingId = bindings[key].fromId; bindingId = bindings[key].fromId;
@@ -35,7 +38,6 @@ export const ArrowTo = ({ app, shapes }: GroupAndUnGroupProps) => {
toNextShapBindings.forEach(binding => { toNextShapBindings.forEach(binding => {
if (binding.toId !== activeShape.id) { if (binding.toId !== activeShape.id) {
allShape.forEach(item => { allShape.forEach(item => {
console.log(item);
if (item.id === binding.toId) { if (item.id === binding.toId) {
ArrowToArr.push(item); ArrowToArr.push(item);
} }
@@ -44,7 +46,7 @@ export const ArrowTo = ({ app, shapes }: GroupAndUnGroupProps) => {
}); });
setarrowToArr(ArrowToArr); setarrowToArr(ArrowToArr);
return () => {}; return () => {};
}, [app.page.bindings, app.shapes]); }, [app.page.bindings]);
const jumpToNextShap = (shape: TDShape) => { const jumpToNextShap = (shape: TDShape) => {
app.zoomToShapes([shape]); app.zoomToShapes([shape]);
}; };
@@ -68,7 +70,7 @@ export const ArrowTo = ({ app, shapes }: GroupAndUnGroupProps) => {
</div> </div>
} }
> >
<Tooltip content="Font Size" placement="top-start"> <Tooltip content="ArrowToEditor" placement="top-start">
<IconButton> <IconButton>
<ConnectorIcon></ConnectorIcon> <ConnectorIcon></ConnectorIcon>
</IconButton> </IconButton>

View File

@@ -626,7 +626,7 @@ export class TldrawApp extends StateManager<TDSnapshot> {
private prev_bindings = this.page.bindings; private prev_bindings = this.page.bindings;
private prev_assets = this.document.assets; private prev_assets = this.document.assets;
private _broadcastPageChanges = () => { private _broadcastPageChanges = async () => {
const visited = new Set<string>(); const visited = new Set<string>();
const changedShapes: Record<string, TDShape | undefined> = {}; const changedShapes: Record<string, TDShape | undefined> = {};
@@ -683,7 +683,7 @@ export class TldrawApp extends StateManager<TDSnapshot> {
Object.keys(changedAssets).length > 0 Object.keys(changedAssets).length > 0
) { ) {
this.just_sent = true; this.just_sent = true;
this.callbacks.onChangePage?.( await this.callbacks.onChangePage?.(
this, this,
changedShapes, changedShapes,
changedBindings, changedBindings,

View File

@@ -804,7 +804,7 @@ const EditorLeaf = ({ attributes, children, leaf }: any) => {
backgroundColor: '#F2F5F9', backgroundColor: '#F2F5F9',
borderRadius: '5px', borderRadius: '5px',
color: '#3A4C5C', color: '#3A4C5C',
padding: '3px 8px', padding: '1px 8px',
margin: '0 2px', margin: '0 2px',
}} }}
> >