diff options
author | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-02-02 20:42:28 +0100 |
---|---|---|
committer | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-02-02 20:42:28 +0100 |
commit | f34094bae31e216228d5c2da2f2461d03df38302 (patch) | |
tree | be78d0059fafcf0bfc451b9add9a0dbd175a4a85 /devtools/client/inspector/inspector.js | |
parent | 9627f18cebab38cdfe45592d83371ee7bbc62cfa (diff) | |
download | UXP-f34094bae31e216228d5c2da2f2461d03df38302.tar UXP-f34094bae31e216228d5c2da2f2461d03df38302.tar.gz UXP-f34094bae31e216228d5c2da2f2461d03df38302.tar.lz UXP-f34094bae31e216228d5c2da2f2461d03df38302.tar.xz UXP-f34094bae31e216228d5c2da2f2461d03df38302.zip |
Add a "copy full CSS path" option to the inspector's menu
Issue #3
Diffstat (limited to 'devtools/client/inspector/inspector.js')
-rw-r--r-- | devtools/client/inspector/inspector.js | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/devtools/client/inspector/inspector.js b/devtools/client/inspector/inspector.js index c056c213f..d0458fc1f 100644 --- a/devtools/client/inspector/inspector.js +++ b/devtools/client/inspector/inspector.js @@ -169,6 +169,10 @@ Inspector.prototype = { return this._target.client.traits.getUniqueSelector; }, + get canGetCssPath() { + return this._target.client.traits.getCssPath; + }, + get canGetUsedFontFaces() { return this._target.client.traits.getUsedFontFaces; }, @@ -1074,6 +1078,15 @@ Inspector.prototype = { click: () => this.copyUniqueSelector(), })); copySubmenu.append(new MenuItem({ + id: "node-menu-copycsspath", + label: INSPECTOR_L10N.getStr("inspectorCopyCSSPath.label"), + accesskey: + INSPECTOR_L10N.getStr("inspectorCopyCSSPath.accesskey"), + disabled: !isSelectionElement, + hidden: !this.canGetCssPath, + click: () => this.copyCssPath(), + })); + copySubmenu.append(new MenuItem({ id: "node-menu-copyimagedatauri", label: INSPECTOR_L10N.getStr("inspectorImageDataUri.label"), disabled: !isSelectionElement || !markupContainer || @@ -1677,9 +1690,24 @@ Inspector.prototype = { return; } - this.selection.nodeFront.getUniqueSelector().then((selector) => { + this.telemetry.toolOpened("copyuniquecssselector"); + this.selection.nodeFront.getUniqueSelector().then(selector => { clipboardHelper.copyString(selector); - }).then(null, console.error); + }).catch(e => console.error); + }, + + /** + * Copy the full CSS Path of the selected Node to the clipboard. + */ + copyCssPath: function () { + if (!this.selection.isNode()) { + return; + } + + this.telemetry.toolOpened("copyfullcssselector"); + this.selection.nodeFront.getCssPath().then(path => { + clipboardHelper.copyString(path); + }).catch(e => console.error); }, /** |