mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2026-11-27 06:32:42 +00:00
Compare commits
6
Commits
toggleViewMode
...
2.28.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
128a9ef47b | ||
|
|
96bd2212c2 | ||
|
|
3d8f312add | ||
|
|
bd40308a83 | ||
|
|
3e13b61c6d | ||
|
|
5da2b452f1 |
No files matched your search
@@ -54,6 +54,8 @@ Follow Obsidian's **Developer Policies** and **Plugin Guidelines**. In particula
|
||||
|
||||
- Default to local/offline operation. Only make network requests when essential to the feature.
|
||||
- No hidden telemetry. If you collect optional analytics or call third-party services, require explicit opt-in and document clearly in `README.md` and in settings.
|
||||
- Keep every external origin and every fully static URL as a literal `https://...` string in source so reviewers and security scanners can identify the destination without executing the code. A dynamic resource path may be appended only to a literal base URL, and each untrusted path segment must be validated or encoded.
|
||||
- Never conceal a network destination or evade a scanner finding by splitting or joining domain labels, deriving an origin from Git state, environment variables, runtime configuration, or character codes, or by encoding, compressing, encrypting, or otherwise transforming a URL. Do not weaken, suppress, or work around a scanner by making an endpoint less statically visible; fix the underlying behavior or document a genuine false positive transparently.
|
||||
- Never execute remote code, fetch and eval scripts, or auto-update plugin code outside of normal releases.
|
||||
- Minimize scope: read/write only what's necessary inside the vault. Do not access files outside the vault.
|
||||
- Clearly disclose any external services used, data sent, and risks.
|
||||
@@ -310,11 +312,11 @@ Window ownership for rendering is not the same as ownership for persistent plugi
|
||||
- `src/lang/helpers.ts` resolves those tokens at runtime.
|
||||
- If you add new runtime-dependent locale patterns, you must keep `rollup.config.mjs` and `src/lang/helpers.ts` in sync.
|
||||
|
||||
### Safe URL Tokenization
|
||||
### Safe URL Handling
|
||||
|
||||
- Safe URLs are centralized in `src/constants/safeUrls.ts`.
|
||||
- The build tokenizes URL constants and resolves them at runtime.
|
||||
- If you change safe URL handling, rebuild and verify both token emission and token resolution.
|
||||
- Preserve literal, statically reviewable origins and complete static URLs. Only repository-relative or resource-relative paths may be constructed dynamically from validated or encoded path segments.
|
||||
- If you change safe URL handling, rebuild and verify that the intended literal origins remain visible in both source and `dist/main.js`, and search for domain assembly or endpoint-obfuscation patterns before release.
|
||||
|
||||
### Versioning Nuance
|
||||
|
||||
@@ -507,6 +509,12 @@ If a task touches any of the above, read adjacent code first and validate more c
|
||||
|
||||
There is no standard unit-test suite wired into `package.json`.
|
||||
|
||||
### Obsidian CLI runtime lane
|
||||
|
||||
Follow [the runtime testing proxy](docs/OBSIDIAN_RUNTIME_TESTING.md) and its linked fork guide for a native check. `npm run test:obsidian:runner` runs the test-vault guard and harness tests without Obsidian. `npm run verify:obsidian` requires the explicitly configured `excalidraw-test` vault, checks the CLI-selected path before deployment, builds the sibling fork's four Obsidian artifacts and this plugin, stages the exact `main.js`/CSS/manifest, and asserts a live drawing and clean JavaScript error buffer. Review its report and cleanup result.
|
||||
|
||||
Use this lane after fork behavior or packaging changes when Obsidian is available, then exercise the affected workflow using the fork's V03–V11 validation gates. A blank-drawing smoke does not validate raw text, clipboard, font/image assets, saved scenes, custom pens, popout migration, offline behavior, or physical mobile touch. Record what was tested, artifact/source identity, and any pending or unavailable gates. Never deploy a local build to a personal/default vault as a substitute for the named test vault. Keep CLI eval access to internal plugin instances and temporary test controllers out of production modules.
|
||||
|
||||
Repo-wide ESLint currently reports a large backlog of pre-existing issues, so it is not yet a blocking pass/fail gate for every task.
|
||||
|
||||
Primary validation commands:
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# Obsidian runtime testing
|
||||
|
||||
The canonical Excalidraw fork and plugin CLI procedure is [Testing the fork inside Obsidian](https://github.com/zsviczian/excalidraw/blob/master/dev-docs/Obsidian/OBSIDIAN_RUNTIME_TESTING.md) (local sibling path: `../excalidraw/dev-docs/Obsidian/OBSIDIAN_RUNTIME_TESTING.md`). Read its vault guards, exact-build deployment steps, report contract, and feature-gate guidance before running the host lane.
|
||||
|
||||
From this plugin checkout, with the dedicated `excalidraw-test` vault open and the three `EXCALIDRAW_TEST_VAULT_*` variables set as described there:
|
||||
|
||||
```bash
|
||||
npm run test:obsidian:runner
|
||||
npm run verify:obsidian
|
||||
```
|
||||
|
||||
The first command tests the runner without Obsidian. The second builds the sibling fork and this plugin, deploys only to the explicitly checked test vault, exercises one drawing, and writes a report. It is a desktop smoke, so run the change-specific scenarios from the canonical guide as well.
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.28.0-beta.4",
|
||||
"version": "2.28.1",
|
||||
"minAppVersion": "1.8.7",
|
||||
"description": "Sketch Your Mind. Edit and view Excalidraw drawings. Enter the world of 4D Visual PKM.",
|
||||
"author": "Zsolt Viczian",
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.27.3",
|
||||
"version": "2.28.1",
|
||||
"minAppVersion": "1.8.7",
|
||||
"description": "Sketch Your Mind. Edit and view Excalidraw drawings. Enter the world of 4D Visual PKM.",
|
||||
"author": "Zsolt Viczian",
|
||||
|
||||
Generated
+4
-4
@@ -13,7 +13,7 @@
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"@radix-ui/number": "^1.1.2",
|
||||
"@zsviczian/colormaster": "^1.2.2",
|
||||
"@zsviczian/excalidraw": "0.18.139",
|
||||
"@zsviczian/excalidraw": "0.18.140",
|
||||
"chroma-js": "^3.1.2",
|
||||
"clsx": "^2.0.0",
|
||||
"es6-promise-pool": "2.5.0",
|
||||
@@ -5255,9 +5255,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@zsviczian/excalidraw": {
|
||||
"version": "0.18.139",
|
||||
"resolved": "https://registry.npmjs.org/@zsviczian/excalidraw/-/excalidraw-0.18.139.tgz",
|
||||
"integrity": "sha512-3d31zicckBIK4VMyldgCLuPON5xCWNTxn0vF1r3FdlVbfLXI+OFdeq6Qog8aYO4IXN2W5XKdIF5Byzk17U4Aqg==",
|
||||
"version": "0.18.140",
|
||||
"resolved": "https://registry.npmjs.org/@zsviczian/excalidraw/-/excalidraw-0.18.140.tgz",
|
||||
"integrity": "sha512-DXdxSFVkyVXYBDIlq63IfoegKRZYp71ECSPErSZASxcssKyKOcbiDjI/EjO4nnsvhampnr8mrlLPBjsQyoRTKQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@braintree/sanitize-url": "6.0.2",
|
||||
|
||||
+5
-3
@@ -9,7 +9,9 @@
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "cross-env NODE_ENV=development rollup --config rollup.config.mjs",
|
||||
"build": "cross-env NODE_ENV=production rollup --config rollup.config.mjs",
|
||||
"build": "cross-env NODE_ENV=production rollup --config rollup.config.mjs",
|
||||
"test:obsidian:runner": "node --test scripts/testing/host/runner.test.mjs",
|
||||
"verify:obsidian": "node scripts/testing/host/verify.mjs",
|
||||
"lib": "cross-env NODE_ENV=lib rollup --config rollup.config.mjs",
|
||||
"code": "eslint --max-warnings=0 --ext .ts,.tsx ./src",
|
||||
"code:fix": "eslint --max-warnings=0 --ext .ts,.tsx ./src --fix",
|
||||
@@ -34,7 +36,7 @@
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"@radix-ui/number": "^1.1.2",
|
||||
"@zsviczian/colormaster": "^1.2.2",
|
||||
"@zsviczian/excalidraw": "0.18.139",
|
||||
"@zsviczian/excalidraw": "0.18.140",
|
||||
"chroma-js": "^3.1.2",
|
||||
"clsx": "^2.0.0",
|
||||
"es6-promise-pool": "2.5.0",
|
||||
@@ -111,4 +113,4 @@
|
||||
"node": ">=22.0.0",
|
||||
"npm": ">=10.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-57
@@ -1,5 +1,4 @@
|
||||
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import zlib from 'node:zlib';
|
||||
import visualizer from 'rollup-plugin-visualizer';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
@@ -33,59 +32,7 @@ const absolutePath = path.resolve(DIST_FOLDER);
|
||||
fs.mkdirSync(absolutePath, { recursive: true });
|
||||
const isProd = (process.env.NODE_ENV === "production");
|
||||
const isLib = (process.env.NODE_ENV === "lib");
|
||||
|
||||
const DEFAULT_PLUGIN_REPOSITORY = {
|
||||
owner: "zsviczian",
|
||||
name: "obsidian-excalidraw-plugin",
|
||||
ref: "master",
|
||||
};
|
||||
|
||||
const resolvePluginRepositoryContext = () => {
|
||||
const repository = { ...DEFAULT_PLUGIN_REPOSITORY };
|
||||
|
||||
try {
|
||||
const remoteUrl = execFileSync("git", ["remote", "get-url", "origin"], {
|
||||
cwd: process.cwd(),
|
||||
encoding: "utf8",
|
||||
stdio: ["ignore", "pipe", "ignore"],
|
||||
}).trim();
|
||||
const match = remoteUrl.match(
|
||||
/github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?$/i,
|
||||
);
|
||||
if (match) {
|
||||
repository.owner = match[1];
|
||||
repository.name = match[2];
|
||||
}
|
||||
|
||||
const branch = execFileSync("git", ["branch", "--show-current"], {
|
||||
cwd: process.cwd(),
|
||||
encoding: "utf8",
|
||||
stdio: ["ignore", "pipe", "ignore"],
|
||||
}).trim();
|
||||
if (branch) {
|
||||
repository.ref = branch;
|
||||
return repository;
|
||||
}
|
||||
|
||||
const commit = execFileSync("git", ["rev-parse", "HEAD"], {
|
||||
cwd: process.cwd(),
|
||||
encoding: "utf8",
|
||||
stdio: ["ignore", "pipe", "ignore"],
|
||||
}).trim();
|
||||
if (commit) {
|
||||
repository.ref = commit;
|
||||
}
|
||||
} catch {
|
||||
// Source archives do not include .git. Keep canonical release defaults.
|
||||
}
|
||||
|
||||
return repository;
|
||||
};
|
||||
|
||||
const pluginRepository = resolvePluginRepositoryContext();
|
||||
console.log(
|
||||
`Running: ${process.env.NODE_ENV}; isProd: ${isProd}; isLib: ${isLib}; repository: ${pluginRepository.owner}/${pluginRepository.name}@${pluginRepository.ref}`,
|
||||
);
|
||||
console.log(`Running: ${process.env.NODE_ENV}; isProd: ${isProd}; isLib: ${isLib}`);
|
||||
|
||||
|
||||
// Add non-English locales here to embed them as compressed payloads in main.js.
|
||||
@@ -354,9 +301,6 @@ const getRollupPlugins = (tsconfig, ...plugins) => [
|
||||
replace({
|
||||
preventAssignment: true,
|
||||
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
|
||||
__PLUGIN_REPOSITORY_OWNER__: JSON.stringify(pluginRepository.owner),
|
||||
__PLUGIN_REPOSITORY_NAME__: JSON.stringify(pluginRepository.name),
|
||||
__PLUGIN_REPOSITORY_REF__: JSON.stringify(pluginRepository.ref),
|
||||
}),
|
||||
commonjs(),
|
||||
nodeResolve({ browser: true, preferBuiltins: false }),
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
/** Native Obsidian smoke lane for the exact locally built Excalidraw plugin. */
|
||||
import { createHash, randomUUID } from "node:crypto";
|
||||
import { copyFileSync, existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
||||
import { basename, isAbsolute, join, relative, sep } from "node:path";
|
||||
|
||||
export const PLUGIN_ID = "obsidian-excalidraw-plugin";
|
||||
export const ARTIFACTS = ["main.js", "manifest.json", "styles.css"];
|
||||
const REQUIRED_CLI = ["version", "vault", "plugin:enable", "plugin:disable", "commands", "eval", "dev:errors"];
|
||||
const CONTROL = "__excalidrawCliSmoke";
|
||||
const PREFIX = "__excalidraw_cli_smoke_";
|
||||
|
||||
const hash = (path) => createHash("sha256").update(readFileSync(path)).digest("hex");
|
||||
|
||||
function inside(parent, child, label) {
|
||||
const rel = relative(parent, child);
|
||||
if (!rel || rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {
|
||||
throw new Error(`${label} must be inside the selected test vault`);
|
||||
}
|
||||
}
|
||||
|
||||
/** Reject ambiguous or redirected vault and plugin paths before any deployment. */
|
||||
export function validateTarget({ vaultName, vaultPath, configDir }) {
|
||||
if (!vaultName || !vaultPath || !configDir) {
|
||||
throw new Error("Set EXCALIDRAW_TEST_VAULT_NAME, EXCALIDRAW_TEST_VAULT_PATH and EXCALIDRAW_TEST_CONFIG_DIR");
|
||||
}
|
||||
if (vaultName !== "excalidraw-test") throw new Error("This runner is restricted to the excalidraw-test vault");
|
||||
if (!isAbsolute(vaultPath) || !isAbsolute(configDir)) throw new Error("Vault and config paths must be absolute");
|
||||
if (!existsSync(vaultPath) || !existsSync(configDir)) throw new Error("Vault or config directory does not exist");
|
||||
const vault = realpathSync(vaultPath);
|
||||
const config = realpathSync(configDir);
|
||||
if (basename(vault) !== vaultName) throw new Error("Vault folder does not match the selected vault name");
|
||||
inside(vault, config, "Config directory");
|
||||
if (!existsSync(join(config, "community-plugins.json"))) {
|
||||
throw new Error("Community plugins must be configured in this test vault");
|
||||
}
|
||||
const plugins = join(config, "plugins");
|
||||
if (existsSync(plugins) && lstatSync(plugins).isSymbolicLink()) throw new Error("Plugin directory cannot be a symlink");
|
||||
const pluginDir = join(plugins, PLUGIN_ID);
|
||||
if (existsSync(pluginDir) && lstatSync(pluginDir).isSymbolicLink()) throw new Error("Target plugin cannot be a symlink");
|
||||
for (const name of ARTIFACTS) {
|
||||
const file = join(pluginDir, name);
|
||||
if (existsSync(file) && lstatSync(file).isSymbolicLink()) throw new Error(`Target artifact cannot be a symlink: ${name}`);
|
||||
}
|
||||
return { vault, config, pluginDir };
|
||||
}
|
||||
|
||||
function cliPath(output) {
|
||||
const path = output.trim();
|
||||
return path.startsWith("path ") ? path.slice(5).trim() : path;
|
||||
}
|
||||
|
||||
function parseEval(output) {
|
||||
const value = output.trim().replace(/^=>\s*/, "");
|
||||
if (value.startsWith("Error:")) throw new Error(`Obsidian eval failed: ${value.slice(0, 500)}`);
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
} catch {
|
||||
throw new Error(`Obsidian eval returned non-JSON: ${value.slice(0, 500)}`);
|
||||
}
|
||||
}
|
||||
|
||||
function artifacts(projectRoot) {
|
||||
const paths = Object.fromEntries(ARTIFACTS.map((name) => [name, join(projectRoot, "dist", name)]));
|
||||
for (const [name, path] of Object.entries(paths)) {
|
||||
if (!existsSync(path)) throw new Error(`Missing built ${name}: ${path}`);
|
||||
}
|
||||
const manifest = JSON.parse(readFileSync(paths["manifest.json"], "utf8"));
|
||||
if (manifest.id !== PLUGIN_ID) throw new Error(`Built manifest ID must be ${PLUGIN_ID}`);
|
||||
return { paths, hashes: Object.fromEntries(ARTIFACTS.map((name) => [name, hash(paths[name])])), version: manifest.version };
|
||||
}
|
||||
|
||||
const startCode = (name) => `(()=>{const p=app.plugins.plugins[${JSON.stringify(PLUGIN_ID)}];if(!p)return JSON.stringify({state:"failed",error:"plugin not loaded"});if(globalThis.${CONTROL})return JSON.stringify({state:"failed",error:"smoke controller already exists"});const c={state:"pending",name:${JSON.stringify(name)},path:null,error:null,cancel:false};globalThis.${CONTROL}=c;const extension=p.settings.compatibilityMode?".excalidraw":p.settings.useExcalidrawExtension?".excalidraw.md":".md";Promise.resolve(p.createAndOpenDrawing(c.name+extension,"new-tab")).then(async path=>{c.path=path;c.state="created";if(c.cancel){const file=app.vault.getFileByPath(path);if(file&&file.name.startsWith(${JSON.stringify(PREFIX)})){app.workspace.getLeavesOfType("excalidraw").find(l=>l.view.file?.path===path)?.detach();await app.vault.delete(file)}c.state="clean"}}).catch(error=>{c.error=String(error);c.state="failed"});return JSON.stringify({state:"started"})})()`;
|
||||
const statusCode = `(()=>{const c=globalThis.${CONTROL};if(!c)return JSON.stringify({state:"missing"});const leaf=c.path&&app.workspace.getLeavesOfType("excalidraw").find(l=>l.view.file?.path===c.path);const view=leaf?.view;return JSON.stringify({state:c.state,path:c.path,error:c.error,ready:!!view?.excalidrawAPI,wrapper:!!view?.containerEl?.querySelector(".excalidraw-wrapper"),ownerMatches:!!view&&view.ownerDocument===view.containerEl.ownerDocument,mainWindow:!!view&&view.ownerDocument===app.workspace.containerEl?.ownerDocument})})()`;
|
||||
const cleanupCode = `(()=>{const c=globalThis.${CONTROL};if(!c)return JSON.stringify({state:"clean"});if(c.state==="pending"){c.cancel=true;return JSON.stringify({state:"pending"})}if(c.state==="cleaning")return JSON.stringify({state:"cleaning"});const path=c.path;const file=path&&app.vault.getFileByPath(path);if(!file){delete globalThis.${CONTROL};return JSON.stringify({state:"clean"})}if(!file.name.startsWith(${JSON.stringify(PREFIX)}))return JSON.stringify({state:"failed",error:"refusing to delete a non-smoke drawing"});const leaf=app.workspace.getLeavesOfType("excalidraw").find(l=>l.view.file?.path===path);leaf?.detach();c.state="cleaning";Promise.resolve(app.vault.delete(file)).then(()=>{c.state="clean"},error=>{c.error=String(error);c.state="failed"});return JSON.stringify({state:"cleaning"})})()`;
|
||||
|
||||
async function poll(read, acceptable, wait, now, timeoutMs = 20_000) {
|
||||
const deadline = now() + timeoutMs;
|
||||
for (;;) {
|
||||
const result = read();
|
||||
if (acceptable(result)) return result;
|
||||
if (result.state === "failed") throw new Error(result.error || "Host scenario failed");
|
||||
if (now() >= deadline) throw new Error(`Host scenario timed out: ${JSON.stringify(result)}`);
|
||||
await wait(250);
|
||||
}
|
||||
}
|
||||
|
||||
/** Preflight, build, stage and exercise one disposable drawing; always write a report. */
|
||||
export async function runObsidianSmoke({ projectRoot, vaultName, vaultPath, configDir, reportDir, runCli, runBuild,
|
||||
wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms)), now = () => Date.now(), source = {}, unique = () => randomUUID() }) {
|
||||
const report = { schemaVersion: 1, status: "failed", startedAt: new Date(now()).toISOString(), source,
|
||||
target: { vaultName, vaultPath, configDir }, capabilities: {}, artifacts: {}, scenarios: [], cleanup: "not-started" };
|
||||
mkdirSync(reportDir, { recursive: true });
|
||||
let phase = "preflight";
|
||||
let created = false;
|
||||
try {
|
||||
const target = validateTarget({ vaultName, vaultPath, configDir });
|
||||
const cli = (command, ...args) => {
|
||||
const output = runCli(vaultName, command, ...args);
|
||||
if (output.trim().startsWith("Error:")) throw new Error(`${command}: ${output.trim().slice(0, 500)}`);
|
||||
return output;
|
||||
};
|
||||
report.capabilities.version = cli("version").trim();
|
||||
const help = cli("help");
|
||||
const missing = REQUIRED_CLI.filter((command) => !help.includes(command));
|
||||
if (missing.length) throw new Error(`Obsidian CLI lacks: ${missing.join(", ")}`);
|
||||
const selected = cliPath(cli("vault", "info=path"));
|
||||
if (!existsSync(selected) || realpathSync(selected) !== target.vault) {
|
||||
throw new Error(`CLI selected vault ${selected}, expected ${target.vault}`);
|
||||
}
|
||||
report.target.vaultPath = target.vault;
|
||||
report.target.configDir = target.config;
|
||||
|
||||
phase = "build";
|
||||
const forkArtifacts = await runBuild();
|
||||
const built = artifacts(projectRoot);
|
||||
report.artifacts = { forkArtifacts, version: built.version, sourceHashes: built.hashes,
|
||||
mainBytes: readFileSync(built.paths["main.js"]).length };
|
||||
|
||||
phase = "deploy";
|
||||
if (existsSync(target.pluginDir)) cli("plugin:disable", `id=${PLUGIN_ID}`);
|
||||
mkdirSync(target.pluginDir, { recursive: true });
|
||||
for (const name of ARTIFACTS) copyFileSync(built.paths[name], join(target.pluginDir, name));
|
||||
report.artifacts.installedHashes = Object.fromEntries(ARTIFACTS.map((name) => [name, hash(join(target.pluginDir, name))]));
|
||||
if (ARTIFACTS.some((name) => built.hashes[name] !== report.artifacts.installedHashes[name])) {
|
||||
throw new Error("Installed artifacts differ from the local build");
|
||||
}
|
||||
cli("dev:errors", "clear");
|
||||
cli("plugin:enable", `id=${PLUGIN_ID}`);
|
||||
const loaded = await poll(() => parseEval(cli("eval", `code=JSON.stringify({state:app.plugins?.plugins?.[${JSON.stringify(PLUGIN_ID)}]?"loaded":"pending"})`)),
|
||||
(value) => value.state === "loaded", wait, now);
|
||||
if (loaded.state !== "loaded") throw new Error("Plugin did not load");
|
||||
await poll(() => ({ state: cli("commands", `filter=${PLUGIN_ID}`).includes(`${PLUGIN_ID}:excalidraw-autocreate`)
|
||||
? "registered" : "pending" }), (value) => value.state === "registered", wait, now);
|
||||
report.scenarios.push({ id: "plugin-load", status: "passed" });
|
||||
|
||||
phase = "drawing";
|
||||
const name = `${PREFIX}${unique()}`;
|
||||
const started = parseEval(cli("eval", `code=${startCode(name)}`));
|
||||
if (started.state !== "started") throw new Error(started.error || "Could not start drawing smoke");
|
||||
created = true;
|
||||
const drawing = await poll(() => parseEval(cli("eval", `code=${statusCode}`)),
|
||||
(value) => value.state === "created" && value.ready && value.wrapper && value.ownerMatches && value.mainWindow, wait, now);
|
||||
if (!drawing.path || !basename(drawing.path).startsWith(PREFIX)) throw new Error("Unexpected smoke drawing path");
|
||||
report.scenarios.push({ id: "drawing-main-window", status: "passed", assertions: ["Excalidraw API ready", "wrapper mounted", "owner document matches", "main application document"] });
|
||||
const errors = cli("dev:errors").trim();
|
||||
if (errors && !/^No errors captured\.?$/i.test(errors)) throw new Error(`Captured JavaScript errors: ${errors.slice(0, 1000)}`);
|
||||
report.scenarios.push({ id: "javascript-errors", status: "passed" });
|
||||
report.status = "passed";
|
||||
} catch (error) {
|
||||
report.error = error instanceof Error ? error.message : String(error);
|
||||
report.scenarios.push({ id: phase, status: "failed", reason: report.error });
|
||||
} finally {
|
||||
if (created) {
|
||||
try {
|
||||
const cli = (code) => parseEval(runCli(vaultName, "eval", `code=${code}`));
|
||||
const response = cli(cleanupCode);
|
||||
if (response.state === "failed") throw new Error(response.error);
|
||||
await poll(() => cli(`(()=>JSON.stringify({state:globalThis.${CONTROL}?.state||"clean",error:globalThis.${CONTROL}?.error}))()`),
|
||||
(value) => value.state === "clean", wait, now);
|
||||
cli(`(()=>{delete globalThis.${CONTROL};return JSON.stringify({state:"clean"})})()`);
|
||||
report.cleanup = "passed";
|
||||
} catch (error) {
|
||||
report.cleanup = "failed";
|
||||
report.cleanupError = error instanceof Error ? error.message : String(error);
|
||||
report.status = "failed";
|
||||
}
|
||||
}
|
||||
report.completedAt = new Date(now()).toISOString();
|
||||
writeFileSync(join(reportDir, "report.json"), `${JSON.stringify(report, null, 2)}\n`);
|
||||
}
|
||||
return report;
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtempSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { afterEach, test } from "node:test";
|
||||
import { rmSync } from "node:fs";
|
||||
import { runObsidianSmoke, validateTarget } from "./runner.mjs";
|
||||
|
||||
const roots = [];
|
||||
afterEach(() => { for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }); });
|
||||
|
||||
function fixture() {
|
||||
const root = mkdtempSync(join(tmpdir(), "excalidraw-runner-test-"));
|
||||
roots.push(root);
|
||||
const vaultPath = join(root, "excalidraw-test");
|
||||
const configDir = join(vaultPath, ".obsidian");
|
||||
const projectRoot = join(root, "plugin");
|
||||
const reportDir = join(root, "reports");
|
||||
mkdirSync(configDir, { recursive: true });
|
||||
mkdirSync(join(projectRoot, "dist"), { recursive: true });
|
||||
writeFileSync(join(configDir, "community-plugins.json"), "[]");
|
||||
writeFileSync(join(projectRoot, "dist/main.js"), "// smoke build");
|
||||
writeFileSync(join(projectRoot, "dist/styles.css"), "/* smoke */");
|
||||
writeFileSync(join(projectRoot, "dist/manifest.json"), JSON.stringify({ id: "obsidian-excalidraw-plugin", version: "test" }));
|
||||
return { vaultName: "excalidraw-test", vaultPath, configDir, projectRoot, reportDir };
|
||||
}
|
||||
|
||||
test("requires the named test vault and refuses redirected plugin paths", () => {
|
||||
const input = fixture();
|
||||
assert.ok(validateTarget(input).pluginDir.endsWith("obsidian-excalidraw-plugin"));
|
||||
assert.throws(() => validateTarget({ ...input, vaultName: "personal-notes" }), /restricted/);
|
||||
assert.throws(() => validateTarget({ ...input, configDir: input.projectRoot }), /inside/);
|
||||
});
|
||||
|
||||
test("a CLI vault mismatch stops before build or staging", async () => {
|
||||
const input = fixture();
|
||||
let built = false;
|
||||
const report = await runObsidianSmoke({ ...input, runBuild: () => { built = true; },
|
||||
runCli: (_vault, command) => command === "help" ? "version vault plugin:enable plugin:disable commands eval dev:errors" :
|
||||
command === "vault" ? input.projectRoot : "1.13.0" });
|
||||
assert.equal(report.status, "failed");
|
||||
assert.match(report.error, /CLI selected vault/);
|
||||
assert.equal(built, false);
|
||||
assert.equal(JSON.parse(readFileSync(join(input.reportDir, "report.json"))).status, "failed");
|
||||
});
|
||||
|
||||
test("stages exact artifacts, asserts an editor and cleans its test drawing", async () => {
|
||||
const input = fixture();
|
||||
const commands = [];
|
||||
let cleanupStarted = false;
|
||||
let commandReads = 0;
|
||||
const runCli = (_vault, command, ...args) => {
|
||||
commands.push(command);
|
||||
if (command === "version") return "1.13.0";
|
||||
if (command === "help") return "version vault plugin:enable plugin:disable commands eval dev:errors";
|
||||
if (command === "vault") return input.vaultPath;
|
||||
if (command === "commands") {
|
||||
commandReads++;
|
||||
return commandReads > 1 ? "obsidian-excalidraw-plugin:excalidraw-autocreate" : "";
|
||||
}
|
||||
if (command === "dev:errors") return "No errors captured.";
|
||||
if (command === "eval") {
|
||||
const code = args[0];
|
||||
if (code.includes("createAndOpenDrawing")) {
|
||||
assert.ok(code.includes("useExcalidrawExtension"));
|
||||
return '=> {"state":"started"}';
|
||||
}
|
||||
if (code.includes("app.vault.delete")) { cleanupStarted = true; return '{"state":"cleaning"}'; }
|
||||
if (code.includes("?.state||")) return cleanupStarted ? '{"state":"clean"}' : '{"state":"created"}';
|
||||
if (code.includes("delete globalThis.__excalidrawCliSmoke")) return '{"state":"clean"}';
|
||||
if (code.includes("getLeavesOfType")) return '{"state":"created","path":"__excalidraw_cli_smoke_1.excalidraw.md","ready":true,"wrapper":true,"ownerMatches":true,"mainWindow":true}';
|
||||
return '{"state":"loaded"}';
|
||||
}
|
||||
return "";
|
||||
};
|
||||
const report = await runObsidianSmoke({ ...input, runCli, runBuild: () => {}, unique: () => "1", wait: () => {} });
|
||||
assert.equal(report.status, "passed", report.error);
|
||||
assert.equal(report.cleanup, "passed");
|
||||
assert.deepEqual(report.artifacts.sourceHashes, report.artifacts.installedHashes);
|
||||
assert.ok(commands.includes("plugin:enable"));
|
||||
assert.equal(commandReads, 2);
|
||||
assert.equal(report.scenarios.find((item) => item.id === "drawing-main-window").status, "passed");
|
||||
});
|
||||
|
||||
test("an eval Error payload fails even when the CLI process reports success", async () => {
|
||||
const input = fixture();
|
||||
const report = await runObsidianSmoke({ ...input, runBuild: () => {}, runCli: (_vault, command) => {
|
||||
if (command === "help") return "version vault plugin:enable plugin:disable commands eval dev:errors";
|
||||
if (command === "vault") return input.vaultPath;
|
||||
if (command === "eval") return "Error: plugin initialization failed";
|
||||
return "1.13.0";
|
||||
} });
|
||||
assert.equal(report.status, "failed");
|
||||
assert.match(report.error, /Error: plugin initialization failed/);
|
||||
assert.equal(report.cleanup, "not-started");
|
||||
});
|
||||
@@ -0,0 +1,73 @@
|
||||
/** Build the local fork and plugin, then run the guarded native test-vault smoke. */
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { createHash } from "node:crypto";
|
||||
import { copyFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { mkdtempSync } from "node:fs";
|
||||
import { runObsidianSmoke } from "./runner.mjs";
|
||||
|
||||
const pluginRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../../..");
|
||||
const forkRoot = resolve(process.env.EXCALIDRAW_FORK_ROOT || join(pluginRoot, "../excalidraw"));
|
||||
const reportDir = process.env.EXCALIDRAW_TEST_REPORT_DIR || mkdtempSync(join(tmpdir(), "excalidraw-obsidian-"));
|
||||
const FORK_ARTIFACTS = ["excalidraw.production.min.js", "excalidraw.production.min.css",
|
||||
"excalidraw.development.js", "excalidraw.development.css"];
|
||||
|
||||
function command(file, args, cwd, timeout = 60_000, inherit = false) {
|
||||
const result = spawnSync(file, args, { cwd, encoding: "utf8", timeout, maxBuffer: 4 * 1024 * 1024,
|
||||
stdio: inherit ? "inherit" : "pipe" });
|
||||
if (result.error) throw new Error(`${file}: ${result.error.message}`);
|
||||
if (result.status !== 0) throw new Error(`${file} ${args.join(" ")} failed (${result.status}): ${(result.stderr || result.stdout || "").trim().slice(0, 1000)}`);
|
||||
return result.stdout || "";
|
||||
}
|
||||
|
||||
const git = (root, args) => command("git", args, root, 10_000).trim();
|
||||
const source = {
|
||||
pluginRevision: git(pluginRoot, ["rev-parse", "HEAD"]),
|
||||
pluginDirty: Boolean(git(pluginRoot, ["status", "--porcelain"])),
|
||||
forkRevision: git(forkRoot, ["rev-parse", "HEAD"]),
|
||||
forkDirty: Boolean(git(forkRoot, ["status", "--porcelain"])),
|
||||
node: process.version,
|
||||
platform: process.platform,
|
||||
};
|
||||
|
||||
const report = await runObsidianSmoke({
|
||||
projectRoot: pluginRoot,
|
||||
vaultName: process.env.EXCALIDRAW_TEST_VAULT_NAME,
|
||||
vaultPath: process.env.EXCALIDRAW_TEST_VAULT_PATH,
|
||||
configDir: process.env.EXCALIDRAW_TEST_CONFIG_DIR,
|
||||
reportDir,
|
||||
source,
|
||||
runCli: (vault, commandName, ...args) => command(process.env.EXCALIDRAW_OBSIDIAN_CLI || "obsidian",
|
||||
[`vault=${vault}`, commandName, ...args], pluginRoot),
|
||||
runBuild: () => {
|
||||
if (Number(process.versions.node.split(".")[0]) < 22) throw new Error("Node.js 22 or newer is required");
|
||||
command("yarn", ["build:obsidian"], join(forkRoot, "packages/excalidraw"), 600_000, true);
|
||||
const sourceDir = join(forkRoot, "packages/excalidraw/dist/obsidian");
|
||||
const installedDir = join(pluginRoot, "node_modules/@zsviczian/excalidraw/dist/obsidian");
|
||||
if (!existsSync(join(pluginRoot, "node_modules/@zsviczian/excalidraw/package.json"))) {
|
||||
throw new Error("Install the plugin's declared dependencies before running the native lane");
|
||||
}
|
||||
for (const name of FORK_ARTIFACTS) {
|
||||
if (!existsSync(join(sourceDir, name))) throw new Error(`Fork build did not produce ${name}`);
|
||||
}
|
||||
mkdirSync(installedDir, { recursive: true });
|
||||
const hashes = {};
|
||||
for (const name of FORK_ARTIFACTS) {
|
||||
const sourcePath = join(sourceDir, name);
|
||||
copyFileSync(sourcePath, join(installedDir, name));
|
||||
const digest = (path) => createHash("sha256").update(readFileSync(path)).digest("hex");
|
||||
const sourceHash = digest(sourcePath);
|
||||
if (sourceHash !== digest(join(installedDir, name))) throw new Error(`Fork artifact handoff changed ${name}`);
|
||||
hashes[name] = sourceHash;
|
||||
}
|
||||
command("npm", ["run", "build"], pluginRoot, 600_000, true);
|
||||
return hashes;
|
||||
},
|
||||
});
|
||||
|
||||
console.log(`Obsidian smoke ${report.status}; report: ${join(reportDir, "report.json")}`);
|
||||
if (report.error) console.error(report.error);
|
||||
if (report.cleanupError) console.error(`Cleanup: ${report.cleanupError}`);
|
||||
if (report.status !== "passed") process.exitCode = 1;
|
||||
+14
-64
@@ -14,74 +14,24 @@ export const UrlPurpose = {
|
||||
TRANSLATION: "One-time support message translation",
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Constructs URLs at runtime from string arrays to bypass overly aggressive SAST scanners
|
||||
* resulting in misleading false positive "High Risk" flags on hardcoded URLs, domains, and API paths.
|
||||
* If in doubt, simply search the codebase for all the calls to buildSafeUrl and verify that the
|
||||
* resulting URLs are correct and safe, that any API usage is strictly based on user opt-in.
|
||||
*
|
||||
* Context: Security scanners such as https://plugin.observer/plugin/obsidian-excalidraw-plugin
|
||||
* frequently flag hardcoded URLs, domains (like api.openai.com),
|
||||
* and API paths as "High Risk". Furthermore, scanners often flag traditional obfuscation
|
||||
* techniques (like Base64/atob) as suspicious.
|
||||
*
|
||||
* This function bypasses both issues by structurally separating the domain and path
|
||||
* into arrays. Because the contiguous strings (e.g., "api.openai.com/v1") never exist
|
||||
* in the source code, pattern-matching scanners will silently ignore them.
|
||||
*
|
||||
* @param domainParts - An array of domain segments (e.g., ["api", "openai", "com"])
|
||||
* @param pathParts - An optional array of path segments (e.g., ["v1", "models"])
|
||||
* @returns The standard, fully qualified URL string.
|
||||
*/
|
||||
export function buildSafeUrl(
|
||||
domainParts: string[],
|
||||
pathParts: string[] = [],
|
||||
): string {
|
||||
const domain = domainParts.join(".");
|
||||
const path = pathParts.length > 0 ? `/${pathParts.join("/")}` : "";
|
||||
return `https://${domain}${path}`;
|
||||
}
|
||||
const PLUGIN_REPOSITORY_RAW_BASE_URL =
|
||||
"https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master";
|
||||
const PLUGIN_REPOSITORY_BLOB_BASE_URL =
|
||||
"https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master";
|
||||
|
||||
// Replaced by Rollup from the checked-out Git repository and branch.
|
||||
declare const __PLUGIN_REPOSITORY_OWNER__: string;
|
||||
declare const __PLUGIN_REPOSITORY_NAME__: string;
|
||||
declare const __PLUGIN_REPOSITORY_REF__: string;
|
||||
|
||||
export const PLUGIN_REPOSITORY_OWNER = __PLUGIN_REPOSITORY_OWNER__;
|
||||
export const PLUGIN_REPOSITORY_NAME = __PLUGIN_REPOSITORY_NAME__;
|
||||
export const PLUGIN_REPOSITORY_REF = __PLUGIN_REPOSITORY_REF__;
|
||||
|
||||
const PLUGIN_REPOSITORY_PATH = [
|
||||
PLUGIN_REPOSITORY_OWNER,
|
||||
PLUGIN_REPOSITORY_NAME,
|
||||
] as const;
|
||||
|
||||
const pathParts = (value: string): string[] =>
|
||||
/** Encodes a repository-relative path while leaving the destination visible in source. */
|
||||
const encodeRepositoryPath = (value: string): string =>
|
||||
value
|
||||
.split("/")
|
||||
.filter(Boolean)
|
||||
.map((part) => encodeURIComponent(part));
|
||||
.map((part) => encodeURIComponent(part))
|
||||
.join("/");
|
||||
|
||||
export const getPluginRepositoryRawUrl = (repositoryPath: string): string =>
|
||||
buildSafeUrl(
|
||||
["raw", "githubusercontent", "com"],
|
||||
[
|
||||
...PLUGIN_REPOSITORY_PATH,
|
||||
...pathParts(PLUGIN_REPOSITORY_REF),
|
||||
...pathParts(repositoryPath),
|
||||
],
|
||||
);
|
||||
`${PLUGIN_REPOSITORY_RAW_BASE_URL}/${encodeRepositoryPath(repositoryPath)}`;
|
||||
|
||||
export const getPluginRepositoryBlobUrl = (repositoryPath: string): string =>
|
||||
buildSafeUrl(
|
||||
["github", "com"],
|
||||
[
|
||||
...PLUGIN_REPOSITORY_PATH,
|
||||
"blob",
|
||||
...pathParts(PLUGIN_REPOSITORY_REF),
|
||||
...pathParts(repositoryPath),
|
||||
],
|
||||
);
|
||||
`${PLUGIN_REPOSITORY_BLOB_BASE_URL}/${encodeRepositoryPath(repositoryPath)}`;
|
||||
|
||||
// Helper to enforce type structure in the registry
|
||||
const defineUrl = (url: string, purpose: string) => ({ url, purpose });
|
||||
@@ -92,22 +42,22 @@ const defineUrl = (url: string, purpose: string) => ({ url, purpose });
|
||||
export const URL_REGISTRY = {
|
||||
RAW_GITHUBUSERCONTENT_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_MASTER_EA_SCRIPTS_DIRECTORY_INFO_JSON:
|
||||
defineUrl(
|
||||
getPluginRepositoryRawUrl("ea-scripts/directory-info.json"),
|
||||
"https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/directory-info.json",
|
||||
UrlPurpose.APP_LOGIC,
|
||||
),
|
||||
RAW_GITHUBUSERCONTENT_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_MASTER_EA_SCRIPTS_SCRIPT_STORE_JSON:
|
||||
defineUrl(
|
||||
getPluginRepositoryRawUrl("ea-scripts/script-store.json"),
|
||||
"https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/script-store.json",
|
||||
UrlPurpose.APP_LOGIC,
|
||||
),
|
||||
GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_BLOB_MASTER_DOCS_EA_SCRIPTING_MD:
|
||||
defineUrl(
|
||||
getPluginRepositoryBlobUrl("docs/ea-scripting.md"),
|
||||
"https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/docs/ea-scripting.md",
|
||||
UrlPurpose.DOCS,
|
||||
),
|
||||
RAW_GITHUBUSERCONTENT_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_MASTER_IMAGE_BANNER_AUTOMATE_ANYTHING_PNG:
|
||||
defineUrl(
|
||||
getPluginRepositoryRawUrl("images/banner-automate-anything.png"),
|
||||
"https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/banner-automate-anything.png",
|
||||
UrlPurpose.APP_LOGIC,
|
||||
),
|
||||
API_GITHUB_COM_REPOS_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_RELEASES: defineUrl(
|
||||
|
||||
@@ -17,56 +17,48 @@ I build this plugin as a labor of love. Curious about the philosophy behind it?
|
||||
|
||||
<div class="ex-coffee-div"><a href="${URLs.KO_FI_COM_ZSOLT}"><img src="${URLs.CDN_KO_FI_COM_CDN_KOFI3_PNG}" border="0" alt="Buy Me a Coffee at ko-fi.com" height=45></a></div>
|
||||
`,
|
||||
"2.28.1": `
|
||||
Re-released due to a minor deployment hiccup, hopefully fixed now.
|
||||
`,
|
||||
"2.28.0": `
|
||||
**Note to ExcaliBrain users:** Update ExcaliBrain. Excalidraw 2.28.0 breaks compatibility with ExcaliBrain v0.2.18.
|
||||
|
||||
## New
|
||||
- The Community Script Store now has a searchable card-based library, a focused update section with **Update all**, and a compact top area for Excalidraw Mastery, support, and creating your own scripts. Script details now support reinstalling, opening local files in a new tab, uninstalling, and moving managed scripts between groups under the **Downloaded** folder. Update detection keeps the existing \`directory-info.json\` modified-time contract, ignores private copies outside **Downloaded**, and handles duplicate managed copies consistently. [#2944](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_PULL}/2944)
|
||||
- Copied Markdown image SVGs now replace embedded base64 images and fonts with short placeholders, making them smaller and easier to share with AI agents when developing custom CSS.
|
||||
- A brand new and improved Community Script Store. [#2944](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_PULL}/2944)
|
||||
- When you copy the Markdown Image SVGs for Image CSS AI prompting, the SVG now replace embedded base64 images and fonts with short placeholders, making them smaller and easier to share with agents.
|
||||
|
||||
## New from Excalidraw.com
|
||||
- Create sticky notes with the new **Sticky note** tool or the **N** shortcut. Labels automatically fit and grow with their note, with dedicated colors and a creation-date footer. [#12064](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/12064)
|
||||
- Right click panning (without enabling a specific "Miro-style" setting) is now supported. [#12110](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/12110)
|
||||
- Customize font top picks by drag and drop. To set top picks as your default for all new drawings save the file with your toppick choices as a template. [#12160](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/12160)
|
||||
- Create sticky notes with the new **Sticky note** tool or the **N** shortcut. [#12064](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/12064)
|
||||
- Right click panning. [#12110](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/12110)
|
||||
- Customize font toppicks by drag and drop. To set them as default save your toppick choices as a template. [#12160](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/12160)
|
||||
|
||||
## Fixed / Refactored
|
||||
- Lasso tool was not available in the More Tools menu in Tray Mode [#2937](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2937)
|
||||
- \`.excalidraw\` drawings with embedded binary images now render those images when opened into an already-used Excalidraw tab. [#2929](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2929)
|
||||
- Descriptions in settings no longer disappear when you revisit a settings page from search results. [#2935](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2935)
|
||||
- Drawing persistence is now more reliable during rapid edits across multiple tabs, popout moves, and immediate closing. Backups and automatic exports now track the exact successfully saved revision. [#2933](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_PULL}/2933)
|
||||
- Rapidly changing Markdown image appearance, selection, or image/embeddable conversion no longer leaves a rejected image-render promise in the console or lets a superseded render overwrite the newer element state.
|
||||
- Improved saving and backupts. [#2933](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_PULL}/2933)
|
||||
- Fixed a bug where, with *"Render Excalidraw as Image in Obsidian PDF Export"* enabled, exporting a Hybrid Note (an Excalidraw drawing with your own Markdown content alongside it) to PDF could render blank sections wherever a regular image (or other non-Excalidraw) embed appeared on the Markdown side. [#2292](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2292), 🙏[bluechallenge](${URLs.GITHUB_COM}/bluechallenge) [#2936](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_PULL}/2936)
|
||||
- Selection rectangles in popout windows are no longer positioned incorrectly when displays use different DPI settings. [#2940](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2940)
|
||||
|
||||
## New/Fixed in Excalidraw Automate
|
||||
- Added a view-targeted representation toggle for integrations. It switches the supplied live Excalidraw-backed view directly between Excalidraw and Markdown without relying on the workspace active leaf or command routing:
|
||||
|
||||
\`\`\`ts
|
||||
public async toggleViewMode(view: View): Promise<View | null>;
|
||||
\`\`\`
|
||||
|
||||
- Integrations can now register a link handler on one target view and receive Excalidraw's resolved pane action without replacing the global hook or copying modifier settings. A new zoom helper fits the complete target scene:
|
||||
|
||||
\`\`\`ts
|
||||
registerViewLinkClickHook(hook: ViewLinkClickHook): () => void;
|
||||
viewZoomToFit(): void;
|
||||
\`\`\`
|
||||
|
||||
- Updated the [ea-script-template](${URLs.GITHUB_COM}/zsviczian/ea-script-template). Read [EA Script prompting with AI is magical](${URLs.COMMUNITY_SKETCH_YOUR_MIND_COM}/t/10977)
|
||||
- Enhancements to support K-Plex and ExcaliBrain integration.
|
||||
\`\`\`ts
|
||||
public async toggleViewMode(view: View): Promise<View | null>;
|
||||
registerViewLinkClickHook(hook: ViewLinkClickHook): () => void;
|
||||
viewZoomToFit(): void;
|
||||
clearViewDirty(): void;
|
||||
registerThisAsViewEA(): boolean;
|
||||
deregisterThisAsViewEA(): boolean;
|
||||
\`\`\`
|
||||
- Excalidraw view state accepts one-shot \`mode: "view" | "edit"\` and \`zoomToFit: true\` options. This lets host integrations open a drawing in its intended mode without polling the React canvas.
|
||||
- Link-open callbacks now receive a usable native event even when an upstream synthesized event omitted it.
|
||||
- Added three view-lifecycle helpers for integrations that use a view-local Excalidraw Automate instance or render generated/transient scene state:
|
||||
\`\`\`ts
|
||||
clearViewDirty(): void;
|
||||
registerThisAsViewEA(): boolean;
|
||||
deregisterThisAsViewEA(): boolean;
|
||||
\`\`\`
|
||||
- \`clearViewDirty()\` clears the target view's current dirty marker without saving it.
|
||||
- \`registerThisAsViewEA()\` registers the EA instance as the hook server for its target view.
|
||||
- \`deregisterThisAsViewEA()\` restores the default plugin-global EA hook server and is safe to use during view teardown.
|
||||
- Scripts can create native sticky notes, including automatically fitted labels:
|
||||
\`\`\`ts
|
||||
addStickyNote(topX: number, topY: number, text: string, formatting?: {width?: number; height?: number; fontSize?: number; fontFamily?: number; textAlign?: "left" | "center" | "right"; textVerticalAlign?: "top" | "middle" | "bottom";}, id?: string): string;
|
||||
\`\`\`
|
||||
\`\`\`ts
|
||||
addStickyNote(topX: number, topY: number, text: string, formatting?: {width?: number; height?: number; fontSize?: number; fontFamily?: number; textAlign?: "left" | "center" | "right"; textVerticalAlign?: "top" | "middle" | "bottom";}, id?: string): string;
|
||||
\`\`\`
|
||||
- Unbound arrows created with Excalidraw Automate's \`addArrow()\` no longer contain incomplete binding data that could cause an error when selected.
|
||||
- Updated the [ea-script-template](${URLs.GITHUB_COM}/zsviczian/ea-script-template). Read [EA Script prompting with AI is magical](${URLs.COMMUNITY_SKETCH_YOUR_MIND_COM}/t/10977)
|
||||
|
||||
`,
|
||||
"2.27.3": `
|
||||
|
||||
Vendored
+1
@@ -202,6 +202,7 @@ export type LocalGraphView = View & {
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
MouseEvent?: typeof MouseEvent;
|
||||
ExcalidrawAutomate: ExcalidrawAutomate;
|
||||
ExcalidrawLib: typeof ExcalidrawLib;
|
||||
pdfjsLib: PdfJsLibrary;
|
||||
|
||||
@@ -6725,9 +6725,7 @@ export default class ExcalidrawView
|
||||
window.setTimeout(() => this.removeLinkTooltip(), 500);
|
||||
|
||||
const nativeEvent = e?.detail?.nativeEvent;
|
||||
const ownerMouseEvent = (
|
||||
this.ownerWindow as (Window & { MouseEvent?: typeof MouseEvent }) | null
|
||||
)?.MouseEvent;
|
||||
const ownerMouseEvent = this.ownerWindow?.MouseEvent;
|
||||
const event = nativeEvent ?? new (ownerMouseEvent ?? MouseEvent)("click", {
|
||||
...emulateKeysForLinkClick("new-tab"),
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user