Bug 1645887 - Fix text copied by 'Copy to clipboard' and 'Copy source text' context menu items r=davidwalsh

This patch addresses the issue reported by [[ https://bugzilla.mozilla.org/show_bug.cgi?id=1645887 | Bug 1645887 ]] where the context menu items in the `Editor` were not copying the expected text to the clipboard.

Regarding the context menu in the `Editor` this patch modifies the menu items so that:

1. 'Copy to clipboard' => Copies the text that has been selected by a user to the clipboard.
2. 'Copy source text' => Copies all of the text from a source to the clipboard.

In addition to the above fix, this patch also modifies a related item in the `Tab` context menu so that:

1. The text for the ‘Copy to clipboard’ menu item is now replaced with ‘Copy source text’.

As with the context menu in the `Editor`, the pre-existing ‘Copy to clipboard’ menu item in the `Tab` copied all of the text from a source to the clipboard. However, instead of modifying the functionality of this menu item, the decision was made to replace the ‘Copy to clipboard’ text with ‘Copy source text’. This was done as the `Tab` and its context menu typically provides the user with general information about the file being displayed instead of being concerned with details such as the state of the editor.

{F2332380}

Differential Revision: https://phabricator.services.mozilla.com/D81887
This commit is contained in:
Kyle Knaggs 2020-07-08 14:40:29 +00:00
Родитель d8e1e4a499
Коммит 967178f81b
4 изменённых файлов: 18 добавлений и 20 удалений

Просмотреть файл

@ -137,7 +137,7 @@ class Tab extends PureComponent<Props> {
{ item: { type: "separator" } },
{
item: {
...tabMenuItems.copyToClipboard,
...tabMenuItems.copySource,
disabled: selectedSource.id !== tab,
click: () => copyToClipboard(sourceTab),
},

Просмотреть файл

@ -28,6 +28,7 @@ import type {
ThreadContext,
} from "../../../types";
// Menu Items
export const continueToHereItem = (
cx: ThreadContext,
location: SourceLocation,
@ -41,31 +42,28 @@ export const continueToHereItem = (
label: L10N.getStr("editor.continueToHere.label"),
});
// menu items
const copyToClipboardItem = (
selectedContent: SourceContent,
selectionText: string,
editorActions: EditorItemActions
) => ({
id: "node-menu-copy-to-clipboard",
label: L10N.getStr("copyToClipboard.label"),
accesskey: L10N.getStr("copyToClipboard.accesskey"),
disabled: false,
click: () =>
selectedContent.type === "text" &&
copyToTheClipboard(selectedContent.value),
disabled: selectionText.length === 0,
click: () => copyToTheClipboard(selectionText),
});
const copySourceItem = (
selectedSource: Source,
selectionText: string,
selectedContent: SourceContent,
editorActions: EditorItemActions
) => ({
id: "node-menu-copy-source",
label: L10N.getStr("copySource.label"),
accesskey: L10N.getStr("copySource.accesskey"),
disabled: selectionText.length === 0,
click: () => copyToTheClipboard(selectionText),
disabled: false,
click: () =>
selectedContent.type === "text" &&
copyToTheClipboard(selectedContent.value),
});
const copySourceUri2Item = (
@ -203,10 +201,10 @@ export function editorMenuItems({
),
continueToHereItem(cx, location, isPaused, editorActions),
{ type: "separator" },
...(content ? [copyToClipboardItem(content, editorActions)] : []),
copyToClipboardItem(selectionText, editorActions),
...(!selectedSource.isWasm
? [
copySourceItem(selectedSource, selectionText, editorActions),
...(content ? [copySourceItem(content, editorActions)] : []),
copySourceUri2Item(selectedSource, editorActions),
]
: []),

Просмотреть файл

@ -78,10 +78,10 @@ export function getTabMenuItems(): Object {
accesskey: L10N.getStr("sourceTabs.revealInTree.accesskey"),
disabled: false,
},
copyToClipboard: {
id: "node-menu-copy-to-clipboard",
label: L10N.getStr("copyToClipboard.label"),
accesskey: L10N.getStr("copyToClipboard.accesskey"),
copySource: {
id: "node-menu-copy-source",
label: L10N.getStr("copySource.label"),
accesskey: L10N.getStr("copySource.accesskey"),
disabled: false,
},
copySourceUri2: {

Просмотреть файл

@ -19,12 +19,12 @@ collapseSources=Collapse Sources and Outline panes
collapseBreakpoints=Collapse Breakpoints pane
# LOCALIZATION NOTE (copyToClipboard.label): This is the text that appears in the
# context menu to copy the complete source of the open file.
# context menu to copy the text that the user selected.
copyToClipboard.label=Copy to clipboard
copyToClipboard.accesskey=C
# LOCALIZATION NOTE (copySource.label): This is the text that appears in the
# context menu to copy the selected source of file open.
# context menu to copy all of the text in the open file.
copySource.label=Copy source text
copySource.accesskey=y