@toast-ui/editor 3.1.1 → 3.1.2

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 (54) hide show
  1. package/dist/esm/i18n/ar.js +1 -1
  2. package/dist/esm/i18n/cs-cz.js +1 -1
  3. package/dist/esm/i18n/de-de.js +1 -1
  4. package/dist/esm/i18n/en-us.js +1 -1
  5. package/dist/esm/i18n/es-es.js +1 -1
  6. package/dist/esm/i18n/fi-fi.js +1 -1
  7. package/dist/esm/i18n/fr-fr.js +1 -1
  8. package/dist/esm/i18n/gl-es.js +1 -1
  9. package/dist/esm/i18n/hr-hr.js +1 -1
  10. package/dist/esm/i18n/i18n.js +1 -1
  11. package/dist/esm/i18n/it-it.js +1 -1
  12. package/dist/esm/i18n/ja-jp.js +1 -1
  13. package/dist/esm/i18n/ko-kr.js +1 -1
  14. package/dist/esm/i18n/nb-no.js +1 -1
  15. package/dist/esm/i18n/nl-nl.js +1 -1
  16. package/dist/esm/i18n/pl-pl.js +1 -1
  17. package/dist/esm/i18n/pt-br.js +1 -1
  18. package/dist/esm/i18n/ru-ru.js +1 -1
  19. package/dist/esm/i18n/sv-se.js +1 -1
  20. package/dist/esm/i18n/tr-tr.js +1 -1
  21. package/dist/esm/i18n/uk-ua.js +1 -1
  22. package/dist/esm/i18n/zh-cn.js +1 -1
  23. package/dist/esm/i18n/zh-tw.js +1 -1
  24. package/dist/esm/index.js +104 -38
  25. package/dist/esm/indexViewer.js +13 -3
  26. package/dist/i18n/ar.js +1 -1
  27. package/dist/i18n/cs-cz.js +1 -1
  28. package/dist/i18n/de-de.js +1 -1
  29. package/dist/i18n/es-es.js +1 -1
  30. package/dist/i18n/fi-fi.js +1 -1
  31. package/dist/i18n/fr-fr.js +1 -1
  32. package/dist/i18n/gl-es.js +1 -1
  33. package/dist/i18n/hr-hr.js +1 -1
  34. package/dist/i18n/it-it.js +1 -1
  35. package/dist/i18n/ja-jp.js +1 -1
  36. package/dist/i18n/ko-kr.js +1 -1
  37. package/dist/i18n/nb-no.js +1 -1
  38. package/dist/i18n/nl-nl.js +1 -1
  39. package/dist/i18n/pl-pl.js +1 -1
  40. package/dist/i18n/pt-br.js +1 -1
  41. package/dist/i18n/ru-ru.js +1 -1
  42. package/dist/i18n/sv-se.js +1 -1
  43. package/dist/i18n/tr-tr.js +1 -1
  44. package/dist/i18n/uk-ua.js +1 -1
  45. package/dist/i18n/zh-cn.js +1 -1
  46. package/dist/i18n/zh-tw.js +1 -1
  47. package/dist/toastui-editor-only.css +1 -1
  48. package/dist/toastui-editor-viewer.css +1 -1
  49. package/dist/toastui-editor-viewer.js +35 -3
  50. package/dist/toastui-editor.css +1 -1
  51. package/dist/toastui-editor.js +117 -48
  52. package/package.json +1 -1
  53. package/types/event.d.ts +1 -0
  54. package/types/index.d.ts +1 -1
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -703,6 +703,28 @@ var reEscapeChars$1 = /[>(){}[\]+-.!#|]/g;
703
703
  var reEscapeHTML = /<([a-zA-Z_][a-zA-Z0-9\-._]*)(\s|[^\\/>])*\/?>|<(\/)([a-zA-Z_][a-zA-Z0-9\-._]*)\s*\/?>|<!--[^-]+-->|<([a-zA-Z_][a-zA-Z0-9\-.:/]*)>/g;
704
704
  var reEscapeBackSlash = /\\[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~\\]/g;
705
705
  var reEscapePairedChars = /[*_~`]/g;
706
+ var XMLSPECIAL$1 = '[&<>"]';
707
+ var reXmlSpecial$1 = new RegExp(XMLSPECIAL$1, 'g');
708
+ function replaceUnsafeChar$1(char) {
709
+ switch (char) {
710
+ case '&':
711
+ return '&amp;';
712
+ case '<':
713
+ return '&lt;';
714
+ case '>':
715
+ return '&gt;';
716
+ case '"':
717
+ return '&quot;';
718
+ default:
719
+ return char;
720
+ }
721
+ }
722
+ function escapeXml$1(text) {
723
+ if (reXmlSpecial$1.test(text)) {
724
+ return text.replace(reXmlSpecial$1, replaceUnsafeChar$1);
725
+ }
726
+ return text;
727
+ }
706
728
  function sendHostName() {
707
729
  sendHostname_1('editor', 'UA-129966929-1');
708
730
  }
@@ -3346,9 +3368,11 @@ var ThematicBreak$1 = /** @class */ (function (_super) {
3346
3368
  return ThematicBreak;
3347
3369
  }(Mark));
3348
3370
 
3349
- function cannotBeListNode(_a) {
3350
- var type = _a.type;
3351
- return type === 'codeBlock' || type === 'heading' || type.indexOf('table') !== -1;
3371
+ function cannotBeListNode(_a, line) {
3372
+ var type = _a.type, sourcepos = _a.sourcepos;
3373
+ // eslint-disable-next-line prefer-destructuring
3374
+ var startLine = sourcepos[0][0];
3375
+ return line <= startLine && (type === 'codeBlock' || type === 'heading' || type.match('table'));
3352
3376
  }
3353
3377
  var ListItem$1 = /** @class */ (function (_super) {
3354
3378
  __extends$1(ListItem, _super);
@@ -3451,7 +3475,7 @@ var ListItem$1 = /** @class */ (function (_super) {
3451
3475
  var skipLines = [];
3452
3476
  for (var line = startLine; line <= endLine; line += 1) {
3453
3477
  var mdNode = toastMark.findFirstNodeAtLine(line);
3454
- if (mdNode && cannotBeListNode(mdNode)) {
3478
+ if (mdNode && cannotBeListNode(mdNode, line)) {
3455
3479
  break;
3456
3480
  }
3457
3481
  // to skip unnecessary processing
@@ -4099,15 +4123,20 @@ var MdEditor = /** @class */ (function (_super) {
4099
4123
  _this.commands = _this.createCommands();
4100
4124
  _this.specs.setContext(__assign$1(__assign$1({}, _this.context), { view: _this.view }));
4101
4125
  _this.createClipboard();
4102
- _this.eventEmitter.listen('changePreviewTabWrite', function () { return _this.toggleActive(true); });
4126
+ // To prevent unnecessary focus setting during initial rendering
4127
+ _this.eventEmitter.listen('changePreviewTabWrite', function (isMarkdownTabMounted) {
4128
+ return _this.toggleActive(true, isMarkdownTabMounted);
4129
+ });
4103
4130
  _this.eventEmitter.listen('changePreviewTabPreview', function () { return _this.toggleActive(false); });
4104
4131
  _this.initEvent();
4105
4132
  return _this;
4106
4133
  }
4107
- MdEditor.prototype.toggleActive = function (active) {
4134
+ MdEditor.prototype.toggleActive = function (active, isMarkdownTabMounted) {
4108
4135
  toggleClass(this.el, 'active', active);
4109
4136
  if (active) {
4110
- this.focus();
4137
+ if (!isMarkdownTabMounted) {
4138
+ this.focus();
4139
+ }
4111
4140
  }
4112
4141
  else {
4113
4142
  this.blur();
@@ -15437,10 +15466,16 @@ var MarkdownPreview = /** @class */ (function () {
15437
15466
  this.sanitizer = sanitizer;
15438
15467
  this.initEvent(highlight);
15439
15468
  this.initContentSection();
15469
+ // To prevent overflowing contents in the viewer
15470
+ if (this.isViewer) {
15471
+ this.previewContent.style.overflowWrap = 'break-word';
15472
+ }
15440
15473
  }
15441
15474
  MarkdownPreview.prototype.initContentSection = function () {
15442
15475
  this.previewContent = createElementWith("<div class=\"" + cls('contents') + "\"></div>");
15443
- this.el.appendChild(this.previewContent);
15476
+ if (!this.isViewer) {
15477
+ this.el.appendChild(this.previewContent);
15478
+ }
15444
15479
  };
15445
15480
  MarkdownPreview.prototype.toggleActive = function (active) {
15446
15481
  toggleClass(this.el, 'active', active);
@@ -15448,6 +15483,9 @@ var MarkdownPreview = /** @class */ (function () {
15448
15483
  MarkdownPreview.prototype.initEvent = function (highlight) {
15449
15484
  var _this = this;
15450
15485
  this.eventEmitter.listen('updatePreview', this.update.bind(this));
15486
+ if (this.isViewer) {
15487
+ return;
15488
+ }
15451
15489
  if (highlight) {
15452
15490
  this.eventEmitter.listen('changeToolbarState', function (_a) {
15453
15491
  var mdNode = _a.mdNode, cursorPos = _a.cursorPos;
@@ -16761,6 +16799,7 @@ var CustomBlockView = /** @class */ (function () {
16761
16799
  if (_this.innerEditorView) {
16762
16800
  throw new Error('The editor is already opened.');
16763
16801
  }
16802
+ _this.dom.draggable = false;
16764
16803
  _this.wrapper.style.display = 'none';
16765
16804
  _this.innerViewContainer.style.display = 'block';
16766
16805
  _this.innerEditorView = new EditorView(_this.innerViewContainer, {
@@ -17729,7 +17768,8 @@ var Heading = /** @class */ (function (_super) {
17729
17768
  });
17730
17769
  Heading.prototype.commands = function () {
17731
17770
  return function (payload) { return function (state, dispatch) {
17732
- return setBlockType(state.schema.nodes.heading, payload)(state, dispatch);
17771
+ var nodeType = state.schema.nodes[payload.level ? 'heading' : 'paragraph'];
17772
+ return setBlockType(nodeType, payload)(state, dispatch);
17733
17773
  }; };
17734
17774
  };
17735
17775
  return Heading;
@@ -18819,7 +18859,7 @@ var Image = /** @class */ (function (_super) {
18819
18859
  if (!imageUrl) {
18820
18860
  return false;
18821
18861
  }
18822
- var node = schema.nodes.image.createAndFill(__assign$1({ imageUrl: encodeMarkdownText(imageUrl) }, (altText && { altText: altText })));
18862
+ var node = schema.nodes.image.createAndFill(__assign$1({ imageUrl: escapeXml$1(imageUrl) }, (altText && { altText: altText })));
18823
18863
  dispatch(tr.replaceSelectionWith(node).scrollIntoView());
18824
18864
  return true;
18825
18865
  }; };
@@ -19097,7 +19137,7 @@ var Link = /** @class */ (function (_super) {
19097
19137
  var empty = selection.empty, from = selection.from, to = selection.to;
19098
19138
  if (from && to && linkUrl) {
19099
19139
  var attrs = {
19100
- linkUrl: encodeMarkdownText(linkUrl),
19140
+ linkUrl: escapeXml$1(linkUrl),
19101
19141
  linkText: escapeMarkdownText(linkText),
19102
19142
  };
19103
19143
  var mark = schema.mark('link', attrs);
@@ -19601,6 +19641,7 @@ var eventTypeList = [
19601
19641
  'mixinTableOffsetMapPrototype',
19602
19642
  'setFocusedNode',
19603
19643
  'removePopupWidget',
19644
+ 'query',
19604
19645
  // provide event for user
19605
19646
  'openPopup',
19606
19647
  'closePopup',
@@ -20226,32 +20267,37 @@ var toWwConvertors = {
20226
20267
  }
20227
20268
  },
20228
20269
  tableCell: function (state, node, _a) {
20270
+ var _b;
20229
20271
  var entering = _a.entering;
20230
- if (!node.ignored) {
20231
- var hasParaNode = function (childNode) {
20232
- return childNode && (isInlineNode(childNode) || isCustomHTMLInlineNode(state, childNode));
20233
- };
20234
- if (entering) {
20235
- var _b = state.schema.nodes, tableHeadCell = _b.tableHeadCell, tableBodyCell = _b.tableBodyCell, paragraph = _b.paragraph;
20236
- var tablePart = node.parent.parent;
20237
- var cell = tablePart.type === 'tableHead' ? tableHeadCell : tableBodyCell;
20272
+ var _c = state.schema.nodes, tableHeadCell = _c.tableHeadCell, tableBodyCell = _c.tableBodyCell, paragraph = _c.paragraph;
20273
+ var tablePart = node.parent.parent;
20274
+ var cell = tablePart.type === 'tableHead' ? tableHeadCell : tableBodyCell;
20275
+ var hasParaNode = function (childNode) {
20276
+ return childNode && (isInlineNode(childNode) || isCustomHTMLInlineNode(state, childNode));
20277
+ };
20278
+ if (entering) {
20279
+ var attrs = null;
20280
+ if (!node.ignored) {
20238
20281
  var table = tablePart.parent;
20239
- var align = table.columns[node.startIdx].align;
20240
- var attrs = __assign$1({}, node.attrs);
20241
- if (align) {
20242
- attrs.align = align;
20243
- }
20244
- state.openNode(cell, attrs);
20245
- if (hasParaNode(node.firstChild)) {
20246
- state.openNode(paragraph);
20282
+ var startIdx = node.startIdx;
20283
+ if (table.columns.length > startIdx) {
20284
+ var align = table.columns[startIdx].align;
20285
+ attrs = (_b = node.attrs) !== null && _b !== void 0 ? _b : {};
20286
+ if (align) {
20287
+ attrs.align = align;
20288
+ }
20247
20289
  }
20248
20290
  }
20249
- else {
20250
- if (hasParaNode(node.lastChild)) {
20251
- state.closeNode();
20252
- }
20291
+ state.openNode(cell, attrs);
20292
+ if (hasParaNode(node.firstChild)) {
20293
+ state.openNode(paragraph);
20294
+ }
20295
+ }
20296
+ else {
20297
+ if (hasParaNode(node.lastChild)) {
20253
20298
  state.closeNode();
20254
20299
  }
20300
+ state.closeNode();
20255
20301
  }
20256
20302
  },
20257
20303
  strike: function (state, _, _a, customAttrs) {
@@ -20872,7 +20918,7 @@ var toMdConvertors = {
20872
20918
  var node = _a.node;
20873
20919
  var attrs = node.attrs;
20874
20920
  var altText = escape$1(attrs.altText || '');
20875
- var imageUrl = escape$1(attrs.imageUrl);
20921
+ var imageUrl = escapeXml$1(attrs.imageUrl);
20876
20922
  var altAttr = altText ? " alt=\"" + altText + "\"" : '';
20877
20923
  return {
20878
20924
  rawHTML: attrs.rawHTML ? "<" + attrs.rawHTML + " src=\"" + imageUrl + "\"" + altAttr + ">" : null,
@@ -20940,7 +20986,7 @@ var toMdConvertors = {
20940
20986
  var node = _a.node;
20941
20987
  var entering = _b.entering;
20942
20988
  var attrs = node.attrs;
20943
- var linkUrl = escape$1(attrs.linkUrl);
20989
+ var linkUrl = escapeXml$1(attrs.linkUrl);
20944
20990
  var rawHTML = attrs.rawHTML;
20945
20991
  if (entering) {
20946
20992
  return {
@@ -20977,7 +21023,8 @@ var toMdConvertors = {
20977
21023
  var openTag = "<" + tagName;
20978
21024
  var closeTag = "</" + tagName + ">";
20979
21025
  Object.keys(attrs).forEach(function (attrName) {
20980
- openTag += " " + attrName + "=\"" + attrs[attrName] + "\"";
21026
+ // To prevent broken converting when attributes has double quote string
21027
+ openTag += " " + attrName + "=\"" + attrs[attrName].replace(/"/g, "'") + "\"";
20981
21028
  });
20982
21029
  openTag += '>';
20983
21030
  if (node.attrs.htmlInline) {
@@ -21515,7 +21562,7 @@ var ToastUIEditorViewer = /** @class */ (function () {
21515
21562
  customParser: markdownParsers,
21516
21563
  });
21517
21564
  this.preview = new MarkdownPreview(this.eventEmitter, __assign$1(__assign$1({}, rendererOptions), { isViewer: true }));
21518
- on_1(this.preview.el, 'mousedown', this.toggleTask.bind(this));
21565
+ on_1(this.preview.previewContent, 'mousedown', this.toggleTask.bind(this));
21519
21566
  if (initialValue) {
21520
21567
  this.setMarkdown(initialValue);
21521
21568
  }
@@ -21929,6 +21976,18 @@ var ScrollSync = /** @class */ (function () {
21929
21976
  return ScrollSync;
21930
21977
  }());
21931
21978
 
21979
+ var queryMap = {
21980
+ getPopupInitialValues: function (editor, payload) {
21981
+ var popupName = payload.popupName;
21982
+ return popupName === 'link' ? { linkText: editor.getSelectedText() } : {};
21983
+ },
21984
+ };
21985
+ function buildQuery(editor) {
21986
+ editor.eventEmitter.listen('query', function (query, payload) {
21987
+ return queryMap[query](editor, payload);
21988
+ });
21989
+ }
21990
+
21932
21991
  /**
21933
21992
  * ToastUIEditorCore
21934
21993
  * @param {Object} options Option object
@@ -22063,6 +22122,7 @@ var ToastUIEditorCore = /** @class */ (function () {
22063
22122
  this.scrollSync = new ScrollSync(this.mdEditor, this.preview, this.eventEmitter);
22064
22123
  this.addInitEvent();
22065
22124
  this.addInitCommand(mdCommands, wwCommands);
22125
+ buildQuery(this);
22066
22126
  if (this.options.hooks) {
22067
22127
  forEachOwnProperties_1(this.options.hooks, function (fn, key) { return _this.addHook(key, fn); });
22068
22128
  }
@@ -24425,6 +24485,10 @@ var CustomPopupBody = /** @class */ (function (_super) {
24425
24485
  // append the custom popup body element
24426
24486
  this.refs.el.appendChild(this.props.body);
24427
24487
  };
24488
+ CustomPopupBody.prototype.updated = function (prevProps) {
24489
+ // update custom popup element
24490
+ this.refs.el.replaceChild(this.props.body, prevProps.body);
24491
+ };
24428
24492
  CustomPopupBody.prototype.render = function () {
24429
24493
  var _this = this;
24430
24494
  return html(templateObject_1$b || (templateObject_1$b = __makeTemplateObject(["<div ref=", "></div>"], ["<div ref=", "></div>"])), function (el) { return (_this.refs.el = el); });
@@ -24787,17 +24851,19 @@ var ToolbarButtonComp = /** @class */ (function (_super) {
24787
24851
  _this.props.showTooltip(_this.refs.el);
24788
24852
  };
24789
24853
  _this.execCommand = function () {
24790
- var _a = _this.props, item = _a.item, execCommand = _a.execCommand, setPopupInfo = _a.setPopupInfo, getBound = _a.getBound;
24854
+ var _a = _this.props, item = _a.item, execCommand = _a.execCommand, setPopupInfo = _a.setPopupInfo, getBound = _a.getBound, eventEmitter = _a.eventEmitter;
24791
24855
  var command = item.command, name = item.name, popup = item.popup;
24792
24856
  if (command) {
24793
24857
  execCommand(command);
24794
24858
  }
24795
24859
  else {
24796
24860
  var popupName = popup ? 'customPopupBody' : name;
24861
+ var initialValues = eventEmitter.emit('query', 'getPopupInitialValues', { popupName: popupName })[0];
24797
24862
  var info = createPopupInfo(popupName, {
24798
24863
  el: _this.refs.el,
24799
24864
  pos: getBound(_this.refs.el),
24800
24865
  popup: popup,
24866
+ initialValues: initialValues,
24801
24867
  });
24802
24868
  if (info) {
24803
24869
  setPopupInfo(info);
@@ -25128,7 +25194,7 @@ var Toolbar = /** @class */ (function (_super) {
25128
25194
  };
25129
25195
  Toolbar.prototype.mounted = function () {
25130
25196
  if (this.props.previewStyle === 'tab') {
25131
- this.props.eventEmitter.emit('changePreviewTabWrite');
25197
+ this.props.eventEmitter.emit('changePreviewTabWrite', true);
25132
25198
  }
25133
25199
  // classify toolbar and dropdown toolbar after DOM has been rendered
25134
25200
  this.setState(this.classifyToolbarItems());
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : viewer
3
- * @version 3.1.1 | Wed Oct 27 2021
3
+ * @version 3.1.2 | Mon Dec 27 2021
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -11792,10 +11792,16 @@ var MarkdownPreview = /** @class */ (function () {
11792
11792
  this.sanitizer = sanitizer;
11793
11793
  this.initEvent(highlight);
11794
11794
  this.initContentSection();
11795
+ // To prevent overflowing contents in the viewer
11796
+ if (this.isViewer) {
11797
+ this.previewContent.style.overflowWrap = 'break-word';
11798
+ }
11795
11799
  }
11796
11800
  MarkdownPreview.prototype.initContentSection = function () {
11797
11801
  this.previewContent = createElementWith("<div class=\"" + cls('contents') + "\"></div>");
11798
- this.el.appendChild(this.previewContent);
11802
+ if (!this.isViewer) {
11803
+ this.el.appendChild(this.previewContent);
11804
+ }
11799
11805
  };
11800
11806
  MarkdownPreview.prototype.toggleActive = function (active) {
11801
11807
  toggleClass(this.el, 'active', active);
@@ -11803,6 +11809,9 @@ var MarkdownPreview = /** @class */ (function () {
11803
11809
  MarkdownPreview.prototype.initEvent = function (highlight) {
11804
11810
  var _this = this;
11805
11811
  this.eventEmitter.listen('updatePreview', this.update.bind(this));
11812
+ if (this.isViewer) {
11813
+ return;
11814
+ }
11806
11815
  if (highlight) {
11807
11816
  this.eventEmitter.listen('changeToolbarState', function (_a) {
11808
11817
  var mdNode = _a.mdNode, cursorPos = _a.cursorPos;
@@ -12364,6 +12373,7 @@ var eventTypeList = [
12364
12373
  'mixinTableOffsetMapPrototype',
12365
12374
  'setFocusedNode',
12366
12375
  'removePopupWidget',
12376
+ 'query',
12367
12377
  // provide event for user
12368
12378
  'openPopup',
12369
12379
  'closePopup',
@@ -12635,7 +12645,7 @@ var ToastUIEditorViewer = /** @class */ (function () {
12635
12645
  customParser: markdownParsers,
12636
12646
  });
12637
12647
  this.preview = new MarkdownPreview(this.eventEmitter, __assign$1(__assign$1({}, rendererOptions), { isViewer: true }));
12638
- on_1(this.preview.el, 'mousedown', this.toggleTask.bind(this));
12648
+ on_1(this.preview.previewContent, 'mousedown', this.toggleTask.bind(this));
12639
12649
  if (initialValue) {
12640
12650
  this.setMarkdown(initialValue);
12641
12651
  }
package/dist/i18n/ar.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * TOAST UI Editor : i18n
3
- * @version 3.1.1
3
+ * @version 3.1.2
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * TOAST UI Editor : i18n
3
- * @version 3.1.1
3
+ * @version 3.1.2
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * TOAST UI Editor : i18n
3
- * @version 3.1.1
3
+ * @version 3.1.2
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * TOAST UI Editor : i18n
3
- * @version 3.1.1
3
+ * @version 3.1.2
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * TOAST UI Editor : i18n
3
- * @version 3.1.1
3
+ * @version 3.1.2
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * TOAST UI Editor : i18n
3
- * @version 3.1.1
3
+ * @version 3.1.2
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * TOAST UI Editor : i18n
3
- * @version 3.1.1
3
+ * @version 3.1.2
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * TOAST UI Editor : i18n
3
- * @version 3.1.1
3
+ * @version 3.1.2
4
4
  * @author NHN FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */