@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
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
  */
@@ -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
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
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
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
  */
@@ -12090,6 +12090,28 @@ var common_reEscapeChars = /[>(){}[\]+-.!#|]/g;
12090
12090
  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;
12091
12091
  var reEscapeBackSlash = /\\[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~\\]/g;
12092
12092
  var reEscapePairedChars = /[*_~`]/g;
12093
+ var common_XMLSPECIAL = '[&<>"]';
12094
+ var common_reXmlSpecial = new RegExp(common_XMLSPECIAL, 'g');
12095
+ function common_replaceUnsafeChar(char) {
12096
+ switch (char) {
12097
+ case '&':
12098
+ return '&amp;';
12099
+ case '<':
12100
+ return '&lt;';
12101
+ case '>':
12102
+ return '&gt;';
12103
+ case '"':
12104
+ return '&quot;';
12105
+ default:
12106
+ return char;
12107
+ }
12108
+ }
12109
+ function common_escapeXml(text) {
12110
+ if (common_reXmlSpecial.test(text)) {
12111
+ return text.replace(common_reXmlSpecial, common_replaceUnsafeChar);
12112
+ }
12113
+ return text;
12114
+ }
12093
12115
  function sendHostName() {
12094
12116
  sendHostname('editor', 'UA-129966929-1');
12095
12117
  }
@@ -13237,10 +13259,16 @@ var MarkdownPreview = /** @class */ (function () {
13237
13259
  this.sanitizer = sanitizer;
13238
13260
  this.initEvent(highlight);
13239
13261
  this.initContentSection();
13262
+ // To prevent overflowing contents in the viewer
13263
+ if (this.isViewer) {
13264
+ this.previewContent.style.overflowWrap = 'break-word';
13265
+ }
13240
13266
  }
13241
13267
  MarkdownPreview.prototype.initContentSection = function () {
13242
13268
  this.previewContent = createElementWith("<div class=\"" + cls('contents') + "\"></div>");
13243
- this.el.appendChild(this.previewContent);
13269
+ if (!this.isViewer) {
13270
+ this.el.appendChild(this.previewContent);
13271
+ }
13244
13272
  };
13245
13273
  MarkdownPreview.prototype.toggleActive = function (active) {
13246
13274
  toggleClass(this.el, 'active', active);
@@ -13248,6 +13276,9 @@ var MarkdownPreview = /** @class */ (function () {
13248
13276
  MarkdownPreview.prototype.initEvent = function (highlight) {
13249
13277
  var _this = this;
13250
13278
  this.eventEmitter.listen('updatePreview', this.update.bind(this));
13279
+ if (this.isViewer) {
13280
+ return;
13281
+ }
13251
13282
  if (highlight) {
13252
13283
  this.eventEmitter.listen('changeToolbarState', function (_a) {
13253
13284
  var mdNode = _a.mdNode, cursorPos = _a.cursorPos;
@@ -13842,6 +13873,7 @@ var eventTypeList = [
13842
13873
  'mixinTableOffsetMapPrototype',
13843
13874
  'setFocusedNode',
13844
13875
  'removePopupWidget',
13876
+ 'query',
13845
13877
  // provide event for user
13846
13878
  'openPopup',
13847
13879
  'closePopup',
@@ -14127,7 +14159,7 @@ var ToastUIEditorViewer = /** @class */ (function () {
14127
14159
  customParser: markdownParsers,
14128
14160
  });
14129
14161
  this.preview = new mdPreview(this.eventEmitter, tslib_es6_assign(tslib_es6_assign({}, rendererOptions), { isViewer: true }));
14130
- on_default()(this.preview.el, 'mousedown', this.toggleTask.bind(this));
14162
+ on_default()(this.preview.previewContent, 'mousedown', this.toggleTask.bind(this));
14131
14163
  if (initialValue) {
14132
14164
  this.setMarkdown(initialValue);
14133
14165
  }
@@ -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
  */
@@ -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
  */
@@ -3391,6 +3391,28 @@ var reEscapeChars = /[>(){}[\]+-.!#|]/g;
3391
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 XMLSPECIAL = '[&<>"]';
3395
+ var reXmlSpecial = new RegExp(XMLSPECIAL, 'g');
3396
+ function replaceUnsafeChar(char) {
3397
+ switch (char) {
3398
+ case '&':
3399
+ return '&amp;';
3400
+ case '<':
3401
+ return '&lt;';
3402
+ case '>':
3403
+ return '&gt;';
3404
+ case '"':
3405
+ return '&quot;';
3406
+ default:
3407
+ return char;
3408
+ }
3409
+ }
3410
+ function escapeXml(text) {
3411
+ if (reXmlSpecial.test(text)) {
3412
+ return text.replace(reXmlSpecial, replaceUnsafeChar);
3413
+ }
3414
+ return text;
3415
+ }
3394
3416
  function sendHostName() {
3395
3417
  sendHostname_default()('editor', 'UA-129966929-1');
3396
3418
  }
@@ -6167,9 +6189,11 @@ var ThematicBreak = /** @class */ (function (_super) {
6167
6189
 
6168
6190
 
6169
6191
 
6170
- function cannotBeListNode(_a) {
6171
- var type = _a.type;
6172
- return type === 'codeBlock' || type === 'heading' || type.indexOf('table') !== -1;
6192
+ function cannotBeListNode(_a, line) {
6193
+ var type = _a.type, sourcepos = _a.sourcepos;
6194
+ // eslint-disable-next-line prefer-destructuring
6195
+ var startLine = sourcepos[0][0];
6196
+ return line <= startLine && (type === 'codeBlock' || type === 'heading' || type.match('table'));
6173
6197
  }
6174
6198
  var ListItem = /** @class */ (function (_super) {
6175
6199
  __extends(ListItem, _super);
@@ -6272,7 +6296,7 @@ var ListItem = /** @class */ (function (_super) {
6272
6296
  var skipLines = [];
6273
6297
  for (var line = startLine; line <= endLine; line += 1) {
6274
6298
  var mdNode = toastMark.findFirstNodeAtLine(line);
6275
- if (mdNode && cannotBeListNode(mdNode)) {
6299
+ if (mdNode && cannotBeListNode(mdNode, line)) {
6276
6300
  break;
6277
6301
  }
6278
6302
  // to skip unnecessary processing
@@ -7014,15 +7038,20 @@ var MdEditor = /** @class */ (function (_super) {
7014
7038
  _this.commands = _this.createCommands();
7015
7039
  _this.specs.setContext(__assign(__assign({}, _this.context), { view: _this.view }));
7016
7040
  _this.createClipboard();
7017
- _this.eventEmitter.listen('changePreviewTabWrite', function () { return _this.toggleActive(true); });
7041
+ // To prevent unnecessary focus setting during initial rendering
7042
+ _this.eventEmitter.listen('changePreviewTabWrite', function (isMarkdownTabMounted) {
7043
+ return _this.toggleActive(true, isMarkdownTabMounted);
7044
+ });
7018
7045
  _this.eventEmitter.listen('changePreviewTabPreview', function () { return _this.toggleActive(false); });
7019
7046
  _this.initEvent();
7020
7047
  return _this;
7021
7048
  }
7022
- MdEditor.prototype.toggleActive = function (active) {
7049
+ MdEditor.prototype.toggleActive = function (active, isMarkdownTabMounted) {
7023
7050
  toggleClass(this.el, 'active', active);
7024
7051
  if (active) {
7025
- this.focus();
7052
+ if (!isMarkdownTabMounted) {
7053
+ this.focus();
7054
+ }
7026
7055
  }
7027
7056
  else {
7028
7057
  this.blur();
@@ -12202,8 +12231,8 @@ var C_BACKSLASH$1 = 92;
12202
12231
  var reBackslashOrAmp = /[\\&]/;
12203
12232
  var ESCAPABLE = '[!"#$%&\'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]';
12204
12233
  var reEntityOrEscapedChar = new RegExp("\\\\" + ESCAPABLE + "|" + ENTITY, 'gi');
12205
- var XMLSPECIAL = '[&<>"]';
12206
- var reXmlSpecial = new RegExp(XMLSPECIAL, 'g');
12234
+ var esm_XMLSPECIAL = '[&<>"]';
12235
+ var esm_reXmlSpecial = new RegExp(esm_XMLSPECIAL, 'g');
12207
12236
  var unescapeChar = function (s) {
12208
12237
  if (s.charCodeAt(0) === C_BACKSLASH$1) {
12209
12238
  return s.charAt(1);
@@ -12225,7 +12254,7 @@ function normalizeURI(uri) {
12225
12254
  return uri;
12226
12255
  }
12227
12256
  }
12228
- function replaceUnsafeChar(s) {
12257
+ function esm_replaceUnsafeChar(s) {
12229
12258
  switch (s) {
12230
12259
  case '&':
12231
12260
  return '&amp;';
@@ -12239,9 +12268,9 @@ function replaceUnsafeChar(s) {
12239
12268
  return s;
12240
12269
  }
12241
12270
  }
12242
- function escapeXml(s) {
12243
- if (reXmlSpecial.test(s)) {
12244
- return s.replace(reXmlSpecial, replaceUnsafeChar);
12271
+ function esm_escapeXml(s) {
12272
+ if (esm_reXmlSpecial.test(s)) {
12273
+ return s.replace(esm_reXmlSpecial, esm_replaceUnsafeChar);
12245
12274
  }
12246
12275
  return s;
12247
12276
  }
@@ -15848,7 +15877,7 @@ var baseConvertors = {
15848
15877
  var infoWords = infoStr ? infoStr.split(/\s+/) : [];
15849
15878
  var codeClassNames = [];
15850
15879
  if (infoWords.length > 0 && infoWords[0].length > 0) {
15851
- codeClassNames.push("language-" + escapeXml(infoWords[0]));
15880
+ codeClassNames.push("language-" + esm_escapeXml(infoWords[0]));
15852
15881
  }
15853
15882
  return [
15854
15883
  { type: 'openTag', tagName: 'pre', outerNewLine: true },
@@ -15865,7 +15894,7 @@ var baseConvertors = {
15865
15894
  return {
15866
15895
  type: 'openTag',
15867
15896
  tagName: 'a',
15868
- attributes: esm_assign({ href: escapeXml(destination) }, (title && { title: escapeXml(title) })),
15897
+ attributes: esm_assign({ href: esm_escapeXml(destination) }, (title && { title: esm_escapeXml(title) })),
15869
15898
  };
15870
15899
  }
15871
15900
  return { type: 'closeTag', tagName: 'a' };
@@ -15878,7 +15907,7 @@ var baseConvertors = {
15878
15907
  type: 'openTag',
15879
15908
  tagName: 'img',
15880
15909
  selfClose: true,
15881
- attributes: esm_assign({ src: escapeXml(destination), alt: getChildrenText(node) }, (title && { title: escapeXml(title) })),
15910
+ attributes: esm_assign({ src: esm_escapeXml(destination), alt: getChildrenText(node) }, (title && { title: esm_escapeXml(title) })),
15882
15911
  };
15883
15912
  },
15884
15913
  customBlock: function (node, context, convertors) {
@@ -16217,7 +16246,7 @@ var Renderer = /** @class */ (function () {
16217
16246
  }
16218
16247
  };
16219
16248
  Renderer.prototype.renderTextNode = function (node) {
16220
- this.buffer.push(escapeXml(node.content));
16249
+ this.buffer.push(esm_escapeXml(node.content));
16221
16250
  };
16222
16251
  Renderer.prototype.renderRawHtmlNode = function (node) {
16223
16252
  this.addOuterNewLine(node);
@@ -16725,10 +16754,16 @@ var MarkdownPreview = /** @class */ (function () {
16725
16754
  this.sanitizer = sanitizer;
16726
16755
  this.initEvent(highlight);
16727
16756
  this.initContentSection();
16757
+ // To prevent overflowing contents in the viewer
16758
+ if (this.isViewer) {
16759
+ this.previewContent.style.overflowWrap = 'break-word';
16760
+ }
16728
16761
  }
16729
16762
  MarkdownPreview.prototype.initContentSection = function () {
16730
16763
  this.previewContent = createElementWith("<div class=\"" + cls('contents') + "\"></div>");
16731
- this.el.appendChild(this.previewContent);
16764
+ if (!this.isViewer) {
16765
+ this.el.appendChild(this.previewContent);
16766
+ }
16732
16767
  };
16733
16768
  MarkdownPreview.prototype.toggleActive = function (active) {
16734
16769
  toggleClass(this.el, 'active', active);
@@ -16736,6 +16771,9 @@ var MarkdownPreview = /** @class */ (function () {
16736
16771
  MarkdownPreview.prototype.initEvent = function (highlight) {
16737
16772
  var _this = this;
16738
16773
  this.eventEmitter.listen('updatePreview', this.update.bind(this));
16774
+ if (this.isViewer) {
16775
+ return;
16776
+ }
16739
16777
  if (highlight) {
16740
16778
  this.eventEmitter.listen('changeToolbarState', function (_a) {
16741
16779
  var mdNode = _a.mdNode, cursorPos = _a.cursorPos;
@@ -18124,6 +18162,7 @@ var CustomBlockView = /** @class */ (function () {
18124
18162
  if (_this.innerEditorView) {
18125
18163
  throw new Error('The editor is already opened.');
18126
18164
  }
18165
+ _this.dom.draggable = false;
18127
18166
  _this.wrapper.style.display = 'none';
18128
18167
  _this.innerViewContainer.style.display = 'block';
18129
18168
  _this.innerEditorView = new external_commonjs_prosemirror_view_commonjs2_prosemirror_view_amd_prosemirror_view_.EditorView(_this.innerViewContainer, {
@@ -19140,7 +19179,8 @@ var heading_Heading = /** @class */ (function (_super) {
19140
19179
  });
19141
19180
  Heading.prototype.commands = function () {
19142
19181
  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);
19182
+ var nodeType = state.schema.nodes[payload.level ? 'heading' : 'paragraph'];
19183
+ return (0,external_commonjs_prosemirror_commands_commonjs2_prosemirror_commands_amd_prosemirror_commands_.setBlockType)(nodeType, payload)(state, dispatch);
19144
19184
  }; };
19145
19185
  };
19146
19186
  return Heading;
@@ -20317,7 +20357,7 @@ var Image = /** @class */ (function (_super) {
20317
20357
  if (!imageUrl) {
20318
20358
  return false;
20319
20359
  }
20320
- var node = schema.nodes.image.createAndFill(__assign({ imageUrl: encodeMarkdownText(imageUrl) }, (altText && { altText: altText })));
20360
+ var node = schema.nodes.image.createAndFill(__assign({ imageUrl: escapeXml(imageUrl) }, (altText && { altText: altText })));
20321
20361
  dispatch(tr.replaceSelectionWith(node).scrollIntoView());
20322
20362
  return true;
20323
20363
  }; };
@@ -20576,6 +20616,7 @@ var strike_Strike = /** @class */ (function (_super) {
20576
20616
 
20577
20617
 
20578
20618
 
20619
+
20579
20620
  var link_Link = /** @class */ (function (_super) {
20580
20621
  __extends(Link, _super);
20581
20622
  function Link(linkAttributes) {
@@ -20627,7 +20668,7 @@ var link_Link = /** @class */ (function (_super) {
20627
20668
  var empty = selection.empty, from = selection.from, to = selection.to;
20628
20669
  if (from && to && linkUrl) {
20629
20670
  var attrs = {
20630
- linkUrl: encodeMarkdownText(linkUrl),
20671
+ linkUrl: escapeXml(linkUrl),
20631
20672
  linkText: escapeMarkdownText(linkText),
20632
20673
  };
20633
20674
  var mark = schema.mark('link', attrs);
@@ -21132,6 +21173,7 @@ var eventTypeList = [
21132
21173
  'mixinTableOffsetMapPrototype',
21133
21174
  'setFocusedNode',
21134
21175
  'removePopupWidget',
21176
+ 'query',
21135
21177
  // provide event for user
21136
21178
  'openPopup',
21137
21179
  'closePopup',
@@ -21776,32 +21818,37 @@ var toWwConvertors = {
21776
21818
  }
21777
21819
  },
21778
21820
  tableCell: function (state, node, _a) {
21821
+ var _b;
21779
21822
  var entering = _a.entering;
21780
- if (!node.ignored) {
21781
- var hasParaNode = function (childNode) {
21782
- return childNode && (htmlToWwConvertors_isInlineNode(childNode) || isCustomHTMLInlineNode(state, childNode));
21783
- };
21784
- if (entering) {
21785
- var _b = state.schema.nodes, tableHeadCell = _b.tableHeadCell, tableBodyCell = _b.tableBodyCell, paragraph = _b.paragraph;
21786
- var tablePart = node.parent.parent;
21787
- var cell = tablePart.type === 'tableHead' ? tableHeadCell : tableBodyCell;
21823
+ var _c = state.schema.nodes, tableHeadCell = _c.tableHeadCell, tableBodyCell = _c.tableBodyCell, paragraph = _c.paragraph;
21824
+ var tablePart = node.parent.parent;
21825
+ var cell = tablePart.type === 'tableHead' ? tableHeadCell : tableBodyCell;
21826
+ var hasParaNode = function (childNode) {
21827
+ return childNode && (htmlToWwConvertors_isInlineNode(childNode) || isCustomHTMLInlineNode(state, childNode));
21828
+ };
21829
+ if (entering) {
21830
+ var attrs = null;
21831
+ if (!node.ignored) {
21788
21832
  var table = tablePart.parent;
21789
- var align = table.columns[node.startIdx].align;
21790
- var attrs = __assign({}, node.attrs);
21791
- if (align) {
21792
- attrs.align = align;
21793
- }
21794
- state.openNode(cell, attrs);
21795
- if (hasParaNode(node.firstChild)) {
21796
- state.openNode(paragraph);
21833
+ var startIdx = node.startIdx;
21834
+ if (table.columns.length > startIdx) {
21835
+ var align = table.columns[startIdx].align;
21836
+ attrs = (_b = node.attrs) !== null && _b !== void 0 ? _b : {};
21837
+ if (align) {
21838
+ attrs.align = align;
21839
+ }
21797
21840
  }
21798
21841
  }
21799
- else {
21800
- if (hasParaNode(node.lastChild)) {
21801
- state.closeNode();
21802
- }
21842
+ state.openNode(cell, attrs);
21843
+ if (hasParaNode(node.firstChild)) {
21844
+ state.openNode(paragraph);
21845
+ }
21846
+ }
21847
+ else {
21848
+ if (hasParaNode(node.lastChild)) {
21803
21849
  state.closeNode();
21804
21850
  }
21851
+ state.closeNode();
21805
21852
  }
21806
21853
  },
21807
21854
  strike: function (state, _, _a, customAttrs) {
@@ -22435,7 +22482,7 @@ var toMdConvertors = {
22435
22482
  var node = _a.node;
22436
22483
  var attrs = node.attrs;
22437
22484
  var altText = common_escape(attrs.altText || '');
22438
- var imageUrl = common_escape(attrs.imageUrl);
22485
+ var imageUrl = escapeXml(attrs.imageUrl);
22439
22486
  var altAttr = altText ? " alt=\"" + altText + "\"" : '';
22440
22487
  return {
22441
22488
  rawHTML: attrs.rawHTML ? "<" + attrs.rawHTML + " src=\"" + imageUrl + "\"" + altAttr + ">" : null,
@@ -22503,7 +22550,7 @@ var toMdConvertors = {
22503
22550
  var node = _a.node;
22504
22551
  var entering = _b.entering;
22505
22552
  var attrs = node.attrs;
22506
- var linkUrl = common_escape(attrs.linkUrl);
22553
+ var linkUrl = escapeXml(attrs.linkUrl);
22507
22554
  var rawHTML = attrs.rawHTML;
22508
22555
  if (entering) {
22509
22556
  return {
@@ -22540,7 +22587,8 @@ var toMdConvertors = {
22540
22587
  var openTag = "<" + tagName;
22541
22588
  var closeTag = "</" + tagName + ">";
22542
22589
  Object.keys(attrs).forEach(function (attrName) {
22543
- openTag += " " + attrName + "=\"" + attrs[attrName] + "\"";
22590
+ // To prevent broken converting when attributes has double quote string
22591
+ openTag += " " + attrName + "=\"" + attrs[attrName].replace(/"/g, "'") + "\"";
22544
22592
  });
22545
22593
  openTag += '>';
22546
22594
  if (node.attrs.htmlInline) {
@@ -23109,7 +23157,7 @@ var ToastUIEditorViewer = /** @class */ (function () {
23109
23157
  customParser: markdownParsers,
23110
23158
  });
23111
23159
  this.preview = new mdPreview(this.eventEmitter, __assign(__assign({}, rendererOptions), { isViewer: true }));
23112
- on_default()(this.preview.el, 'mousedown', this.toggleTask.bind(this));
23160
+ on_default()(this.preview.previewContent, 'mousedown', this.toggleTask.bind(this));
23113
23161
  if (initialValue) {
23114
23162
  this.setMarkdown(initialValue);
23115
23163
  }
@@ -23544,6 +23592,19 @@ var ScrollSync = /** @class */ (function () {
23544
23592
  }());
23545
23593
 
23546
23594
 
23595
+ ;// CONCATENATED MODULE: ./src/queries/queryManager.ts
23596
+ var queryMap = {
23597
+ getPopupInitialValues: function (editor, payload) {
23598
+ var popupName = payload.popupName;
23599
+ return popupName === 'link' ? { linkText: editor.getSelectedText() } : {};
23600
+ },
23601
+ };
23602
+ function buildQuery(editor) {
23603
+ editor.eventEmitter.listen('query', function (query, payload) {
23604
+ return queryMap[query](editor, payload);
23605
+ });
23606
+ }
23607
+
23547
23608
  ;// CONCATENATED MODULE: ./src/editorCore.ts
23548
23609
 
23549
23610
 
@@ -23571,6 +23632,7 @@ var ScrollSync = /** @class */ (function () {
23571
23632
 
23572
23633
 
23573
23634
 
23635
+
23574
23636
 
23575
23637
 
23576
23638
  /**
@@ -23707,6 +23769,7 @@ var ToastUIEditorCore = /** @class */ (function () {
23707
23769
  this.scrollSync = new ScrollSync(this.mdEditor, this.preview, this.eventEmitter);
23708
23770
  this.addInitEvent();
23709
23771
  this.addInitCommand(mdCommands, wwCommands);
23772
+ buildQuery(this);
23710
23773
  if (this.options.hooks) {
23711
23774
  forEachOwnProperties_default()(this.options.hooks, function (fn, key) { return _this.addHook(key, fn); });
23712
23775
  }
@@ -25974,6 +26037,10 @@ var CustomPopupBody = /** @class */ (function (_super) {
25974
26037
  // append the custom popup body element
25975
26038
  this.refs.el.appendChild(this.props.body);
25976
26039
  };
26040
+ CustomPopupBody.prototype.updated = function (prevProps) {
26041
+ // update custom popup element
26042
+ this.refs.el.replaceChild(this.props.body, prevProps.body);
26043
+ };
25977
26044
  CustomPopupBody.prototype.render = function () {
25978
26045
  var _this = this;
25979
26046
  return template(customPopupBody_templateObject_1 || (customPopupBody_templateObject_1 = __makeTemplateObject(["<div ref=", "></div>"], ["<div ref=", "></div>"])), function (el) { return (_this.refs.el = el); });
@@ -26371,17 +26438,19 @@ var ToolbarButtonComp = /** @class */ (function (_super) {
26371
26438
  _this.props.showTooltip(_this.refs.el);
26372
26439
  };
26373
26440
  _this.execCommand = function () {
26374
- var _a = _this.props, item = _a.item, execCommand = _a.execCommand, setPopupInfo = _a.setPopupInfo, getBound = _a.getBound;
26441
+ var _a = _this.props, item = _a.item, execCommand = _a.execCommand, setPopupInfo = _a.setPopupInfo, getBound = _a.getBound, eventEmitter = _a.eventEmitter;
26375
26442
  var command = item.command, name = item.name, popup = item.popup;
26376
26443
  if (command) {
26377
26444
  execCommand(command);
26378
26445
  }
26379
26446
  else {
26380
26447
  var popupName = popup ? 'customPopupBody' : name;
26448
+ var initialValues = eventEmitter.emit('query', 'getPopupInitialValues', { popupName: popupName })[0];
26381
26449
  var info = createPopupInfo(popupName, {
26382
26450
  el: _this.refs.el,
26383
26451
  pos: getBound(_this.refs.el),
26384
26452
  popup: popup,
26453
+ initialValues: initialValues,
26385
26454
  });
26386
26455
  if (info) {
26387
26456
  setPopupInfo(info);
@@ -26749,7 +26818,7 @@ var Toolbar = /** @class */ (function (_super) {
26749
26818
  };
26750
26819
  Toolbar.prototype.mounted = function () {
26751
26820
  if (this.props.previewStyle === 'tab') {
26752
- this.props.eventEmitter.emit('changePreviewTabWrite');
26821
+ this.props.eventEmitter.emit('changePreviewTabWrite', true);
26753
26822
  }
26754
26823
  // classify toolbar and dropdown toolbar after DOM has been rendered
26755
26824
  this.setState(this.classifyToolbarItems());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toast-ui/editor",
3
- "version": "3.1.1",
3
+ "version": "3.1.2",
4
4
  "description": "GFM Markdown Wysiwyg Editor - Productive and Extensible",
5
5
  "keywords": [
6
6
  "nhn",
package/types/event.d.ts CHANGED
@@ -38,6 +38,7 @@ export type EventTypes =
38
38
  | 'mixinTableOffsetMapPrototype'
39
39
  | 'setFocusedNode'
40
40
  | 'removePopupWidget'
41
+ | 'query'
41
42
  // provide event for user
42
43
  | 'openPopup'
43
44
  | 'closePopup'
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Type definitions for TOAST UI Editor v3.1.1
1
+ // Type definitions for TOAST UI Editor v3.1.2
2
2
  // TypeScript Version: 4.2.3
3
3
  import {
4
4
  EditorCore,