Skip to content

Commit

Permalink
feat(canvas): tweak UndoManager config
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcfps committed Feb 13, 2025
1 parent 36c815f commit e07ba74
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useThrottledCallback } from 'use-debounce';
import { Edge } from '@xyflow/react';
import { CanvasNode } from '../../components/canvas/nodes';
import { UndoManager } from 'yjs';
import { omit } from '@refly/utils';

export const useCanvasSync = () => {
const { provider } = useCanvasContext();
Expand All @@ -16,7 +17,7 @@ export const useCanvasSync = () => {
return new UndoManager(
[ydoc.getText('title'), ydoc.getArray('nodes'), ydoc.getArray('edges')],
{
captureTimeout: 500, // Merge edits that are within 500ms together
captureTimeout: 1000,
},
);
}, [ydoc]);
Expand All @@ -42,7 +43,7 @@ export const useCanvasSync = () => {
ydoc?.transact(() => {
const yEdges = ydoc?.getArray('edges');
yEdges?.delete(0, yEdges?.length ?? 0);
yEdges?.push(edges);
yEdges?.push(edges.map((edge) => omit(edge, ['style'])));
});
};

Expand Down

0 comments on commit e07ba74

Please sign in to comment.