@bigbinary/neeto-editor 1.45.8 → 1.45.9

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.
package/dist/Editor.js CHANGED
@@ -10578,12 +10578,25 @@ var ImageExtension = Node.create({
10578
10578
  props: {
10579
10579
  handleDOMEvents: {
10580
10580
  paste: function paste(view, event) {
10581
- var _event$clipboardData;
10581
+ var _event$clipboardData, _event$clipboardData2;
10582
10582
  var _view$state = view.state,
10583
10583
  schema = _view$state.schema,
10584
10584
  pos = _view$state.selection.$anchor.pos;
10585
- var hasFiles = (_event$clipboardData = event.clipboardData) === null || _event$clipboardData === void 0 || (_event$clipboardData = _event$clipboardData.files) === null || _event$clipboardData === void 0 ? void 0 : _event$clipboardData.length;
10585
+
10586
+ // Microsoft Excel and a few other products might copy content as
10587
+ // both `text/plain` and `text/html`. If `text/plain` exists,
10588
+ // an early return will ensure that it fallbacks to tiptap's
10589
+ // default paste behavior.
10590
+ var text = event === null || event === void 0 || (_event$clipboardData = event.clipboardData) === null || _event$clipboardData === void 0 ? void 0 : _event$clipboardData.getData("text/plain");
10591
+ var hasFiles = (_event$clipboardData2 = event.clipboardData) === null || _event$clipboardData2 === void 0 || (_event$clipboardData2 = _event$clipboardData2.files) === null || _event$clipboardData2 === void 0 ? void 0 : _event$clipboardData2.length;
10586
10592
  if (!hasFiles) return;
10593
+ if (hasFiles && text) {
10594
+ var _DOMParser$parseFromS;
10595
+ event.preventDefault();
10596
+ var plainText = (_DOMParser$parseFromS = new DOMParser().parseFromString(text, "text/html").body.textContent) !== null && _DOMParser$parseFromS !== void 0 ? _DOMParser$parseFromS : "";
10597
+ view.pasteText(plainText);
10598
+ return;
10599
+ }
10587
10600
  var images = Array.from(event.clipboardData.files).filter(function (file) {
10588
10601
  return /image/i.test(file.type);
10589
10602
  });