Skip to content

Commit

Permalink
Merge branch 'rm/285925' into 'master'
Browse files Browse the repository at this point in the history
add function to get the last numbered line from text for numbered list

See merge request kchat/webapp!896
  • Loading branch information
antonbuks committed Oct 1, 2024
2 parents e61f5a6 + 7f1b909 commit 9cc148c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions webapp/channels/src/utils/markdown/apply_markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ const applyOlMarkdown = ({selectionEnd, selectionStart, message}: ApplySpecificM
newEnd = Math.max(selectionEnd - (delimiterLength * count), 0);
} else {
let count = 0;

const getLastNumberedLine = (text: string): number => {
const match = text.match(/(\d+)\.\s/g);
if (match) {
return parseInt(match[match.length - 1], 10);
}
return 0;
};
getDelimiter.counter = getLastNumberedLine(newPrefix) + 1;

if (isFirstLineSelected) {
multilineSelection = getDelimiter() + multilineSelection;
count++;
Expand Down

0 comments on commit 9cc148c

Please sign in to comment.