Edit files and diffs
Enable a full-featured yet lightweight editor that lazy-loads when needed on top of any File or FileDiff. All the ergonomics and customization of @pierre/diffs, with everything you need to edit in place.
Live editing
Edit mode (experimental) makes any code component—File or FileDiff—editable in place. Toggle between a read-only Review and a live Edit, switch the component between a file and a diff, and render the diff unified or side-by-side split. Start typing in the code below and it updates as you edit.
debounce.ts
1234567891011121314151617181920212223242526272829303132export interface DebounceOptions { waitMs: number; trailing?: boolean;}
export function debounce<Args extends unknown[]>( fn: (...args: Args) => void, options: DebounceOptions,) { let timer: ReturnType<typeof setTimeout> | undefined;
const debounced = (...args: Args) => { if (timer != null) { clearTimeout(timer); }
timer = setTimeout(() => { timer = undefined; if (options.trailing !== false) { fn(...args); } }, options.waitMs); };
debounced.cancel = () => { clearTimeout(timer); timer = undefined; };
return debounced;}
Remote carets and highlights
Show collaborators with editor.setCarets(). Type or select in either editor below to see edits, carets, and highlights reflected in the other collaborator's view.