ExtensionUtils
Import :
const ExtensionUtils = brackets.getModule("utils/ExtensionUtils")
FileSystem
ExtensionUtils defines utility methods for implementing extensions.
Kind: global constant
addEmbeddedStyleSheet(css) ⇒ HTMLStyleElement
Appends a "style" tag to the document's head.
Kind: global function
Returns: HTMLStyleElement
- The generated HTML node
Param | Type | Description |
---|---|---|
css | string | CSS code to use as the tag's content |
addLinkedStyleSheet(url, [deferred]) ⇒ HTMLLinkElement
Appends a "link" tag to the document's head.
Kind: global function
Returns: HTMLLinkElement
- The generated HTML node
Param | Type | Description |
---|---|---|
url | string | URL to a style sheet |
[deferred] | $.Deferred | Optionally check for load and error events |
parseLessCode(code, url) ⇒ $.Promise
Parses LESS code and returns a promise that resolves with plain CSS code.
Pass the link url argument to resolve relative URLs contained in the code. Make sure URLs in the code are wrapped in quotes, like so: background-image: url("image.png");
Kind: global function
Returns: $.Promise
- A promise object that is resolved with CSS code if the LESS code can be parsed
Param | Type | Description |
---|---|---|
code | string | LESS code to parse |
url | string | URL to the file containing the code |
getModulePath(module, path) ⇒ string
Returns a path to an extension module.
Kind: global function
Returns: string
- The path to the module's folder
Param | Type | Description |
---|---|---|
module | module | Module provided by RequireJS |
path | string | Relative path from the extension folder to a file |
getModuleUrl(module, path) ⇒ string
Returns a URL to an extension module.
Kind: global function
Returns: string
- The URL to the module's folder
Param | Type | Description |
---|---|---|
module | module | Module provided by RequireJS |
path | string | Relative path from the extension folder to a file |
loadFile(module, path) ⇒ $.Promise
Performs a GET request using a path relative to an extension module.
The resulting URL can be retrieved in the resolve callback by accessing
Kind: global function
Returns: $.Promise
- A promise object that is resolved with the contents of the requested file
Param | Type | Description |
---|---|---|
module | module | Module provided by RequireJS |
path | string | Relative path from the extension folder to a file |
loadStyleSheet(module, path) ⇒ $.Promise
Loads a style sheet (CSS or LESS) relative to the extension module.
Kind: global function
Returns: $.Promise
- A promise object that is resolved with an HTML node if the file can be loaded.
Param | Type | Description |
---|---|---|
module | module | Module provided by RequireJS |
path | string | Relative path from the extension folder to a CSS or LESS file |
loadMetadata(metadataURL, extensionName) ⇒ $.Promise
Loads the package.json file in the given extension folder as well as any additional metadata for default extensions in the source directory.
If there's a .disabled file in the extension directory, then the content of package.json will be augmented with disabled property set to true. It will override whatever value of disabled might be set.
Kind: global function
Returns: $.Promise
- A promise object that is resolved with the parsed contents of the package.json file,
or rejected if there is no package.json with the boolean indicating whether .disabled file exists.
Param | Type | Description |
---|---|---|
metadataURL | string | The extension folder/base url for default extensions. |
extensionName | string | name of the extension |