From d8c67a8f003590870eb9c18af20ac3cb2eb4958e Mon Sep 17 00:00:00 2001 From: Russel Neiss Date: Mon, 25 Apr 2022 14:16:55 -0500 Subject: [PATCH] Fix for weirdness when pasting sefaria links into an empty spacer node --- static/js/Editor.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/static/js/Editor.jsx b/static/js/Editor.jsx index d861cb80df..eafab2a379 100644 --- a/static/js/Editor.jsx +++ b/static/js/Editor.jsx @@ -1410,7 +1410,12 @@ const withSefariaSheet = editor => { return } const link = editor.createLinkNode(url.href, matches[1]) + Transforms.insertText(editor, " ") // this is start of dance that's required to ensure that link gets inserted properly + const initLoc = editor.selection Transforms.insertNodes(editor, link); + Transforms.select(editor, initLoc); // dance ii + Transforms.move(editor, { distance: 1, unit: 'character', reverse: true }) // dance dance dance + Transforms.delete(editor); // end of dance }, error: function (e) { Transforms.insertText(editor, url.href) @@ -1419,12 +1424,12 @@ const withSefariaSheet = editor => { } else { + console.log('not sef link') insertData(data) } } catch { insertData(data) - return false; } } @@ -1554,6 +1559,7 @@ const withSefariaSheet = editor => { editor.convertEmptyParagraphToSpacer = (node, path) => { if (node.type === "paragraph") { if (Node.string(node) === "" && node.children.length <= 1) { + console.log('spacer?') Transforms.setNodes(editor, {type: "spacer"}, {at: path}); } }