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".
This commit is contained in:
Dan Stillman 2022-11-01 03:54:54 -04:00
parent cbb524d257
commit b9a5fd9f78

View file

@ -325,14 +325,19 @@ Zotero.QuickCopy = new function() {
var _loadNoteOutputFormat = async function () { var _loadNoteOutputFormat = async function () {
var format = Zotero.Prefs.get("export.noteQuickCopy.setting"); var format = Zotero.Prefs.get("export.noteQuickCopy.setting");
format = Zotero.QuickCopy.unserializeSetting(format); format = Zotero.QuickCopy.unserializeSetting(format);
// If virtual "Markdown + Rich Text" translator is selected, preload Note Markdown and
// Note HTML translators // Always preload Note Markdown and Note HTML translators. They're both needed for note
if (format.id == Zotero.Translators.TRANSLATOR_ID_MARKDOWN_AND_RICH_TEXT) { // dragging if the format is "Markdown + Rich Text", HTML is needed for note dragging if
await _preloadFormat({ mode: 'export', id: Zotero.Translators.TRANSLATOR_ID_NOTE_MARKDOWN, options: format.markdownOptions }); // the format is "HTML", and they're both needed for copying or dragging from the note
await _preloadFormat({ mode: 'export', id: Zotero.Translators.TRANSLATOR_ID_NOTE_HTML, options: format.htmlOptions }); // editor, which uses `noWait`.
return; 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);
}; };