Converting types to interfaces

This commit is contained in:
KoloMl 2024-08-29 02:19:27 +04:00
parent fee1c3e656
commit 7643f5ddb2

View file

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