mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 04:00:59 +01:00
fix: pasting plain text should respect paragraphs
This commit is contained in:
18
apps/web/src/components/editor/react-quill.js
vendored
18
apps/web/src/components/editor/react-quill.js
vendored
@@ -19,12 +19,9 @@ Quill.register("modules/magicUrl", MagicUrl);
|
||||
Quill.register("modules/focus", QuillFocus);
|
||||
|
||||
let Embed = Quill.import("blots/embed");
|
||||
let Delta = Quill.import("delta");
|
||||
|
||||
function lineBreakMatcher() {
|
||||
var newDelta = new Delta();
|
||||
newDelta.insert({ manualbreak: true });
|
||||
return newDelta;
|
||||
return { ops: [{ insert: { manualbreak: true } }] };
|
||||
}
|
||||
|
||||
class SmartBreak extends Embed {}
|
||||
@@ -112,6 +109,7 @@ const quillModules = (isSimple, isFocusMode, isMobile) => ({
|
||||
},
|
||||
clipboard: {
|
||||
matchers: [["BR", lineBreakMatcher]],
|
||||
matchVisual: false,
|
||||
},
|
||||
keyboard: {
|
||||
bindings: {
|
||||
@@ -227,6 +225,18 @@ export default class ReactQuill extends Component {
|
||||
);
|
||||
}
|
||||
|
||||
this.quill.clipboard.addMatcher(Node.TEXT_NODE, function (_node, delta) {
|
||||
return {
|
||||
ops: delta.ops[0].insert
|
||||
.split("\n")
|
||||
.filter((p) => !!p)
|
||||
.map((para) => ({
|
||||
insert: para + "\n",
|
||||
attributes: { background: "transparent" },
|
||||
})),
|
||||
};
|
||||
});
|
||||
|
||||
if (onQuillInitialized) onQuillInitialized();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user