tiny-markdown-editor 0.2.27 → 0.2.29
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.
- package/README.md +1 -1
- package/dist/demo.html +11 -3
- package/dist/tiny-mde.css +47 -0
- package/dist/tiny-mde.js +551 -149
- package/dist/tiny-mde.min.css +1 -1
- package/dist/tiny-mde.min.js +1 -1
- package/dist/tiny-mde.tiny.js +1 -1
- package/lib/TinyMDE.d.ts +63 -0
- package/lib/TinyMDE.js +423 -36
- package/lib/grammar.d.ts +7 -0
- package/lib/grammar.js +60 -2
- package/package.json +3 -3
package/lib/grammar.d.ts
CHANGED
|
@@ -35,6 +35,13 @@ export interface LineCommand {
|
|
|
35
35
|
export type Command = InlineCommand | LineCommand;
|
|
36
36
|
export declare const punctuationLeading: RegExp;
|
|
37
37
|
export declare const punctuationTrailing: RegExp;
|
|
38
|
+
/**
|
|
39
|
+
* Standalone regular expressions used by the editor logic (TinyMDE.ts) that aren't part of the
|
|
40
|
+
* block / inline grammar tables above. Centralized here so every pattern the editor relies on lives
|
|
41
|
+
* in one place. Patterns flagged `g` are only ever used with String.prototype.replace(), which
|
|
42
|
+
* resets lastIndex, so sharing a single instance across call sites is safe.
|
|
43
|
+
*/
|
|
44
|
+
export declare const editorRegExp: Record<string, RegExp>;
|
|
38
45
|
/**
|
|
39
46
|
* This is CommonMark's block grammar, but we're ignoring nested blocks here.
|
|
40
47
|
*/
|
package/lib/grammar.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.commands = exports.inlineGrammar = exports.htmlBlockGrammar = exports.lineGrammar = exports.punctuationTrailing = exports.punctuationLeading = void 0;
|
|
3
|
+
exports.commands = exports.inlineGrammar = exports.htmlBlockGrammar = exports.lineGrammar = exports.editorRegExp = exports.punctuationTrailing = exports.punctuationLeading = void 0;
|
|
4
4
|
exports.createMergedInlineGrammar = createMergedInlineGrammar;
|
|
5
5
|
exports.htmlescape = htmlescape;
|
|
6
6
|
const replacements = {
|
|
7
7
|
ASCIIPunctuation: /[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~\\]/,
|
|
8
|
-
|
|
8
|
+
// Newlines are excluded so that, when a paragraph spanning multiple source lines is parsed as
|
|
9
|
+
// one joined string, a soft line break (\n) terminates the current text run and can be handled
|
|
10
|
+
// explicitly as a line break rather than being swallowed into a default token.
|
|
11
|
+
NotTriggerChar: /[^`_*[\]()<>!~\n]/,
|
|
9
12
|
Scheme: /[A-Za-z][A-Za-z0-9+.-]{1,31}/,
|
|
10
13
|
Email: /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*/, // From CommonMark spec
|
|
11
14
|
HTMLOpenTag: /<HTMLTagName(?:HTMLAttribute)*\s*\/?>/,
|
|
@@ -22,6 +25,61 @@ const replacements = {
|
|
|
22
25
|
// From CommonMark.js.
|
|
23
26
|
exports.punctuationLeading = new RegExp(/^(?:[!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B])/);
|
|
24
27
|
exports.punctuationTrailing = new RegExp(/(?:[!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B])$/);
|
|
28
|
+
/**
|
|
29
|
+
* Standalone regular expressions used by the editor logic (TinyMDE.ts) that aren't part of the
|
|
30
|
+
* block / inline grammar tables above. Centralized here so every pattern the editor relies on lives
|
|
31
|
+
* in one place. Patterns flagged `g` are only ever used with String.prototype.replace(), which
|
|
32
|
+
* resets lastIndex, so sharing a single instance across call sites is safe.
|
|
33
|
+
*/
|
|
34
|
+
exports.editorRegExp = {
|
|
35
|
+
// Platform detection and line splitting.
|
|
36
|
+
macPlatform: /Mac|iPod|iPhone|iPad/,
|
|
37
|
+
lineSplit: /(?:\r\n|\r|\n)/,
|
|
38
|
+
// Replacement-template placeholder substitution.
|
|
39
|
+
replacementPlaceholder: /(\${1,2})([0-9])/g, // $N (literal) or $$N (inline content)
|
|
40
|
+
inlineContentPlaceholder: /\$\$([0-9])/, // locate the $$N inline-content placeholder
|
|
41
|
+
inlineReplacementPlaceholder: /\$([1-9])/g, // single-$ placeholder in merged inline grammar
|
|
42
|
+
// Blank / whitespace helpers.
|
|
43
|
+
blankContent: /^\s*$/,
|
|
44
|
+
leadingWhitespace: /^\s/,
|
|
45
|
+
trailingWhitespace: /\s$/,
|
|
46
|
+
leadingWhitespaceRun: /^\s+/,
|
|
47
|
+
surroundingWhitespace: /^(?<leading>\s*).*\S(?<trailing>\s*)$/,
|
|
48
|
+
// List / task list items.
|
|
49
|
+
taskListItem: /^(\[)([ xX])(\])(\s|$)([\s\S]*)$/,
|
|
50
|
+
orderedListNumber: /\d{1,9}/,
|
|
51
|
+
// Opening tag name of an inline HTML element.
|
|
52
|
+
inlineTagName: /^<\s*([a-zA-Z][a-zA-Z0-9]*)/,
|
|
53
|
+
// Event type matching (addEventListener).
|
|
54
|
+
changeEvent: /^(?:change|input)$/i,
|
|
55
|
+
selectionEvent: /^(?:selection|selectionchange)$/i,
|
|
56
|
+
dropEvent: /^(?:drop)$/i,
|
|
57
|
+
// Inline emphasis / strikethrough delimiters and the extended-autolink boundary.
|
|
58
|
+
autolinkPrecedingChar: /[\s*_~(]/,
|
|
59
|
+
emphasisDelimiter: /(^\*+)|(^_+)/,
|
|
60
|
+
strikethroughDelimiter: /^~~/,
|
|
61
|
+
// GFM extended (non-delimited) autolinks.
|
|
62
|
+
autolinkScheme: /^(?:https?|ftp):\/\//i,
|
|
63
|
+
autolinkWww: /^www\./i,
|
|
64
|
+
autolinkDomain: /^[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+)+/,
|
|
65
|
+
autolinkPath: /^[^\s<]*/,
|
|
66
|
+
autolinkProtocol: /^(?:mailto|xmpp):/i,
|
|
67
|
+
autolinkXmpp: /^xmpp:/i,
|
|
68
|
+
autolinkXmppResource: /^\/[a-zA-Z0-9@.\-_]+/,
|
|
69
|
+
autolinkEmail: /^[a-zA-Z0-9.\-_+]+@[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+)+/,
|
|
70
|
+
emailTrailingChar: /[-_]$/,
|
|
71
|
+
emailTld: /\.[a-zA-Z0-9]+$/,
|
|
72
|
+
// Link / image destination parser (character-by-character scanning).
|
|
73
|
+
linkClosingBracket: /^\]/,
|
|
74
|
+
openingAngle: /^</,
|
|
75
|
+
closingAngle: /^>/,
|
|
76
|
+
titleQuote: /^["']/,
|
|
77
|
+
openingParen: /^\(/,
|
|
78
|
+
closingParen: /^\)/,
|
|
79
|
+
endsWithOpenAngle: /<$/,
|
|
80
|
+
containsOpenAngle: /</,
|
|
81
|
+
anyChar: /^./,
|
|
82
|
+
};
|
|
25
83
|
/**
|
|
26
84
|
* This is CommonMark's block grammar, but we're ignoring nested blocks here.
|
|
27
85
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiny-markdown-editor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.29",
|
|
4
4
|
"description": "TinyMDE: A tiny, ultra low dependency, embeddable HTML/JavaScript Markdown editor.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@babel/plugin-transform-modules-commonjs": "^7.27.1",
|
|
46
46
|
"@babel/preset-env": "^7.27.2",
|
|
47
47
|
"@babel/preset-typescript": "^7.27.1",
|
|
48
|
-
"@playwright/test": "^1.
|
|
48
|
+
"@playwright/test": "^1.60.0",
|
|
49
49
|
"@rollup/plugin-babel": "^6.0.4",
|
|
50
50
|
"@rollup/plugin-commonjs": "^28.0.3",
|
|
51
51
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"gulp-typescript": "^6.0.0-alpha.1",
|
|
70
70
|
"jest": "^29.7.0",
|
|
71
71
|
"jest-cli": "^29.7.0",
|
|
72
|
-
"playwright": "^1.
|
|
72
|
+
"playwright": "^1.60.0",
|
|
73
73
|
"postcss-import": "^16.1.0",
|
|
74
74
|
"rollup": "^4.41.1",
|
|
75
75
|
"rollup-plugin-eslint": "^7.0.0",
|