@toast-ui/editor 3.1.7 → 3.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +69 -19
  25. package/dist/esm/indexViewer.js +1 -1
  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 +21 -7
  50. package/dist/toastui-editor.css +1 -1
  51. package/dist/toastui-editor.js +70 -19
  52. package/package.json +1 -1
  53. package/types/convertor.d.ts +6 -2
  54. package/types/index.d.ts +1 -1
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : i18n
3
- * @version 3.1.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -704,7 +704,8 @@ var reEscapeHTML = /<([a-zA-Z_][a-zA-Z0-9\-._]*)(\s|[^\\>])*\/?>|<(\/)([a-zA-Z_]
704
704
  var reEscapeBackSlash = /\\[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~\\]/g;
705
705
  var reEscapePairedChars = /[*_~`]/g;
706
706
  var reMdImageSyntax = /!\[.*\]\(.*\)/g;
707
- var reEscapedCharInLinkSyntax = /[[\]]/g; //
707
+ var reEscapedCharInLinkSyntax = /[[\]]/g;
708
+ var reEscapeBackSlashInSentence = /(?:^|[^\\])\\(?!\\)/g;
708
709
  var XMLSPECIAL$1 = '[&<>"]';
709
710
  var reXmlSpecial$1 = new RegExp(XMLSPECIAL$1, 'g');
710
711
  function replaceUnsafeChar$1(char) {
@@ -789,17 +790,21 @@ function escapeTextForLink(text) {
789
790
  });
790
791
  }
791
792
  function escape$1(text) {
792
- var replacer = function (matched) { return "\\" + matched; };
793
+ var aheadReplacer = function (matched) { return "\\" + matched; };
794
+ var behindReplacer = function (matched) { return matched + "\\"; };
793
795
  var escapedText = text.replace(reSpaceMoreThanOne, ' ');
794
796
  if (reEscapeBackSlash.test(escapedText)) {
795
- escapedText = escapedText.replace(reEscapeBackSlash, replacer);
797
+ escapedText = escapedText.replace(reEscapeBackSlash, aheadReplacer);
796
798
  }
797
- escapedText = escapedText.replace(reEscapePairedChars, replacer);
799
+ if (reEscapeBackSlashInSentence.test(escapedText)) {
800
+ escapedText = escapedText.replace(reEscapeBackSlashInSentence, behindReplacer);
801
+ }
802
+ escapedText = escapedText.replace(reEscapePairedChars, aheadReplacer);
798
803
  if (reEscapeHTML.test(escapedText)) {
799
- escapedText = escapedText.replace(reEscapeHTML, replacer);
804
+ escapedText = escapedText.replace(reEscapeHTML, aheadReplacer);
800
805
  }
801
806
  if (isNeedEscapeText(escapedText)) {
802
- escapedText = escapedText.replace(reEscapeChars$1, replacer);
807
+ escapedText = escapedText.replace(reEscapeChars$1, aheadReplacer);
803
808
  }
804
809
  return escapedText;
805
810
  }
@@ -909,6 +914,14 @@ function assign(targetObj, obj) {
909
914
  function getSortedNumPair(valueA, valueB) {
910
915
  return valueA > valueB ? [valueB, valueA] : [valueA, valueB];
911
916
  }
917
+ function isStartWithSpace(text) {
918
+ var reStartWithSpace = /^\s(\S*)/g;
919
+ return reStartWithSpace.test(text);
920
+ }
921
+ function isEndWithSpace(text) {
922
+ var reEndWithSpace = /(\S*)\s$/g;
923
+ return reEndWithSpace.test(text);
924
+ }
912
925
 
913
926
  /**
914
927
  * @fileoverview Transform the Array-like object to Array.
@@ -1360,6 +1373,7 @@ var reHTMLTag = new RegExp("^" + HTML_TAG, 'i');
1360
1373
  var reBR = /<br\s*\/*>/i;
1361
1374
  var reHTMLComment = /<! ---->|<!--(?:-?[^>-])(?:-?[^-])*-->/;
1362
1375
  var ALTERNATIVE_TAG_FOR_BR = '</p><p>';
1376
+ var DEFAULT_TEXT_NOT_START_OR_END_WITH_SPACE = 'a';
1363
1377
 
1364
1378
  function isPositionInBox(style, offsetX, offsetY) {
1365
1379
  var left = parseInt(style.left, 10);
@@ -20789,6 +20803,12 @@ var nodeTypeWriters = {
20789
20803
  state.write('<br>\n');
20790
20804
  }
20791
20805
  else if (emptyNode && !prevEmptyNode && !firstChildNode) {
20806
+ if ((parent === null || parent === void 0 ? void 0 : parent.type.name) === 'listItem') {
20807
+ var prevDelim = state.getDelim();
20808
+ state.setDelim('');
20809
+ state.write('<br>');
20810
+ state.setDelim(prevDelim);
20811
+ }
20792
20812
  state.write('\n');
20793
20813
  }
20794
20814
  else {
@@ -21143,30 +21163,42 @@ var toMdConvertors = {
21143
21163
  text: node.textContent,
21144
21164
  };
21145
21165
  },
21146
- strong: function (_a, _b) {
21166
+ strong: function (_a, _b, betweenSpace) {
21147
21167
  var node = _a.node;
21148
21168
  var entering = _b.entering;
21149
21169
  var rawHTML = node.attrs.rawHTML;
21170
+ var delim = '**';
21171
+ if (!betweenSpace) {
21172
+ delim = entering ? '<strong>' : '</strong>';
21173
+ }
21150
21174
  return {
21151
- delim: '**',
21175
+ delim: delim,
21152
21176
  rawHTML: entering ? getOpenRawHTML(rawHTML) : getCloseRawHTML(rawHTML),
21153
21177
  };
21154
21178
  },
21155
- emph: function (_a, _b) {
21179
+ emph: function (_a, _b, betweenSpace) {
21156
21180
  var node = _a.node;
21157
21181
  var entering = _b.entering;
21158
21182
  var rawHTML = node.attrs.rawHTML;
21183
+ var delim = '*';
21184
+ if (!betweenSpace) {
21185
+ delim = entering ? '<em>' : '</em>';
21186
+ }
21159
21187
  return {
21160
- delim: '*',
21188
+ delim: delim,
21161
21189
  rawHTML: entering ? getOpenRawHTML(rawHTML) : getCloseRawHTML(rawHTML),
21162
21190
  };
21163
21191
  },
21164
- strike: function (_a, _b) {
21192
+ strike: function (_a, _b, betweenSpace) {
21165
21193
  var node = _a.node;
21166
21194
  var entering = _b.entering;
21167
21195
  var rawHTML = node.attrs.rawHTML;
21196
+ var delim = '~~';
21197
+ if (!betweenSpace) {
21198
+ delim = entering ? '<del>' : '</del>';
21199
+ }
21168
21200
  return {
21169
- delim: '~~',
21201
+ delim: delim,
21170
21202
  rawHTML: entering ? getOpenRawHTML(rawHTML) : getCloseRawHTML(rawHTML),
21171
21203
  };
21172
21204
  },
@@ -21273,7 +21305,7 @@ function createMarkTypeConvertors(convertors) {
21273
21305
  var markTypeConvertors = {};
21274
21306
  var markTypes = Object.keys(markTypeOptions);
21275
21307
  markTypes.forEach(function (type) {
21276
- markTypeConvertors[type] = function (nodeInfo, entering) {
21308
+ markTypeConvertors[type] = function (nodeInfo, entering, betweenSpace) {
21277
21309
  var markOption = markTypeOptions[type];
21278
21310
  var convertor = convertors[type];
21279
21311
  // There are two ways to call the mark type converter
@@ -21281,7 +21313,9 @@ function createMarkTypeConvertors(convertors) {
21281
21313
  // When calling the converter without using `delim` and `rawHTML` values,
21282
21314
  // the converter is called without parameters.
21283
21315
  var runConvertor = convertor && nodeInfo && !isUndefined_1(entering);
21284
- var params = runConvertor ? convertor(nodeInfo, { entering: entering }) : {};
21316
+ var params = runConvertor
21317
+ ? convertor(nodeInfo, { entering: entering }, betweenSpace)
21318
+ : {};
21285
21319
  return __assign$1(__assign$1({}, params), markOption);
21286
21320
  };
21287
21321
  });
@@ -21342,14 +21376,30 @@ var ToMdConvertorState = /** @class */ (function () {
21342
21376
  ToMdConvertorState.prototype.isInBlank = function () {
21343
21377
  return /(^|\n)$/.test(this.result);
21344
21378
  };
21379
+ ToMdConvertorState.prototype.isBetweenSpaces = function (parent, index) {
21380
+ var _a, _b;
21381
+ var content = parent.content;
21382
+ var isFrontNodeEndWithSpace = index === 0 ||
21383
+ isEndWithSpace((_a = content.child(index - 1).text) !== null && _a !== void 0 ? _a : DEFAULT_TEXT_NOT_START_OR_END_WITH_SPACE);
21384
+ var isRearNodeStartWithSpace = index >= content.childCount - 1 ||
21385
+ isStartWithSpace((_b = content.child(index + 1).text) !== null && _b !== void 0 ? _b : DEFAULT_TEXT_NOT_START_OR_END_WITH_SPACE);
21386
+ return isFrontNodeEndWithSpace && isRearNodeStartWithSpace;
21387
+ };
21345
21388
  ToMdConvertorState.prototype.markText = function (mark, entering, parent, index) {
21346
21389
  var convertor = this.getMarkConvertor(mark);
21347
21390
  if (convertor) {
21348
- var _a = convertor({ node: mark, parent: parent, index: index }, entering), delim = _a.delim, rawHTML = _a.rawHTML;
21391
+ var betweenSpace = this.isBetweenSpaces(parent, entering ? index : index - 1);
21392
+ var _a = convertor({ node: mark, parent: parent, index: index }, entering, betweenSpace), delim = _a.delim, rawHTML = _a.rawHTML;
21349
21393
  return rawHTML || delim;
21350
21394
  }
21351
21395
  return '';
21352
21396
  };
21397
+ ToMdConvertorState.prototype.setDelim = function (delim) {
21398
+ this.delim = delim;
21399
+ };
21400
+ ToMdConvertorState.prototype.getDelim = function () {
21401
+ return this.delim;
21402
+ };
21353
21403
  ToMdConvertorState.prototype.flushClose = function (size) {
21354
21404
  if (!this.stopNewline && this.closed) {
21355
21405
  if (!this.isInBlank()) {
@@ -21372,11 +21422,11 @@ var ToMdConvertorState = /** @class */ (function () {
21372
21422
  }
21373
21423
  };
21374
21424
  ToMdConvertorState.prototype.wrapBlock = function (delim, firstDelim, node, fn) {
21375
- var old = this.delim;
21425
+ var old = this.getDelim();
21376
21426
  this.write(firstDelim || delim);
21377
- this.delim += delim;
21427
+ this.setDelim(this.getDelim() + delim);
21378
21428
  fn();
21379
- this.delim = old;
21429
+ this.setDelim(old);
21380
21430
  this.closeBlock(node);
21381
21431
  };
21382
21432
  ToMdConvertorState.prototype.ensureNewLine = function () {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @toast-ui/editor : viewer
3
- * @version 3.1.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
package/dist/i18n/ar.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * TOAST UI Editor : i18n
3
- * @version 3.1.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7
3
+ * @version 3.1.8
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -12080,6 +12080,7 @@ var reHTMLTag = new RegExp("^" + constants_HTML_TAG, 'i');
12080
12080
  var constants_reBR = /<br\s*\/*>/i;
12081
12081
  var reHTMLComment = /<! ---->|<!--(?:-?[^>-])(?:-?[^-])*-->/;
12082
12082
  var constants_ALTERNATIVE_TAG_FOR_BR = '</p><p>';
12083
+ var DEFAULT_TEXT_NOT_START_OR_END_WITH_SPACE = 'a';
12083
12084
 
12084
12085
  // EXTERNAL MODULE: ../../node_modules/tui-code-snippet/type/isNull.js
12085
12086
  var type_isNull = __webpack_require__(934);
@@ -12098,7 +12099,8 @@ var reEscapeHTML = /<([a-zA-Z_][a-zA-Z0-9\-._]*)(\s|[^\\>])*\/?>|<(\/)([a-zA-Z_]
12098
12099
  var reEscapeBackSlash = /\\[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~\\]/g;
12099
12100
  var reEscapePairedChars = /[*_~`]/g;
12100
12101
  var reMdImageSyntax = /!\[.*\]\(.*\)/g;
12101
- var reEscapedCharInLinkSyntax = /[[\]]/g; //
12102
+ var reEscapedCharInLinkSyntax = /[[\]]/g;
12103
+ var reEscapeBackSlashInSentence = /(?:^|[^\\])\\(?!\\)/g;
12102
12104
  var common_XMLSPECIAL = '[&<>"]';
12103
12105
  var common_reXmlSpecial = new RegExp(common_XMLSPECIAL, 'g');
12104
12106
  function common_replaceUnsafeChar(char) {
@@ -12183,17 +12185,21 @@ function escapeTextForLink(text) {
12183
12185
  });
12184
12186
  }
12185
12187
  function common_escape(text) {
12186
- var replacer = function (matched) { return "\\" + matched; };
12188
+ var aheadReplacer = function (matched) { return "\\" + matched; };
12189
+ var behindReplacer = function (matched) { return matched + "\\"; };
12187
12190
  var escapedText = text.replace(reSpaceMoreThanOne, ' ');
12188
12191
  if (reEscapeBackSlash.test(escapedText)) {
12189
- escapedText = escapedText.replace(reEscapeBackSlash, replacer);
12192
+ escapedText = escapedText.replace(reEscapeBackSlash, aheadReplacer);
12190
12193
  }
12191
- escapedText = escapedText.replace(reEscapePairedChars, replacer);
12194
+ if (reEscapeBackSlashInSentence.test(escapedText)) {
12195
+ escapedText = escapedText.replace(reEscapeBackSlashInSentence, behindReplacer);
12196
+ }
12197
+ escapedText = escapedText.replace(reEscapePairedChars, aheadReplacer);
12192
12198
  if (reEscapeHTML.test(escapedText)) {
12193
- escapedText = escapedText.replace(reEscapeHTML, replacer);
12199
+ escapedText = escapedText.replace(reEscapeHTML, aheadReplacer);
12194
12200
  }
12195
12201
  if (isNeedEscapeText(escapedText)) {
12196
- escapedText = escapedText.replace(common_reEscapeChars, replacer);
12202
+ escapedText = escapedText.replace(common_reEscapeChars, aheadReplacer);
12197
12203
  }
12198
12204
  return escapedText;
12199
12205
  }
@@ -12303,6 +12309,14 @@ function common_assign(targetObj, obj) {
12303
12309
  function getSortedNumPair(valueA, valueB) {
12304
12310
  return valueA > valueB ? [valueB, valueA] : [valueA, valueB];
12305
12311
  }
12312
+ function isStartWithSpace(text) {
12313
+ var reStartWithSpace = /^\s(\S*)/g;
12314
+ return reStartWithSpace.test(text);
12315
+ }
12316
+ function isEndWithSpace(text) {
12317
+ var reEndWithSpace = /(\S*)\s$/g;
12318
+ return reEndWithSpace.test(text);
12319
+ }
12306
12320
 
12307
12321
  ;// CONCATENATED MODULE: ./src/utils/dom.ts
12308
12322
 
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @toast-ui/editor
3
- * @version 3.1.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud 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.7 | Tue May 17 2022
3
+ * @version 3.1.8 | Tue Jul 12 2022
4
4
  * @author NHN Cloud FE Development Lab <dl_javascript@nhn.com>
5
5
  * @license MIT
6
6
  */
@@ -3392,7 +3392,8 @@ var reEscapeHTML = /<([a-zA-Z_][a-zA-Z0-9\-._]*)(\s|[^\\>])*\/?>|<(\/)([a-zA-Z_]
3392
3392
  var reEscapeBackSlash = /\\[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~\\]/g;
3393
3393
  var reEscapePairedChars = /[*_~`]/g;
3394
3394
  var reMdImageSyntax = /!\[.*\]\(.*\)/g;
3395
- var reEscapedCharInLinkSyntax = /[[\]]/g; //
3395
+ var reEscapedCharInLinkSyntax = /[[\]]/g;
3396
+ var reEscapeBackSlashInSentence = /(?:^|[^\\])\\(?!\\)/g;
3396
3397
  var XMLSPECIAL = '[&<>"]';
3397
3398
  var reXmlSpecial = new RegExp(XMLSPECIAL, 'g');
3398
3399
  function replaceUnsafeChar(char) {
@@ -3477,17 +3478,21 @@ function escapeTextForLink(text) {
3477
3478
  });
3478
3479
  }
3479
3480
  function common_escape(text) {
3480
- var replacer = function (matched) { return "\\" + matched; };
3481
+ var aheadReplacer = function (matched) { return "\\" + matched; };
3482
+ var behindReplacer = function (matched) { return matched + "\\"; };
3481
3483
  var escapedText = text.replace(reSpaceMoreThanOne, ' ');
3482
3484
  if (reEscapeBackSlash.test(escapedText)) {
3483
- escapedText = escapedText.replace(reEscapeBackSlash, replacer);
3485
+ escapedText = escapedText.replace(reEscapeBackSlash, aheadReplacer);
3484
3486
  }
3485
- escapedText = escapedText.replace(reEscapePairedChars, replacer);
3487
+ if (reEscapeBackSlashInSentence.test(escapedText)) {
3488
+ escapedText = escapedText.replace(reEscapeBackSlashInSentence, behindReplacer);
3489
+ }
3490
+ escapedText = escapedText.replace(reEscapePairedChars, aheadReplacer);
3486
3491
  if (reEscapeHTML.test(escapedText)) {
3487
- escapedText = escapedText.replace(reEscapeHTML, replacer);
3492
+ escapedText = escapedText.replace(reEscapeHTML, aheadReplacer);
3488
3493
  }
3489
3494
  if (isNeedEscapeText(escapedText)) {
3490
- escapedText = escapedText.replace(reEscapeChars, replacer);
3495
+ escapedText = escapedText.replace(reEscapeChars, aheadReplacer);
3491
3496
  }
3492
3497
  return escapedText;
3493
3498
  }
@@ -3597,6 +3602,14 @@ function common_assign(targetObj, obj) {
3597
3602
  function getSortedNumPair(valueA, valueB) {
3598
3603
  return valueA > valueB ? [valueB, valueA] : [valueA, valueB];
3599
3604
  }
3605
+ function isStartWithSpace(text) {
3606
+ var reStartWithSpace = /^\s(\S*)/g;
3607
+ return reStartWithSpace.test(text);
3608
+ }
3609
+ function isEndWithSpace(text) {
3610
+ var reEndWithSpace = /(\S*)\s$/g;
3611
+ return reEndWithSpace.test(text);
3612
+ }
3600
3613
 
3601
3614
  // EXTERNAL MODULE: external {"commonjs":"prosemirror-view","commonjs2":"prosemirror-view","amd":"prosemirror-view"}
3602
3615
  var external_commonjs_prosemirror_view_commonjs2_prosemirror_view_amd_prosemirror_view_ = __webpack_require__(311);
@@ -4001,6 +4014,7 @@ var reHTMLTag = new RegExp("^" + HTML_TAG, 'i');
4001
4014
  var reBR = /<br\s*\/*>/i;
4002
4015
  var reHTMLComment = /<! ---->|<!--(?:-?[^>-])(?:-?[^-])*-->/;
4003
4016
  var ALTERNATIVE_TAG_FOR_BR = '</p><p>';
4017
+ var DEFAULT_TEXT_NOT_START_OR_END_WITH_SPACE = 'a';
4004
4018
 
4005
4019
  ;// CONCATENATED MODULE: ./src/utils/dom.ts
4006
4020
 
@@ -22351,6 +22365,12 @@ var nodeTypeWriters = {
22351
22365
  state.write('<br>\n');
22352
22366
  }
22353
22367
  else if (emptyNode && !prevEmptyNode && !firstChildNode) {
22368
+ if ((parent === null || parent === void 0 ? void 0 : parent.type.name) === 'listItem') {
22369
+ var prevDelim = state.getDelim();
22370
+ state.setDelim('');
22371
+ state.write('<br>');
22372
+ state.setDelim(prevDelim);
22373
+ }
22354
22374
  state.write('\n');
22355
22375
  }
22356
22376
  else {
@@ -22710,30 +22730,42 @@ var toMdConvertors = {
22710
22730
  text: node.textContent,
22711
22731
  };
22712
22732
  },
22713
- strong: function (_a, _b) {
22733
+ strong: function (_a, _b, betweenSpace) {
22714
22734
  var node = _a.node;
22715
22735
  var entering = _b.entering;
22716
22736
  var rawHTML = node.attrs.rawHTML;
22737
+ var delim = '**';
22738
+ if (!betweenSpace) {
22739
+ delim = entering ? '<strong>' : '</strong>';
22740
+ }
22717
22741
  return {
22718
- delim: '**',
22742
+ delim: delim,
22719
22743
  rawHTML: entering ? getOpenRawHTML(rawHTML) : getCloseRawHTML(rawHTML),
22720
22744
  };
22721
22745
  },
22722
- emph: function (_a, _b) {
22746
+ emph: function (_a, _b, betweenSpace) {
22723
22747
  var node = _a.node;
22724
22748
  var entering = _b.entering;
22725
22749
  var rawHTML = node.attrs.rawHTML;
22750
+ var delim = '*';
22751
+ if (!betweenSpace) {
22752
+ delim = entering ? '<em>' : '</em>';
22753
+ }
22726
22754
  return {
22727
- delim: '*',
22755
+ delim: delim,
22728
22756
  rawHTML: entering ? getOpenRawHTML(rawHTML) : getCloseRawHTML(rawHTML),
22729
22757
  };
22730
22758
  },
22731
- strike: function (_a, _b) {
22759
+ strike: function (_a, _b, betweenSpace) {
22732
22760
  var node = _a.node;
22733
22761
  var entering = _b.entering;
22734
22762
  var rawHTML = node.attrs.rawHTML;
22763
+ var delim = '~~';
22764
+ if (!betweenSpace) {
22765
+ delim = entering ? '<del>' : '</del>';
22766
+ }
22735
22767
  return {
22736
- delim: '~~',
22768
+ delim: delim,
22737
22769
  rawHTML: entering ? getOpenRawHTML(rawHTML) : getCloseRawHTML(rawHTML),
22738
22770
  };
22739
22771
  },
@@ -22840,7 +22872,7 @@ function createMarkTypeConvertors(convertors) {
22840
22872
  var markTypeConvertors = {};
22841
22873
  var markTypes = Object.keys(markTypeOptions);
22842
22874
  markTypes.forEach(function (type) {
22843
- markTypeConvertors[type] = function (nodeInfo, entering) {
22875
+ markTypeConvertors[type] = function (nodeInfo, entering, betweenSpace) {
22844
22876
  var markOption = markTypeOptions[type];
22845
22877
  var convertor = convertors[type];
22846
22878
  // There are two ways to call the mark type converter
@@ -22848,7 +22880,9 @@ function createMarkTypeConvertors(convertors) {
22848
22880
  // When calling the converter without using `delim` and `rawHTML` values,
22849
22881
  // the converter is called without parameters.
22850
22882
  var runConvertor = convertor && nodeInfo && !isUndefined_default()(entering);
22851
- var params = runConvertor ? convertor(nodeInfo, { entering: entering }) : {};
22883
+ var params = runConvertor
22884
+ ? convertor(nodeInfo, { entering: entering }, betweenSpace)
22885
+ : {};
22852
22886
  return __assign(__assign({}, params), markOption);
22853
22887
  };
22854
22888
  });
@@ -22892,6 +22926,7 @@ function createMdConvertors(customConvertors) {
22892
22926
 
22893
22927
  ;// CONCATENATED MODULE: ./src/convertors/toMarkdown/toMdConvertorState.ts
22894
22928
 
22929
+
22895
22930
  var ToMdConvertorState = /** @class */ (function () {
22896
22931
  function ToMdConvertorState(_a) {
22897
22932
  var nodeTypeConvertors = _a.nodeTypeConvertors, markTypeConvertors = _a.markTypeConvertors;
@@ -22911,14 +22946,30 @@ var ToMdConvertorState = /** @class */ (function () {
22911
22946
  ToMdConvertorState.prototype.isInBlank = function () {
22912
22947
  return /(^|\n)$/.test(this.result);
22913
22948
  };
22949
+ ToMdConvertorState.prototype.isBetweenSpaces = function (parent, index) {
22950
+ var _a, _b;
22951
+ var content = parent.content;
22952
+ var isFrontNodeEndWithSpace = index === 0 ||
22953
+ isEndWithSpace((_a = content.child(index - 1).text) !== null && _a !== void 0 ? _a : DEFAULT_TEXT_NOT_START_OR_END_WITH_SPACE);
22954
+ var isRearNodeStartWithSpace = index >= content.childCount - 1 ||
22955
+ isStartWithSpace((_b = content.child(index + 1).text) !== null && _b !== void 0 ? _b : DEFAULT_TEXT_NOT_START_OR_END_WITH_SPACE);
22956
+ return isFrontNodeEndWithSpace && isRearNodeStartWithSpace;
22957
+ };
22914
22958
  ToMdConvertorState.prototype.markText = function (mark, entering, parent, index) {
22915
22959
  var convertor = this.getMarkConvertor(mark);
22916
22960
  if (convertor) {
22917
- var _a = convertor({ node: mark, parent: parent, index: index }, entering), delim = _a.delim, rawHTML = _a.rawHTML;
22961
+ var betweenSpace = this.isBetweenSpaces(parent, entering ? index : index - 1);
22962
+ var _a = convertor({ node: mark, parent: parent, index: index }, entering, betweenSpace), delim = _a.delim, rawHTML = _a.rawHTML;
22918
22963
  return rawHTML || delim;
22919
22964
  }
22920
22965
  return '';
22921
22966
  };
22967
+ ToMdConvertorState.prototype.setDelim = function (delim) {
22968
+ this.delim = delim;
22969
+ };
22970
+ ToMdConvertorState.prototype.getDelim = function () {
22971
+ return this.delim;
22972
+ };
22922
22973
  ToMdConvertorState.prototype.flushClose = function (size) {
22923
22974
  if (!this.stopNewline && this.closed) {
22924
22975
  if (!this.isInBlank()) {
@@ -22941,11 +22992,11 @@ var ToMdConvertorState = /** @class */ (function () {
22941
22992
  }
22942
22993
  };
22943
22994
  ToMdConvertorState.prototype.wrapBlock = function (delim, firstDelim, node, fn) {
22944
- var old = this.delim;
22995
+ var old = this.getDelim();
22945
22996
  this.write(firstDelim || delim);
22946
- this.delim += delim;
22997
+ this.setDelim(this.getDelim() + delim);
22947
22998
  fn();
22948
- this.delim = old;
22999
+ this.setDelim(old);
22949
23000
  this.closeBlock(node);
22950
23001
  };
22951
23002
  ToMdConvertorState.prototype.ensureNewLine = function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toast-ui/editor",
3
- "version": "3.1.7",
3
+ "version": "3.1.8",
4
4
  "description": "GFM Markdown Wysiwyg Editor - Productive and Extensible",
5
5
  "keywords": [
6
6
  "nhn",
@@ -45,6 +45,8 @@ export type FirstDelimFn = (index: number) => string;
45
45
  export interface ToMdConvertorState {
46
46
  stopNewline: boolean;
47
47
  inTable: boolean;
48
+ getDelim(): string;
49
+ setDelim(delim: string): void;
48
50
  flushClose(size?: number): void;
49
51
  wrapBlock(delim: string, firstDelim: string | null, node: ProsemirrorNode, fn: () => void): void;
50
52
  ensureNewLine(): void;
@@ -111,7 +113,8 @@ export type ToMdNodeTypeConvertorMap = Partial<Record<WwNodeType, ToMdNodeTypeCo
111
113
 
112
114
  type ToMdMarkTypeConvertor = (
113
115
  nodeInfo?: MarkInfo,
114
- entering?: boolean
116
+ entering?: boolean,
117
+ betweenSpace?: boolean
115
118
  ) => ToMdConvertorReturnValues & ToMdMarkTypeOption;
116
119
 
117
120
  export type ToMdMarkTypeConvertorMap = Partial<Record<WwMarkType, ToMdMarkTypeConvertor>>;
@@ -124,7 +127,8 @@ interface ToMdConvertorContext {
124
127
 
125
128
  type ToMdConvertor = (
126
129
  nodeInfo: NodeInfo | MarkInfo,
127
- context: ToMdConvertorContext
130
+ context: ToMdConvertorContext,
131
+ betweenSpace?: boolean
128
132
  ) => ToMdConvertorReturnValues;
129
133
 
130
134
  export type ToMdConvertorMap = Partial<Record<WwNodeType | MdNodeType, ToMdConvertor>>;
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Type definitions for TOAST UI Editor v3.1.7
1
+ // Type definitions for TOAST UI Editor v3.1.8
2
2
  // TypeScript Version: 4.2.3
3
3
  import {
4
4
  EditorCore,