mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2025-08-06 05:46:28 +00:00
2.0.7
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.0.6",
|
||||
"version": "2.0.7",
|
||||
"minAppVersion": "1.1.6",
|
||||
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
|
||||
"author": "Zsolt Viczian",
|
||||
|
||||
@@ -18,12 +18,11 @@
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@zsviczian/excalidraw": "0.17.0-obsidian-2",
|
||||
"@zsviczian/excalidraw": "0.17.0-obsidian-3",
|
||||
"chroma-js": "^2.4.2",
|
||||
"clsx": "^2.0.0",
|
||||
"colormaster": "^1.2.1",
|
||||
"gl-matrix": "^3.4.3",
|
||||
"lz-string": "^1.5.0",
|
||||
"monkey-around": "^2.3.0",
|
||||
"polybooljs": "^1.2.0",
|
||||
"react": "^18.2.0",
|
||||
@@ -35,6 +34,7 @@
|
||||
"lucide-react": "^0.263.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"lz-string": "^1.5.0",
|
||||
"@babel/core": "^7.22.9",
|
||||
"@babel/preset-env": "^7.22.10",
|
||||
"@babel/preset-react": "^7.22.5",
|
||||
@@ -63,7 +63,8 @@
|
||||
"rollup-plugin-web-worker-loader": "^1.6.1",
|
||||
"tslib": "^2.6.1",
|
||||
"ttypescript": "^1.5.15",
|
||||
"typescript": "^5.2.2"
|
||||
"typescript": "^5.2.2",
|
||||
"mathjax-full": "3.2.1"
|
||||
},
|
||||
"resolutions": {
|
||||
"@typescript-eslint/typescript-estree": "5.3.0"
|
||||
|
||||
@@ -25,16 +25,22 @@ const reactdom_pkg = isLib ? "" : isProd
|
||||
? fs.readFileSync("./node_modules/react-dom/umd/react-dom.production.min.js", "utf8")
|
||||
: fs.readFileSync("./node_modules/react-dom/umd/react-dom.development.js", "utf8");
|
||||
const lzstring_pkg = isLib ? "" : fs.readFileSync("./node_modules/lz-string/libs/lz-string.min.js", "utf8");
|
||||
const mathjax_pkg = isLib ? "" : fs.readFileSync("./node_modules/mathjax-full/es5/tex-svg-full.js", "utf8");
|
||||
|
||||
const manifestStr = isLib ? "" : fs.readFileSync("manifest.json", "utf-8");
|
||||
const manifest = isLib ? {} : JSON.parse(manifestStr);
|
||||
!isLib && console.log(manifest.version);
|
||||
|
||||
const packageString = isLib ? "" : ';'+lzstring_pkg+'const EXCALIDRAW_PACKAGES = "' + LZString.compressToBase64(react_pkg + reactdom_pkg + excalidraw_pkg) + '";' +
|
||||
'const {react, reactDOM, excalidrawLib} = window.eval.call(window, `(function() {' +
|
||||
'${LZString.decompressFromBase64(EXCALIDRAW_PACKAGES)};' +
|
||||
'return {react:React, reactDOM:ReactDOM, excalidrawLib: ExcalidrawLib};})();`);' +
|
||||
'const PLUGIN_VERSION="'+manifest.version+'";';
|
||||
const packageString = isLib
|
||||
? ""
|
||||
: ';' + lzstring_pkg +
|
||||
'const MATHJAX_SOURCE_LZCOMPRESSED = "' +
|
||||
LZString.compressToBase64(btoa(unescape(encodeURIComponent(mathjax_pkg.replaceAll("MathJax","ExcalidrawMathJax"))))) + '";' +
|
||||
'const EXCALIDRAW_PACKAGES = "' + LZString.compressToBase64(react_pkg + reactdom_pkg + excalidraw_pkg) + '";' +
|
||||
'const {react, reactDOM, excalidrawLib} = window.eval.call(window, `(function() {' +
|
||||
'${LZString.decompressFromBase64(EXCALIDRAW_PACKAGES)};' +
|
||||
'return {react:React, reactDOM:ReactDOM, excalidrawLib: ExcalidrawLib};})();`);' +
|
||||
'const PLUGIN_VERSION="'+manifest.version+'";';
|
||||
|
||||
const BASE_CONFIG = {
|
||||
input: 'src/main.ts',
|
||||
|
||||
@@ -79,14 +79,13 @@ import { ClipboardData } from "@zsviczian/excalidraw/types/clipboard";
|
||||
import { emulateKeysForLinkClick, KeyEvent, PaneTarget } from "src/utils/ModifierkeyHelper";
|
||||
import { Mutable } from "@zsviczian/excalidraw/types/utility-types";
|
||||
import PolyBool from "polybooljs";
|
||||
import { compressToBase64, decompressFromBase64 } from "lz-string";
|
||||
//import { compressToBase64, decompressFromBase64 } from "lz-string";
|
||||
import { EmbeddableMDCustomProps } from "./dialogs/EmbeddableSettings";
|
||||
import {
|
||||
AIRequest,
|
||||
postOpenAI as _postOpenAI,
|
||||
extractCodeBlocks as _extractCodeBlocks,
|
||||
} from "./utils/AIUtils";
|
||||
import ExcalidrawScene from "./svgToExcalidraw/elements/ExcalidrawScene";
|
||||
|
||||
extendPlugins([
|
||||
HarmonyPlugin,
|
||||
@@ -105,6 +104,7 @@ extendPlugins([
|
||||
]);
|
||||
|
||||
declare const PLUGIN_VERSION:string;
|
||||
declare var LZString: any;
|
||||
|
||||
const GAP = 4;
|
||||
|
||||
@@ -200,11 +200,11 @@ export class ExcalidrawAutomate {
|
||||
}
|
||||
|
||||
public compressToBase64(str:string):string {
|
||||
return compressToBase64(str);
|
||||
return LZString.compressToBase64(str);
|
||||
}
|
||||
|
||||
public decompressFromBase64(str:string):string {
|
||||
return decompressFromBase64(str);
|
||||
return LZString.decompressFromBase64(str);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -928,7 +928,10 @@ export default class ExcalidrawView extends TextFileView {
|
||||
if (partsArray.length > 1) {
|
||||
parts = await ScriptEngine.suggester(
|
||||
this.app,
|
||||
partsArray.filter(p=>Boolean(p.value)).map(p => REGEX_LINK.getLink(p)),
|
||||
partsArray.filter(p=>Boolean(p.value)).map(p => {
|
||||
const alias = REGEX_LINK.getAliasOrLink(p);
|
||||
return alias === "100%" ? REGEX_LINK.getLink(p) : alias;
|
||||
}),
|
||||
partsArray.filter(p=>Boolean(p.value)),
|
||||
"Select link to open"
|
||||
);
|
||||
@@ -1074,6 +1077,19 @@ export default class ExcalidrawView extends TextFileView {
|
||||
}
|
||||
}
|
||||
|
||||
let secondOrderLinks: string = " ";
|
||||
|
||||
const backlinks = this.app.metadataCache?.getBacklinksForFile(ef.file)?.data;
|
||||
if(backlinks) {
|
||||
const linkPaths = Object.keys(backlinks)
|
||||
.filter(path => (path !== this.file.path) && (path !== ef.file.path))
|
||||
.map(path => {
|
||||
const filepathParts = splitFolderAndFilename(path);
|
||||
return `[[${path}|Second Order Link: ${filepathParts.basename}]]`;
|
||||
});
|
||||
secondOrderLinks += linkPaths.join(" ");
|
||||
}
|
||||
|
||||
const linkString = (ef.isHyperLink || ef.isLocalLink
|
||||
? `[](${ef.hyperlink}) `
|
||||
: `[[${ef.linkParts.original}]] `
|
||||
@@ -1083,7 +1099,7 @@ export default class ExcalidrawView extends TextFileView {
|
||||
: imageElement.link
|
||||
: "");
|
||||
|
||||
const result = await this.linkPrompt(linkString);
|
||||
const result = await this.linkPrompt(linkString + secondOrderLinks);
|
||||
if(!result) return;
|
||||
[file, linkText, subpath] = result;
|
||||
|
||||
|
||||
@@ -17,6 +17,25 @@ I develop this plugin as a hobby, spending my free time doing this. If you find
|
||||
|
||||
<div class="ex-coffee-div"><a href="https://ko-fi.com/zsolt"><img src="https://cdn.ko-fi.com/cdn/kofi3.png?v=3" height=45></a></div>
|
||||
`,
|
||||
"2.0.7":`
|
||||
<div class="excalidraw-videoWrapper"><div>
|
||||
<iframe src="https://www.youtube.com/embed/kp1K7GRrE6E" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
||||
</div></div>
|
||||
|
||||
# Fixed
|
||||
- The Android and iOS crash with 2.0.5 😰. I can't apologize enough for releasing a version that I did not properly test on Android and iOS. That ought to teach me something about last-minute changes before hitting release.
|
||||
- Scaled-resizing a sticky note (SHIFT+resize) caused Excalidraw to choke on slower devices
|
||||
- Improved plugin performance focusing on minimizing Excalidraw's effect on Obsidian overall
|
||||
- Images embedded with a URL often did not show up in image exports, hopefully, the issue will less frequently occur in the future.
|
||||
- Local file URL now follows Obsidian standard - making it easier to navigate in Markdown view mode.
|
||||
|
||||
# New
|
||||
- Bonus feature compared to 2.0.4: Second-order links when clicking embedded images. I use images to connect ideas. Clicking on an image and seeing all the connections immediately is very powerful.
|
||||
- In plugin settings, under "Startup Script", the button now opens the startup script if it already exists.
|
||||
- Partial support for animated GIFs (will not show up in image exports, but can be added as interactive embeddables)
|
||||
- Configurable modifier keys for link click action and drag&drop actions.
|
||||
- Improved support for drag&drop from your local drive and embedding of files external to Excalidraw.
|
||||
`,
|
||||
"2.0.5":`
|
||||
<div class="excalidraw-videoWrapper"><div>
|
||||
<iframe src="https://www.youtube.com/embed/kp1K7GRrE6E" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
||||
|
||||
10
src/main.ts
10
src/main.ts
@@ -106,7 +106,7 @@ import {
|
||||
|
||||
import { FieldSuggester } from "./dialogs/FieldSuggester";
|
||||
import { ReleaseNotes } from "./dialogs/ReleaseNotes";
|
||||
import { decompressFromBase64 } from "lz-string";
|
||||
//import { decompressFromBase64 } from "lz-string";
|
||||
import { Packages } from "./types";
|
||||
import { PreviewImageType } from "./utils/UtilTypes";
|
||||
import { ScriptInstallPrompt } from "./dialogs/ScriptInstallPrompt";
|
||||
@@ -117,7 +117,7 @@ import { ExportDialog } from "./dialogs/ExportDialog";
|
||||
import { UniversalInsertFileModal } from "./dialogs/UniversalInsertFileModal";
|
||||
import { imageCache } from "./utils/ImageCache";
|
||||
import { StylesManager } from "./utils/StylesManager";
|
||||
import { MATHJAX_SOURCE_LZCOMPRESSED } from "./constants/constMathJaxSource";
|
||||
//import { MATHJAX_SOURCE_LZCOMPRESSED } from "./constants/constMathJaxSource";
|
||||
import { PublishOutOfDateFilesDialog } from "./dialogs/PublishOutOfDateFiles";
|
||||
import { EmbeddableSettings } from "./dialogs/EmbeddableSettings";
|
||||
import { processLinkText } from "./utils/CustomEmbeddableUtils";
|
||||
@@ -132,6 +132,8 @@ declare const react:any;
|
||||
declare const reactDOM:any;
|
||||
declare const excalidrawLib: any;
|
||||
declare const PLUGIN_VERSION:string;
|
||||
declare const MATHJAX_SOURCE_LZCOMPRESSED:string;
|
||||
declare var LZString: any;
|
||||
|
||||
export default class ExcalidrawPlugin extends Plugin {
|
||||
public taskbone: Taskbone;
|
||||
@@ -200,7 +202,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
//@ts-ignore
|
||||
const {react:r, reactDOM:rd, excalidrawLib:e} = win.eval.call(win,
|
||||
`(function() {
|
||||
${decompressFromBase64(EXCALIDRAW_PACKAGES)};
|
||||
${LZString.decompressFromBase64(EXCALIDRAW_PACKAGES)};
|
||||
return {react:React,reactDOM:ReactDOM,excalidrawLib:ExcalidrawLib};
|
||||
})()`);
|
||||
this.packageMap.set(win,{react:r, reactDOM:rd, excalidrawLib:e});
|
||||
@@ -416,7 +418,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
self.mathjaxLoaderFinished = true;
|
||||
});
|
||||
};
|
||||
script.src = "data:text/javascript;base64," + decompressFromBase64(MATHJAX_SOURCE_LZCOMPRESSED); //self.settings.mathjaxSourceURL; // "https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg.js";
|
||||
script.src = "data:text/javascript;base64," + LZString.decompressFromBase64(MATHJAX_SOURCE_LZCOMPRESSED); //self.settings.mathjaxSourceURL; // "https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg.js";
|
||||
//script.src = MATHJAX_DATAURL;
|
||||
document.head.appendChild(script);
|
||||
} catch {
|
||||
|
||||
3
src/types.d.ts
vendored
3
src/types.d.ts
vendored
@@ -58,4 +58,7 @@ declare module "obsidian" {
|
||||
interface Editor {
|
||||
insertText(data: string): void;
|
||||
}
|
||||
interface MetadataCache {
|
||||
getBacklinksForFile(file: TFile): any;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { DataURL } from "@zsviczian/excalidraw/types/types";
|
||||
import { loadPdfJs, normalizePath, Notice, requestUrl, RequestUrlResponse, TAbstractFile, TFile, TFolder, Vault } from "obsidian";
|
||||
import { URLFETCHTIMEOUT } from "src/constants/constants";
|
||||
import { DEVICE, URLFETCHTIMEOUT } from "src/constants/constants";
|
||||
import { IMAGE_MIME_TYPES, MimeType } from "src/EmbeddedFileLoader";
|
||||
import { ExcalidrawSettings } from "src/settings";
|
||||
import { errorlog, getDataURL } from "./Utils";
|
||||
@@ -295,6 +295,7 @@ export const getPDFDoc = async (f: TFile): Promise<any> => {
|
||||
}
|
||||
|
||||
export const readLocalFile = async (filePath:string): Promise<string> => {
|
||||
if (!DEVICE.isDesktop) return null;
|
||||
return new Promise((resolve, reject) => {
|
||||
//@ts-ignore
|
||||
app.vault.adapter.fs.readFile(filePath, 'utf8', (err:any, data:any) => {
|
||||
@@ -308,6 +309,7 @@ export const readLocalFile = async (filePath:string): Promise<string> => {
|
||||
}
|
||||
|
||||
export const readLocalFileBinary = async (filePath:string): Promise<ArrayBuffer> => {
|
||||
if (!DEVICE.isDesktop) return null;
|
||||
return new Promise((resolve, reject) => {
|
||||
const path = decodeURI(filePath);
|
||||
//@ts-ignore
|
||||
@@ -327,10 +329,18 @@ export const getPathWithoutExtension = (f:TFile): string => {
|
||||
return f.path.substring(0, f.path.lastIndexOf("."));
|
||||
}
|
||||
|
||||
const VAULT_BASE_URL = app.vault.adapter.url.pathToFileURL(app.vault.adapter.basePath).toString();
|
||||
debugger;
|
||||
const VAULT_BASE_URL = DEVICE.isDesktop
|
||||
? app.vault.adapter.url.pathToFileURL(app.vault.adapter.basePath).toString()
|
||||
: "";
|
||||
export const getInternalLinkOrFileURLLink = (
|
||||
path: string, plugin:ExcalidrawPlugin, alias?: string, sourceFile?: TFile
|
||||
):{link: string, isInternal: boolean, file?: TFile, url?: string} => {
|
||||
):{link: string, isInternal: boolean, file?: TFile, url?: string} => {
|
||||
if(!DEVICE.isDesktop) {
|
||||
//I've not tested this... don't even know if external drag and drop works on mobile
|
||||
//Added this for safety
|
||||
return {link: `[${alias??""}](${path})`, isInternal: false, url: path};
|
||||
}
|
||||
const vault = plugin.app.vault;
|
||||
const fileURLString = vault.adapter.url.pathToFileURL(path).toString();
|
||||
if (fileURLString.startsWith(VAULT_BASE_URL)) {
|
||||
@@ -343,7 +353,7 @@ export const getInternalLinkOrFileURLLink = (
|
||||
true,
|
||||
);
|
||||
return {link: getLink(plugin, { embed: false, path: link, alias}), isInternal: true, file};
|
||||
};
|
||||
};
|
||||
}
|
||||
return {link: `[${alias??""}](${fileURLString})`, isInternal: false, url: fileURLString};
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
import ExcalidrawPlugin from "../main";
|
||||
import { ExcalidrawElement } from "@zsviczian/excalidraw/types/element/types";
|
||||
import { ExportSettings } from "../ExcalidrawView";
|
||||
import { compressToBase64, decompressFromBase64 } from "lz-string";
|
||||
//import { compressToBase64, decompressFromBase64 } from "lz-string";
|
||||
import { getDataURLFromURL, getIMGFilename, getMimeType, getURLImageExtension } from "./FileUtils";
|
||||
import { generateEmbeddableLink } from "./CustomEmbeddableUtils";
|
||||
import ExcalidrawScene from "src/svgToExcalidraw/elements/ExcalidrawScene";
|
||||
@@ -38,6 +38,7 @@ import { updateElementLinksToObsidianLinks } from "src/ExcalidrawAutomate";
|
||||
|
||||
|
||||
declare const PLUGIN_VERSION:string;
|
||||
declare var LZString: any;
|
||||
|
||||
declare module "obsidian" {
|
||||
interface Workspace {
|
||||
@@ -515,11 +516,11 @@ export const getLinkParts = (fname: string, file?: TFile): LinkParts => {
|
||||
};
|
||||
|
||||
export const compress = (data: string): string => {
|
||||
return compressToBase64(data).replace(/(.{64})/g, "$1\n\n");
|
||||
return LZString.compressToBase64(data).replace(/(.{64})/g, "$1\n\n");
|
||||
};
|
||||
|
||||
export const decompress = (data: string): string => {
|
||||
return decompressFromBase64(data.replaceAll("\n", "").replaceAll("\r", ""));
|
||||
return LZString.decompressFromBase64(data.replaceAll("\n", "").replaceAll("\r", ""));
|
||||
};
|
||||
|
||||
export const hasExportTheme = (
|
||||
|
||||
Reference in New Issue
Block a user