Skip to content

Commit

Permalink
refactor: move noDistractions default extensions to integrated extension
Browse files Browse the repository at this point in the history
  • Loading branch information
abose committed Dec 13, 2023
1 parent 272f554 commit bfdc18b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 37 deletions.
2 changes: 0 additions & 2 deletions src/extensions/default/DefaultExtensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"LightTheme",
"CloseOthers",
"CodeFolding",
"NoDistractions",
"CSSAtRuleCodeHints",
"CSSCodeHints",
"CSSPseudoSelectorHints",
Expand All @@ -20,7 +19,6 @@
"JSHint",
"MDNDocs",
"NavigationAndHistory",
"NoDistractions",
"Phoenix",
"Phoenix-prettier",
"PrefsCodeHints",
Expand Down
6 changes: 0 additions & 6 deletions src/extensions/default/NoDistractions/package.json

This file was deleted.

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,33 @@
define(function (require, exports, module) {


var Menus = brackets.getModule("command/Menus"),
CommandManager = brackets.getModule("command/CommandManager"),
Commands = brackets.getModule("command/Commands"),
Strings = brackets.getModule("strings"),
PreferencesManager = brackets.getModule("preferences/PreferencesManager"),
ViewUtils = brackets.getModule("utils/ViewUtils"),
KeyBindingManager = brackets.getModule("command/KeyBindingManager"),
Metrics = brackets.getModule("utils/Metrics"),
WorkspaceManager = brackets.getModule("view/WorkspaceManager");
const AppInit = require("utils/AppInit"),
Menus = require("command/Menus"),
CommandManager = require("command/CommandManager"),
Commands = require("command/Commands"),
Strings = require("strings"),
PreferencesManager = require("preferences/PreferencesManager"),
ViewUtils = require("utils/ViewUtils"),
KeyBindingManager = require("command/KeyBindingManager"),
Metrics = require("utils/Metrics"),
WorkspaceManager = require("view/WorkspaceManager");

// Constants
var PREFS_PURE_CODE = "noDistractions",
const PREFS_PURE_CODE = "noDistractions",
CMD_TOGGLE_PURE_CODE = "view.togglePureCode",
CMD_TOGGLE_FULLSCREEN = "view.toggleFullscreen",
CMD_TOGGLE_PANELS = "view.togglePanels";

//key binding keys
var togglePureCodeKey = "Ctrl-Shift-2",
const togglePureCodeKey = "Ctrl-Shift-2",
togglePureCodeKeyMac = "Cmd-Shift-2",
togglePanelsKey = "Ctrl-Shift-1",
togglePanelsKeyMac = "Cmd-Shift-1",
togglePanelsKey_EN = "Ctrl-Shift-`",
togglePanelsKeyMac_EN = "Cmd-Shift-`";

//locals
var _previouslyOpenPanelIDs = [],
let _previouslyOpenPanelIDs = [],
panelsToggled = false,
layoutUpdated = false;

Expand Down Expand Up @@ -139,25 +140,12 @@ define(function (require, exports, module) {
description: Strings.DESCRIPTION_PURE_CODING_SURFACE
});

PreferencesManager.on("change", PREFS_PURE_CODE, function () {
if (PreferencesManager.get(PREFS_PURE_CODE)) {
ViewUtils.hideMainToolBar();
CommandManager.execute(Commands.HIDE_SIDEBAR);
_hidePanelsIfRequired();
} else {
ViewUtils.showMainToolBar();
CommandManager.execute(Commands.SHOW_SIDEBAR);
_showPanelsIfRequired();
}
_updateCheckedState();
});

WorkspaceManager.on(WorkspaceManager.EVENT_WORKSPACE_PANEL_SHOWN, _updateLayout);

/**
* Register the Commands , add the Menu Items and key bindings
*/
function initializeCommands() {
AppInit.appReady(function () {
CommandManager.register(Strings.CMD_TOGGLE_PURE_CODE, CMD_TOGGLE_PURE_CODE, _togglePureCode);
CommandManager.register(Strings.CMD_TOGGLE_FULLSCREEN, CMD_TOGGLE_FULLSCREEN, _toggleFullScreen);
CommandManager.register(Strings.CMD_TOGGLE_PANELS, CMD_TOGGLE_PANELS, _togglePanels);
Expand All @@ -172,8 +160,19 @@ define(function (require, exports, module) {
//from IQE team than non-English keyboards does not have the ` char. So added one more shortcut ctrl+shift+1 which will be preferred
KeyBindingManager.addBinding(CMD_TOGGLE_PANELS, [ {key: togglePanelsKey}, {key: togglePanelsKeyMac, platform: "mac"} ]);
KeyBindingManager.addBinding(CMD_TOGGLE_PANELS, [ {key: togglePanelsKey_EN}, {key: togglePanelsKeyMac_EN, platform: "mac"} ]);
}

initializeCommands();
PreferencesManager.on("change", PREFS_PURE_CODE, function () {
if (PreferencesManager.get(PREFS_PURE_CODE)) {
ViewUtils.hideMainToolBar();
CommandManager.execute(Commands.HIDE_SIDEBAR);
_hidePanelsIfRequired();
} else {
ViewUtils.showMainToolBar();
CommandManager.execute(Commands.SHOW_SIDEBAR);
_showPanelsIfRequired();
}
_updateCheckedState();
});
});

});
1 change: 1 addition & 0 deletions src/extensionsIntegrated/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@
*/
define(function (require, exports, module) {
require("./InAppNotifications/main");
require("./NoDistractions/main");
});

0 comments on commit bfdc18b

Please sign in to comment.