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.
44 lines
2.4 KiB
JavaScript
44 lines
2.4 KiB
JavaScript
/** Obsidian's display labels are not link targets; retain cache-owned source identity. */
|
|
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { sourceHarness } from "./sourceHarness.mjs";
|
|
|
|
const sourceHeading = "[Heading](http://www.google.com)", linkHeading = "Heading http www google com";
|
|
const harness = sourceHarness({
|
|
obsidian: {
|
|
stripHeading: heading => heading === sourceHeading ? linkHeading : heading,
|
|
resolveSubpath: (cache, subpath) => {
|
|
const current = cache.headings.find(heading => "#" + (heading.heading === sourceHeading ? linkHeading : heading.heading) === subpath);
|
|
return current ? { type: "heading", current } : null;
|
|
},
|
|
},
|
|
"src/constants/constants": { MD_EX_SECTIONS: ["# Excalidraw Data"], nanoid: () => "new-block" },
|
|
"src/lang/helpers": { t: key => key }, "src/shared/Scripts": { ScriptEngine: {} },
|
|
"src/utils/pathUtils": { cleanSectionHeading: heading => heading.replace(/[#:]/g, "").trim() },
|
|
});
|
|
const { getMarkdownHeadingSubpaths } = await harness.importModule("src/shared/Suggesters/markdownSubpathSuggester.ts");
|
|
test.after(() => harness.close());
|
|
|
|
function fixture(headings = ["Plain", sourceHeading, "Plain"]) {
|
|
const cache = { headings: headings.map((heading, i) => ({ heading, position: { start: { offset: i * 100 } } })) };
|
|
const blocks = headings.map((heading, i) => ({ display: heading === sourceHeading ? "# Heading" : "# " + heading,
|
|
node: { type: "heading", position: { start: { offset: i * 100 } } } }));
|
|
return { cache, blocks, app: { metadataCache: { getFileCache: () => cache, blockCache: { getForFile: async () => ({ blocks }) } } } };
|
|
}
|
|
|
|
test("heading suggestions retain formatted source targets, friendly labels and duplicate order", async () => {
|
|
const { app, cache, blocks } = fixture();
|
|
const before = structuredClone({ cache, blocks });
|
|
assert.deepEqual(await getMarkdownHeadingSubpaths(app, {}, false), [
|
|
{ display: "# Plain", subpath: "#Plain" }, { display: "# Heading", subpath: "#" + linkHeading }, { display: "# Plain", subpath: "#Plain" },
|
|
]);
|
|
assert.deepEqual({ cache, blocks }, before);
|
|
});
|
|
|
|
test("missing or unmatched cache cannot offer a section that Obsidian cannot resolve", async () => {
|
|
const f = fixture(); f.cache.headings = [];
|
|
assert.deepEqual(await getMarkdownHeadingSubpaths(f.app, {}, false), []);
|
|
f.app.metadataCache.getFileCache = () => null;
|
|
assert.deepEqual(await getMarkdownHeadingSubpaths(f.app, {}, false), []);
|
|
});
|