@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.
@@ -5214,9 +5214,9 @@ var sanitizeHTML = function sanitizeHTML(html) {
5214
5214
  // Parse the HTML string and pipe it through our transformers
5215
5215
  var doc = transformers.reduce(function (value, cb) {
5216
5216
  return cb(value);
5217
- }, new DOMParser().parseFromString(html, 'text/html')); // Remove whitespace between tags
5218
-
5219
- return doc.body.innerHTML.replace(/>\s+</g, '><');
5217
+ }, new DOMParser().parseFromString(html, 'text/html'));
5218
+ return doc.body.innerHTML.replace(/>\s+</g, '><') // Remove whitespace between tags
5219
+ .replace(/(.*)<div.*>(<table.*<\/table>)<\/div>(.*)/g, '$1$2$3'); // remove div containers from tables
5220
5220
  };
5221
5221
 
5222
5222
  /**
@@ -5757,6 +5757,9 @@ var isNotEmpty = function isNotEmpty(editor, _ref4) {
5757
5757
  var path = _ref4[1];
5758
5758
  return Array.from(Node.children(editor, path)).length !== 0;
5759
5759
  };
5760
+ var isTable = function isTable(node) {
5761
+ return Element.isElement(node) && node.type === BLOCKS.TABLE;
5762
+ };
5760
5763
 
5761
5764
  var styles$i = {
5762
5765
  topRight: /*#__PURE__*/css({
@@ -5934,13 +5937,19 @@ var createTablePlugin = function createTablePlugin() {
5934
5937
  var insertFragment = editor.insertFragment;
5935
5938
 
5936
5939
  editor.insertFragment = function (fragments) {
5940
+ var _editor$selection;
5941
+
5937
5942
  // 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
5938
5943
  // More info: https://github.com/ianstormtaylor/slate/pull/4489 and https://github.com/ianstormtaylor/slate/issues/4542
5939
- var fragmentHasTable = fragments.some(function (fragment) {
5940
- return fragment.type === BLOCKS.TABLE;
5944
+ var isInsertingTable = fragments.some(function (fragment) {
5945
+ return isTable(fragment);
5941
5946
  });
5947
+ var isTableFirstFragment = fragments.findIndex(function (fragment) {
5948
+ return isTable(fragment);
5949
+ }) === 0;
5950
+ var currentLineHasText = getText(editor, (_editor$selection = editor.selection) == null ? void 0 : _editor$selection.focus.path) !== '';
5942
5951
 
5943
- if (fragmentHasTable) {
5952
+ if (isInsertingTable && isTableFirstFragment && currentLineHasText) {
5944
5953
  insertEmptyParagraph(editor);
5945
5954
  }
5946
5955