From b5ce8b655a14773b032fb94eec616409d8cd770e Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 1 Nov 2022 03:54:54 -0400 Subject: [PATCH] Fix error copying from note if note Quick Copy format is "HTML" In this case, Note Markdown wouldn't be preloaded, but it's always used for copying from the note editor, and since the note editor uses `noWait`, this would result in "Code promise is not resolved in noWait mode". --- chrome/content/zotero/xpcom/quickCopy.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/chrome/content/zotero/xpcom/quickCopy.js b/chrome/content/zotero/xpcom/quickCopy.js index f70a151ae7..098034cdfa 100644 --- a/chrome/content/zotero/xpcom/quickCopy.js +++ b/chrome/content/zotero/xpcom/quickCopy.js @@ -325,14 +325,19 @@ Zotero.QuickCopy = new function() { var _loadNoteOutputFormat = async function () { var format = Zotero.Prefs.get("export.noteQuickCopy.setting"); format = Zotero.QuickCopy.unserializeSetting(format); - // If virtual "Markdown + Rich Text" translator is selected, preload Note Markdown and - // Note HTML translators - if (format.id == Zotero.Translators.TRANSLATOR_ID_MARKDOWN_AND_RICH_TEXT) { - await _preloadFormat({ mode: 'export', id: Zotero.Translators.TRANSLATOR_ID_NOTE_MARKDOWN, options: format.markdownOptions }); - await _preloadFormat({ mode: 'export', id: Zotero.Translators.TRANSLATOR_ID_NOTE_HTML, options: format.htmlOptions }); - return; + + // Always preload Note Markdown and Note HTML translators. They're both needed for note + // dragging if the format is "Markdown + Rich Text", HTML is needed for note dragging if + // the format is "HTML", and they're both needed for copying or dragging from the note + // editor, which uses `noWait`. + await _preloadFormat({ mode: 'export', id: Zotero.Translators.TRANSLATOR_ID_NOTE_MARKDOWN }); + await _preloadFormat({ mode: 'export', id: Zotero.Translators.TRANSLATOR_ID_NOTE_HTML }); + + // If there's another format, preload it for note item dragging + if (format.id != Zotero.Translators.TRANSLATOR_ID_MARKDOWN_AND_RICH_TEXT + && format.id != Zotero.Translators.TRANSLATOR_ID_NOTE_HTML) { + await _preloadFormat(format); } - return _preloadFormat(format); };