Skip to content

Commit 3e55719

Browse files
committed
2.16.0-beta-2, 0.18.0-40
1 parent c5ca730 commit 3e55719

9 files changed

Lines changed: 111 additions & 16 deletions

File tree

manifest-beta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "obsidian-excalidraw-plugin",
33
"name": "Excalidraw",
4-
"version": "2.16.0-beta-1",
4+
"version": "2.16.0-beta-2",
55
"minAppVersion": "1.5.7",
66
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
77
"author": "Zsolt Viczian",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"license": "MIT",
2525
"dependencies": {
2626
"@popperjs/core": "^2.11.8",
27-
"@zsviczian/excalidraw": "0.18.0-39",
27+
"@zsviczian/excalidraw": "0.18.0-40",
2828
"chroma-js": "^3.1.2",
2929
"clsx": "^2.0.0",
3030
"@zsviczian/colormaster": "^1.2.2",

src/core/settings.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
addIframe,
3030
fragWithHTML,
3131
setLeftHandedMode,
32+
setTrayMode,
3233
} from "src/utils/utils";
3334
import { imageCache } from "src/shared/ImageCache";
3435
import { MultiOptionConfirmationPrompt } from "src/shared/Dialogs/Prompt";
@@ -179,6 +180,7 @@ export interface ExcalidrawSettings {
179180
}
180181
};
181182
defaultTrayMode: boolean;
183+
compactModeOnTablets: boolean;
182184
previousRelease: string;
183185
showReleaseNotes: boolean;
184186
compareManifestToPluginVersion: boolean;
@@ -364,6 +366,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
364366
mdCSS: "",
365367
scriptEngineSettings: {},
366368
defaultTrayMode: true,
369+
compactModeOnTablets: true,
367370
previousRelease: "0.0.0",
368371
showReleaseNotes: true,
369372
compareManifestToPluginVersion: true,
@@ -1243,6 +1246,39 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
12431246
}),
12441247
);
12451248

1249+
detailsEl = displayDetailsEl.createEl("details");
1250+
detailsEl.createEl("summary", {
1251+
text: t("MODES_HEAD"),
1252+
cls: "excalidraw-setting-h3",
1253+
});
1254+
1255+
new Setting(detailsEl)
1256+
.setName(t("TRAY_MODE_NAME"))
1257+
.setDesc(fragWithHTML(t("ARIA_LABEL_TRAY_MODE")))
1258+
.addToggle((toggle) =>
1259+
toggle
1260+
.setValue(this.plugin.settings.defaultTrayMode)
1261+
.onChange((value) => {
1262+
this.plugin.settings.defaultTrayMode = value;
1263+
setTrayMode(this.app, this.plugin.settings);
1264+
this.applySettingsUpdate();
1265+
})
1266+
);
1267+
1268+
new Setting(detailsEl)
1269+
.setName(t("COMPACT_MODE_NAME"))
1270+
.setDesc(fragWithHTML(t("COMPACT_MODE_DESC")))
1271+
.addToggle((toggle) =>
1272+
toggle
1273+
.setValue(this.plugin.settings.compactModeOnTablets)
1274+
.onChange((value) => {
1275+
this.plugin.settings.compactModeOnTablets = value;
1276+
setTrayMode(this.app, this.plugin.settings);
1277+
this.applySettingsUpdate();
1278+
}),
1279+
);
1280+
1281+
12461282
new Setting(detailsEl)
12471283
.setName(t("LEFTHANDED_MODE_NAME"))
12481284
.setDesc(fragWithHTML(t("LEFTHANDED_MODE_DESC")))

src/lang/locale/en.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export default {
139139
"3) and paste your work to the new document with CTRL/CMD+V.",
140140
ARIA_LABEL_TRAY_MODE: "Tray-mode offers an alternative, more spacious canvas",
141141
TRAY_TRAY_MODE: "Toggle tray-mode",
142+
TOGGLE_COMPACT_MODE: "Toggle compact-mode",
142143
TRAY_SCRIPT_LIBRARY: "Script Library",
143144
TRAY_SCRIPT_LIBRARY_ARIA: "Explore the Excalidraw Script Library",
144145
TRAY_EXPORT: "Export Image...",
@@ -449,6 +450,10 @@ export default {
449450
"Note: This setting does not affect the PDF export feature within Excalidraw itself.<br>" +
450451
"See the other related setting for <a href='#"+TAG_MDREADINGMODE+"'>Markdown Reading Mode</a> under 'Appearance and Behavior' further above.<br>" +
451452
"⚠️ You must close and reopen the Excalidraw/markdown file for changes to take effect. ⚠️",
453+
MODES_HEAD: "Modes",
454+
TRAY_MODE_NAME: "Enable tray-mode",
455+
COMPACT_MODE_NAME: "Compact-mode on Tablets",
456+
COMPACT_MODE_DESC: "Overrides tray-mode on tablets, allowing the native Excalidraw compact-mode to be used instead.",
452457
HOTKEY_OVERRIDE_HEAD: "Hotkey overrides",
453458
HOTKEY_OVERRIDE_DESC: `Some of the Excalidraw hotkeys such as <code>${labelCTRL()}+Enter</code> to edit text or <code>${labelCTRL()}+K</code> to create an element link ` +
454459
"conflict with Obsidian hotkey settings. The hotkey combinations you add below will override Obsidian's hotkey settings while using Excalidraw, thus " +

src/shared/Dialogs/InsertPDFModal.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,10 @@ export class InsertPDFModal extends Modal {
439439

440440
if(this.frame) {
441441
const frameID = ea.addFrame(topX, topY,imgWidth,imgHeight,`${page}`);
442-
ea.addElementsToFrame(frameID, [boxID,imageID]);
442+
const frameEl = ea.getElement(frameID) as any;
443+
frameEl.frameRole = "marker";
444+
ea.addToGroup([frameID,boxID,imageID]);
445+
//ea.addElementsToFrame(frameID, [boxID,imageID]);
443446
ea.getElement(frameID).link = this.pdfFile.path + `#page=${page}`;
444447
}
445448

src/shared/Dialogs/Messages.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ I build this plugin in my free time, as a labor of love. Curious about the philo
2121
# New from Excalidraw.com
2222
- New library search feature [#9903](https://github.com/excalidraw/excalidraw/pull/9903)
2323
- You can rename library items by selecting them, then choosing "Rename or publish" from the ... menu.
24+
- New compact mode for tablets [#9910](https://github.com/excalidraw/excalidraw/pull/9910)
25+
- New setting in plugin setting \`Compact-mode on Tablets\` to override tray-mode on tablets in favor of the new compact mode.
26+
27+
# New
28+
- Embedding PDF as images, frames are now marker frames instead of regular frames. You can reference pages including their markup in markdown notes using this syntax: \`![[drawing#^frame=12]]\` (page 12)
29+
- Pinned scripts and Obsidian toolbar is now on the right side in all modes: tray-, normal-, and compact. The toolbar moves into view when the sidpanel is openned for the stencil library or for search.
2430
`,
2531
"2.15.3":`
2632
## Fixed

src/utils/utils.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { getDataURLFromURL, getIMGFilename, getMimeType, getURLImageExtension }
2525
import { generateEmbeddableLink } from "./customEmbeddableUtils";
2626
import { FILENAMEPARTS } from "../types/utilTypes";
2727
import { Mutable } from "@zsviczian/excalidraw/types/common/src/utility-types";
28-
import { cleanBlockRef, cleanSectionHeading, getFileCSSClasses } from "./obsidianUtils";
28+
import { cleanBlockRef, cleanSectionHeading, getExcalidrawViews, getFileCSSClasses } from "./obsidianUtils";
2929
import { updateElementLinksToObsidianLinks } from "./excalidrawAutomateUtils";
3030
import { CropImage } from "../shared/CropImage";
3131
import opentype from 'opentype.js';
@@ -35,6 +35,7 @@ import { FileData } from "../shared/EmbeddedFileLoader";
3535
import { t } from "src/lang/helpers";
3636
import { log } from "./debugHelper";
3737
import { VersionMismatchPrompt } from "src/shared/Dialogs/VersionMismatch";
38+
import { ExcalidrawSettings } from "src/core/settings";
3839

3940
declare const PLUGIN_VERSION:string;
4041
declare var LZString: any;
@@ -625,6 +626,19 @@ export function setLeftHandedMode (isLeftHanded: boolean) {
625626
})
626627
};
627628

629+
export function calculateTrayModeValue(settings: ExcalidrawSettings): boolean {
630+
const { defaultTrayMode, compactModeOnTablets } = settings;
631+
const isTrayMode = DEVICE.isTablet
632+
? (compactModeOnTablets ? false : defaultTrayMode)
633+
: defaultTrayMode;
634+
return isTrayMode;
635+
}
636+
637+
export function setTrayMode(app: App, settings: ExcalidrawSettings) {
638+
const isTrayMode = calculateTrayModeValue(settings);
639+
getExcalidrawViews(app).forEach((view) => view.setTrayMode(isTrayMode));
640+
}
641+
628642
export type LinkParts = {
629643
original: string;
630644
path: string;

src/view/ExcalidrawView.ts

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ import {
110110
getFilePathFromObsidianURL,
111111
getLinkParts,
112112
checkVersionMismatch,
113+
calculateTrayModeValue,
114+
setTrayMode,
113115
} from "../utils/utils";
114116
import { cleanBlockRef, cleanSectionHeading, closeLeafView, getAttachmentsFolderAndFilePath, getExcalidraAndMarkdowViewsForFile, getLeaf, getParentOfClass, obsidianPDFQuoteWithRef, openLeaf, setExcalidrawView } from "../utils/obsidianUtils";
115117
import { splitFolderAndFilename } from "../utils/fileUtils";
@@ -2824,7 +2826,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
28242826
zenModeEnabled,
28252827
viewModeEnabled,
28262828
linkOpacity: this.excalidrawData.getLinkOpacity(),
2827-
trayModeEnabled: this.plugin.settings.defaultTrayMode,
2829+
trayModeEnabled: calculateTrayModeValue(this.plugin.settings),
28282830
penMode: penEnabled,
28292831
penDetected: penEnabled,
28302832
allowPinchZoom: this.plugin.settings.allowPinchZoom,
@@ -2858,7 +2860,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
28582860
zenModeEnabled: om.zenModeEnabled,
28592861
viewModeEnabled: excalidrawData.elements.length > 0 ? om.viewModeEnabled : false,
28602862
linkOpacity: this.excalidrawData.getLinkOpacity(),
2861-
trayModeEnabled: this.plugin.settings.defaultTrayMode,
2863+
trayModeEnabled: calculateTrayModeValue(this.plugin.settings),
28622864
penMode: penEnabled,
28632865
penDetected: penEnabled,
28642866
allowPinchZoom: this.plugin.settings.allowPinchZoom,
@@ -5338,7 +5340,17 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
53385340
{
53395341
icon: ICONS.trayMode,
53405342
"aria-label": t("ARIA_LABEL_TRAY_MODE"),
5341-
onSelect: ()=> this.toggleTrayMode(),
5343+
onSelect: ()=> {
5344+
if(!DEVICE.isTablet) {
5345+
this.toggleTrayMode();
5346+
return;
5347+
}
5348+
if(this.plugin.settings.defaultTrayMode) {
5349+
this.toggleCompactMode();
5350+
return;
5351+
}
5352+
this.toggleTrayMode(false);
5353+
},
53425354
},
53435355
t("TRAY_TRAY_MODE")
53445356
) : null,
@@ -5804,22 +5816,41 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
58045816
});
58055817
}
58065818

5807-
public async toggleTrayMode() {
5819+
public async toggleCompactMode() {
5820+
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.toggleCompactMode, "ExcalidrawView.toggleCompactMode");
5821+
5822+
//just in case settings were updated via Obsidian sync
5823+
const newCompactMode = !this.plugin.settings.compactModeOnTablets;
5824+
await this.plugin.loadSettings();
5825+
this.plugin.settings.compactModeOnTablets = newCompactMode;
5826+
setTrayMode(this.app, this.plugin.settings);
5827+
await this.plugin.saveSettings();
5828+
}
5829+
5830+
public async toggleTrayMode(compactMode?: boolean) {
58085831
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.toggleTrayMode, "ExcalidrawView.toggleTrayMode");
5832+
//just in case settings were updated via Obsidian sync
5833+
const newTrayMode = !this.plugin.settings.defaultTrayMode;
5834+
await this.plugin.loadSettings();
5835+
this.plugin.settings.defaultTrayMode = newTrayMode;
5836+
if(compactMode!==undefined) {
5837+
this.plugin.settings.compactModeOnTablets = compactMode;
5838+
}
5839+
setTrayMode(this.app, this.plugin.settings);
5840+
await this.plugin.saveSettings();
5841+
}
5842+
5843+
public setTrayMode(on: boolean) {
5844+
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.toggleTrayMode, "ExcalidrawView.setTrayMode");
58095845
const api = this.excalidrawAPI as ExcalidrawImperativeAPI;
58105846
if (!api) {
58115847
return false;
58125848
}
5813-
const st = api.getAppState();
58145849
api.updateScene({
5815-
appState: { trayModeEnabled: !st.trayModeEnabled },
5850+
appState: { trayModeEnabled: on },
58165851
captureUpdate: CaptureUpdateAction.NEVER,
58175852
});
5818-
5819-
//just in case settings were updated via Obsidian sync
5820-
await this.plugin.loadSettings();
5821-
this.plugin.settings.defaultTrayMode = !st.trayModeEnabled;
5822-
this.plugin.saveSettings();
5853+
setTimeout(()=>api.refreshEditorBreakpoints());
58235854
}
58245855

58255856
/**

styles.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ label.color-input-container > input {
329329
.excalidraw .FixedSideContainer_side_top {
330330
left: 10px !important;
331331
top: 10px !important;
332-
right: 10px !important;
332+
right: 10px;
333333
bottom: 10px !important;
334334
}
335335

0 commit comments

Comments
 (0)