mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2026-11-27 06:32:42 +00:00
2.20.5-beta-2, 0.18.0-78
This commit is contained in:
1 parent
6a69d61f2d
commit
376738f894
15 files changed
+112
-37
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.20.5-beta-1",
|
||||
"version": "2.20.5-beta-2",
|
||||
"minAppVersion": "1.5.7",
|
||||
"description": "Sketch Your Mind. An Obsidian plugin to edit and view Excalidraw drawings. Enter the world of 4D Visual PKM.",
|
||||
"author": "Zsolt Viczian",
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"@zsviczian/excalidraw": "0.18.0-77",
|
||||
"@zsviczian/excalidraw": "0.18.0-78",
|
||||
"chroma-js": "^3.1.2",
|
||||
"clsx": "^2.0.0",
|
||||
"@zsviczian/colormaster": "^1.2.2",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Bookmark, Camera, Copy, Crop, Globe, RotateCcw, Scan, Settings, TextSelect } from "lucide-react";
|
||||
import { getIcon } from "obsidian";
|
||||
import * as React from "react";
|
||||
import { PenStyle } from "src/types/penTypes";
|
||||
|
||||
@@ -488,20 +489,6 @@ export const ICONS = {
|
||||
<path d="M495.9 166.6C499.2 175.2 496.4 184.9 489.6 191.2L446.3 230.6C447.4 238.9 448 247.4 448 256C448 264.6 447.4 273.1 446.3 281.4L489.6 320.8C496.4 327.1 499.2 336.8 495.9 345.4C491.5 357.3 486.2 368.8 480.2 379.7L475.5 387.8C468.9 398.8 461.5 409.2 453.4 419.1C447.4 426.2 437.7 428.7 428.9 425.9L373.2 408.1C359.8 418.4 344.1 427 329.2 433.6L316.7 490.7C314.7 499.7 307.7 506.1 298.5 508.5C284.7 510.8 270.5 512 255.1 512C241.5 512 227.3 510.8 213.5 508.5C204.3 506.1 197.3 499.7 195.3 490.7L182.8 433.6C167 427 152.2 418.4 138.8 408.1L83.14 425.9C74.3 428.7 64.55 426.2 58.63 419.1C50.52 409.2 43.12 398.8 36.52 387.8L31.84 379.7C25.77 368.8 20.49 357.3 16.06 345.4C12.82 336.8 15.55 327.1 22.41 320.8L65.67 281.4C64.57 273.1 64 264.6 64 256C64 247.4 64.57 238.9 65.67 230.6L22.41 191.2C15.55 184.9 12.82 175.3 16.06 166.6C20.49 154.7 25.78 143.2 31.84 132.3L36.51 124.2C43.12 113.2 50.52 102.8 58.63 92.95C64.55 85.8 74.3 83.32 83.14 86.14L138.8 103.9C152.2 93.56 167 84.96 182.8 78.43L195.3 21.33C197.3 12.25 204.3 5.04 213.5 3.51C227.3 1.201 241.5 0 256 0C270.5 0 284.7 1.201 298.5 3.51C307.7 5.04 314.7 12.25 316.7 21.33L329.2 78.43C344.1 84.96 359.8 93.56 373.2 103.9L428.9 86.14C437.7 83.32 447.4 85.8 453.4 92.95C461.5 102.8 468.9 113.2 475.5 124.2L480.2 132.3C486.2 143.2 491.5 154.7 495.9 166.6V166.6zM256 336C300.2 336 336 300.2 336 255.1C336 211.8 300.2 175.1 256 175.1C211.8 175.1 176 211.8 176 255.1C176 300.2 211.8 336 256 336z" />
|
||||
</svg>
|
||||
),
|
||||
trayMode: (
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
focusable="false"
|
||||
role="img"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 640 512"
|
||||
stroke="var(--icon-fill-color)"
|
||||
fill="var(--icon-fill-color)"
|
||||
strokeWidth="20"
|
||||
>
|
||||
<path d="M618.1 97.67c-13.02-4.375-27.45 .1562-35.72 11.16L464 266.7l-118.4-157.8c-8.266-11.03-22.64-15.56-35.72-11.16C296.8 102 288 114.2 288 128v256c0 17.69 14.33 32 32 32s32-14.31 32-32v-160l86.41 115.2c12.06 16.12 39.13 16.12 51.19 0L576 224v160c0 17.69 14.33 32 32 32s32-14.31 32-32v-256C640 114.2 631.2 102 618.1 97.67zM224 96.01H32c-17.67 0-32 14.31-32 32s14.33 32 32 32h64v223.1c0 17.69 14.33 31.99 32 31.99s32-14.3 32-31.99V160h64c17.67 0 32-14.31 32-32S241.7 96.01 224 96.01z" />
|
||||
</svg>
|
||||
),
|
||||
copyElementLink: (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
@@ -900,3 +887,8 @@ export const LogoWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const getTrayIcon = (): JSX.Element => {
|
||||
const obsidianIcon = getIcon("monitor-check");
|
||||
return stringToSVG(obsidianIcon.outerHTML);
|
||||
}
|
||||
@@ -235,7 +235,7 @@ export class EventManager {
|
||||
this.plugin.removeModalContainerObserver();
|
||||
}
|
||||
|
||||
setMobileNavbarPosition(newActiveviewEV && !previouslyActiveEV);
|
||||
setMobileNavbarPosition(!!newActiveviewEV);
|
||||
//----------------------
|
||||
//----------------------
|
||||
|
||||
|
||||
@@ -92,6 +92,7 @@ export interface ExcalidrawSettings {
|
||||
isLeftHanded: boolean;
|
||||
desktopUIMode: UIMode;
|
||||
tabletUIMode: UIMode;
|
||||
phoneUIMode: UIMode;
|
||||
iframeMatchExcalidrawTheme: boolean;
|
||||
matchTheme: boolean;
|
||||
matchThemeAlways: boolean;
|
||||
@@ -283,6 +284,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
isLeftHanded: false,
|
||||
desktopUIMode: "tray",
|
||||
tabletUIMode: "compact",
|
||||
phoneUIMode: "mobile",
|
||||
iframeMatchExcalidrawTheme: true,
|
||||
matchTheme: false,
|
||||
matchThemeAlways: false,
|
||||
|
||||
@@ -465,9 +465,13 @@ export default {
|
||||
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.",
|
||||
PHONE_UI_MODE_NAME: "Preferred Phone Mode",
|
||||
PHONE_UI_MODE_DESC: "Select the default UI mode for phone devices.",
|
||||
MODE_FULL: "Desktop-mode",
|
||||
MODE_COMPACT: "Compact-mode",
|
||||
MODE_TRAY: "Tray-mode",
|
||||
MODE_PHONE: "Phone-mode",
|
||||
REAPPLY_UI_MODE_BUTTON: "Reapply UI mode now",
|
||||
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. " +
|
||||
|
||||
@@ -17,6 +17,14 @@ I build this plugin in my free time, as a labor of love. Curious about the philo
|
||||
|
||||
<div class="ex-coffee-div"><a href="https://ko-fi.com/zsolt"><img src="https://storage.ko-fi.com/cdn/kofi6.png?v=6" border="0" alt="Buy Me a Coffee at ko-fi.com" height=45></a></div>
|
||||
`,
|
||||
"2.20.5":`
|
||||
## Fixed
|
||||
- Floating navigation bar styling not removed when closing Excalidraw view on Obsidian Mobile [#2673](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2673)
|
||||
- UI mode preference on Mobile Devices [#2670](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2670)
|
||||
|
||||
## New
|
||||
- Added "Toggle Full Screen" button to toolbar after the "Insert Any File" button.
|
||||
`,
|
||||
"2.20.4":`
|
||||
## Fixed
|
||||
- Fix NativeSVG embed mode into Markdown documents, ahead of the Obsidian 1.12.1 release. [#2665](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2665)
|
||||
|
||||
@@ -4,9 +4,8 @@ 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";
|
||||
export type UIMode = "full" | "compact" | "tray" | "mobile";
|
||||
|
||||
//setTrayMode(this.app, this.plugin.settings);
|
||||
//setDesktopUIMode(this.app, this.plugin.settings);
|
||||
|
||||
|
||||
@@ -15,17 +14,20 @@ export class UIModeSettingsComponent {
|
||||
private settings: ExcalidrawSettings;
|
||||
private app: App;
|
||||
private onChange: () => void;
|
||||
private reapplyButtonAction: ()=>void = null;
|
||||
|
||||
constructor(
|
||||
containerEl: HTMLElement,
|
||||
settings: ExcalidrawSettings,
|
||||
app: App,
|
||||
onChange: () => void,
|
||||
reapplyButtonAction: ()=>void = null,
|
||||
) {
|
||||
this.containerEl = containerEl;
|
||||
this.settings = settings;
|
||||
this.app = app;
|
||||
this.onChange = onChange;
|
||||
this.reapplyButtonAction = reapplyButtonAction;
|
||||
}
|
||||
|
||||
render(): void {
|
||||
@@ -54,6 +56,7 @@ export class UIModeSettingsComponent {
|
||||
.setDesc(t("TABLET_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.tabletUIMode)
|
||||
@@ -66,6 +69,25 @@ export class UIModeSettingsComponent {
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(t("PHONE_UI_MODE_NAME"))
|
||||
.setDesc(t("PHONE_UI_MODE_DESC"))
|
||||
.addDropdown((dropdown: DropdownComponent) =>
|
||||
dropdown
|
||||
.addOption("full", t("MODE_FULL"))
|
||||
.addOption("compact", t("MODE_COMPACT"))
|
||||
.addOption("tray", t("MODE_TRAY"))
|
||||
.addOption("mobile", t("MODE_PHONE"))
|
||||
.setValue(this.settings.phoneUIMode ?? "mobile")
|
||||
.onChange((value: UIMode) => {
|
||||
this.settings.phoneUIMode = value;
|
||||
if (DEVICE.isPhone) {
|
||||
setUIMode(this.app, this.settings);
|
||||
}
|
||||
this.onChange();
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(t("LEFTHANDED_MODE_NAME"))
|
||||
.setDesc(fragWithHTML(t("LEFTHANDED_MODE_DESC")))
|
||||
@@ -82,5 +104,18 @@ export class UIModeSettingsComponent {
|
||||
}),
|
||||
);
|
||||
|
||||
if (this.reapplyButtonAction) {
|
||||
new Setting(containerEl)
|
||||
.addButton((button) =>
|
||||
button
|
||||
.setButtonText(t("REAPPLY_UI_MODE_BUTTON"))
|
||||
.setCta()
|
||||
.onClick(() => {
|
||||
setUIMode(this.app, this.settings);
|
||||
this.reapplyButtonAction();
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
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 {
|
||||
@@ -31,6 +30,7 @@ export class UIModeSettings extends Modal {
|
||||
this.plugin.settings,
|
||||
this.app,
|
||||
()=>this.applySettingsUpdate(),
|
||||
()=>this.close(),
|
||||
).render();
|
||||
}
|
||||
|
||||
|
||||
@@ -628,10 +628,14 @@ export function getViewColorPalette(
|
||||
//!Temporary hack
|
||||
//https://discord.com/channels/686053708261228577/817515900349448202/1031101635784613968
|
||||
export const setMobileNavbarPosition = (dock:boolean) => {
|
||||
if (DEVICE.isMobile && dock) {
|
||||
if (DEVICE.isMobile) {
|
||||
const navbar = document.querySelector("body>.app-container>.mobile-navbar");
|
||||
if(navbar && navbar instanceof HTMLDivElement) {
|
||||
navbar.style.position= dock ? "relative" : "";
|
||||
if (dock) {
|
||||
navbar.addClass("excalidraw-mobile-navbar-docked");
|
||||
} else {
|
||||
navbar.removeClass("excalidraw-mobile-navbar-docked");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-3
@@ -652,12 +652,16 @@ export function setLeftHandedMode (isLeftHanded: boolean) {
|
||||
};
|
||||
|
||||
export function calculateUIModeValue(settings: ExcalidrawSettings): UIMode {
|
||||
const phoneMode = settings.phoneUIMode ?? "mobile";
|
||||
const tabletMode = settings.tabletUIMode ?? "compact";
|
||||
const desktopMode = settings.desktopUIMode ?? "tray";
|
||||
|
||||
return DEVICE.isPhone
|
||||
? "phone"
|
||||
? phoneMode
|
||||
: DEVICE.isTablet
|
||||
? settings.tabletUIMode
|
||||
? tabletMode
|
||||
: DEVICE.isDesktop
|
||||
? settings.desktopUIMode
|
||||
? desktopMode
|
||||
: "tray";
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ import { ObsidianMenu } from "./components/menu/ObsidianMenu";
|
||||
import { ToolsPanel } from "./components/menu/ToolsPanel";
|
||||
import { ScriptEngine } from "../shared/Scripts";
|
||||
import { getTextElementAtPointer, getImageElementAtPointer, getElementWithLinkAtPointer } from "../utils/getElementAtPointer";
|
||||
import { excalidrawSword, ICONS, LogoWrapper, Rank, saveIcon, SwordColors } from "../constants/actionIcons";
|
||||
import { excalidrawSword, getTrayIcon, ICONS, LogoWrapper, Rank, saveIcon, SwordColors } from "../constants/actionIcons";
|
||||
import { ExportDialog } from "../shared/Dialogs/ExportDialog";
|
||||
import { getEA } from "src/core"
|
||||
import { anyModifierKeysPressed, emulateKeysForLinkClick, isWinALTorMacOPT, isWinCTRLorMacCMD, isWinMETAorMacCTRL, isSHIFT, linkClickModifierType, ModifierKeys } from "../utils/modifierkeyHelper";
|
||||
@@ -2134,7 +2134,6 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
//onClose happens after onunload
|
||||
protected async onClose(): Promise<void> {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.onClose,`ExcalidrawView.onClose, file:${this.file?.name}`);
|
||||
|
||||
//I noticed Obsidian calls this function twice when disabling the plugin
|
||||
//once from "unregisterView"
|
||||
//the from "detachLeavesOfType"
|
||||
@@ -5812,10 +5811,10 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
React.createElement(MainMenu.DefaultItems.ChangeCanvasBackground),
|
||||
React.createElement(MainMenu.DefaultItems.ToggleTheme),
|
||||
React.createElement(MainMenu.Separator),
|
||||
!DEVICE.isPhone ? React.createElement(
|
||||
React.createElement(
|
||||
MainMenu.Item,
|
||||
{
|
||||
icon: ICONS.trayMode,
|
||||
icon: getTrayIcon(),
|
||||
"aria-label": t("ARIA_LABEL_TRAY_MODE"),
|
||||
onSelect: ()=> {
|
||||
const uiModes = new UIModeSettings(this.plugin);
|
||||
@@ -5823,7 +5822,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
},
|
||||
},
|
||||
t("TRAY_TRAY_MODE")
|
||||
) : null,
|
||||
),
|
||||
React.createElement(
|
||||
MainMenu.Item,
|
||||
{
|
||||
@@ -6342,11 +6341,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
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");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -156,6 +156,18 @@ export class ObsidianMenu {
|
||||
insertFileModal.open();
|
||||
}
|
||||
|
||||
private actionToggleFullscreen() {
|
||||
if (this.view.isFullscreen()) {
|
||||
this.view.exitFullscreen();
|
||||
} else {
|
||||
this.view.gotoFullscreen();
|
||||
}
|
||||
this.view.excalidrawAPI?.updateScene({
|
||||
appState: {},
|
||||
captureUpdate: CaptureUpdateAction.NEVER,
|
||||
});
|
||||
}
|
||||
|
||||
public renderCustomPens (isMobile: boolean, appState: AppState) {
|
||||
return(
|
||||
appState.customPens?.map((_,index)=>{
|
||||
@@ -256,6 +268,7 @@ export class ObsidianMenu {
|
||||
}
|
||||
|
||||
public renderButton (isMobile: boolean, appState: AppState) {
|
||||
const isFullscreen = this.view.isFullscreen();
|
||||
return (
|
||||
<div className={clsx(
|
||||
{
|
||||
@@ -291,6 +304,20 @@ export class ObsidianMenu {
|
||||
{ICONS["add-file"]}
|
||||
</div>
|
||||
</label>
|
||||
<label
|
||||
className={clsx(
|
||||
"ToolIcon",
|
||||
"ToolIcon_size_medium",
|
||||
{
|
||||
"is-mobile": isMobile,
|
||||
},
|
||||
)}
|
||||
onClick={this.actionToggleFullscreen.bind(this)}
|
||||
>
|
||||
<div className="ToolIcon__icon" aria-label={isFullscreen ? t("EXIT_FULLSCREEN") : t("GOTO_FULLSCREEN")}>
|
||||
{isFullscreen ? ICONS.exitFullScreen : ICONS.gotoFullScreen}
|
||||
</div>
|
||||
</label>
|
||||
{this.renderCustomPens(isMobile,appState)}
|
||||
{this.renderPinnedScriptButtons(isMobile,appState)}
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import clsx from "clsx";
|
||||
import { Notice, TFile } from "obsidian";
|
||||
import { Notice, TFile, getIcon } from "obsidian";
|
||||
import * as React from "react";
|
||||
import { ActionButton } from "./ActionButton";
|
||||
import { ICONS, saveIcon, stringToSVG } from "../../../constants/actionIcons";
|
||||
import { getTrayIcon, ICONS, saveIcon, stringToSVG } from "../../../constants/actionIcons";
|
||||
import { DEVICE, SCRIPT_INSTALL_FOLDER } from "../../../constants/constants";
|
||||
import { insertLaTeXToView, search } from "../../../utils/excalidrawAutomateUtils";
|
||||
import ExcalidrawView, { TextMode } from "../../ExcalidrawView";
|
||||
@@ -580,7 +580,7 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
key={"ui-mode"}
|
||||
title={t("UI_MODE")}
|
||||
action={this.actionToggleTrayMode.bind(this)}
|
||||
icon={ICONS.trayMode}
|
||||
icon={getTrayIcon()}
|
||||
/>
|
||||
<ActionButton
|
||||
key={"fullscreen"}
|
||||
|
||||
@@ -1107,3 +1107,7 @@ textarea.excalidraw-wysiwyg, .excalidraw input {
|
||||
.excalidraw-filetype-tag {
|
||||
order: 99;
|
||||
}
|
||||
|
||||
.excalidraw-mobile-navbar-docked {
|
||||
position: relative;
|
||||
}
|
||||
Reference in new issue
Block a user