tiny-markdown-editor 0.1.10 → 0.1.12
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/dist/tiny-mde.js +3 -3
- package/dist/tiny-mde.min.js +1 -1
- package/dist/tiny-mde.tiny.js +1 -1
- package/lib/TinyMDE.js +63 -57
- package/lib/TinyMDECommandBar.js +22 -15
- package/lib/grammar.js +16 -9
- package/lib/index.js +20 -3
- package/lib/svg/svg.js +7 -1
- package/lib/tiny.js +13 -2
- package/package.json +2 -1
package/lib/TinyMDE.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _grammar = require("./grammar");
|
|
2
8
|
class Editor {
|
|
3
9
|
constructor() {
|
|
4
10
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -115,7 +121,7 @@ class Editor {
|
|
|
115
121
|
this.linkLabels = [];
|
|
116
122
|
for (let l = 0; l < this.lines.length; l++) {
|
|
117
123
|
if (this.lineTypes[l] == 'TMLinkReferenceDefinition') {
|
|
118
|
-
this.linkLabels.push(this.lineCaptures[l][lineGrammar.TMLinkReferenceDefinition.labelPlaceholder]);
|
|
124
|
+
this.linkLabels.push(this.lineCaptures[l][_grammar.lineGrammar.TMLinkReferenceDefinition.labelPlaceholder]);
|
|
119
125
|
}
|
|
120
126
|
}
|
|
121
127
|
}
|
|
@@ -132,7 +138,7 @@ class Editor {
|
|
|
132
138
|
*/
|
|
133
139
|
replace(replacement, capture) {
|
|
134
140
|
return replacement.replace(/(\${1,2})([0-9])/g, (str, p1, p2) => {
|
|
135
|
-
if (p1 == '$') return htmlescape(capture[p2]);else return `<span class="TMInlineFormatted">${this.processInlineStyles(capture[p2])}</span>`;
|
|
141
|
+
if (p1 == '$') return (0, _grammar.htmlescape)(capture[p2]);else return `<span class="TMInlineFormatted">${this.processInlineStyles(capture[p2])}</span>`;
|
|
136
142
|
});
|
|
137
143
|
}
|
|
138
144
|
|
|
@@ -172,10 +178,10 @@ class Editor {
|
|
|
172
178
|
// if (lineNum > 0 && (this.lineTypes[lineNum - 1] == 'TMCodeFenceBacktickOpen' || this.lineTypes[lineNum - 1] == 'TMFencedCodeBacktick')) {
|
|
173
179
|
if (codeBlockType == 'TMCodeFenceBacktickOpen') {
|
|
174
180
|
// We're in a backtick-fenced code block, check if the current line closes it
|
|
175
|
-
let capture = lineGrammar.TMCodeFenceBacktickClose.regexp.exec(this.lines[lineNum]);
|
|
181
|
+
let capture = _grammar.lineGrammar.TMCodeFenceBacktickClose.regexp.exec(this.lines[lineNum]);
|
|
176
182
|
if (capture && capture.groups['seq'].length >= codeBlockSeqLength) {
|
|
177
183
|
lineType = 'TMCodeFenceBacktickClose';
|
|
178
|
-
lineReplacement = lineGrammar.TMCodeFenceBacktickClose.replacement;
|
|
184
|
+
lineReplacement = _grammar.lineGrammar.TMCodeFenceBacktickClose.replacement;
|
|
179
185
|
lineCapture = capture;
|
|
180
186
|
codeBlockType = false;
|
|
181
187
|
} else {
|
|
@@ -187,10 +193,10 @@ class Editor {
|
|
|
187
193
|
// if (lineNum > 0 && (this.lineTypes[lineNum - 1] == 'TMCodeFenceTildeOpen' || this.lineTypes[lineNum - 1] == 'TMFencedCodeTilde')) {
|
|
188
194
|
else if (codeBlockType == 'TMCodeFenceTildeOpen') {
|
|
189
195
|
// We're in a tilde-fenced code block
|
|
190
|
-
let capture = lineGrammar.TMCodeFenceTildeClose.regexp.exec(this.lines[lineNum]);
|
|
196
|
+
let capture = _grammar.lineGrammar.TMCodeFenceTildeClose.regexp.exec(this.lines[lineNum]);
|
|
191
197
|
if (capture && capture.groups['seq'].length >= codeBlockSeqLength) {
|
|
192
198
|
lineType = 'TMCodeFenceTildeClose';
|
|
193
|
-
lineReplacement = lineGrammar.TMCodeFenceTildeClose.replacement;
|
|
199
|
+
lineReplacement = _grammar.lineGrammar.TMCodeFenceTildeClose.replacement;
|
|
194
200
|
lineCapture = capture;
|
|
195
201
|
codeBlockType = false;
|
|
196
202
|
} else {
|
|
@@ -202,7 +208,7 @@ class Editor {
|
|
|
202
208
|
|
|
203
209
|
// Check HTML block types
|
|
204
210
|
if (lineType == 'TMPara' && htmlBlock === false) {
|
|
205
|
-
for (let htmlBlockType of htmlBlockGrammar) {
|
|
211
|
+
for (let htmlBlockType of _grammar.htmlBlockGrammar) {
|
|
206
212
|
if (this.lines[lineNum].match(htmlBlockType.start)) {
|
|
207
213
|
// Matching start condition. Check if this tag can start here (not all start conditions allow breaking a paragraph).
|
|
208
214
|
if (htmlBlockType.paraInterrupt || lineNum == 0 || !(this.lineTypes[lineNum - 1] == 'TMPara' || this.lineTypes[lineNum - 1] == 'TMUL' || this.lineTypes[lineNum - 1] == 'TMOL' || this.lineTypes[lineNum - 1] == 'TMBlockquote')) {
|
|
@@ -225,7 +231,7 @@ class Editor {
|
|
|
225
231
|
}
|
|
226
232
|
} else {
|
|
227
233
|
// No specific end condition, ends with blank line
|
|
228
|
-
if (lineNum == this.lines.length - 1 || this.lines[lineNum + 1].match(lineGrammar.TMBlankLine.regexp)) {
|
|
234
|
+
if (lineNum == this.lines.length - 1 || this.lines[lineNum + 1].match(_grammar.lineGrammar.TMBlankLine.regexp)) {
|
|
229
235
|
htmlBlock = false;
|
|
230
236
|
}
|
|
231
237
|
}
|
|
@@ -233,12 +239,12 @@ class Editor {
|
|
|
233
239
|
|
|
234
240
|
// Check all regexps if we haven't applied one of the code block types
|
|
235
241
|
if (lineType == 'TMPara') {
|
|
236
|
-
for (let type in lineGrammar) {
|
|
237
|
-
if (lineGrammar[type].regexp) {
|
|
238
|
-
let capture = lineGrammar[type].regexp.exec(this.lines[lineNum]);
|
|
242
|
+
for (let type in _grammar.lineGrammar) {
|
|
243
|
+
if (_grammar.lineGrammar[type].regexp) {
|
|
244
|
+
let capture = _grammar.lineGrammar[type].regexp.exec(this.lines[lineNum]);
|
|
239
245
|
if (capture) {
|
|
240
246
|
lineType = type;
|
|
241
|
-
lineReplacement = lineGrammar[type].replacement;
|
|
247
|
+
lineReplacement = _grammar.lineGrammar[type].replacement;
|
|
242
248
|
lineCapture = capture;
|
|
243
249
|
break;
|
|
244
250
|
}
|
|
@@ -262,10 +268,10 @@ class Editor {
|
|
|
262
268
|
|
|
263
269
|
// Setext H2 markers that can also be interpreted as an empty list item should be regarded as such (as per CommonMark spec)
|
|
264
270
|
if (lineType == 'TMSetextH2Marker') {
|
|
265
|
-
let capture = lineGrammar.TMUL.regexp.exec(this.lines[lineNum]);
|
|
271
|
+
let capture = _grammar.lineGrammar.TMUL.regexp.exec(this.lines[lineNum]);
|
|
266
272
|
if (capture) {
|
|
267
273
|
lineType = 'TMUL';
|
|
268
|
-
lineReplacement = lineGrammar.TMUL.replacement;
|
|
274
|
+
lineReplacement = _grammar.lineGrammar.TMUL.replacement;
|
|
269
275
|
lineCapture = capture;
|
|
270
276
|
}
|
|
271
277
|
}
|
|
@@ -274,12 +280,12 @@ class Editor {
|
|
|
274
280
|
if (lineType == 'TMSetextH1Marker' || lineType == 'TMSetextH2Marker') {
|
|
275
281
|
if (lineNum == 0 || this.lineTypes[lineNum - 1] != 'TMPara') {
|
|
276
282
|
// Setext marker is invalid. However, a H2 marker might still be a valid HR, so let's check that
|
|
277
|
-
let capture = lineGrammar.TMHR.regexp.exec(this.lines[lineNum]);
|
|
283
|
+
let capture = _grammar.lineGrammar.TMHR.regexp.exec(this.lines[lineNum]);
|
|
278
284
|
if (capture) {
|
|
279
285
|
// Valid HR
|
|
280
286
|
lineType = 'TMHR';
|
|
281
287
|
lineCapture = capture;
|
|
282
|
-
lineReplacement = lineGrammar.TMHR.replacement;
|
|
288
|
+
lineReplacement = _grammar.lineGrammar.TMHR.replacement;
|
|
283
289
|
} else {
|
|
284
290
|
// Not valid HR, format as TMPara
|
|
285
291
|
lineType = 'TMPara';
|
|
@@ -347,7 +353,7 @@ class Editor {
|
|
|
347
353
|
// Capture any escapes and code blocks at current position, they bind more strongly than links
|
|
348
354
|
// We don't have to actually process them here, that'll be done later in case the link / image is valid, but we need to skip over them.
|
|
349
355
|
for (let rule of ['escape', 'code', 'autolink', 'html']) {
|
|
350
|
-
let cap = inlineGrammar[rule].regexp.exec(string);
|
|
356
|
+
let cap = _grammar.inlineGrammar[rule].regexp.exec(string);
|
|
351
357
|
if (cap) {
|
|
352
358
|
currentOffset += cap[0].length;
|
|
353
359
|
continue textOuter;
|
|
@@ -355,7 +361,7 @@ class Editor {
|
|
|
355
361
|
}
|
|
356
362
|
|
|
357
363
|
// Check for image. It's okay for an image to be included in a link or image
|
|
358
|
-
if (string.match(inlineGrammar.imageOpen.regexp)) {
|
|
364
|
+
if (string.match(_grammar.inlineGrammar.imageOpen.regexp)) {
|
|
359
365
|
// Opening image. It's okay if this is a matching pair of brackets
|
|
360
366
|
bracketLevel++;
|
|
361
367
|
currentOffset += 2;
|
|
@@ -363,7 +369,7 @@ class Editor {
|
|
|
363
369
|
}
|
|
364
370
|
|
|
365
371
|
// Check for link (not an image because that would have been captured and skipped over above)
|
|
366
|
-
if (string.match(inlineGrammar.linkOpen.regexp)) {
|
|
372
|
+
if (string.match(_grammar.inlineGrammar.linkOpen.regexp)) {
|
|
367
373
|
// Opening bracket. Two things to do:
|
|
368
374
|
// 1) it's okay if this part of a pair of brackets.
|
|
369
375
|
// 2) If we are currently trying to parse a link, this nested bracket musn't start a valid link (no nested links allowed)
|
|
@@ -403,14 +409,14 @@ class Editor {
|
|
|
403
409
|
// REFERENCE LINKS
|
|
404
410
|
if (nextChar == '[') {
|
|
405
411
|
let string = originalString.substr(currentOffset);
|
|
406
|
-
let cap = inlineGrammar.linkLabel.regexp.exec(string);
|
|
412
|
+
let cap = _grammar.inlineGrammar.linkLabel.regexp.exec(string);
|
|
407
413
|
if (cap) {
|
|
408
414
|
// Valid link label
|
|
409
415
|
currentOffset += cap[0].length;
|
|
410
416
|
linkLabel.push(cap[1], cap[2], cap[3]);
|
|
411
|
-
if (cap[inlineGrammar.linkLabel.labelPlaceholder]) {
|
|
417
|
+
if (cap[_grammar.inlineGrammar.linkLabel.labelPlaceholder]) {
|
|
412
418
|
// Full reference link
|
|
413
|
-
linkRef = cap[inlineGrammar.linkLabel.labelPlaceholder];
|
|
419
|
+
linkRef = cap[_grammar.inlineGrammar.linkLabel.labelPlaceholder];
|
|
414
420
|
} else {
|
|
415
421
|
// Collapsed reference link
|
|
416
422
|
linkRef = linkText.trim();
|
|
@@ -484,7 +490,7 @@ class Editor {
|
|
|
484
490
|
}
|
|
485
491
|
|
|
486
492
|
// Process backslash escapes
|
|
487
|
-
cap = inlineGrammar.escape.regexp.exec(string);
|
|
493
|
+
cap = _grammar.inlineGrammar.escape.regexp.exec(string);
|
|
488
494
|
if (cap) {
|
|
489
495
|
switch (linkDetails.length) {
|
|
490
496
|
case 0:
|
|
@@ -713,20 +719,20 @@ class Editor {
|
|
|
713
719
|
outer: while (string) {
|
|
714
720
|
// Process simple rules (non-delimiter)
|
|
715
721
|
for (let rule of ['escape', 'code', 'autolink', 'html']) {
|
|
716
|
-
let cap = inlineGrammar[rule].regexp.exec(string);
|
|
722
|
+
let cap = _grammar.inlineGrammar[rule].regexp.exec(string);
|
|
717
723
|
if (cap) {
|
|
718
724
|
string = string.substr(cap[0].length);
|
|
719
725
|
offset += cap[0].length;
|
|
720
|
-
processed += inlineGrammar[rule].replacement
|
|
726
|
+
processed += _grammar.inlineGrammar[rule].replacement
|
|
721
727
|
// .replace(/\$\$([1-9])/g, (str, p1) => processInlineStyles(cap[p1])) // todo recursive calling
|
|
722
|
-
.replace(/\$([1-9])/g, (str, p1) => htmlescape(cap[p1]));
|
|
728
|
+
.replace(/\$([1-9])/g, (str, p1) => (0, _grammar.htmlescape)(cap[p1]));
|
|
723
729
|
continue outer;
|
|
724
730
|
}
|
|
725
731
|
}
|
|
726
732
|
|
|
727
733
|
// Check for links / images
|
|
728
|
-
let potentialLink = string.match(inlineGrammar.linkOpen.regexp);
|
|
729
|
-
let potentialImage = string.match(inlineGrammar.imageOpen.regexp);
|
|
734
|
+
let potentialLink = string.match(_grammar.inlineGrammar.linkOpen.regexp);
|
|
735
|
+
let potentialImage = string.match(_grammar.inlineGrammar.imageOpen.regexp);
|
|
730
736
|
if (potentialImage || potentialLink) {
|
|
731
737
|
let result = this.parseLinkOrImage(string, potentialImage);
|
|
732
738
|
if (result) {
|
|
@@ -750,8 +756,8 @@ class Editor {
|
|
|
750
756
|
|
|
751
757
|
const preceding = offset > 0 ? originalString.substr(0, offset) : ' '; // beginning and end of line count as whitespace
|
|
752
758
|
const following = offset + cap[0].length < originalString.length ? string : ' ';
|
|
753
|
-
const punctuationFollows = following.match(punctuationLeading);
|
|
754
|
-
const punctuationPrecedes = preceding.match(punctuationTrailing);
|
|
759
|
+
const punctuationFollows = following.match(_grammar.punctuationLeading);
|
|
760
|
+
const punctuationPrecedes = preceding.match(_grammar.punctuationTrailing);
|
|
755
761
|
const whitespaceFollows = following.match(/^\s/);
|
|
756
762
|
const whitespacePrecedes = preceding.match(/\s$/);
|
|
757
763
|
|
|
@@ -870,11 +876,11 @@ class Editor {
|
|
|
870
876
|
}
|
|
871
877
|
|
|
872
878
|
// Process 'default' rule
|
|
873
|
-
cap = inlineGrammar.default.regexp.exec(string);
|
|
879
|
+
cap = _grammar.inlineGrammar.default.regexp.exec(string);
|
|
874
880
|
if (cap) {
|
|
875
881
|
string = string.substr(cap[0].length);
|
|
876
882
|
offset += cap[0].length;
|
|
877
|
-
processed += inlineGrammar.default.replacement.replace(/\$([1-9])/g, (str, p1) => htmlescape(cap[p1]));
|
|
883
|
+
processed += _grammar.inlineGrammar.default.replacement.replace(/\$([1-9])/g, (str, p1) => (0, _grammar.htmlescape)(cap[p1]));
|
|
878
884
|
continue outer;
|
|
879
885
|
}
|
|
880
886
|
throw 'Infinite loop!';
|
|
@@ -978,7 +984,7 @@ class Editor {
|
|
|
978
984
|
sel.col = 0;
|
|
979
985
|
if (continuableType) {
|
|
980
986
|
// Check if the previous line was non-empty
|
|
981
|
-
let capture = lineGrammar[continuableType].regexp.exec(this.lines[sel.row - 1]);
|
|
987
|
+
let capture = _grammar.lineGrammar[continuableType].regexp.exec(this.lines[sel.row - 1]);
|
|
982
988
|
if (capture) {
|
|
983
989
|
// Convention: capture[1] is the line type marker, capture[2] is the content
|
|
984
990
|
if (capture[2]) {
|
|
@@ -1375,7 +1381,7 @@ class Editor {
|
|
|
1375
1381
|
if (!focus) focus = this.getSelection(false);
|
|
1376
1382
|
if (!anchor) anchor = this.getSelection(true);
|
|
1377
1383
|
if (!focus) {
|
|
1378
|
-
for (let cmd in commands) {
|
|
1384
|
+
for (let cmd in _grammar.commands) {
|
|
1379
1385
|
commandState[cmd] = null;
|
|
1380
1386
|
}
|
|
1381
1387
|
return commandState;
|
|
@@ -1394,25 +1400,25 @@ class Editor {
|
|
|
1394
1400
|
end.col = this.lines[end.row].length; // Selection to beginning of next line is said to end at the beginning of the last line
|
|
1395
1401
|
}
|
|
1396
1402
|
|
|
1397
|
-
for (let cmd in commands) {
|
|
1398
|
-
if (commands[cmd].type == 'inline') {
|
|
1403
|
+
for (let cmd in _grammar.commands) {
|
|
1404
|
+
if (_grammar.commands[cmd].type == 'inline') {
|
|
1399
1405
|
if (!focus || focus.row != anchor.row || !this.isInlineFormattingAllowed(focus, anchor)) {
|
|
1400
1406
|
commandState[cmd] = null;
|
|
1401
1407
|
} else {
|
|
1402
1408
|
// The command state is true if there is a respective enclosing markup node (e.g., the selection is enclosed in a <b>..</b>) ...
|
|
1403
|
-
commandState[cmd] = !!this.computeEnclosingMarkupNode(focus, anchor, commands[cmd].className) ||
|
|
1409
|
+
commandState[cmd] = !!this.computeEnclosingMarkupNode(focus, anchor, _grammar.commands[cmd].className) ||
|
|
1404
1410
|
// ... or if it's an empty string preceded by and followed by formatting markers, e.g. **|** where | is the cursor
|
|
1405
1411
|
|
|
1406
|
-
focus.col == anchor.col && !!this.lines[focus.row].substr(0, focus.col).match(commands[cmd].unset.prePattern) && !!this.lines[focus.row].substr(focus.col).match(commands[cmd].unset.postPattern);
|
|
1412
|
+
focus.col == anchor.col && !!this.lines[focus.row].substr(0, focus.col).match(_grammar.commands[cmd].unset.prePattern) && !!this.lines[focus.row].substr(focus.col).match(_grammar.commands[cmd].unset.postPattern);
|
|
1407
1413
|
}
|
|
1408
1414
|
}
|
|
1409
|
-
if (commands[cmd].type == 'line') {
|
|
1415
|
+
if (_grammar.commands[cmd].type == 'line') {
|
|
1410
1416
|
if (!focus) {
|
|
1411
1417
|
commandState[cmd] = null;
|
|
1412
1418
|
} else {
|
|
1413
|
-
let state = this.lineTypes[start.row] == commands[cmd].className;
|
|
1419
|
+
let state = this.lineTypes[start.row] == _grammar.commands[cmd].className;
|
|
1414
1420
|
for (let line = start.row; line <= end.row; line++) {
|
|
1415
|
-
if (this.lineTypes[line] == commands[cmd].className != state) {
|
|
1421
|
+
if (this.lineTypes[line] == _grammar.commands[cmd].className != state) {
|
|
1416
1422
|
state = null;
|
|
1417
1423
|
break;
|
|
1418
1424
|
}
|
|
@@ -1430,14 +1436,14 @@ class Editor {
|
|
|
1430
1436
|
* @param {boolean} state
|
|
1431
1437
|
*/
|
|
1432
1438
|
setCommandState(command, state) {
|
|
1433
|
-
if (commands[command].type == 'inline') {
|
|
1439
|
+
if (_grammar.commands[command].type == 'inline') {
|
|
1434
1440
|
let anchor = this.getSelection(true);
|
|
1435
1441
|
let focus = this.getSelection(false);
|
|
1436
1442
|
if (!anchor) anchor = focus;
|
|
1437
1443
|
if (!anchor) return;
|
|
1438
1444
|
if (anchor.row != focus.row) return;
|
|
1439
1445
|
if (!this.isInlineFormattingAllowed(focus, anchor)) return;
|
|
1440
|
-
let markupNode = this.computeEnclosingMarkupNode(focus, anchor, commands[command].className);
|
|
1446
|
+
let markupNode = this.computeEnclosingMarkupNode(focus, anchor, _grammar.commands[command].className);
|
|
1441
1447
|
this.clearDirtyFlag();
|
|
1442
1448
|
|
|
1443
1449
|
// First case: There's an enclosing markup node, remove the markers around that markup node
|
|
@@ -1445,9 +1451,9 @@ class Editor {
|
|
|
1445
1451
|
this.lineDirty[focus.row] = true;
|
|
1446
1452
|
const startCol = this.computeColumn(markupNode, 0);
|
|
1447
1453
|
const len = markupNode.textContent.length;
|
|
1448
|
-
const left = this.lines[focus.row].substr(0, startCol).replace(commands[command].unset.prePattern, '');
|
|
1454
|
+
const left = this.lines[focus.row].substr(0, startCol).replace(_grammar.commands[command].unset.prePattern, '');
|
|
1449
1455
|
const mid = this.lines[focus.row].substr(startCol, len);
|
|
1450
|
-
const right = this.lines[focus.row].substr(startCol + len).replace(commands[command].unset.postPattern, '');
|
|
1456
|
+
const right = this.lines[focus.row].substr(startCol + len).replace(_grammar.commands[command].unset.postPattern, '');
|
|
1451
1457
|
this.lines[focus.row] = left.concat(mid, right);
|
|
1452
1458
|
anchor.col = left.length;
|
|
1453
1459
|
focus.col = anchor.col + len;
|
|
@@ -1456,10 +1462,10 @@ class Editor {
|
|
|
1456
1462
|
this.fireChange();
|
|
1457
1463
|
|
|
1458
1464
|
// Second case: Empty selection with surrounding formatting markers, remove those
|
|
1459
|
-
} else if (focus.col == anchor.col && !!this.lines[focus.row].substr(0, focus.col).match(commands[command].unset.prePattern) && !!this.lines[focus.row].substr(focus.col).match(commands[command].unset.postPattern)) {
|
|
1465
|
+
} else if (focus.col == anchor.col && !!this.lines[focus.row].substr(0, focus.col).match(_grammar.commands[command].unset.prePattern) && !!this.lines[focus.row].substr(focus.col).match(_grammar.commands[command].unset.postPattern)) {
|
|
1460
1466
|
this.lineDirty[focus.row] = true;
|
|
1461
|
-
const left = this.lines[focus.row].substr(0, focus.col).replace(commands[command].unset.prePattern, '');
|
|
1462
|
-
const right = this.lines[focus.row].substr(focus.col).replace(commands[command].unset.postPattern, '');
|
|
1467
|
+
const left = this.lines[focus.row].substr(0, focus.col).replace(_grammar.commands[command].unset.prePattern, '');
|
|
1468
|
+
const right = this.lines[focus.row].substr(focus.col).replace(_grammar.commands[command].unset.postPattern, '');
|
|
1463
1469
|
this.lines[focus.row] = left.concat(right);
|
|
1464
1470
|
focus.col = anchor.col = left.length;
|
|
1465
1471
|
this.updateFormatting();
|
|
@@ -1488,11 +1494,11 @@ class Editor {
|
|
|
1488
1494
|
anchor.col = endCol;
|
|
1489
1495
|
|
|
1490
1496
|
// Just insert markup before and after and hope for the best.
|
|
1491
|
-
this.wrapSelection(commands[command].set.pre, commands[command].set.post, focus, anchor);
|
|
1497
|
+
this.wrapSelection(_grammar.commands[command].set.pre, _grammar.commands[command].set.post, focus, anchor);
|
|
1492
1498
|
this.fireChange();
|
|
1493
1499
|
// TODO clean this up so that markup remains properly nested
|
|
1494
1500
|
}
|
|
1495
|
-
} else if (commands[command].type == 'line') {
|
|
1501
|
+
} else if (_grammar.commands[command].type == 'line') {
|
|
1496
1502
|
let anchor = this.getSelection(true);
|
|
1497
1503
|
let focus = this.getSelection(false);
|
|
1498
1504
|
if (!anchor) anchor = focus;
|
|
@@ -1504,12 +1510,12 @@ class Editor {
|
|
|
1504
1510
|
end.row--;
|
|
1505
1511
|
}
|
|
1506
1512
|
for (let line = start.row; line <= end.row; line++) {
|
|
1507
|
-
if (state && this.lineTypes[line] != commands[command].className) {
|
|
1508
|
-
this.lines[line] = this.lines[line].replace(commands[command].set.pattern, commands[command].set.replacement.replace('$#', line - start.row + 1));
|
|
1513
|
+
if (state && this.lineTypes[line] != _grammar.commands[command].className) {
|
|
1514
|
+
this.lines[line] = this.lines[line].replace(_grammar.commands[command].set.pattern, _grammar.commands[command].set.replacement.replace('$#', line - start.row + 1));
|
|
1509
1515
|
this.lineDirty[line] = true;
|
|
1510
1516
|
}
|
|
1511
|
-
if (!state && this.lineTypes[line] == commands[command].className) {
|
|
1512
|
-
this.lines[line] = this.lines[line].replace(commands[command].unset.pattern, commands[command].unset.replacement);
|
|
1517
|
+
if (!state && this.lineTypes[line] == _grammar.commands[command].className) {
|
|
1518
|
+
this.lines[line] = this.lines[line].replace(_grammar.commands[command].unset.pattern, _grammar.commands[command].unset.replacement);
|
|
1513
1519
|
this.lineDirty[line] = true;
|
|
1514
1520
|
}
|
|
1515
1521
|
}
|
|
@@ -1532,7 +1538,7 @@ class Editor {
|
|
|
1532
1538
|
isInlineFormattingAllowed() {
|
|
1533
1539
|
// TODO Remove parameters from all calls
|
|
1534
1540
|
const sel = window.getSelection();
|
|
1535
|
-
if (!sel) return false;
|
|
1541
|
+
if (!sel || !sel.focusNode || !sel.anchorNode) return false;
|
|
1536
1542
|
|
|
1537
1543
|
// Check if we can find a common ancestor with the class `TMInlineFormatted`
|
|
1538
1544
|
|
|
@@ -1642,4 +1648,4 @@ class Editor {
|
|
|
1642
1648
|
}
|
|
1643
1649
|
}
|
|
1644
1650
|
}
|
|
1645
|
-
|
|
1651
|
+
var _default = exports.default = Editor;
|
package/lib/TinyMDECommandBar.js
CHANGED
|
@@ -1,63 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _svg = _interopRequireDefault(require("./svg/svg"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
const isMacLike = /(Mac|iPhone|iPod|iPad)/i.test(typeof navigator !== "undefined" ? navigator.platform : "");
|
|
3
10
|
const DefaultCommands = {
|
|
4
11
|
'bold': {
|
|
5
12
|
name: 'bold',
|
|
6
13
|
action: 'bold',
|
|
7
|
-
innerHTML:
|
|
14
|
+
innerHTML: _svg.default.bold,
|
|
8
15
|
title: 'Bold',
|
|
9
16
|
hotkey: 'Mod-B'
|
|
10
17
|
},
|
|
11
18
|
'italic': {
|
|
12
19
|
name: 'italic',
|
|
13
20
|
action: 'italic',
|
|
14
|
-
innerHTML:
|
|
21
|
+
innerHTML: _svg.default.italic,
|
|
15
22
|
title: 'Italic',
|
|
16
23
|
hotkey: 'Mod-I'
|
|
17
24
|
},
|
|
18
25
|
'strikethrough': {
|
|
19
26
|
name: 'strikethrough',
|
|
20
27
|
action: 'strikethrough',
|
|
21
|
-
innerHTML:
|
|
28
|
+
innerHTML: _svg.default.strikethrough,
|
|
22
29
|
title: 'Strikethrough',
|
|
23
30
|
hotkey: 'Mod2-Shift-5'
|
|
24
31
|
},
|
|
25
32
|
'code': {
|
|
26
33
|
name: 'code',
|
|
27
34
|
action: 'code',
|
|
28
|
-
innerHTML:
|
|
35
|
+
innerHTML: _svg.default.code,
|
|
29
36
|
title: 'Format as code'
|
|
30
37
|
},
|
|
31
38
|
'h1': {
|
|
32
39
|
name: 'h1',
|
|
33
40
|
action: 'h1',
|
|
34
|
-
innerHTML:
|
|
41
|
+
innerHTML: _svg.default.h1,
|
|
35
42
|
title: 'Level 1 heading',
|
|
36
43
|
hotkey: 'Mod-Shift-1'
|
|
37
44
|
},
|
|
38
45
|
'h2': {
|
|
39
46
|
name: 'h2',
|
|
40
47
|
action: 'h2',
|
|
41
|
-
innerHTML:
|
|
48
|
+
innerHTML: _svg.default.h2,
|
|
42
49
|
title: 'Level 2 heading',
|
|
43
50
|
hotkey: 'Mod-Shift-2'
|
|
44
51
|
},
|
|
45
52
|
'ul': {
|
|
46
53
|
name: 'ul',
|
|
47
54
|
action: 'ul',
|
|
48
|
-
innerHTML:
|
|
55
|
+
innerHTML: _svg.default.ul,
|
|
49
56
|
title: 'Bulleted list'
|
|
50
57
|
},
|
|
51
58
|
'ol': {
|
|
52
59
|
name: 'ol',
|
|
53
60
|
action: 'ol',
|
|
54
|
-
innerHTML:
|
|
61
|
+
innerHTML: _svg.default.ol,
|
|
55
62
|
title: 'Numbered list'
|
|
56
63
|
},
|
|
57
64
|
'blockquote': {
|
|
58
65
|
name: 'blockquote',
|
|
59
66
|
action: 'blockquote',
|
|
60
|
-
innerHTML:
|
|
67
|
+
innerHTML: _svg.default.blockquote,
|
|
61
68
|
title: 'Quote',
|
|
62
69
|
hotkey: 'Mod2-Shift-Q'
|
|
63
70
|
},
|
|
@@ -67,7 +74,7 @@ const DefaultCommands = {
|
|
|
67
74
|
if (editor.isInlineFormattingAllowed()) editor.wrapSelection('[', ']()');
|
|
68
75
|
},
|
|
69
76
|
enabled: (editor, focus, anchor) => editor.isInlineFormattingAllowed(focus, anchor) ? false : null,
|
|
70
|
-
innerHTML:
|
|
77
|
+
innerHTML: _svg.default.link,
|
|
71
78
|
title: 'Insert link',
|
|
72
79
|
hotkey: 'Mod-K'
|
|
73
80
|
},
|
|
@@ -77,7 +84,7 @@ const DefaultCommands = {
|
|
|
77
84
|
if (editor.isInlineFormattingAllowed()) editor.wrapSelection('![', ']()');
|
|
78
85
|
},
|
|
79
86
|
enabled: (editor, focus, anchor) => editor.isInlineFormattingAllowed(focus, anchor) ? false : null,
|
|
80
|
-
innerHTML:
|
|
87
|
+
innerHTML: _svg.default.image,
|
|
81
88
|
title: 'Insert image',
|
|
82
89
|
hotkey: 'Mod2-Shift-I'
|
|
83
90
|
},
|
|
@@ -85,7 +92,7 @@ const DefaultCommands = {
|
|
|
85
92
|
name: 'hr',
|
|
86
93
|
action: editor => editor.paste('\n***\n'),
|
|
87
94
|
enabled: () => false,
|
|
88
|
-
innerHTML:
|
|
95
|
+
innerHTML: _svg.default.hr,
|
|
89
96
|
title: 'Insert horizontal line',
|
|
90
97
|
hotkey: 'Mod2-Shift-L'
|
|
91
98
|
}
|
|
@@ -255,4 +262,4 @@ class CommandBar {
|
|
|
255
262
|
}
|
|
256
263
|
}
|
|
257
264
|
}
|
|
258
|
-
|
|
265
|
+
var _default = exports.default = CommandBar;
|
package/lib/grammar.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.htmlBlockGrammar = exports.commands = void 0;
|
|
7
|
+
exports.htmlescape = htmlescape;
|
|
8
|
+
exports.punctuationTrailing = exports.punctuationLeading = exports.lineGrammar = exports.inlineGrammar = void 0;
|
|
9
|
+
require("core-js/modules/es.regexp.flags.js");
|
|
2
10
|
// const replacements = {
|
|
3
11
|
// ASCIIPunctuation: '!"#$%&\'()*+,\\-./:;<=>?@\\[\\]^_`{|}~',
|
|
4
12
|
// TriggerChars: '`_\*\[\]\(\)',
|
|
@@ -25,15 +33,15 @@ const replacements = {
|
|
|
25
33
|
};
|
|
26
34
|
|
|
27
35
|
// From CommonMark.js.
|
|
28
|
-
const 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])/);
|
|
29
|
-
const 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])$/);
|
|
36
|
+
const punctuationLeading = 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])/);
|
|
37
|
+
const punctuationTrailing = 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])$/);
|
|
30
38
|
|
|
31
39
|
// export const inlineTriggerChars = new RegExp(`[${replacements.TriggerChars}]`);
|
|
32
40
|
|
|
33
41
|
/**
|
|
34
42
|
* This is CommonMark's block grammar, but we're ignoring nested blocks here.
|
|
35
43
|
*/
|
|
36
|
-
const lineGrammar = {
|
|
44
|
+
const lineGrammar = exports.lineGrammar = {
|
|
37
45
|
TMH1: {
|
|
38
46
|
regexp: /^( {0,3}#\s)(.*?)((?:\s+#+\s*)?)$/,
|
|
39
47
|
replacement: '<span class="TMMark TMMark_TMH1">$1</span>$$2<span class="TMMark TMMark_TMH1">$3</span>'
|
|
@@ -118,7 +126,7 @@ const lineGrammar = {
|
|
|
118
126
|
/**
|
|
119
127
|
* HTML blocks have multiple different classes of opener and closer. This array defines all the cases
|
|
120
128
|
*/
|
|
121
|
-
var htmlBlockGrammar = [{
|
|
129
|
+
var htmlBlockGrammar = exports.htmlBlockGrammar = [{
|
|
122
130
|
start: /^ {0,3}<(?:script|pre|style)(?:\s|>|$)/i,
|
|
123
131
|
end: /(?:<\/script>|<\/pre>|<\/style>)/i,
|
|
124
132
|
paraInterrupt: true
|
|
@@ -153,7 +161,7 @@ var htmlBlockGrammar = [{
|
|
|
153
161
|
* Top level entries are rules, each consisting of a regular expressions (in string format) as well as a replacement.
|
|
154
162
|
* In the regular expressions, replacements from the object 'replacements' will be processed before compiling into the property regexp.
|
|
155
163
|
*/
|
|
156
|
-
var inlineGrammar = {
|
|
164
|
+
var inlineGrammar = exports.inlineGrammar = {
|
|
157
165
|
escape: {
|
|
158
166
|
regexp: /^\\(ASCIIPunctuation)/,
|
|
159
167
|
replacement: '<span class="TMMark TMMark_TMEscape">\\</span>$1'
|
|
@@ -237,7 +245,7 @@ function htmlescape(string) {
|
|
|
237
245
|
* be inserted before and after the selection. The unset object contains a prePattern and a postPattern. Both should be regular expressions and
|
|
238
246
|
* they will be applied to the portion of the line before and after the selection (using String.replace, with an empty replacement string).
|
|
239
247
|
*/
|
|
240
|
-
const commands = {
|
|
248
|
+
const commands = exports.commands = {
|
|
241
249
|
// Replacements for unset for inline commands are '' by default
|
|
242
250
|
bold: {
|
|
243
251
|
type: 'inline',
|
|
@@ -396,5 +404,4 @@ const commands = {
|
|
|
396
404
|
replacement: '$2'
|
|
397
405
|
}
|
|
398
406
|
}
|
|
399
|
-
};
|
|
400
|
-
export { lineGrammar, inlineGrammar, punctuationLeading, punctuationTrailing, htmlescape, htmlBlockGrammar, commands };
|
|
407
|
+
};
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "CommandBar", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _TinyMDECommandBar.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "Editor", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _TinyMDE.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _TinyMDECommandBar = _interopRequireDefault(require("./TinyMDECommandBar"));
|
|
19
|
+
var _TinyMDE = _interopRequireDefault(require("./TinyMDE"));
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/lib/svg/svg.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
1
7
|
const svg = {
|
|
2
8
|
blockquote: `<svg height="18" width="18"><rect width="5" height="5" x="3" y="4" ry="1"/><rect ry="1" y="4" x="10" height="5" width="5"/><path d="M8 6.999v3c0 1-1 3-1 3s-.331 1-1.331 1h-1c-1 0-.669-1-.669-1s1-2 1-3v-3zm7 0v3c0 1-1 3-1 3s-.331 1-1.331 1h-1c-1 0-.669-1-.669-1s1-2 1-3v-3z"/></svg>`,
|
|
3
9
|
bold: `<svg height="18" width="18"><path d="M4 2a1 1 0 00-1 1v12a1 1 0 001 1h6c4 0 5-2 5-4 0-1.322-.434-2.636-1.885-3.381C13.772 7.885 14 6.945 14 6c0-2-1-4-5-4zm1 2h4c1.668 0 2.32.393 2.6.672.28.279.4.662.4 1.328s-.12 1.057-.4 1.338c-.275.274-1.014.646-2.6.662H5zm5 6c1.666.005 2.318.388 2.596.666.277.278.404.667.404 1.334s-.127 1.06-.404 1.338c-.278.278-.93.66-2.596.662l-4.992.004L5 10z"/></svg>`,
|
|
@@ -13,4 +19,4 @@ const svg = {
|
|
|
13
19
|
strikethrough: `<svg width="18" height="18"><path d="M10 2C6 2 4 4 4 6c0 .338.08.672.193 1h2.34C6.113 6.629 6 6.295 6 6c0-.334.117-.725.691-1.154C7.265 4.416 8.331 4 10 4h3a1 1 0 000-2zm1.477 9c.413.368.523.706.523 1 0 .334-.127.712-.701 1.143-.575.43-1.632.85-3.299.857l-1.006.007V14H5a1 1 0 000 2h3c4 0 6-2 6-4 0-.338-.081-.672-.195-1z"/><rect ry="1" y="8" x="1" height="2" width="16"/></svg>`,
|
|
14
20
|
ul: `<svg height="18" width="18"><circle cx="2" cy="9" r="2"/><circle cy="4" cx="2" r="2"/><rect y="3" x="6" height="2" width="12" ry="1"/><circle cx="2" cy="14" r="2"/><rect ry="1" width="12" height="2" x="6" y="8"/><rect y="13" x="6" height="2" width="12" ry="1"/></svg>`
|
|
15
21
|
};
|
|
16
|
-
|
|
22
|
+
var _default = exports.default = svg;
|
package/lib/tiny.js
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Editor", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _TinyMDE.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _TinyMDE = _interopRequireDefault(require("./TinyMDE"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiny-markdown-editor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "TinyMDE: A tiny, ultra low dependency, embeddable HTML/JavaScript Markdown editor.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@babel/core": "^7.11.6",
|
|
42
|
+
"@babel/plugin-transform-modules-commonjs": "^7.23.3",
|
|
42
43
|
"@babel/preset-env": "^7.22.20",
|
|
43
44
|
"@octokit/rest": "^20.0.2",
|
|
44
45
|
"@rollup/plugin-babel": "^6.0.2",
|