diff --git a/ts/editor/cloze.ts b/ts/editor/cloze.ts index 9d3be3530..8a3a6491a 100644 --- a/ts/editor/cloze.ts +++ b/ts/editor/cloze.ts @@ -17,11 +17,15 @@ function getCurrentHighestCloze(increment: boolean): number { let highest = 0; forEditorField([], (field) => { - const matches = field.editingArea.editable.fieldHTML.matchAll(clozePattern); - highest = Math.max( - highest, - ...[...matches].map((match: RegExpMatchArray): number => Number(match[1])) - ); + const fieldHTML = field.editingArea.editable.fieldHTML; + const matches: number[] = []; + let match: RegExpMatchArray | null = null; + + while ((match = clozePattern.exec(fieldHTML))) { + matches.push(Number(match[1])); + } + + highest = Math.max(highest, ...matches); }); if (increment) { diff --git a/ts/tsconfig.json b/ts/tsconfig.json index 63afaad58..bc98946fd 100644 --- a/ts/tsconfig.json +++ b/ts/tsconfig.json @@ -3,14 +3,7 @@ "compilerOptions": { "target": "es6", "module": "es6", - "lib": [ - "es2017", - "es2020.string", - "es2019.array", - "es2018.promise", - "dom", - "dom.iterable" - ], + "lib": ["es2017", "es2019.array", "es2018.promise", "dom", "dom.iterable"], "baseUrl": ".", "paths": { "anki/*": ["../bazel-bin/ts/lib/*"],