diff --git a/chrome/content/zotero/xpcom/editorInstance.js b/chrome/content/zotero/xpcom/editorInstance.js index d253388ad1..c8795262ee 100644 --- a/chrome/content/zotero/xpcom/editorInstance.js +++ b/chrome/content/zotero/xpcom/editorInstance.js @@ -89,6 +89,25 @@ class EditorInstance { return doc.execCommand(command, ui, value); }; + // Translate note HTML into Markdown, for setting it as text/plain in clipboard (on text copy/drag) + this._iframeWindow.wrappedJSObject.zoteroTranslateToMarkdown = (html) => { + let item = new Zotero.Item('note'); + item.libraryID = this._item.libraryID; + item.setNote(html); + let text = ''; + var translation = new Zotero.Translate.Export; + translation.noWait = true; + translation.setItems([item]); + translation.setTranslator(Zotero.Translators.TRANSLATOR_ID_NOTE_MARKDOWN); + translation.setHandler("done", (obj, worked) => { + if (worked) { + text = obj.string.replace(/\r\n/g, '\n'); + } + }); + translation.translate(); + return text; + }; + this._iframeWindow.addEventListener('message', this._messageHandler); this._iframeWindow.addEventListener('error', (event) => { Zotero.logError(event.error); diff --git a/note-editor b/note-editor index 3c75eb213b..8e7b266875 160000 --- a/note-editor +++ b/note-editor @@ -1 +1 @@ -Subproject commit 3c75eb213b23da239b5b0c69b9e61ff54a2f2a4c +Subproject commit 8e7b266875dc9d7dc14d5c9413197ae80d8dbf11