@contentful/field-editor-rich-text 2.0.0-next.35 → 2.0.0-next.36
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/CHANGELOG.md +410 -0
- package/dist/field-editor-rich-text.cjs.development.js +40 -0
- package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
- package/dist/field-editor-rich-text.esm.js +40 -0
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/test-utils/jsx.d.ts +1 -1
- package/package.json +1 -1
|
@@ -6607,6 +6607,7 @@ function createTextPlugin() {
|
|
|
6607
6607
|
deleteEmptyParagraph(unit, editor, deleteForward);
|
|
6608
6608
|
};
|
|
6609
6609
|
|
|
6610
|
+
fixPasteAsPlainText(editor);
|
|
6610
6611
|
return editor;
|
|
6611
6612
|
}
|
|
6612
6613
|
};
|
|
@@ -6657,6 +6658,45 @@ function deleteEmptyParagraph(unit, editor, deleteFunction) {
|
|
|
6657
6658
|
deleteFunction(unit);
|
|
6658
6659
|
}
|
|
6659
6660
|
}
|
|
6661
|
+
/**
|
|
6662
|
+
* To be compatible with the old behavior we need to treat each 2 consecutive
|
|
6663
|
+
* line breaks as a new paragraph when pasting as plain text (also known as
|
|
6664
|
+
* paste and match style in macOS)
|
|
6665
|
+
*/
|
|
6666
|
+
|
|
6667
|
+
|
|
6668
|
+
function fixPasteAsPlainText(editor) {
|
|
6669
|
+
editor.insertTextData = function (data) {
|
|
6670
|
+
var text = data.getData('text/plain');
|
|
6671
|
+
|
|
6672
|
+
if (!text) {
|
|
6673
|
+
return false;
|
|
6674
|
+
}
|
|
6675
|
+
|
|
6676
|
+
var lines = text.split(/\n{2}/);
|
|
6677
|
+
var split = false;
|
|
6678
|
+
|
|
6679
|
+
for (var _iterator = _createForOfIteratorHelperLoose(lines), _step; !(_step = _iterator()).done;) {
|
|
6680
|
+
var line = _step.value;
|
|
6681
|
+
|
|
6682
|
+
// empty lines
|
|
6683
|
+
if (/^(\r\n?|\n)$/.test(line)) {
|
|
6684
|
+
continue;
|
|
6685
|
+
}
|
|
6686
|
+
|
|
6687
|
+
if (split) {
|
|
6688
|
+
Transforms.splitNodes(editor, {
|
|
6689
|
+
always: true
|
|
6690
|
+
});
|
|
6691
|
+
}
|
|
6692
|
+
|
|
6693
|
+
editor.insertText(line);
|
|
6694
|
+
split = true;
|
|
6695
|
+
}
|
|
6696
|
+
|
|
6697
|
+
return true;
|
|
6698
|
+
};
|
|
6699
|
+
}
|
|
6660
6700
|
|
|
6661
6701
|
var createTrailingParagraphPlugin = function createTrailingParagraphPlugin() {
|
|
6662
6702
|
return createTrailingBlockPlugin({
|