Added a "copy current url" shortcut

This commit is contained in:
mr. M
2024-12-19 18:14:32 +01:00
parent 108e4a603e
commit 1f99e2547a
4 changed files with 43 additions and 3 deletions

2
l10n

Submodule l10n updated: f0ed268683...d5d4b0f128

View File

@@ -53,3 +53,27 @@ class ZenPreloadedFeature {
document.addEventListener('MozBeforeInitialXULLayout', initBound, { once: true });
}
}
var gZenCommonActions = {
copyCurrentURLToClipboard() {
const currentUrl = gBrowser.currentURI.spec;
if (currentUrl) {
let str = Cc["@mozilla.org/supports-string;1"].createInstance(
Ci.nsISupportsString
);
str.data = currentUrl;
let transferable = Cc[
"@mozilla.org/widget/transferable;1"
].createInstance(Ci.nsITransferable);
transferable.init(getLoadContext());
transferable.addDataFlavor("text/plain");
transferable.setTransferData("text/plain", str);
Services.clipboard.setData(
transferable,
null,
Ci.nsIClipboard.kGlobalClipboard
);
ConfirmationHint.show(document.getElementById("PanelUI-menu-button"), "zen-copy-current-url-confirmation");
}
}
};

View File

@@ -152,7 +152,7 @@ var gZenCompactModeManager = {
}
window.requestAnimationFrame(() => {
this.sidebar.style.transition = "margin .3s ease, transform .3s ease, opacity .3s ease";
this.sidebar.style.transition = "margin .3s ease, transform .275s ease, opacity .3s ease";
// we are in compact mode and we are exiting it
if (!this.sidebarIsOnRight) {
this.sidebar.style.marginLeft = "0";

View File

@@ -66,6 +66,7 @@ const defaultKeyboardGroups = {
'zen-search-find-again-shortcut-prev',
],
pageOperations: [
'zen-text-action-copy-url-shortcut',
'zen-location-open-shortcut',
'zen-location-open-shortcut-alt',
'zen-save-page-shortcut',
@@ -702,7 +703,7 @@ function zenGetDefaultShortcuts() {
}
class ZenKeyboardShortcutsVersioner {
static LATEST_KBS_VERSION = 5;
static LATEST_KBS_VERSION = 6;
constructor() {}
@@ -822,6 +823,21 @@ class ZenKeyboardShortcutsVersioner {
)
);
}
if (version < 6) {
// Migrate from 5 to 6
// In this new version, we add the "Copy URL" shortcut to the default shortcuts
data.push(
new KeyShortcut(
'zen-copy-url',
'C',
'',
ZEN_OTHER_SHORTCUTS_GROUP,
KeyShortcutModifiers.fromObject({ accel: true, shift: true }),
'code:gZenCommonActions.copyCurrentURLToClipboard()',
'zen-text-action-copy-url-shortcut'
)
);
}
return data;
}
}