mirror of
https://github.com/zen-browser/desktop.git
synced 2025-10-08 19:06:38 +00:00
Add feature: copy current URL as markdown
This commit is contained in:
2
l10n
2
l10n
Submodule l10n updated: cb32b48cb5...98c54b87df
@@ -72,6 +72,21 @@ var gZenCommonActions = {
|
||||
ConfirmationHint.show(document.getElementById('PanelUI-menu-button'), 'zen-copy-current-url-confirmation');
|
||||
}
|
||||
},
|
||||
CopyCurrentURLAsMarkdownToClipboard() {
|
||||
const currentUrl = gBrowser.currentURI.spec;
|
||||
const tabTitle = gBrowser.selectedTab.label;
|
||||
if (currentUrl && tabTitle) {
|
||||
const markdownLink = `[${tabTitle}](${currentUrl})`
|
||||
let str = Cc['@mozilla.org/supports-string;1'].createInstance(Ci.nsISupportsString);
|
||||
str.data = markdownLink;
|
||||
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');
|
||||
}
|
||||
},
|
||||
|
||||
throttle(f, delay) {
|
||||
let timer = 0;
|
||||
|
@@ -80,6 +80,7 @@ const defaultKeyboardGroups = {
|
||||
'zen-search-find-again-shortcut-prev',
|
||||
],
|
||||
pageOperations: [
|
||||
'zen-text-action-copy-url-markdown-shortcut',
|
||||
'zen-text-action-copy-url-shortcut',
|
||||
'zen-location-open-shortcut',
|
||||
'zen-location-open-shortcut-alt',
|
||||
@@ -755,7 +756,7 @@ class ZenKeyboardShortcutsLoader {
|
||||
}
|
||||
|
||||
class ZenKeyboardShortcutsVersioner {
|
||||
static LATEST_KBS_VERSION = 7;
|
||||
static LATEST_KBS_VERSION = 8;
|
||||
|
||||
constructor() {}
|
||||
|
||||
@@ -907,6 +908,21 @@ class ZenKeyboardShortcutsVersioner {
|
||||
gZenKeyboardShortcutsManager._hasToLoadDefaultDevtools = true;
|
||||
window.addEventListener('zen-devtools-keyset-added', listener);
|
||||
}
|
||||
if (version < 8) {
|
||||
// Migrate from 7 to 8
|
||||
// In this new version, we add the "Copy URL as Markdown" shortcut to the default shortcuts
|
||||
data.push(
|
||||
new KeyShortcut(
|
||||
'zen-copy-url-markdown',
|
||||
'C',
|
||||
'',
|
||||
ZEN_OTHER_SHORTCUTS_GROUP,
|
||||
KeyShortcutModifiers.fromObject({ accel: true, shift: true, alt: true }),
|
||||
'code:gZenCommonActions.CopyCurrentURLAsMarkdownToClipboard()',
|
||||
'zen-text-action-copy-url-markdown-shortcut'
|
||||
)
|
||||
)
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user