diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/styleeditor/styleeditor-commands.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/styleeditor/styleeditor-commands.js')
-rw-r--r-- | devtools/client/styleeditor/styleeditor-commands.js | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/devtools/client/styleeditor/styleeditor-commands.js b/devtools/client/styleeditor/styleeditor-commands.js new file mode 100644 index 000000000..ded63e499 --- /dev/null +++ b/devtools/client/styleeditor/styleeditor-commands.js @@ -0,0 +1,72 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* globals gDevTools */ + +"use strict"; + +const l10n = require("gcli/l10n"); +loader.lazyRequireGetter(this, "gDevTools", + "devtools/client/framework/devtools", true); + +/** + * The `edit` command opens the toolbox to the style editor, with a given + * stylesheet open. + * + * This command is tricky. The 'edit' command uses the toolbox, so it's + * clearly runAt:client, but it uses the 'resource' type which accesses the + * DOM, so it must also be runAt:server. + * + * Our solution is to have the command technically be runAt:server, but to not + * actually do anything other than basically `return args;`, and have the + * converter (all converters are runAt:client) do the actual work of opening + * a toolbox. + * + * For alternative solutions that we considered, see the comment on commit + * 2645af7. + */ +exports.items = [{ + item: "command", + runAt: "server", + name: "edit", + description: l10n.lookup("editDesc"), + manual: l10n.lookup("editManual2"), + params: [ + { + name: "resource", + type: { + name: "resource", + include: "text/css" + }, + description: l10n.lookup("editResourceDesc") + }, + { + name: "line", + defaultValue: 1, + type: { + name: "number", + min: 1, + step: 10 + }, + description: l10n.lookup("editLineToJumpToDesc") + } + ], + returnType: "editArgs", + exec: args => { + return { href: args.resource.name, line: args.line }; + } +}, { + item: "converter", + from: "editArgs", + to: "dom", + exec: function (args, context) { + let target = context.environment.target; + let toolboxOpened = gDevTools.showToolbox(target, "styleeditor"); + return toolboxOpened.then(function (toolbox) { + let styleEditor = toolbox.getCurrentPanel(); + styleEditor.selectStyleSheet(args.href, args.line); + return null; + }); + } +}]; |