From 5a1e329618e11fc53354bea19bc0bce896af348b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Mon, 23 Dec 2019 13:25:00 +0200 Subject: [PATCH] Fix being unable to place the cursor in between bubbles in the citation dialog Regression in Fx60 --- .../content/zotero/integration/quickFormat.js | 109 +++++++++++------- 1 file changed, 67 insertions(+), 42 deletions(-) diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js index a1d6c92182..9b181f8f41 100644 --- a/chrome/content/zotero/integration/quickFormat.js +++ b/chrome/content/zotero/integration/quickFormat.js @@ -124,9 +124,10 @@ var Zotero_QuickFormat = new function () { if(Zotero.isMac || Zotero.isWin) { referencePanel.setAttribute("noautohide", true); } - } else if(event.target === qfi.contentDocument) { + } else if (event.target === qfi.contentDocument) { qfiWindow = qfi.contentWindow; qfiDocument = qfi.contentDocument; + qfb.addEventListener("click", _onQuickSearchClick, false); qfb.addEventListener("keypress", _onQuickSearchKeyPress, false); qfe = qfiDocument.getElementById("quick-format-editor"); qfe.addEventListener("drop", _onBubbleDrop, false); @@ -138,7 +139,7 @@ var Zotero_QuickFormat = new function () { * Initialize add citation dialog */ this.onLoad = function(event) { - if(event.target !== document) return; + if (event.target !== document) return; // make sure we are visible window.setTimeout(function() { window.resizeTo(window.outerWidth, qfb.clientHeight); @@ -236,9 +237,11 @@ var Zotero_QuickFormat = new function () { // add to previous cite var node = _getCurrentEditorTextNode(); var prevNode = node.previousSibling; - if(prevNode && prevNode.citationItem && prevNode.citationItem.locator) { - prevNode.citationItem.locator += str; - prevNode.textContent = _buildBubbleString(prevNode.citationItem); + let citationItem = JSON.parse(prevNode && prevNode.dataset.citationItem || "{}"); + if (citationItem.locator) { + citationItem.locator += str; + prevNode.dataset.citationItem = JSON.stringify(citationItem); + prevNode.textContent = _buildBubbleString(citationItem); node.nodeValue = ""; _clearEntryList(); return; @@ -253,9 +256,11 @@ var Zotero_QuickFormat = new function () { // add to previous cite var node = _getCurrentEditorTextNode(); var prevNode = node.previousSibling; + let citationItem = JSON.parse(prevNode && prevNode.dataset.citationItem || "{}"); if(prevNode && prevNode.citationItem) { - prevNode.citationItem.locator = m[2]; - prevNode.textContent = _buildBubbleString(prevNode.citationItem); + citationItem.locator = m[2]; + prevNode.dataset.citationItem = JSON.stringify(citationItem); + prevNode.textContent = _buildBubbleString(citationItem); node.nodeValue = ""; _clearEntryList(); return; @@ -695,7 +700,7 @@ var Zotero_QuickFormat = new function () { bubble.textContent = str; bubble.addEventListener("click", _onBubbleClick, false); bubble.addEventListener("dragstart", _onBubbleDrag, false); - bubble.citationItem = citationItem; + bubble.dataset.citationItem = JSON.stringify(citationItem); if(nextNode && nextNode instanceof Range) { nextNode.insertNode(bubble); } else { @@ -924,8 +929,10 @@ var Zotero_QuickFormat = new function () { function _updateCitationObject() { var nodes = qfe.childNodes; io.citation.citationItems = []; - for(var i=0, n=nodes.length; i