diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js index 700b6ee8fc..beeb8d6a72 100644 --- a/chrome/content/zotero/integration/quickFormat.js +++ b/chrome/content/zotero/integration/quickFormat.js @@ -38,7 +38,8 @@ var Zotero_QuickFormat = new function () { keepSorted, showEditor, referencePanel, referenceBox, referenceHeight = 0, separatorHeight = 0, currentLocator, currentLocatorLabel, currentSearchTime, dragging, panel, panelPrefix, panelSuffix, panelSuppressAuthor, panelLocatorLabel, panelLocator, - panelLibraryLink, panelInfo, panelRefersToBubble, panelFrameHeight = 0, accepted = false; + panelLibraryLink, panelInfo, panelRefersToBubble, panelFrameHeight = 0, accepted = false, + isPaste = false; var locatorLocked = true; var locatorNode = null; var _searchPromise; @@ -221,10 +222,10 @@ var Zotero_QuickFormat = new function () { // Range could be referenced to the body element if(node === qfe) { - var offset = range.startOffset; - if(offset !== range.endOffset) return false; - node = qfe.childNodes[Math.min(qfe.childNodes.length-1, offset)]; - if(node.nodeType === Node.TEXT_NODE) return node; + for (let i = qfe.childNodes.length - 1; i >= 0; i--) { + node = qfe.childNodes[i]; + if(node.nodeType === Node.TEXT_NODE) return node; + } } return false; } @@ -244,7 +245,7 @@ var Zotero_QuickFormat = new function () { * @return {String} str without locator */ function _updateLocator(str) { - m = locatorRe.exec(str); + m = !isPaste && locatorRe.exec(str); if(m && (m[1] || m[2] || m[3].length !== 4) && m.index > 0) { currentLocator = m[3]; str = str.substr(0, m.index)+str.substring(m.index+m[0].length); @@ -872,6 +873,7 @@ var Zotero_QuickFormat = new function () { // handling to maintain the correct locator node in // _showCitation() var bubble = locatorNode = _insertBubble(citationItem, node); + isPaste = false; _clearEntryList(); yield _previewAndSort(); _refocusQfe(); @@ -1357,6 +1359,7 @@ var Zotero_QuickFormat = new function () { event.preventDefault(); } } else { + isPaste = false; _resetSearchTimer(); } });