restrict screenshot to main workspace
Some checks failed
CodeQL / Analyze (javascript) (push) Has been cancelled

This commit is contained in:
zsviczian
2025-04-28 07:33:53 +02:00
parent 05b72f9f07
commit aa4fbe1f6c
3 changed files with 14 additions and 3 deletions

View File

@@ -1101,6 +1101,7 @@ FILENAME_HEAD: "Filename",
EXPORTDIALOG_PDF_PROGRESS_ERROR: "Error exporting PDF, check developer console for details",
// Screenshot tab
EXPORTDIALOG_NOT_AVAILALBE: "Sorry, this feature is only available when the drawing is open in the main Obsidian workspace.",
EXPORTDIALOG_TAB_SCREENSHOT: "Screenshot",
EXPORTDIALOG_SCREENSHOT_DESC: "Screenshots will include embeddables such as markdown pages, YouTube, websites, etc. They are only available on desktop, cannot be automatically exported, and only support PNG format.",
SCREENSHOT_DESKTOP_ONLY: "Screenshot feature is only available on desktop",

View File

@@ -195,8 +195,10 @@ export class ExportDialog extends Modal {
this.createPDFButton();
break;
case "screenshot":
this.createImageSettings(true);
this.createImageButtons(true);
if(this.view.isInMainObsidianWorkspace) {
this.createImageSettings(true);
this.createImageButtons(true);
}
break;
case "image":
default:
@@ -221,7 +223,11 @@ export class ExportDialog extends Modal {
break;
case "screenshot":
this.contentContainer.createEl("h1",{text: t("EXPORTDIALOG_TAB_SCREENSHOT")});
this.contentContainer.createEl("p",{text: t("EXPORTDIALOG_SCREENSHOT_DESC")})
if(this.view.isInMainObsidianWorkspace) {
this.contentContainer.createEl("p",{text: t("EXPORTDIALOG_SCREENSHOT_DESC")})
} else {
this.contentContainer.createEl("p",{text: t("EXPORTDIALOG_NOT_AVAILALBE")})
}
break;
case "image":
default:

View File

@@ -390,6 +390,10 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
return this.ownerDocument.defaultView;
}
get isInMainObsidianWorkspace(): boolean {
return document === this.ownerDocument;
}
setHookServer(ea?:ExcalidrawAutomate) {
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.setHookServer, "ExcalidrawView.setHookServer", ea);
if(ea) {