removed copy all in split view feature.

it needs more work
This commit is contained in:
EmilyxFox
2025-02-03 22:05:47 +01:00
parent ffbe58b808
commit 7758b14f26
2 changed files with 15 additions and 48 deletions

View File

@@ -60,23 +60,10 @@ class ZenPreloadedFeature {
var gZenCommonActions = {
copyCurrentURLToClipboard() {
let urlStringToCopy = "";
if (Services.prefs.getBoolPref('zen.keyboard.shortcuts.copy-current-url.copy-all-in-split-view', false)) {
const currentTabs = gZenViewSplitter.getTabsInCurrentView();
if (currentTabs) {
const stringArray = currentTabs.map(t => `${t.linkedBrowser.currentURI.spec}`);
urlStringToCopy = stringArray.join("\n");
}
} else {
const currentUrl = gBrowser.currentURI.spec;
if (currentUrl) {
urlStringToCopy = `${currentUrl}`
}
}
if (urlStringToCopy) {
const currentUrl = gBrowser.currentURI.spec;
if (currentUrl) {
let str = Cc['@mozilla.org/supports-string;1'].createInstance(Ci.nsISupportsString);
str.data = urlStringToCopy;
str.data = currentUrl;
let transferable = Cc['@mozilla.org/widget/transferable;1'].createInstance(Ci.nsITransferable);
transferable.init(getLoadContext());
transferable.addDataFlavor('text/plain');
@@ -86,29 +73,18 @@ var gZenCommonActions = {
}
},
CopyCurrentURLAsMarkdownToClipboard() {
let markdownString = "";
if (Services.prefs.getBoolPref('zen.keyboard.shortcuts.copy-current-url-as-markdown.copy-all-in-split-view', false)) {
const currentTabs = gZenViewSplitter.getTabsInCurrentView();
if (currentTabs) {
const stringArray = currentTabs.map(t => `[${t.label}](${t.linkedBrowser.currentURI.spec})`);
markdownString = stringArray.join("\n");
}
} else {
const currentUrl = gBrowser.currentURI.spec;
const tabTitle = gBrowser.selectedTab.label;
if (currentUrl && tabTitle) {
markdownString = `[${tabTitle}](${currentUrl})`;
}
}
if (markdownString) {
let str = Cc['@mozilla.org/supports-string;1'].createInstance(Ci.nsISupportsString);
str.data = markdownString;
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');
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');
}
},

View File

@@ -1136,15 +1136,6 @@ class ZenViewSplitter extends ZenDOMOperatedFeature {
: [gBrowser.selectedTab, tabs[nextTabIndex]];
this.splitTabs(selected_tabs, gridType);
}
/**
* Gets all the tabs in the current view.
* @returns {Tab[]} The tabs in the current view.
*/
getTabsInCurrentView() {
if (this.currentView < 0) return [gBrowser.selectedTab];
return this._data[this.currentView].tabs;
}
}
window.gZenViewSplitter = new ZenViewSplitter();