@toast-ui/editor 3.1.2 → 3.1.3
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/esm/i18n/ar.js +1 -1
- package/dist/esm/i18n/cs-cz.js +1 -1
- package/dist/esm/i18n/de-de.js +1 -1
- package/dist/esm/i18n/en-us.js +1 -1
- package/dist/esm/i18n/es-es.js +1 -1
- package/dist/esm/i18n/fi-fi.js +1 -1
- package/dist/esm/i18n/fr-fr.js +1 -1
- package/dist/esm/i18n/gl-es.js +1 -1
- package/dist/esm/i18n/hr-hr.js +1 -1
- package/dist/esm/i18n/i18n.js +2 -3
- package/dist/esm/i18n/it-it.js +1 -1
- package/dist/esm/i18n/ja-jp.js +1 -1
- package/dist/esm/i18n/ko-kr.js +1 -1
- package/dist/esm/i18n/nb-no.js +1 -1
- package/dist/esm/i18n/nl-nl.js +1 -1
- package/dist/esm/i18n/pl-pl.js +1 -1
- package/dist/esm/i18n/pt-br.js +1 -1
- package/dist/esm/i18n/ru-ru.js +1 -1
- package/dist/esm/i18n/sv-se.js +1 -1
- package/dist/esm/i18n/tr-tr.js +1 -1
- package/dist/esm/i18n/uk-ua.js +1 -1
- package/dist/esm/i18n/zh-cn.js +1 -1
- package/dist/esm/i18n/zh-tw.js +1 -1
- package/dist/esm/index.js +924 -714
- package/dist/esm/indexViewer.js +11 -11
- package/dist/i18n/ar.js +5 -5
- package/dist/i18n/cs-cz.js +5 -5
- package/dist/i18n/de-de.js +5 -5
- package/dist/i18n/es-es.js +5 -5
- package/dist/i18n/fi-fi.js +5 -5
- package/dist/i18n/fr-fr.js +5 -5
- package/dist/i18n/gl-es.js +5 -5
- package/dist/i18n/hr-hr.js +5 -5
- package/dist/i18n/it-it.js +5 -5
- package/dist/i18n/ja-jp.js +5 -5
- package/dist/i18n/ko-kr.js +5 -5
- package/dist/i18n/nb-no.js +5 -5
- package/dist/i18n/nl-nl.js +5 -5
- package/dist/i18n/pl-pl.js +5 -5
- package/dist/i18n/pt-br.js +5 -5
- package/dist/i18n/ru-ru.js +5 -5
- package/dist/i18n/sv-se.js +5 -5
- package/dist/i18n/tr-tr.js +5 -5
- package/dist/i18n/uk-ua.js +5 -5
- package/dist/i18n/zh-cn.js +5 -5
- package/dist/i18n/zh-tw.js +5 -5
- package/dist/toastui-editor-only.css +1 -1
- package/dist/toastui-editor-viewer.css +6 -6
- package/dist/toastui-editor-viewer.js +39 -32
- package/dist/toastui-editor.css +6 -6
- package/dist/toastui-editor.js +755 -541
- package/package.json +2 -2
- package/types/event.d.ts +1 -0
- package/types/index.d.ts +1 -1
- package/types/spec.d.ts +1 -1
- package/types/ui.d.ts +22 -20
- package/types/wysiwyg.d.ts +2 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @toast-ui/editor
|
|
3
|
-
* @version 3.1.
|
|
3
|
+
* @version 3.1.3 | Thu Feb 10 2022
|
|
4
4
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
@@ -703,6 +703,8 @@ var reEscapeChars$1 = /[>(){}[\]+-.!#|]/g;
|
|
|
703
703
|
var reEscapeHTML = /<([a-zA-Z_][a-zA-Z0-9\-._]*)(\s|[^\\/>])*\/?>|<(\/)([a-zA-Z_][a-zA-Z0-9\-._]*)\s*\/?>|<!--[^-]+-->|<([a-zA-Z_][a-zA-Z0-9\-.:/]*)>/g;
|
|
704
704
|
var reEscapeBackSlash = /\\[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~\\]/g;
|
|
705
705
|
var reEscapePairedChars = /[*_~`]/g;
|
|
706
|
+
var reMdImageSyntax = /!\[.*\]\(.*\)/g;
|
|
707
|
+
var reEscapedCharInLinkSyntax = /[[\]]/g; //
|
|
706
708
|
var XMLSPECIAL$1 = '[&<>"]';
|
|
707
709
|
var reXmlSpecial$1 = new RegExp(XMLSPECIAL$1, 'g');
|
|
708
710
|
function replaceUnsafeChar$1(char) {
|
|
@@ -774,6 +776,18 @@ function isNeedEscapeText(text) {
|
|
|
774
776
|
});
|
|
775
777
|
return needEscape;
|
|
776
778
|
}
|
|
779
|
+
function escapeTextForLink(text) {
|
|
780
|
+
var imageSyntaxRanges = [];
|
|
781
|
+
var result = reMdImageSyntax.exec(text);
|
|
782
|
+
while (result) {
|
|
783
|
+
imageSyntaxRanges.push([result.index, result.index + result[0].length]);
|
|
784
|
+
result = reMdImageSyntax.exec(text);
|
|
785
|
+
}
|
|
786
|
+
return text.replace(reEscapedCharInLinkSyntax, function (matched, offset) {
|
|
787
|
+
var isDelimiter = imageSyntaxRanges.some(function (range) { return offset > range[0] && offset < range[1]; });
|
|
788
|
+
return isDelimiter ? matched : "\\" + matched;
|
|
789
|
+
});
|
|
790
|
+
}
|
|
777
791
|
function escape$1(text) {
|
|
778
792
|
var replacer = function (matched) { return "\\" + matched; };
|
|
779
793
|
var escapedText = text.replace(reSpaceMoreThanOne, ' ');
|
|
@@ -896,6 +910,54 @@ function getSortedNumPair(valueA, valueB) {
|
|
|
896
910
|
return valueA > valueB ? [valueB, valueA] : [valueA, valueB];
|
|
897
911
|
}
|
|
898
912
|
|
|
913
|
+
/**
|
|
914
|
+
* @fileoverview Transform the Array-like object to Array.
|
|
915
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
916
|
+
*/
|
|
917
|
+
|
|
918
|
+
var forEachArray = forEachArray_1;
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* Transform the Array-like object to Array.
|
|
922
|
+
* In low IE (below 8), Array.prototype.slice.call is not perfect. So, try-catch statement is used.
|
|
923
|
+
* @param {*} arrayLike Array-like object
|
|
924
|
+
* @returns {Array} Array
|
|
925
|
+
* @memberof module:collection
|
|
926
|
+
* @example
|
|
927
|
+
* // ES6
|
|
928
|
+
* import toArray from 'tui-code-snippet/collection/toArray';
|
|
929
|
+
*
|
|
930
|
+
* // CommonJS
|
|
931
|
+
* const toArray = require('tui-code-snippet/collection/toArray');
|
|
932
|
+
*
|
|
933
|
+
* const arrayLike = {
|
|
934
|
+
* 0: 'one',
|
|
935
|
+
* 1: 'two',
|
|
936
|
+
* 2: 'three',
|
|
937
|
+
* 3: 'four',
|
|
938
|
+
* length: 4
|
|
939
|
+
* };
|
|
940
|
+
* const result = toArray(arrayLike);
|
|
941
|
+
*
|
|
942
|
+
* alert(result instanceof Array); // true
|
|
943
|
+
* alert(result); // one,two,three,four
|
|
944
|
+
*/
|
|
945
|
+
function toArray$1(arrayLike) {
|
|
946
|
+
var arr;
|
|
947
|
+
try {
|
|
948
|
+
arr = Array.prototype.slice.call(arrayLike);
|
|
949
|
+
} catch (e) {
|
|
950
|
+
arr = [];
|
|
951
|
+
forEachArray(arrayLike, function(value) {
|
|
952
|
+
arr.push(value);
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
return arr;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
var toArray_1 = toArray$1;
|
|
960
|
+
|
|
899
961
|
function createParagraph(schema, content) {
|
|
900
962
|
var paragraph = schema.nodes.paragraph;
|
|
901
963
|
if (!content) {
|
|
@@ -1219,192 +1281,393 @@ function placeholder(options) {
|
|
|
1219
1281
|
});
|
|
1220
1282
|
}
|
|
1221
1283
|
|
|
1222
|
-
var pluginKey$1 = new PluginKey('widget');
|
|
1223
|
-
var PopupWidget = /** @class */ (function () {
|
|
1224
|
-
function PopupWidget(eventEmitter) {
|
|
1225
|
-
var _this = this;
|
|
1226
|
-
this.popup = null;
|
|
1227
|
-
this.removeWidget = function () {
|
|
1228
|
-
if (_this.popup) {
|
|
1229
|
-
document.body.removeChild(_this.popup);
|
|
1230
|
-
_this.popup = null;
|
|
1231
|
-
}
|
|
1232
|
-
};
|
|
1233
|
-
this.eventEmitter = eventEmitter;
|
|
1234
|
-
this.eventEmitter.listen('blur', this.removeWidget);
|
|
1235
|
-
this.eventEmitter.listen('removePopupWidget', this.removeWidget);
|
|
1236
|
-
}
|
|
1237
|
-
PopupWidget.prototype.update = function (view) {
|
|
1238
|
-
var widget = pluginKey$1.getState(view.state);
|
|
1239
|
-
this.removeWidget();
|
|
1240
|
-
if (widget) {
|
|
1241
|
-
var node = widget.node, style = widget.style;
|
|
1242
|
-
var _a = view.coordsAtPos(widget.pos), top_1 = _a.top, left = _a.left, bottom = _a.bottom;
|
|
1243
|
-
var height = bottom - top_1;
|
|
1244
|
-
css_1(node, { position: 'absolute', left: left + "px", opacity: '0' });
|
|
1245
|
-
document.body.appendChild(node);
|
|
1246
|
-
css_1(node, {
|
|
1247
|
-
top: (style === 'bottom' ? top_1 + height : top_1 - node.clientHeight - height) + "px",
|
|
1248
|
-
opacity: '1',
|
|
1249
|
-
});
|
|
1250
|
-
this.popup = node;
|
|
1251
|
-
view.focus();
|
|
1252
|
-
}
|
|
1253
|
-
};
|
|
1254
|
-
PopupWidget.prototype.destroy = function () {
|
|
1255
|
-
this.eventEmitter.removeEventHandler('blur', this.removeWidget);
|
|
1256
|
-
};
|
|
1257
|
-
return PopupWidget;
|
|
1258
|
-
}());
|
|
1259
|
-
function addWidget(eventEmitter) {
|
|
1260
|
-
return new Plugin({
|
|
1261
|
-
key: pluginKey$1,
|
|
1262
|
-
state: {
|
|
1263
|
-
init: function () {
|
|
1264
|
-
return null;
|
|
1265
|
-
},
|
|
1266
|
-
apply: function (tr) {
|
|
1267
|
-
return tr.getMeta('widget');
|
|
1268
|
-
},
|
|
1269
|
-
},
|
|
1270
|
-
view: function () {
|
|
1271
|
-
return new PopupWidget(eventEmitter);
|
|
1272
|
-
},
|
|
1273
|
-
});
|
|
1274
|
-
}
|
|
1275
|
-
|
|
1276
1284
|
/**
|
|
1277
|
-
* @fileoverview
|
|
1285
|
+
* @fileoverview Check element has specific css class
|
|
1278
1286
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
1279
1287
|
*/
|
|
1280
1288
|
|
|
1281
|
-
var
|
|
1289
|
+
var inArray$1 = inArray_1;
|
|
1290
|
+
var getClass = getClass_1;
|
|
1282
1291
|
|
|
1283
1292
|
/**
|
|
1284
|
-
*
|
|
1285
|
-
*
|
|
1286
|
-
* @param {
|
|
1287
|
-
* @returns {
|
|
1288
|
-
* @memberof module:
|
|
1289
|
-
* @example
|
|
1290
|
-
* // ES6
|
|
1291
|
-
* import toArray from 'tui-code-snippet/collection/toArray';
|
|
1292
|
-
*
|
|
1293
|
-
* // CommonJS
|
|
1294
|
-
* const toArray = require('tui-code-snippet/collection/toArray');
|
|
1295
|
-
*
|
|
1296
|
-
* const arrayLike = {
|
|
1297
|
-
* 0: 'one',
|
|
1298
|
-
* 1: 'two',
|
|
1299
|
-
* 2: 'three',
|
|
1300
|
-
* 3: 'four',
|
|
1301
|
-
* length: 4
|
|
1302
|
-
* };
|
|
1303
|
-
* const result = toArray(arrayLike);
|
|
1304
|
-
*
|
|
1305
|
-
* alert(result instanceof Array); // true
|
|
1306
|
-
* alert(result); // one,two,three,four
|
|
1293
|
+
* Check element has specific css class
|
|
1294
|
+
* @param {(HTMLElement|SVGElement)} element - target element
|
|
1295
|
+
* @param {string} cssClass - css class
|
|
1296
|
+
* @returns {boolean}
|
|
1297
|
+
* @memberof module:domUtil
|
|
1307
1298
|
*/
|
|
1308
|
-
function
|
|
1309
|
-
var
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
arr = [];
|
|
1314
|
-
forEachArray(arrayLike, function(value) {
|
|
1315
|
-
arr.push(value);
|
|
1316
|
-
});
|
|
1299
|
+
function hasClass(element, cssClass) {
|
|
1300
|
+
var origin;
|
|
1301
|
+
|
|
1302
|
+
if (element.classList) {
|
|
1303
|
+
return element.classList.contains(cssClass);
|
|
1317
1304
|
}
|
|
1318
1305
|
|
|
1319
|
-
|
|
1306
|
+
origin = getClass(element).split(/\s+/);
|
|
1307
|
+
|
|
1308
|
+
return inArray$1(cssClass, origin) > -1;
|
|
1320
1309
|
}
|
|
1321
1310
|
|
|
1322
|
-
var
|
|
1311
|
+
var hasClass_1 = hasClass;
|
|
1323
1312
|
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
var target = _a.target;
|
|
1329
|
-
return callback(target.result);
|
|
1330
|
-
};
|
|
1331
|
-
reader.readAsDataURL(blob);
|
|
1332
|
-
});
|
|
1333
|
-
}
|
|
1334
|
-
function emitImageBlobHook(eventEmitter, blob, type) {
|
|
1335
|
-
var hook = function (imageUrl, altText) {
|
|
1336
|
-
eventEmitter.emit('command', 'addImage', {
|
|
1337
|
-
imageUrl: imageUrl,
|
|
1338
|
-
altText: altText || blob.name || 'image',
|
|
1339
|
-
});
|
|
1340
|
-
};
|
|
1341
|
-
eventEmitter.emit('addImageBlobHook', blob, hook, type);
|
|
1342
|
-
}
|
|
1343
|
-
function pasteImageOnly(items) {
|
|
1344
|
-
var images = toArray_1(items).filter(function (_a) {
|
|
1345
|
-
var type = _a.type;
|
|
1346
|
-
return type.indexOf('image') !== -1;
|
|
1347
|
-
});
|
|
1348
|
-
if (images.length === 1) {
|
|
1349
|
-
var item = images[0];
|
|
1350
|
-
if (item) {
|
|
1351
|
-
return item.getAsFile();
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
return null;
|
|
1355
|
-
}
|
|
1313
|
+
/**
|
|
1314
|
+
* @fileoverview Check element match selector
|
|
1315
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
1316
|
+
*/
|
|
1356
1317
|
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
return new Plugin({
|
|
1360
|
-
props: {
|
|
1361
|
-
handleDOMEvents: {
|
|
1362
|
-
drop: function (_, ev) {
|
|
1363
|
-
var _a;
|
|
1364
|
-
var items = (_a = ev.dataTransfer) === null || _a === void 0 ? void 0 : _a.files;
|
|
1365
|
-
if (items) {
|
|
1366
|
-
forEachArray_1(items, function (item) {
|
|
1367
|
-
if (item.type.indexOf('image') !== -1) {
|
|
1368
|
-
ev.preventDefault();
|
|
1369
|
-
ev.stopPropagation();
|
|
1370
|
-
emitImageBlobHook(eventEmitter, item, ev.type);
|
|
1371
|
-
return false;
|
|
1372
|
-
}
|
|
1373
|
-
return true;
|
|
1374
|
-
});
|
|
1375
|
-
}
|
|
1376
|
-
return true;
|
|
1377
|
-
},
|
|
1378
|
-
},
|
|
1379
|
-
},
|
|
1380
|
-
});
|
|
1381
|
-
}
|
|
1318
|
+
var inArray = inArray_1;
|
|
1319
|
+
var toArray = toArray_1;
|
|
1382
1320
|
|
|
1383
|
-
var
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
});
|
|
1393
|
-
Node.prototype.setContext = function (context) {
|
|
1394
|
-
this.context = context;
|
|
1321
|
+
var elProto = Element.prototype;
|
|
1322
|
+
var matchSelector = elProto.matches ||
|
|
1323
|
+
elProto.webkitMatchesSelector ||
|
|
1324
|
+
elProto.mozMatchesSelector ||
|
|
1325
|
+
elProto.msMatchesSelector ||
|
|
1326
|
+
function(selector) {
|
|
1327
|
+
var doc = this.document || this.ownerDocument;
|
|
1328
|
+
|
|
1329
|
+
return inArray(this, toArray(doc.querySelectorAll(selector))) > -1;
|
|
1395
1330
|
};
|
|
1396
|
-
return Node;
|
|
1397
|
-
}());
|
|
1398
1331
|
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
function
|
|
1407
|
-
|
|
1332
|
+
/**
|
|
1333
|
+
* Check element match selector
|
|
1334
|
+
* @param {HTMLElement} element - element to check
|
|
1335
|
+
* @param {string} selector - selector to check
|
|
1336
|
+
* @returns {boolean} is selector matched to element?
|
|
1337
|
+
* @memberof module:domUtil
|
|
1338
|
+
*/
|
|
1339
|
+
function matches(element, selector) {
|
|
1340
|
+
return matchSelector.call(element, selector);
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
var matches_1 = matches;
|
|
1344
|
+
|
|
1345
|
+
var TAG_NAME = '[A-Za-z][A-Za-z0-9-]*';
|
|
1346
|
+
var ATTRIBUTE_NAME = '[a-zA-Z_:][a-zA-Z0-9:._-]*';
|
|
1347
|
+
var UNQUOTED_VALUE = '[^"\'=<>`\\x00-\\x20]+';
|
|
1348
|
+
var SINGLE_QUOTED_VALUE = "'[^']*'";
|
|
1349
|
+
var DOUBLE_QUOTED_VALUE = '"[^"]*"';
|
|
1350
|
+
var ATTRIBUTE_VALUE = "(?:" + UNQUOTED_VALUE + "|" + SINGLE_QUOTED_VALUE + "|" + DOUBLE_QUOTED_VALUE + ")";
|
|
1351
|
+
var ATTRIBUTE_VALUE_SPEC = "" + '(?:\\s*=\\s*' + ATTRIBUTE_VALUE + ")";
|
|
1352
|
+
var ATTRIBUTE$1 = "" + '(?:\\s+' + ATTRIBUTE_NAME + ATTRIBUTE_VALUE_SPEC + "?)";
|
|
1353
|
+
var OPEN_TAG = "<(" + TAG_NAME + ")(" + ATTRIBUTE$1 + ")*\\s*/?>";
|
|
1354
|
+
var CLOSE_TAG = "</(" + TAG_NAME + ")\\s*[>]";
|
|
1355
|
+
var HTML_TAG = "(?:" + OPEN_TAG + "|" + CLOSE_TAG + ")";
|
|
1356
|
+
var reHTMLTag = new RegExp("^" + HTML_TAG, 'i');
|
|
1357
|
+
var reBR = /<br\s*\/*>/i;
|
|
1358
|
+
var reHTMLComment = /<! ---->|<!--(?:-?[^>-])(?:-?[^-])*-->/;
|
|
1359
|
+
var ALTERNATIVE_TAG_FOR_BR = '</p><p>';
|
|
1360
|
+
|
|
1361
|
+
function isPositionInBox(style, offsetX, offsetY) {
|
|
1362
|
+
var left = parseInt(style.left, 10);
|
|
1363
|
+
var top = parseInt(style.top, 10);
|
|
1364
|
+
var width = parseInt(style.width, 10) + parseInt(style.paddingLeft, 10) + parseInt(style.paddingRight, 10);
|
|
1365
|
+
var height = parseInt(style.height, 10) + parseInt(style.paddingTop, 10) + parseInt(style.paddingBottom, 10);
|
|
1366
|
+
return offsetX >= left && offsetX <= left + width && offsetY >= top && offsetY <= top + height;
|
|
1367
|
+
}
|
|
1368
|
+
var CLS_PREFIX = 'toastui-editor-';
|
|
1369
|
+
function cls() {
|
|
1370
|
+
var names = [];
|
|
1371
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1372
|
+
names[_i] = arguments[_i];
|
|
1373
|
+
}
|
|
1374
|
+
var result = [];
|
|
1375
|
+
for (var _a = 0, names_1 = names; _a < names_1.length; _a++) {
|
|
1376
|
+
var name_1 = names_1[_a];
|
|
1377
|
+
var className = void 0;
|
|
1378
|
+
if (Array.isArray(name_1)) {
|
|
1379
|
+
className = name_1[0] ? name_1[1] : null;
|
|
1380
|
+
}
|
|
1381
|
+
else {
|
|
1382
|
+
className = name_1;
|
|
1383
|
+
}
|
|
1384
|
+
if (className) {
|
|
1385
|
+
result.push("" + CLS_PREFIX + className);
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
return result.join(' ');
|
|
1389
|
+
}
|
|
1390
|
+
function clsWithMdPrefix() {
|
|
1391
|
+
var names = [];
|
|
1392
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1393
|
+
names[_i] = arguments[_i];
|
|
1394
|
+
}
|
|
1395
|
+
return names.map(function (className) { return CLS_PREFIX + "md-" + className; }).join(' ');
|
|
1396
|
+
}
|
|
1397
|
+
function isTextNode(node) {
|
|
1398
|
+
return (node === null || node === void 0 ? void 0 : node.nodeType) === Node.TEXT_NODE;
|
|
1399
|
+
}
|
|
1400
|
+
function isElemNode(node) {
|
|
1401
|
+
return node && node.nodeType === Node.ELEMENT_NODE;
|
|
1402
|
+
}
|
|
1403
|
+
function findNodes(element, selector) {
|
|
1404
|
+
var nodeList = toArray_1(element.querySelectorAll(selector));
|
|
1405
|
+
if (nodeList.length) {
|
|
1406
|
+
return nodeList;
|
|
1407
|
+
}
|
|
1408
|
+
return [];
|
|
1409
|
+
}
|
|
1410
|
+
function appendNodes(node, nodesToAppend) {
|
|
1411
|
+
nodesToAppend = isArray_1(nodesToAppend) ? toArray_1(nodesToAppend) : [nodesToAppend];
|
|
1412
|
+
nodesToAppend.forEach(function (nodeToAppend) {
|
|
1413
|
+
node.appendChild(nodeToAppend);
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
function insertBeforeNode(insertedNode, node) {
|
|
1417
|
+
if (node.parentNode) {
|
|
1418
|
+
node.parentNode.insertBefore(insertedNode, node);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
function removeNode$1(node) {
|
|
1422
|
+
if (node.parentNode) {
|
|
1423
|
+
node.parentNode.removeChild(node);
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
function unwrapNode(node) {
|
|
1427
|
+
var result = [];
|
|
1428
|
+
while (node.firstChild) {
|
|
1429
|
+
result.push(node.firstChild);
|
|
1430
|
+
if (node.parentNode) {
|
|
1431
|
+
node.parentNode.insertBefore(node.firstChild, node);
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
removeNode$1(node);
|
|
1435
|
+
return result;
|
|
1436
|
+
}
|
|
1437
|
+
function toggleClass(element, className, state) {
|
|
1438
|
+
if (isUndefined_1(state)) {
|
|
1439
|
+
state = !hasClass_1(element, className);
|
|
1440
|
+
}
|
|
1441
|
+
var toggleFn = state ? addClass_1 : removeClass_1;
|
|
1442
|
+
toggleFn(element, className);
|
|
1443
|
+
}
|
|
1444
|
+
function createElementWith(contents, target) {
|
|
1445
|
+
var container = document.createElement('div');
|
|
1446
|
+
if (isString_1(contents)) {
|
|
1447
|
+
container.innerHTML = contents;
|
|
1448
|
+
}
|
|
1449
|
+
else {
|
|
1450
|
+
container.appendChild(contents);
|
|
1451
|
+
}
|
|
1452
|
+
var firstChild = container.firstChild;
|
|
1453
|
+
if (target) {
|
|
1454
|
+
target.appendChild(firstChild);
|
|
1455
|
+
}
|
|
1456
|
+
return firstChild;
|
|
1457
|
+
}
|
|
1458
|
+
function getOuterWidth(el) {
|
|
1459
|
+
var computed = window.getComputedStyle(el);
|
|
1460
|
+
return (['margin-left', 'margin-right'].reduce(function (acc, type) { return acc + parseInt(computed.getPropertyValue(type), 10); }, 0) + el.offsetWidth);
|
|
1461
|
+
}
|
|
1462
|
+
function closest(node, found) {
|
|
1463
|
+
var condition;
|
|
1464
|
+
if (isString_1(found)) {
|
|
1465
|
+
condition = function (target) { return matches_1(target, found); };
|
|
1466
|
+
}
|
|
1467
|
+
else {
|
|
1468
|
+
condition = function (target) { return target === found; };
|
|
1469
|
+
}
|
|
1470
|
+
while (node && node !== document) {
|
|
1471
|
+
if (isElemNode(node) && condition(node)) {
|
|
1472
|
+
return node;
|
|
1473
|
+
}
|
|
1474
|
+
node = node.parentNode;
|
|
1475
|
+
}
|
|
1476
|
+
return null;
|
|
1477
|
+
}
|
|
1478
|
+
function getTotalOffset(el, root) {
|
|
1479
|
+
var offsetTop = 0;
|
|
1480
|
+
var offsetLeft = 0;
|
|
1481
|
+
while (el && el !== root) {
|
|
1482
|
+
var top_1 = el.offsetTop, left = el.offsetLeft, offsetParent = el.offsetParent;
|
|
1483
|
+
offsetTop += top_1;
|
|
1484
|
+
offsetLeft += left;
|
|
1485
|
+
if (offsetParent === root.offsetParent) {
|
|
1486
|
+
break;
|
|
1487
|
+
}
|
|
1488
|
+
el = el.offsetParent;
|
|
1489
|
+
}
|
|
1490
|
+
return { offsetTop: offsetTop, offsetLeft: offsetLeft };
|
|
1491
|
+
}
|
|
1492
|
+
function setAttributes(attributes, element) {
|
|
1493
|
+
Object.keys(attributes).forEach(function (attrName) {
|
|
1494
|
+
if (isNil(attributes[attrName])) {
|
|
1495
|
+
element.removeAttribute(attrName);
|
|
1496
|
+
}
|
|
1497
|
+
else {
|
|
1498
|
+
element.setAttribute(attrName, attributes[attrName]);
|
|
1499
|
+
}
|
|
1500
|
+
});
|
|
1501
|
+
}
|
|
1502
|
+
function replaceBRWithEmptyBlock(html) {
|
|
1503
|
+
// remove br in paragraph to compatible with markdown
|
|
1504
|
+
var replacedHTML = html.replace(/<p><br\s*\/*><\/p>/gi, '<p></p>');
|
|
1505
|
+
var reHTMLTag = new RegExp(HTML_TAG, 'ig');
|
|
1506
|
+
var htmlTagMatched = replacedHTML.match(reHTMLTag);
|
|
1507
|
+
htmlTagMatched === null || htmlTagMatched === void 0 ? void 0 : htmlTagMatched.forEach(function (htmlTag, index) {
|
|
1508
|
+
if (reBR.test(htmlTag)) {
|
|
1509
|
+
var alternativeTag = ALTERNATIVE_TAG_FOR_BR;
|
|
1510
|
+
if (index) {
|
|
1511
|
+
var prevTag = htmlTagMatched[index - 1];
|
|
1512
|
+
var openTagMatched = prevTag.match(OPEN_TAG);
|
|
1513
|
+
if (openTagMatched && !/br/i.test(openTagMatched[1])) {
|
|
1514
|
+
var tagName = openTagMatched[1];
|
|
1515
|
+
alternativeTag = "</" + tagName + "><" + tagName + ">";
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
replacedHTML = replacedHTML.replace(reBR, alternativeTag);
|
|
1519
|
+
}
|
|
1520
|
+
});
|
|
1521
|
+
return replacedHTML;
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
var pluginKey$1 = new PluginKey('widget');
|
|
1525
|
+
var MARGIN = 5;
|
|
1526
|
+
var PopupWidget = /** @class */ (function () {
|
|
1527
|
+
function PopupWidget(view, eventEmitter) {
|
|
1528
|
+
var _this = this;
|
|
1529
|
+
this.popup = null;
|
|
1530
|
+
this.removeWidget = function () {
|
|
1531
|
+
if (_this.popup) {
|
|
1532
|
+
_this.rootEl.removeChild(_this.popup);
|
|
1533
|
+
_this.popup = null;
|
|
1534
|
+
}
|
|
1535
|
+
};
|
|
1536
|
+
this.rootEl = view.dom.parentElement;
|
|
1537
|
+
this.eventEmitter = eventEmitter;
|
|
1538
|
+
this.eventEmitter.listen('blur', this.removeWidget);
|
|
1539
|
+
this.eventEmitter.listen('loadUI', function () {
|
|
1540
|
+
_this.rootEl = closest(view.dom.parentElement, "." + cls('defaultUI'));
|
|
1541
|
+
});
|
|
1542
|
+
this.eventEmitter.listen('removePopupWidget', this.removeWidget);
|
|
1543
|
+
}
|
|
1544
|
+
PopupWidget.prototype.update = function (view) {
|
|
1545
|
+
var widget = pluginKey$1.getState(view.state);
|
|
1546
|
+
this.removeWidget();
|
|
1547
|
+
if (widget) {
|
|
1548
|
+
var node = widget.node, style = widget.style;
|
|
1549
|
+
var _a = view.coordsAtPos(widget.pos), top_1 = _a.top, left = _a.left, bottom = _a.bottom;
|
|
1550
|
+
var height = bottom - top_1;
|
|
1551
|
+
var rect = this.rootEl.getBoundingClientRect();
|
|
1552
|
+
var relTopPos = top_1 - rect.top;
|
|
1553
|
+
css_1(node, { opacity: '0' });
|
|
1554
|
+
this.rootEl.appendChild(node);
|
|
1555
|
+
css_1(node, {
|
|
1556
|
+
position: 'absolute',
|
|
1557
|
+
left: left - rect.left + MARGIN + "px",
|
|
1558
|
+
top: (style === 'bottom' ? relTopPos + height - MARGIN : relTopPos - height) + "px",
|
|
1559
|
+
opacity: '1',
|
|
1560
|
+
});
|
|
1561
|
+
this.popup = node;
|
|
1562
|
+
view.focus();
|
|
1563
|
+
}
|
|
1564
|
+
};
|
|
1565
|
+
PopupWidget.prototype.destroy = function () {
|
|
1566
|
+
this.eventEmitter.removeEventHandler('blur', this.removeWidget);
|
|
1567
|
+
};
|
|
1568
|
+
return PopupWidget;
|
|
1569
|
+
}());
|
|
1570
|
+
function addWidget(eventEmitter) {
|
|
1571
|
+
return new Plugin({
|
|
1572
|
+
key: pluginKey$1,
|
|
1573
|
+
state: {
|
|
1574
|
+
init: function () {
|
|
1575
|
+
return null;
|
|
1576
|
+
},
|
|
1577
|
+
apply: function (tr) {
|
|
1578
|
+
return tr.getMeta('widget');
|
|
1579
|
+
},
|
|
1580
|
+
},
|
|
1581
|
+
view: function (editorView) {
|
|
1582
|
+
return new PopupWidget(editorView, eventEmitter);
|
|
1583
|
+
},
|
|
1584
|
+
});
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
function addDefaultImageBlobHook(eventEmitter) {
|
|
1588
|
+
eventEmitter.listen('addImageBlobHook', function (blob, callback) {
|
|
1589
|
+
var reader = new FileReader();
|
|
1590
|
+
reader.onload = function (_a) {
|
|
1591
|
+
var target = _a.target;
|
|
1592
|
+
return callback(target.result);
|
|
1593
|
+
};
|
|
1594
|
+
reader.readAsDataURL(blob);
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1597
|
+
function emitImageBlobHook(eventEmitter, blob, type) {
|
|
1598
|
+
var hook = function (imageUrl, altText) {
|
|
1599
|
+
eventEmitter.emit('command', 'addImage', {
|
|
1600
|
+
imageUrl: imageUrl,
|
|
1601
|
+
altText: altText || blob.name || 'image',
|
|
1602
|
+
});
|
|
1603
|
+
};
|
|
1604
|
+
eventEmitter.emit('addImageBlobHook', blob, hook, type);
|
|
1605
|
+
}
|
|
1606
|
+
function pasteImageOnly(items) {
|
|
1607
|
+
var images = toArray_1(items).filter(function (_a) {
|
|
1608
|
+
var type = _a.type;
|
|
1609
|
+
return type.indexOf('image') !== -1;
|
|
1610
|
+
});
|
|
1611
|
+
if (images.length === 1) {
|
|
1612
|
+
var item = images[0];
|
|
1613
|
+
if (item) {
|
|
1614
|
+
return item.getAsFile();
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
return null;
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
function dropImage(_a) {
|
|
1621
|
+
var eventEmitter = _a.eventEmitter;
|
|
1622
|
+
return new Plugin({
|
|
1623
|
+
props: {
|
|
1624
|
+
handleDOMEvents: {
|
|
1625
|
+
drop: function (_, ev) {
|
|
1626
|
+
var _a;
|
|
1627
|
+
var items = (_a = ev.dataTransfer) === null || _a === void 0 ? void 0 : _a.files;
|
|
1628
|
+
if (items) {
|
|
1629
|
+
forEachArray_1(items, function (item) {
|
|
1630
|
+
if (item.type.indexOf('image') !== -1) {
|
|
1631
|
+
ev.preventDefault();
|
|
1632
|
+
ev.stopPropagation();
|
|
1633
|
+
emitImageBlobHook(eventEmitter, item, ev.type);
|
|
1634
|
+
return false;
|
|
1635
|
+
}
|
|
1636
|
+
return true;
|
|
1637
|
+
});
|
|
1638
|
+
}
|
|
1639
|
+
return true;
|
|
1640
|
+
},
|
|
1641
|
+
},
|
|
1642
|
+
},
|
|
1643
|
+
});
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
var Node$2 = /** @class */ (function () {
|
|
1647
|
+
function Node() {
|
|
1648
|
+
}
|
|
1649
|
+
Object.defineProperty(Node.prototype, "type", {
|
|
1650
|
+
get: function () {
|
|
1651
|
+
return 'node';
|
|
1652
|
+
},
|
|
1653
|
+
enumerable: false,
|
|
1654
|
+
configurable: true
|
|
1655
|
+
});
|
|
1656
|
+
Node.prototype.setContext = function (context) {
|
|
1657
|
+
this.context = context;
|
|
1658
|
+
};
|
|
1659
|
+
return Node;
|
|
1660
|
+
}());
|
|
1661
|
+
|
|
1662
|
+
function widgetNodeView(pmNode) {
|
|
1663
|
+
var dom = document.createElement('span');
|
|
1664
|
+
var node = widgetToDOM(pmNode.attrs.info, pmNode.textContent);
|
|
1665
|
+
dom.className = 'tui-widget';
|
|
1666
|
+
dom.appendChild(node);
|
|
1667
|
+
return { dom: dom };
|
|
1668
|
+
}
|
|
1669
|
+
function isWidgetNode(pmNode) {
|
|
1670
|
+
return pmNode.type.name === 'widget';
|
|
1408
1671
|
}
|
|
1409
1672
|
var Widget = /** @class */ (function (_super) {
|
|
1410
1673
|
__extends$1(Widget, _super);
|
|
@@ -1452,6 +1715,7 @@ var Widget = /** @class */ (function (_super) {
|
|
|
1452
1715
|
|
|
1453
1716
|
var EditorBase = /** @class */ (function () {
|
|
1454
1717
|
function EditorBase(eventEmitter) {
|
|
1718
|
+
this.timer = null;
|
|
1455
1719
|
this.el = document.createElement('div');
|
|
1456
1720
|
this.el.className = 'toastui-editor';
|
|
1457
1721
|
this.eventEmitter = eventEmitter;
|
|
@@ -1476,10 +1740,9 @@ var EditorBase = /** @class */ (function () {
|
|
|
1476
1740
|
};
|
|
1477
1741
|
Object.defineProperty(EditorBase.prototype, "defaultPlugins", {
|
|
1478
1742
|
get: function () {
|
|
1479
|
-
var _a = getDefaultCommands(), undo = _a.undo, redo = _a.redo;
|
|
1480
1743
|
var rules = this.createInputRules();
|
|
1481
1744
|
var plugins = __spreadArray$1(__spreadArray$1([], this.keymaps), [
|
|
1482
|
-
keymap(__assign$1({ '
|
|
1745
|
+
keymap(__assign$1({ 'Shift-Enter': baseKeymap.Enter }, baseKeymap)),
|
|
1483
1746
|
history(),
|
|
1484
1747
|
placeholder(this.placeholder),
|
|
1485
1748
|
addWidget(this.eventEmitter),
|
|
@@ -1516,6 +1779,12 @@ var EditorBase = /** @class */ (function () {
|
|
|
1516
1779
|
});
|
|
1517
1780
|
return rules.length ? inputRules({ rules: rules }) : null;
|
|
1518
1781
|
};
|
|
1782
|
+
EditorBase.prototype.clearTimer = function () {
|
|
1783
|
+
if (this.timer) {
|
|
1784
|
+
clearTimeout(this.timer);
|
|
1785
|
+
this.timer = null;
|
|
1786
|
+
}
|
|
1787
|
+
};
|
|
1519
1788
|
EditorBase.prototype.createSchema = function () {
|
|
1520
1789
|
return new Schema({
|
|
1521
1790
|
nodes: this.specs.nodes,
|
|
@@ -1523,7 +1792,13 @@ var EditorBase = /** @class */ (function () {
|
|
|
1523
1792
|
});
|
|
1524
1793
|
};
|
|
1525
1794
|
EditorBase.prototype.createKeymaps = function (useCommandShortcut) {
|
|
1526
|
-
|
|
1795
|
+
var _a = getDefaultCommands(), undo = _a.undo, redo = _a.redo;
|
|
1796
|
+
var allKeymaps = this.specs.keymaps(useCommandShortcut);
|
|
1797
|
+
var historyKeymap = {
|
|
1798
|
+
'Mod-z': undo(),
|
|
1799
|
+
'Shift-Mod-z': redo(),
|
|
1800
|
+
};
|
|
1801
|
+
return useCommandShortcut ? allKeymaps.concat(keymap(historyKeymap)) : allKeymaps;
|
|
1527
1802
|
};
|
|
1528
1803
|
EditorBase.prototype.createCommands = function () {
|
|
1529
1804
|
return this.specs.commands(this.view);
|
|
@@ -1534,390 +1809,181 @@ var EditorBase = /** @class */ (function () {
|
|
|
1534
1809
|
};
|
|
1535
1810
|
EditorBase.prototype.focus = function () {
|
|
1536
1811
|
var _this = this;
|
|
1812
|
+
this.clearTimer();
|
|
1537
1813
|
// prevent the error for IE11
|
|
1538
|
-
setTimeout(function () {
|
|
1814
|
+
this.timer = setTimeout(function () {
|
|
1539
1815
|
_this.view.focus();
|
|
1540
1816
|
_this.view.dispatch(_this.view.state.tr.scrollIntoView());
|
|
1541
1817
|
});
|
|
1542
1818
|
};
|
|
1543
1819
|
EditorBase.prototype.blur = function () {
|
|
1544
1820
|
this.view.dom.blur();
|
|
1545
|
-
};
|
|
1546
|
-
EditorBase.prototype.destroy = function () {
|
|
1547
|
-
var _this = this;
|
|
1548
|
-
this.
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
};
|
|
1553
|
-
EditorBase.prototype.moveCursorToStart = function (focus) {
|
|
1554
|
-
var tr = this.view.state.tr;
|
|
1555
|
-
this.view.dispatch(tr.setSelection(createTextSelection(tr, 1)).scrollIntoView());
|
|
1556
|
-
if (focus) {
|
|
1557
|
-
this.focus();
|
|
1558
|
-
}
|
|
1559
|
-
};
|
|
1560
|
-
EditorBase.prototype.moveCursorToEnd = function (focus) {
|
|
1561
|
-
var tr = this.view.state.tr;
|
|
1562
|
-
this.view.dispatch(tr.setSelection(createTextSelection(tr, tr.doc.content.size - 1)).scrollIntoView());
|
|
1563
|
-
if (focus) {
|
|
1564
|
-
this.focus();
|
|
1565
|
-
}
|
|
1566
|
-
};
|
|
1567
|
-
EditorBase.prototype.setScrollTop = function (top) {
|
|
1568
|
-
this.view.dom.scrollTop = top;
|
|
1569
|
-
};
|
|
1570
|
-
EditorBase.prototype.getScrollTop = function () {
|
|
1571
|
-
return this.view.dom.scrollTop;
|
|
1572
|
-
};
|
|
1573
|
-
EditorBase.prototype.setPlaceholder = function (text) {
|
|
1574
|
-
this.placeholder.text = text;
|
|
1575
|
-
this.view.dispatch(this.view.state.tr.scrollIntoView());
|
|
1576
|
-
};
|
|
1577
|
-
EditorBase.prototype.setHeight = function (height) {
|
|
1578
|
-
css_1(this.el, { height: height + "px" });
|
|
1579
|
-
};
|
|
1580
|
-
EditorBase.prototype.setMinHeight = function (minHeight) {
|
|
1581
|
-
css_1(this.el, { minHeight: minHeight + "px" });
|
|
1582
|
-
};
|
|
1583
|
-
EditorBase.prototype.getElement = function () {
|
|
1584
|
-
return this.el;
|
|
1585
|
-
};
|
|
1586
|
-
return EditorBase;
|
|
1587
|
-
}());
|
|
1588
|
-
|
|
1589
|
-
/**
|
|
1590
|
-
* @fileoverview Check whether the given variable is a function or not.
|
|
1591
|
-
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
1592
|
-
*/
|
|
1593
|
-
|
|
1594
|
-
/**
|
|
1595
|
-
* Check whether the given variable is a function or not.
|
|
1596
|
-
* If the given variable is a function, return true.
|
|
1597
|
-
* @param {*} obj - Target for checking
|
|
1598
|
-
* @returns {boolean} Is function?
|
|
1599
|
-
* @memberof module:type
|
|
1600
|
-
*/
|
|
1601
|
-
function isFunction(obj) {
|
|
1602
|
-
return obj instanceof Function;
|
|
1603
|
-
}
|
|
1604
|
-
|
|
1605
|
-
var isFunction_1 = isFunction;
|
|
1606
|
-
|
|
1607
|
-
function execCommand(view, command, payload) {
|
|
1608
|
-
view.focus();
|
|
1609
|
-
return command(payload)(view.state, view.dispatch, view);
|
|
1610
|
-
}
|
|
1611
|
-
var SpecManager = /** @class */ (function () {
|
|
1612
|
-
function SpecManager(specs) {
|
|
1613
|
-
this.specs = specs;
|
|
1614
|
-
}
|
|
1615
|
-
Object.defineProperty(SpecManager.prototype, "nodes", {
|
|
1616
|
-
get: function () {
|
|
1617
|
-
return this.specs
|
|
1618
|
-
.filter(function (spec) { return spec.type === 'node'; })
|
|
1619
|
-
.reduce(function (nodes, _a) {
|
|
1620
|
-
var _b;
|
|
1621
|
-
var name = _a.name, schema = _a.schema;
|
|
1622
|
-
return __assign$1(__assign$1({}, nodes), (_b = {}, _b[name] = schema, _b));
|
|
1623
|
-
}, {});
|
|
1624
|
-
},
|
|
1625
|
-
enumerable: false,
|
|
1626
|
-
configurable: true
|
|
1627
|
-
});
|
|
1628
|
-
Object.defineProperty(SpecManager.prototype, "marks", {
|
|
1629
|
-
get: function () {
|
|
1630
|
-
return this.specs
|
|
1631
|
-
.filter(function (spec) { return spec.type === 'mark'; })
|
|
1632
|
-
.reduce(function (marks, _a) {
|
|
1633
|
-
var _b;
|
|
1634
|
-
var name = _a.name, schema = _a.schema;
|
|
1635
|
-
return __assign$1(__assign$1({}, marks), (_b = {}, _b[name] = schema, _b));
|
|
1636
|
-
}, {});
|
|
1637
|
-
},
|
|
1638
|
-
enumerable: false,
|
|
1639
|
-
configurable: true
|
|
1640
|
-
});
|
|
1641
|
-
SpecManager.prototype.commands = function (view, addedCommands) {
|
|
1642
|
-
var specCommands = this.specs
|
|
1643
|
-
.filter(function (_a) {
|
|
1644
|
-
var commands = _a.commands;
|
|
1645
|
-
return commands;
|
|
1646
|
-
})
|
|
1647
|
-
.reduce(function (allCommands, spec) {
|
|
1648
|
-
var commands = {};
|
|
1649
|
-
var specCommand = spec.commands();
|
|
1650
|
-
if (isFunction_1(specCommand)) {
|
|
1651
|
-
commands[spec.name] = function (payload) { return execCommand(view, specCommand, payload); };
|
|
1652
|
-
}
|
|
1653
|
-
else {
|
|
1654
|
-
Object.keys(specCommand).forEach(function (name) {
|
|
1655
|
-
commands[name] = function (payload) { return execCommand(view, specCommand[name], payload); };
|
|
1656
|
-
});
|
|
1657
|
-
}
|
|
1658
|
-
return __assign$1(__assign$1({}, allCommands), commands);
|
|
1659
|
-
}, {});
|
|
1660
|
-
var defaultCommands = getDefaultCommands();
|
|
1661
|
-
Object.keys(defaultCommands).forEach(function (name) {
|
|
1662
|
-
specCommands[name] = function (payload) { return execCommand(view, defaultCommands[name], payload); };
|
|
1821
|
+
};
|
|
1822
|
+
EditorBase.prototype.destroy = function () {
|
|
1823
|
+
var _this = this;
|
|
1824
|
+
this.clearTimer();
|
|
1825
|
+
this.view.destroy();
|
|
1826
|
+
Object.keys(this).forEach(function (prop) {
|
|
1827
|
+
delete _this[prop];
|
|
1663
1828
|
});
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1829
|
+
};
|
|
1830
|
+
EditorBase.prototype.moveCursorToStart = function (focus) {
|
|
1831
|
+
var tr = this.view.state.tr;
|
|
1832
|
+
this.view.dispatch(tr.setSelection(createTextSelection(tr, 1)).scrollIntoView());
|
|
1833
|
+
if (focus) {
|
|
1834
|
+
this.focus();
|
|
1668
1835
|
}
|
|
1669
|
-
return specCommands;
|
|
1670
1836
|
};
|
|
1671
|
-
|
|
1672
|
-
var
|
|
1673
|
-
|
|
1837
|
+
EditorBase.prototype.moveCursorToEnd = function (focus) {
|
|
1838
|
+
var tr = this.view.state.tr;
|
|
1839
|
+
this.view.dispatch(tr.setSelection(createTextSelection(tr, tr.doc.content.size - 1)).scrollIntoView());
|
|
1840
|
+
if (focus) {
|
|
1841
|
+
this.focus();
|
|
1842
|
+
}
|
|
1674
1843
|
};
|
|
1675
|
-
|
|
1676
|
-
this.
|
|
1677
|
-
spec.setContext(context);
|
|
1678
|
-
});
|
|
1844
|
+
EditorBase.prototype.setScrollTop = function (top) {
|
|
1845
|
+
this.view.dom.scrollTop = top;
|
|
1679
1846
|
};
|
|
1680
|
-
|
|
1847
|
+
EditorBase.prototype.getScrollTop = function () {
|
|
1848
|
+
return this.view.dom.scrollTop;
|
|
1849
|
+
};
|
|
1850
|
+
EditorBase.prototype.setPlaceholder = function (text) {
|
|
1851
|
+
this.placeholder.text = text;
|
|
1852
|
+
this.view.dispatch(this.view.state.tr.scrollIntoView());
|
|
1853
|
+
};
|
|
1854
|
+
EditorBase.prototype.setHeight = function (height) {
|
|
1855
|
+
css_1(this.el, { height: height + "px" });
|
|
1856
|
+
};
|
|
1857
|
+
EditorBase.prototype.setMinHeight = function (minHeight) {
|
|
1858
|
+
css_1(this.el, { minHeight: minHeight + "px" });
|
|
1859
|
+
};
|
|
1860
|
+
EditorBase.prototype.getElement = function () {
|
|
1861
|
+
return this.el;
|
|
1862
|
+
};
|
|
1863
|
+
return EditorBase;
|
|
1681
1864
|
}());
|
|
1682
1865
|
|
|
1683
1866
|
/**
|
|
1684
|
-
* @fileoverview Check
|
|
1685
|
-
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
1686
|
-
*/
|
|
1687
|
-
|
|
1688
|
-
var inArray$1 = inArray_1;
|
|
1689
|
-
var getClass = getClass_1;
|
|
1690
|
-
|
|
1691
|
-
/**
|
|
1692
|
-
* Check element has specific css class
|
|
1693
|
-
* @param {(HTMLElement|SVGElement)} element - target element
|
|
1694
|
-
* @param {string} cssClass - css class
|
|
1695
|
-
* @returns {boolean}
|
|
1696
|
-
* @memberof module:domUtil
|
|
1697
|
-
*/
|
|
1698
|
-
function hasClass(element, cssClass) {
|
|
1699
|
-
var origin;
|
|
1700
|
-
|
|
1701
|
-
if (element.classList) {
|
|
1702
|
-
return element.classList.contains(cssClass);
|
|
1703
|
-
}
|
|
1704
|
-
|
|
1705
|
-
origin = getClass(element).split(/\s+/);
|
|
1706
|
-
|
|
1707
|
-
return inArray$1(cssClass, origin) > -1;
|
|
1708
|
-
}
|
|
1709
|
-
|
|
1710
|
-
var hasClass_1 = hasClass;
|
|
1711
|
-
|
|
1712
|
-
/**
|
|
1713
|
-
* @fileoverview Check element match selector
|
|
1867
|
+
* @fileoverview Check whether the given variable is a function or not.
|
|
1714
1868
|
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
1715
1869
|
*/
|
|
1716
1870
|
|
|
1717
|
-
var inArray = inArray_1;
|
|
1718
|
-
var toArray = toArray_1;
|
|
1719
|
-
|
|
1720
|
-
var elProto = Element.prototype;
|
|
1721
|
-
var matchSelector = elProto.matches ||
|
|
1722
|
-
elProto.webkitMatchesSelector ||
|
|
1723
|
-
elProto.mozMatchesSelector ||
|
|
1724
|
-
elProto.msMatchesSelector ||
|
|
1725
|
-
function(selector) {
|
|
1726
|
-
var doc = this.document || this.ownerDocument;
|
|
1727
|
-
|
|
1728
|
-
return inArray(this, toArray(doc.querySelectorAll(selector))) > -1;
|
|
1729
|
-
};
|
|
1730
|
-
|
|
1731
1871
|
/**
|
|
1732
|
-
* Check
|
|
1733
|
-
*
|
|
1734
|
-
* @param {
|
|
1735
|
-
* @returns {boolean}
|
|
1736
|
-
* @memberof module:
|
|
1872
|
+
* Check whether the given variable is a function or not.
|
|
1873
|
+
* If the given variable is a function, return true.
|
|
1874
|
+
* @param {*} obj - Target for checking
|
|
1875
|
+
* @returns {boolean} Is function?
|
|
1876
|
+
* @memberof module:type
|
|
1737
1877
|
*/
|
|
1738
|
-
function
|
|
1739
|
-
return
|
|
1878
|
+
function isFunction(obj) {
|
|
1879
|
+
return obj instanceof Function;
|
|
1740
1880
|
}
|
|
1741
1881
|
|
|
1742
|
-
var
|
|
1743
|
-
|
|
1744
|
-
var TAG_NAME = '[A-Za-z][A-Za-z0-9-]*';
|
|
1745
|
-
var ATTRIBUTE_NAME = '[a-zA-Z_:][a-zA-Z0-9:._-]*';
|
|
1746
|
-
var UNQUOTED_VALUE = '[^"\'=<>`\\x00-\\x20]+';
|
|
1747
|
-
var SINGLE_QUOTED_VALUE = "'[^']*'";
|
|
1748
|
-
var DOUBLE_QUOTED_VALUE = '"[^"]*"';
|
|
1749
|
-
var ATTRIBUTE_VALUE = "(?:" + UNQUOTED_VALUE + "|" + SINGLE_QUOTED_VALUE + "|" + DOUBLE_QUOTED_VALUE + ")";
|
|
1750
|
-
var ATTRIBUTE_VALUE_SPEC = "" + '(?:\\s*=\\s*' + ATTRIBUTE_VALUE + ")";
|
|
1751
|
-
var ATTRIBUTE$1 = "" + '(?:\\s+' + ATTRIBUTE_NAME + ATTRIBUTE_VALUE_SPEC + "?)";
|
|
1752
|
-
var OPEN_TAG = "<(" + TAG_NAME + ")(" + ATTRIBUTE$1 + ")*\\s*/?>";
|
|
1753
|
-
var CLOSE_TAG = "</(" + TAG_NAME + ")\\s*[>]";
|
|
1754
|
-
var HTML_TAG = "(?:" + OPEN_TAG + "|" + CLOSE_TAG + ")";
|
|
1755
|
-
var reHTMLTag = new RegExp("^" + HTML_TAG, 'i');
|
|
1756
|
-
var reBR = /<br\s*\/*>/i;
|
|
1757
|
-
var ALTERNATIVE_TAG_FOR_BR = '</p><p>';
|
|
1882
|
+
var isFunction_1 = isFunction;
|
|
1758
1883
|
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
}
|
|
1782
|
-
if (className) {
|
|
1783
|
-
result.push("" + CLS_PREFIX + className);
|
|
1784
|
-
}
|
|
1785
|
-
}
|
|
1786
|
-
return result.join(' ');
|
|
1787
|
-
}
|
|
1788
|
-
function clsWithMdPrefix() {
|
|
1789
|
-
var names = [];
|
|
1790
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1791
|
-
names[_i] = arguments[_i];
|
|
1792
|
-
}
|
|
1793
|
-
return names.map(function (className) { return CLS_PREFIX + "md-" + className; }).join(' ');
|
|
1794
|
-
}
|
|
1795
|
-
function isTextNode(node) {
|
|
1796
|
-
return (node === null || node === void 0 ? void 0 : node.nodeType) === Node.TEXT_NODE;
|
|
1797
|
-
}
|
|
1798
|
-
function isElemNode(node) {
|
|
1799
|
-
return node && node.nodeType === Node.ELEMENT_NODE;
|
|
1800
|
-
}
|
|
1801
|
-
function findNodes(element, selector) {
|
|
1802
|
-
var nodeList = toArray_1(element.querySelectorAll(selector));
|
|
1803
|
-
if (nodeList.length) {
|
|
1804
|
-
return nodeList;
|
|
1805
|
-
}
|
|
1806
|
-
return [];
|
|
1807
|
-
}
|
|
1808
|
-
function appendNodes(node, nodesToAppend) {
|
|
1809
|
-
nodesToAppend = isArray_1(nodesToAppend) ? toArray_1(nodesToAppend) : [nodesToAppend];
|
|
1810
|
-
nodesToAppend.forEach(function (nodeToAppend) {
|
|
1811
|
-
node.appendChild(nodeToAppend);
|
|
1812
|
-
});
|
|
1813
|
-
}
|
|
1814
|
-
function insertBeforeNode(insertedNode, node) {
|
|
1815
|
-
if (node.parentNode) {
|
|
1816
|
-
node.parentNode.insertBefore(insertedNode, node);
|
|
1817
|
-
}
|
|
1818
|
-
}
|
|
1819
|
-
function removeNode$1(node) {
|
|
1820
|
-
if (node.parentNode) {
|
|
1821
|
-
node.parentNode.removeChild(node);
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
function unwrapNode(node) {
|
|
1825
|
-
var result = [];
|
|
1826
|
-
while (node.firstChild) {
|
|
1827
|
-
result.push(node.firstChild);
|
|
1828
|
-
if (node.parentNode) {
|
|
1829
|
-
node.parentNode.insertBefore(node.firstChild, node);
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
removeNode$1(node);
|
|
1833
|
-
return result;
|
|
1834
|
-
}
|
|
1835
|
-
function toggleClass(element, className, state) {
|
|
1836
|
-
if (isUndefined_1(state)) {
|
|
1837
|
-
state = !hasClass_1(element, className);
|
|
1838
|
-
}
|
|
1839
|
-
var toggleFn = state ? addClass_1 : removeClass_1;
|
|
1840
|
-
toggleFn(element, className);
|
|
1841
|
-
}
|
|
1842
|
-
function createElementWith(contents, target) {
|
|
1843
|
-
var container = document.createElement('div');
|
|
1844
|
-
if (isString_1(contents)) {
|
|
1845
|
-
container.innerHTML = contents;
|
|
1846
|
-
}
|
|
1847
|
-
else {
|
|
1848
|
-
container.appendChild(contents);
|
|
1849
|
-
}
|
|
1850
|
-
var firstChild = container.firstChild;
|
|
1851
|
-
if (target) {
|
|
1852
|
-
target.appendChild(firstChild);
|
|
1853
|
-
}
|
|
1854
|
-
return firstChild;
|
|
1855
|
-
}
|
|
1856
|
-
function getOuterWidth(el) {
|
|
1857
|
-
var computed = window.getComputedStyle(el);
|
|
1858
|
-
return (['margin-left', 'margin-right'].reduce(function (acc, type) { return acc + parseInt(computed.getPropertyValue(type), 10); }, 0) + el.offsetWidth);
|
|
1859
|
-
}
|
|
1860
|
-
function closest(node, found) {
|
|
1861
|
-
var condition;
|
|
1862
|
-
if (isString_1(found)) {
|
|
1863
|
-
condition = function (target) { return matches_1(target, found); };
|
|
1864
|
-
}
|
|
1865
|
-
else {
|
|
1866
|
-
condition = function (target) { return target === found; };
|
|
1867
|
-
}
|
|
1868
|
-
while (node && node !== document) {
|
|
1869
|
-
if (isElemNode(node) && condition(node)) {
|
|
1870
|
-
return node;
|
|
1871
|
-
}
|
|
1872
|
-
node = node.parentNode;
|
|
1873
|
-
}
|
|
1874
|
-
return null;
|
|
1875
|
-
}
|
|
1876
|
-
function getTotalOffset(el, root) {
|
|
1877
|
-
var offsetTop = 0;
|
|
1878
|
-
var offsetLeft = 0;
|
|
1879
|
-
while (el && el !== root) {
|
|
1880
|
-
var top_1 = el.offsetTop, left = el.offsetLeft, offsetParent = el.offsetParent;
|
|
1881
|
-
offsetTop += top_1;
|
|
1882
|
-
offsetLeft += left;
|
|
1883
|
-
if (offsetParent === root.offsetParent) {
|
|
1884
|
-
break;
|
|
1885
|
-
}
|
|
1886
|
-
el = el.offsetParent;
|
|
1887
|
-
}
|
|
1888
|
-
return { offsetTop: offsetTop, offsetLeft: offsetLeft };
|
|
1884
|
+
var defaultCommandShortcuts = [
|
|
1885
|
+
'Enter',
|
|
1886
|
+
'Shift-Enter',
|
|
1887
|
+
'Mod-Enter',
|
|
1888
|
+
'Tab',
|
|
1889
|
+
'Shift-Tab',
|
|
1890
|
+
'Delete',
|
|
1891
|
+
'Backspace',
|
|
1892
|
+
'Mod-Delete',
|
|
1893
|
+
'Mod-Backspace',
|
|
1894
|
+
'ArrowUp',
|
|
1895
|
+
'ArrowDown',
|
|
1896
|
+
'ArrowLeft',
|
|
1897
|
+
'ArrowRight',
|
|
1898
|
+
'Mod-d',
|
|
1899
|
+
'Mod-D',
|
|
1900
|
+
'Alt-ArrowUp',
|
|
1901
|
+
'Alt-ArrowDown',
|
|
1902
|
+
];
|
|
1903
|
+
function execCommand(view, command, payload) {
|
|
1904
|
+
view.focus();
|
|
1905
|
+
return command(payload)(view.state, view.dispatch, view);
|
|
1889
1906
|
}
|
|
1890
|
-
function
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1907
|
+
var SpecManager = /** @class */ (function () {
|
|
1908
|
+
function SpecManager(specs) {
|
|
1909
|
+
this.specs = specs;
|
|
1910
|
+
}
|
|
1911
|
+
Object.defineProperty(SpecManager.prototype, "nodes", {
|
|
1912
|
+
get: function () {
|
|
1913
|
+
return this.specs
|
|
1914
|
+
.filter(function (spec) { return spec.type === 'node'; })
|
|
1915
|
+
.reduce(function (nodes, _a) {
|
|
1916
|
+
var _b;
|
|
1917
|
+
var name = _a.name, schema = _a.schema;
|
|
1918
|
+
return __assign$1(__assign$1({}, nodes), (_b = {}, _b[name] = schema, _b));
|
|
1919
|
+
}, {});
|
|
1920
|
+
},
|
|
1921
|
+
enumerable: false,
|
|
1922
|
+
configurable: true
|
|
1898
1923
|
});
|
|
1899
|
-
|
|
1900
|
-
function
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1924
|
+
Object.defineProperty(SpecManager.prototype, "marks", {
|
|
1925
|
+
get: function () {
|
|
1926
|
+
return this.specs
|
|
1927
|
+
.filter(function (spec) { return spec.type === 'mark'; })
|
|
1928
|
+
.reduce(function (marks, _a) {
|
|
1929
|
+
var _b;
|
|
1930
|
+
var name = _a.name, schema = _a.schema;
|
|
1931
|
+
return __assign$1(__assign$1({}, marks), (_b = {}, _b[name] = schema, _b));
|
|
1932
|
+
}, {});
|
|
1933
|
+
},
|
|
1934
|
+
enumerable: false,
|
|
1935
|
+
configurable: true
|
|
1936
|
+
});
|
|
1937
|
+
SpecManager.prototype.commands = function (view, addedCommands) {
|
|
1938
|
+
var specCommands = this.specs
|
|
1939
|
+
.filter(function (_a) {
|
|
1940
|
+
var commands = _a.commands;
|
|
1941
|
+
return commands;
|
|
1942
|
+
})
|
|
1943
|
+
.reduce(function (allCommands, spec) {
|
|
1944
|
+
var commands = {};
|
|
1945
|
+
var specCommand = spec.commands();
|
|
1946
|
+
if (isFunction_1(specCommand)) {
|
|
1947
|
+
commands[spec.name] = function (payload) { return execCommand(view, specCommand, payload); };
|
|
1915
1948
|
}
|
|
1916
|
-
|
|
1949
|
+
else {
|
|
1950
|
+
Object.keys(specCommand).forEach(function (name) {
|
|
1951
|
+
commands[name] = function (payload) { return execCommand(view, specCommand[name], payload); };
|
|
1952
|
+
});
|
|
1953
|
+
}
|
|
1954
|
+
return __assign$1(__assign$1({}, allCommands), commands);
|
|
1955
|
+
}, {});
|
|
1956
|
+
var defaultCommands = getDefaultCommands();
|
|
1957
|
+
Object.keys(defaultCommands).forEach(function (name) {
|
|
1958
|
+
specCommands[name] = function (payload) { return execCommand(view, defaultCommands[name], payload); };
|
|
1959
|
+
});
|
|
1960
|
+
if (addedCommands) {
|
|
1961
|
+
Object.keys(addedCommands).forEach(function (name) {
|
|
1962
|
+
specCommands[name] = function (payload) { return execCommand(view, addedCommands[name], payload); };
|
|
1963
|
+
});
|
|
1917
1964
|
}
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1965
|
+
return specCommands;
|
|
1966
|
+
};
|
|
1967
|
+
SpecManager.prototype.keymaps = function (useCommandShortcut) {
|
|
1968
|
+
var specKeymaps = this.specs.filter(function (spec) { return spec.keymaps; }).map(function (spec) { return spec.keymaps(); });
|
|
1969
|
+
return specKeymaps.map(function (keys) {
|
|
1970
|
+
if (!useCommandShortcut) {
|
|
1971
|
+
Object.keys(keys).forEach(function (key) {
|
|
1972
|
+
if (!includes(defaultCommandShortcuts, key)) {
|
|
1973
|
+
delete keys[key];
|
|
1974
|
+
}
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
return keymap(keys);
|
|
1978
|
+
});
|
|
1979
|
+
};
|
|
1980
|
+
SpecManager.prototype.setContext = function (context) {
|
|
1981
|
+
this.specs.forEach(function (spec) {
|
|
1982
|
+
spec.setContext(context);
|
|
1983
|
+
});
|
|
1984
|
+
};
|
|
1985
|
+
return SpecManager;
|
|
1986
|
+
}());
|
|
1921
1987
|
|
|
1922
1988
|
function resolveSelectionPos(selection) {
|
|
1923
1989
|
var from = selection.from, to = selection.to;
|
|
@@ -2378,34 +2444,60 @@ function getMarkForAdding(node, toastMark) {
|
|
|
2378
2444
|
return markInfo !== null && markInfo !== void 0 ? markInfo : [];
|
|
2379
2445
|
}
|
|
2380
2446
|
|
|
2447
|
+
var defaultToolbarStateKeys = [
|
|
2448
|
+
'taskList',
|
|
2449
|
+
'orderedList',
|
|
2450
|
+
'bulletList',
|
|
2451
|
+
'table',
|
|
2452
|
+
'strong',
|
|
2453
|
+
'emph',
|
|
2454
|
+
'strike',
|
|
2455
|
+
'heading',
|
|
2456
|
+
'thematicBreak',
|
|
2457
|
+
'blockQuote',
|
|
2458
|
+
'code',
|
|
2459
|
+
'codeBlock',
|
|
2460
|
+
'indent',
|
|
2461
|
+
'outdent',
|
|
2462
|
+
];
|
|
2381
2463
|
function getToolbarStateType$1(mdNode) {
|
|
2464
|
+
var type = mdNode.type;
|
|
2382
2465
|
if (isListNode$1(mdNode)) {
|
|
2383
2466
|
if (mdNode.listData.task) {
|
|
2384
2467
|
return 'taskList';
|
|
2385
2468
|
}
|
|
2386
2469
|
return mdNode.listData.type === 'ordered' ? 'orderedList' : 'bulletList';
|
|
2387
2470
|
}
|
|
2388
|
-
if (
|
|
2471
|
+
if (type.indexOf('table') !== -1) {
|
|
2389
2472
|
return 'table';
|
|
2390
2473
|
}
|
|
2391
|
-
|
|
2474
|
+
if (!includes(defaultToolbarStateKeys, type)) {
|
|
2475
|
+
return null;
|
|
2476
|
+
}
|
|
2477
|
+
return type;
|
|
2392
2478
|
}
|
|
2393
2479
|
function getToolbarState$1(targetNode) {
|
|
2394
|
-
var toolbarState = {
|
|
2480
|
+
var toolbarState = {
|
|
2481
|
+
indent: { active: false, disabled: true },
|
|
2482
|
+
outdent: { active: false, disabled: true },
|
|
2483
|
+
};
|
|
2395
2484
|
var listEnabled = true;
|
|
2396
2485
|
traverseParentNodes(targetNode, function (mdNode) {
|
|
2397
2486
|
var type = getToolbarStateType$1(mdNode);
|
|
2398
|
-
if (type
|
|
2487
|
+
if (!type) {
|
|
2399
2488
|
return;
|
|
2400
2489
|
}
|
|
2401
2490
|
if (type === 'bulletList' || type === 'orderedList') {
|
|
2491
|
+
// to apply the nearlist list state in the nested list
|
|
2402
2492
|
if (listEnabled) {
|
|
2403
|
-
toolbarState[type] = true;
|
|
2493
|
+
toolbarState[type] = { active: true };
|
|
2494
|
+
toolbarState.indent.disabled = false;
|
|
2495
|
+
toolbarState.outdent.disabled = false;
|
|
2404
2496
|
listEnabled = false;
|
|
2405
2497
|
}
|
|
2406
2498
|
}
|
|
2407
2499
|
else {
|
|
2408
|
-
toolbarState[type] = true;
|
|
2500
|
+
toolbarState[type] = { active: true };
|
|
2409
2501
|
}
|
|
2410
2502
|
});
|
|
2411
2503
|
return toolbarState;
|
|
@@ -3766,56 +3858,6 @@ var Code$1 = /** @class */ (function (_super) {
|
|
|
3766
3858
|
return Code;
|
|
3767
3859
|
}(Mark));
|
|
3768
3860
|
|
|
3769
|
-
var encoderList = [
|
|
3770
|
-
{
|
|
3771
|
-
regExp: /\(/g,
|
|
3772
|
-
encoded: '%28',
|
|
3773
|
-
escaped: '\\(',
|
|
3774
|
-
},
|
|
3775
|
-
{
|
|
3776
|
-
regExp: /\)/g,
|
|
3777
|
-
encoded: '%29',
|
|
3778
|
-
escaped: '\\)',
|
|
3779
|
-
},
|
|
3780
|
-
{
|
|
3781
|
-
regExp: /\[/g,
|
|
3782
|
-
encoded: '%5B',
|
|
3783
|
-
escaped: '\\[',
|
|
3784
|
-
},
|
|
3785
|
-
{
|
|
3786
|
-
regExp: /\]/g,
|
|
3787
|
-
encoded: '%5D',
|
|
3788
|
-
escaped: '\\]',
|
|
3789
|
-
},
|
|
3790
|
-
{
|
|
3791
|
-
regExp: /</g,
|
|
3792
|
-
encoded: '%3C',
|
|
3793
|
-
escaped: '\\<',
|
|
3794
|
-
},
|
|
3795
|
-
{
|
|
3796
|
-
regExp: />/g,
|
|
3797
|
-
encoded: '%3E',
|
|
3798
|
-
escaped: '\\>',
|
|
3799
|
-
},
|
|
3800
|
-
{
|
|
3801
|
-
regExp: / /g,
|
|
3802
|
-
encoded: '%20',
|
|
3803
|
-
escaped: ' ',
|
|
3804
|
-
},
|
|
3805
|
-
];
|
|
3806
|
-
function escapeMarkdownText(text) {
|
|
3807
|
-
return encoderList.reduce(function (result, _a) {
|
|
3808
|
-
var regExp = _a.regExp, escaped = _a.escaped;
|
|
3809
|
-
return result.replace(regExp, escaped);
|
|
3810
|
-
}, text);
|
|
3811
|
-
}
|
|
3812
|
-
function encodeMarkdownText(text) {
|
|
3813
|
-
return encoderList.reduce(function (result, _a) {
|
|
3814
|
-
var regExp = _a.regExp, encoded = _a.encoded;
|
|
3815
|
-
return result.replace(regExp, encoded);
|
|
3816
|
-
}, text);
|
|
3817
|
-
}
|
|
3818
|
-
|
|
3819
3861
|
var Link$1 = /** @class */ (function (_super) {
|
|
3820
3862
|
__extends$1(Link, _super);
|
|
3821
3863
|
function Link() {
|
|
@@ -3865,8 +3907,7 @@ var Link$1 = /** @class */ (function (_super) {
|
|
|
3865
3907
|
url = imageUrl;
|
|
3866
3908
|
syntax = '!';
|
|
3867
3909
|
}
|
|
3868
|
-
text =
|
|
3869
|
-
url = encodeMarkdownText(url);
|
|
3910
|
+
text = escapeTextForLink(text);
|
|
3870
3911
|
syntax += "[" + text + "](" + url + ")";
|
|
3871
3912
|
dispatch(tr.replaceWith(from, to, createTextNode$1(schema, syntax)));
|
|
3872
3913
|
return true;
|
|
@@ -4033,6 +4074,7 @@ var Html = /** @class */ (function (_super) {
|
|
|
4033
4074
|
return Html;
|
|
4034
4075
|
}(Mark));
|
|
4035
4076
|
|
|
4077
|
+
var customBlockSyntax = '$$';
|
|
4036
4078
|
var CustomBlock$1 = /** @class */ (function (_super) {
|
|
4037
4079
|
__extends$1(CustomBlock, _super);
|
|
4038
4080
|
function CustomBlock() {
|
|
@@ -4056,6 +4098,22 @@ var CustomBlock$1 = /** @class */ (function (_super) {
|
|
|
4056
4098
|
enumerable: false,
|
|
4057
4099
|
configurable: true
|
|
4058
4100
|
});
|
|
4101
|
+
CustomBlock.prototype.commands = function () {
|
|
4102
|
+
return function (payload) { return function (state, dispatch) {
|
|
4103
|
+
var selection = state.selection, schema = state.schema, tr = state.tr;
|
|
4104
|
+
var _a = getRangeInfo(selection), startFromOffset = _a.startFromOffset, endToOffset = _a.endToOffset;
|
|
4105
|
+
if (!(payload === null || payload === void 0 ? void 0 : payload.info)) {
|
|
4106
|
+
return false;
|
|
4107
|
+
}
|
|
4108
|
+
var customBlock = "" + customBlockSyntax + payload.info;
|
|
4109
|
+
var startNode = createTextNode$1(schema, customBlock);
|
|
4110
|
+
var endNode = createTextNode$1(schema, customBlockSyntax);
|
|
4111
|
+
tr.insert(startFromOffset, startNode).split(startFromOffset + customBlock.length);
|
|
4112
|
+
tr.split(tr.mapping.map(endToOffset)).insert(tr.mapping.map(endToOffset), endNode);
|
|
4113
|
+
dispatch(tr.setSelection(createTextSelection(tr, tr.mapping.map(endToOffset) - (customBlockSyntax.length + 2))));
|
|
4114
|
+
return true;
|
|
4115
|
+
}; };
|
|
4116
|
+
};
|
|
4059
4117
|
return CustomBlock;
|
|
4060
4118
|
}(Mark));
|
|
4061
4119
|
|
|
@@ -4150,10 +4208,14 @@ var MdEditor = /** @class */ (function (_super) {
|
|
|
4150
4208
|
var clipboardData = ev.clipboardData || window.clipboardData;
|
|
4151
4209
|
var items = clipboardData && clipboardData.items;
|
|
4152
4210
|
if (items) {
|
|
4153
|
-
var
|
|
4154
|
-
if
|
|
4155
|
-
|
|
4156
|
-
|
|
4211
|
+
var containRtfItem = toArray_1(items).some(function (item) { return item.kind === 'string' && item.type === 'text/rtf'; });
|
|
4212
|
+
// if it contains rtf, it's most likely copy paste from office -> no image
|
|
4213
|
+
if (!containRtfItem) {
|
|
4214
|
+
var imageBlob = pasteImageOnly(items);
|
|
4215
|
+
if (imageBlob) {
|
|
4216
|
+
ev.preventDefault();
|
|
4217
|
+
emitImageBlobHook(_this.eventEmitter, imageBlob, ev.type);
|
|
4218
|
+
}
|
|
4157
4219
|
}
|
|
4158
4220
|
}
|
|
4159
4221
|
});
|
|
@@ -10674,7 +10736,7 @@ var InlineParser = /** @class */ (function () {
|
|
|
10674
10736
|
var literal = textNode.literal || '';
|
|
10675
10737
|
var info = literal.split(/\s/)[0];
|
|
10676
10738
|
newNode.info = info;
|
|
10677
|
-
if (literal.length
|
|
10739
|
+
if (literal.length <= info.length) {
|
|
10678
10740
|
textNode.unlink();
|
|
10679
10741
|
}
|
|
10680
10742
|
else {
|
|
@@ -13118,7 +13180,6 @@ function filterDisallowedTags(str) {
|
|
|
13118
13180
|
return str;
|
|
13119
13181
|
}
|
|
13120
13182
|
|
|
13121
|
-
var CUSTOM_SYNTAX_LENGTH = 4;
|
|
13122
13183
|
var baseConvertors$1 = {
|
|
13123
13184
|
heading: function (node, _a) {
|
|
13124
13185
|
var entering = _a.entering;
|
|
@@ -13309,7 +13370,7 @@ var baseConvertors$1 = {
|
|
|
13309
13370
|
];
|
|
13310
13371
|
},
|
|
13311
13372
|
customInline: function (node, context, convertors) {
|
|
13312
|
-
var _a = node,
|
|
13373
|
+
var _a = node, info = _a.info, firstChild = _a.firstChild;
|
|
13313
13374
|
var nomalizedInfo = info.trim().toLowerCase();
|
|
13314
13375
|
var customConvertor = convertors[nomalizedInfo];
|
|
13315
13376
|
var entering = context.entering;
|
|
@@ -13321,13 +13382,10 @@ var baseConvertors$1 = {
|
|
|
13321
13382
|
console.warn("[@toast-ui/editor] - The error occurred when " + nomalizedInfo + " inline node was parsed in markdown renderer: " + e);
|
|
13322
13383
|
}
|
|
13323
13384
|
}
|
|
13324
|
-
var text = sourcepos[1][1] - sourcepos[0][1] + 1 === info.length + CUSTOM_SYNTAX_LENGTH
|
|
13325
|
-
? ''
|
|
13326
|
-
: info + " ";
|
|
13327
13385
|
return entering
|
|
13328
13386
|
? [
|
|
13329
13387
|
{ type: 'openTag', tagName: 'span' },
|
|
13330
|
-
{ type: 'text', content: "$$" +
|
|
13388
|
+
{ type: 'text', content: "$$" + info + (firstChild ? ' ' : '') },
|
|
13331
13389
|
]
|
|
13332
13390
|
: [
|
|
13333
13391
|
{ type: 'text', content: '$$' },
|
|
@@ -15057,7 +15115,7 @@ function sanitizeHTML(html, options) {
|
|
|
15057
15115
|
|
|
15058
15116
|
function getChildrenHTML(node, typeName) {
|
|
15059
15117
|
return node
|
|
15060
|
-
.literal.replace(new RegExp("(<\\s*" + typeName + "[^>]
|
|
15118
|
+
.literal.replace(new RegExp("(<\\s*" + typeName + "[^>]*>)|(</" + typeName + "\\s*[>])", 'ig'), '')
|
|
15061
15119
|
.trim();
|
|
15062
15120
|
}
|
|
15063
15121
|
function getHTMLAttrsByHTMLString(html) {
|
|
@@ -15372,11 +15430,11 @@ function getAdditionalPos(scrollTop, offsetTop, height, targetNodeHeight) {
|
|
|
15372
15430
|
var ratio = Math.min((scrollTop - offsetTop) / height, 1);
|
|
15373
15431
|
return ratio * targetNodeHeight;
|
|
15374
15432
|
}
|
|
15375
|
-
function getParentNodeObj(mdNode) {
|
|
15376
|
-
var el =
|
|
15433
|
+
function getParentNodeObj(previewContent, mdNode) {
|
|
15434
|
+
var el = previewContent.querySelector("[data-nodeid=\"" + mdNode.id + "\"]");
|
|
15377
15435
|
while (!el || isStyledInlineNode(mdNode)) {
|
|
15378
15436
|
mdNode = mdNode.parent;
|
|
15379
|
-
el =
|
|
15437
|
+
el = previewContent.querySelector("[data-nodeid=\"" + mdNode.id + "\"]");
|
|
15380
15438
|
}
|
|
15381
15439
|
return getNonNestableNodeObj({ mdNode: mdNode, el: el });
|
|
15382
15440
|
}
|
|
@@ -16076,7 +16134,10 @@ var TableOffsetMap = /** @class */ (function () {
|
|
|
16076
16134
|
};
|
|
16077
16135
|
TableOffsetMap.prototype.getNodeAndPos = function (rowIdx, colIdx) {
|
|
16078
16136
|
var cellInfo = this.rowInfo[rowIdx][colIdx];
|
|
16079
|
-
return {
|
|
16137
|
+
return {
|
|
16138
|
+
node: this.table.nodeAt(cellInfo.offset - this.tableStartOffset),
|
|
16139
|
+
pos: cellInfo.offset,
|
|
16140
|
+
};
|
|
16080
16141
|
};
|
|
16081
16142
|
TableOffsetMap.prototype.extendedRowspan = function (rowIdx, colIdx) {
|
|
16082
16143
|
return false;
|
|
@@ -16737,47 +16798,49 @@ function getToolbarStateType(node, parentNode) {
|
|
|
16737
16798
|
return type;
|
|
16738
16799
|
}
|
|
16739
16800
|
function setListNodeToolbarState(type, nodeTypeState) {
|
|
16740
|
-
nodeTypeState[type] = true;
|
|
16801
|
+
nodeTypeState[type] = { active: true };
|
|
16741
16802
|
LIST_TYPES.filter(function (listName) { return listName !== type; }).forEach(function (listType) {
|
|
16742
16803
|
if (nodeTypeState[listType]) {
|
|
16743
16804
|
delete nodeTypeState[listType];
|
|
16744
16805
|
}
|
|
16745
16806
|
});
|
|
16746
16807
|
}
|
|
16747
|
-
function
|
|
16748
|
-
var markTypeState = {};
|
|
16808
|
+
function setMarkTypeStates(from, to, schema, toolbarState) {
|
|
16749
16809
|
MARK_TYPES.forEach(function (type) {
|
|
16750
16810
|
var mark = schema.marks[type];
|
|
16751
16811
|
var marksAtPos = from.marksAcross(to) || [];
|
|
16752
16812
|
var foundMark = !!mark.isInSet(marksAtPos);
|
|
16753
16813
|
if (foundMark) {
|
|
16754
|
-
|
|
16814
|
+
toolbarState[type] = { active: true };
|
|
16755
16815
|
}
|
|
16756
16816
|
});
|
|
16757
|
-
return markTypeState;
|
|
16758
16817
|
}
|
|
16759
16818
|
function getToolbarState(selection, doc, schema) {
|
|
16760
16819
|
var $from = selection.$from, $to = selection.$to, from = selection.from, to = selection.to;
|
|
16761
|
-
var
|
|
16762
|
-
|
|
16820
|
+
var toolbarState = {
|
|
16821
|
+
indent: { active: false, disabled: true },
|
|
16822
|
+
outdent: { active: false, disabled: true },
|
|
16823
|
+
};
|
|
16763
16824
|
doc.nodesBetween(from, to, function (node, _, parentNode) {
|
|
16764
16825
|
var type = getToolbarStateType(node, parentNode);
|
|
16765
16826
|
if (includes(EXCEPT_TYPES, type)) {
|
|
16766
16827
|
return;
|
|
16767
16828
|
}
|
|
16768
16829
|
if (includes(LIST_TYPES, type)) {
|
|
16769
|
-
setListNodeToolbarState(type,
|
|
16830
|
+
setListNodeToolbarState(type, toolbarState);
|
|
16831
|
+
toolbarState.indent.disabled = false;
|
|
16832
|
+
toolbarState.outdent.disabled = false;
|
|
16770
16833
|
}
|
|
16771
16834
|
else if (type === 'paragraph' || type === 'text') {
|
|
16772
|
-
|
|
16835
|
+
setMarkTypeStates($from, $to, schema, toolbarState);
|
|
16773
16836
|
}
|
|
16774
16837
|
else {
|
|
16775
|
-
|
|
16838
|
+
toolbarState[type] = { active: true };
|
|
16776
16839
|
}
|
|
16777
16840
|
});
|
|
16778
|
-
return
|
|
16841
|
+
return toolbarState;
|
|
16779
16842
|
}
|
|
16780
|
-
function
|
|
16843
|
+
function toolbarStateHighlight(eventEmitter) {
|
|
16781
16844
|
return new Plugin({
|
|
16782
16845
|
view: function () {
|
|
16783
16846
|
return {
|
|
@@ -17041,6 +17104,7 @@ var CodeBlockView = /** @class */ (function () {
|
|
|
17041
17104
|
this.dom = null;
|
|
17042
17105
|
this.contentDOM = null;
|
|
17043
17106
|
this.input = null;
|
|
17107
|
+
this.timer = null;
|
|
17044
17108
|
this.handleMousedown = function (ev) {
|
|
17045
17109
|
var target = ev.target;
|
|
17046
17110
|
var style = getComputedStyle(target, ':after');
|
|
@@ -17096,7 +17160,7 @@ var CodeBlockView = /** @class */ (function () {
|
|
|
17096
17160
|
input.type = 'text';
|
|
17097
17161
|
input.value = this.node.attrs.language;
|
|
17098
17162
|
wrapper.appendChild(input);
|
|
17099
|
-
|
|
17163
|
+
this.view.dom.parentElement.appendChild(wrapper);
|
|
17100
17164
|
var wrpperWidth = wrapper.clientWidth;
|
|
17101
17165
|
css_1(wrapper, {
|
|
17102
17166
|
top: top + 10 + "px",
|
|
@@ -17106,7 +17170,10 @@ var CodeBlockView = /** @class */ (function () {
|
|
|
17106
17170
|
this.input = input;
|
|
17107
17171
|
this.input.addEventListener('blur', function () { return _this.changeLanguage(); });
|
|
17108
17172
|
this.input.addEventListener('keydown', this.handleKeydown);
|
|
17109
|
-
|
|
17173
|
+
this.clearTimer();
|
|
17174
|
+
this.timer = setTimeout(function () {
|
|
17175
|
+
_this.input.focus();
|
|
17176
|
+
});
|
|
17110
17177
|
};
|
|
17111
17178
|
CodeBlockView.prototype.bindDOMEvent = function () {
|
|
17112
17179
|
if (this.dom) {
|
|
@@ -17139,6 +17206,12 @@ var CodeBlockView = /** @class */ (function () {
|
|
|
17139
17206
|
removeNode$1(parent_1);
|
|
17140
17207
|
}
|
|
17141
17208
|
};
|
|
17209
|
+
CodeBlockView.prototype.clearTimer = function () {
|
|
17210
|
+
if (this.timer) {
|
|
17211
|
+
clearTimeout(this.timer);
|
|
17212
|
+
this.timer = null;
|
|
17213
|
+
}
|
|
17214
|
+
};
|
|
17142
17215
|
CodeBlockView.prototype.stopEvent = function () {
|
|
17143
17216
|
return true;
|
|
17144
17217
|
};
|
|
@@ -17151,6 +17224,7 @@ var CodeBlockView = /** @class */ (function () {
|
|
|
17151
17224
|
};
|
|
17152
17225
|
CodeBlockView.prototype.destroy = function () {
|
|
17153
17226
|
this.reset();
|
|
17227
|
+
this.clearTimer();
|
|
17154
17228
|
if (this.dom) {
|
|
17155
17229
|
this.dom.removeEventListener('click', this.handleMousedown);
|
|
17156
17230
|
}
|
|
@@ -18183,9 +18257,10 @@ function addParagraphBeforeTable(tr, map, schema) {
|
|
|
18183
18257
|
}
|
|
18184
18258
|
return tr.setSelection(Selection.near(tableStartPos, -1));
|
|
18185
18259
|
}
|
|
18186
|
-
function addParagraphAfterTable(tr, map, schema) {
|
|
18260
|
+
function addParagraphAfterTable(tr, map, schema, forcedAddtion) {
|
|
18261
|
+
if (forcedAddtion === void 0) { forcedAddtion = false; }
|
|
18187
18262
|
var tableEndPos = tr.doc.resolve(map.tableEndOffset);
|
|
18188
|
-
if (!tableEndPos.nodeAfter) {
|
|
18263
|
+
if (forcedAddtion || !tableEndPos.nodeAfter) {
|
|
18189
18264
|
return addParagraph(tr, tableEndPos, schema);
|
|
18190
18265
|
}
|
|
18191
18266
|
return tr.setSelection(Selection.near(tableEndPos, 1));
|
|
@@ -18590,6 +18665,29 @@ var Table = /** @class */ (function (_super) {
|
|
|
18590
18665
|
return false;
|
|
18591
18666
|
};
|
|
18592
18667
|
};
|
|
18668
|
+
Table.prototype.exitTable = function () {
|
|
18669
|
+
return function (state, dispatch) {
|
|
18670
|
+
var selection = state.selection, tr = state.tr, schema = state.schema;
|
|
18671
|
+
var $from = selection.$from;
|
|
18672
|
+
var cell = findNodeBy($from, function (_a) {
|
|
18673
|
+
var type = _a.type;
|
|
18674
|
+
return type.name === 'tableHeadCell' || type.name === 'tableBodyCell';
|
|
18675
|
+
});
|
|
18676
|
+
if (cell) {
|
|
18677
|
+
var para = findNodeBy($from, function (_a) {
|
|
18678
|
+
var type = _a.type;
|
|
18679
|
+
return type.name === 'paragraph';
|
|
18680
|
+
});
|
|
18681
|
+
if (para) {
|
|
18682
|
+
var anchor = getResolvedSelection(selection).anchor;
|
|
18683
|
+
var map = TableOffsetMap.create(anchor);
|
|
18684
|
+
dispatch(addParagraphAfterTable(tr, map, schema, true));
|
|
18685
|
+
return true;
|
|
18686
|
+
}
|
|
18687
|
+
}
|
|
18688
|
+
return false;
|
|
18689
|
+
};
|
|
18690
|
+
};
|
|
18593
18691
|
Table.prototype.commands = function () {
|
|
18594
18692
|
return {
|
|
18595
18693
|
addTable: this.addTable(),
|
|
@@ -18616,6 +18714,7 @@ var Table = /** @class */ (function (_super) {
|
|
|
18616
18714
|
'Mod-Backspace': deleteCellContent,
|
|
18617
18715
|
Delete: deleteCellContent,
|
|
18618
18716
|
'Mod-Delete': deleteCellContent,
|
|
18717
|
+
'Mod-Enter': this.exitTable(),
|
|
18619
18718
|
};
|
|
18620
18719
|
};
|
|
18621
18720
|
return Table;
|
|
@@ -18844,7 +18943,7 @@ var Image = /** @class */ (function (_super) {
|
|
|
18844
18943
|
var attrs = _a.attrs;
|
|
18845
18944
|
return [
|
|
18846
18945
|
attrs.rawHTML || 'img',
|
|
18847
|
-
__assign$1(__assign$1({ src: attrs.imageUrl }, (attrs.altText && { alt: attrs.altText })), getCustomAttrs(attrs)),
|
|
18946
|
+
__assign$1(__assign$1({ src: escapeXml$1(attrs.imageUrl) }, (attrs.altText && { alt: attrs.altText })), getCustomAttrs(attrs)),
|
|
18848
18947
|
];
|
|
18849
18948
|
},
|
|
18850
18949
|
};
|
|
@@ -18859,7 +18958,7 @@ var Image = /** @class */ (function (_super) {
|
|
|
18859
18958
|
if (!imageUrl) {
|
|
18860
18959
|
return false;
|
|
18861
18960
|
}
|
|
18862
|
-
var node = schema.nodes.image.createAndFill(__assign$1({ imageUrl:
|
|
18961
|
+
var node = schema.nodes.image.createAndFill(__assign$1({ imageUrl: imageUrl }, (altText && { altText: altText })));
|
|
18863
18962
|
dispatch(tr.replaceSelectionWith(node).scrollIntoView());
|
|
18864
18963
|
return true;
|
|
18865
18964
|
}; };
|
|
@@ -19104,7 +19203,7 @@ var Link = /** @class */ (function (_super) {
|
|
|
19104
19203
|
get: function () {
|
|
19105
19204
|
var _this = this;
|
|
19106
19205
|
return {
|
|
19107
|
-
attrs: __assign$1({ linkUrl: { default: '' },
|
|
19206
|
+
attrs: __assign$1({ linkUrl: { default: '' }, title: { default: null }, rawHTML: { default: null } }, getDefaultCustomAttrs()),
|
|
19108
19207
|
inclusive: false,
|
|
19109
19208
|
parseDOM: [
|
|
19110
19209
|
{
|
|
@@ -19113,8 +19212,9 @@ var Link = /** @class */ (function (_super) {
|
|
|
19113
19212
|
var sanitizedDOM = sanitizeHTML(dom, { RETURN_DOM_FRAGMENT: true })
|
|
19114
19213
|
.firstChild;
|
|
19115
19214
|
var href = sanitizedDOM.getAttribute('href') || '';
|
|
19215
|
+
var title = sanitizedDOM.getAttribute('title') || '';
|
|
19116
19216
|
var rawHTML = sanitizedDOM.getAttribute('data-raw-html');
|
|
19117
|
-
return __assign$1({ linkUrl: href,
|
|
19217
|
+
return __assign$1({ linkUrl: href, title: title }, (rawHTML && { rawHTML: rawHTML }));
|
|
19118
19218
|
},
|
|
19119
19219
|
},
|
|
19120
19220
|
],
|
|
@@ -19122,7 +19222,7 @@ var Link = /** @class */ (function (_super) {
|
|
|
19122
19222
|
var attrs = _a.attrs;
|
|
19123
19223
|
return [
|
|
19124
19224
|
attrs.rawHTML || 'a',
|
|
19125
|
-
__assign$1(__assign$1({ href: attrs.linkUrl }, _this.linkAttributes), getCustomAttrs(attrs)),
|
|
19225
|
+
__assign$1(__assign$1({ href: escapeXml$1(attrs.linkUrl) }, _this.linkAttributes), getCustomAttrs(attrs)),
|
|
19126
19226
|
];
|
|
19127
19227
|
},
|
|
19128
19228
|
};
|
|
@@ -19136,10 +19236,7 @@ var Link = /** @class */ (function (_super) {
|
|
|
19136
19236
|
var schema = state.schema, tr = state.tr, selection = state.selection;
|
|
19137
19237
|
var empty = selection.empty, from = selection.from, to = selection.to;
|
|
19138
19238
|
if (from && to && linkUrl) {
|
|
19139
|
-
var attrs = {
|
|
19140
|
-
linkUrl: escapeXml$1(linkUrl),
|
|
19141
|
-
linkText: escapeMarkdownText(linkText),
|
|
19142
|
-
};
|
|
19239
|
+
var attrs = { linkUrl: linkUrl };
|
|
19143
19240
|
var mark = schema.mark('link', attrs);
|
|
19144
19241
|
if (empty && linkText) {
|
|
19145
19242
|
var node = createTextNode$1(schema, linkText, mark);
|
|
@@ -19256,6 +19353,13 @@ var CustomBlock = /** @class */ (function (_super) {
|
|
|
19256
19353
|
enumerable: false,
|
|
19257
19354
|
configurable: true
|
|
19258
19355
|
});
|
|
19356
|
+
CustomBlock.prototype.commands = function () {
|
|
19357
|
+
return function (payload) { return function (state, dispatch) {
|
|
19358
|
+
return (payload === null || payload === void 0 ? void 0 : payload.info)
|
|
19359
|
+
? setBlockType(state.schema.nodes.customBlock, payload)(state, dispatch)
|
|
19360
|
+
: false;
|
|
19361
|
+
}; };
|
|
19362
|
+
};
|
|
19259
19363
|
return CustomBlock;
|
|
19260
19364
|
}(Node$2));
|
|
19261
19365
|
|
|
@@ -19277,8 +19381,10 @@ var FrontMatter = /** @class */ (function (_super) {
|
|
|
19277
19381
|
content: 'text*',
|
|
19278
19382
|
group: 'block',
|
|
19279
19383
|
code: true,
|
|
19384
|
+
defining: true,
|
|
19280
19385
|
parseDOM: [
|
|
19281
19386
|
{
|
|
19387
|
+
preserveWhitespace: 'full',
|
|
19282
19388
|
tag: 'div[data-front-matter]',
|
|
19283
19389
|
},
|
|
19284
19390
|
],
|
|
@@ -19307,6 +19413,51 @@ var FrontMatter = /** @class */ (function (_super) {
|
|
|
19307
19413
|
return FrontMatter;
|
|
19308
19414
|
}(Node$2));
|
|
19309
19415
|
|
|
19416
|
+
var HTMLComment = /** @class */ (function (_super) {
|
|
19417
|
+
__extends$1(HTMLComment, _super);
|
|
19418
|
+
function HTMLComment() {
|
|
19419
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
19420
|
+
}
|
|
19421
|
+
Object.defineProperty(HTMLComment.prototype, "name", {
|
|
19422
|
+
get: function () {
|
|
19423
|
+
return 'htmlComment';
|
|
19424
|
+
},
|
|
19425
|
+
enumerable: false,
|
|
19426
|
+
configurable: true
|
|
19427
|
+
});
|
|
19428
|
+
Object.defineProperty(HTMLComment.prototype, "schema", {
|
|
19429
|
+
get: function () {
|
|
19430
|
+
return {
|
|
19431
|
+
content: 'text*',
|
|
19432
|
+
group: 'block',
|
|
19433
|
+
code: true,
|
|
19434
|
+
defining: true,
|
|
19435
|
+
parseDOM: [{ preserveWhitespace: 'full', tag: 'div[data-html-comment]' }],
|
|
19436
|
+
toDOM: function () {
|
|
19437
|
+
return ['div', { 'data-html-comment': 'true' }, 0];
|
|
19438
|
+
},
|
|
19439
|
+
};
|
|
19440
|
+
},
|
|
19441
|
+
enumerable: false,
|
|
19442
|
+
configurable: true
|
|
19443
|
+
});
|
|
19444
|
+
HTMLComment.prototype.commands = function () {
|
|
19445
|
+
return function () { return function (state, dispatch, view) {
|
|
19446
|
+
var $from = state.selection.$from;
|
|
19447
|
+
if (view.endOfTextblock('down') && $from.node().type.name === 'htmlComment') {
|
|
19448
|
+
return exitCode(state, dispatch);
|
|
19449
|
+
}
|
|
19450
|
+
return false;
|
|
19451
|
+
}; };
|
|
19452
|
+
};
|
|
19453
|
+
HTMLComment.prototype.keymaps = function () {
|
|
19454
|
+
return {
|
|
19455
|
+
Enter: this.commands()(),
|
|
19456
|
+
};
|
|
19457
|
+
};
|
|
19458
|
+
return HTMLComment;
|
|
19459
|
+
}(Node$2));
|
|
19460
|
+
|
|
19310
19461
|
function createSpecs(linkAttributes) {
|
|
19311
19462
|
return new SpecManager([
|
|
19312
19463
|
new Doc(),
|
|
@@ -19334,6 +19485,7 @@ function createSpecs(linkAttributes) {
|
|
|
19334
19485
|
new CustomBlock(),
|
|
19335
19486
|
new FrontMatter(),
|
|
19336
19487
|
new Widget(),
|
|
19488
|
+
new HTMLComment(),
|
|
19337
19489
|
]);
|
|
19338
19490
|
}
|
|
19339
19491
|
|
|
@@ -19379,7 +19531,7 @@ var WysiwygEditor = /** @class */ (function (_super) {
|
|
|
19379
19531
|
tableSelection(),
|
|
19380
19532
|
tableContextMenu(this.eventEmitter),
|
|
19381
19533
|
task(),
|
|
19382
|
-
|
|
19534
|
+
toolbarStateHighlight(this.eventEmitter)
|
|
19383
19535
|
], this.createPluginProps()));
|
|
19384
19536
|
};
|
|
19385
19537
|
WysiwygEditor.prototype.createPluginNodeViews = function () {
|
|
@@ -19430,11 +19582,15 @@ var WysiwygEditor = /** @class */ (function (_super) {
|
|
|
19430
19582
|
paste: function (_, ev) {
|
|
19431
19583
|
var clipboardData = ev.clipboardData || window.clipboardData;
|
|
19432
19584
|
var items = clipboardData === null || clipboardData === void 0 ? void 0 : clipboardData.items;
|
|
19433
|
-
if (
|
|
19434
|
-
var
|
|
19435
|
-
if
|
|
19436
|
-
|
|
19437
|
-
|
|
19585
|
+
if (items) {
|
|
19586
|
+
var containRtfItem = toArray_1(items).some(function (item) { return item.kind === 'string' && item.type === 'text/rtf'; });
|
|
19587
|
+
// if it contains rtf, it's most likely copy paste from office -> no image
|
|
19588
|
+
if (!containRtfItem) {
|
|
19589
|
+
var imageBlob = pasteImageOnly(items);
|
|
19590
|
+
if (imageBlob) {
|
|
19591
|
+
ev.preventDefault();
|
|
19592
|
+
emitImageBlobHook(_this.eventEmitter, imageBlob, ev.type);
|
|
19593
|
+
}
|
|
19438
19594
|
}
|
|
19439
19595
|
}
|
|
19440
19596
|
return false;
|
|
@@ -19649,6 +19805,7 @@ var eventTypeList = [
|
|
|
19649
19805
|
'beforePreviewRender',
|
|
19650
19806
|
'beforeConvertWysiwygToMarkdown',
|
|
19651
19807
|
'load',
|
|
19808
|
+
'loadUI',
|
|
19652
19809
|
'change',
|
|
19653
19810
|
'caretChange',
|
|
19654
19811
|
'destroy',
|
|
@@ -20211,7 +20368,7 @@ var toWwConvertors = {
|
|
|
20211
20368
|
var link = state.schema.marks.link;
|
|
20212
20369
|
var _b = node, destination = _b.destination, title = _b.title;
|
|
20213
20370
|
if (entering) {
|
|
20214
|
-
var attrs = __assign$1(
|
|
20371
|
+
var attrs = __assign$1({ linkUrl: destination, title: title }, customAttrs);
|
|
20215
20372
|
state.openMark(link.create(attrs));
|
|
20216
20373
|
}
|
|
20217
20374
|
else {
|
|
@@ -20267,37 +20424,32 @@ var toWwConvertors = {
|
|
|
20267
20424
|
}
|
|
20268
20425
|
},
|
|
20269
20426
|
tableCell: function (state, node, _a) {
|
|
20270
|
-
var _b;
|
|
20271
20427
|
var entering = _a.entering;
|
|
20272
|
-
|
|
20273
|
-
|
|
20274
|
-
|
|
20275
|
-
|
|
20276
|
-
|
|
20277
|
-
|
|
20278
|
-
|
|
20279
|
-
|
|
20280
|
-
if (!node.ignored) {
|
|
20428
|
+
if (!node.ignored) {
|
|
20429
|
+
var hasParaNode = function (childNode) {
|
|
20430
|
+
return childNode && (isInlineNode(childNode) || isCustomHTMLInlineNode(state, childNode));
|
|
20431
|
+
};
|
|
20432
|
+
if (entering) {
|
|
20433
|
+
var _b = state.schema.nodes, tableHeadCell = _b.tableHeadCell, tableBodyCell = _b.tableBodyCell, paragraph = _b.paragraph;
|
|
20434
|
+
var tablePart = node.parent.parent;
|
|
20435
|
+
var cell = tablePart.type === 'tableHead' ? tableHeadCell : tableBodyCell;
|
|
20281
20436
|
var table = tablePart.parent;
|
|
20282
|
-
var
|
|
20283
|
-
|
|
20284
|
-
|
|
20285
|
-
attrs =
|
|
20286
|
-
|
|
20287
|
-
|
|
20288
|
-
|
|
20437
|
+
var align = (table.columns[node.startIdx] || {}).align;
|
|
20438
|
+
var attrs = __assign$1({}, node.attrs);
|
|
20439
|
+
if (align) {
|
|
20440
|
+
attrs.align = align;
|
|
20441
|
+
}
|
|
20442
|
+
state.openNode(cell, attrs);
|
|
20443
|
+
if (hasParaNode(node.firstChild)) {
|
|
20444
|
+
state.openNode(paragraph);
|
|
20289
20445
|
}
|
|
20290
20446
|
}
|
|
20291
|
-
|
|
20292
|
-
|
|
20293
|
-
|
|
20294
|
-
|
|
20295
|
-
}
|
|
20296
|
-
else {
|
|
20297
|
-
if (hasParaNode(node.lastChild)) {
|
|
20447
|
+
else {
|
|
20448
|
+
if (hasParaNode(node.lastChild)) {
|
|
20449
|
+
state.closeNode();
|
|
20450
|
+
}
|
|
20298
20451
|
state.closeNode();
|
|
20299
20452
|
}
|
|
20300
|
-
state.closeNode();
|
|
20301
20453
|
}
|
|
20302
20454
|
},
|
|
20303
20455
|
strike: function (state, _, _a, customAttrs) {
|
|
@@ -20360,26 +20512,34 @@ var toWwConvertors = {
|
|
|
20360
20512
|
htmlBlock: function (state, node) {
|
|
20361
20513
|
var html = node.literal;
|
|
20362
20514
|
var container = document.createElement('div');
|
|
20363
|
-
var
|
|
20364
|
-
|
|
20365
|
-
|
|
20366
|
-
|
|
20367
|
-
|
|
20368
|
-
// for user defined html schema
|
|
20369
|
-
if (nodeType === null || nodeType === void 0 ? void 0 : nodeType.spec.attrs.htmlBlock) {
|
|
20370
|
-
var htmlAttrs = getHTMLAttrsByHTMLString(sanitizedHTML);
|
|
20371
|
-
var childrenHTML = getChildrenHTML(node, typeName);
|
|
20372
|
-
state.addNode(nodeType, { htmlAttrs: htmlAttrs, childrenHTML: childrenHTML });
|
|
20515
|
+
var isHTMLComment = reHTMLComment.test(html);
|
|
20516
|
+
if (isHTMLComment) {
|
|
20517
|
+
state.openNode(state.schema.nodes.htmlComment);
|
|
20518
|
+
state.addText(node.literal);
|
|
20519
|
+
state.closeNode();
|
|
20373
20520
|
}
|
|
20374
20521
|
else {
|
|
20375
|
-
|
|
20376
|
-
|
|
20377
|
-
|
|
20522
|
+
var matched = html.match(reHTMLTag);
|
|
20523
|
+
var openTagName = matched[1], closeTagName = matched[3];
|
|
20524
|
+
var typeName = (openTagName || closeTagName).toLowerCase();
|
|
20525
|
+
var nodeType = state.schema.nodes[typeName];
|
|
20526
|
+
var sanitizedHTML = sanitizeHTML(html);
|
|
20527
|
+
// for user defined html schema
|
|
20528
|
+
if (nodeType === null || nodeType === void 0 ? void 0 : nodeType.spec.attrs.htmlBlock) {
|
|
20529
|
+
var htmlAttrs = getHTMLAttrsByHTMLString(sanitizedHTML);
|
|
20530
|
+
var childrenHTML = getChildrenHTML(node, typeName);
|
|
20531
|
+
state.addNode(nodeType, { htmlAttrs: htmlAttrs, childrenHTML: childrenHTML });
|
|
20532
|
+
}
|
|
20533
|
+
else {
|
|
20534
|
+
container.innerHTML = sanitizedHTML;
|
|
20535
|
+
addRawHTMLAttributeToDOM(container);
|
|
20536
|
+
state.convertByDOMParser(container);
|
|
20537
|
+
}
|
|
20378
20538
|
}
|
|
20379
20539
|
},
|
|
20380
20540
|
customInline: function (state, node, _a) {
|
|
20381
20541
|
var entering = _a.entering, skipChildren = _a.skipChildren;
|
|
20382
|
-
var info =
|
|
20542
|
+
var _b = node, info = _b.info, firstChild = _b.firstChild;
|
|
20383
20543
|
var schema = state.schema;
|
|
20384
20544
|
if (info.indexOf('widget') !== -1 && entering) {
|
|
20385
20545
|
var content = getWidgetContent(node);
|
|
@@ -20388,6 +20548,13 @@ var toWwConvertors = {
|
|
|
20388
20548
|
schema.text(createWidgetContent(info, content)),
|
|
20389
20549
|
]);
|
|
20390
20550
|
}
|
|
20551
|
+
else {
|
|
20552
|
+
var text = '$$';
|
|
20553
|
+
if (entering) {
|
|
20554
|
+
text += firstChild ? info + " " : info;
|
|
20555
|
+
}
|
|
20556
|
+
state.addText(text);
|
|
20557
|
+
}
|
|
20391
20558
|
},
|
|
20392
20559
|
};
|
|
20393
20560
|
function createWwConvertors(customConvertors) {
|
|
@@ -20403,7 +20570,7 @@ function createWwConvertors(customConvertors) {
|
|
|
20403
20570
|
var wwConvertor = toWwConvertors[type];
|
|
20404
20571
|
if (wwConvertor && !includes(['htmlBlock', 'htmlInline'], type)) {
|
|
20405
20572
|
convertors[type] = function (state, node, context) {
|
|
20406
|
-
context.origin = function () { return orgConvertors[type](node, context); };
|
|
20573
|
+
context.origin = function () { return orgConvertors[type](node, context, orgConvertors); };
|
|
20407
20574
|
var tokens = customConvertors[type](node, context);
|
|
20408
20575
|
var attrs;
|
|
20409
20576
|
if (tokens) {
|
|
@@ -20593,7 +20760,13 @@ var nodeTypeWriters = {
|
|
|
20593
20760
|
text: function (state, _a) {
|
|
20594
20761
|
var _b;
|
|
20595
20762
|
var node = _a.node;
|
|
20596
|
-
|
|
20763
|
+
var text = (_b = node.text) !== null && _b !== void 0 ? _b : '';
|
|
20764
|
+
if ((node.marks || []).some(function (mark) { return mark.type.name === 'link'; })) {
|
|
20765
|
+
state.text(escapeTextForLink(text), false);
|
|
20766
|
+
}
|
|
20767
|
+
else {
|
|
20768
|
+
state.text(text);
|
|
20769
|
+
}
|
|
20597
20770
|
},
|
|
20598
20771
|
paragraph: function (state, _a) {
|
|
20599
20772
|
var node = _a.node, parent = _a.parent, _b = _a.index, index = _b === void 0 ? 0 : _b;
|
|
@@ -20758,9 +20931,19 @@ var nodeTypeWriters = {
|
|
|
20758
20931
|
var text = _a.text;
|
|
20759
20932
|
state.write(text);
|
|
20760
20933
|
},
|
|
20761
|
-
html: function (state,
|
|
20762
|
-
var
|
|
20934
|
+
html: function (state, _a, _b) {
|
|
20935
|
+
var node = _a.node;
|
|
20936
|
+
var text = _b.text;
|
|
20937
|
+
state.write(text);
|
|
20938
|
+
if (node.attrs.htmlBlock) {
|
|
20939
|
+
state.closeBlock(node);
|
|
20940
|
+
}
|
|
20941
|
+
},
|
|
20942
|
+
htmlComment: function (state, _a, _b) {
|
|
20943
|
+
var node = _a.node;
|
|
20944
|
+
var text = _b.text;
|
|
20763
20945
|
state.write(text);
|
|
20946
|
+
state.closeBlock(node);
|
|
20764
20947
|
},
|
|
20765
20948
|
};
|
|
20766
20949
|
function write(type, _a) {
|
|
@@ -20917,13 +21100,13 @@ var toMdConvertors = {
|
|
|
20917
21100
|
image: function (_a) {
|
|
20918
21101
|
var node = _a.node;
|
|
20919
21102
|
var attrs = node.attrs;
|
|
20920
|
-
var
|
|
20921
|
-
var imageUrl =
|
|
20922
|
-
var altAttr = altText ? " alt=\"" + altText + "\"" : '';
|
|
21103
|
+
var rawHTML = attrs.rawHTML, altText = attrs.altText;
|
|
21104
|
+
var imageUrl = attrs.imageUrl.replace(/&/g, '&');
|
|
21105
|
+
var altAttr = altText ? " alt=\"" + escapeXml$1(altText) + "\"" : '';
|
|
20923
21106
|
return {
|
|
20924
|
-
rawHTML:
|
|
21107
|
+
rawHTML: rawHTML ? "<" + rawHTML + " src=\"" + escapeXml$1(imageUrl) + "\"" + altAttr + ">" : null,
|
|
20925
21108
|
attrs: {
|
|
20926
|
-
altText: altText,
|
|
21109
|
+
altText: escapeTextForLink(altText || ''),
|
|
20927
21110
|
imageUrl: imageUrl,
|
|
20928
21111
|
},
|
|
20929
21112
|
};
|
|
@@ -20986,17 +21169,17 @@ var toMdConvertors = {
|
|
|
20986
21169
|
var node = _a.node;
|
|
20987
21170
|
var entering = _b.entering;
|
|
20988
21171
|
var attrs = node.attrs;
|
|
20989
|
-
var
|
|
20990
|
-
var
|
|
21172
|
+
var title = attrs.title, rawHTML = attrs.rawHTML;
|
|
21173
|
+
var linkUrl = attrs.linkUrl.replace(/&/g, '&');
|
|
21174
|
+
var titleAttr = title ? " title=\"" + escapeXml$1(title) + "\"" : '';
|
|
20991
21175
|
if (entering) {
|
|
20992
21176
|
return {
|
|
20993
21177
|
delim: '[',
|
|
20994
|
-
rawHTML: rawHTML ? "<" + rawHTML + " href=\"" + linkUrl + "\">" : null,
|
|
21178
|
+
rawHTML: rawHTML ? "<" + rawHTML + " href=\"" + escapeXml$1(linkUrl) + "\"" + titleAttr + ">" : null,
|
|
20995
21179
|
};
|
|
20996
21180
|
}
|
|
20997
|
-
var linkText = attrs.title ? " " + quote(attrs.linkText) : '';
|
|
20998
21181
|
return {
|
|
20999
|
-
delim: "](" +
|
|
21182
|
+
delim: "](" + linkUrl + (title ? " " + quote(escapeTextForLink(title)) : '') + ")",
|
|
21000
21183
|
rawHTML: getCloseRawHTML(rawHTML),
|
|
21001
21184
|
};
|
|
21002
21185
|
},
|
|
@@ -21014,6 +21197,12 @@ var toMdConvertors = {
|
|
|
21014
21197
|
rawHTML: rawHTML,
|
|
21015
21198
|
};
|
|
21016
21199
|
},
|
|
21200
|
+
htmlComment: function (_a) {
|
|
21201
|
+
var node = _a.node;
|
|
21202
|
+
return {
|
|
21203
|
+
text: node.textContent,
|
|
21204
|
+
};
|
|
21205
|
+
},
|
|
21017
21206
|
// html inline node, html block node
|
|
21018
21207
|
html: function (_a, _b) {
|
|
21019
21208
|
var node = _a.node;
|
|
@@ -21690,7 +21879,7 @@ function createMdLikeNode(node) {
|
|
|
21690
21879
|
};
|
|
21691
21880
|
var nodeTypeMap = {
|
|
21692
21881
|
heading: { level: attrs.level },
|
|
21693
|
-
link: { destination: attrs.linkUrl, title: attrs.
|
|
21882
|
+
link: { destination: attrs.linkUrl, title: attrs.title },
|
|
21694
21883
|
image: { destination: attrs.imageUrl },
|
|
21695
21884
|
codeBlock: { info: attrs.language },
|
|
21696
21885
|
bulletList: { type: 'list', listData: { type: 'bullet' } },
|
|
@@ -21828,6 +22017,7 @@ var ScrollSync = /** @class */ (function () {
|
|
|
21828
22017
|
this.latestPreviewScrollTop = null;
|
|
21829
22018
|
this.blockedScroll = null;
|
|
21830
22019
|
this.active = true;
|
|
22020
|
+
this.timer = null;
|
|
21831
22021
|
var previewRoot = preview.previewContent, previewEl = preview.el;
|
|
21832
22022
|
this.previewRoot = previewRoot;
|
|
21833
22023
|
this.previewEl = previewEl;
|
|
@@ -21840,10 +22030,11 @@ var ScrollSync = /** @class */ (function () {
|
|
|
21840
22030
|
ScrollSync.prototype.addScrollSyncEvent = function () {
|
|
21841
22031
|
var _this = this;
|
|
21842
22032
|
this.eventEmitter.listen('afterPreviewRender', function () {
|
|
22033
|
+
_this.clearTimer();
|
|
21843
22034
|
// Immediately after the 'afterPreviewRender' event has occurred,
|
|
21844
22035
|
// browser rendering is not yet complete.
|
|
21845
22036
|
// So the size of elements can not be accurately measured.
|
|
21846
|
-
setTimeout(function () {
|
|
22037
|
+
_this.timer = setTimeout(function () {
|
|
21847
22038
|
_this.syncPreviewScrollTop(true);
|
|
21848
22039
|
}, 200);
|
|
21849
22040
|
});
|
|
@@ -21870,7 +22061,7 @@ var ScrollSync = /** @class */ (function () {
|
|
|
21870
22061
|
var pos = this.mdEditor.getSelection();
|
|
21871
22062
|
var firstMdNode = this.toastMark.findFirstNodeAtLine(pos[0][0]);
|
|
21872
22063
|
var previewHeight = this.previewEl.clientHeight;
|
|
21873
|
-
var el = getParentNodeObj(firstMdNode).el;
|
|
22064
|
+
var el = getParentNodeObj(this.previewRoot, firstMdNode).el;
|
|
21874
22065
|
var totalOffsetTop = getTotalOffsetTop(el, this.previewRoot) || el.offsetTop;
|
|
21875
22066
|
var nodeHeight = el.clientHeight;
|
|
21876
22067
|
// multiply 0.5 for calculating the position in the middle of preview area
|
|
@@ -21902,7 +22093,7 @@ var ScrollSync = /** @class */ (function () {
|
|
|
21902
22093
|
targetScrollTop = scrollTopByEditing;
|
|
21903
22094
|
}
|
|
21904
22095
|
else {
|
|
21905
|
-
var _d = getParentNodeObj(firstMdNode), el = _d.el, mdNode = _d.mdNode;
|
|
22096
|
+
var _d = getParentNodeObj(this.previewRoot, firstMdNode), el = _d.el, mdNode = _d.mdNode;
|
|
21906
22097
|
var _e = getEditorRangeHeightInfo(doc, mdNode, children), height = _e.height, rect = _e.rect;
|
|
21907
22098
|
var totalOffsetTop = getTotalOffsetTop(el, previewRoot) || el.offsetTop;
|
|
21908
22099
|
var nodeHeight = el.clientHeight;
|
|
@@ -21930,7 +22121,7 @@ var ScrollSync = /** @class */ (function () {
|
|
|
21930
22121
|
}
|
|
21931
22122
|
var children = dom.children;
|
|
21932
22123
|
var mdNodeId = Number(targetNode.getAttribute('data-nodeid'));
|
|
21933
|
-
var _b = getParentNodeObj(toastMark.findNodeById(mdNodeId)), mdNode = _b.mdNode, el = _b.el;
|
|
22124
|
+
var _b = getParentNodeObj(this.previewRoot, toastMark.findNodeById(mdNodeId)), mdNode = _b.mdNode, el = _b.el;
|
|
21934
22125
|
var mdNodeStartLine = getMdStartLine(mdNode);
|
|
21935
22126
|
targetScrollTop = children[mdNodeStartLine - 1].offsetTop;
|
|
21936
22127
|
var height = getEditorRangeHeightInfo(state.doc, mdNode, children).height;
|
|
@@ -21969,7 +22160,14 @@ var ScrollSync = /** @class */ (function () {
|
|
|
21969
22160
|
};
|
|
21970
22161
|
animate(curScrollTop, targetScrollTop, syncCallbacks);
|
|
21971
22162
|
};
|
|
22163
|
+
ScrollSync.prototype.clearTimer = function () {
|
|
22164
|
+
if (this.timer) {
|
|
22165
|
+
clearTimeout(this.timer);
|
|
22166
|
+
this.timer = null;
|
|
22167
|
+
}
|
|
22168
|
+
};
|
|
21972
22169
|
ScrollSync.prototype.destroy = function () {
|
|
22170
|
+
this.clearTimer();
|
|
21973
22171
|
this.eventEmitter.removeEventHandler('scroll');
|
|
21974
22172
|
this.eventEmitter.removeEventHandler('afterPreviewRender');
|
|
21975
22173
|
};
|
|
@@ -22133,7 +22331,15 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
22133
22331
|
this.moveCursorToStart(this.options.autofocus);
|
|
22134
22332
|
}
|
|
22135
22333
|
ToastUIEditorCore.prototype.addInitEvent = function () {
|
|
22334
|
+
var _this = this;
|
|
22136
22335
|
this.on('needChangeMode', this.changeMode.bind(this));
|
|
22336
|
+
this.on('loadUI', function () {
|
|
22337
|
+
if (_this.height !== 'auto') {
|
|
22338
|
+
// 75px equals default editor ui height - the editing area height
|
|
22339
|
+
var minHeight = Math.min(parseInt(_this.minHeight, 10), parseInt(_this.height, 10) - 75) + "px";
|
|
22340
|
+
_this.setMinHeight(minHeight);
|
|
22341
|
+
}
|
|
22342
|
+
});
|
|
22137
22343
|
addDefaultImageBlobHook(this.eventEmitter);
|
|
22138
22344
|
};
|
|
22139
22345
|
ToastUIEditorCore.prototype.addInitCommand = function (mdCommands, wwCommands) {
|
|
@@ -22405,12 +22611,11 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
22405
22611
|
if (isString_1(height)) {
|
|
22406
22612
|
if (height === 'auto') {
|
|
22407
22613
|
addClass_1(el, 'auto-height');
|
|
22408
|
-
this.setMinHeight(this.getMinHeight());
|
|
22409
22614
|
}
|
|
22410
22615
|
else {
|
|
22411
22616
|
removeClass_1(el, 'auto-height');
|
|
22412
|
-
this.setMinHeight(height);
|
|
22413
22617
|
}
|
|
22618
|
+
this.setMinHeight(this.getMinHeight());
|
|
22414
22619
|
}
|
|
22415
22620
|
css_1(el, { height: height });
|
|
22416
22621
|
this.height = height;
|
|
@@ -22427,16 +22632,18 @@ var ToastUIEditorCore = /** @class */ (function () {
|
|
|
22427
22632
|
* @param {string} minHeight - min content height in pixel
|
|
22428
22633
|
*/
|
|
22429
22634
|
ToastUIEditorCore.prototype.setMinHeight = function (minHeight) {
|
|
22430
|
-
|
|
22431
|
-
|
|
22432
|
-
|
|
22433
|
-
|
|
22434
|
-
|
|
22435
|
-
|
|
22436
|
-
|
|
22437
|
-
|
|
22438
|
-
|
|
22439
|
-
|
|
22635
|
+
if (minHeight !== this.minHeight) {
|
|
22636
|
+
var height = this.height || this.options.height;
|
|
22637
|
+
if (height !== 'auto' && this.options.el.querySelector("." + cls('main'))) {
|
|
22638
|
+
// 75px equals default editor ui height - the editing area height
|
|
22639
|
+
minHeight = Math.min(parseInt(minHeight, 10), parseInt(height, 10) - 75) + "px";
|
|
22640
|
+
}
|
|
22641
|
+
var minHeightNum = parseInt(minHeight, 10);
|
|
22642
|
+
this.minHeight = minHeight;
|
|
22643
|
+
this.wwEditor.setMinHeight(minHeightNum);
|
|
22644
|
+
this.mdEditor.setMinHeight(minHeightNum);
|
|
22645
|
+
this.preview.setMinHeight(minHeightNum);
|
|
22646
|
+
}
|
|
22440
22647
|
};
|
|
22441
22648
|
/**
|
|
22442
22649
|
* Get minimum height of editor content
|
|
@@ -24657,6 +24864,7 @@ function createDefaultToolbarItemInfo(type) {
|
|
|
24657
24864
|
className: 'indent',
|
|
24658
24865
|
command: 'indent',
|
|
24659
24866
|
tooltip: i18n.get('Indent'),
|
|
24867
|
+
state: 'indent',
|
|
24660
24868
|
};
|
|
24661
24869
|
break;
|
|
24662
24870
|
case 'outdent':
|
|
@@ -24665,6 +24873,7 @@ function createDefaultToolbarItemInfo(type) {
|
|
|
24665
24873
|
className: 'outdent',
|
|
24666
24874
|
command: 'outdent',
|
|
24667
24875
|
tooltip: i18n.get('Outdent'),
|
|
24876
|
+
state: 'outdent',
|
|
24668
24877
|
};
|
|
24669
24878
|
break;
|
|
24670
24879
|
case 'scrollSync':
|
|
@@ -24815,7 +25024,7 @@ function connectHOC(WrappedComponent) {
|
|
|
24815
25024
|
_this.hideTooltip = function () {
|
|
24816
25025
|
css_1(_this.props.tooltipRef.current, 'display', 'none');
|
|
24817
25026
|
};
|
|
24818
|
-
_this.state = { active: false };
|
|
25027
|
+
_this.state = { active: false, disabled: props.disabled };
|
|
24819
25028
|
_this.addEvent();
|
|
24820
25029
|
return _this;
|
|
24821
25030
|
}
|
|
@@ -24824,9 +25033,10 @@ function connectHOC(WrappedComponent) {
|
|
|
24824
25033
|
var _a = this.props, item = _a.item, eventEmitter = _a.eventEmitter;
|
|
24825
25034
|
if (item.state) {
|
|
24826
25035
|
eventEmitter.listen('changeToolbarState', function (_a) {
|
|
25036
|
+
var _b;
|
|
24827
25037
|
var toolbarState = _a.toolbarState;
|
|
24828
|
-
var
|
|
24829
|
-
_this.setState({ active: active });
|
|
25038
|
+
var _c = (_b = toolbarState[item.state]) !== null && _b !== void 0 ? _b : {}, active = _c.active, disabled = _c.disabled;
|
|
25039
|
+
_this.setState({ active: !!active, disabled: disabled !== null && disabled !== void 0 ? disabled : _this.props.disabled });
|
|
24830
25040
|
});
|
|
24831
25041
|
}
|
|
24832
25042
|
};
|
|
@@ -24835,7 +25045,7 @@ function connectHOC(WrappedComponent) {
|
|
|
24835
25045
|
return { left: offsetLeft, top: el.offsetHeight + offsetTop };
|
|
24836
25046
|
};
|
|
24837
25047
|
ButtonHOC.prototype.render = function () {
|
|
24838
|
-
return html(templateObject_1$8 || (templateObject_1$8 = __makeTemplateObject(["\n <", "\n ...", "\n active=", "\n showTooltip=", "\n hideTooltip=", "\n getBound=", "\n />\n "], ["\n <", "\n ...", "\n active=", "\n showTooltip=", "\n hideTooltip=", "\n getBound=", "\n />\n "])), WrappedComponent, this.props, this.state.active, this.showTooltip, this.hideTooltip, this.getBound);
|
|
25048
|
+
return html(templateObject_1$8 || (templateObject_1$8 = __makeTemplateObject(["\n <", "\n ...", "\n active=", "\n showTooltip=", "\n hideTooltip=", "\n getBound=", "\n disabled=", "\n />\n "], ["\n <", "\n ...", "\n active=", "\n showTooltip=", "\n hideTooltip=", "\n getBound=", "\n disabled=", "\n />\n "])), WrappedComponent, this.props, this.state.active, this.showTooltip, this.hideTooltip, this.getBound, this.state.disabled || this.props.disabled);
|
|
24839
25049
|
};
|
|
24840
25050
|
return ButtonHOC;
|
|
24841
25051
|
}(Component));
|
|
@@ -25046,7 +25256,7 @@ var Toolbar = /** @class */ (function (_super) {
|
|
|
25046
25256
|
};
|
|
25047
25257
|
_this.openPopup = function (popupName, initialValues) {
|
|
25048
25258
|
if (initialValues === void 0) { initialValues = {}; }
|
|
25049
|
-
var el =
|
|
25259
|
+
var el = _this.refs.el.querySelector("." + cls('toolbar-group') + " ." + popupName);
|
|
25050
25260
|
if (el) {
|
|
25051
25261
|
var _a = getTotalOffset(el, closest(el, "." + cls('toolbar'))), offsetLeft = _a.offsetLeft, offsetTop = _a.offsetTop;
|
|
25052
25262
|
var info = createPopupInfo(popupName, {
|
|
@@ -25389,6 +25599,7 @@ var ToastUIEditor = /** @class */ (function (_super) {
|
|
|
25389
25599
|
var groupIndex = toolbarItem.groupIndex, itemIndex = toolbarItem.itemIndex, item = toolbarItem.item;
|
|
25390
25600
|
_this.defaultUI.insertToolbarItem({ groupIndex: groupIndex, itemIndex: itemIndex }, item);
|
|
25391
25601
|
});
|
|
25602
|
+
_this.eventEmitter.emit('loadUI', _this);
|
|
25392
25603
|
return _this;
|
|
25393
25604
|
}
|
|
25394
25605
|
/**
|
|
@@ -25480,5 +25691,4 @@ ToastUIEditorCore.setLanguage(['en', 'en-US'], {
|
|
|
25480
25691
|
'Choose language': 'Choose language',
|
|
25481
25692
|
});
|
|
25482
25693
|
|
|
25483
|
-
export default
|
|
25484
|
-
export { ToastUIEditor as Editor, ToastUIEditorCore as EditorCore };
|
|
25694
|
+
export { ToastUIEditor as Editor, ToastUIEditorCore as EditorCore, ToastUIEditor as default };
|