Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit 422ff9a

Browse files
zeojasonLaster
authored andcommitted
Enhancement add contenxt menu copy to clipboard (#5704)
* Add copy to clipboard item to context menus(Source Editor Context Menu, Tab Contenxt Menu) * Change context menu label to 'Copy to clipboard'. Avoid unnecessary call to getRawSourceURL. * Change "copyToClipboard" to "copyToClipboard.label" in debugger.properties. * Change in Localization note for copyToClipboard.label
1 parent e5e324a commit 422ff9a

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

assets/panel/debugger.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
# that collapses the left and right panes in the debugger UI.
1515
collapsePanes=Collapse panes
1616

17+
# LOCALIZATION NOTE (copyToClipboard.label): This is the text that appears in the
18+
# context menu to copy the complete source of the open file.
19+
copyToClipboard.label=Copy to clipboard
20+
copyToClipboard.accesskey=C
21+
1722
# LOCALIZATION NOTE (copySource): This is the text that appears in the
1823
# context menu to copy the selected source of file open.
1924
copySource=Copy

src/components/Editor/EditorMenu.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ function getMenuItems(
7777
const copyFunctionLabel = L10N.getStr("copyFunction.label");
7878
const copySourceKey = L10N.getStr("copySource.accesskey");
7979
const copySourceLabel = L10N.getStr("copySource");
80+
const copyToClipboardKey = L10N.getStr("copyToClipboard.accesskey");
81+
const copyToClipboardLabel = L10N.getStr("copyToClipboard.label");
8082
const copySourceUri2Key = L10N.getStr("copySourceUri2.accesskey");
8183
const copySourceUri2Label = L10N.getStr("copySourceUri2");
8284
const evaluateInConsoleLabel = L10N.getStr("evaluateInConsole.label");
@@ -93,6 +95,15 @@ function getMenuItems(
9395
const watchExpressionLabel = L10N.getStr("expressions.label");
9496

9597
// menu items
98+
99+
const copyToClipboardItem = {
100+
id: "node-menu-copy-to-clipboard",
101+
label: copyToClipboardLabel,
102+
accesskey: copyToClipboardKey,
103+
disabled: false,
104+
click: () => copyToTheClipboard(selectedSource.get("text"))
105+
};
106+
96107
const copySourceItem = {
97108
id: "node-menu-copy-source",
98109
label: copySourceLabel,
@@ -168,6 +179,7 @@ function getMenuItems(
168179

169180
// construct menu
170181
const menuItems = [
182+
copyToClipboardItem,
171183
copySourceItem,
172184
copySourceUri2Item,
173185
copyFunctionItem,

src/components/Editor/Tab.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ class Tab extends PureComponent<Props> {
6363
closeTabs,
6464
tabSources,
6565
showSource,
66-
togglePrettyPrint
66+
togglePrettyPrint,
67+
selectedSource
6768
} = this.props;
6869

6970
const otherTabs = tabSources.filter(t => t.get("id") !== tab);
@@ -107,6 +108,13 @@ class Tab extends PureComponent<Props> {
107108
item: { ...tabMenuItems.closeAllTabs, click: () => closeTabs(tabURLs) }
108109
},
109110
{ item: { type: "separator" } },
111+
{
112+
item: {
113+
...tabMenuItems.copyToClipboard,
114+
disabled: selectedSource.get("id") !== tab,
115+
click: () => copyToTheClipboard(sourceTab.get("text"))
116+
}
117+
},
110118
{
111119
item: {
112120
...tabMenuItems.copySourceUri2,

src/utils/tabs.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ export function getTabMenuItems() {
9898
accesskey: L10N.getStr("sourceTabs.revealInTree.accesskey"),
9999
disabled: false
100100
},
101+
copyToClipboard: {
102+
id: "node-menu-copy-to-clipboard",
103+
label: L10N.getStr("copyToClipboard.label"),
104+
accesskey: L10N.getStr("copyToClipboard.accesskey"),
105+
disabled: false
106+
},
101107
copySourceUri2: {
102108
id: "node-menu-copy-source-url",
103109
label: L10N.getStr("copySourceUri2"),

0 commit comments

Comments
 (0)