From 1d5d0688aa80762827a8dc6e203a5eeaa4d5ed47 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Fri, 14 May 2021 18:35:11 -0400 Subject: [PATCH] Fix "add numbered list" styleSelectedText action Looks like I missed the `numberedLines` function used by the `orderedList` function in dd8323ee3610231f6da990823133c44d032c94b8 --- js/src/common/utils/styleSelectedText.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/js/src/common/utils/styleSelectedText.ts b/js/src/common/utils/styleSelectedText.ts index eacd5abc1..fc42c7c4b 100644 --- a/js/src/common/utils/styleSelectedText.ts +++ b/js/src/common/utils/styleSelectedText.ts @@ -260,3 +260,15 @@ function orderedList(textarea: HTMLTextAreaElement): SelectionRange { return { text, selectionStart, selectionEnd }; } + +function numberedLines(lines: string[]) { + let i; + let len; + let index; + const results = []; + for (index = i = 0, len = lines.length; i < len; index = ++i) { + const line = lines[index]; + results.push(`${index + 1}. ${line}`); + } + return results; +}