@contentful/field-editor-rich-text 2.0.0-next.24 → 2.0.0-next.25

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.
@@ -5221,9 +5221,9 @@ var sanitizeHTML = function sanitizeHTML(html) {
5221
5221
  // Parse the HTML string and pipe it through our transformers
5222
5222
  var doc = transformers.reduce(function (value, cb) {
5223
5223
  return cb(value);
5224
- }, new DOMParser().parseFromString(html, 'text/html')); // Remove whitespace between tags
5225
-
5226
- return doc.body.innerHTML.replace(/>\s+</g, '><');
5224
+ }, new DOMParser().parseFromString(html, 'text/html'));
5225
+ return doc.body.innerHTML.replace(/>\s+</g, '><') // Remove whitespace between tags
5226
+ .replace(/(.*)<div.*>(<table.*<\/table>)<\/div>(.*)/g, '$1$2$3'); // remove div containers from tables
5227
5227
  };
5228
5228
 
5229
5229
  /**
@@ -5764,6 +5764,9 @@ var isNotEmpty = function isNotEmpty(editor, _ref4) {
5764
5764
  var path = _ref4[1];
5765
5765
  return Array.from(slate.Node.children(editor, path)).length !== 0;
5766
5766
  };
5767
+ var isTable = function isTable(node) {
5768
+ return slate.Element.isElement(node) && node.type === Contentful.BLOCKS.TABLE;
5769
+ };
5767
5770
 
5768
5771
  var styles$i = {
5769
5772
  topRight: /*#__PURE__*/emotion.css({
@@ -5941,13 +5944,19 @@ var createTablePlugin = function createTablePlugin() {
5941
5944
  var insertFragment = editor.insertFragment;
5942
5945
 
5943
5946
  editor.insertFragment = function (fragments) {
5947
+ var _editor$selection;
5948
+
5944
5949
  // We need to make sure we have a new, empty and clean paragraph in order to paste tables as-is due to how Slate behaves
5945
5950
  // More info: https://github.com/ianstormtaylor/slate/pull/4489 and https://github.com/ianstormtaylor/slate/issues/4542
5946
- var fragmentHasTable = fragments.some(function (fragment) {
5947
- return fragment.type === Contentful.BLOCKS.TABLE;
5951
+ var isInsertingTable = fragments.some(function (fragment) {
5952
+ return isTable(fragment);
5948
5953
  });
5954
+ var isTableFirstFragment = fragments.findIndex(function (fragment) {
5955
+ return isTable(fragment);
5956
+ }) === 0;
5957
+ var currentLineHasText = plateCore.getText(editor, (_editor$selection = editor.selection) == null ? void 0 : _editor$selection.focus.path) !== '';
5949
5958
 
5950
- if (fragmentHasTable) {
5959
+ if (isInsertingTable && isTableFirstFragment && currentLineHasText) {
5951
5960
  insertEmptyParagraph(editor);
5952
5961
  }
5953
5962