diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts index f232bd4b95..720d916b98 100644 --- a/frontend/src/lib/utils.ts +++ b/frontend/src/lib/utils.ts @@ -1432,4 +1432,10 @@ export function scroll_into_view_if_needed_polyfill(elem: Element, centerIfNeede return observer // return for testing } +export function clone(t: T): T { + if (typeof t === 'function') throw new Error('Cannot clone a function') + if (typeof t === 'object') return stateSnapshot(t) as T + return t +} + export const editorPositionMap: Record = {}