Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Open linked Excalidraw boards in the whiteboard (PRD-8093) (#5139)

Abraham95e4a1852221
diff --git a/.changeset/excalidraw-link-opens-board.md b/.changeset/excalidraw-link-opens-board.md
new file mode 100644
index 000000000..2b3619207
--- /dev/null
+++ b/.changeset/excalidraw-link-opens-board.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge-app": patch
+---
+
+Clicking a link to an Excalidraw board in a note now opens the whiteboard instead of a file preview with View as text and Open file buttons.
diff --git a/packages/app/src/App.tsx b/packages/app/src/App.tsx
index 9ef38bcb5..f9680225a 100644
--- a/packages/app/src/App.tsx
+++ b/packages/app/src/App.tsx
@@ -50,6 +50,7 @@ import { createPageRequest, nextUntitledDocName, openCreatedPage } from '@/lib/c
import {
assetPathFromHash,
docNameFromHash,
+ hashFromDocName,
isContentRootHash,
isManagedHashHistoryState,
markCurrentHashHistoryEntry,
@@ -250,6 +251,10 @@ function NavigationHandler() {
if (assetPath) {
const assetExt = assetPath.split('.').pop() ?? '';
const mediaKind = mediaKindForSidebarAssetExtension(assetExt);
+ if (mediaKind === 'excalidraw') {
+ window.location.replace(hashFromDocName(assetPath));
+ return;
+ }
mark('ok/nav/hash-change', { docName: null, kind: 'asset' });
openHashTarget({
kind: 'asset',
diff --git a/packages/app/src/editor/editor-tabs.test.ts b/packages/app/src/editor/editor-tabs.test.ts
index a2919dd9f..1cd91f95e 100644
--- a/packages/app/src/editor/editor-tabs.test.ts
+++ b/packages/app/src/editor/editor-tabs.test.ts
@@ -959,6 +959,27 @@ describe('persisted tab ids are repaired on read', () => {
expect(state.panes[0].activeTabId).toBe('notes/foo.mdx');
});
+ test('an Excalidraw board saved as an asset tab restores as the board tab', () => {
+ const board = 'fishing-log/assets/2026-08/test2.Excalidraw';
+ const state = parseEditorTabSessionState(
+ session([assetTabId(board)], { activeTabId: assetTabId(board) }),
+ );
+ expect(state.panes[0].openTabs).toEqual([board]);
+ expect(state.panes[0].activeTabId).toBe(board);
+ });
+
+ test('a board saved as both an asset tab and a board tab restores as one tab', () => {
+ const state = parseEditorTabSessionState(
+ session([assetTabId('board.excalidraw'), 'board.excalidraw'], {
+ pinnedTabIds: [assetTabId('board.excalidraw')],
+ activeTabId: assetTabId('board.excalidraw'),
+ }),
+ );
+ expect(state.panes[0].openTabs).toEqual(['board.excalidraw']);
+ expect(state.panes[0].pinnedTabIds).toEqual(['board.excalidraw']);
+ expect(state.panes[0].activeTabId).toBe('board.excalidraw');
+ });
+
test('folder and asset tab ids keep their path verbatim', () => {
const ids = [folderTabId('specs/demo'), assetTabId('.ok/local/notes.md')];
expect(parseEditorTabSessionState(session(ids)).panes[0].openTabs).toEqual(ids);
diff --git a/packages/app/src/editor/editor-tabs.ts b/packages/app/src/editor/editor-tabs.ts
index e9f8091a3..4fb372afd 100644
--- a/packages/app/src/editor/editor-tabs.ts
+++ b/packages/app/src/editor/editor-tabs.ts
@@ -1,4 +1,5 @@
import {
+ isExcalidrawDocFile,
isManagedArtifactDocName,
MANAGED_ARTIFACT_SCOPES,
parseExternalSkillDocName,
@@ -79,7 +80,11 @@ function sharesStemWithAnotherQualifiedTab(
}
function canonicalTabId(tabId: string, siblingTabIds: readonly string[] = []): string {
- if (parseEditorTabId(tabId).kind !== 'doc') return tabId;
+ const parsed = parseEditorTabId(tabId);
+ if (parsed.kind === 'asset' && isExcalidrawDocFile(parsed.assetPath)) {
+ return docTabId(parsed.assetPath);
+ }
+ if (parsed.kind !== 'doc') return tabId;
if (sharesStemWithAnotherQualifiedTab(tabId, siblingTabIds)) return tabId;
let docName = tabId;
let stripped = stripMarkdownTabExtension(docName);
diff --git a/packages/app/src/editor/internal-link-helpers.test.ts b/packages/app/src/editor/internal-link-helpers.test.ts
index 98bad189f..992770b0b 100644
--- a/packages/app/src/editor/internal-link-helpers.test.ts
+++ b/packages/app/src/editor/internal-link-helpers.test.ts
@@ -116,6 +116,32 @@ describe('activateAssetLink', () => {
expect(assign).toHaveBeenCalledTimes(1);
expect(assign).toHaveBeenCalledWith('#/__asset__/docs/report.html');
});
+
+ it('Cmd/Ctrl/middle-click on an Excalidraw board opens the board in a new app tab, not the OS', () => {
+ const open = vi.fn(() => null);
+ Object.defineProperty(globalThis, 'window', {
+ configurable: true,
+ value: { open },
+ writable: true,
+ });
+ const navigate = vi.fn((_assetPath: string) => {});
+ const dispatch = vi.fn(async () => {});
+
+ activateAssetLink(
+ {
+ url: './board.excalidraw',
+ projectRelPath: 'docs/board.excalidraw',
+ ext: 'excalidraw',
+ title: 'board.excalidraw',
+ newTab: true,
+ },
+ { navigate, dispatch },
+ );
+
+ expect(open).toHaveBeenCalledWith('#/docs/board.excalidraw', '_blank', 'noopener,noreferrer');
+ expect(dispatch).not.toHaveBeenCalled();
+ expect(navigate).not.toHaveBeenCalled();
+ });
});
describe('navigateToMarkdownTarget — external routing', () => {
diff --git a/packages/app/src/editor/internal-link-helpers.ts b/packages/app/src/editor/internal-link-helpers.ts
index f1adc6178..9a5b2a8ed 100644
--- a/packages/app/src/editor/internal-link-helpers.ts
+++ b/packages/app/src/editor/internal-link-helpers.ts
@@ -3,6 +3,7 @@ import {
type ClassifiedLinkTarget,
classifyMarkdownHref,
type DocLinkTarget,
+ mediaKindForSidebarAssetExtension,
} from '@inkeep/open-knowledge-core';
import { hashFromAssetPath, hashFromDocName } from '../lib/doc-hash';
import { openExternalUrl } from '../lib/external-link';
@@ -71,7 +72,11 @@ export function activateAssetLink(
const navigate = deps.navigate ?? navigateToAssetPreview;
const dispatch = deps.dispatch ?? dispatchAssetClick;
if (newTab) {
- void dispatch({ url, projectRelPath, ext, title, forceOsDelegation: true });
+ if (mediaKindForSidebarAssetExtension(ext) === 'excalidraw') {
+ openInternalHashHrefInNewTab({ docName: projectRelPath, anchor: null });
+ } else {
+ void dispatch({ url, projectRelPath, ext, title, forceOsDelegation: true });
+ }
return;
}
navigate(projectRelPath);
diff --git a/packages/app/tests/stress/asset-click-dispatch.e2e.ts b/packages/app/tests/stress/asset-click-dispatch.e2e.ts
index 3d124a949..ac36b0210 100644
--- a/packages/app/tests/stress/asset-click-dispatch.e2e.ts
+++ b/packages/app/tests/stress/asset-click-dispatch.e2e.ts
@@ -59,6 +59,37 @@ async function dropFileIntoEditor(
);
}
+function writeEmptyBoard(contentDir: string, runId: string): string {
+ const board = `board-${runId}.excalidraw`;
+ writeFileSync(
+ join(contentDir, board),
+ JSON.stringify({ type: 'excalidraw', version: 2, elements: [], appState: {}, files: {} }),
+ );
+ return board;
+}
+
+async function clickLinkAndExpectBoard(
+ page: Page,
+ docName: string,
+ linkSelector: string,
+ board: string,
+): Promise<void> {
+ await page.goto(`/#/${docName}`);
+ await waitForProvider(page);
+ await page.waitForSelector('.ProseMirror:not(.composer-prosemirror)');
+ await expect(page.locator('[data-resolution-state="asset"]').first()).toBeVisible({
+ timeout: 10_000,
+ });
+
+ await page.click(linkSelector);
+
+ await expect.poll(async () => page.evaluate(() => window.location.hash)).toBe(`#/${board}`);
+ await expect(page.getByRole('main', { name: 'Excalidraw canvas' })).toBeVisible({
+ timeout: 30_000,
+ });
+ await expect(page.getByTestId('asset-preview-open-as-text')).toHaveCount(0);
+}
+
const TINY_PDF_SOURCE = `%PDF-1.4
1 0 obj<</Type/Catalog/Pages 2 0 R>>endobj
2 0 obj<</Type/Pages/Kids[3 0 R]/Count 1>>endobj
@@ -191,6 +222,43 @@ test.describe('asset-click dispatcher — P9 E2E scenarios (SPEC 2026-04-23)', (
await newPage.close();
});
+ test('P9.10c: bare click on a markdown link to an Excalidraw board opens the board canvas', async ({
+ page,
+ api,
+ workerServer,
+ }) => {
+ const board = writeEmptyBoard(workerServer.contentDir, runId);
+ await api.replaceDoc(docName, `# Board link test\n\nSee [the board](./${board}).\n`);
+
+ await clickLinkAndExpectBoard(page, docName, 'span[data-link]', board);
+ });
+
+ test('P9.10d: bare click on a wiki link to an Excalidraw board opens the board canvas', async ({
+ page,
+ api,
+ workerServer,
+ }) => {
+ const board = writeEmptyBoard(workerServer.contentDir, runId);
+ await api.replaceDoc(docName, `# Board link test\n\nSee [[${board}]].\n`);
+
+ await clickLinkAndExpectBoard(page, docName, '[data-wiki-link]', board);
+ });
+
+ test('P9.10e: one Back after a link opens an Excalidraw board returns to the note', async ({
+ page,
+ api,
+ workerServer,
+ }) => {
+ const board = writeEmptyBoard(workerServer.contentDir, runId);
+ await api.replaceDoc(docName, `# Board link test\n\nSee [[${board}]].\n`);
+ await clickLinkAndExpectBoard(page, docName, '[data-wiki-link]', board);
+
+ await page.goBack();
+
+ await expect.poll(async () => page.evaluate(() => window.location.hash)).toBe(`#/${docName}`);
+ await expect(page.getByRole('heading', { level: 1, name: 'Board link test' })).toBeVisible();
+ });
+
test('P9.11: inline image click is a no-op (regression guard — dispatcher does not fire)', async ({
page,
}) => {