Skip to content

Commit a3bfa68

Browse files
committed
feat: drag and drop experimental menu in linux
1 parent fb2b3ea commit a3bfa68

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

src/extensions/default/DebugCommands/main.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ define(function (require, exports, module) {
3535
PerfUtils = brackets.getModule("utils/PerfUtils"),
3636
StringUtils = brackets.getModule("utils/StringUtils"),
3737
Dialogs = brackets.getModule("widgets/Dialogs"),
38-
DefaultDialogs = brackets.getModule("widgets/DefaultDialogs"),
38+
DragAndDrop = brackets.getModule("utils/DragAndDrop"),
3939
Strings = brackets.getModule("strings"),
4040
PreferencesManager = brackets.getModule("preferences/PreferencesManager"),
4141
LocalizationUtils = brackets.getModule("utils/LocalizationUtils"),
@@ -53,7 +53,8 @@ define(function (require, exports, module) {
5353

5454
const KeyboardPrefs = JSON.parse(require("text!keyboard.json"));
5555

56-
const DIAGNOSTICS_SUBMENU = "debug-diagnostics-sub-menu";
56+
const DIAGNOSTICS_SUBMENU = "debug-diagnostics-sub-menu",
57+
EXPERIMENTAL_FEATURES_SUB_MENU = "debug-experimental-features";
5758

5859
// default preferences file name
5960
const DEFAULT_PREFERENCES_FILENAME = "defaultPreferences.json",
@@ -81,7 +82,8 @@ define(function (require, exports, module) {
8182
DEBUG_OPEN_VFS = "debug.openVFS",
8283
DEBUG_OPEN_EXTENSION_FOLDER = "debug.openExtensionFolders",
8384
DEBUG_OPEN_VIRTUAL_SERVER = "debug.openVirtualServer",
84-
DEBUG_OPEN_PREFERENCES_IN_SPLIT_VIEW = "debug.openPrefsInSplitView";
85+
DEBUG_OPEN_PREFERENCES_IN_SPLIT_VIEW = "debug.openPrefsInSplitView",
86+
DEBUG_DRAG_AND_DROP = "debug.dragAndDrop";
8587

8688
const LOG_TO_CONSOLE_KEY = logger.loggingOptions.LOCAL_STORAGE_KEYS.LOG_TO_CONSOLE_KEY,
8789
LOG_LIVE_PREVIEW_KEY = logger.loggingOptions.LOCAL_STORAGE_KEYS.LOG_LIVE_PREVIEW;
@@ -824,6 +826,19 @@ define(function (require, exports, module) {
824826
hideWhenCommandDisabled: true
825827
});
826828

829+
if(Phoenix.isNativeApp && Phoenix.platform === "linux") {
830+
// there is only one experimental feature- drag and drop available in native linux apps only.
831+
const experimentalSubmenu = debugMenu.addSubMenu(Strings.CMD_EXPERIMENTAL_FEATURES, EXPERIMENTAL_FEATURES_SUB_MENU);
832+
CommandManager.register(Strings.CMD_ENABLE_DRAG_AND_DROP, DEBUG_DRAG_AND_DROP, ()=>{
833+
PreferencesManager.set(DragAndDrop._PREF_DRAG_AND_DROP,
834+
!PreferencesManager.get(DragAndDrop._PREF_DRAG_AND_DROP));
835+
});
836+
PreferencesManager.on("change", DragAndDrop._PREF_DRAG_AND_DROP, function () {
837+
CommandManager.get(DEBUG_DRAG_AND_DROP).setChecked(PreferencesManager.get(DragAndDrop._PREF_DRAG_AND_DROP));
838+
});
839+
experimentalSubmenu.addMenuItem(DEBUG_DRAG_AND_DROP);
840+
}
841+
827842
CommandManager.get(DEBUG_UNLOAD_CURRENT_EXTENSION)
828843
.setEnabled(extensionDevelopment.isProjectLoadedAsExtension());
829844
CommandManager.get(DEBUG_OPEN_EXTENSION_FOLDER)

src/nls/root/strings.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,8 @@ define({
579579
// Debug menu commands
580580
"CMD_OPEN_VFS": "Open Virtual File System",
581581
"CMD_DIAGNOSTIC_TOOLS": "{APP_NAME} Diagnostic Tools",
582+
"CMD_EXPERIMENTAL_FEATURES": "Experimental Features",
583+
"CMD_ENABLE_DRAG_AND_DROP": "Drag And Drop Files",
582584
"CMD_OPEN_EXTENSIONS_FOLDER": "Open Extensions Folder\u2026",
583585
"CMD_OPEN_VIRTUAL_SERVER": "Open Virtual Server",
584586

@@ -1001,6 +1003,7 @@ define({
10011003
"DESCRIPTION_RULERS_COLUMNS": "An array of column numbers to draw vertical rulers in the editor. Eg: [80, 100]",
10021004
"DESCRIPTION_RULERS_COLORS": "An array of ruler colors corresponding to the rulers option in the editor. Eg: [\"#3d3d3d\", \"red\"]",
10031005
"DESCRIPTION_RULERS_ENABLED": "true to enable editor rulers, else false",
1006+
"DESCRIPTION_DRAG_AND_DROP_ENABLED": "true to enable drag and drop functionality for files and folders from the file explorer or Finder",
10041007
"DESCRIPTION_SMART_INDENT": "Automatically indent when creating a new block",
10051008
"DESCRIPTION_SOFT_TABS": "false to turn off soft tabs behavior",
10061009
"DESCRIPTION_SORT_DIRECTORIES_FIRST": "true to sort the directories first in the project tree",

src/utils/DragAndDrop.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,17 @@ define(function (require, exports, module) {
2929
DefaultDialogs = require("widgets/DefaultDialogs"),
3030
MainViewManager = require("view/MainViewManager"),
3131
FileSystem = require("filesystem/FileSystem"),
32+
PreferencesManager = require("preferences/PreferencesManager"),
3233
FileUtils = require("file/FileUtils"),
3334
ProjectManager = require("project/ProjectManager"),
3435
Strings = require("strings"),
3536
StringUtils = require("utils/StringUtils");
3637

38+
const _PREF_DRAG_AND_DROP = "dragAndDrop"; // used in debug menu
39+
PreferencesManager.definePreference(_PREF_DRAG_AND_DROP, "boolean",
40+
Phoenix.isNativeApp && Phoenix.platform !== "linux", {description: Strings.DESCRIPTION_DRAG_AND_DROP_ENABLED}
41+
);
42+
3743
/**
3844
* Returns true if the drag and drop items contains valid drop objects.
3945
* @param {Array.<DataTransferItem>} items Array of items being dragged
@@ -265,7 +271,7 @@ define(function (require, exports, module) {
265271
var files = event.dataTransfer.files;
266272

267273
stopURIListPropagation(files, event);
268-
if(Phoenix.isNativeApp && Phoenix.platform !== "linux" &&
274+
if(PreferencesManager.get(_PREF_DRAG_AND_DROP) &&
269275
event.dataTransfer.types && event.dataTransfer.types.includes("Files")){
270276
// in linux, there is a bug in ubuntu 24 where dropping a file will cause a ghost icon which only
271277
// goes away on reboot. So we dont support drop files in linux for now.
@@ -333,4 +339,7 @@ define(function (require, exports, module) {
333339
exports.attachHandlers = attachHandlers;
334340
exports.isValidDrop = isValidDrop;
335341
exports.openDroppedFiles = openDroppedFiles;
342+
343+
// private exports
344+
exports._PREF_DRAG_AND_DROP = _PREF_DRAG_AND_DROP;
336345
});

0 commit comments

Comments
 (0)