@toast-ui/editor 3.1.1 → 3.1.4

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.
Files changed (58) hide show
  1. package/dist/esm/i18n/ar.js +2 -2
  2. package/dist/esm/i18n/cs-cz.js +2 -2
  3. package/dist/esm/i18n/de-de.js +4 -4
  4. package/dist/esm/i18n/en-us.js +3 -3
  5. package/dist/esm/i18n/es-es.js +2 -2
  6. package/dist/esm/i18n/fi-fi.js +2 -2
  7. package/dist/esm/i18n/fr-fr.js +2 -2
  8. package/dist/esm/i18n/gl-es.js +2 -2
  9. package/dist/esm/i18n/hr-hr.js +2 -2
  10. package/dist/esm/i18n/i18n.js +4 -5
  11. package/dist/esm/i18n/it-it.js +2 -2
  12. package/dist/esm/i18n/ja-jp.js +3 -3
  13. package/dist/esm/i18n/ko-kr.js +3 -3
  14. package/dist/esm/i18n/nb-no.js +2 -2
  15. package/dist/esm/i18n/nl-nl.js +3 -3
  16. package/dist/esm/i18n/pl-pl.js +2 -2
  17. package/dist/esm/i18n/pt-br.js +2 -2
  18. package/dist/esm/i18n/ru-ru.js +2 -2
  19. package/dist/esm/i18n/sv-se.js +2 -2
  20. package/dist/esm/i18n/tr-tr.js +2 -2
  21. package/dist/esm/i18n/uk-ua.js +2 -2
  22. package/dist/esm/i18n/zh-cn.js +3 -3
  23. package/dist/esm/i18n/zh-tw.js +2 -2
  24. package/dist/esm/index.js +990 -703
  25. package/dist/esm/indexViewer.js +34 -18
  26. package/dist/i18n/ar.js +6 -6
  27. package/dist/i18n/cs-cz.js +6 -6
  28. package/dist/i18n/de-de.js +8 -8
  29. package/dist/i18n/es-es.js +6 -6
  30. package/dist/i18n/fi-fi.js +6 -6
  31. package/dist/i18n/fr-fr.js +6 -6
  32. package/dist/i18n/gl-es.js +6 -6
  33. package/dist/i18n/hr-hr.js +6 -6
  34. package/dist/i18n/it-it.js +6 -6
  35. package/dist/i18n/ja-jp.js +7 -7
  36. package/dist/i18n/ko-kr.js +7 -7
  37. package/dist/i18n/nb-no.js +6 -6
  38. package/dist/i18n/nl-nl.js +7 -7
  39. package/dist/i18n/pl-pl.js +6 -6
  40. package/dist/i18n/pt-br.js +6 -6
  41. package/dist/i18n/ru-ru.js +6 -6
  42. package/dist/i18n/sv-se.js +6 -6
  43. package/dist/i18n/tr-tr.js +6 -6
  44. package/dist/i18n/uk-ua.js +6 -6
  45. package/dist/i18n/zh-cn.js +7 -7
  46. package/dist/i18n/zh-tw.js +6 -6
  47. package/dist/toastui-editor-only.css +2 -2
  48. package/dist/toastui-editor-viewer.css +7 -7
  49. package/dist/toastui-editor-viewer.js +98 -43
  50. package/dist/toastui-editor.css +7 -7
  51. package/dist/toastui-editor.js +1021 -726
  52. package/package.json +4 -3
  53. package/types/editor.d.ts +9 -1
  54. package/types/event.d.ts +2 -0
  55. package/types/index.d.ts +1 -1
  56. package/types/spec.d.ts +1 -1
  57. package/types/ui.d.ts +22 -20
  58. package/types/wysiwyg.d.ts +2 -1
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * @toast-ui/editor
3
- * @version 3.1.1 | Wed Oct 27 2021
4
- * @author NHN FE Development Lab <dl_javascript@nhn.com>
3
+ * @version 3.1.4 | Thu Apr 14 2022
4
+ * @author NHN Cloud FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
7
7
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -13,7 +13,7 @@
13
13
  exports["toastui"] = factory(require("prosemirror-commands"), require("prosemirror-history"), require("prosemirror-inputrules"), require("prosemirror-keymap"), require("prosemirror-model"), require("prosemirror-state"), require("prosemirror-transform"), require("prosemirror-view"));
14
14
  else
15
15
  root["toastui"] = root["toastui"] || {}, root["toastui"]["Editor"] = factory(root[undefined], root[undefined], root[undefined], root[undefined], root[undefined], root[undefined], root[undefined], root[undefined]);
16
- })(self, function(__WEBPACK_EXTERNAL_MODULE__818__, __WEBPACK_EXTERNAL_MODULE__168__, __WEBPACK_EXTERNAL_MODULE__925__, __WEBPACK_EXTERNAL_MODULE__703__, __WEBPACK_EXTERNAL_MODULE__959__, __WEBPACK_EXTERNAL_MODULE__676__, __WEBPACK_EXTERNAL_MODULE__747__, __WEBPACK_EXTERNAL_MODULE__754__) {
16
+ })(self, function(__WEBPACK_EXTERNAL_MODULE__695__, __WEBPACK_EXTERNAL_MODULE__412__, __WEBPACK_EXTERNAL_MODULE__479__, __WEBPACK_EXTERNAL_MODULE__481__, __WEBPACK_EXTERNAL_MODULE__43__, __WEBPACK_EXTERNAL_MODULE__814__, __WEBPACK_EXTERNAL_MODULE__785__, __WEBPACK_EXTERNAL_MODULE__311__) {
17
17
  return /******/ (function() { // webpackBootstrap
18
18
  /******/ var __webpack_modules__ = ({
19
19
 
@@ -2961,67 +2961,67 @@ module.exports = isUndefined;
2961
2961
 
2962
2962
  /***/ }),
2963
2963
 
2964
- /***/ 818:
2964
+ /***/ 695:
2965
2965
  /***/ (function(module) {
2966
2966
 
2967
2967
  "use strict";
2968
- module.exports = __WEBPACK_EXTERNAL_MODULE__818__;
2968
+ module.exports = __WEBPACK_EXTERNAL_MODULE__695__;
2969
2969
 
2970
2970
  /***/ }),
2971
2971
 
2972
- /***/ 168:
2972
+ /***/ 412:
2973
2973
  /***/ (function(module) {
2974
2974
 
2975
2975
  "use strict";
2976
- module.exports = __WEBPACK_EXTERNAL_MODULE__168__;
2976
+ module.exports = __WEBPACK_EXTERNAL_MODULE__412__;
2977
2977
 
2978
2978
  /***/ }),
2979
2979
 
2980
- /***/ 925:
2980
+ /***/ 479:
2981
2981
  /***/ (function(module) {
2982
2982
 
2983
2983
  "use strict";
2984
- module.exports = __WEBPACK_EXTERNAL_MODULE__925__;
2984
+ module.exports = __WEBPACK_EXTERNAL_MODULE__479__;
2985
2985
 
2986
2986
  /***/ }),
2987
2987
 
2988
- /***/ 703:
2988
+ /***/ 481:
2989
2989
  /***/ (function(module) {
2990
2990
 
2991
2991
  "use strict";
2992
- module.exports = __WEBPACK_EXTERNAL_MODULE__703__;
2992
+ module.exports = __WEBPACK_EXTERNAL_MODULE__481__;
2993
2993
 
2994
2994
  /***/ }),
2995
2995
 
2996
- /***/ 959:
2996
+ /***/ 43:
2997
2997
  /***/ (function(module) {
2998
2998
 
2999
2999
  "use strict";
3000
- module.exports = __WEBPACK_EXTERNAL_MODULE__959__;
3000
+ module.exports = __WEBPACK_EXTERNAL_MODULE__43__;
3001
3001
 
3002
3002
  /***/ }),
3003
3003
 
3004
- /***/ 676:
3004
+ /***/ 814:
3005
3005
  /***/ (function(module) {
3006
3006
 
3007
3007
  "use strict";
3008
- module.exports = __WEBPACK_EXTERNAL_MODULE__676__;
3008
+ module.exports = __WEBPACK_EXTERNAL_MODULE__814__;
3009
3009
 
3010
3010
  /***/ }),
3011
3011
 
3012
- /***/ 747:
3012
+ /***/ 785:
3013
3013
  /***/ (function(module) {
3014
3014
 
3015
3015
  "use strict";
3016
- module.exports = __WEBPACK_EXTERNAL_MODULE__747__;
3016
+ module.exports = __WEBPACK_EXTERNAL_MODULE__785__;
3017
3017
 
3018
3018
  /***/ }),
3019
3019
 
3020
- /***/ 754:
3020
+ /***/ 311:
3021
3021
  /***/ (function(module) {
3022
3022
 
3023
3023
  "use strict";
3024
- module.exports = __WEBPACK_EXTERNAL_MODULE__754__;
3024
+ module.exports = __WEBPACK_EXTERNAL_MODULE__311__;
3025
3025
 
3026
3026
  /***/ })
3027
3027
 
@@ -3348,7 +3348,7 @@ function __classPrivateFieldSet(receiver, state, value, kind, f) {
3348
3348
  }
3349
3349
 
3350
3350
  // EXTERNAL MODULE: external {"commonjs":"prosemirror-model","commonjs2":"prosemirror-model","amd":"prosemirror-model"}
3351
- var external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_ = __webpack_require__(959);
3351
+ var external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_ = __webpack_require__(43);
3352
3352
  // EXTERNAL MODULE: ../../node_modules/tui-code-snippet/collection/forEachOwnProperties.js
3353
3353
  var forEachOwnProperties = __webpack_require__(956);
3354
3354
  var forEachOwnProperties_default = /*#__PURE__*/__webpack_require__.n(forEachOwnProperties);
@@ -3388,9 +3388,33 @@ var sendHostname_default = /*#__PURE__*/__webpack_require__.n(sendHostname);
3388
3388
  var isMac = /Mac/.test(navigator.platform);
3389
3389
  var reSpaceMoreThanOne = /[\u0020]+/g;
3390
3390
  var reEscapeChars = /[>(){}[\]+-.!#|]/g;
3391
- 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;
3391
+ 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;
3392
3392
  var reEscapeBackSlash = /\\[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~\\]/g;
3393
3393
  var reEscapePairedChars = /[*_~`]/g;
3394
+ var reMdImageSyntax = /!\[.*\]\(.*\)/g;
3395
+ var reEscapedCharInLinkSyntax = /[[\]]/g; //
3396
+ var XMLSPECIAL = '[&<>"]';
3397
+ var reXmlSpecial = new RegExp(XMLSPECIAL, 'g');
3398
+ function replaceUnsafeChar(char) {
3399
+ switch (char) {
3400
+ case '&':
3401
+ return '&amp;';
3402
+ case '<':
3403
+ return '&lt;';
3404
+ case '>':
3405
+ return '&gt;';
3406
+ case '"':
3407
+ return '&quot;';
3408
+ default:
3409
+ return char;
3410
+ }
3411
+ }
3412
+ function escapeXml(text) {
3413
+ if (reXmlSpecial.test(text)) {
3414
+ return text.replace(reXmlSpecial, replaceUnsafeChar);
3415
+ }
3416
+ return text;
3417
+ }
3394
3418
  function sendHostName() {
3395
3419
  sendHostname_default()('editor', 'UA-129966929-1');
3396
3420
  }
@@ -3440,6 +3464,18 @@ function isNeedEscapeText(text) {
3440
3464
  });
3441
3465
  return needEscape;
3442
3466
  }
3467
+ function escapeTextForLink(text) {
3468
+ var imageSyntaxRanges = [];
3469
+ var result = reMdImageSyntax.exec(text);
3470
+ while (result) {
3471
+ imageSyntaxRanges.push([result.index, result.index + result[0].length]);
3472
+ result = reMdImageSyntax.exec(text);
3473
+ }
3474
+ return text.replace(reEscapedCharInLinkSyntax, function (matched, offset) {
3475
+ var isDelimiter = imageSyntaxRanges.some(function (range) { return offset > range[0] && offset < range[1]; });
3476
+ return isDelimiter ? matched : "\\" + matched;
3477
+ });
3478
+ }
3443
3479
  function common_escape(text) {
3444
3480
  var replacer = function (matched) { return "\\" + matched; };
3445
3481
  var escapedText = text.replace(reSpaceMoreThanOne, ' ');
@@ -3563,19 +3599,22 @@ function getSortedNumPair(valueA, valueB) {
3563
3599
  }
3564
3600
 
3565
3601
  // EXTERNAL MODULE: external {"commonjs":"prosemirror-view","commonjs2":"prosemirror-view","amd":"prosemirror-view"}
3566
- var external_commonjs_prosemirror_view_commonjs2_prosemirror_view_amd_prosemirror_view_ = __webpack_require__(754);
3602
+ var external_commonjs_prosemirror_view_commonjs2_prosemirror_view_amd_prosemirror_view_ = __webpack_require__(311);
3567
3603
  // EXTERNAL MODULE: external {"commonjs":"prosemirror-transform","commonjs2":"prosemirror-transform","amd":"prosemirror-transform"}
3568
- var external_commonjs_prosemirror_transform_commonjs2_prosemirror_transform_amd_prosemirror_transform_ = __webpack_require__(747);
3604
+ var external_commonjs_prosemirror_transform_commonjs2_prosemirror_transform_amd_prosemirror_transform_ = __webpack_require__(785);
3605
+ // EXTERNAL MODULE: ../../node_modules/tui-code-snippet/collection/toArray.js
3606
+ var collection_toArray = __webpack_require__(990);
3607
+ var toArray_default = /*#__PURE__*/__webpack_require__.n(collection_toArray);
3569
3608
  // EXTERNAL MODULE: external {"commonjs":"prosemirror-state","commonjs2":"prosemirror-state","amd":"prosemirror-state"}
3570
- var external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_ = __webpack_require__(676);
3609
+ var external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_ = __webpack_require__(814);
3571
3610
  // EXTERNAL MODULE: external {"commonjs":"prosemirror-keymap","commonjs2":"prosemirror-keymap","amd":"prosemirror-keymap"}
3572
- var external_commonjs_prosemirror_keymap_commonjs2_prosemirror_keymap_amd_prosemirror_keymap_ = __webpack_require__(703);
3611
+ var external_commonjs_prosemirror_keymap_commonjs2_prosemirror_keymap_amd_prosemirror_keymap_ = __webpack_require__(481);
3573
3612
  // EXTERNAL MODULE: external {"commonjs":"prosemirror-commands","commonjs2":"prosemirror-commands","amd":"prosemirror-commands"}
3574
- var external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_ = __webpack_require__(818);
3613
+ var external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_ = __webpack_require__(695);
3575
3614
  // EXTERNAL MODULE: external {"commonjs":"prosemirror-inputrules","commonjs2":"prosemirror-inputrules","amd":"prosemirror-inputrules"}
3576
- var external_commonjs_prosemirror_inputrules_commonjs2_prosemirror_inputrules_amd_prosemirror_inputrules_ = __webpack_require__(925);
3615
+ var external_commonjs_prosemirror_inputrules_commonjs2_prosemirror_inputrules_amd_prosemirror_inputrules_ = __webpack_require__(479);
3577
3616
  // EXTERNAL MODULE: external {"commonjs":"prosemirror-history","commonjs2":"prosemirror-history","amd":"prosemirror-history"}
3578
- var external_commonjs_prosemirror_history_commonjs2_prosemirror_history_amd_prosemirror_history_ = __webpack_require__(168);
3617
+ var external_commonjs_prosemirror_history_commonjs2_prosemirror_history_amd_prosemirror_history_ = __webpack_require__(412);
3579
3618
  ;// CONCATENATED MODULE: ./src/helper/manipulation.ts
3580
3619
 
3581
3620
 
@@ -3934,185 +3973,439 @@ function placeholder(options) {
3934
3973
  });
3935
3974
  }
3936
3975
 
3937
- ;// CONCATENATED MODULE: ./src/plugins/popupWidget.ts
3938
-
3939
-
3940
- var pluginKey = new external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.PluginKey('widget');
3941
- var PopupWidget = /** @class */ (function () {
3942
- function PopupWidget(eventEmitter) {
3943
- var _this = this;
3944
- this.popup = null;
3945
- this.removeWidget = function () {
3946
- if (_this.popup) {
3947
- document.body.removeChild(_this.popup);
3948
- _this.popup = null;
3949
- }
3950
- };
3951
- this.eventEmitter = eventEmitter;
3952
- this.eventEmitter.listen('blur', this.removeWidget);
3953
- this.eventEmitter.listen('removePopupWidget', this.removeWidget);
3954
- }
3955
- PopupWidget.prototype.update = function (view) {
3956
- var widget = pluginKey.getState(view.state);
3957
- this.removeWidget();
3958
- if (widget) {
3959
- var node = widget.node, style = widget.style;
3960
- var _a = view.coordsAtPos(widget.pos), top = _a.top, left = _a.left, bottom = _a.bottom;
3961
- var height = bottom - top;
3962
- css_default()(node, { position: 'absolute', left: left + "px", opacity: '0' });
3963
- document.body.appendChild(node);
3964
- css_default()(node, {
3965
- top: (style === 'bottom' ? top + height : top - node.clientHeight - height) + "px",
3966
- opacity: '1',
3967
- });
3968
- this.popup = node;
3969
- view.focus();
3970
- }
3971
- };
3972
- PopupWidget.prototype.destroy = function () {
3973
- this.eventEmitter.removeEventHandler('blur', this.removeWidget);
3974
- };
3975
- return PopupWidget;
3976
- }());
3977
- function addWidget(eventEmitter) {
3978
- return new external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.Plugin({
3979
- key: pluginKey,
3980
- state: {
3981
- init: function () {
3982
- return null;
3983
- },
3984
- apply: function (tr) {
3985
- return tr.getMeta('widget');
3986
- },
3987
- },
3988
- view: function () {
3989
- return new PopupWidget(eventEmitter);
3990
- },
3991
- });
3992
- }
3976
+ // EXTERNAL MODULE: ../../node_modules/tui-code-snippet/type/isArray.js
3977
+ var isArray = __webpack_require__(322);
3978
+ var isArray_default = /*#__PURE__*/__webpack_require__.n(isArray);
3979
+ // EXTERNAL MODULE: ../../node_modules/tui-code-snippet/domUtil/hasClass.js
3980
+ var hasClass = __webpack_require__(714);
3981
+ var hasClass_default = /*#__PURE__*/__webpack_require__.n(hasClass);
3982
+ // EXTERNAL MODULE: ../../node_modules/tui-code-snippet/domUtil/matches.js
3983
+ var matches = __webpack_require__(471);
3984
+ var matches_default = /*#__PURE__*/__webpack_require__.n(matches);
3985
+ ;// CONCATENATED MODULE: ./src/utils/constants.ts
3986
+ var TAG_NAME = '[A-Za-z][A-Za-z0-9-]*';
3987
+ var ATTRIBUTE_NAME = '[a-zA-Z_:][a-zA-Z0-9:._-]*';
3988
+ var UNQUOTED_VALUE = '[^"\'=<>`\\x00-\\x20]+';
3989
+ var SINGLE_QUOTED_VALUE = "'[^']*'";
3990
+ var DOUBLE_QUOTED_VALUE = '"[^"]*"';
3991
+ var ATTRIBUTE_VALUE = "(?:" + UNQUOTED_VALUE + "|" + SINGLE_QUOTED_VALUE + "|" + DOUBLE_QUOTED_VALUE + ")";
3992
+ var ATTRIBUTE_VALUE_SPEC = "" + '(?:\\s*=\\s*' + ATTRIBUTE_VALUE + ")";
3993
+ var ATTRIBUTE = "" + '(?:\\s+' + ATTRIBUTE_NAME + ATTRIBUTE_VALUE_SPEC + "?)";
3994
+ var OPEN_TAG = "<(" + TAG_NAME + ")(" + ATTRIBUTE + ")*\\s*/?>";
3995
+ var CLOSE_TAG = "</(" + TAG_NAME + ")\\s*[>]";
3996
+ var HTML_TAG = "(?:" + OPEN_TAG + "|" + CLOSE_TAG + ")";
3997
+ var reHTMLTag = new RegExp("^" + HTML_TAG, 'i');
3998
+ var reBR = /<br\s*\/*>/i;
3999
+ var reHTMLComment = /<! ---->|<!--(?:-?[^>-])(?:-?[^-])*-->/;
4000
+ var ALTERNATIVE_TAG_FOR_BR = '</p><p>';
3993
4001
 
3994
- // EXTERNAL MODULE: ../../node_modules/tui-code-snippet/collection/forEachArray.js
3995
- var forEachArray = __webpack_require__(893);
3996
- var forEachArray_default = /*#__PURE__*/__webpack_require__.n(forEachArray);
3997
- // EXTERNAL MODULE: ../../node_modules/tui-code-snippet/collection/toArray.js
3998
- var collection_toArray = __webpack_require__(990);
3999
- var toArray_default = /*#__PURE__*/__webpack_require__.n(collection_toArray);
4000
- ;// CONCATENATED MODULE: ./src/helper/image.ts
4002
+ ;// CONCATENATED MODULE: ./src/utils/dom.ts
4001
4003
 
4002
- function addDefaultImageBlobHook(eventEmitter) {
4003
- eventEmitter.listen('addImageBlobHook', function (blob, callback) {
4004
- var reader = new FileReader();
4005
- reader.onload = function (_a) {
4006
- var target = _a.target;
4007
- return callback(target.result);
4008
- };
4009
- reader.readAsDataURL(blob);
4010
- });
4011
- }
4012
- function emitImageBlobHook(eventEmitter, blob, type) {
4013
- var hook = function (imageUrl, altText) {
4014
- eventEmitter.emit('command', 'addImage', {
4015
- imageUrl: imageUrl,
4016
- altText: altText || blob.name || 'image',
4017
- });
4018
- };
4019
- eventEmitter.emit('addImageBlobHook', blob, hook, type);
4020
- }
4021
- function pasteImageOnly(items) {
4022
- var images = toArray_default()(items).filter(function (_a) {
4023
- var type = _a.type;
4024
- return type.indexOf('image') !== -1;
4025
- });
4026
- if (images.length === 1) {
4027
- var item = images[0];
4028
- if (item) {
4029
- return item.getAsFile();
4030
- }
4031
- }
4032
- return null;
4033
- }
4034
4004
 
4035
- ;// CONCATENATED MODULE: ./src/plugins/dropImage.ts
4036
4005
 
4037
4006
 
4038
4007
 
4039
- function dropImage(_a) {
4040
- var eventEmitter = _a.eventEmitter;
4041
- return new external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.Plugin({
4042
- props: {
4043
- handleDOMEvents: {
4044
- drop: function (_, ev) {
4045
- var _a;
4046
- var items = (_a = ev.dataTransfer) === null || _a === void 0 ? void 0 : _a.files;
4047
- if (items) {
4048
- forEachArray_default()(items, function (item) {
4049
- if (item.type.indexOf('image') !== -1) {
4050
- ev.preventDefault();
4051
- ev.stopPropagation();
4052
- emitImageBlobHook(eventEmitter, item, ev.type);
4053
- return false;
4054
- }
4055
- return true;
4056
- });
4057
- }
4058
- return true;
4059
- },
4060
- },
4061
- },
4062
- });
4063
- }
4064
4008
 
4065
- ;// CONCATENATED MODULE: ./src/spec/node.ts
4066
- var node_Node = /** @class */ (function () {
4067
- function Node() {
4068
- }
4069
- Object.defineProperty(Node.prototype, "type", {
4070
- get: function () {
4071
- return 'node';
4072
- },
4073
- enumerable: false,
4074
- configurable: true
4075
- });
4076
- Node.prototype.setContext = function (context) {
4077
- this.context = context;
4078
- };
4079
- return Node;
4080
- }());
4081
- /* harmony default export */ var node = (node_Node);
4082
4009
 
4083
- ;// CONCATENATED MODULE: ./src/widget/widgetNode.ts
4084
4010
 
4085
4011
 
4086
4012
 
4087
- function widgetNodeView(pmNode) {
4088
- var dom = document.createElement('span');
4089
- var node = widgetToDOM(pmNode.attrs.info, pmNode.textContent);
4090
- dom.className = 'tui-widget';
4091
- dom.appendChild(node);
4092
- return { dom: dom };
4013
+ function isPositionInBox(style, offsetX, offsetY) {
4014
+ var left = parseInt(style.left, 10);
4015
+ var top = parseInt(style.top, 10);
4016
+ var width = parseInt(style.width, 10) + parseInt(style.paddingLeft, 10) + parseInt(style.paddingRight, 10);
4017
+ var height = parseInt(style.height, 10) + parseInt(style.paddingTop, 10) + parseInt(style.paddingBottom, 10);
4018
+ return offsetX >= left && offsetX <= left + width && offsetY >= top && offsetY <= top + height;
4093
4019
  }
4094
- function isWidgetNode(pmNode) {
4095
- return pmNode.type.name === 'widget';
4020
+ var CLS_PREFIX = 'toastui-editor-';
4021
+ function cls() {
4022
+ var names = [];
4023
+ for (var _i = 0; _i < arguments.length; _i++) {
4024
+ names[_i] = arguments[_i];
4025
+ }
4026
+ var result = [];
4027
+ for (var _a = 0, names_1 = names; _a < names_1.length; _a++) {
4028
+ var name = names_1[_a];
4029
+ var className = void 0;
4030
+ if (Array.isArray(name)) {
4031
+ className = name[0] ? name[1] : null;
4032
+ }
4033
+ else {
4034
+ className = name;
4035
+ }
4036
+ if (className) {
4037
+ result.push("" + CLS_PREFIX + className);
4038
+ }
4039
+ }
4040
+ return result.join(' ');
4096
4041
  }
4097
- var Widget = /** @class */ (function (_super) {
4098
- __extends(Widget, _super);
4099
- function Widget() {
4100
- return _super !== null && _super.apply(this, arguments) || this;
4042
+ function clsWithMdPrefix() {
4043
+ var names = [];
4044
+ for (var _i = 0; _i < arguments.length; _i++) {
4045
+ names[_i] = arguments[_i];
4101
4046
  }
4102
- Object.defineProperty(Widget.prototype, "name", {
4103
- get: function () {
4104
- return 'widget';
4105
- },
4106
- enumerable: false,
4107
- configurable: true
4047
+ return names.map(function (className) { return CLS_PREFIX + "md-" + className; }).join(' ');
4048
+ }
4049
+ function isTextNode(node) {
4050
+ return (node === null || node === void 0 ? void 0 : node.nodeType) === Node.TEXT_NODE;
4051
+ }
4052
+ function isElemNode(node) {
4053
+ return node && node.nodeType === Node.ELEMENT_NODE;
4054
+ }
4055
+ function findNodes(element, selector) {
4056
+ var nodeList = toArray_default()(element.querySelectorAll(selector));
4057
+ if (nodeList.length) {
4058
+ return nodeList;
4059
+ }
4060
+ return [];
4061
+ }
4062
+ function appendNodes(node, nodesToAppend) {
4063
+ nodesToAppend = isArray_default()(nodesToAppend) ? toArray_default()(nodesToAppend) : [nodesToAppend];
4064
+ nodesToAppend.forEach(function (nodeToAppend) {
4065
+ node.appendChild(nodeToAppend);
4108
4066
  });
4109
- Object.defineProperty(Widget.prototype, "schema", {
4110
- get: function () {
4111
- return {
4112
- attrs: {
4113
- info: { default: null },
4114
- },
4115
- group: 'inline',
4067
+ }
4068
+ function insertBeforeNode(insertedNode, node) {
4069
+ if (node.parentNode) {
4070
+ node.parentNode.insertBefore(insertedNode, node);
4071
+ }
4072
+ }
4073
+ function removeNode(node) {
4074
+ if (node.parentNode) {
4075
+ node.parentNode.removeChild(node);
4076
+ }
4077
+ }
4078
+ function unwrapNode(node) {
4079
+ var result = [];
4080
+ while (node.firstChild) {
4081
+ result.push(node.firstChild);
4082
+ if (node.parentNode) {
4083
+ node.parentNode.insertBefore(node.firstChild, node);
4084
+ }
4085
+ }
4086
+ removeNode(node);
4087
+ return result;
4088
+ }
4089
+ function toggleClass(element, className, state) {
4090
+ if (isUndefined_default()(state)) {
4091
+ state = !hasClass_default()(element, className);
4092
+ }
4093
+ var toggleFn = state ? (addClass_default()) : (removeClass_default());
4094
+ toggleFn(element, className);
4095
+ }
4096
+ function createElementWith(contents, target) {
4097
+ var container = document.createElement('div');
4098
+ if (isString_default()(contents)) {
4099
+ container.innerHTML = contents;
4100
+ }
4101
+ else {
4102
+ container.appendChild(contents);
4103
+ }
4104
+ var firstChild = container.firstChild;
4105
+ if (target) {
4106
+ target.appendChild(firstChild);
4107
+ }
4108
+ return firstChild;
4109
+ }
4110
+ function getOuterWidth(el) {
4111
+ var computed = window.getComputedStyle(el);
4112
+ return (['margin-left', 'margin-right'].reduce(function (acc, type) { return acc + parseInt(computed.getPropertyValue(type), 10); }, 0) + el.offsetWidth);
4113
+ }
4114
+ function closest(node, found) {
4115
+ var condition;
4116
+ if (isString_default()(found)) {
4117
+ condition = function (target) { return matches_default()(target, found); };
4118
+ }
4119
+ else {
4120
+ condition = function (target) { return target === found; };
4121
+ }
4122
+ while (node && node !== document) {
4123
+ if (isElemNode(node) && condition(node)) {
4124
+ return node;
4125
+ }
4126
+ node = node.parentNode;
4127
+ }
4128
+ return null;
4129
+ }
4130
+ function getTotalOffset(el, root) {
4131
+ var offsetTop = 0;
4132
+ var offsetLeft = 0;
4133
+ while (el && el !== root) {
4134
+ var top = el.offsetTop, left = el.offsetLeft, offsetParent = el.offsetParent;
4135
+ offsetTop += top;
4136
+ offsetLeft += left;
4137
+ if (offsetParent === root.offsetParent) {
4138
+ break;
4139
+ }
4140
+ el = el.offsetParent;
4141
+ }
4142
+ return { offsetTop: offsetTop, offsetLeft: offsetLeft };
4143
+ }
4144
+ function finalizeHtml(html, needHtmlText) {
4145
+ var result;
4146
+ if (needHtmlText) {
4147
+ result = html.innerHTML;
4148
+ }
4149
+ else {
4150
+ var frag = document.createDocumentFragment();
4151
+ var childNodes = toArray(html.childNodes);
4152
+ var length = childNodes.length;
4153
+ for (var i = 0; i < length; i += 1) {
4154
+ frag.appendChild(childNodes[i]);
4155
+ }
4156
+ result = frag;
4157
+ }
4158
+ return result;
4159
+ }
4160
+ function empty(node) {
4161
+ while (node.firstChild) {
4162
+ node.removeChild(node.firstChild);
4163
+ }
4164
+ }
4165
+ function appendNode(node, appended) {
4166
+ if (isString(appended)) {
4167
+ node.insertAdjacentHTML('beforeend', appended);
4168
+ }
4169
+ else {
4170
+ var nodes = appended.length
4171
+ ? toArray(appended)
4172
+ : [appended];
4173
+ for (var i = 0, len = nodes.length; i < len; i += 1) {
4174
+ node.appendChild(nodes[i]);
4175
+ }
4176
+ }
4177
+ }
4178
+ function prependNode(node, appended) {
4179
+ if (isString(appended)) {
4180
+ node.insertAdjacentHTML('afterbegin', appended);
4181
+ }
4182
+ else {
4183
+ var nodes = appended.length
4184
+ ? toArray(appended)
4185
+ : [appended];
4186
+ for (var i = nodes.length - 1, len = 0; i >= len; i -= 1) {
4187
+ node.insertBefore(nodes[i], node.firstChild);
4188
+ }
4189
+ }
4190
+ }
4191
+ function setAttributes(attributes, element) {
4192
+ Object.keys(attributes).forEach(function (attrName) {
4193
+ if (isNil(attributes[attrName])) {
4194
+ element.removeAttribute(attrName);
4195
+ }
4196
+ else {
4197
+ element.setAttribute(attrName, attributes[attrName]);
4198
+ }
4199
+ });
4200
+ }
4201
+ function replaceBRWithEmptyBlock(html) {
4202
+ // remove br in paragraph to compatible with markdown
4203
+ var replacedHTML = html.replace(/<p><br\s*\/*><\/p>/gi, '<p></p>');
4204
+ var reHTMLTag = new RegExp(HTML_TAG, 'ig');
4205
+ var htmlTagMatched = replacedHTML.match(reHTMLTag);
4206
+ htmlTagMatched === null || htmlTagMatched === void 0 ? void 0 : htmlTagMatched.forEach(function (htmlTag, index) {
4207
+ if (reBR.test(htmlTag)) {
4208
+ var alternativeTag = ALTERNATIVE_TAG_FOR_BR;
4209
+ if (index) {
4210
+ var prevTag = htmlTagMatched[index - 1];
4211
+ var openTagMatched = prevTag.match(OPEN_TAG);
4212
+ if (openTagMatched && !/br/i.test(openTagMatched[1])) {
4213
+ var tagName = openTagMatched[1];
4214
+ alternativeTag = "</" + tagName + "><" + tagName + ">";
4215
+ }
4216
+ }
4217
+ replacedHTML = replacedHTML.replace(reBR, alternativeTag);
4218
+ }
4219
+ });
4220
+ return replacedHTML;
4221
+ }
4222
+
4223
+ ;// CONCATENATED MODULE: ./src/plugins/popupWidget.ts
4224
+
4225
+
4226
+
4227
+ var pluginKey = new external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.PluginKey('widget');
4228
+ var MARGIN = 5;
4229
+ var PopupWidget = /** @class */ (function () {
4230
+ function PopupWidget(view, eventEmitter) {
4231
+ var _this = this;
4232
+ this.popup = null;
4233
+ this.removeWidget = function () {
4234
+ if (_this.popup) {
4235
+ _this.rootEl.removeChild(_this.popup);
4236
+ _this.popup = null;
4237
+ }
4238
+ };
4239
+ this.rootEl = view.dom.parentElement;
4240
+ this.eventEmitter = eventEmitter;
4241
+ this.eventEmitter.listen('blur', this.removeWidget);
4242
+ this.eventEmitter.listen('loadUI', function () {
4243
+ _this.rootEl = closest(view.dom.parentElement, "." + cls('defaultUI'));
4244
+ });
4245
+ this.eventEmitter.listen('removePopupWidget', this.removeWidget);
4246
+ }
4247
+ PopupWidget.prototype.update = function (view) {
4248
+ var widget = pluginKey.getState(view.state);
4249
+ this.removeWidget();
4250
+ if (widget) {
4251
+ var node = widget.node, style = widget.style;
4252
+ var _a = view.coordsAtPos(widget.pos), top = _a.top, left = _a.left, bottom = _a.bottom;
4253
+ var height = bottom - top;
4254
+ var rect = this.rootEl.getBoundingClientRect();
4255
+ var relTopPos = top - rect.top;
4256
+ css_default()(node, { opacity: '0' });
4257
+ this.rootEl.appendChild(node);
4258
+ css_default()(node, {
4259
+ position: 'absolute',
4260
+ left: left - rect.left + MARGIN + "px",
4261
+ top: (style === 'bottom' ? relTopPos + height - MARGIN : relTopPos - height) + "px",
4262
+ opacity: '1',
4263
+ });
4264
+ this.popup = node;
4265
+ view.focus();
4266
+ }
4267
+ };
4268
+ PopupWidget.prototype.destroy = function () {
4269
+ this.eventEmitter.removeEventHandler('blur', this.removeWidget);
4270
+ };
4271
+ return PopupWidget;
4272
+ }());
4273
+ function addWidget(eventEmitter) {
4274
+ return new external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.Plugin({
4275
+ key: pluginKey,
4276
+ state: {
4277
+ init: function () {
4278
+ return null;
4279
+ },
4280
+ apply: function (tr) {
4281
+ return tr.getMeta('widget');
4282
+ },
4283
+ },
4284
+ view: function (editorView) {
4285
+ return new PopupWidget(editorView, eventEmitter);
4286
+ },
4287
+ });
4288
+ }
4289
+
4290
+ // EXTERNAL MODULE: ../../node_modules/tui-code-snippet/collection/forEachArray.js
4291
+ var forEachArray = __webpack_require__(893);
4292
+ var forEachArray_default = /*#__PURE__*/__webpack_require__.n(forEachArray);
4293
+ ;// CONCATENATED MODULE: ./src/helper/image.ts
4294
+
4295
+ function addDefaultImageBlobHook(eventEmitter) {
4296
+ eventEmitter.listen('addImageBlobHook', function (blob, callback) {
4297
+ var reader = new FileReader();
4298
+ reader.onload = function (_a) {
4299
+ var target = _a.target;
4300
+ return callback(target.result);
4301
+ };
4302
+ reader.readAsDataURL(blob);
4303
+ });
4304
+ }
4305
+ function emitImageBlobHook(eventEmitter, blob, type) {
4306
+ var hook = function (imageUrl, altText) {
4307
+ eventEmitter.emit('command', 'addImage', {
4308
+ imageUrl: imageUrl,
4309
+ altText: altText || blob.name || 'image',
4310
+ });
4311
+ };
4312
+ eventEmitter.emit('addImageBlobHook', blob, hook, type);
4313
+ }
4314
+ function pasteImageOnly(items) {
4315
+ var images = toArray_default()(items).filter(function (_a) {
4316
+ var type = _a.type;
4317
+ return type.indexOf('image') !== -1;
4318
+ });
4319
+ if (images.length === 1) {
4320
+ var item = images[0];
4321
+ if (item) {
4322
+ return item.getAsFile();
4323
+ }
4324
+ }
4325
+ return null;
4326
+ }
4327
+
4328
+ ;// CONCATENATED MODULE: ./src/plugins/dropImage.ts
4329
+
4330
+
4331
+
4332
+ function dropImage(_a) {
4333
+ var eventEmitter = _a.eventEmitter;
4334
+ return new external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.Plugin({
4335
+ props: {
4336
+ handleDOMEvents: {
4337
+ drop: function (_, ev) {
4338
+ var _a;
4339
+ var items = (_a = ev.dataTransfer) === null || _a === void 0 ? void 0 : _a.files;
4340
+ if (items) {
4341
+ forEachArray_default()(items, function (item) {
4342
+ if (item.type.indexOf('image') !== -1) {
4343
+ ev.preventDefault();
4344
+ ev.stopPropagation();
4345
+ emitImageBlobHook(eventEmitter, item, ev.type);
4346
+ return false;
4347
+ }
4348
+ return true;
4349
+ });
4350
+ }
4351
+ return true;
4352
+ },
4353
+ },
4354
+ },
4355
+ });
4356
+ }
4357
+
4358
+ ;// CONCATENATED MODULE: ./src/spec/node.ts
4359
+ var node_Node = /** @class */ (function () {
4360
+ function Node() {
4361
+ }
4362
+ Object.defineProperty(Node.prototype, "type", {
4363
+ get: function () {
4364
+ return 'node';
4365
+ },
4366
+ enumerable: false,
4367
+ configurable: true
4368
+ });
4369
+ Node.prototype.setContext = function (context) {
4370
+ this.context = context;
4371
+ };
4372
+ return Node;
4373
+ }());
4374
+ /* harmony default export */ var node = (node_Node);
4375
+
4376
+ ;// CONCATENATED MODULE: ./src/widget/widgetNode.ts
4377
+
4378
+
4379
+
4380
+ function widgetNodeView(pmNode) {
4381
+ var dom = document.createElement('span');
4382
+ var node = widgetToDOM(pmNode.attrs.info, pmNode.textContent);
4383
+ dom.className = 'tui-widget';
4384
+ dom.appendChild(node);
4385
+ return { dom: dom };
4386
+ }
4387
+ function isWidgetNode(pmNode) {
4388
+ return pmNode.type.name === 'widget';
4389
+ }
4390
+ var Widget = /** @class */ (function (_super) {
4391
+ __extends(Widget, _super);
4392
+ function Widget() {
4393
+ return _super !== null && _super.apply(this, arguments) || this;
4394
+ }
4395
+ Object.defineProperty(Widget.prototype, "name", {
4396
+ get: function () {
4397
+ return 'widget';
4398
+ },
4399
+ enumerable: false,
4400
+ configurable: true
4401
+ });
4402
+ Object.defineProperty(Widget.prototype, "schema", {
4403
+ get: function () {
4404
+ return {
4405
+ attrs: {
4406
+ info: { default: null },
4407
+ },
4408
+ group: 'inline',
4116
4409
  inline: true,
4117
4410
  content: 'text*',
4118
4411
  selectable: false,
@@ -4158,6 +4451,7 @@ var Widget = /** @class */ (function (_super) {
4158
4451
 
4159
4452
  var EditorBase = /** @class */ (function () {
4160
4453
  function EditorBase(eventEmitter) {
4454
+ this.timer = null;
4161
4455
  this.el = document.createElement('div');
4162
4456
  this.el.className = 'toastui-editor';
4163
4457
  this.eventEmitter = eventEmitter;
@@ -4182,10 +4476,9 @@ var EditorBase = /** @class */ (function () {
4182
4476
  };
4183
4477
  Object.defineProperty(EditorBase.prototype, "defaultPlugins", {
4184
4478
  get: function () {
4185
- var _a = getDefaultCommands(), undo = _a.undo, redo = _a.redo;
4186
4479
  var rules = this.createInputRules();
4187
4480
  var plugins = __spreadArray(__spreadArray([], this.keymaps), [
4188
- (0,external_commonjs_prosemirror_keymap_commonjs2_prosemirror_keymap_amd_prosemirror_keymap_.keymap)(__assign({ 'Mod-z': undo(), 'Shift-Mod-z': redo(), 'Shift-Enter': external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.baseKeymap.Enter }, external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.baseKeymap)),
4481
+ (0,external_commonjs_prosemirror_keymap_commonjs2_prosemirror_keymap_amd_prosemirror_keymap_.keymap)(__assign({ 'Shift-Enter': external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.baseKeymap.Enter }, external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.baseKeymap)),
4189
4482
  (0,external_commonjs_prosemirror_history_commonjs2_prosemirror_history_amd_prosemirror_history_.history)(),
4190
4483
  placeholder(this.placeholder),
4191
4484
  addWidget(this.eventEmitter),
@@ -4222,6 +4515,12 @@ var EditorBase = /** @class */ (function () {
4222
4515
  });
4223
4516
  return rules.length ? (0,external_commonjs_prosemirror_inputrules_commonjs2_prosemirror_inputrules_amd_prosemirror_inputrules_.inputRules)({ rules: rules }) : null;
4224
4517
  };
4518
+ EditorBase.prototype.clearTimer = function () {
4519
+ if (this.timer) {
4520
+ clearTimeout(this.timer);
4521
+ this.timer = null;
4522
+ }
4523
+ };
4225
4524
  EditorBase.prototype.createSchema = function () {
4226
4525
  return new external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Schema({
4227
4526
  nodes: this.specs.nodes,
@@ -4229,7 +4528,13 @@ var EditorBase = /** @class */ (function () {
4229
4528
  });
4230
4529
  };
4231
4530
  EditorBase.prototype.createKeymaps = function (useCommandShortcut) {
4232
- return useCommandShortcut ? this.specs.keymaps() : [];
4531
+ var _a = getDefaultCommands(), undo = _a.undo, redo = _a.redo;
4532
+ var allKeymaps = this.specs.keymaps(useCommandShortcut);
4533
+ var historyKeymap = {
4534
+ 'Mod-z': undo(),
4535
+ 'Shift-Mod-z': redo(),
4536
+ };
4537
+ return useCommandShortcut ? allKeymaps.concat((0,external_commonjs_prosemirror_keymap_commonjs2_prosemirror_keymap_amd_prosemirror_keymap_.keymap)(historyKeymap)) : allKeymaps;
4233
4538
  };
4234
4539
  EditorBase.prototype.createCommands = function () {
4235
4540
  return this.specs.commands(this.view);
@@ -4240,8 +4545,9 @@ var EditorBase = /** @class */ (function () {
4240
4545
  };
4241
4546
  EditorBase.prototype.focus = function () {
4242
4547
  var _this = this;
4548
+ this.clearTimer();
4243
4549
  // prevent the error for IE11
4244
- setTimeout(function () {
4550
+ this.timer = setTimeout(function () {
4245
4551
  _this.view.focus();
4246
4552
  _this.view.dispatch(_this.view.state.tr.scrollIntoView());
4247
4553
  });
@@ -4251,6 +4557,7 @@ var EditorBase = /** @class */ (function () {
4251
4557
  };
4252
4558
  EditorBase.prototype.destroy = function () {
4253
4559
  var _this = this;
4560
+ this.clearTimer();
4254
4561
  this.view.destroy();
4255
4562
  Object.keys(this).forEach(function (prop) {
4256
4563
  delete _this[prop];
@@ -4274,355 +4581,138 @@ var EditorBase = /** @class */ (function () {
4274
4581
  this.view.dom.scrollTop = top;
4275
4582
  };
4276
4583
  EditorBase.prototype.getScrollTop = function () {
4277
- return this.view.dom.scrollTop;
4278
- };
4279
- EditorBase.prototype.setPlaceholder = function (text) {
4280
- this.placeholder.text = text;
4281
- this.view.dispatch(this.view.state.tr.scrollIntoView());
4282
- };
4283
- EditorBase.prototype.setHeight = function (height) {
4284
- css_default()(this.el, { height: height + "px" });
4285
- };
4286
- EditorBase.prototype.setMinHeight = function (minHeight) {
4287
- css_default()(this.el, { minHeight: minHeight + "px" });
4288
- };
4289
- EditorBase.prototype.getElement = function () {
4290
- return this.el;
4291
- };
4292
- return EditorBase;
4293
- }());
4294
- /* harmony default export */ var base = (EditorBase);
4295
-
4296
- // EXTERNAL MODULE: ../../node_modules/tui-code-snippet/type/isFunction.js
4297
- var isFunction = __webpack_require__(294);
4298
- var isFunction_default = /*#__PURE__*/__webpack_require__.n(isFunction);
4299
- ;// CONCATENATED MODULE: ./src/spec/specManager.ts
4300
-
4301
-
4302
-
4303
-
4304
- function execCommand(view, command, payload) {
4305
- view.focus();
4306
- return command(payload)(view.state, view.dispatch, view);
4307
- }
4308
- var SpecManager = /** @class */ (function () {
4309
- function SpecManager(specs) {
4310
- this.specs = specs;
4311
- }
4312
- Object.defineProperty(SpecManager.prototype, "nodes", {
4313
- get: function () {
4314
- return this.specs
4315
- .filter(function (spec) { return spec.type === 'node'; })
4316
- .reduce(function (nodes, _a) {
4317
- var _b;
4318
- var name = _a.name, schema = _a.schema;
4319
- return __assign(__assign({}, nodes), (_b = {}, _b[name] = schema, _b));
4320
- }, {});
4321
- },
4322
- enumerable: false,
4323
- configurable: true
4324
- });
4325
- Object.defineProperty(SpecManager.prototype, "marks", {
4326
- get: function () {
4327
- return this.specs
4328
- .filter(function (spec) { return spec.type === 'mark'; })
4329
- .reduce(function (marks, _a) {
4330
- var _b;
4331
- var name = _a.name, schema = _a.schema;
4332
- return __assign(__assign({}, marks), (_b = {}, _b[name] = schema, _b));
4333
- }, {});
4334
- },
4335
- enumerable: false,
4336
- configurable: true
4337
- });
4338
- SpecManager.prototype.commands = function (view, addedCommands) {
4339
- var specCommands = this.specs
4340
- .filter(function (_a) {
4341
- var commands = _a.commands;
4342
- return commands;
4343
- })
4344
- .reduce(function (allCommands, spec) {
4345
- var commands = {};
4346
- var specCommand = spec.commands();
4347
- if (isFunction_default()(specCommand)) {
4348
- commands[spec.name] = function (payload) { return execCommand(view, specCommand, payload); };
4349
- }
4350
- else {
4351
- Object.keys(specCommand).forEach(function (name) {
4352
- commands[name] = function (payload) { return execCommand(view, specCommand[name], payload); };
4353
- });
4354
- }
4355
- return __assign(__assign({}, allCommands), commands);
4356
- }, {});
4357
- var defaultCommands = getDefaultCommands();
4358
- Object.keys(defaultCommands).forEach(function (name) {
4359
- specCommands[name] = function (payload) { return execCommand(view, defaultCommands[name], payload); };
4360
- });
4361
- if (addedCommands) {
4362
- Object.keys(addedCommands).forEach(function (name) {
4363
- specCommands[name] = function (payload) { return execCommand(view, addedCommands[name], payload); };
4364
- });
4365
- }
4366
- return specCommands;
4584
+ return this.view.dom.scrollTop;
4367
4585
  };
4368
- SpecManager.prototype.keymaps = function () {
4369
- var specKeymaps = this.specs.filter(function (spec) { return spec.keymaps; }).map(function (spec) { return spec.keymaps(); });
4370
- return specKeymaps.map(function (keys) { return (0,external_commonjs_prosemirror_keymap_commonjs2_prosemirror_keymap_amd_prosemirror_keymap_.keymap)(keys); });
4586
+ EditorBase.prototype.setPlaceholder = function (text) {
4587
+ this.placeholder.text = text;
4588
+ this.view.dispatch(this.view.state.tr.scrollIntoView());
4371
4589
  };
4372
- SpecManager.prototype.setContext = function (context) {
4373
- this.specs.forEach(function (spec) {
4374
- spec.setContext(context);
4375
- });
4590
+ EditorBase.prototype.setHeight = function (height) {
4591
+ css_default()(this.el, { height: height + "px" });
4376
4592
  };
4377
- return SpecManager;
4593
+ EditorBase.prototype.setMinHeight = function (minHeight) {
4594
+ css_default()(this.el, { minHeight: minHeight + "px" });
4595
+ };
4596
+ EditorBase.prototype.getElement = function () {
4597
+ return this.el;
4598
+ };
4599
+ return EditorBase;
4378
4600
  }());
4379
- /* harmony default export */ var specManager = (SpecManager);
4380
-
4381
- // EXTERNAL MODULE: ../../node_modules/tui-code-snippet/type/isArray.js
4382
- var isArray = __webpack_require__(322);
4383
- var isArray_default = /*#__PURE__*/__webpack_require__.n(isArray);
4384
- // EXTERNAL MODULE: ../../node_modules/tui-code-snippet/domUtil/hasClass.js
4385
- var hasClass = __webpack_require__(714);
4386
- var hasClass_default = /*#__PURE__*/__webpack_require__.n(hasClass);
4387
- // EXTERNAL MODULE: ../../node_modules/tui-code-snippet/domUtil/matches.js
4388
- var matches = __webpack_require__(471);
4389
- var matches_default = /*#__PURE__*/__webpack_require__.n(matches);
4390
- ;// CONCATENATED MODULE: ./src/utils/constants.ts
4391
- var TAG_NAME = '[A-Za-z][A-Za-z0-9-]*';
4392
- var ATTRIBUTE_NAME = '[a-zA-Z_:][a-zA-Z0-9:._-]*';
4393
- var UNQUOTED_VALUE = '[^"\'=<>`\\x00-\\x20]+';
4394
- var SINGLE_QUOTED_VALUE = "'[^']*'";
4395
- var DOUBLE_QUOTED_VALUE = '"[^"]*"';
4396
- var ATTRIBUTE_VALUE = "(?:" + UNQUOTED_VALUE + "|" + SINGLE_QUOTED_VALUE + "|" + DOUBLE_QUOTED_VALUE + ")";
4397
- var ATTRIBUTE_VALUE_SPEC = "" + '(?:\\s*=\\s*' + ATTRIBUTE_VALUE + ")";
4398
- var ATTRIBUTE = "" + '(?:\\s+' + ATTRIBUTE_NAME + ATTRIBUTE_VALUE_SPEC + "?)";
4399
- var OPEN_TAG = "<(" + TAG_NAME + ")(" + ATTRIBUTE + ")*\\s*/?>";
4400
- var CLOSE_TAG = "</(" + TAG_NAME + ")\\s*[>]";
4401
- var HTML_TAG = "(?:" + OPEN_TAG + "|" + CLOSE_TAG + ")";
4402
- var reHTMLTag = new RegExp("^" + HTML_TAG, 'i');
4403
- var reBR = /<br\s*\/*>/i;
4404
- var ALTERNATIVE_TAG_FOR_BR = '</p><p>';
4405
-
4406
- ;// CONCATENATED MODULE: ./src/utils/dom.ts
4407
-
4408
-
4409
-
4410
-
4601
+ /* harmony default export */ var base = (EditorBase);
4411
4602
 
4603
+ // EXTERNAL MODULE: ../../node_modules/tui-code-snippet/type/isFunction.js
4604
+ var isFunction = __webpack_require__(294);
4605
+ var isFunction_default = /*#__PURE__*/__webpack_require__.n(isFunction);
4606
+ ;// CONCATENATED MODULE: ./src/spec/specManager.ts
4412
4607
 
4413
4608
 
4414
4609
 
4415
4610
 
4416
4611
 
4417
- function isPositionInBox(style, offsetX, offsetY) {
4418
- var left = parseInt(style.left, 10);
4419
- var top = parseInt(style.top, 10);
4420
- var width = parseInt(style.width, 10) + parseInt(style.paddingLeft, 10) + parseInt(style.paddingRight, 10);
4421
- var height = parseInt(style.height, 10) + parseInt(style.paddingTop, 10) + parseInt(style.paddingBottom, 10);
4422
- return offsetX >= left && offsetX <= left + width && offsetY >= top && offsetY <= top + height;
4423
- }
4424
- var CLS_PREFIX = 'toastui-editor-';
4425
- function cls() {
4426
- var names = [];
4427
- for (var _i = 0; _i < arguments.length; _i++) {
4428
- names[_i] = arguments[_i];
4429
- }
4430
- var result = [];
4431
- for (var _a = 0, names_1 = names; _a < names_1.length; _a++) {
4432
- var name = names_1[_a];
4433
- var className = void 0;
4434
- if (Array.isArray(name)) {
4435
- className = name[0] ? name[1] : null;
4436
- }
4437
- else {
4438
- className = name;
4439
- }
4440
- if (className) {
4441
- result.push("" + CLS_PREFIX + className);
4442
- }
4443
- }
4444
- return result.join(' ');
4445
- }
4446
- function clsWithMdPrefix() {
4447
- var names = [];
4448
- for (var _i = 0; _i < arguments.length; _i++) {
4449
- names[_i] = arguments[_i];
4450
- }
4451
- return names.map(function (className) { return CLS_PREFIX + "md-" + className; }).join(' ');
4452
- }
4453
- function isTextNode(node) {
4454
- return (node === null || node === void 0 ? void 0 : node.nodeType) === Node.TEXT_NODE;
4455
- }
4456
- function isElemNode(node) {
4457
- return node && node.nodeType === Node.ELEMENT_NODE;
4458
- }
4459
- function findNodes(element, selector) {
4460
- var nodeList = toArray_default()(element.querySelectorAll(selector));
4461
- if (nodeList.length) {
4462
- return nodeList;
4463
- }
4464
- return [];
4465
- }
4466
- function appendNodes(node, nodesToAppend) {
4467
- nodesToAppend = isArray_default()(nodesToAppend) ? toArray_default()(nodesToAppend) : [nodesToAppend];
4468
- nodesToAppend.forEach(function (nodeToAppend) {
4469
- node.appendChild(nodeToAppend);
4470
- });
4471
- }
4472
- function insertBeforeNode(insertedNode, node) {
4473
- if (node.parentNode) {
4474
- node.parentNode.insertBefore(insertedNode, node);
4475
- }
4476
- }
4477
- function removeNode(node) {
4478
- if (node.parentNode) {
4479
- node.parentNode.removeChild(node);
4480
- }
4481
- }
4482
- function unwrapNode(node) {
4483
- var result = [];
4484
- while (node.firstChild) {
4485
- result.push(node.firstChild);
4486
- if (node.parentNode) {
4487
- node.parentNode.insertBefore(node.firstChild, node);
4488
- }
4489
- }
4490
- removeNode(node);
4491
- return result;
4492
- }
4493
- function toggleClass(element, className, state) {
4494
- if (isUndefined_default()(state)) {
4495
- state = !hasClass_default()(element, className);
4496
- }
4497
- var toggleFn = state ? (addClass_default()) : (removeClass_default());
4498
- toggleFn(element, className);
4499
- }
4500
- function createElementWith(contents, target) {
4501
- var container = document.createElement('div');
4502
- if (isString_default()(contents)) {
4503
- container.innerHTML = contents;
4504
- }
4505
- else {
4506
- container.appendChild(contents);
4507
- }
4508
- var firstChild = container.firstChild;
4509
- if (target) {
4510
- target.appendChild(firstChild);
4511
- }
4512
- return firstChild;
4513
- }
4514
- function getOuterWidth(el) {
4515
- var computed = window.getComputedStyle(el);
4516
- return (['margin-left', 'margin-right'].reduce(function (acc, type) { return acc + parseInt(computed.getPropertyValue(type), 10); }, 0) + el.offsetWidth);
4517
- }
4518
- function closest(node, found) {
4519
- var condition;
4520
- if (isString_default()(found)) {
4521
- condition = function (target) { return matches_default()(target, found); };
4522
- }
4523
- else {
4524
- condition = function (target) { return target === found; };
4525
- }
4526
- while (node && node !== document) {
4527
- if (isElemNode(node) && condition(node)) {
4528
- return node;
4529
- }
4530
- node = node.parentNode;
4531
- }
4532
- return null;
4533
- }
4534
- function getTotalOffset(el, root) {
4535
- var offsetTop = 0;
4536
- var offsetLeft = 0;
4537
- while (el && el !== root) {
4538
- var top = el.offsetTop, left = el.offsetLeft, offsetParent = el.offsetParent;
4539
- offsetTop += top;
4540
- offsetLeft += left;
4541
- if (offsetParent === root.offsetParent) {
4542
- break;
4543
- }
4544
- el = el.offsetParent;
4545
- }
4546
- return { offsetTop: offsetTop, offsetLeft: offsetLeft };
4547
- }
4548
- function finalizeHtml(html, needHtmlText) {
4549
- var result;
4550
- if (needHtmlText) {
4551
- result = html.innerHTML;
4552
- }
4553
- else {
4554
- var frag = document.createDocumentFragment();
4555
- var childNodes = toArray(html.childNodes);
4556
- var length = childNodes.length;
4557
- for (var i = 0; i < length; i += 1) {
4558
- frag.appendChild(childNodes[i]);
4559
- }
4560
- result = frag;
4561
- }
4562
- return result;
4563
- }
4564
- function empty(node) {
4565
- while (node.firstChild) {
4566
- node.removeChild(node.firstChild);
4567
- }
4568
- }
4569
- function appendNode(node, appended) {
4570
- if (isString(appended)) {
4571
- node.insertAdjacentHTML('beforeend', appended);
4572
- }
4573
- else {
4574
- var nodes = appended.length
4575
- ? toArray(appended)
4576
- : [appended];
4577
- for (var i = 0, len = nodes.length; i < len; i += 1) {
4578
- node.appendChild(nodes[i]);
4579
- }
4580
- }
4612
+ var defaultCommandShortcuts = [
4613
+ 'Enter',
4614
+ 'Shift-Enter',
4615
+ 'Mod-Enter',
4616
+ 'Tab',
4617
+ 'Shift-Tab',
4618
+ 'Delete',
4619
+ 'Backspace',
4620
+ 'Mod-Delete',
4621
+ 'Mod-Backspace',
4622
+ 'ArrowUp',
4623
+ 'ArrowDown',
4624
+ 'ArrowLeft',
4625
+ 'ArrowRight',
4626
+ 'Mod-d',
4627
+ 'Mod-D',
4628
+ 'Alt-ArrowUp',
4629
+ 'Alt-ArrowDown',
4630
+ ];
4631
+ function execCommand(view, command, payload) {
4632
+ view.focus();
4633
+ return command(payload)(view.state, view.dispatch, view);
4581
4634
  }
4582
- function prependNode(node, appended) {
4583
- if (isString(appended)) {
4584
- node.insertAdjacentHTML('afterbegin', appended);
4585
- }
4586
- else {
4587
- var nodes = appended.length
4588
- ? toArray(appended)
4589
- : [appended];
4590
- for (var i = nodes.length - 1, len = 0; i >= len; i -= 1) {
4591
- node.insertBefore(nodes[i], node.firstChild);
4592
- }
4635
+ var SpecManager = /** @class */ (function () {
4636
+ function SpecManager(specs) {
4637
+ this.specs = specs;
4593
4638
  }
4594
- }
4595
- function setAttributes(attributes, element) {
4596
- Object.keys(attributes).forEach(function (attrName) {
4597
- if (isNil(attributes[attrName])) {
4598
- element.removeAttribute(attrName);
4599
- }
4600
- else {
4601
- element.setAttribute(attrName, attributes[attrName]);
4602
- }
4639
+ Object.defineProperty(SpecManager.prototype, "nodes", {
4640
+ get: function () {
4641
+ return this.specs
4642
+ .filter(function (spec) { return spec.type === 'node'; })
4643
+ .reduce(function (nodes, _a) {
4644
+ var _b;
4645
+ var name = _a.name, schema = _a.schema;
4646
+ return __assign(__assign({}, nodes), (_b = {}, _b[name] = schema, _b));
4647
+ }, {});
4648
+ },
4649
+ enumerable: false,
4650
+ configurable: true
4603
4651
  });
4604
- }
4605
- function replaceBRWithEmptyBlock(html) {
4606
- // remove br in paragraph to compatible with markdown
4607
- var replacedHTML = html.replace(/<p><br\s*\/*><\/p>/gi, '<p></p>');
4608
- var reHTMLTag = new RegExp(HTML_TAG, 'ig');
4609
- var htmlTagMatched = replacedHTML.match(reHTMLTag);
4610
- htmlTagMatched === null || htmlTagMatched === void 0 ? void 0 : htmlTagMatched.forEach(function (htmlTag, index) {
4611
- if (reBR.test(htmlTag)) {
4612
- var alternativeTag = ALTERNATIVE_TAG_FOR_BR;
4613
- if (index) {
4614
- var prevTag = htmlTagMatched[index - 1];
4615
- var openTagMatched = prevTag.match(OPEN_TAG);
4616
- if (openTagMatched && !/br/i.test(openTagMatched[1])) {
4617
- var tagName = openTagMatched[1];
4618
- alternativeTag = "</" + tagName + "><" + tagName + ">";
4619
- }
4652
+ Object.defineProperty(SpecManager.prototype, "marks", {
4653
+ get: function () {
4654
+ return this.specs
4655
+ .filter(function (spec) { return spec.type === 'mark'; })
4656
+ .reduce(function (marks, _a) {
4657
+ var _b;
4658
+ var name = _a.name, schema = _a.schema;
4659
+ return __assign(__assign({}, marks), (_b = {}, _b[name] = schema, _b));
4660
+ }, {});
4661
+ },
4662
+ enumerable: false,
4663
+ configurable: true
4664
+ });
4665
+ SpecManager.prototype.commands = function (view, addedCommands) {
4666
+ var specCommands = this.specs
4667
+ .filter(function (_a) {
4668
+ var commands = _a.commands;
4669
+ return commands;
4670
+ })
4671
+ .reduce(function (allCommands, spec) {
4672
+ var commands = {};
4673
+ var specCommand = spec.commands();
4674
+ if (isFunction_default()(specCommand)) {
4675
+ commands[spec.name] = function (payload) { return execCommand(view, specCommand, payload); };
4620
4676
  }
4621
- replacedHTML = replacedHTML.replace(reBR, alternativeTag);
4677
+ else {
4678
+ Object.keys(specCommand).forEach(function (name) {
4679
+ commands[name] = function (payload) { return execCommand(view, specCommand[name], payload); };
4680
+ });
4681
+ }
4682
+ return __assign(__assign({}, allCommands), commands);
4683
+ }, {});
4684
+ var defaultCommands = getDefaultCommands();
4685
+ Object.keys(defaultCommands).forEach(function (name) {
4686
+ specCommands[name] = function (payload) { return execCommand(view, defaultCommands[name], payload); };
4687
+ });
4688
+ if (addedCommands) {
4689
+ Object.keys(addedCommands).forEach(function (name) {
4690
+ specCommands[name] = function (payload) { return execCommand(view, addedCommands[name], payload); };
4691
+ });
4622
4692
  }
4623
- });
4624
- return replacedHTML;
4625
- }
4693
+ return specCommands;
4694
+ };
4695
+ SpecManager.prototype.keymaps = function (useCommandShortcut) {
4696
+ var specKeymaps = this.specs.filter(function (spec) { return spec.keymaps; }).map(function (spec) { return spec.keymaps(); });
4697
+ return specKeymaps.map(function (keys) {
4698
+ if (!useCommandShortcut) {
4699
+ Object.keys(keys).forEach(function (key) {
4700
+ if (!common_includes(defaultCommandShortcuts, key)) {
4701
+ delete keys[key];
4702
+ }
4703
+ });
4704
+ }
4705
+ return (0,external_commonjs_prosemirror_keymap_commonjs2_prosemirror_keymap_amd_prosemirror_keymap_.keymap)(keys);
4706
+ });
4707
+ };
4708
+ SpecManager.prototype.setContext = function (context) {
4709
+ this.specs.forEach(function (spec) {
4710
+ spec.setContext(context);
4711
+ });
4712
+ };
4713
+ return SpecManager;
4714
+ }());
4715
+ /* harmony default export */ var specManager = (SpecManager);
4626
4716
 
4627
4717
  ;// CONCATENATED MODULE: ./src/markdown/helper/pos.ts
4628
4718
 
@@ -5099,34 +5189,61 @@ function getMarkForAdding(node, toastMark) {
5099
5189
  ;// CONCATENATED MODULE: ./src/markdown/plugins/previewHighlight.ts
5100
5190
 
5101
5191
 
5192
+
5193
+ var defaultToolbarStateKeys = [
5194
+ 'taskList',
5195
+ 'orderedList',
5196
+ 'bulletList',
5197
+ 'table',
5198
+ 'strong',
5199
+ 'emph',
5200
+ 'strike',
5201
+ 'heading',
5202
+ 'thematicBreak',
5203
+ 'blockQuote',
5204
+ 'code',
5205
+ 'codeBlock',
5206
+ 'indent',
5207
+ 'outdent',
5208
+ ];
5102
5209
  function getToolbarStateType(mdNode) {
5210
+ var type = mdNode.type;
5103
5211
  if (isListNode(mdNode)) {
5104
5212
  if (mdNode.listData.task) {
5105
5213
  return 'taskList';
5106
5214
  }
5107
5215
  return mdNode.listData.type === 'ordered' ? 'orderedList' : 'bulletList';
5108
5216
  }
5109
- if (mdNode.type.indexOf('table') !== -1) {
5217
+ if (type.indexOf('table') !== -1) {
5110
5218
  return 'table';
5111
5219
  }
5112
- return mdNode.type;
5220
+ if (!common_includes(defaultToolbarStateKeys, type)) {
5221
+ return null;
5222
+ }
5223
+ return type;
5113
5224
  }
5114
5225
  function getToolbarState(targetNode) {
5115
- var toolbarState = {};
5226
+ var toolbarState = {
5227
+ indent: { active: false, disabled: true },
5228
+ outdent: { active: false, disabled: true },
5229
+ };
5116
5230
  var listEnabled = true;
5117
5231
  traverseParentNodes(targetNode, function (mdNode) {
5118
5232
  var type = getToolbarStateType(mdNode);
5119
- if (type === 'customBlock' || type === 'image' || type === 'link') {
5233
+ if (!type) {
5120
5234
  return;
5121
5235
  }
5122
5236
  if (type === 'bulletList' || type === 'orderedList') {
5237
+ // to apply the nearlist list state in the nested list
5123
5238
  if (listEnabled) {
5124
- toolbarState[type] = true;
5239
+ toolbarState[type] = { active: true };
5240
+ toolbarState.indent.disabled = false;
5241
+ toolbarState.outdent.disabled = false;
5125
5242
  listEnabled = false;
5126
5243
  }
5127
5244
  }
5128
5245
  else {
5129
- toolbarState[type] = true;
5246
+ toolbarState[type] = { active: true };
5130
5247
  }
5131
5248
  });
5132
5249
  return toolbarState;
@@ -6167,9 +6284,11 @@ var ThematicBreak = /** @class */ (function (_super) {
6167
6284
 
6168
6285
 
6169
6286
 
6170
- function cannotBeListNode(_a) {
6171
- var type = _a.type;
6172
- return type === 'codeBlock' || type === 'heading' || type.indexOf('table') !== -1;
6287
+ function cannotBeListNode(_a, line) {
6288
+ var type = _a.type, sourcepos = _a.sourcepos;
6289
+ // eslint-disable-next-line prefer-destructuring
6290
+ var startLine = sourcepos[0][0];
6291
+ return line <= startLine && (type === 'codeBlock' || type === 'heading' || type.match('table'));
6173
6292
  }
6174
6293
  var ListItem = /** @class */ (function (_super) {
6175
6294
  __extends(ListItem, _super);
@@ -6272,7 +6391,7 @@ var ListItem = /** @class */ (function (_super) {
6272
6391
  var skipLines = [];
6273
6392
  for (var line = startLine; line <= endLine; line += 1) {
6274
6393
  var mdNode = toastMark.findFirstNodeAtLine(line);
6275
- if (mdNode && cannotBeListNode(mdNode)) {
6394
+ if (mdNode && cannotBeListNode(mdNode, line)) {
6276
6395
  break;
6277
6396
  }
6278
6397
  // to skip unnecessary processing
@@ -6592,57 +6711,6 @@ var Code = /** @class */ (function (_super) {
6592
6711
  }(mark));
6593
6712
 
6594
6713
 
6595
- ;// CONCATENATED MODULE: ./src/utils/encoder.ts
6596
- var encoderList = [
6597
- {
6598
- regExp: /\(/g,
6599
- encoded: '%28',
6600
- escaped: '\\(',
6601
- },
6602
- {
6603
- regExp: /\)/g,
6604
- encoded: '%29',
6605
- escaped: '\\)',
6606
- },
6607
- {
6608
- regExp: /\[/g,
6609
- encoded: '%5B',
6610
- escaped: '\\[',
6611
- },
6612
- {
6613
- regExp: /\]/g,
6614
- encoded: '%5D',
6615
- escaped: '\\]',
6616
- },
6617
- {
6618
- regExp: /</g,
6619
- encoded: '%3C',
6620
- escaped: '\\<',
6621
- },
6622
- {
6623
- regExp: />/g,
6624
- encoded: '%3E',
6625
- escaped: '\\>',
6626
- },
6627
- {
6628
- regExp: / /g,
6629
- encoded: '%20',
6630
- escaped: ' ',
6631
- },
6632
- ];
6633
- function escapeMarkdownText(text) {
6634
- return encoderList.reduce(function (result, _a) {
6635
- var regExp = _a.regExp, escaped = _a.escaped;
6636
- return result.replace(regExp, escaped);
6637
- }, text);
6638
- }
6639
- function encodeMarkdownText(text) {
6640
- return encoderList.reduce(function (result, _a) {
6641
- var regExp = _a.regExp, encoded = _a.encoded;
6642
- return result.replace(regExp, encoded);
6643
- }, text);
6644
- }
6645
-
6646
6714
  ;// CONCATENATED MODULE: ./src/markdown/marks/link.ts
6647
6715
 
6648
6716
 
@@ -6699,8 +6767,7 @@ var Link = /** @class */ (function (_super) {
6699
6767
  url = imageUrl;
6700
6768
  syntax = '!';
6701
6769
  }
6702
- text = escapeMarkdownText(text);
6703
- url = encodeMarkdownText(url);
6770
+ text = escapeTextForLink(text);
6704
6771
  syntax += "[" + text + "](" + url + ")";
6705
6772
  dispatch(tr.replaceWith(from, to, createTextNode(schema, syntax)));
6706
6773
  return true;
@@ -6886,6 +6953,9 @@ var Html = /** @class */ (function (_super) {
6886
6953
 
6887
6954
 
6888
6955
 
6956
+
6957
+
6958
+ var customBlockSyntax = '$$';
6889
6959
  var CustomBlock = /** @class */ (function (_super) {
6890
6960
  __extends(CustomBlock, _super);
6891
6961
  function CustomBlock() {
@@ -6909,6 +6979,22 @@ var CustomBlock = /** @class */ (function (_super) {
6909
6979
  enumerable: false,
6910
6980
  configurable: true
6911
6981
  });
6982
+ CustomBlock.prototype.commands = function () {
6983
+ return function (payload) { return function (state, dispatch) {
6984
+ var selection = state.selection, schema = state.schema, tr = state.tr;
6985
+ var _a = getRangeInfo(selection), startFromOffset = _a.startFromOffset, endToOffset = _a.endToOffset;
6986
+ if (!(payload === null || payload === void 0 ? void 0 : payload.info)) {
6987
+ return false;
6988
+ }
6989
+ var customBlock = "" + customBlockSyntax + payload.info;
6990
+ var startNode = createTextNode(schema, customBlock);
6991
+ var endNode = createTextNode(schema, customBlockSyntax);
6992
+ tr.insert(startFromOffset, startNode).split(startFromOffset + customBlock.length);
6993
+ tr.split(tr.mapping.map(endToOffset)).insert(tr.mapping.map(endToOffset), endNode);
6994
+ dispatch(tr.setSelection(createTextSelection(tr, tr.mapping.map(endToOffset) - (customBlockSyntax.length + 2))));
6995
+ return true;
6996
+ }; };
6997
+ };
6912
6998
  return CustomBlock;
6913
6999
  }(mark));
6914
7000
 
@@ -6993,6 +7079,7 @@ function smartTask(_a) {
6993
7079
 
6994
7080
 
6995
7081
 
7082
+
6996
7083
 
6997
7084
 
6998
7085
  var EVENT_TYPE = 'cut';
@@ -7014,15 +7101,20 @@ var MdEditor = /** @class */ (function (_super) {
7014
7101
  _this.commands = _this.createCommands();
7015
7102
  _this.specs.setContext(__assign(__assign({}, _this.context), { view: _this.view }));
7016
7103
  _this.createClipboard();
7017
- _this.eventEmitter.listen('changePreviewTabWrite', function () { return _this.toggleActive(true); });
7104
+ // To prevent unnecessary focus setting during initial rendering
7105
+ _this.eventEmitter.listen('changePreviewTabWrite', function (isMarkdownTabMounted) {
7106
+ return _this.toggleActive(true, isMarkdownTabMounted);
7107
+ });
7018
7108
  _this.eventEmitter.listen('changePreviewTabPreview', function () { return _this.toggleActive(false); });
7019
7109
  _this.initEvent();
7020
7110
  return _this;
7021
7111
  }
7022
- MdEditor.prototype.toggleActive = function (active) {
7112
+ MdEditor.prototype.toggleActive = function (active, isMarkdownTabMounted) {
7023
7113
  toggleClass(this.el, 'active', active);
7024
7114
  if (active) {
7025
- this.focus();
7115
+ if (!isMarkdownTabMounted) {
7116
+ this.focus();
7117
+ }
7026
7118
  }
7027
7119
  else {
7028
7120
  this.blur();
@@ -7036,10 +7128,14 @@ var MdEditor = /** @class */ (function (_super) {
7036
7128
  var clipboardData = ev.clipboardData || window.clipboardData;
7037
7129
  var items = clipboardData && clipboardData.items;
7038
7130
  if (items) {
7039
- var imageBlob = pasteImageOnly(items);
7040
- if (imageBlob) {
7041
- ev.preventDefault();
7042
- emitImageBlobHook(_this.eventEmitter, imageBlob, ev.type);
7131
+ var containRtfItem = toArray_default()(items).some(function (item) { return item.kind === 'string' && item.type === 'text/rtf'; });
7132
+ // if it contains rtf, it's most likely copy paste from office -> no image
7133
+ if (!containRtfItem) {
7134
+ var imageBlob = pasteImageOnly(items);
7135
+ if (imageBlob) {
7136
+ ev.preventDefault();
7137
+ emitImageBlobHook(_this.eventEmitter, imageBlob, ev.type);
7138
+ }
7043
7139
  }
7044
7140
  }
7045
7141
  });
@@ -12202,8 +12298,8 @@ var C_BACKSLASH$1 = 92;
12202
12298
  var reBackslashOrAmp = /[\\&]/;
12203
12299
  var ESCAPABLE = '[!"#$%&\'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]';
12204
12300
  var reEntityOrEscapedChar = new RegExp("\\\\" + ESCAPABLE + "|" + ENTITY, 'gi');
12205
- var XMLSPECIAL = '[&<>"]';
12206
- var reXmlSpecial = new RegExp(XMLSPECIAL, 'g');
12301
+ var esm_XMLSPECIAL = '[&<>"]';
12302
+ var esm_reXmlSpecial = new RegExp(esm_XMLSPECIAL, 'g');
12207
12303
  var unescapeChar = function (s) {
12208
12304
  if (s.charCodeAt(0) === C_BACKSLASH$1) {
12209
12305
  return s.charAt(1);
@@ -12225,7 +12321,7 @@ function normalizeURI(uri) {
12225
12321
  return uri;
12226
12322
  }
12227
12323
  }
12228
- function replaceUnsafeChar(s) {
12324
+ function esm_replaceUnsafeChar(s) {
12229
12325
  switch (s) {
12230
12326
  case '&':
12231
12327
  return '&amp;';
@@ -12239,9 +12335,9 @@ function replaceUnsafeChar(s) {
12239
12335
  return s;
12240
12336
  }
12241
12337
  }
12242
- function escapeXml(s) {
12243
- if (reXmlSpecial.test(s)) {
12244
- return s.replace(reXmlSpecial, replaceUnsafeChar);
12338
+ function esm_escapeXml(s) {
12339
+ if (esm_reXmlSpecial.test(s)) {
12340
+ return s.replace(esm_reXmlSpecial, esm_replaceUnsafeChar);
12245
12341
  }
12246
12342
  return s;
12247
12343
  }
@@ -13286,7 +13382,7 @@ var InlineParser = /** @class */ (function () {
13286
13382
  var literal = textNode.literal || '';
13287
13383
  var info = literal.split(/\s/)[0];
13288
13384
  newNode.info = info;
13289
- if (literal.length === info.length + 1) {
13385
+ if (literal.length <= info.length) {
13290
13386
  textNode.unlink();
13291
13387
  }
13292
13388
  else {
@@ -15721,7 +15817,6 @@ function filterDisallowedTags(str) {
15721
15817
  }
15722
15818
  return str;
15723
15819
  }
15724
- var CUSTOM_SYNTAX_LENGTH = 4;
15725
15820
  var baseConvertors = {
15726
15821
  heading: function (node, _a) {
15727
15822
  var entering = _a.entering;
@@ -15848,7 +15943,7 @@ var baseConvertors = {
15848
15943
  var infoWords = infoStr ? infoStr.split(/\s+/) : [];
15849
15944
  var codeClassNames = [];
15850
15945
  if (infoWords.length > 0 && infoWords[0].length > 0) {
15851
- codeClassNames.push("language-" + escapeXml(infoWords[0]));
15946
+ codeClassNames.push("language-" + esm_escapeXml(infoWords[0]));
15852
15947
  }
15853
15948
  return [
15854
15949
  { type: 'openTag', tagName: 'pre', outerNewLine: true },
@@ -15865,7 +15960,7 @@ var baseConvertors = {
15865
15960
  return {
15866
15961
  type: 'openTag',
15867
15962
  tagName: 'a',
15868
- attributes: esm_assign({ href: escapeXml(destination) }, (title && { title: escapeXml(title) })),
15963
+ attributes: esm_assign({ href: esm_escapeXml(destination) }, (title && { title: esm_escapeXml(title) })),
15869
15964
  };
15870
15965
  }
15871
15966
  return { type: 'closeTag', tagName: 'a' };
@@ -15878,7 +15973,7 @@ var baseConvertors = {
15878
15973
  type: 'openTag',
15879
15974
  tagName: 'img',
15880
15975
  selfClose: true,
15881
- attributes: esm_assign({ src: escapeXml(destination), alt: getChildrenText(node) }, (title && { title: escapeXml(title) })),
15976
+ attributes: esm_assign({ src: esm_escapeXml(destination), alt: getChildrenText(node) }, (title && { title: esm_escapeXml(title) })),
15882
15977
  };
15883
15978
  },
15884
15979
  customBlock: function (node, context, convertors) {
@@ -15912,7 +16007,7 @@ var baseConvertors = {
15912
16007
  ];
15913
16008
  },
15914
16009
  customInline: function (node, context, convertors) {
15915
- var _a = node, sourcepos = _a.sourcepos, info = _a.info;
16010
+ var _a = node, info = _a.info, firstChild = _a.firstChild;
15916
16011
  var nomalizedInfo = info.trim().toLowerCase();
15917
16012
  var customConvertor = convertors[nomalizedInfo];
15918
16013
  var entering = context.entering;
@@ -15924,13 +16019,10 @@ var baseConvertors = {
15924
16019
  console.warn("[@toast-ui/editor] - The error occurred when " + nomalizedInfo + " inline node was parsed in markdown renderer: " + e);
15925
16020
  }
15926
16021
  }
15927
- var text = sourcepos[1][1] - sourcepos[0][1] + 1 === info.length + CUSTOM_SYNTAX_LENGTH
15928
- ? ''
15929
- : info + " ";
15930
16022
  return entering
15931
16023
  ? [
15932
16024
  { type: 'openTag', tagName: 'span' },
15933
- { type: 'text', content: "$$" + text },
16025
+ { type: 'text', content: "$$" + info + (firstChild ? ' ' : '') },
15934
16026
  ]
15935
16027
  : [
15936
16028
  { type: 'text', content: '$$' },
@@ -16217,7 +16309,7 @@ var Renderer = /** @class */ (function () {
16217
16309
  }
16218
16310
  };
16219
16311
  Renderer.prototype.renderTextNode = function (node) {
16220
- this.buffer.push(escapeXml(node.content));
16312
+ this.buffer.push(esm_escapeXml(node.content));
16221
16313
  };
16222
16314
  Renderer.prototype.renderRawHtmlNode = function (node) {
16223
16315
  this.addOuterNewLine(node);
@@ -16283,7 +16375,7 @@ function sanitizeHTML(html, options) {
16283
16375
 
16284
16376
  function getChildrenHTML(node, typeName) {
16285
16377
  return node
16286
- .literal.replace(new RegExp("(<\\s*" + typeName + "[^>]+?>)|(</" + typeName + "\\s*[>])", 'ig'), '')
16378
+ .literal.replace(new RegExp("(<\\s*" + typeName + "[^>]*>)|(</" + typeName + "\\s*[>])", 'ig'), '')
16287
16379
  .trim();
16288
16380
  }
16289
16381
  function getHTMLAttrsByHTMLString(html) {
@@ -16541,14 +16633,6 @@ function isBlankLine(doc, index) {
16541
16633
  var pmNode = doc.child(index);
16542
16634
  return !pmNode.childCount || (pmNode.childCount === 1 && !((_a = pmNode.firstChild.text) === null || _a === void 0 ? void 0 : _a.trim()));
16543
16635
  }
16544
- function getNextNonBlankElement(mdNode) {
16545
- var next = mdNode.next, parent = mdNode.parent;
16546
- while (!next && parent) {
16547
- next = parent.next;
16548
- parent = parent.parent;
16549
- }
16550
- return next ? document.querySelector("[data-nodeid=\"" + next.id + "\"]") : null;
16551
- }
16552
16636
  function getEditorRangeHeightInfo(doc, mdNode, children) {
16553
16637
  var start = getMdStartLine(mdNode) - 1;
16554
16638
  var end = getMdEndLine(mdNode) - 1;
@@ -16616,11 +16700,11 @@ function getAdditionalPos(scrollTop, offsetTop, height, targetNodeHeight) {
16616
16700
  var ratio = Math.min((scrollTop - offsetTop) / height, 1);
16617
16701
  return ratio * targetNodeHeight;
16618
16702
  }
16619
- function getParentNodeObj(mdNode) {
16620
- var el = document.querySelector("[data-nodeid=\"" + mdNode.id + "\"]");
16703
+ function getParentNodeObj(previewContent, mdNode) {
16704
+ var el = previewContent.querySelector("[data-nodeid=\"" + mdNode.id + "\"]");
16621
16705
  while (!el || isStyledInlineNode(mdNode)) {
16622
16706
  mdNode = mdNode.parent;
16623
- el = document.querySelector("[data-nodeid=\"" + mdNode.id + "\"]");
16707
+ el = previewContent.querySelector("[data-nodeid=\"" + mdNode.id + "\"]");
16624
16708
  }
16625
16709
  return getNonNestableNodeObj({ mdNode: mdNode, el: el });
16626
16710
  }
@@ -16725,10 +16809,16 @@ var MarkdownPreview = /** @class */ (function () {
16725
16809
  this.sanitizer = sanitizer;
16726
16810
  this.initEvent(highlight);
16727
16811
  this.initContentSection();
16812
+ // To prevent overflowing contents in the viewer
16813
+ if (this.isViewer) {
16814
+ this.previewContent.style.overflowWrap = 'break-word';
16815
+ }
16728
16816
  }
16729
16817
  MarkdownPreview.prototype.initContentSection = function () {
16730
16818
  this.previewContent = createElementWith("<div class=\"" + cls('contents') + "\"></div>");
16731
- this.el.appendChild(this.previewContent);
16819
+ if (!this.isViewer) {
16820
+ this.el.appendChild(this.previewContent);
16821
+ }
16732
16822
  };
16733
16823
  MarkdownPreview.prototype.toggleActive = function (active) {
16734
16824
  toggleClass(this.el, 'active', active);
@@ -16736,6 +16826,9 @@ var MarkdownPreview = /** @class */ (function () {
16736
16826
  MarkdownPreview.prototype.initEvent = function (highlight) {
16737
16827
  var _this = this;
16738
16828
  this.eventEmitter.listen('updatePreview', this.update.bind(this));
16829
+ if (this.isViewer) {
16830
+ return;
16831
+ }
16739
16832
  if (highlight) {
16740
16833
  this.eventEmitter.listen('changeToolbarState', function (_a) {
16741
16834
  var mdNode = _a.mdNode, cursorPos = _a.cursorPos;
@@ -17345,7 +17438,10 @@ var TableOffsetMap = /** @class */ (function () {
17345
17438
  };
17346
17439
  TableOffsetMap.prototype.getNodeAndPos = function (rowIdx, colIdx) {
17347
17440
  var cellInfo = this.rowInfo[rowIdx][colIdx];
17348
- return { node: this.table.nodeAt(cellInfo.offset - 1), pos: cellInfo.offset };
17441
+ return {
17442
+ node: this.table.nodeAt(cellInfo.offset - this.tableStartOffset),
17443
+ pos: cellInfo.offset,
17444
+ };
17349
17445
  };
17350
17446
  TableOffsetMap.prototype.extendedRowspan = function (rowIdx, colIdx) {
17351
17447
  return false;
@@ -17855,7 +17951,7 @@ var map_Map = /** @class */ (function () {
17855
17951
  ;// CONCATENATED MODULE: ./src/i18n/i18n.ts
17856
17952
  /**
17857
17953
  * @fileoverview Implements i18n
17858
- * @author NHN FE Development Lab <dl_javascript@nhn.com>
17954
+ * @author NHN Cloud FE Development Lab <dl_javascript@nhn.com>
17859
17955
  */
17860
17956
 
17861
17957
 
@@ -18037,7 +18133,6 @@ function task() {
18037
18133
  ;// CONCATENATED MODULE: ./src/wysiwyg/plugins/toolbarState.ts
18038
18134
 
18039
18135
 
18040
-
18041
18136
  var EXCEPT_TYPES = ['image', 'link', 'customBlock', 'frontMatter'];
18042
18137
  var MARK_TYPES = ['strong', 'strike', 'emph', 'code'];
18043
18138
  var LIST_TYPES = ['bulletList', 'orderedList', 'taskList'];
@@ -18052,47 +18147,49 @@ function toolbarState_getToolbarStateType(node, parentNode) {
18052
18147
  return type;
18053
18148
  }
18054
18149
  function setListNodeToolbarState(type, nodeTypeState) {
18055
- nodeTypeState[type] = true;
18150
+ nodeTypeState[type] = { active: true };
18056
18151
  LIST_TYPES.filter(function (listName) { return listName !== type; }).forEach(function (listType) {
18057
18152
  if (nodeTypeState[listType]) {
18058
18153
  delete nodeTypeState[listType];
18059
18154
  }
18060
18155
  });
18061
18156
  }
18062
- function getMarkTypeStates(from, to, schema) {
18063
- var markTypeState = {};
18157
+ function setMarkTypeStates(from, to, schema, toolbarState) {
18064
18158
  MARK_TYPES.forEach(function (type) {
18065
18159
  var mark = schema.marks[type];
18066
18160
  var marksAtPos = from.marksAcross(to) || [];
18067
18161
  var foundMark = !!mark.isInSet(marksAtPos);
18068
18162
  if (foundMark) {
18069
- markTypeState[type] = true;
18163
+ toolbarState[type] = { active: true };
18070
18164
  }
18071
18165
  });
18072
- return markTypeState;
18073
18166
  }
18074
18167
  function toolbarState_getToolbarState(selection, doc, schema) {
18075
18168
  var $from = selection.$from, $to = selection.$to, from = selection.from, to = selection.to;
18076
- var nodeTypeState = {};
18077
- var markTypeState = {};
18169
+ var toolbarState = {
18170
+ indent: { active: false, disabled: true },
18171
+ outdent: { active: false, disabled: true },
18172
+ };
18078
18173
  doc.nodesBetween(from, to, function (node, _, parentNode) {
18079
18174
  var type = toolbarState_getToolbarStateType(node, parentNode);
18080
18175
  if (common_includes(EXCEPT_TYPES, type)) {
18081
18176
  return;
18082
18177
  }
18083
18178
  if (common_includes(LIST_TYPES, type)) {
18084
- setListNodeToolbarState(type, nodeTypeState);
18179
+ setListNodeToolbarState(type, toolbarState);
18180
+ toolbarState.indent.disabled = false;
18181
+ toolbarState.outdent.disabled = false;
18085
18182
  }
18086
18183
  else if (type === 'paragraph' || type === 'text') {
18087
- markTypeState = getMarkTypeStates($from, $to, schema);
18184
+ setMarkTypeStates($from, $to, schema, toolbarState);
18088
18185
  }
18089
18186
  else {
18090
- nodeTypeState[type] = true;
18187
+ toolbarState[type] = { active: true };
18091
18188
  }
18092
18189
  });
18093
- return __assign(__assign({}, nodeTypeState), markTypeState);
18190
+ return toolbarState;
18094
18191
  }
18095
- function toolbarState(eventEmitter) {
18192
+ function toolbarStateHighlight(eventEmitter) {
18096
18193
  return new external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.Plugin({
18097
18194
  view: function () {
18098
18195
  return {
@@ -18124,6 +18221,7 @@ var CustomBlockView = /** @class */ (function () {
18124
18221
  if (_this.innerEditorView) {
18125
18222
  throw new Error('The editor is already opened.');
18126
18223
  }
18224
+ _this.dom.draggable = false;
18127
18225
  _this.wrapper.style.display = 'none';
18128
18226
  _this.innerViewContainer.style.display = 'block';
18129
18227
  _this.innerEditorView = new external_commonjs_prosemirror_view_commonjs2_prosemirror_view_amd_prosemirror_view_.EditorView(_this.innerViewContainer, {
@@ -18378,6 +18476,7 @@ var CodeBlockView = /** @class */ (function () {
18378
18476
  this.dom = null;
18379
18477
  this.contentDOM = null;
18380
18478
  this.input = null;
18479
+ this.timer = null;
18381
18480
  this.handleMousedown = function (ev) {
18382
18481
  var target = ev.target;
18383
18482
  var style = getComputedStyle(target, ':after');
@@ -18433,7 +18532,7 @@ var CodeBlockView = /** @class */ (function () {
18433
18532
  input.type = 'text';
18434
18533
  input.value = this.node.attrs.language;
18435
18534
  wrapper.appendChild(input);
18436
- document.querySelector('.toastui-editor.ww-mode').appendChild(wrapper);
18535
+ this.view.dom.parentElement.appendChild(wrapper);
18437
18536
  var wrpperWidth = wrapper.clientWidth;
18438
18537
  css_default()(wrapper, {
18439
18538
  top: top + 10 + "px",
@@ -18443,7 +18542,10 @@ var CodeBlockView = /** @class */ (function () {
18443
18542
  this.input = input;
18444
18543
  this.input.addEventListener('blur', function () { return _this.changeLanguage(); });
18445
18544
  this.input.addEventListener('keydown', this.handleKeydown);
18446
- setTimeout(function () { return _this.input.focus(); });
18545
+ this.clearTimer();
18546
+ this.timer = setTimeout(function () {
18547
+ _this.input.focus();
18548
+ });
18447
18549
  };
18448
18550
  CodeBlockView.prototype.bindDOMEvent = function () {
18449
18551
  if (this.dom) {
@@ -18476,6 +18578,12 @@ var CodeBlockView = /** @class */ (function () {
18476
18578
  removeNode(parent);
18477
18579
  }
18478
18580
  };
18581
+ CodeBlockView.prototype.clearTimer = function () {
18582
+ if (this.timer) {
18583
+ clearTimeout(this.timer);
18584
+ this.timer = null;
18585
+ }
18586
+ };
18479
18587
  CodeBlockView.prototype.stopEvent = function () {
18480
18588
  return true;
18481
18589
  };
@@ -18488,6 +18596,7 @@ var CodeBlockView = /** @class */ (function () {
18488
18596
  };
18489
18597
  CodeBlockView.prototype.destroy = function () {
18490
18598
  this.reset();
18599
+ this.clearTimer();
18491
18600
  if (this.dom) {
18492
18601
  this.dom.removeEventListener('click', this.handleMousedown);
18493
18602
  }
@@ -19140,7 +19249,8 @@ var heading_Heading = /** @class */ (function (_super) {
19140
19249
  });
19141
19250
  Heading.prototype.commands = function () {
19142
19251
  return function (payload) { return function (state, dispatch) {
19143
- return (0,external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.setBlockType)(state.schema.nodes.heading, payload)(state, dispatch);
19252
+ var nodeType = state.schema.nodes[payload.level ? 'heading' : 'paragraph'];
19253
+ return (0,external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.setBlockType)(nodeType, payload)(state, dispatch);
19144
19254
  }; };
19145
19255
  };
19146
19256
  return Heading;
@@ -19592,9 +19702,10 @@ function addParagraphBeforeTable(tr, map, schema) {
19592
19702
  }
19593
19703
  return tr.setSelection(external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.Selection.near(tableStartPos, -1));
19594
19704
  }
19595
- function addParagraphAfterTable(tr, map, schema) {
19705
+ function addParagraphAfterTable(tr, map, schema, forcedAddtion) {
19706
+ if (forcedAddtion === void 0) { forcedAddtion = false; }
19596
19707
  var tableEndPos = tr.doc.resolve(map.tableEndOffset);
19597
- if (!tableEndPos.nodeAfter) {
19708
+ if (forcedAddtion || !tableEndPos.nodeAfter) {
19598
19709
  return addParagraph(tr, tableEndPos, schema);
19599
19710
  }
19600
19711
  return tr.setSelection(external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.Selection.near(tableEndPos, 1));
@@ -20016,6 +20127,29 @@ var table_Table = /** @class */ (function (_super) {
20016
20127
  return false;
20017
20128
  };
20018
20129
  };
20130
+ Table.prototype.exitTable = function () {
20131
+ return function (state, dispatch) {
20132
+ var selection = state.selection, tr = state.tr, schema = state.schema;
20133
+ var $from = selection.$from;
20134
+ var cell = findNodeBy($from, function (_a) {
20135
+ var type = _a.type;
20136
+ return type.name === 'tableHeadCell' || type.name === 'tableBodyCell';
20137
+ });
20138
+ if (cell) {
20139
+ var para = findNodeBy($from, function (_a) {
20140
+ var type = _a.type;
20141
+ return type.name === 'paragraph';
20142
+ });
20143
+ if (para) {
20144
+ var anchor = getResolvedSelection(selection).anchor;
20145
+ var map = TableOffsetMap.create(anchor);
20146
+ dispatch(addParagraphAfterTable(tr, map, schema, true));
20147
+ return true;
20148
+ }
20149
+ }
20150
+ return false;
20151
+ };
20152
+ };
20019
20153
  Table.prototype.commands = function () {
20020
20154
  return {
20021
20155
  addTable: this.addTable(),
@@ -20042,6 +20176,7 @@ var table_Table = /** @class */ (function (_super) {
20042
20176
  'Mod-Backspace': deleteCellContent,
20043
20177
  Delete: deleteCellContent,
20044
20178
  'Mod-Delete': deleteCellContent,
20179
+ 'Mod-Enter': this.exitTable(),
20045
20180
  };
20046
20181
  };
20047
20182
  return Table;
@@ -20302,7 +20437,7 @@ var Image = /** @class */ (function (_super) {
20302
20437
  var attrs = _a.attrs;
20303
20438
  return [
20304
20439
  attrs.rawHTML || 'img',
20305
- __assign(__assign({ src: attrs.imageUrl }, (attrs.altText && { alt: attrs.altText })), getCustomAttrs(attrs)),
20440
+ __assign(__assign({ src: escapeXml(attrs.imageUrl) }, (attrs.altText && { alt: attrs.altText })), getCustomAttrs(attrs)),
20306
20441
  ];
20307
20442
  },
20308
20443
  };
@@ -20317,7 +20452,7 @@ var Image = /** @class */ (function (_super) {
20317
20452
  if (!imageUrl) {
20318
20453
  return false;
20319
20454
  }
20320
- var node = schema.nodes.image.createAndFill(__assign({ imageUrl: encodeMarkdownText(imageUrl) }, (altText && { altText: altText })));
20455
+ var node = schema.nodes.image.createAndFill(__assign({ imageUrl: imageUrl }, (altText && { altText: altText })));
20321
20456
  dispatch(tr.replaceSelectionWith(node).scrollIntoView());
20322
20457
  return true;
20323
20458
  }; };
@@ -20594,7 +20729,7 @@ var link_Link = /** @class */ (function (_super) {
20594
20729
  get: function () {
20595
20730
  var _this = this;
20596
20731
  return {
20597
- attrs: __assign({ linkUrl: { default: '' }, linkText: { default: null }, rawHTML: { default: null } }, getDefaultCustomAttrs()),
20732
+ attrs: __assign({ linkUrl: { default: '' }, title: { default: null }, rawHTML: { default: null } }, getDefaultCustomAttrs()),
20598
20733
  inclusive: false,
20599
20734
  parseDOM: [
20600
20735
  {
@@ -20603,8 +20738,9 @@ var link_Link = /** @class */ (function (_super) {
20603
20738
  var sanitizedDOM = sanitizeHTML(dom, { RETURN_DOM_FRAGMENT: true })
20604
20739
  .firstChild;
20605
20740
  var href = sanitizedDOM.getAttribute('href') || '';
20741
+ var title = sanitizedDOM.getAttribute('title') || '';
20606
20742
  var rawHTML = sanitizedDOM.getAttribute('data-raw-html');
20607
- return __assign({ linkUrl: href, linkText: sanitizedDOM.textContent }, (rawHTML && { rawHTML: rawHTML }));
20743
+ return __assign({ linkUrl: href, title: title }, (rawHTML && { rawHTML: rawHTML }));
20608
20744
  },
20609
20745
  },
20610
20746
  ],
@@ -20612,7 +20748,7 @@ var link_Link = /** @class */ (function (_super) {
20612
20748
  var attrs = _a.attrs;
20613
20749
  return [
20614
20750
  attrs.rawHTML || 'a',
20615
- __assign(__assign({ href: attrs.linkUrl }, _this.linkAttributes), getCustomAttrs(attrs)),
20751
+ __assign(__assign({ href: escapeXml(attrs.linkUrl) }, _this.linkAttributes), getCustomAttrs(attrs)),
20616
20752
  ];
20617
20753
  },
20618
20754
  };
@@ -20626,10 +20762,7 @@ var link_Link = /** @class */ (function (_super) {
20626
20762
  var schema = state.schema, tr = state.tr, selection = state.selection;
20627
20763
  var empty = selection.empty, from = selection.from, to = selection.to;
20628
20764
  if (from && to && linkUrl) {
20629
- var attrs = {
20630
- linkUrl: encodeMarkdownText(linkUrl),
20631
- linkText: escapeMarkdownText(linkText),
20632
- };
20765
+ var attrs = { linkUrl: linkUrl };
20633
20766
  var mark = schema.mark('link', attrs);
20634
20767
  if (empty && linkText) {
20635
20768
  var node = createTextNode(schema, linkText, mark);
@@ -20715,6 +20848,7 @@ var code_Code = /** @class */ (function (_super) {
20715
20848
  ;// CONCATENATED MODULE: ./src/wysiwyg/nodes/customBlock.ts
20716
20849
 
20717
20850
 
20851
+
20718
20852
  var customBlock_CustomBlock = /** @class */ (function (_super) {
20719
20853
  __extends(CustomBlock, _super);
20720
20854
  function CustomBlock() {
@@ -20756,6 +20890,13 @@ var customBlock_CustomBlock = /** @class */ (function (_super) {
20756
20890
  enumerable: false,
20757
20891
  configurable: true
20758
20892
  });
20893
+ CustomBlock.prototype.commands = function () {
20894
+ return function (payload) { return function (state, dispatch) {
20895
+ return (payload === null || payload === void 0 ? void 0 : payload.info)
20896
+ ? (0,external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.setBlockType)(state.schema.nodes.customBlock, payload)(state, dispatch)
20897
+ : false;
20898
+ }; };
20899
+ };
20759
20900
  return CustomBlock;
20760
20901
  }(node));
20761
20902
 
@@ -20782,8 +20923,10 @@ var FrontMatter = /** @class */ (function (_super) {
20782
20923
  content: 'text*',
20783
20924
  group: 'block',
20784
20925
  code: true,
20926
+ defining: true,
20785
20927
  parseDOM: [
20786
20928
  {
20929
+ preserveWhitespace: 'full',
20787
20930
  tag: 'div[data-front-matter]',
20788
20931
  },
20789
20932
  ],
@@ -20813,6 +20956,56 @@ var FrontMatter = /** @class */ (function (_super) {
20813
20956
  }(node));
20814
20957
 
20815
20958
 
20959
+ ;// CONCATENATED MODULE: ./src/wysiwyg/nodes/htmlComment.ts
20960
+
20961
+
20962
+
20963
+ var HTMLComment = /** @class */ (function (_super) {
20964
+ __extends(HTMLComment, _super);
20965
+ function HTMLComment() {
20966
+ return _super !== null && _super.apply(this, arguments) || this;
20967
+ }
20968
+ Object.defineProperty(HTMLComment.prototype, "name", {
20969
+ get: function () {
20970
+ return 'htmlComment';
20971
+ },
20972
+ enumerable: false,
20973
+ configurable: true
20974
+ });
20975
+ Object.defineProperty(HTMLComment.prototype, "schema", {
20976
+ get: function () {
20977
+ return {
20978
+ content: 'text*',
20979
+ group: 'block',
20980
+ code: true,
20981
+ defining: true,
20982
+ parseDOM: [{ preserveWhitespace: 'full', tag: 'div[data-html-comment]' }],
20983
+ toDOM: function () {
20984
+ return ['div', { 'data-html-comment': 'true' }, 0];
20985
+ },
20986
+ };
20987
+ },
20988
+ enumerable: false,
20989
+ configurable: true
20990
+ });
20991
+ HTMLComment.prototype.commands = function () {
20992
+ return function () { return function (state, dispatch, view) {
20993
+ var $from = state.selection.$from;
20994
+ if (view.endOfTextblock('down') && $from.node().type.name === 'htmlComment') {
20995
+ return (0,external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.exitCode)(state, dispatch);
20996
+ }
20997
+ return false;
20998
+ }; };
20999
+ };
21000
+ HTMLComment.prototype.keymaps = function () {
21001
+ return {
21002
+ Enter: this.commands()(),
21003
+ };
21004
+ };
21005
+ return HTMLComment;
21006
+ }(node));
21007
+
21008
+
20816
21009
  ;// CONCATENATED MODULE: ./src/wysiwyg/specCreator.ts
20817
21010
 
20818
21011
 
@@ -20838,6 +21031,7 @@ var FrontMatter = /** @class */ (function (_super) {
20838
21031
 
20839
21032
 
20840
21033
 
21034
+
20841
21035
 
20842
21036
 
20843
21037
  function createSpecs(linkAttributes) {
@@ -20867,6 +21061,7 @@ function createSpecs(linkAttributes) {
20867
21061
  new customBlock_CustomBlock(),
20868
21062
  new FrontMatter(),
20869
21063
  new Widget(),
21064
+ new HTMLComment(),
20870
21065
  ]);
20871
21066
  }
20872
21067
 
@@ -20892,6 +21087,7 @@ function createSpecs(linkAttributes) {
20892
21087
 
20893
21088
 
20894
21089
 
21090
+
20895
21091
 
20896
21092
 
20897
21093
  var CONTENTS_CLASS_NAME = cls('contents');
@@ -20936,7 +21132,7 @@ var WysiwygEditor = /** @class */ (function (_super) {
20936
21132
  tableSelection(),
20937
21133
  tableContextMenu(this.eventEmitter),
20938
21134
  task(),
20939
- toolbarState(this.eventEmitter)
21135
+ toolbarStateHighlight(this.eventEmitter)
20940
21136
  ], this.createPluginProps()));
20941
21137
  };
20942
21138
  WysiwygEditor.prototype.createPluginNodeViews = function () {
@@ -20987,11 +21183,15 @@ var WysiwygEditor = /** @class */ (function (_super) {
20987
21183
  paste: function (_, ev) {
20988
21184
  var clipboardData = ev.clipboardData || window.clipboardData;
20989
21185
  var items = clipboardData === null || clipboardData === void 0 ? void 0 : clipboardData.items;
20990
- if ((items === null || items === void 0 ? void 0 : items.length) === 1) {
20991
- var imageBlob = pasteImageOnly(items);
20992
- if (imageBlob) {
20993
- ev.preventDefault();
20994
- emitImageBlobHook(_this.eventEmitter, imageBlob, ev.type);
21186
+ if (items) {
21187
+ var containRtfItem = toArray_default()(items).some(function (item) { return item.kind === 'string' && item.type === 'text/rtf'; });
21188
+ // if it contains rtf, it's most likely copy paste from office -> no image
21189
+ if (!containRtfItem) {
21190
+ var imageBlob = pasteImageOnly(items);
21191
+ if (imageBlob) {
21192
+ ev.preventDefault();
21193
+ emitImageBlobHook(_this.eventEmitter, imageBlob, ev.type);
21194
+ }
20995
21195
  }
20996
21196
  }
20997
21197
  return false;
@@ -21132,6 +21332,7 @@ var eventTypeList = [
21132
21332
  'mixinTableOffsetMapPrototype',
21133
21333
  'setFocusedNode',
21134
21334
  'removePopupWidget',
21335
+ 'query',
21135
21336
  // provide event for user
21136
21337
  'openPopup',
21137
21338
  'closePopup',
@@ -21139,6 +21340,7 @@ var eventTypeList = [
21139
21340
  'beforePreviewRender',
21140
21341
  'beforeConvertWysiwygToMarkdown',
21141
21342
  'load',
21343
+ 'loadUI',
21142
21344
  'change',
21143
21345
  'caretChange',
21144
21346
  'destroy',
@@ -21720,7 +21922,7 @@ var toWwConvertors = {
21720
21922
  var link = state.schema.marks.link;
21721
21923
  var _b = node, destination = _b.destination, title = _b.title;
21722
21924
  if (entering) {
21723
- var attrs = __assign(__assign({ linkUrl: destination }, (title && { linkText: title })), customAttrs);
21925
+ var attrs = __assign({ linkUrl: destination, title: title }, customAttrs);
21724
21926
  state.openMark(link.create(attrs));
21725
21927
  }
21726
21928
  else {
@@ -21786,7 +21988,7 @@ var toWwConvertors = {
21786
21988
  var tablePart = node.parent.parent;
21787
21989
  var cell = tablePart.type === 'tableHead' ? tableHeadCell : tableBodyCell;
21788
21990
  var table = tablePart.parent;
21789
- var align = table.columns[node.startIdx].align;
21991
+ var align = (table.columns[node.startIdx] || {}).align;
21790
21992
  var attrs = __assign({}, node.attrs);
21791
21993
  if (align) {
21792
21994
  attrs.align = align;
@@ -21864,26 +22066,34 @@ var toWwConvertors = {
21864
22066
  htmlBlock: function (state, node) {
21865
22067
  var html = node.literal;
21866
22068
  var container = document.createElement('div');
21867
- var matched = html.match(reHTMLTag);
21868
- var openTagName = matched[1], closeTagName = matched[3];
21869
- var typeName = (openTagName || closeTagName).toLowerCase();
21870
- var nodeType = state.schema.nodes[typeName];
21871
- var sanitizedHTML = sanitizeHTML(html);
21872
- // for user defined html schema
21873
- if (nodeType === null || nodeType === void 0 ? void 0 : nodeType.spec.attrs.htmlBlock) {
21874
- var htmlAttrs = getHTMLAttrsByHTMLString(sanitizedHTML);
21875
- var childrenHTML = getChildrenHTML(node, typeName);
21876
- state.addNode(nodeType, { htmlAttrs: htmlAttrs, childrenHTML: childrenHTML });
22069
+ var isHTMLComment = reHTMLComment.test(html);
22070
+ if (isHTMLComment) {
22071
+ state.openNode(state.schema.nodes.htmlComment);
22072
+ state.addText(node.literal);
22073
+ state.closeNode();
21877
22074
  }
21878
22075
  else {
21879
- container.innerHTML = sanitizedHTML;
21880
- addRawHTMLAttributeToDOM(container);
21881
- state.convertByDOMParser(container);
22076
+ var matched = html.match(reHTMLTag);
22077
+ var openTagName = matched[1], closeTagName = matched[3];
22078
+ var typeName = (openTagName || closeTagName).toLowerCase();
22079
+ var nodeType = state.schema.nodes[typeName];
22080
+ var sanitizedHTML = sanitizeHTML(html);
22081
+ // for user defined html schema
22082
+ if (nodeType === null || nodeType === void 0 ? void 0 : nodeType.spec.attrs.htmlBlock) {
22083
+ var htmlAttrs = getHTMLAttrsByHTMLString(sanitizedHTML);
22084
+ var childrenHTML = getChildrenHTML(node, typeName);
22085
+ state.addNode(nodeType, { htmlAttrs: htmlAttrs, childrenHTML: childrenHTML });
22086
+ }
22087
+ else {
22088
+ container.innerHTML = sanitizedHTML;
22089
+ addRawHTMLAttributeToDOM(container);
22090
+ state.convertByDOMParser(container);
22091
+ }
21882
22092
  }
21883
22093
  },
21884
22094
  customInline: function (state, node, _a) {
21885
22095
  var entering = _a.entering, skipChildren = _a.skipChildren;
21886
- var info = node.info;
22096
+ var _b = node, info = _b.info, firstChild = _b.firstChild;
21887
22097
  var schema = state.schema;
21888
22098
  if (info.indexOf('widget') !== -1 && entering) {
21889
22099
  var content = getWidgetContent(node);
@@ -21892,6 +22102,13 @@ var toWwConvertors = {
21892
22102
  schema.text(createWidgetContent(info, content)),
21893
22103
  ]);
21894
22104
  }
22105
+ else {
22106
+ var text = '$$';
22107
+ if (entering) {
22108
+ text += firstChild ? info + " " : info;
22109
+ }
22110
+ state.addText(text);
22111
+ }
21895
22112
  },
21896
22113
  };
21897
22114
  function createWwConvertors(customConvertors) {
@@ -21907,7 +22124,7 @@ function createWwConvertors(customConvertors) {
21907
22124
  var wwConvertor = toWwConvertors[type];
21908
22125
  if (wwConvertor && !common_includes(['htmlBlock', 'htmlInline'], type)) {
21909
22126
  convertors[type] = function (state, node, context) {
21910
- context.origin = function () { return orgConvertors[type](node, context); };
22127
+ context.origin = function () { return orgConvertors[type](node, context, orgConvertors); };
21911
22128
  var tokens = customConvertors[type](node, context);
21912
22129
  var attrs;
21913
22130
  if (tokens) {
@@ -22105,7 +22322,13 @@ var nodeTypeWriters = {
22105
22322
  text: function (state, _a) {
22106
22323
  var _b;
22107
22324
  var node = _a.node;
22108
- state.text((_b = node.text) !== null && _b !== void 0 ? _b : '');
22325
+ var text = (_b = node.text) !== null && _b !== void 0 ? _b : '';
22326
+ if ((node.marks || []).some(function (mark) { return mark.type.name === 'link'; })) {
22327
+ state.text(escapeTextForLink(text), false);
22328
+ }
22329
+ else {
22330
+ state.text(text);
22331
+ }
22109
22332
  },
22110
22333
  paragraph: function (state, _a) {
22111
22334
  var node = _a.node, parent = _a.parent, _b = _a.index, index = _b === void 0 ? 0 : _b;
@@ -22270,9 +22493,19 @@ var nodeTypeWriters = {
22270
22493
  var text = _a.text;
22271
22494
  state.write(text);
22272
22495
  },
22273
- html: function (state, _, _a) {
22274
- var text = _a.text;
22496
+ html: function (state, _a, _b) {
22497
+ var node = _a.node;
22498
+ var text = _b.text;
22499
+ state.write(text);
22500
+ if (node.attrs.htmlBlock) {
22501
+ state.closeBlock(node);
22502
+ }
22503
+ },
22504
+ htmlComment: function (state, _a, _b) {
22505
+ var node = _a.node;
22506
+ var text = _b.text;
22275
22507
  state.write(text);
22508
+ state.closeBlock(node);
22276
22509
  },
22277
22510
  };
22278
22511
  function write(type, _a) {
@@ -22434,13 +22667,13 @@ var toMdConvertors = {
22434
22667
  image: function (_a) {
22435
22668
  var node = _a.node;
22436
22669
  var attrs = node.attrs;
22437
- var altText = common_escape(attrs.altText || '');
22438
- var imageUrl = common_escape(attrs.imageUrl);
22439
- var altAttr = altText ? " alt=\"" + altText + "\"" : '';
22670
+ var rawHTML = attrs.rawHTML, altText = attrs.altText;
22671
+ var imageUrl = attrs.imageUrl.replace(/&amp;/g, '&');
22672
+ var altAttr = altText ? " alt=\"" + escapeXml(altText) + "\"" : '';
22440
22673
  return {
22441
- rawHTML: attrs.rawHTML ? "<" + attrs.rawHTML + " src=\"" + imageUrl + "\"" + altAttr + ">" : null,
22674
+ rawHTML: rawHTML ? "<" + rawHTML + " src=\"" + escapeXml(imageUrl) + "\"" + altAttr + ">" : null,
22442
22675
  attrs: {
22443
- altText: altText,
22676
+ altText: escapeTextForLink(altText || ''),
22444
22677
  imageUrl: imageUrl,
22445
22678
  },
22446
22679
  };
@@ -22503,17 +22736,17 @@ var toMdConvertors = {
22503
22736
  var node = _a.node;
22504
22737
  var entering = _b.entering;
22505
22738
  var attrs = node.attrs;
22506
- var linkUrl = common_escape(attrs.linkUrl);
22507
- var rawHTML = attrs.rawHTML;
22739
+ var title = attrs.title, rawHTML = attrs.rawHTML;
22740
+ var linkUrl = attrs.linkUrl.replace(/&amp;/g, '&');
22741
+ var titleAttr = title ? " title=\"" + escapeXml(title) + "\"" : '';
22508
22742
  if (entering) {
22509
22743
  return {
22510
22744
  delim: '[',
22511
- rawHTML: rawHTML ? "<" + rawHTML + " href=\"" + linkUrl + "\">" : null,
22745
+ rawHTML: rawHTML ? "<" + rawHTML + " href=\"" + escapeXml(linkUrl) + "\"" + titleAttr + ">" : null,
22512
22746
  };
22513
22747
  }
22514
- var linkText = attrs.title ? " " + quote(attrs.linkText) : '';
22515
22748
  return {
22516
- delim: "](" + linkText + linkUrl + ")",
22749
+ delim: "](" + linkUrl + (title ? " " + quote(escapeTextForLink(title)) : '') + ")",
22517
22750
  rawHTML: getCloseRawHTML(rawHTML),
22518
22751
  };
22519
22752
  },
@@ -22531,6 +22764,12 @@ var toMdConvertors = {
22531
22764
  rawHTML: rawHTML,
22532
22765
  };
22533
22766
  },
22767
+ htmlComment: function (_a) {
22768
+ var node = _a.node;
22769
+ return {
22770
+ text: node.textContent,
22771
+ };
22772
+ },
22534
22773
  // html inline node, html block node
22535
22774
  html: function (_a, _b) {
22536
22775
  var node = _a.node;
@@ -22540,7 +22779,8 @@ var toMdConvertors = {
22540
22779
  var openTag = "<" + tagName;
22541
22780
  var closeTag = "</" + tagName + ">";
22542
22781
  Object.keys(attrs).forEach(function (attrName) {
22543
- openTag += " " + attrName + "=\"" + attrs[attrName] + "\"";
22782
+ // To prevent broken converting when attributes has double quote string
22783
+ openTag += " " + attrName + "=\"" + attrs[attrName].replace(/"/g, "'") + "\"";
22544
22784
  });
22545
22785
  openTag += '>';
22546
22786
  if (node.attrs.htmlInline) {
@@ -22959,11 +23199,13 @@ var Convertor = /** @class */ (function () {
22959
23199
 
22960
23200
 
22961
23201
 
23202
+
22962
23203
  function execPlugin(plugin, eventEmitter, usageStatistics) {
22963
- var pmState = { Plugin: external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.Plugin, Selection: external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.Selection, TextSelection: external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.TextSelection };
23204
+ var pmState = { Plugin: external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.Plugin, PluginKey: external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.PluginKey, Selection: external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.Selection, TextSelection: external_commonjs_prosemirror_state_commonjs2_prosemirror_state_amd_prosemirror_state_.TextSelection };
22964
23205
  var pmView = { Decoration: external_commonjs_prosemirror_view_commonjs2_prosemirror_view_amd_prosemirror_view_.Decoration, DecorationSet: external_commonjs_prosemirror_view_commonjs2_prosemirror_view_amd_prosemirror_view_.DecorationSet };
22965
23206
  var pmModel = { Fragment: external_commonjs_prosemirror_model_commonjs2_prosemirror_model_amd_prosemirror_model_.Fragment };
22966
- var context = { eventEmitter: eventEmitter, usageStatistics: usageStatistics, pmState: pmState, pmView: pmView, pmModel: pmModel, i18n: i18n };
23207
+ var pmRules = { InputRule: external_commonjs_prosemirror_inputrules_commonjs2_prosemirror_inputrules_amd_prosemirror_inputrules_.InputRule, inputRules: external_commonjs_prosemirror_inputrules_commonjs2_prosemirror_inputrules_amd_prosemirror_inputrules_.inputRules, undoInputRule: external_commonjs_prosemirror_inputrules_commonjs2_prosemirror_inputrules_amd_prosemirror_inputrules_.undoInputRule };
23208
+ var context = { eventEmitter: eventEmitter, usageStatistics: usageStatistics, pmState: pmState, pmView: pmView, pmModel: pmModel, pmRules: pmRules, i18n: i18n };
22967
23209
  if (isArray_default()(plugin)) {
22968
23210
  var pluginFn = plugin[0], _a = plugin[1], options = _a === void 0 ? {} : _a;
22969
23211
  return pluginFn(context, options);
@@ -23109,7 +23351,7 @@ var ToastUIEditorViewer = /** @class */ (function () {
23109
23351
  customParser: markdownParsers,
23110
23352
  });
23111
23353
  this.preview = new mdPreview(this.eventEmitter, __assign(__assign({}, rendererOptions), { isViewer: true }));
23112
- on_default()(this.preview.el, 'mousedown', this.toggleTask.bind(this));
23354
+ on_default()(this.preview.previewContent, 'mousedown', this.toggleTask.bind(this));
23113
23355
  if (initialValue) {
23114
23356
  this.setMarkdown(initialValue);
23115
23357
  }
@@ -23131,6 +23373,10 @@ var ToastUIEditorViewer = /** @class */ (function () {
23131
23373
  element.hasAttribute(TASK_ATTR_NAME) &&
23132
23374
  isPositionInBox(style, ev.offsetX, ev.offsetY)) {
23133
23375
  toggleClass(element, TASK_CHECKED_CLASS_NAME);
23376
+ this.eventEmitter.emit('change', {
23377
+ source: 'viewer',
23378
+ date: ev,
23379
+ });
23134
23380
  }
23135
23381
  };
23136
23382
  /**
@@ -23242,7 +23488,7 @@ function createMdLikeNode(node) {
23242
23488
  };
23243
23489
  var nodeTypeMap = {
23244
23490
  heading: { level: attrs.level },
23245
- link: { destination: attrs.linkUrl, title: attrs.linkText },
23491
+ link: { destination: attrs.linkUrl, title: attrs.title },
23246
23492
  image: { destination: attrs.imageUrl },
23247
23493
  codeBlock: { info: attrs.language },
23248
23494
  bulletList: { type: 'list', listData: { type: 'bullet' } },
@@ -23395,6 +23641,7 @@ var ScrollSync = /** @class */ (function () {
23395
23641
  this.latestPreviewScrollTop = null;
23396
23642
  this.blockedScroll = null;
23397
23643
  this.active = true;
23644
+ this.timer = null;
23398
23645
  var previewRoot = preview.previewContent, previewEl = preview.el;
23399
23646
  this.previewRoot = previewRoot;
23400
23647
  this.previewEl = previewEl;
@@ -23407,10 +23654,11 @@ var ScrollSync = /** @class */ (function () {
23407
23654
  ScrollSync.prototype.addScrollSyncEvent = function () {
23408
23655
  var _this = this;
23409
23656
  this.eventEmitter.listen('afterPreviewRender', function () {
23657
+ _this.clearTimer();
23410
23658
  // Immediately after the 'afterPreviewRender' event has occurred,
23411
23659
  // browser rendering is not yet complete.
23412
23660
  // So the size of elements can not be accurately measured.
23413
- setTimeout(function () {
23661
+ _this.timer = setTimeout(function () {
23414
23662
  _this.syncPreviewScrollTop(true);
23415
23663
  }, 200);
23416
23664
  });
@@ -23437,7 +23685,7 @@ var ScrollSync = /** @class */ (function () {
23437
23685
  var pos = this.mdEditor.getSelection();
23438
23686
  var firstMdNode = this.toastMark.findFirstNodeAtLine(pos[0][0]);
23439
23687
  var previewHeight = this.previewEl.clientHeight;
23440
- var el = getParentNodeObj(firstMdNode).el;
23688
+ var el = getParentNodeObj(this.previewRoot, firstMdNode).el;
23441
23689
  var totalOffsetTop = getTotalOffsetTop(el, this.previewRoot) || el.offsetTop;
23442
23690
  var nodeHeight = el.clientHeight;
23443
23691
  // multiply 0.5 for calculating the position in the middle of preview area
@@ -23469,7 +23717,7 @@ var ScrollSync = /** @class */ (function () {
23469
23717
  targetScrollTop = scrollTopByEditing;
23470
23718
  }
23471
23719
  else {
23472
- var _d = getParentNodeObj(firstMdNode), el = _d.el, mdNode = _d.mdNode;
23720
+ var _d = getParentNodeObj(this.previewRoot, firstMdNode), el = _d.el, mdNode = _d.mdNode;
23473
23721
  var _e = getEditorRangeHeightInfo(doc, mdNode, children), height = _e.height, rect = _e.rect;
23474
23722
  var totalOffsetTop = getTotalOffsetTop(el, previewRoot) || el.offsetTop;
23475
23723
  var nodeHeight = el.clientHeight;
@@ -23497,7 +23745,7 @@ var ScrollSync = /** @class */ (function () {
23497
23745
  }
23498
23746
  var children = dom.children;
23499
23747
  var mdNodeId = Number(targetNode.getAttribute('data-nodeid'));
23500
- var _b = getParentNodeObj(toastMark.findNodeById(mdNodeId)), mdNode = _b.mdNode, el = _b.el;
23748
+ var _b = getParentNodeObj(this.previewRoot, toastMark.findNodeById(mdNodeId)), mdNode = _b.mdNode, el = _b.el;
23501
23749
  var mdNodeStartLine = getMdStartLine(mdNode);
23502
23750
  targetScrollTop = children[mdNodeStartLine - 1].offsetTop;
23503
23751
  var height = getEditorRangeHeightInfo(state.doc, mdNode, children).height;
@@ -23536,7 +23784,14 @@ var ScrollSync = /** @class */ (function () {
23536
23784
  };
23537
23785
  animate(curScrollTop, targetScrollTop, syncCallbacks);
23538
23786
  };
23787
+ ScrollSync.prototype.clearTimer = function () {
23788
+ if (this.timer) {
23789
+ clearTimeout(this.timer);
23790
+ this.timer = null;
23791
+ }
23792
+ };
23539
23793
  ScrollSync.prototype.destroy = function () {
23794
+ this.clearTimer();
23540
23795
  this.eventEmitter.removeEventHandler('scroll');
23541
23796
  this.eventEmitter.removeEventHandler('afterPreviewRender');
23542
23797
  };
@@ -23544,6 +23799,19 @@ var ScrollSync = /** @class */ (function () {
23544
23799
  }());
23545
23800
 
23546
23801
 
23802
+ ;// CONCATENATED MODULE: ./src/queries/queryManager.ts
23803
+ var queryMap = {
23804
+ getPopupInitialValues: function (editor, payload) {
23805
+ var popupName = payload.popupName;
23806
+ return popupName === 'link' ? { linkText: editor.getSelectedText() } : {};
23807
+ },
23808
+ };
23809
+ function buildQuery(editor) {
23810
+ editor.eventEmitter.listen('query', function (query, payload) {
23811
+ return queryMap[query](editor, payload);
23812
+ });
23813
+ }
23814
+
23547
23815
  ;// CONCATENATED MODULE: ./src/editorCore.ts
23548
23816
 
23549
23817
 
@@ -23571,6 +23839,7 @@ var ScrollSync = /** @class */ (function () {
23571
23839
 
23572
23840
 
23573
23841
 
23842
+
23574
23843
 
23575
23844
 
23576
23845
  /**
@@ -23707,6 +23976,7 @@ var ToastUIEditorCore = /** @class */ (function () {
23707
23976
  this.scrollSync = new ScrollSync(this.mdEditor, this.preview, this.eventEmitter);
23708
23977
  this.addInitEvent();
23709
23978
  this.addInitCommand(mdCommands, wwCommands);
23979
+ buildQuery(this);
23710
23980
  if (this.options.hooks) {
23711
23981
  forEachOwnProperties_default()(this.options.hooks, function (fn, key) { return _this.addHook(key, fn); });
23712
23982
  }
@@ -23717,7 +23987,15 @@ var ToastUIEditorCore = /** @class */ (function () {
23717
23987
  this.moveCursorToStart(this.options.autofocus);
23718
23988
  }
23719
23989
  ToastUIEditorCore.prototype.addInitEvent = function () {
23990
+ var _this = this;
23720
23991
  this.on('needChangeMode', this.changeMode.bind(this));
23992
+ this.on('loadUI', function () {
23993
+ if (_this.height !== 'auto') {
23994
+ // 75px equals default editor ui height - the editing area height
23995
+ var minHeight = Math.min(parseInt(_this.minHeight, 10), parseInt(_this.height, 10) - 75) + "px";
23996
+ _this.setMinHeight(minHeight);
23997
+ }
23998
+ });
23721
23999
  addDefaultImageBlobHook(this.eventEmitter);
23722
24000
  };
23723
24001
  ToastUIEditorCore.prototype.addInitCommand = function (mdCommands, wwCommands) {
@@ -23901,7 +24179,12 @@ var ToastUIEditorCore = /** @class */ (function () {
23901
24179
  _this.wwEditor.setModel(wwNode);
23902
24180
  }
23903
24181
  });
23904
- return this.wwEditor.view.dom.innerHTML;
24182
+ var html = this.wwEditor.view.dom.innerHTML;
24183
+ if (this.placeholder) {
24184
+ var rePlaceholder = new RegExp("<span class=\"placeholder[^>]+>" + this.placeholder + "</span>", 'i');
24185
+ return html.replace(rePlaceholder, '');
24186
+ }
24187
+ return html;
23905
24188
  };
23906
24189
  /**
23907
24190
  * Insert text
@@ -23989,12 +24272,11 @@ var ToastUIEditorCore = /** @class */ (function () {
23989
24272
  if (isString_default()(height)) {
23990
24273
  if (height === 'auto') {
23991
24274
  addClass_default()(el, 'auto-height');
23992
- this.setMinHeight(this.getMinHeight());
23993
24275
  }
23994
24276
  else {
23995
24277
  removeClass_default()(el, 'auto-height');
23996
- this.setMinHeight(height);
23997
24278
  }
24279
+ this.setMinHeight(this.getMinHeight());
23998
24280
  }
23999
24281
  css_default()(el, { height: height });
24000
24282
  this.height = height;
@@ -24011,16 +24293,18 @@ var ToastUIEditorCore = /** @class */ (function () {
24011
24293
  * @param {string} minHeight - min content height in pixel
24012
24294
  */
24013
24295
  ToastUIEditorCore.prototype.setMinHeight = function (minHeight) {
24014
- var _a;
24015
- this.minHeight = minHeight;
24016
- var editorHeight = this.options.el.clientHeight;
24017
- var editorSectionHeight = ((_a = document.querySelector("." + cls('main'))) === null || _a === void 0 ? void 0 : _a.clientHeight) || 0;
24018
- var diffHeight = editorHeight - editorSectionHeight;
24019
- var minHeightNum = parseInt(minHeight, 10);
24020
- minHeightNum = Math.max(minHeightNum - diffHeight, 0);
24021
- this.wwEditor.setMinHeight(minHeightNum);
24022
- this.mdEditor.setMinHeight(minHeightNum);
24023
- this.preview.setMinHeight(minHeightNum);
24296
+ if (minHeight !== this.minHeight) {
24297
+ var height = this.height || this.options.height;
24298
+ if (height !== 'auto' && this.options.el.querySelector("." + cls('main'))) {
24299
+ // 75px equals default editor ui height - the editing area height
24300
+ minHeight = Math.min(parseInt(minHeight, 10), parseInt(height, 10) - 75) + "px";
24301
+ }
24302
+ var minHeightNum = parseInt(minHeight, 10);
24303
+ this.minHeight = minHeight;
24304
+ this.wwEditor.setMinHeight(minHeightNum);
24305
+ this.mdEditor.setMinHeight(minHeightNum);
24306
+ this.preview.setMinHeight(minHeightNum);
24307
+ }
24024
24308
  };
24025
24309
  /**
24026
24310
  * Get minimum height of editor content
@@ -24156,6 +24440,7 @@ var ToastUIEditorCore = /** @class */ (function () {
24156
24440
  * @param {string} placeholder - placeholder to set
24157
24441
  */
24158
24442
  ToastUIEditorCore.prototype.setPlaceholder = function (placeholder) {
24443
+ this.placeholder = placeholder;
24159
24444
  this.mdEditor.setPlaceholder(placeholder);
24160
24445
  this.wwEditor.setPlaceholder(placeholder);
24161
24446
  };
@@ -25974,6 +26259,10 @@ var CustomPopupBody = /** @class */ (function (_super) {
25974
26259
  // append the custom popup body element
25975
26260
  this.refs.el.appendChild(this.props.body);
25976
26261
  };
26262
+ CustomPopupBody.prototype.updated = function (prevProps) {
26263
+ // update custom popup element
26264
+ this.refs.el.replaceChild(this.props.body, prevProps.body);
26265
+ };
25977
26266
  CustomPopupBody.prototype.render = function () {
25978
26267
  var _this = this;
25979
26268
  return template(customPopupBody_templateObject_1 || (customPopupBody_templateObject_1 = __makeTemplateObject(["<div ref=", "></div>"], ["<div ref=", "></div>"])), function (el) { return (_this.refs.el = el); });
@@ -26156,6 +26445,7 @@ function createDefaultToolbarItemInfo(type) {
26156
26445
  className: 'indent',
26157
26446
  command: 'indent',
26158
26447
  tooltip: i18n.get('Indent'),
26448
+ state: 'indent',
26159
26449
  };
26160
26450
  break;
26161
26451
  case 'outdent':
@@ -26164,6 +26454,7 @@ function createDefaultToolbarItemInfo(type) {
26164
26454
  className: 'outdent',
26165
26455
  command: 'outdent',
26166
26456
  tooltip: i18n.get('Outdent'),
26457
+ state: 'outdent',
26167
26458
  };
26168
26459
  break;
26169
26460
  case 'scrollSync':
@@ -26328,7 +26619,7 @@ function connectHOC(WrappedComponent) {
26328
26619
  _this.hideTooltip = function () {
26329
26620
  css_default()(_this.props.tooltipRef.current, 'display', 'none');
26330
26621
  };
26331
- _this.state = { active: false };
26622
+ _this.state = { active: false, disabled: props.disabled };
26332
26623
  _this.addEvent();
26333
26624
  return _this;
26334
26625
  }
@@ -26337,9 +26628,10 @@ function connectHOC(WrappedComponent) {
26337
26628
  var _a = this.props, item = _a.item, eventEmitter = _a.eventEmitter;
26338
26629
  if (item.state) {
26339
26630
  eventEmitter.listen('changeToolbarState', function (_a) {
26631
+ var _b;
26340
26632
  var toolbarState = _a.toolbarState;
26341
- var active = !!toolbarState[item.state];
26342
- _this.setState({ active: active });
26633
+ var _c = (_b = toolbarState[item.state]) !== null && _b !== void 0 ? _b : {}, active = _c.active, disabled = _c.disabled;
26634
+ _this.setState({ active: !!active, disabled: disabled !== null && disabled !== void 0 ? disabled : _this.props.disabled });
26343
26635
  });
26344
26636
  }
26345
26637
  };
@@ -26348,7 +26640,7 @@ function connectHOC(WrappedComponent) {
26348
26640
  return { left: offsetLeft, top: el.offsetHeight + offsetTop };
26349
26641
  };
26350
26642
  ButtonHOC.prototype.render = function () {
26351
- return template(buttonHoc_templateObject_1 || (buttonHoc_templateObject_1 = __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);
26643
+ return template(buttonHoc_templateObject_1 || (buttonHoc_templateObject_1 = __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);
26352
26644
  };
26353
26645
  return ButtonHOC;
26354
26646
  }(Component));
@@ -26371,17 +26663,19 @@ var ToolbarButtonComp = /** @class */ (function (_super) {
26371
26663
  _this.props.showTooltip(_this.refs.el);
26372
26664
  };
26373
26665
  _this.execCommand = function () {
26374
- var _a = _this.props, item = _a.item, execCommand = _a.execCommand, setPopupInfo = _a.setPopupInfo, getBound = _a.getBound;
26666
+ var _a = _this.props, item = _a.item, execCommand = _a.execCommand, setPopupInfo = _a.setPopupInfo, getBound = _a.getBound, eventEmitter = _a.eventEmitter;
26375
26667
  var command = item.command, name = item.name, popup = item.popup;
26376
26668
  if (command) {
26377
26669
  execCommand(command);
26378
26670
  }
26379
26671
  else {
26380
26672
  var popupName = popup ? 'customPopupBody' : name;
26673
+ var initialValues = eventEmitter.emit('query', 'getPopupInitialValues', { popupName: popupName })[0];
26381
26674
  var info = createPopupInfo(popupName, {
26382
26675
  el: _this.refs.el,
26383
26676
  pos: getBound(_this.refs.el),
26384
26677
  popup: popup,
26678
+ initialValues: initialValues,
26385
26679
  });
26386
26680
  if (info) {
26387
26681
  setPopupInfo(info);
@@ -26601,7 +26895,7 @@ var Toolbar = /** @class */ (function (_super) {
26601
26895
  };
26602
26896
  _this.openPopup = function (popupName, initialValues) {
26603
26897
  if (initialValues === void 0) { initialValues = {}; }
26604
- var el = document.querySelector("." + cls('toolbar-group') + " ." + popupName);
26898
+ var el = _this.refs.el.querySelector("." + cls('toolbar-group') + " ." + popupName);
26605
26899
  if (el) {
26606
26900
  var _a = getTotalOffset(el, closest(el, "." + cls('toolbar'))), offsetLeft = _a.offsetLeft, offsetTop = _a.offsetTop;
26607
26901
  var info = createPopupInfo(popupName, {
@@ -26749,7 +27043,7 @@ var Toolbar = /** @class */ (function (_super) {
26749
27043
  };
26750
27044
  Toolbar.prototype.mounted = function () {
26751
27045
  if (this.props.previewStyle === 'tab') {
26752
- this.props.eventEmitter.emit('changePreviewTabWrite');
27046
+ this.props.eventEmitter.emit('changePreviewTabWrite', true);
26753
27047
  }
26754
27048
  // classify toolbar and dropdown toolbar after DOM has been rendered
26755
27049
  this.setState(this.classifyToolbarItems());
@@ -26967,6 +27261,7 @@ var ToastUIEditor = /** @class */ (function (_super) {
26967
27261
  var groupIndex = toolbarItem.groupIndex, itemIndex = toolbarItem.itemIndex, item = toolbarItem.item;
26968
27262
  _this.defaultUI.insertToolbarItem({ groupIndex: groupIndex, itemIndex: itemIndex }, item);
26969
27263
  });
27264
+ _this.eventEmitter.emit('loadUI', _this);
26970
27265
  return _this;
26971
27266
  }
26972
27267
  /**
@@ -27007,7 +27302,7 @@ var editor_templateObject_1;
27007
27302
  ;// CONCATENATED MODULE: ./src/i18n/en-us.ts
27008
27303
  /**
27009
27304
  * @fileoverview I18N for English
27010
- * @author NHN FE Development Lab <dl_javascript@nhn.com>
27305
+ * @author NHN Cloud FE Development Lab <dl_javascript@nhn.com>
27011
27306
  */
27012
27307
 
27013
27308
  editorCore.setLanguage(['en', 'en-US'], {
@@ -27074,7 +27369,7 @@ editorCore.setLanguage(['en', 'en-US'], {
27074
27369
 
27075
27370
 
27076
27371
  }();
27077
- __webpack_exports__ = __webpack_exports__.default;
27372
+ __webpack_exports__ = __webpack_exports__["default"];
27078
27373
  /******/ return __webpack_exports__;
27079
27374
  /******/ })()
27080
27375
  ;