tiny-markdown-editor 0.1.5 → 0.1.8
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 +2 -2
- package/dist/tiny-mde.js +2041 -4500
- package/dist/tiny-mde.min.js +1 -1
- package/dist/tiny-mde.tiny.js +1 -1
- package/lib/TinyMDE.js +1405 -1591
- package/lib/TinyMDECommandBar.js +144 -226
- package/lib/grammar.js +27 -82
- package/lib/index.js +2 -3
- package/lib/svg/svg.js +15 -17
- package/lib/tiny.js +1 -2
- package/package.json +7 -3
package/lib/TinyMDECommandBar.js
CHANGED
|
@@ -1,34 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.object.define-property.js");
|
|
4
|
-
require("core-js/modules/es.array.slice.js");
|
|
5
|
-
require("core-js/modules/es.object.to-string.js");
|
|
6
|
-
require("core-js/modules/es.array.from.js");
|
|
7
|
-
require("core-js/modules/es.string.iterator.js");
|
|
8
|
-
require("core-js/modules/es.symbol.js");
|
|
9
|
-
require("core-js/modules/es.symbol.description.js");
|
|
10
|
-
require("core-js/modules/es.symbol.iterator.js");
|
|
11
|
-
require("core-js/modules/es.array.iterator.js");
|
|
12
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
13
3
|
Object.defineProperty(exports, "__esModule", {
|
|
14
4
|
value: true
|
|
15
5
|
});
|
|
16
6
|
exports.default = void 0;
|
|
17
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
18
|
-
require("core-js/modules/es.object.assign.js");
|
|
19
|
-
require("core-js/modules/es.string.match.js");
|
|
20
|
-
require("core-js/modules/es.array.concat.js");
|
|
21
7
|
var _svg = _interopRequireDefault(require("./svg/svg"));
|
|
22
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
26
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
27
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
28
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
29
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
30
|
-
var isMacLike = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
|
|
31
|
-
var DefaultCommands = {
|
|
9
|
+
const isMacLike = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
|
|
10
|
+
const DefaultCommands = {
|
|
32
11
|
'bold': {
|
|
33
12
|
name: 'bold',
|
|
34
13
|
action: 'bold',
|
|
@@ -91,52 +70,42 @@ var DefaultCommands = {
|
|
|
91
70
|
},
|
|
92
71
|
'insertLink': {
|
|
93
72
|
name: 'insertLink',
|
|
94
|
-
action:
|
|
73
|
+
action: editor => {
|
|
95
74
|
if (editor.isInlineFormattingAllowed()) editor.wrapSelection('[', ']()');
|
|
96
75
|
},
|
|
97
|
-
enabled:
|
|
98
|
-
return editor.isInlineFormattingAllowed(focus, anchor) ? false : null;
|
|
99
|
-
},
|
|
76
|
+
enabled: (editor, focus, anchor) => editor.isInlineFormattingAllowed(focus, anchor) ? false : null,
|
|
100
77
|
innerHTML: _svg.default.link,
|
|
101
78
|
title: 'Insert link',
|
|
102
79
|
hotkey: 'Mod-K'
|
|
103
80
|
},
|
|
104
81
|
'insertImage': {
|
|
105
82
|
name: 'insertImage',
|
|
106
|
-
action:
|
|
83
|
+
action: editor => {
|
|
107
84
|
if (editor.isInlineFormattingAllowed()) editor.wrapSelection('![', ']()');
|
|
108
85
|
},
|
|
109
|
-
enabled:
|
|
110
|
-
return editor.isInlineFormattingAllowed(focus, anchor) ? false : null;
|
|
111
|
-
},
|
|
86
|
+
enabled: (editor, focus, anchor) => editor.isInlineFormattingAllowed(focus, anchor) ? false : null,
|
|
112
87
|
innerHTML: _svg.default.image,
|
|
113
88
|
title: 'Insert image',
|
|
114
89
|
hotkey: 'Mod2-Shift-I'
|
|
115
90
|
},
|
|
116
91
|
'hr': {
|
|
117
92
|
name: 'hr',
|
|
118
|
-
action:
|
|
119
|
-
|
|
120
|
-
},
|
|
121
|
-
enabled: function enabled() {
|
|
122
|
-
return false;
|
|
123
|
-
},
|
|
93
|
+
action: editor => editor.paste('\n***\n'),
|
|
94
|
+
enabled: () => false,
|
|
124
95
|
innerHTML: _svg.default.hr,
|
|
125
96
|
title: 'Insert horizontal line',
|
|
126
97
|
hotkey: 'Mod2-Shift-L'
|
|
127
98
|
}
|
|
128
99
|
};
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
var _this = this;
|
|
132
|
-
_classCallCheck(this, CommandBar);
|
|
100
|
+
class CommandBar {
|
|
101
|
+
constructor(props) {
|
|
133
102
|
this.e = null;
|
|
134
103
|
this.editor = null;
|
|
135
104
|
this.commands = [];
|
|
136
105
|
this.buttons = {};
|
|
137
106
|
this.state = {};
|
|
138
107
|
this.hotkeys = [];
|
|
139
|
-
|
|
108
|
+
let element = props.element;
|
|
140
109
|
if (element && !element.tagName) {
|
|
141
110
|
element = document.getElementById(props.element);
|
|
142
111
|
}
|
|
@@ -144,204 +113,153 @@ var CommandBar = /*#__PURE__*/function () {
|
|
|
144
113
|
element = document.body;
|
|
145
114
|
}
|
|
146
115
|
this.createCommandBarElement(element, props.commands || ['bold', 'italic', 'strikethrough', '|', 'code', '|', 'h1', 'h2', '|', 'ul', 'ol', '|', 'blockquote', 'hr', '|', 'insertLink', 'insertImage']);
|
|
147
|
-
document.addEventListener('keydown',
|
|
148
|
-
return _this.handleKeydown(e);
|
|
149
|
-
});
|
|
116
|
+
document.addEventListener('keydown', e => this.handleKeydown(e));
|
|
150
117
|
if (props.editor) this.setEditor(props.editor);
|
|
151
118
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
var el = document.createElement('div');
|
|
165
|
-
el.className = 'TMCommandDivider';
|
|
166
|
-
this.e.appendChild(el);
|
|
167
|
-
} else {
|
|
168
|
-
var _ret = function () {
|
|
169
|
-
var commandName = void 0;
|
|
170
|
-
if (typeof command == "string") {
|
|
171
|
-
// Reference to default command
|
|
119
|
+
createCommandBarElement(parentElement, commands) {
|
|
120
|
+
this.e = document.createElement('div');
|
|
121
|
+
this.e.className = 'TMCommandBar';
|
|
122
|
+
for (let command of commands) {
|
|
123
|
+
if (command == '|') {
|
|
124
|
+
let el = document.createElement('div');
|
|
125
|
+
el.className = 'TMCommandDivider';
|
|
126
|
+
this.e.appendChild(el);
|
|
127
|
+
} else {
|
|
128
|
+
let commandName;
|
|
129
|
+
if (typeof command == "string") {
|
|
130
|
+
// Reference to default command
|
|
172
131
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
132
|
+
if (DefaultCommands[command]) {
|
|
133
|
+
commandName = command;
|
|
134
|
+
this.commands[commandName] = DefaultCommands[commandName];
|
|
135
|
+
} else {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
} else if (typeof command == "object" && command.name) {
|
|
139
|
+
commandName = command.name;
|
|
140
|
+
this.commands[commandName] = {};
|
|
141
|
+
if (DefaultCommands[commandName]) Object.assign(this.commands[commandName], DefaultCommands[commandName]);
|
|
142
|
+
Object.assign(this.commands[commandName], command);
|
|
143
|
+
} else {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
let title = this.commands[commandName].title || commandName;
|
|
147
|
+
if (this.commands[commandName].hotkey) {
|
|
148
|
+
const keys = this.commands[commandName].hotkey.split('-');
|
|
149
|
+
// construct modifiers
|
|
150
|
+
let modifiers = [];
|
|
151
|
+
let modifierexplanation = [];
|
|
152
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
153
|
+
switch (keys[i]) {
|
|
154
|
+
case 'Ctrl':
|
|
155
|
+
modifiers.push('ctrlKey');
|
|
156
|
+
modifierexplanation.push('Ctrl');
|
|
157
|
+
break;
|
|
158
|
+
case 'Cmd':
|
|
159
|
+
modifiers.push('metaKey');
|
|
160
|
+
modifierexplanation.push('⌘');
|
|
161
|
+
break;
|
|
162
|
+
case 'Alt':
|
|
163
|
+
modifiers.push('altKey');
|
|
164
|
+
modifierexplanation.push('Alt');
|
|
165
|
+
break;
|
|
166
|
+
case 'Option':
|
|
167
|
+
modifiers.push('altKey');
|
|
168
|
+
modifierexplanation.push('⌥');
|
|
169
|
+
break;
|
|
170
|
+
case 'Win':
|
|
171
|
+
modifiers.push('metaKey');
|
|
172
|
+
modifierexplanation.push('⊞ Win');
|
|
173
|
+
break;
|
|
174
|
+
case 'Shift':
|
|
175
|
+
modifiers.push('shiftKey');
|
|
176
|
+
modifierexplanation.push('⇧');
|
|
177
|
+
break;
|
|
178
|
+
case 'Mod':
|
|
179
|
+
// Mod is a convenience mechanism: Ctrl on Windows, Cmd on Mac
|
|
180
|
+
if (isMacLike) {
|
|
181
|
+
modifiers.push('metaKey');
|
|
182
|
+
modifierexplanation.push('⌘');
|
|
176
183
|
} else {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
} else if (_typeof(command) == "object" && command.name) {
|
|
180
|
-
commandName = command.name;
|
|
181
|
-
_this2.commands[commandName] = {};
|
|
182
|
-
if (DefaultCommands[commandName]) Object.assign(_this2.commands[commandName], DefaultCommands[commandName]);
|
|
183
|
-
Object.assign(_this2.commands[commandName], command);
|
|
184
|
-
} else {
|
|
185
|
-
return "continue";
|
|
186
|
-
}
|
|
187
|
-
var title = _this2.commands[commandName].title || commandName;
|
|
188
|
-
if (_this2.commands[commandName].hotkey) {
|
|
189
|
-
var keys = _this2.commands[commandName].hotkey.split('-');
|
|
190
|
-
// construct modifiers
|
|
191
|
-
var modifiers = [];
|
|
192
|
-
var modifierexplanation = [];
|
|
193
|
-
for (var i = 0; i < keys.length - 1; i++) {
|
|
194
|
-
switch (keys[i]) {
|
|
195
|
-
case 'Ctrl':
|
|
196
|
-
modifiers.push('ctrlKey');
|
|
197
|
-
modifierexplanation.push('Ctrl');
|
|
198
|
-
break;
|
|
199
|
-
case 'Cmd':
|
|
200
|
-
modifiers.push('metaKey');
|
|
201
|
-
modifierexplanation.push('⌘');
|
|
202
|
-
break;
|
|
203
|
-
case 'Alt':
|
|
204
|
-
modifiers.push('altKey');
|
|
205
|
-
modifierexplanation.push('Alt');
|
|
206
|
-
break;
|
|
207
|
-
case 'Option':
|
|
208
|
-
modifiers.push('altKey');
|
|
209
|
-
modifierexplanation.push('⌥');
|
|
210
|
-
break;
|
|
211
|
-
case 'Win':
|
|
212
|
-
modifiers.push('metaKey');
|
|
213
|
-
modifierexplanation.push('⊞ Win');
|
|
214
|
-
break;
|
|
215
|
-
case 'Shift':
|
|
216
|
-
modifiers.push('shiftKey');
|
|
217
|
-
modifierexplanation.push('⇧');
|
|
218
|
-
break;
|
|
219
|
-
case 'Mod':
|
|
220
|
-
// Mod is a convenience mechanism: Ctrl on Windows, Cmd on Mac
|
|
221
|
-
if (isMacLike) {
|
|
222
|
-
modifiers.push('metaKey');
|
|
223
|
-
modifierexplanation.push('⌘');
|
|
224
|
-
} else {
|
|
225
|
-
modifiers.push('ctrlKey');
|
|
226
|
-
modifierexplanation.push('Ctrl');
|
|
227
|
-
}
|
|
228
|
-
break;
|
|
229
|
-
case 'Mod2':
|
|
230
|
-
modifiers.push('altKey');
|
|
231
|
-
if (isMacLike) modifierexplanation.push('⌥');else modifierexplanation.push('Alt');
|
|
232
|
-
break;
|
|
233
|
-
// Mod2 is a convenience mechanism: Alt on Windows, Option on Mac
|
|
234
|
-
}
|
|
184
|
+
modifiers.push('ctrlKey');
|
|
185
|
+
modifierexplanation.push('Ctrl');
|
|
235
186
|
}
|
|
187
|
+
break;
|
|
188
|
+
case 'Mod2':
|
|
189
|
+
modifiers.push('altKey');
|
|
190
|
+
if (isMacLike) modifierexplanation.push('⌥');else modifierexplanation.push('Alt');
|
|
191
|
+
break;
|
|
192
|
+
// Mod2 is a convenience mechanism: Alt on Windows, Option on Mac
|
|
193
|
+
}
|
|
194
|
+
}
|
|
236
195
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
_this2.hotkeys.push(hotkey);
|
|
249
|
-
title = title.concat(" (".concat(modifierexplanation.join('+'), ")"));
|
|
250
|
-
}
|
|
251
|
-
_this2.buttons[commandName] = document.createElement('div');
|
|
252
|
-
_this2.buttons[commandName].className = 'TMCommandButton TMCommandButton_Disabled';
|
|
253
|
-
_this2.buttons[commandName].title = title;
|
|
254
|
-
_this2.buttons[commandName].innerHTML = _this2.commands[commandName].innerHTML;
|
|
255
|
-
_this2.buttons[commandName].addEventListener('mousedown', function (e) {
|
|
256
|
-
return _this2.handleClick(commandName, e);
|
|
257
|
-
});
|
|
258
|
-
_this2.e.appendChild(_this2.buttons[commandName]);
|
|
259
|
-
}();
|
|
260
|
-
if (_ret === "continue") continue;
|
|
196
|
+
modifierexplanation.push(keys[keys.length - 1]);
|
|
197
|
+
let hotkey = {
|
|
198
|
+
modifiers: modifiers,
|
|
199
|
+
command: commandName
|
|
200
|
+
};
|
|
201
|
+
// TODO Right now this is working only for letters and numbers
|
|
202
|
+
if (keys[keys.length - 1].match(/^[0-9]$/)) {
|
|
203
|
+
hotkey.code = `Digit${keys[keys.length - 1]}`;
|
|
204
|
+
} else {
|
|
205
|
+
hotkey.key = keys[keys.length - 1].toLowerCase();
|
|
261
206
|
}
|
|
207
|
+
this.hotkeys.push(hotkey);
|
|
208
|
+
title = title.concat(` (${modifierexplanation.join('+')})`);
|
|
262
209
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
210
|
+
this.buttons[commandName] = document.createElement('div');
|
|
211
|
+
this.buttons[commandName].className = 'TMCommandButton TMCommandButton_Disabled';
|
|
212
|
+
this.buttons[commandName].title = title;
|
|
213
|
+
this.buttons[commandName].innerHTML = this.commands[commandName].innerHTML;
|
|
214
|
+
this.buttons[commandName].addEventListener('mousedown', e => this.handleClick(commandName, e));
|
|
215
|
+
this.e.appendChild(this.buttons[commandName]);
|
|
267
216
|
}
|
|
268
|
-
parentElement.appendChild(this.e);
|
|
269
217
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}, {
|
|
282
|
-
key: "setEditor",
|
|
283
|
-
value: function setEditor(editor) {
|
|
284
|
-
var _this3 = this;
|
|
285
|
-
this.editor = editor;
|
|
286
|
-
editor.addEventListener('selection', function (e) {
|
|
287
|
-
return _this3.handleSelection(e);
|
|
288
|
-
});
|
|
218
|
+
parentElement.appendChild(this.e);
|
|
219
|
+
}
|
|
220
|
+
handleClick(commandName, event) {
|
|
221
|
+
if (!this.editor) return;
|
|
222
|
+
event.preventDefault();
|
|
223
|
+
if (typeof this.commands[commandName].action == "string") {
|
|
224
|
+
if (this.state[commandName] === false) this.editor.setCommandState(commandName, true);else this.editor.setCommandState(commandName, false);
|
|
225
|
+
} else if (typeof this.commands[commandName].action == "function") {
|
|
226
|
+
this.commands[commandName].action(this.editor);
|
|
289
227
|
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
228
|
+
}
|
|
229
|
+
setEditor(editor) {
|
|
230
|
+
this.editor = editor;
|
|
231
|
+
editor.addEventListener('selection', e => this.handleSelection(e));
|
|
232
|
+
}
|
|
233
|
+
handleSelection(event) {
|
|
234
|
+
if (event.commandState) {
|
|
235
|
+
for (let command in this.commands) {
|
|
236
|
+
if (event.commandState[command] === undefined) {
|
|
237
|
+
if (this.commands[command].enabled) this.state[command] = this.commands[command].enabled(this.editor, event.focus, event.anchor);else this.state[command] = event.focus ? false : null;
|
|
238
|
+
} else {
|
|
239
|
+
this.state[command] = event.commandState[command];
|
|
240
|
+
}
|
|
241
|
+
if (this.state[command] === true) {
|
|
242
|
+
this.buttons[command].className = 'TMCommandButton TMCommandButton_Active';
|
|
243
|
+
} else if (this.state[command] === false) {
|
|
244
|
+
this.buttons[command].className = 'TMCommandButton TMCommandButton_Inactive';
|
|
245
|
+
} else {
|
|
246
|
+
this.buttons[command].className = 'TMCommandButton TMCommandButton_Disabled';
|
|
307
247
|
}
|
|
308
248
|
}
|
|
309
249
|
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
var hotkey = _step2.value;
|
|
318
|
-
if (hotkey.key && event.key.toLowerCase() == hotkey.key || hotkey.code && event.code == hotkey.code) {
|
|
319
|
-
// Key matches hotkey. Look for any required modifier that wasn't pressed
|
|
320
|
-
var _iterator3 = _createForOfIteratorHelper(hotkey.modifiers),
|
|
321
|
-
_step3;
|
|
322
|
-
try {
|
|
323
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
324
|
-
var modifier = _step3.value;
|
|
325
|
-
if (!event[modifier]) continue outer;
|
|
326
|
-
}
|
|
327
|
-
// Everything matches.
|
|
328
|
-
} catch (err) {
|
|
329
|
-
_iterator3.e(err);
|
|
330
|
-
} finally {
|
|
331
|
-
_iterator3.f();
|
|
332
|
-
}
|
|
333
|
-
this.handleClick(hotkey.command, event);
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
250
|
+
}
|
|
251
|
+
handleKeydown(event) {
|
|
252
|
+
outer: for (let hotkey of this.hotkeys) {
|
|
253
|
+
if (hotkey.key && event.key.toLowerCase() == hotkey.key || hotkey.code && event.code == hotkey.code) {
|
|
254
|
+
// Key matches hotkey. Look for any required modifier that wasn't pressed
|
|
255
|
+
for (let modifier of hotkey.modifiers) {
|
|
256
|
+
if (!event[modifier]) continue outer;
|
|
336
257
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
_iterator2.f();
|
|
258
|
+
// Everything matches.
|
|
259
|
+
this.handleClick(hotkey.command, event);
|
|
260
|
+
return;
|
|
341
261
|
}
|
|
342
262
|
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
var _default = CommandBar;
|
|
347
|
-
exports.default = _default;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
var _default = exports.default = CommandBar;
|
package/lib/grammar.js
CHANGED
|
@@ -1,43 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
require("core-js/modules/es.object.set-prototype-of.js");
|
|
5
|
-
require("core-js/modules/es.object.define-property.js");
|
|
6
|
-
require("core-js/modules/es.array.iterator.js");
|
|
7
|
-
require("core-js/modules/es.object.to-string.js");
|
|
8
|
-
require("core-js/modules/es.string.iterator.js");
|
|
9
|
-
require("core-js/modules/es.weak-map.js");
|
|
10
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
11
|
-
require("core-js/modules/es.array.reduce.js");
|
|
12
|
-
require("core-js/modules/es.symbol.replace.js");
|
|
13
|
-
require("core-js/modules/es.symbol.js");
|
|
14
|
-
require("core-js/modules/es.symbol.description.js");
|
|
15
|
-
require("core-js/modules/es.array.slice.js");
|
|
16
|
-
require("core-js/modules/es.symbol.iterator.js");
|
|
17
|
-
require("core-js/modules/es.array.from.js");
|
|
18
3
|
Object.defineProperty(exports, "__esModule", {
|
|
19
4
|
value: true
|
|
20
5
|
});
|
|
21
6
|
exports.htmlBlockGrammar = exports.commands = void 0;
|
|
22
7
|
exports.htmlescape = htmlescape;
|
|
23
8
|
exports.punctuationTrailing = exports.punctuationLeading = exports.lineGrammar = exports.inlineGrammar = void 0;
|
|
24
|
-
require("core-js/modules/es.regexp.constructor.js");
|
|
25
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
26
|
-
require("core-js/modules/es.regexp.to-string.js");
|
|
27
|
-
require("core-js/modules/es.object.keys.js");
|
|
28
|
-
require("core-js/modules/es.string.match.js");
|
|
29
|
-
require("core-js/modules/es.string.replace.js");
|
|
30
9
|
require("core-js/modules/es.regexp.flags.js");
|
|
31
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
32
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
33
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
34
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
35
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
36
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
37
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
38
|
-
function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re, void 0, groups); }; var _super = RegExp.prototype, _groups = new WeakMap(); function BabelRegExp(re, flags, groups) { var _this = new RegExp(re, flags); return _groups.set(_this, groups || _groups.get(re)), _setPrototypeOf(_this, BabelRegExp.prototype); } function buildGroups(result, re) { var g = _groups.get(re); return Object.keys(g).reduce(function (groups, name) { var i = g[name]; if ("number" == typeof i) groups[name] = result[i];else { for (var k = 0; void 0 === result[i[k]] && k + 1 < i.length;) { k++; } groups[name] = result[i[k]]; } return groups; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (str) { var result = _super.exec.call(this, str); if (result) { result.groups = buildGroups(result, this); var indices = result.indices; indices && (indices.groups = buildGroups(indices, this)); } return result; }, BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { if ("string" == typeof substitution) { var groups = _groups.get(this); return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { var group = groups[name]; return "$" + (Array.isArray(group) ? group.join("$") : group); })); } if ("function" == typeof substitution) { var _this = this; return _super[Symbol.replace].call(this, str, function () { var args = arguments; return "object" != _typeof(args[args.length - 1]) && (args = [].slice.call(args)).push(buildGroups(args, _this)), substitution.apply(this, args); }); } return _super[Symbol.replace].call(this, str, substitution); }, _wrapRegExp.apply(this, arguments); }
|
|
39
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
40
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
41
10
|
// const replacements = {
|
|
42
11
|
// ASCIIPunctuation: '!"#$%&\'()*+,\\-./:;<=>?@\\[\\]^_`{|}~',
|
|
43
12
|
// TriggerChars: '`_\*\[\]\(\)',
|
|
@@ -45,7 +14,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Objec
|
|
|
45
14
|
// 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
|
|
46
15
|
|
|
47
16
|
// }
|
|
48
|
-
|
|
17
|
+
const replacements = {
|
|
49
18
|
ASCIIPunctuation: /[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~\\]/,
|
|
50
19
|
NotTriggerChar: /[^`_*[\]()<>!~]/,
|
|
51
20
|
Scheme: /[A-Za-z][A-Za-z0-9+.-]{1,31}/,
|
|
@@ -64,17 +33,15 @@ var replacements = {
|
|
|
64
33
|
};
|
|
65
34
|
|
|
66
35
|
// From CommonMark.js.
|
|
67
|
-
|
|
68
|
-
exports.
|
|
69
|
-
var 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])$/);
|
|
70
38
|
|
|
71
39
|
// export const inlineTriggerChars = new RegExp(`[${replacements.TriggerChars}]`);
|
|
72
40
|
|
|
73
41
|
/**
|
|
74
42
|
* This is CommonMark's block grammar, but we're ignoring nested blocks here.
|
|
75
43
|
*/
|
|
76
|
-
exports.
|
|
77
|
-
var lineGrammar = {
|
|
44
|
+
const lineGrammar = exports.lineGrammar = {
|
|
78
45
|
TMH1: {
|
|
79
46
|
regexp: /^( {0,3}#\s)(.*?)((?:\s+#+\s*)?)$/,
|
|
80
47
|
replacement: '<span class="TMMark TMMark_TMH1">$1</span>$$2<span class="TMMark TMMark_TMH1">$3</span>'
|
|
@@ -104,27 +71,19 @@ var lineGrammar = {
|
|
|
104
71
|
replacement: '<span class="TMMark TMMark_TMBlockquote">$1</span>$$2'
|
|
105
72
|
},
|
|
106
73
|
TMCodeFenceBacktickOpen: {
|
|
107
|
-
regexp:
|
|
108
|
-
seq: 2
|
|
109
|
-
}),
|
|
74
|
+
regexp: /^( {0,3}(?<seq>````*)\s*)([^`]*?)(\s*)$/,
|
|
110
75
|
replacement: '<span class="TMMark TMMark_TMCodeFenceBacktick">$1</span><span class="TMInfoString">$3</span>$4'
|
|
111
76
|
},
|
|
112
77
|
TMCodeFenceTildeOpen: {
|
|
113
|
-
regexp:
|
|
114
|
-
seq: 2
|
|
115
|
-
}),
|
|
78
|
+
regexp: /^( {0,3}(?<seq>~~~~*)\s*)(.*?)(\s*)$/,
|
|
116
79
|
replacement: '<span class="TMMark TMMark_TMCodeFenceTilde">$1</span><span class="TMInfoString">$3</span>$4'
|
|
117
80
|
},
|
|
118
81
|
TMCodeFenceBacktickClose: {
|
|
119
|
-
regexp:
|
|
120
|
-
seq: 2
|
|
121
|
-
}),
|
|
82
|
+
regexp: /^( {0,3}(?<seq>````*))(\s*)$/,
|
|
122
83
|
replacement: '<span class="TMMark TMMark_TMCodeFenceBacktick">$1</span>$3'
|
|
123
84
|
},
|
|
124
85
|
TMCodeFenceTildeClose: {
|
|
125
|
-
regexp:
|
|
126
|
-
seq: 2
|
|
127
|
-
}),
|
|
86
|
+
regexp: /^( {0,3}(?<seq>~~~~*))(\s*)$/,
|
|
128
87
|
replacement: '<span class="TMMark TMMark_TMCodeFenceTilde">$1</span>$3'
|
|
129
88
|
},
|
|
130
89
|
TMBlankLine: {
|
|
@@ -167,8 +126,7 @@ var lineGrammar = {
|
|
|
167
126
|
/**
|
|
168
127
|
* HTML blocks have multiple different classes of opener and closer. This array defines all the cases
|
|
169
128
|
*/
|
|
170
|
-
exports.
|
|
171
|
-
var htmlBlockGrammar = [{
|
|
129
|
+
var htmlBlockGrammar = exports.htmlBlockGrammar = [{
|
|
172
130
|
start: /^ {0,3}<(?:script|pre|style)(?:\s|>|$)/i,
|
|
173
131
|
end: /(?:<\/script>|<\/pre>|<\/style>)/i,
|
|
174
132
|
paraInterrupt: true
|
|
@@ -203,8 +161,7 @@ var htmlBlockGrammar = [{
|
|
|
203
161
|
* Top level entries are rules, each consisting of a regular expressions (in string format) as well as a replacement.
|
|
204
162
|
* In the regular expressions, replacements from the object 'replacements' will be processed before compiling into the property regexp.
|
|
205
163
|
*/
|
|
206
|
-
exports.
|
|
207
|
-
var inlineGrammar = {
|
|
164
|
+
var inlineGrammar = exports.inlineGrammar = {
|
|
208
165
|
escape: {
|
|
209
166
|
regexp: /^\\(ASCIIPunctuation)/,
|
|
210
167
|
replacement: '<span class="TMMark TMMark_TMEscape">\\</span>$1'
|
|
@@ -241,38 +198,27 @@ var inlineGrammar = {
|
|
|
241
198
|
};
|
|
242
199
|
|
|
243
200
|
// Process replacements in regexps
|
|
244
|
-
|
|
245
|
-
var replacementRegexp = new RegExp(Object.keys(replacements).join('|'));
|
|
201
|
+
const replacementRegexp = new RegExp(Object.keys(replacements).join('|'));
|
|
246
202
|
|
|
247
203
|
// Inline
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
while (_re.match(replacementRegexp)) {
|
|
257
|
-
_re = _re.replace(replacementRegexp, function (string) {
|
|
258
|
-
return replacements[string].source;
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
inlineGrammar[_rule].regexp = new RegExp(_re, inlineGrammar[_rule].regexp.flags);
|
|
204
|
+
const inlineRules = [...Object.keys(inlineGrammar)];
|
|
205
|
+
for (let rule of inlineRules) {
|
|
206
|
+
let re = inlineGrammar[rule].regexp.source;
|
|
207
|
+
// Replace while there is something to replace. This means it also works over multiple levels (replacements containing replacements)
|
|
208
|
+
while (re.match(replacementRegexp)) {
|
|
209
|
+
re = re.replace(replacementRegexp, string => {
|
|
210
|
+
return replacements[string].source;
|
|
211
|
+
});
|
|
262
212
|
}
|
|
263
|
-
|
|
264
|
-
// HTML Block (only opening rule is processed currently)
|
|
265
|
-
} catch (err) {
|
|
266
|
-
_iterator.e(err);
|
|
267
|
-
} finally {
|
|
268
|
-
_iterator.f();
|
|
213
|
+
inlineGrammar[rule].regexp = new RegExp(re, inlineGrammar[rule].regexp.flags);
|
|
269
214
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
215
|
+
|
|
216
|
+
// HTML Block (only opening rule is processed currently)
|
|
217
|
+
for (let rule of htmlBlockGrammar) {
|
|
218
|
+
let re = rule.start.source;
|
|
273
219
|
// Replace while there is something to replace. This means it also works over multiple levels (replacements containing replacements)
|
|
274
220
|
while (re.match(replacementRegexp)) {
|
|
275
|
-
re = re.replace(replacementRegexp,
|
|
221
|
+
re = re.replace(replacementRegexp, string => {
|
|
276
222
|
return replacements[string].source;
|
|
277
223
|
});
|
|
278
224
|
}
|
|
@@ -299,7 +245,7 @@ function htmlescape(string) {
|
|
|
299
245
|
* be inserted before and after the selection. The unset object contains a prePattern and a postPattern. Both should be regular expressions and
|
|
300
246
|
* they will be applied to the portion of the line before and after the selection (using String.replace, with an empty replacement string).
|
|
301
247
|
*/
|
|
302
|
-
|
|
248
|
+
const commands = exports.commands = {
|
|
303
249
|
// Replacements for unset for inline commands are '' by default
|
|
304
250
|
bold: {
|
|
305
251
|
type: 'inline',
|
|
@@ -458,5 +404,4 @@ var commands = {
|
|
|
458
404
|
replacement: '$2'
|
|
459
405
|
}
|
|
460
406
|
}
|
|
461
|
-
};
|
|
462
|
-
exports.commands = commands;
|
|
407
|
+
};
|