mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2026-11-27 06:32:42 +00:00
2.17.0-beta-7, 0.18.0-49
This commit is contained in:
1 parent
c884db0840
commit
b2f051e088
11 files changed
+200
-158
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.17.0-beta-6",
|
||||
"version": "2.17.0-beta-7",
|
||||
"minAppVersion": "1.5.7",
|
||||
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
|
||||
"author": "Zsolt Viczian",
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"@zsviczian/excalidraw": "0.18.0-48",
|
||||
"@zsviczian/excalidraw": "0.18.0-49",
|
||||
"chroma-js": "^3.1.2",
|
||||
"clsx": "^2.0.0",
|
||||
"@zsviczian/colormaster": "^1.2.2",
|
||||
|
||||
@@ -70,6 +70,7 @@ import { carveOutImage, carveOutPDF, createImageCropperFile } from "../../utils/
|
||||
import { showFrameSettings } from "../../shared/Dialogs/FrameSettings";
|
||||
import { insertImageToView } from "../../utils/excalidrawViewUtils";
|
||||
import ExcalidrawPlugin from "src/core/main";
|
||||
import { UIModeSettings } from "src/shared/Dialogs/UIModeSettings";
|
||||
|
||||
declare const PLUGIN_VERSION:string;
|
||||
|
||||
@@ -987,6 +988,7 @@ export class CommandManager {
|
||||
name: t("TOGGLE_LEFTHANDED_MODE"),
|
||||
checkCallback: (checking: boolean) => {
|
||||
if (checking) {
|
||||
if(DEVICE.isMobile) return false;
|
||||
if(this.app.workspace.getActiveViewOfType(ExcalidrawView)) {
|
||||
const view = this.app.workspace.getActiveViewOfType(ExcalidrawView);
|
||||
const api = view?.excalidrawAPI as ExcalidrawImperativeAPI;
|
||||
@@ -1640,7 +1642,7 @@ export class CommandManager {
|
||||
|
||||
this.addCommand({
|
||||
id: "tray-mode",
|
||||
name: t("TRAY_MODE"),
|
||||
name: t("UI_MODE"),
|
||||
checkCallback: (checking: boolean) => {
|
||||
if (checking) {
|
||||
const view = this.app.workspace.getActiveViewOfType(ExcalidrawView);
|
||||
@@ -1655,7 +1657,8 @@ export class CommandManager {
|
||||
}
|
||||
const view = this.app.workspace.getActiveViewOfType(ExcalidrawView);
|
||||
if (view && view.excalidrawAPI) {
|
||||
view.toggleTrayMode();
|
||||
const uiModeSettings = new UIModeSettings(this.plugin);
|
||||
uiModeSettings.open();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
+12
-65
@@ -26,9 +26,6 @@ import { PENS } from "src/utils/pens";
|
||||
import {
|
||||
addYouTubeThumbnail,
|
||||
fragWithHTML,
|
||||
setDesktopUIMode,
|
||||
setLeftHandedMode,
|
||||
setTrayMode,
|
||||
} from "src/utils/utils";
|
||||
import { imageCache } from "src/shared/ImageCache";
|
||||
import { MultiOptionConfirmationPrompt } from "src/shared/Dialogs/Prompt";
|
||||
@@ -47,6 +44,7 @@ import { getExcalidrawViews } from "src/utils/obsidianUtils";
|
||||
import { createSliderWithText } from "src/utils/sliderUtils";
|
||||
import { PDFExportSettingsComponent, PDFExportSettings } from "src/shared/Dialogs/PDFExportSettingsComponent";
|
||||
import { ContentSearcher } from "src/shared/components/ContentSearcher";
|
||||
import { UIMode, UIModeSettingsComponent } from "src/shared/Dialogs/UIModeSettingComponent";
|
||||
|
||||
export interface ExcalidrawSettings {
|
||||
disableDoubleClickTextEditing: boolean;
|
||||
@@ -89,6 +87,8 @@ export interface ExcalidrawSettings {
|
||||
overrideObsidianFontSize: boolean;
|
||||
dynamicStyling: DynamicStyle;
|
||||
isLeftHanded: boolean;
|
||||
desktopUIMode: UIMode;
|
||||
tabletUIMode: UIMode;
|
||||
iframeMatchExcalidrawTheme: boolean;
|
||||
matchTheme: boolean;
|
||||
matchThemeAlways: boolean;
|
||||
@@ -178,9 +178,6 @@ export interface ExcalidrawSettings {
|
||||
}
|
||||
}
|
||||
};
|
||||
defaultTrayMode: boolean;
|
||||
compactModeOnTablets: boolean;
|
||||
compactModeOnDesktops: boolean;
|
||||
previousRelease: string;
|
||||
showReleaseNotes: boolean;
|
||||
compareManifestToPluginVersion: boolean;
|
||||
@@ -282,6 +279,8 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
overrideObsidianFontSize: false,
|
||||
dynamicStyling: "colorful",
|
||||
isLeftHanded: false,
|
||||
desktopUIMode: "tray",
|
||||
tabletUIMode: "compact",
|
||||
iframeMatchExcalidrawTheme: true,
|
||||
matchTheme: false,
|
||||
matchThemeAlways: false,
|
||||
@@ -366,9 +365,6 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
mdBorderColor: "Black",
|
||||
mdCSS: "",
|
||||
scriptEngineSettings: {},
|
||||
defaultTrayMode: true,
|
||||
compactModeOnTablets: true,
|
||||
compactModeOnDesktops: false,
|
||||
previousRelease: "0.0.0",
|
||||
showReleaseNotes: true,
|
||||
compareManifestToPluginVersion: true,
|
||||
@@ -1267,61 +1263,12 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
cls: "excalidraw-setting-h3",
|
||||
});
|
||||
|
||||
new Setting(detailsEl)
|
||||
.setName(t("TRAY_MODE_NAME"))
|
||||
.setDesc(fragWithHTML(t("ARIA_LABEL_TRAY_MODE")))
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.defaultTrayMode)
|
||||
.onChange((value) => {
|
||||
this.plugin.settings.defaultTrayMode = value;
|
||||
setTrayMode(this.app, this.plugin.settings);
|
||||
this.applySettingsUpdate();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(detailsEl)
|
||||
.setName(t("PREFER_COMPACT_MODE_DESKTOP_NAME"))
|
||||
.setDesc(fragWithHTML(t("PREFER_COMPACT_MODE_DESKTOP_DESC")))
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.compactModeOnDesktops)
|
||||
.onChange((value) => {
|
||||
this.plugin.settings.compactModeOnDesktops = value;
|
||||
setDesktopUIMode(this.app, this.plugin.settings);
|
||||
this.applySettingsUpdate();
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(detailsEl)
|
||||
.setName(t("COMPACT_MODE_NAME"))
|
||||
.setDesc(fragWithHTML(t("COMPACT_MODE_DESC")))
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.compactModeOnTablets)
|
||||
.onChange((value) => {
|
||||
this.plugin.settings.compactModeOnTablets = value;
|
||||
setTrayMode(this.app, this.plugin.settings);
|
||||
this.applySettingsUpdate();
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
new Setting(detailsEl)
|
||||
.setName(t("LEFTHANDED_MODE_NAME"))
|
||||
.setDesc(fragWithHTML(t("LEFTHANDED_MODE_DESC")))
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.isLeftHanded)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.isLeftHanded = value;
|
||||
//not clear why I need to do this. If I don't double apply the stylesheet changes
|
||||
//then the style won't be applied in the popout windows
|
||||
setLeftHandedMode(value);
|
||||
setTimeout(()=>setLeftHandedMode(value));
|
||||
this.applySettingsUpdate();
|
||||
}),
|
||||
);
|
||||
new UIModeSettingsComponent(
|
||||
detailsEl,
|
||||
this.plugin.settings,
|
||||
this.app,
|
||||
()=>this.applySettingsUpdate(),
|
||||
).render();
|
||||
addYouTubeThumbnail(detailsEl, "H8Njp7ZXYag",999);
|
||||
|
||||
detailsEl = displayDetailsEl.createEl("details");
|
||||
@@ -2584,7 +2531,7 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
new EmbeddalbeMDFileCustomDataSettingsComponent(
|
||||
detailsEl,
|
||||
this.plugin.settings.embeddableMarkdownDefaults,
|
||||
this.applySettingsUpdate,
|
||||
(val?:boolean) => this.applySettingsUpdate(val),
|
||||
).render();
|
||||
|
||||
detailsEl = embedFilesDetailsEl.createEl("details");
|
||||
|
||||
+11
-5
@@ -98,7 +98,7 @@ export default {
|
||||
RUN_OCR: "OCR full drawing: Grab text from freedraw + images to clipboard and doc.props",
|
||||
RERUN_OCR: "OCR full drawing re-run: Grab text from freedraw + images to clipboard and doc.props",
|
||||
RUN_OCR_ELEMENTS: "OCR selected elements: Grab text from freedraw + images to clipboard",
|
||||
TRAY_MODE: "Toggle property-panel tray-mode",
|
||||
UI_MODE: "Toggle UI-mode",
|
||||
SEARCH: "Search for text in drawing",
|
||||
CROP_PAGE: "Crop and mask selected page",
|
||||
CROP_IMAGE: "Crop and mask image",
|
||||
@@ -137,9 +137,8 @@ export default {
|
||||
"1) Please select your drawing using CTRL/CMD+A and make a copy with CTRL/CMD+C.\n" +
|
||||
"2) Then create an empty drawing in a new pane by CTRL/CMD+clicking the Excalidraw ribbon button,\n" +
|
||||
"3) and paste your work to the new document with CTRL/CMD+V.",
|
||||
ARIA_LABEL_TRAY_MODE: "Tray-mode offers an alternative, more spacious canvas",
|
||||
TRAY_TRAY_MODE: "Toggle tray-mode",
|
||||
TOGGLE_COMPACT_MODE: "Toggle compact-mode",
|
||||
ARIA_LABEL_TRAY_MODE: "You can choose from 3 different desktop and tablet UI modes: Full, Compact, and Tray. On Phones only the Phone mode is available.",
|
||||
TRAY_TRAY_MODE: "Toggle UI-mode",
|
||||
TRAY_SCRIPT_LIBRARY: "Script Library",
|
||||
TRAY_SCRIPT_LIBRARY_ARIA: "Explore the Excalidraw Script Library",
|
||||
TRAY_EXPORT: "Export Image...",
|
||||
@@ -452,7 +451,14 @@ export default {
|
||||
"Note: This setting does not affect the PDF export feature within Excalidraw itself.<br>" +
|
||||
"See the other related setting for <a href='#"+TAG_MDREADINGMODE+"'>Markdown Reading Mode</a> under 'Appearance and Behavior' further above.<br>" +
|
||||
"⚠️ You must close and reopen the Excalidraw/markdown file for changes to take effect. ⚠️",
|
||||
MODES_HEAD: "Modes",
|
||||
MODES_HEAD: "UI Modes",
|
||||
DESKTOP_UI_MODE_NAME: "Preferred Desktop Mode",
|
||||
DESKTOP_UI_MODE_DESC: "Select the default UI mode for desktop devices.",
|
||||
TABLET_UI_MODE_NAME: "Preferred Tablet Mode",
|
||||
TABLET_UI_MODE_DESC: "Select the default UI mode for tablet devices.",
|
||||
MODE_FULL: "Desktop-mode",
|
||||
MODE_COMPACT: "Compact-mode",
|
||||
MODE_TRAY: "Tray-mode",
|
||||
TRAY_MODE_NAME: "Enable tray-mode",
|
||||
PREFER_COMPACT_MODE_DESKTOP_NAME: "Prefer compact-mode on Desktop",
|
||||
PREFER_COMPACT_MODE_DESKTOP_DESC: "When toggling tray-mode on a desktop, if this option is enabled, Excalidraw will toggle between compact-mode and tray-mode. " +
|
||||
|
||||
@@ -22,7 +22,8 @@ I build this plugin in my free time, as a labor of love. Curious about the philo
|
||||
- Phone UI from Excalidraw.com [#9996](https://github.com/excalidraw/excalidraw/pull/9996)
|
||||
- Custom pen settings now allow pen width to be set at 0.1 increments from 0.1 to 8.0
|
||||
- Updated the "Palm Guard" script to support the change UI configurations.
|
||||
- Setting under Modes in Plugin Settings to prefer "compact-mode" on desktops when toggling tray mode.
|
||||
- Restructured Mode settings in Excalidraw Settings. You can now set the preference for UI mode for desktop and tablets.
|
||||
The old "prefer tray-mode" toggle has been removed. "Toggle Tray-Mode" changes to "Toggle UI-Mode".
|
||||
|
||||
## Fixed
|
||||
- side panel does not attach correctly when library is pinned [#2510](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2510)
|
||||
@@ -31,7 +32,7 @@ I build this plugin in my free time, as a labor of love. Curious about the philo
|
||||
- Fixed duplicated PDF elements after copy-pasting from scene to scene.
|
||||
- Resolved the large gap at the top on iOS devices. As it turns out, Apple adds additional padding automatically to avoid collision with the notch.
|
||||
- Fixed the positioning of the "Canvas and Shape Properties" window.
|
||||
- Attempt to fix mobile keyboard popup distorting the view.
|
||||
- Attempt to fix the mobile keyboard pop-up distorting the view.
|
||||
`,
|
||||
"2.16.1":`
|
||||
## Fixed
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
import { Setting, DropdownComponent, App } from "obsidian";
|
||||
import { t } from "src/lang/helpers";
|
||||
import { ExcalidrawSettings } from "src/core/settings";
|
||||
import { fragWithHTML, setLeftHandedMode, setUIMode } from "src/utils/utils";
|
||||
import { DEVICE } from "src/constants/constants";
|
||||
|
||||
export type UIMode = "full" | "compact" | "tray" | "phone";
|
||||
|
||||
//setTrayMode(this.app, this.plugin.settings);
|
||||
//setDesktopUIMode(this.app, this.plugin.settings);
|
||||
|
||||
|
||||
export class UIModeSettingsComponent {
|
||||
private containerEl: HTMLElement;
|
||||
private settings: ExcalidrawSettings;
|
||||
private app: App;
|
||||
private onChange: () => void;
|
||||
|
||||
constructor(
|
||||
containerEl: HTMLElement,
|
||||
settings: ExcalidrawSettings,
|
||||
app: App,
|
||||
onChange: () => void,
|
||||
) {
|
||||
this.containerEl = containerEl;
|
||||
this.settings = settings;
|
||||
this.app = app;
|
||||
this.onChange = onChange;
|
||||
}
|
||||
|
||||
render(): void {
|
||||
const { containerEl } = this;
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(t("DESKTOP_UI_MODE_NAME"))
|
||||
.setDesc(t("DESKTOP_UI_MODE_DESC"))
|
||||
.addDropdown((dropdown: DropdownComponent) =>
|
||||
dropdown
|
||||
.addOption("full", t("MODE_FULL"))
|
||||
.addOption("compact", t("MODE_COMPACT"))
|
||||
.addOption("tray", t("MODE_TRAY"))
|
||||
.setValue(this.settings.desktopUIMode)
|
||||
.onChange((value: UIMode) => {
|
||||
this.settings.desktopUIMode = value;
|
||||
if (DEVICE.isDesktop) {
|
||||
setUIMode(this.app, this.settings);
|
||||
}
|
||||
this.onChange();
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(t("TABLET_UI_MODE_NAME"))
|
||||
.setDesc(t("TABLET_UI_MODE_DESC"))
|
||||
.addDropdown((dropdown: DropdownComponent) =>
|
||||
dropdown
|
||||
.addOption("compact", t("MODE_COMPACT"))
|
||||
.addOption("tray", t("MODE_TRAY"))
|
||||
.setValue(this.settings.tabletUIMode)
|
||||
.onChange((value: UIMode) => {
|
||||
this.settings.tabletUIMode = value;
|
||||
if (DEVICE.isTablet) {
|
||||
setUIMode(this.app, this.settings);
|
||||
}
|
||||
this.onChange();
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(t("LEFTHANDED_MODE_NAME"))
|
||||
.setDesc(fragWithHTML(t("LEFTHANDED_MODE_DESC")))
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.settings.isLeftHanded)
|
||||
.onChange(async (value) => {
|
||||
this.settings.isLeftHanded = value;
|
||||
//not clear why I need to do this. If I don't double apply the stylesheet changes
|
||||
//then the style won't be applied in the popout windows
|
||||
setLeftHandedMode(value);
|
||||
setTimeout(()=>setLeftHandedMode(value));
|
||||
this.onChange();
|
||||
}),
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import ExcalidrawPlugin from "src/core/main";
|
||||
import { t } from "src/lang/helpers";
|
||||
import { UIModeSettingsComponent } from "./UIModeSettingComponent";
|
||||
import { FloatingModal } from "./FloatingModal";
|
||||
import { Modal } from "obsidian";
|
||||
|
||||
export class UIModeSettings extends Modal {
|
||||
private isDirty = false;
|
||||
constructor(
|
||||
private plugin: ExcalidrawPlugin,
|
||||
) {
|
||||
super(plugin.app);
|
||||
}
|
||||
|
||||
onOpen(): void {
|
||||
this.containerEl.classList.add("excalidraw-release");
|
||||
this.createForm();
|
||||
}
|
||||
|
||||
async onClose() {
|
||||
if (this.isDirty) {
|
||||
await this.plugin.saveSettings();
|
||||
}
|
||||
this.plugin = null;
|
||||
}
|
||||
|
||||
async createForm() {
|
||||
this.contentEl.createEl("h1",{text: t("MODES_HEAD")});
|
||||
new UIModeSettingsComponent(
|
||||
this.contentEl,
|
||||
this.plugin.settings,
|
||||
this.app,
|
||||
()=>this.applySettingsUpdate(),
|
||||
).render();
|
||||
}
|
||||
|
||||
private async applySettingsUpdate() {
|
||||
this.isDirty = true;
|
||||
};
|
||||
}
|
||||
|
||||
+21
-25
@@ -6,7 +6,7 @@ import {
|
||||
TFolder,
|
||||
} from "obsidian";
|
||||
import { Random } from "roughjs/bin/math";
|
||||
import { BinaryFileData, DataURL, ExcalidrawImperativeAPI} from "@zsviczian/excalidraw/types/excalidraw/types";
|
||||
import { BinaryFileData, DataURL} from "@zsviczian/excalidraw/types/excalidraw/types";
|
||||
import {
|
||||
exportToSvg,
|
||||
exportToBlob,
|
||||
@@ -36,6 +36,7 @@ import { VersionMismatchPrompt } from "src/shared/Dialogs/VersionMismatch";
|
||||
import { ExcalidrawSettings } from "src/core/settings";
|
||||
import { FileData } from "src/types/embeddedFileLoaderTypes";
|
||||
import { ExportSettings } from "src/types/exportUtilTypes";
|
||||
import { UIMode } from "src/shared/Dialogs/UIModeSettingComponent";
|
||||
|
||||
declare const PLUGIN_VERSION:string;
|
||||
declare var LZString: any;
|
||||
@@ -605,7 +606,12 @@ export function scaleLoadedImage (
|
||||
export function setDocLeftHandedMode(isLeftHanded: boolean, ownerDocument:Document) {
|
||||
const newStylesheet = ownerDocument.createElement("style");
|
||||
newStylesheet.id = "excalidraw-left-handed";
|
||||
newStylesheet.textContent = `.excalidraw .App-bottom-bar{justify-content:flex-end;}`;
|
||||
newStylesheet.textContent = `.excalidraw .App-bottom-bar {
|
||||
justify-content:flex-end !important;
|
||||
left: auto !important;
|
||||
right: 0 !important;
|
||||
transform: none !important;
|
||||
}`;
|
||||
const oldStylesheet = ownerDocument.getElementById(newStylesheet.id);
|
||||
if (oldStylesheet) {
|
||||
ownerDocument.head.removeChild(oldStylesheet);
|
||||
@@ -616,6 +622,7 @@ export function setDocLeftHandedMode(isLeftHanded: boolean, ownerDocument:Docume
|
||||
}
|
||||
|
||||
export function setLeftHandedMode (isLeftHanded: boolean) {
|
||||
if(DEVICE.isPhone) return; //no lefthanded mode on phones
|
||||
const visitedDocs = new Set<Document>();
|
||||
EXCALIDRAW_PLUGIN.app.workspace.iterateAllLeaves((leaf) => {
|
||||
const ownerDocument = DEVICE.isMobile?document:leaf.view.containerEl.ownerDocument;
|
||||
@@ -626,31 +633,20 @@ export function setLeftHandedMode (isLeftHanded: boolean) {
|
||||
})
|
||||
};
|
||||
|
||||
export function calculateTrayModeValue(settings: ExcalidrawSettings): boolean {
|
||||
const { defaultTrayMode, compactModeOnTablets } = settings;
|
||||
const isTrayMode = DEVICE.isTablet
|
||||
? (compactModeOnTablets ? false : defaultTrayMode)
|
||||
: defaultTrayMode;
|
||||
return isTrayMode;
|
||||
export function calculateUIModeValue(settings: ExcalidrawSettings): UIMode {
|
||||
return DEVICE.isPhone
|
||||
? "phone"
|
||||
: DEVICE.isTablet
|
||||
? settings.tabletUIMode
|
||||
: DEVICE.isDesktop
|
||||
? settings.desktopUIMode
|
||||
: "tray";
|
||||
}
|
||||
|
||||
export function setTrayMode(app: App, settings: ExcalidrawSettings) {
|
||||
const isTrayMode = calculateTrayModeValue(settings);
|
||||
getExcalidrawViews(app).forEach((view) => view.setTrayMode(isTrayMode));
|
||||
}
|
||||
|
||||
export function setDesktopUIMode(app: App, settings: ExcalidrawSettings) {
|
||||
const isTrayMode = settings.defaultTrayMode;
|
||||
getExcalidrawViews(app).forEach((view) => view
|
||||
.setDesktopUIMode(
|
||||
isTrayMode
|
||||
? "tray"
|
||||
: settings.compactModeOnDesktops
|
||||
? "compact"
|
||||
: "full"
|
||||
)
|
||||
);
|
||||
}
|
||||
export function setUIMode(app: App, settings: ExcalidrawSettings) {
|
||||
const uiMode = calculateUIModeValue(settings);
|
||||
getExcalidrawViews(app).forEach((view) => view.setUIMode(uiMode));
|
||||
};
|
||||
|
||||
export type LinkParts = {
|
||||
original: string;
|
||||
|
||||
+14
-54
@@ -110,9 +110,7 @@ import {
|
||||
getFilePathFromObsidianURL,
|
||||
getLinkParts,
|
||||
checkVersionMismatch,
|
||||
calculateTrayModeValue,
|
||||
setTrayMode,
|
||||
setDesktopUIMode,
|
||||
calculateUIModeValue,
|
||||
} from "../utils/utils";
|
||||
import { cleanBlockRef, cleanSectionHeading, closeLeafView, getAttachmentsFolderAndFilePath, getExcalidraAndMarkdowViewsForFile, getLeaf, getParentOfClass, obsidianPDFQuoteWithRef, openLeaf, setExcalidrawView } from "../utils/obsidianUtils";
|
||||
import { splitFolderAndFilename } from "../utils/fileUtils";
|
||||
@@ -160,6 +158,8 @@ import { PageOrientation, PageSize, ExportSettings } from "src/types/exportUtilT
|
||||
import { CaptureUpdateAction } from "src/constants/constants";
|
||||
import { updateElementIdsInScene } from "src/utils/excalidrawSceneUtils";
|
||||
import { FileData } from "src/types/embeddedFileLoaderTypes";
|
||||
import { UIMode } from "src/shared/Dialogs/UIModeSettingComponent";
|
||||
import { UIModeSettings } from "src/shared/Dialogs/UIModeSettings";
|
||||
|
||||
const EMBEDDABLE_SEMAPHORE_TIMEOUT = 2000;
|
||||
const PREVENT_RELOAD_TIMEOUT = 2000;
|
||||
@@ -2913,7 +2913,8 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
this.loadSceneFiles();
|
||||
this.updateContainerSize(null, true, justloaded);
|
||||
this.initializeToolsIconPanelAfterLoading();
|
||||
this.setTrayMode(calculateTrayModeValue(this.plugin.settings));
|
||||
const uiMode = calculateUIModeValue(this.plugin.settings);
|
||||
this.setUIMode(uiMode);
|
||||
}
|
||||
|
||||
public setDirty(location?:number) {
|
||||
@@ -5359,15 +5360,8 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
icon: ICONS.trayMode,
|
||||
"aria-label": t("ARIA_LABEL_TRAY_MODE"),
|
||||
onSelect: ()=> {
|
||||
if(!DEVICE.isTablet) {
|
||||
this.toggleTrayMode();
|
||||
return;
|
||||
}
|
||||
if(this.plugin.settings.defaultTrayMode) {
|
||||
this.toggleCompactMode();
|
||||
return;
|
||||
}
|
||||
this.toggleTrayMode(false);
|
||||
const uiModes = new UIModeSettings(this.plugin);
|
||||
uiModes.open();
|
||||
},
|
||||
},
|
||||
t("TRAY_TRAY_MODE")
|
||||
@@ -5685,11 +5679,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
saveAsImage: false,
|
||||
saveToActiveFile: false,
|
||||
},
|
||||
desktopUIMode: this.plugin.settings.defaultTrayMode
|
||||
? "tray"
|
||||
: this.plugin.settings.compactModeOnDesktops
|
||||
? "compact"
|
||||
: "full",
|
||||
desktopUIMode: calculateUIModeValue(this.plugin.settings),
|
||||
//formFactor: DEVICE.isMobile ? "phone" : DEVICE.isTablet ? "tablet" : "desktop",
|
||||
},
|
||||
initState: initdata?.appState,
|
||||
@@ -5866,44 +5856,14 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
});
|
||||
}
|
||||
|
||||
public async toggleCompactMode() {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.toggleCompactMode, "ExcalidrawView.toggleCompactMode");
|
||||
|
||||
//just in case settings were updated via Obsidian sync
|
||||
const newCompactMode = !this.plugin.settings.compactModeOnTablets;
|
||||
await this.plugin.loadSettings();
|
||||
this.plugin.settings.compactModeOnTablets = newCompactMode;
|
||||
await this.plugin.saveSettings();
|
||||
setTrayMode(this.app, this.plugin.settings);
|
||||
}
|
||||
|
||||
public async toggleTrayMode(compactMode?: boolean) {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.toggleTrayMode, "ExcalidrawView.toggleTrayMode");
|
||||
//just in case settings were updated via Obsidian sync
|
||||
const newTrayMode = !this.plugin.settings.defaultTrayMode;
|
||||
await this.plugin.loadSettings();
|
||||
this.plugin.settings.defaultTrayMode = newTrayMode;
|
||||
if(compactMode!==undefined) {
|
||||
this.plugin.settings.compactModeOnTablets = compactMode;
|
||||
}
|
||||
await this.plugin.saveSettings();
|
||||
setTrayMode(this.app, this.plugin.settings);
|
||||
if(!newTrayMode) {
|
||||
setDesktopUIMode(this.app, this.plugin.settings);
|
||||
}
|
||||
}
|
||||
|
||||
public setTrayMode(on: boolean) {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.toggleTrayMode, "ExcalidrawView.setTrayMode");
|
||||
const api = this.excalidrawAPI as ExcalidrawImperativeAPI;
|
||||
api.setTrayModeEnabled(on);
|
||||
//setTimeout(()=>api.refreshEditorBreakpoints());
|
||||
}
|
||||
|
||||
public setDesktopUIMode(mode: "full" | "compact" | "tray") {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.setDesktopUIMode, "ExcalidrawView.setDesktopUIMode");
|
||||
public setUIMode(mode: UIMode) {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.setUIMode, "ExcalidrawView.setDesktopUIMode");
|
||||
const api = this.excalidrawAPI as ExcalidrawImperativeAPI;
|
||||
if (mode === "phone") {
|
||||
return;
|
||||
}
|
||||
api.setDesktopUIMode(mode);
|
||||
api.setTrayModeEnabled(mode === "tray");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@ import { UniversalInsertFileModal } from "src/shared/Dialogs/UniversalInsertFile
|
||||
import { DEBUGGING, debug } from "src/utils/debugHelper";
|
||||
import { REM_VALUE } from "src/core/managers/StylesManager";
|
||||
import { getExcalidrawViews } from "src/utils/obsidianUtils";
|
||||
import { UIModeSettings } from "src/shared/Dialogs/UIModeSettings";
|
||||
|
||||
declare const PLUGIN_VERSION:string;
|
||||
|
||||
@@ -232,7 +233,8 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
}
|
||||
|
||||
actionToggleTrayMode() {
|
||||
this.view.toggleTrayMode();
|
||||
const uiModeSettings = new UIModeSettings(this.view.plugin);
|
||||
uiModeSettings.open();
|
||||
}
|
||||
|
||||
actionToggleFullscreen() {
|
||||
@@ -530,8 +532,8 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
/>
|
||||
)}
|
||||
<ActionButton
|
||||
key={"tray-mode"}
|
||||
title={t("TRAY_MODE")}
|
||||
key={"ui-mode"}
|
||||
title={t("UI_MODE")}
|
||||
action={this.actionToggleTrayMode.bind(this)}
|
||||
icon={ICONS.trayMode}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user