diff --git a/chrome/content/scaffold/scaffold.js b/chrome/content/scaffold/scaffold.js index e1000e92c9..4a0e039a01 100644 --- a/chrome/content/scaffold/scaffold.js +++ b/chrome/content/scaffold/scaffold.js @@ -30,7 +30,7 @@ var { RemoteTranslate } = ChromeUtils.import("chrome://zotero/content/RemoteTran var { ContentDOMReference } = ChromeUtils.import("resource://gre/modules/ContentDOMReference.jsm"); var { Zotero } = ChromeUtils.importESModule("chrome://zotero/content/zotero.mjs"); -import FilePicker from 'zotero/modules/filePicker'; +var { FilePicker } = ChromeUtils.importESModule('chrome://zotero/content/modules/filePicker.mjs'); // Fix JSON stringify 2028/2029 "bug" // Borrowed from http://stackoverflow.com/questions/16686687/json-stringify-and-u2028-u2029-check diff --git a/chrome/content/zotero/fileInterface.js b/chrome/content/zotero/fileInterface.js index 9afe469e9b..768ec2b23e 100644 --- a/chrome/content/zotero/fileInterface.js +++ b/chrome/content/zotero/fileInterface.js @@ -23,9 +23,8 @@ ***** END LICENSE BLOCK ***** */ -Components.utils.import("resource://gre/modules/osfile.jsm"); Components.utils.import("resource://gre/modules/Services.jsm"); -import FilePicker from 'zotero/modules/filePicker'; +var { FilePicker } = ChromeUtils.importESModule('chrome://zotero/content/modules/filePicker.mjs'); import { ImportCitaviAnnotatons } from 'zotero/import/citavi'; /****Zotero_File_Exporter**** diff --git a/chrome/content/zotero/import/importWizard.js b/chrome/content/zotero/import/importWizard.js index dbf7c2d9cd..40aa38191c 100644 --- a/chrome/content/zotero/import/importWizard.js +++ b/chrome/content/zotero/import/importWizard.js @@ -25,7 +25,7 @@ /* eslint camelcase: ["error", {allow: ["Zotero_File_Interface", "Zotero_Import_Wizard"]} ] */ /* global Zotero_File_Interface: false, mendeleyAPIUtils: false */ -import FilePicker from 'zotero/filePicker'; +var { FilePicker } = ChromeUtils.importESModule('chrome://zotero/content/modules/filePicker.mjs'); import React from 'react'; import ReactDOM from 'react-dom'; import ProgressQueueTable from 'components/progressQueueTable'; diff --git a/chrome/content/zotero/modules/filePicker.js b/chrome/content/zotero/modules/filePicker.mjs similarity index 96% rename from chrome/content/zotero/modules/filePicker.js rename to chrome/content/zotero/modules/filePicker.mjs index 3d45d41675..c6c5b1be52 100644 --- a/chrome/content/zotero/modules/filePicker.js +++ b/chrome/content/zotero/modules/filePicker.mjs @@ -23,8 +23,11 @@ ***** END LICENSE BLOCK ***** */ -import { Cc, Ci, Cu } from 'chrome'; -Cu.import("resource://gre/modules/osfile.jsm"); +const lazy = {}; + +ChromeUtils.defineESModuleGetters(lazy, { + FileUtils: "resource://gre/modules/FileUtils.sys.mjs", +}); /** * Interface to the system filepicker. @@ -34,7 +37,7 @@ Cu.import("resource://gre/modules/osfile.jsm"); * * @class */ -class FilePicker { +export class FilePicker { constructor() { this._fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker); } @@ -76,7 +79,7 @@ class FilePicker { * @return {Promise} One of the return constants */ async show() { - return new Zotero.Promise(function (resolve) { + return new Promise(function (resolve) { this._fp.open(returnConstant => resolve(returnConstant)); }.bind(this)); }; @@ -164,7 +167,7 @@ FilePicker.prototype.filterVideo = 0x200; set: function (val) { if (prop == 'displayDirectory') { // Convert to nsIFile - val = Zotero.File.pathToFile(val); + val = new lazy.FileUtils.File(val); } this._fp[prop] = val; }, @@ -222,5 +225,3 @@ FilePicker.prototype.filterVideo = 0x200; }); Object.freeze(FilePicker.prototype); - -export default FilePicker; \ No newline at end of file diff --git a/chrome/content/zotero/preferences/preferences_advanced.js b/chrome/content/zotero/preferences/preferences_advanced.js index 0d8ff40569..34c3b39a37 100644 --- a/chrome/content/zotero/preferences/preferences_advanced.js +++ b/chrome/content/zotero/preferences/preferences_advanced.js @@ -24,7 +24,7 @@ */ Components.utils.import("resource://gre/modules/Services.jsm"); -import FilePicker from 'zotero/modules/filePicker'; +var { FilePicker } = ChromeUtils.importESModule('chrome://zotero/content/modules/filePicker.mjs'); Zotero_Preferences.Advanced = { init: function () { diff --git a/chrome/content/zotero/preferences/preferences_cite.jsx b/chrome/content/zotero/preferences/preferences_cite.jsx index 8281421b8e..a7fd261c3b 100644 --- a/chrome/content/zotero/preferences/preferences_cite.jsx +++ b/chrome/content/zotero/preferences/preferences_cite.jsx @@ -25,7 +25,7 @@ "use strict"; -import FilePicker from 'zotero/modules/filePicker'; +var { FilePicker } = ChromeUtils.importESModule('chrome://zotero/content/modules/filePicker.mjs'); var React = require('react'); var ReactDOM = require('react-dom'); diff --git a/chrome/content/zotero/preferences/preferences_general.js b/chrome/content/zotero/preferences/preferences_general.js index f3c221ea1e..63c13a68e4 100644 --- a/chrome/content/zotero/preferences/preferences_general.js +++ b/chrome/content/zotero/preferences/preferences_general.js @@ -27,7 +27,7 @@ Components.utils.import("resource://gre/modules/Services.jsm"); Components.utils.import("resource://gre/modules/osfile.jsm"); -import FilePicker from 'zotero/modules/filePicker'; +var { FilePicker } = ChromeUtils.importESModule('chrome://zotero/content/modules/filePicker.mjs'); Zotero_Preferences.General = { _openURLResolvers: null, diff --git a/chrome/content/zotero/rtfScan.js b/chrome/content/zotero/rtfScan.js index bf3174c029..5ca49898e3 100644 --- a/chrome/content/zotero/rtfScan.js +++ b/chrome/content/zotero/rtfScan.js @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import FilePicker from 'zotero/modules/filePicker'; +var { FilePicker } = ChromeUtils.importESModule('chrome://zotero/content/modules/filePicker.mjs'); import VirtualizedTable from 'components/virtualized-table'; import { getCSSIcon } from 'components/icons'; diff --git a/chrome/content/zotero/tools/build_typeSchemaData.js b/chrome/content/zotero/tools/build_typeSchemaData.js index 218a5fbcd8..86f1ce0fbd 100644 --- a/chrome/content/zotero/tools/build_typeSchemaData.js +++ b/chrome/content/zotero/tools/build_typeSchemaData.js @@ -1,4 +1,4 @@ -import FilePicker from 'zotero/modules/filePicker'; +var { FilePicker } = ChromeUtils.importESModule('chrome://zotero/content/modules/filePicker.mjs'); (async function () { // Create schema diff --git a/chrome/content/zotero/tools/csledit.js b/chrome/content/zotero/tools/csledit.js index 30bf09e0ea..43f46640ca 100644 --- a/chrome/content/zotero/tools/csledit.js +++ b/chrome/content/zotero/tools/csledit.js @@ -23,7 +23,7 @@ ***** END LICENSE BLOCK ***** */ -import FilePicker from 'zotero/modules/filePicker'; +var { FilePicker } = ChromeUtils.importESModule('chrome://zotero/content/modules/filePicker.mjs'); var Zotero_CSL_Editor = new function () { let monaco, editor; diff --git a/chrome/content/zotero/xpcom/dataDirectory.js b/chrome/content/zotero/xpcom/dataDirectory.js index 3fb16b1b22..e5c8f6cc5b 100644 --- a/chrome/content/zotero/xpcom/dataDirectory.js +++ b/chrome/content/zotero/xpcom/dataDirectory.js @@ -25,7 +25,7 @@ "use strict"; -import FilePicker from 'zotero/modules/filePicker'; +var { FilePicker } = ChromeUtils.importESModule('chrome://zotero/content/modules/filePicker.mjs'); Zotero.DataDirectory = { MIGRATION_MARKER: 'migrate-dir', diff --git a/chrome/content/zotero/xpcom/editorInstance.js b/chrome/content/zotero/xpcom/editorInstance.js index 266992d05d..566d54cf12 100644 --- a/chrome/content/zotero/xpcom/editorInstance.js +++ b/chrome/content/zotero/xpcom/editorInstance.js @@ -25,7 +25,7 @@ Components.utils.import("resource://gre/modules/InlineSpellChecker.jsm"); -import FilePicker from 'zotero/modules/filePicker'; +var { FilePicker } = ChromeUtils.importESModule('chrome://zotero/content/modules/filePicker.mjs'); // Note: TinyMCE is automatically doing some meaningless corrections to // note-editor produced HTML. Which might result to more diff --git a/chrome/content/zotero/xpcom/reader.js b/chrome/content/zotero/xpcom/reader.js index 7a806a61e4..97fabed71f 100644 --- a/chrome/content/zotero/xpcom/reader.js +++ b/chrome/content/zotero/xpcom/reader.js @@ -23,7 +23,7 @@ ***** END LICENSE BLOCK ***** */ -import FilePicker from 'zotero/modules/filePicker'; +var { FilePicker } = ChromeUtils.importESModule('chrome://zotero/content/modules/filePicker.mjs'); const { BlockingObserver } = ChromeUtils.import("chrome://zotero/content/BlockingObserver.jsm"); diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index e63b52ea51..619f5c6b77 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -23,7 +23,7 @@ ***** END LICENSE BLOCK ***** */ -import FilePicker from 'zotero/modules/filePicker'; +var { FilePicker } = ChromeUtils.importESModule('chrome://zotero/content/modules/filePicker.mjs'); /* * This object contains the various functions for the interface diff --git a/resource/require.js b/resource/require.js index 8a962d4ad4..12ce7b5638 100644 --- a/resource/require.js +++ b/resource/require.js @@ -104,9 +104,6 @@ var require = (function() { 'containers/': 'chrome://zotero/content/containers/', 'components/': 'chrome://zotero/content/components/', 'zotero/': 'chrome://zotero/content/', - // TEMP until plugins updated - // TODO: Possible to show a deprecation warning? - 'zotero/filePicker': 'chrome://zotero/content/modules/filePicker', }, globals });