diff --git a/manifest.json b/manifest.json
index 6b58536..cc58eb3 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,7 +1,7 @@
{
"id": "obsidian-excalidraw-plugin",
"name": "Excalidraw",
- "version": "1.6.16",
+ "version": "1.6.17",
"minAppVersion": "0.12.16",
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
"author": "Zsolt Viczian",
diff --git a/src/EmbeddedFileLoader.ts b/src/EmbeddedFileLoader.ts
index a291520..c9fc38a 100644
--- a/src/EmbeddedFileLoader.ts
+++ b/src/EmbeddedFileLoader.ts
@@ -3,7 +3,9 @@ import { BinaryFileData, DataURL } from "@zsviczian/excalidraw/types/types";
import { App, MarkdownRenderer, Notice, TFile } from "obsidian";
import {
CASCADIA_FONT,
+ DEFAULT_MD_EMBED_CSS,
fileid,
+ FRONTMATTER_KEY_BORDERCOLOR,
FRONTMATTER_KEY_FONT,
FRONTMATTER_KEY_FONTCOLOR,
FRONTMATTER_KEY_MD_STYLE,
@@ -430,20 +432,29 @@ const convertMarkdownToSVG = async (
frontmatterCSSisAfile = true;
}
}
- if (
- !frontmatterCSSisAfile &&
- plugin.settings.mdCSS &&
- plugin.settings.mdCSS != ""
- ) {
- const f = plugin.app.metadataCache.getFirstLinkpathDest(
- plugin.settings.mdCSS,
- file.path,
- );
- if (f) {
- style += `\n${await plugin.app.vault.read(f)}`;
+ if(!frontmatterCSSisAfile) {
+ if (plugin.settings.mdCSS && plugin.settings.mdCSS !== "") {
+ const f = plugin.app.metadataCache.getFirstLinkpathDest(
+ plugin.settings.mdCSS,
+ file.path,
+ );
+ style += f
+ ? `\n${await plugin.app.vault.read(f)}`
+ : DEFAULT_MD_EMBED_CSS;
+ } else {
+ style += DEFAULT_MD_EMBED_CSS;
}
}
+ const borderColor = fileCache?.frontmatter
+ ? fileCache.frontmatter[FRONTMATTER_KEY_BORDERCOLOR] ??
+ plugin.settings.mdBorderColor
+ : plugin.settings.mdBorderColor;
+
+ if(borderColor && borderColor !== "" && !style.match(/svg/i)) {
+ style += `svg{border:2px solid;color:${borderColor};transform:scale(.95)}`;
+ }
+
//3.
//SVG helper functions
//the SVG will first have ~infinite height. After sizing this will be reduced
@@ -470,9 +481,8 @@ const convertMarkdownToSVG = async (
}
mdDIV.style.overflow = "auto";
mdDIV.style.display = "block";
- if (fontColor && fontColor != "") {
- mdDIV.style.color = fontColor;
- }
+ mdDIV.style.color = (fontColor && fontColor !== "")
+ ? fontColor : "initial";
await MarkdownRenderer.renderMarkdown(text, mdDIV, file.path, plugin);
mdDIV
diff --git a/src/ExcalidrawView.ts b/src/ExcalidrawView.ts
index d874447..edcd70b 100644
--- a/src/ExcalidrawView.ts
+++ b/src/ExcalidrawView.ts
@@ -7,7 +7,6 @@ import {
Notice,
Menu,
MarkdownView,
- ViewStateResult,
} from "obsidian";
import * as React from "react";
import * as ReactDOM from "react-dom";
@@ -52,7 +51,7 @@ import {
import {
checkAndCreateFolder,
checkExcalidrawVersion,
- debug,
+ //debug,
download,
embedFontsInSVG,
errorlog,
@@ -374,8 +373,7 @@ export default class ExcalidrawView extends TextFileView {
if (allowSave) {
await super.save();
- this.semaphores.dirty = null;
- this.diskIcon.querySelector("svg").removeClass("excalidraw-dirty");
+ this.clearDirty();
}
if (!this.semaphores.autosaving) {
@@ -623,7 +621,7 @@ export default class ExcalidrawView extends TextFileView {
).latex;
const prompt = new Prompt(this.app, t("ENTER_LATEX"), equation, "");
prompt.openAndGetValue(async (formula: string) => {
- if (!formula) {
+ if (!formula || formula === equation) {
return;
}
this.excalidrawData.setEquation(selectedImage.fileId, {
@@ -638,6 +636,7 @@ export default class ExcalidrawView extends TextFileView {
addFiles,
this.plugin,
);
+ this.setDirty();
});
return;
}
@@ -657,12 +656,13 @@ export default class ExcalidrawView extends TextFileView {
"Do not add [[square brackets]] around the filename!
Follow this format when editing your link:
filename#^blockref|WIDTHxMAXHEIGHT",
);
prompt.openAndGetValue(async (link: string) => {
- if (!link) {
+ if (!link || ef.linkParts.original === link) {
return;
}
ef.resetImage(this.file.path, link);
await this.save(true);
await this.loadSceneFiles();
+ this.setDirty();
});
return;
}
@@ -881,7 +881,7 @@ export default class ExcalidrawView extends TextFileView {
}
this.diskIcon.querySelector("svg").removeClass("excalidraw-dirty");
if (this.compatibilityMode) {
- this.semaphores.dirty = null;
+ this.clearDirty();
return;
}
if (!this.excalidrawRef) {
@@ -903,7 +903,7 @@ export default class ExcalidrawView extends TextFileView {
this.excalidrawData.scene.appState.theme =
this.excalidrawAPI.getAppState().theme;
await this.loadDrawing(loadOnModifyTrigger);
- this.semaphores.dirty = null;
+ this.clearDirty();
}
zoomToElementId(id:string) {
@@ -1093,8 +1093,7 @@ export default class ExcalidrawView extends TextFileView {
const excalidrawData = this.excalidrawData.scene;
this.semaphores.justLoaded = justloaded;
this.initialContainerSizeUpdate = justloaded;
- this.semaphores.dirty = null;
- this.diskIcon.querySelector("svg").removeClass("excalidraw-dirty");
+ this.clearDirty();
const om = this.excalidrawData.getOpenMode();
this.semaphores.preventReload = false;
if (this.excalidrawRef) {
@@ -1154,8 +1153,7 @@ export default class ExcalidrawView extends TextFileView {
this.plugin.settings.compress !== isCompressed &&
!this.isEditedAsMarkdownInOtherView()
) {
- this.semaphores.dirty = this.file?.path;
- this.diskIcon.querySelector("svg").addClass("excalidraw-dirty");
+ this.setDirty();
}
}
@@ -1168,6 +1166,16 @@ export default class ExcalidrawView extends TextFileView {
);
}
+ public setDirty() {
+ this.semaphores.dirty = this.file?.path;
+ this.diskIcon.querySelector("svg").addClass("excalidraw-dirty");
+ }
+
+ public clearDirty() {
+ this.semaphores.dirty = null;
+ this.diskIcon.querySelector("svg").removeClass("excalidraw-dirty");
+ }
+
public initializeToolsIconPanelAfterLoading() {
const st = this.excalidrawAPI?.getAppState();
const panel = this.toolsPanelRef?.current;
@@ -1334,8 +1342,7 @@ export default class ExcalidrawView extends TextFileView {
private previousBackgroundColor = "";
private instantiateExcalidraw(initdata: any) {
//console.log("ExcalidrawView.instantiateExcalidraw()");
- this.semaphores.dirty = null;
- this.diskIcon.querySelector("svg").removeClass("excalidraw-dirty");
+ this.clearDirty();
const reactElement = React.createElement(() => {
let currentPosition = { x: 0, y: 0 };
const excalidrawWrapperRef = React.useRef(null);
@@ -1665,8 +1672,7 @@ export default class ExcalidrawView extends TextFileView {
if (save) {
await this.save(false); //preventReload=false will ensure that markdown links are paresed and displayed correctly
} else {
- this.semaphores.dirty = this.file?.path;
- this.diskIcon.querySelector("svg").addClass("excalidraw-dirty");
+ this.setDirty();
}
return true;
};
@@ -2088,8 +2094,7 @@ export default class ExcalidrawView extends TextFileView {
) {
this.previousSceneVersion = sceneVersion;
this.previousBackgroundColor = st.viewBackgroundColor;
- this.semaphores.dirty = this.file?.path;
- this.diskIcon.querySelector("svg").addClass("excalidraw-dirty");
+ this.setDirty();
}
}
},
@@ -2300,8 +2305,7 @@ export default class ExcalidrawView extends TextFileView {
if (isDeleted) {
this.excalidrawData.deleteTextElement(textElement.id);
- this.semaphores.dirty = this.file?.path;
- this.diskIcon.querySelector("svg").addClass("excalidraw-dirty");
+ this.setDirty();
return [null, null, null];
}
@@ -2324,8 +2328,7 @@ export default class ExcalidrawView extends TextFileView {
) {
//the user made changes to the text or the text is missing from Excalidraw Data (recently copy/pasted)
//setTextElement will attempt a quick parse (without processing transclusions)
- this.semaphores.dirty = this.file?.path;
- this.diskIcon.querySelector("svg").addClass("excalidraw-dirty");
+ this.setDirty();
const [parseResultWrapped, parseResultOriginal, link] =
this.excalidrawData.setTextElement(
textElement.id,
diff --git a/src/Messages.ts b/src/Messages.ts
index eb305cb..6f664b4 100644
--- a/src/Messages.ts
+++ b/src/Messages.ts
@@ -6,23 +6,63 @@ If you'd like to learn more, please subscribe to my YouTube channel: [Visual PKM
Thank you & Enjoy!
excalidraw-font-color: steelblue',
+ MD_DEFAULT_BORDER_COLOR_NAME:
+ "The default border color to use for embedded markdown files.",
+ MD_DEFAULT_BORDER_COLOR_DESC:
+ 'Set this to any valid css color name e.g. "steelblue" (color names), or a valid hexadecimal color e.g. "#e67700", ' +
+ 'or any other valid css color string. You can override this setting by adding the following frontmatter-key to the embedded markdown file: excalidraw-border-color: gray. ' +
+ "Leave empty if you don't want a border. ",
MD_CSS_NAME: "CSS file",
MD_CSS_DESC:
"The filename of the CSS to apply to markdown embeds. Provide the filename with extension (e.g. 'md-embed.css'). The css file may also be a plain " +
diff --git a/src/settings.ts b/src/settings.ts
index c86b07a..d29c65b 100644
--- a/src/settings.ts
+++ b/src/settings.ts
@@ -72,6 +72,7 @@ export interface ExcalidrawSettings {
mdSVGmaxHeight: number;
mdFont: string;
mdFontColor: string;
+ mdBorderColor: string;
mdCSS: string;
scriptEngineSettings: {};
defaultTrayMode: boolean;
@@ -144,6 +145,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
mdSVGmaxHeight: 800,
mdFont: "Virgil",
mdFontColor: "Black",
+ mdBorderColor: "Black",
mdCSS: "",
scriptEngineSettings: {},
defaultTrayMode: false,
@@ -734,6 +736,20 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
}),
);
+ new Setting(containerEl)
+ .setName(t("MD_DEFAULT_BORDER_COLOR_NAME"))
+ .setDesc(fragWithHTML(t("MD_DEFAULT_BORDER_COLOR_DESC")))
+ .addText((text) =>
+ text
+ .setPlaceholder("CSS Color-name|RGB-HEX")
+ .setValue(this.plugin.settings.mdBorderColor)
+ .onChange((value) => {
+ this.requestReloadDrawings = true;
+ this.plugin.settings.mdBorderColor = value;
+ this.applySettingsUpdate(true);
+ }),
+ );
+
new Setting(containerEl)
.setName(t("MD_CSS_NAME"))
.setDesc(fragWithHTML(t("MD_CSS_DESC")))
diff --git a/versions.json b/versions.json
index 17361de..f389546 100644
--- a/versions.json
+++ b/versions.json
@@ -1,4 +1,4 @@
{
- "1.6.16": "0.12.16",
+ "1.6.17": "0.12.16",
"1.4.2": "0.11.13"
}