diff --git a/ftl/core-repo b/ftl/core-repo index b90ef6f03..3d04bcbf7 160000 --- a/ftl/core-repo +++ b/ftl/core-repo @@ -1 +1 @@ -Subproject commit b90ef6f03c251eb336029ac7c5f551200d41273f +Subproject commit 3d04bcbf7fefca0007bc9db307409d88210995d8 diff --git a/ftl/qt-repo b/ftl/qt-repo index 9aa63c335..c65a9587b 160000 --- a/ftl/qt-repo +++ b/ftl/qt-repo @@ -1 +1 @@ -Subproject commit 9aa63c335c61b30421d39cf43fd8e3975179059c +Subproject commit c65a9587b1f18931986bdf145872e8e4c44c5c82 diff --git a/ts/lib/sveltelib/undo-manager.ts b/ts/lib/sveltelib/undo-manager.ts index b475dd17c..f6d46f381 100644 --- a/ts/lib/sveltelib/undo-manager.ts +++ b/ts/lib/sveltelib/undo-manager.ts @@ -9,8 +9,8 @@ type State = { export class UndoManager { private undoStack: State[] = []; private redoStack: State[] = []; - private isUpdating: boolean = false; - private transactionStart: number = 0; + private isUpdating = false; + private transactionStart = 0; public register = this.debounce(this.pushToUndo, 500, (position: number) => this.transactionStart = position); public clearRedoStack() { @@ -44,13 +44,13 @@ export class UndoManager { element.innerHTML = last.content; const selection = getSelection(element)!; - let range = getRange(selection); + const range = getRange(selection); let counter = this.transactionStart; let nodeFound: Node | null = null; let nodeOffset = 0; for (const node of element.childNodes) { - let nodeLength = node.textContent?.length || 0; + const nodeLength = node.textContent?.length || 0; if (counter <= nodeLength) { nodeFound = node; nodeOffset = counter; @@ -94,13 +94,13 @@ export class UndoManager { element.innerHTML = redoedState.content; const selection = getSelection(element)!; - let range = getRange(selection); + const range = getRange(selection); let counter = this.transactionStart; let nodeFound: Node | null = null; let nodeOffset = 0; for (const node of element.childNodes) { - let nodeLength = node.textContent?.length || 0; + const nodeLength = node.textContent?.length || 0; if (counter <= nodeLength) { nodeFound = node; nodeOffset = counter; @@ -134,15 +134,23 @@ export class UndoManager { this.isUpdating = false; } - private debounce(func: Function, delay: number, onTransactionStart: Function): Function { - let timeout; - return (...args) => { + private debounce( + func: (arg: A) => void, + delay: number, + onTransactionStart: (arg: B) => void, + ): (mainArg: A, startArg: B) => void { + let timeout: ReturnType | undefined; + + return (mainArg: A, startArg: B) => { const isNewTransaction = timeout === undefined; clearTimeout(timeout); - if (isNewTransaction) { onTransactionStart.call(this, args[1]); } + + if (isNewTransaction) { + onTransactionStart.call(this, startArg); + } timeout = setTimeout(() => { - func.call(this, args[0]); + func.call(this, mainArg); timeout = undefined; }, delay); };