From bfdc18b9560f624c57592c06d258196d551a7e9f Mon Sep 17 00:00:00 2001 From: abose Date: Wed, 13 Dec 2023 00:02:34 +0530 Subject: [PATCH] refactor: move noDistractions default extensions to integrated extension --- src/extensions/default/DefaultExtensions.json | 2 - .../default/NoDistractions/package.json | 6 -- .../NoDistractions/requirejs-config.json | 1 - .../default/NoDistractions/unittests.js | 0 .../NoDistractions/main.js | 55 +++++++++---------- src/extensionsIntegrated/loader.js | 1 + 6 files changed, 28 insertions(+), 37 deletions(-) delete mode 100644 src/extensions/default/NoDistractions/package.json delete mode 100644 src/extensions/default/NoDistractions/requirejs-config.json delete mode 100644 src/extensions/default/NoDistractions/unittests.js rename src/{extensions/default => extensionsIntegrated}/NoDistractions/main.js (82%) diff --git a/src/extensions/default/DefaultExtensions.json b/src/extensions/default/DefaultExtensions.json index a42c947224..0ab717d052 100644 --- a/src/extensions/default/DefaultExtensions.json +++ b/src/extensions/default/DefaultExtensions.json @@ -4,7 +4,6 @@ "LightTheme", "CloseOthers", "CodeFolding", - "NoDistractions", "CSSAtRuleCodeHints", "CSSCodeHints", "CSSPseudoSelectorHints", @@ -20,7 +19,6 @@ "JSHint", "MDNDocs", "NavigationAndHistory", - "NoDistractions", "Phoenix", "Phoenix-prettier", "PrefsCodeHints", diff --git a/src/extensions/default/NoDistractions/package.json b/src/extensions/default/NoDistractions/package.json deleted file mode 100644 index 6a2d99c741..0000000000 --- a/src/extensions/default/NoDistractions/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "NoDistractions", - "version": "1.0.0", - "dependencies": { - } -} diff --git a/src/extensions/default/NoDistractions/requirejs-config.json b/src/extensions/default/NoDistractions/requirejs-config.json deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/src/extensions/default/NoDistractions/requirejs-config.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/src/extensions/default/NoDistractions/unittests.js b/src/extensions/default/NoDistractions/unittests.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/extensions/default/NoDistractions/main.js b/src/extensionsIntegrated/NoDistractions/main.js similarity index 82% rename from src/extensions/default/NoDistractions/main.js rename to src/extensionsIntegrated/NoDistractions/main.js index 9b48b35163..8872e615f1 100644 --- a/src/extensions/default/NoDistractions/main.js +++ b/src/extensionsIntegrated/NoDistractions/main.js @@ -24,24 +24,25 @@ 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", @@ -49,7 +50,7 @@ define(function (require, exports, module) { togglePanelsKeyMac_EN = "Cmd-Shift-`"; //locals - var _previouslyOpenPanelIDs = [], + let _previouslyOpenPanelIDs = [], panelsToggled = false, layoutUpdated = false; @@ -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); @@ -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(); + }); + }); }); diff --git a/src/extensionsIntegrated/loader.js b/src/extensionsIntegrated/loader.js index b52dc5fea8..cb007a594e 100644 --- a/src/extensionsIntegrated/loader.js +++ b/src/extensionsIntegrated/loader.js @@ -32,4 +32,5 @@ */ define(function (require, exports, module) { require("./InAppNotifications/main"); + require("./NoDistractions/main"); });