diff --git a/assets/js/markdowntoolbar.ts b/assets/js/markdowntoolbar.ts index cc39c0bc..f09b586c 100644 --- a/assets/js/markdowntoolbar.ts +++ b/assets/js/markdowntoolbar.ts @@ -5,7 +5,7 @@ import { $, $$ } from './utils/dom'; // List of options provided to the syntax handler function. -type SyntaxHandlerOptions = { +interface SyntaxHandlerOptions { prefix: string; shortcutKeyCode: number; suffix: string; @@ -15,12 +15,12 @@ type SyntaxHandlerOptions = { escapeChar: string; image: boolean; text: string; -}; +} -type SyntaxHandler = { +interface SyntaxHandler { action: (textarea: HTMLTextAreaElement, options: Partial) => void; options: Partial; -}; +} const markdownSyntax: Record = { bold: { @@ -80,12 +80,12 @@ const markdownSyntax: Record = { }, }; -type SelectionResult = { +interface SelectionResult { processLinesOnly: boolean; selectedText: string; beforeSelection: string; afterSelection: string; -}; +} function getSelections(textarea: HTMLTextAreaElement, linesOnly: RegExp | boolean = false): SelectionResult { let { selectionStart, selectionEnd } = textarea, @@ -145,10 +145,10 @@ function getSelections(textarea: HTMLTextAreaElement, linesOnly: RegExp | boolea }; } -type TransformResult = { +interface TransformResult { newText: string; caretOffset: number; -}; +} type TransformCallback = (selectedText: string, processLinesOnly: boolean) => TransformResult;