mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2026-11-27 06:32:42 +00:00
Implement the scoped fixes for PR #3046: - Ignore unsupported aliases while retaining whole string/list aliases and paths. - Use Obsidian source-heading identities for section targets, preserving legacy image-transclusion matching. - Block Ctrl/Cmd+Shift+S only in the focused drawing editor, retaining normal save and explicit legacy export. - Honor internal-link removal in manual vault and clipboard SVG exports through the existing scene filter without mutating source elements or changing hooks. Add source and native regressions, including standalone H2 wikilinks, aliased and unresolved wikilinks, save/reopen, image decoding and ordinary section-link navigation in Reading and Live Preview. Preserve the original NBSP attachment with provenance. Add the requested CLI troubleshooting guidance and remove the temporary plan-only handoff. Validation: 993 portable cases passed; 776 fast/source tests passed; all ten PR-specific native cases passed in main and popout, including the expanded wikilink matrix. Production build and all five bundle tests passed. No new lint diagnostics; the repository retains 116 existing errors. The exact tested build was deployed to Zsolt's Brain with backed-up artifacts and unchanged settings. The complete native profile remains failed: table controls also fail on the unchanged baseline; the offscreen phone toolbar remains unclassified against baseline. Initial zoom-settling and popout code-image reopen failures passed focused reruns. macOS, physical mobile and minimum-version Obsidian remain untested. Original SVG escaping (#2570) and NBSP (#2389) reports did not reproduce on this Windows host; they gain coverage without speculative serializer/cache changes. Optional simple-columns compatibility (#2858) is deferred.
38 lines
2.3 KiB
JavaScript
38 lines
2.3 KiB
JavaScript
/** Exercise the actual vault export entry point and existing scene link filter. */
|
|
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { readFileSync } from "node:fs";
|
|
import vm from "node:vm";
|
|
import ts from "typescript";
|
|
|
|
function compile(path, dependencies) {
|
|
const exports = {};
|
|
vm.runInNewContext(ts.transpileModule(readFileSync(new URL("../../" + path, import.meta.url), "utf8"), {
|
|
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022 },
|
|
}).outputText, { exports, require: name => dependencies[name] ?? {} });
|
|
return exports;
|
|
}
|
|
|
|
const { sceneRemoveInternalLinks } = compile("src/utils/excalidrawViewUtils.ts", {
|
|
obsidian: { Modal: class {} },
|
|
"../shared/ExcalidrawData": { REG_LINKINDEX_HYPERLINK: /^\w+:\/\// },
|
|
});
|
|
const writes = [];
|
|
const { ViewExportManager } = compile("src/view/managers/ViewExportManager.ts", {
|
|
"../../utils/fileUtils": { getIMGFilename: path => path + ".svg", exportImageToFile: async (...args) => writes.push(args) },
|
|
});
|
|
|
|
for (const method of ["vault", "clipboard"]) for (const include of [true, false]) test(`${method} SVG honors internal links=${include} without changing the source scene`, async () => {
|
|
const scene = { elements: [{ id: "internal", link: "[[Target|Alias]]" }, { id: "external", link: "https://example.com/?q=<tag>&x=1" }], appState: {} };
|
|
const before = structuredClone(scene), rendered = [];
|
|
const view = { file: { path: "Drawing.md" }, excalidrawAPI: {}, getScene: () => scene, plugin: { settings: { autoExportLightAndDark: false } } };
|
|
const manager = new ViewExportManager(view, { getOrCreateExportDialog: () => null, getExportInternalLinks: () => include, sceneRemoveInternalLinks });
|
|
manager.svg = async source => { rendered.push(source); return { outerHTML: JSON.stringify(source.elements.map(element => element.link)) }; };
|
|
if (method === "vault") await manager.saveSVG({ scene }); else await manager.getSVG();
|
|
assert.deepEqual(scene, before);
|
|
assert.equal(rendered.length, 1);
|
|
assert.equal(rendered[0].elements[0].link, include ? "[[Target|Alias]]" : null);
|
|
assert.equal(rendered[0].elements[1].link, before.elements[1].link);
|
|
if (method === "vault") assert.equal(writes.at(-1)[2], JSON.stringify(rendered[0].elements.map(element => element.link)));
|
|
});
|