Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/API-Reference/command/Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -1053,3 +1053,15 @@ Shows authors of current file
Toggles display of untracked files

**Kind**: global variable
<a name="CMD_GIT_HISTORY_GLOBAL"></a>

## CMD\_GIT\_HISTORY\_GLOBAL
Toggles global history view in history panel

**Kind**: global variable
<a name="CMD_GIT_HISTORY_FILE"></a>

## CMD\_GIT\_HISTORY\_FILE
Toggles file history view in history panel

**Kind**: global variable
5 changes: 4 additions & 1 deletion docs/API-Reference/file/FileUtils.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ file size (in bytes)
**Kind**: global constant
<a name="readAsText"></a>

## readAsText(file, bypassCache) ⇒ <code>$.Promise</code>
## readAsText(file, bypassCache, [options]) ⇒ <code>$.Promise</code>
Asynchronously reads a file as UTF-8 encoded text.

**Kind**: global function
Expand All @@ -38,6 +38,9 @@ Asynchronously reads a file as UTF-8 encoded text.
| --- | --- | --- |
| file | <code>File</code> | File to read |
| bypassCache | <code>boolean</code> | an optional argument, if specified will read from disc instead of using cache. |
| [options] | <code>object</code> | |
| [options.ignoreFileSizeLimits] | <code>boolean</code> | Will read larger files than 16MB limit. will bypassCache + won't cache if enabled. |
| [options.doNotCache] | <code>boolean</code> | will not cache if enabled. Auto-enabled if ignoreFileSizeLimits = true |

<a name="writeText"></a>

Expand Down
16 changes: 12 additions & 4 deletions docs/API-Reference/filesystem/File.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ const File = brackets.getModule("filesystem/File")

* [File](#File)
* [new File(fullPath, fileSystem)](#new_File_new)
* [.read([options], callback)](#File+read)
* [.read(options, callback)](#File+read)
* [.write(data, [options], [callback])](#File+write)

<a name="new_File_new"></a>

### new File(fullPath, fileSystem)
Model for a File.This class should *not* be instantiated directly. Use FileSystem.getFileForPath,FileSystem.resolve, or Directory.getContents to create an instance of this class.See the FileSystem class for more details.
Model for a File.

This class should *not* be instantiated directly. Use FileSystem.getFileForPath,
FileSystem.resolve, or Directory.getContents to create an instance of this class.

See the FileSystem class for more details.


| Param | Type | Description |
Expand All @@ -26,14 +31,17 @@ Model for a File. This class should *not* be instantiated directly. Use FileSys

<a name="File+read"></a>

### file.read([options], callback)
### file.read(options, callback)
Read a file.

**Kind**: instance method of [<code>File</code>](#File)

| Param | Type | Description |
| --- | --- | --- |
| [options] | <code>Object</code> | properties \{encoding: 'one of format supported here: https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder/encoding'} |
| options | <code>Object</code> | |
| [options.encoding] | <code>string</code> | 'one of format supported here: https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder/encoding' |
| [options.ignoreFileSizeLimits] | <code>boolean</code> | by default max file size that can be read is 16MB. |
| [options.doNotCache] | <code>boolean</code> | will not cache if enabled. Auto-enabled if ignoreFileSizeLimits = true |
| callback | <code>function</code> | Callback that is passed the FileSystemError string or the file's contents and its stats. |

<a name="File+write"></a>
Expand Down
1 change: 0 additions & 1 deletion src/brackets.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ define(function (require, exports, module) {
// load modules for later use
require("utils/Global");
require("editor/CSSInlineEditor");
require("preferences/AllPreferences");
require("project/WorkingSetSort");
require("search/QuickOpen");
require("search/QuickOpenHelper");
Expand Down
3 changes: 2 additions & 1 deletion src/command/Commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ define(function (require, exports, module) {
/** Toggles code beautification on save */
exports.EDIT_BEAUTIFY_CODE_ON_SAVE = "edit.beautifyOnSave"; // CodeHintManager.js _startNewSession()

exports.EDIT_EMMET = "edit.emmet"; // HTMLCodeHints CSSCodeHints

/** Opens find dialog */
exports.CMD_FIND = "cmd.find"; // FindReplace.js _launchFind()

Expand Down Expand Up @@ -580,4 +582,3 @@ define(function (require, exports, module) {
DeprecationWarning.deprecateConstant(exports, "SORT_WORKINGSET_BY_TYPE", "CMD_WORKINGSET_SORT_BY_TYPE");
DeprecationWarning.deprecateConstant(exports, "SORT_WORKINGSET_AUTO", "CMD_WORKING_SORT_TOGGLE_AUTO");
});

4 changes: 3 additions & 1 deletion src/command/DefaultMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ define(function (require, exports, module) {
menu.addMenuItem(Commands.SHOW_CODE_HINTS);
menu.addMenuDivider();
menu.addMenuItem(Commands.TOGGLE_CLOSE_BRACKETS);
menu.addMenuItem(Commands.EDIT_EMMET);


/*
* Find menu
Expand Down Expand Up @@ -472,4 +474,4 @@ define(function (require, exports, module) {
Menus.getContextMenu(Menus.ContextMenuIds.WORKING_SET_CONTEXT_MENU).on("beforeContextMenuOpen", _setMenuItemsVisible);
Menus.getContextMenu(Menus.ContextMenuIds.PROJECT_MENU).on("beforeContextMenuOpen", _setMenuItemsVisible);
});
});
});
24 changes: 24 additions & 0 deletions src/document/DocumentCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,30 @@ define(function (require, exports, module) {
});
EventDispatcher.makeEventDispatcher(exports);


PreferencesManager.definePreference("emmet", "boolean", true, {
description: Strings.DESCRIPTION_EMMET
});

// Register the Emmet toggle command
const EMMET_COMMAND_ID = "edit.emmet";
const emmetCommand = CommandManager.register(Strings.CMD_TOGGLE_EMMET, EMMET_COMMAND_ID, toggleEmmet);

// Set initial state based on the preference
emmetCommand.setChecked(PreferencesManager.get("emmet"));

// Helper function to toggle the Emmet preference
function toggleEmmet() {
PreferencesManager.set("emmet", !PreferencesManager.get("emmet"));
emmetCommand.setChecked(PreferencesManager.get("emmet"));
}

// Listen for any change in the "emmet" preference and update the menu's toggle state
// this is needed because else the menu is not getting updated when the preference is changed
PreferencesManager.on("change", "emmet", function () {
emmetCommand.setChecked(PreferencesManager.get("emmet"));
});

/**
* Event triggered when File Save is cancelled, when prompted to save dirty files
*/
Expand Down
13 changes: 6 additions & 7 deletions src/extensions/default/CSSCodeHints/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ define(function (require, exports, module) {
KeyEvent = brackets.getModule("utils/KeyEvent"),
LiveDevelopment = brackets.getModule("LiveDevelopment/main"),
Metrics = brackets.getModule("utils/Metrics"),
AllPreferences = brackets.getModule("preferences/AllPreferences"),
CSSProperties = require("text!CSSProperties.json"),
properties = JSON.parse(CSSProperties);

Expand Down Expand Up @@ -74,7 +73,7 @@ define(function (require, exports, module) {
// the Emmet icon serves as a clickable link that redirects to the MDN page for the property (if available).
// This object follows the structure:
// { PROPERTY_NAME: MDN_URL }
const MDN_PROPERTIES_URLS = {};
const mdnPropertiesUrls = {};

PreferencesManager.definePreference("codehint.CssPropHints", "boolean", true, {
description: Strings.DESCRIPTION_CSS_PROP_HINTS
Expand Down Expand Up @@ -477,7 +476,7 @@ define(function (require, exports, module) {
const propertyKey = computedPropertyKeys[resultItem.sourceIndex];
if (properties[propertyKey] && properties[propertyKey].MDN_URL) {
resultItem.MDN_URL = properties[propertyKey].MDN_URL;
MDN_PROPERTIES_URLS[propertyKey] = resultItem.MDN_URL;
mdnPropertiesUrls[propertyKey] = resultItem.MDN_URL;
}
}

Expand Down Expand Up @@ -517,8 +516,8 @@ define(function (require, exports, module) {
let $icon = $(`<a class="emmet-css-code-hint" style="text-decoration: none">Emmet</a>`);

// if MDN_URL is available for the property, add the href attribute to redirect to mdn
if (MDN_PROPERTIES_URLS[expandedAbbr]) {
$icon.attr("href", MDN_PROPERTIES_URLS[expandedAbbr]);
if (mdnPropertiesUrls[expandedAbbr]) {
$icon.attr("href", mdnPropertiesUrls[expandedAbbr]);
$icon.attr("title", Strings.DOCS_MORE_LINK_MDN_TITLE);
}

Expand Down Expand Up @@ -825,15 +824,15 @@ define(function (require, exports, module) {
* Checks for preference changes, to enable/disable Emmet
*/
function preferenceChanged() {
enabled = PreferencesManager.get(AllPreferences.EMMET);
enabled = PreferencesManager.get("emmet");
}


AppInit.appReady(function () {
var cssPropHints = new CssPropHints();
CodeHintManager.registerHintProvider(cssPropHints, ["css", "scss", "less"], 1);

PreferencesManager.on("change", AllPreferences.EMMET, preferenceChanged);
PreferencesManager.on("change", "emmet", preferenceChanged);
preferenceChanged();

// For unit testing
Expand Down
9 changes: 4 additions & 5 deletions src/extensions/default/HTMLCodeHints/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ define(function (require, exports, module) {
CSSUtils = brackets.getModule("language/CSSUtils"),
StringMatch = brackets.getModule("utils/StringMatch"),
LiveDevelopment = brackets.getModule("LiveDevelopment/main"),
AllPreferences = brackets.getModule("preferences/AllPreferences"),
KeyEvent = brackets.getModule("utils/KeyEvent"),
Metrics = brackets.getModule("utils/Metrics"),
HTMLTags = require("text!HtmlTags.json"),
Expand Down Expand Up @@ -468,7 +467,7 @@ define(function (require, exports, module) {
return null;
}

// to show emmet hint when either a single or three exclamation mark(s) is present
// not to show emmet hint when either a single or three exclamation mark(s) is present
if (line.includes('!!') && !line.includes('!!!')) {
return null;
}
Expand Down Expand Up @@ -1205,7 +1204,7 @@ define(function (require, exports, module) {
* Checks for preference changes, to enable/disable Emmet
*/
function preferenceChanged() {
enabled = PreferencesManager.get(AllPreferences.EMMET);
enabled = PreferencesManager.get("emmet");
}


Expand All @@ -1222,11 +1221,11 @@ define(function (require, exports, module) {
CodeHintManager.registerHintProvider(attrHints, ["html"], 0);
NewFileContentManager.registerContentProvider(newDocContentProvider, ["html"], 0);

PreferencesManager.on("change", AllPreferences.EMMET, preferenceChanged);
PreferencesManager.on("change", "emmet", preferenceChanged);
preferenceChanged();

var emmetMarkupHints = new EmmetMarkupHints();
CodeHintManager.registerHintProvider(emmetMarkupHints, ["html", "php", "jsp"], 0);
CodeHintManager.registerHintProvider(emmetMarkupHints, ["html", "php"], 0);

// For unit testing
exports.emmetHintProvider = emmetMarkupHints;
Expand Down
1 change: 1 addition & 0 deletions src/nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ define({
"CMD_BEAUTIFY_CODE": "Beautify Code",
"CMD_BEAUTIFY_CODE_ON_SAVE": "Beautify Code After Save",
"CMD_AUTO_RENAME_TAGS": "Auto Rename HTML Tags",
"CMD_TOGGLE_EMMET": "Emmet",

// Search menu commands
"FIND_MENU": "Find",
Expand Down
50 changes: 0 additions & 50 deletions src/preferences/AllPreferences.js

This file was deleted.

1 change: 0 additions & 1 deletion test/SpecRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ define(function (require, exports, module) {
require("worker/ExtensionsWorker");
require("thirdparty/tinycolor");
require("widgets/NotificationUI");
require("preferences/AllPreferences");

// Load modules that self-register and just need to get included in the test-runner window
require("document/ChangedDocumentTracker");
Expand Down
Loading