tiny-markdown-editor 0.1.32 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,70 @@
1
+ export interface GrammarRule {
2
+ regexp: RegExp;
3
+ replacement: string;
4
+ labelPlaceholder?: number;
5
+ }
6
+ export interface HTMLBlockRule {
7
+ start: RegExp;
8
+ end: RegExp | false;
9
+ paraInterrupt: boolean;
10
+ }
11
+ export interface InlineCommand {
12
+ type: 'inline';
13
+ className: string;
14
+ set: {
15
+ pre: string;
16
+ post: string;
17
+ };
18
+ unset: {
19
+ prePattern: RegExp;
20
+ postPattern: RegExp;
21
+ };
22
+ }
23
+ export interface LineCommand {
24
+ type: 'line';
25
+ className: string;
26
+ set: {
27
+ pattern: RegExp;
28
+ replacement: string;
29
+ };
30
+ unset: {
31
+ pattern: RegExp;
32
+ replacement: string;
33
+ };
34
+ }
35
+ export type Command = InlineCommand | LineCommand;
36
+ export declare const punctuationLeading: RegExp;
37
+ export declare const punctuationTrailing: RegExp;
38
+ /**
39
+ * This is CommonMark's block grammar, but we're ignoring nested blocks here.
40
+ */
41
+ export declare const lineGrammar: Record<string, GrammarRule>;
42
+ /**
43
+ * HTML blocks have multiple different classes of opener and closer. This array defines all the cases
44
+ */
45
+ export declare const htmlBlockGrammar: HTMLBlockRule[];
46
+ /**
47
+ * Structure of the object:
48
+ * Top level entries are rules, each consisting of a regular expressions (in string format) as well as a replacement.
49
+ * In the regular expressions, replacements from the object 'replacements' will be processed before compiling into the property regexp.
50
+ */
51
+ export declare const inlineGrammar: Record<string, GrammarRule>;
52
+ /**
53
+ * Escapes HTML special characters (<, >, and &) in the string.
54
+ * @param {string} string The raw string to be escaped
55
+ * @returns {string} The string, ready to be used in HTML
56
+ */
57
+ export declare function htmlescape(string: string): string;
58
+ /**
59
+ * Contains the commands that can be sent to the editor. Contains objects with a name representing the name of the command.
60
+ * Each of the objects contains the following keys:
61
+ *
62
+ * - type: Can be either inline (for inline formatting) or line (for block / line formatting).
63
+ * - className: Used to determine whether the command is active at a given position.
64
+ * For line formatting, this looks at the class of the line element. For inline elements, tries to find an enclosing element with that class.
65
+ * - set / unset: Contain instructions how to set and unset the command. For line type commands, both consist of a pattern and replacement that
66
+ * will be applied to each line (using String.replace). For inline type commands, the set object contains a pre and post string which will
67
+ * be inserted before and after the selection. The unset object contains a prePattern and a postPattern. Both should be regular expressions and
68
+ * they will be applied to the portion of the line before and after the selection (using String.replace, with an empty replacement string).
69
+ */
70
+ export declare const commands: Record<string, Command>;