@commercetools-uikit/rich-text-utils 15.1.1 → 15.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.
@@ -321,13 +321,17 @@ var mapper = {
321
321
  }
322
322
  };
323
323
 
324
+ var wrapWithParagraph = function wrapWithParagraph(textContent) {
325
+ return slateHyperscript.jsx('element', {
326
+ type: 'paragraph'
327
+ }, textContent);
328
+ };
329
+
324
330
  var wrapWithParagraphIfRootElement = function wrapWithParagraphIfRootElement(el, textContent) {
325
331
  var _el$parentNode;
326
332
 
327
333
  return ((_el$parentNode = el.parentNode) === null || _el$parentNode === void 0 ? void 0 : _el$parentNode.nodeName) === 'BODY' // root element, because body is eventually turned to React fragment
328
- ? slateHyperscript.jsx('element', {
329
- type: 'paragraph'
330
- }, textContent) : textContent;
334
+ ? wrapWithParagraph(textContent) : textContent;
331
335
  };
332
336
 
333
337
  var deserializeElement = function deserializeElement(el) {
@@ -419,9 +423,12 @@ var deserializeElement = function deserializeElement(el) {
419
423
  return _mapInstanceProperty__default["default"](children).call(children, function (child) {
420
424
  return slateHyperscript.jsx('text', _attrs2, child);
421
425
  });
422
- }
426
+ } // each non-empty text node must be wrapped with a paragraph
427
+
423
428
 
424
- return children;
429
+ return _mapInstanceProperty__default["default"](children).call(children, function (child) {
430
+ return slate.Text.isText(child) && child.text ? wrapWithParagraph(child) : child;
431
+ });
425
432
  };
426
433
 
427
434
  var deserialize = function deserialize(html) {
@@ -3247,7 +3254,7 @@ RichTextEditorBody.defaultProps = defaultProps;
3247
3254
  var RichTextEditorBody$1 = RichTextEditorBody;
3248
3255
 
3249
3256
  // NOTE: This string will be replaced on build time with the package version.
3250
- var version = "15.1.1";
3257
+ var version = "15.1.2";
3251
3258
 
3252
3259
  exports.Element = Element;
3253
3260
  exports.HiddenInput = HiddenInput$1;
@@ -320,13 +320,17 @@ var mapper = {
320
320
  }
321
321
  };
322
322
 
323
+ var wrapWithParagraph = function wrapWithParagraph(textContent) {
324
+ return slateHyperscript.jsx('element', {
325
+ type: 'paragraph'
326
+ }, textContent);
327
+ };
328
+
323
329
  var wrapWithParagraphIfRootElement = function wrapWithParagraphIfRootElement(el, textContent) {
324
330
  var _el$parentNode;
325
331
 
326
332
  return ((_el$parentNode = el.parentNode) === null || _el$parentNode === void 0 ? void 0 : _el$parentNode.nodeName) === 'BODY' // root element, because body is eventually turned to React fragment
327
- ? slateHyperscript.jsx('element', {
328
- type: 'paragraph'
329
- }, textContent) : textContent;
333
+ ? wrapWithParagraph(textContent) : textContent;
330
334
  };
331
335
 
332
336
  var deserializeElement = function deserializeElement(el) {
@@ -418,9 +422,12 @@ var deserializeElement = function deserializeElement(el) {
418
422
  return _mapInstanceProperty__default["default"](children).call(children, function (child) {
419
423
  return slateHyperscript.jsx('text', _attrs2, child);
420
424
  });
421
- }
425
+ } // each non-empty text node must be wrapped with a paragraph
426
+
422
427
 
423
- return children;
428
+ return _mapInstanceProperty__default["default"](children).call(children, function (child) {
429
+ return slate.Text.isText(child) && child.text ? wrapWithParagraph(child) : child;
430
+ });
424
431
  };
425
432
 
426
433
  var deserialize = function deserialize(html) {
@@ -3122,7 +3129,7 @@ RichTextEditorBody.defaultProps = defaultProps;
3122
3129
  var RichTextEditorBody$1 = RichTextEditorBody;
3123
3130
 
3124
3131
  // NOTE: This string will be replaced on build time with the package version.
3125
- var version = "15.1.1";
3132
+ var version = "15.1.2";
3126
3133
 
3127
3134
  exports.Element = Element;
3128
3135
  exports.HiddenInput = HiddenInput$1;
@@ -284,13 +284,17 @@ var mapper = {
284
284
  }
285
285
  };
286
286
 
287
+ var wrapWithParagraph = function wrapWithParagraph(textContent) {
288
+ return jsx('element', {
289
+ type: 'paragraph'
290
+ }, textContent);
291
+ };
292
+
287
293
  var wrapWithParagraphIfRootElement = function wrapWithParagraphIfRootElement(el, textContent) {
288
294
  var _el$parentNode;
289
295
 
290
296
  return ((_el$parentNode = el.parentNode) === null || _el$parentNode === void 0 ? void 0 : _el$parentNode.nodeName) === 'BODY' // root element, because body is eventually turned to React fragment
291
- ? jsx('element', {
292
- type: 'paragraph'
293
- }, textContent) : textContent;
297
+ ? wrapWithParagraph(textContent) : textContent;
294
298
  };
295
299
 
296
300
  var deserializeElement = function deserializeElement(el) {
@@ -382,9 +386,12 @@ var deserializeElement = function deserializeElement(el) {
382
386
  return _mapInstanceProperty(children).call(children, function (child) {
383
387
  return jsx('text', _attrs2, child);
384
388
  });
385
- }
389
+ } // each non-empty text node must be wrapped with a paragraph
390
+
386
391
 
387
- return children;
392
+ return _mapInstanceProperty(children).call(children, function (child) {
393
+ return Text.isText(child) && child.text ? wrapWithParagraph(child) : child;
394
+ });
388
395
  };
389
396
 
390
397
  var deserialize = function deserialize(html) {
@@ -3210,6 +3217,6 @@ RichTextEditorBody.defaultProps = defaultProps;
3210
3217
  var RichTextEditorBody$1 = RichTextEditorBody;
3211
3218
 
3212
3219
  // NOTE: This string will be replaced on build time with the package version.
3213
- var version = "15.1.1";
3220
+ var version = "15.1.2";
3214
3221
 
3215
3222
  export { Element, HiddenInput$1 as HiddenInput, Leaf, RichTextEditorBody$1 as RichTextBody, focusEditor, html$1 as html, isBlockActive, isRichTextEmpty as isEmpty, isMarkActive, index as localized, resetEditor, toggleBlock, toggleMark, validSlateStateAdapter, version };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/rich-text-utils",
3
3
  "description": "Utilities for working with rich-text components.",
4
- "version": "15.1.1",
4
+ "version": "15.1.2",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -24,12 +24,12 @@
24
24
  "dependencies": {
25
25
  "@babel/runtime": "^7.17.2",
26
26
  "@babel/runtime-corejs3": "^7.17.2",
27
- "@commercetools-uikit/design-system": "15.1.1",
28
- "@commercetools-uikit/icons": "15.1.1",
29
- "@commercetools-uikit/input-utils": "15.1.1",
30
- "@commercetools-uikit/spacings-inline": "15.1.1",
31
- "@commercetools-uikit/tooltip": "15.1.1",
32
- "@commercetools-uikit/utils": "15.1.1",
27
+ "@commercetools-uikit/design-system": "15.1.2",
28
+ "@commercetools-uikit/icons": "15.1.2",
29
+ "@commercetools-uikit/input-utils": "15.1.2",
30
+ "@commercetools-uikit/spacings-inline": "15.1.2",
31
+ "@commercetools-uikit/tooltip": "15.1.2",
32
+ "@commercetools-uikit/utils": "15.1.2",
33
33
  "@emotion/react": "^11.4.0",
34
34
  "@emotion/styled": "^11.3.0",
35
35
  "@types/escape-html": "1.0.2",