Phase E of the AFFiNE parity plan (ADR-15): - internal/ai: OpenAI-compatible, Anthropic (official Go SDK) and Ollama drivers; BYOK profiles per workspace and for the instance, with keys encrypted by DOCWELL_SECRET_KEY, failover order, a test call and usage counters. - Embeddings: an indexer that follows PocketBase like the search index, chunks pages along their blocks and keeps vectors in a bbolt file in the data dir (no cgo); progress, ignored pages and extra files. - Chat sessions scoped to a page, space or workspace, streamed as server-sent events, with citations to pages and blocks, fork and history; retrieval only from pages the asker can read. - Writing actions (rewrite, fix, shorter, longer, summarise, translate, continue, custom) in the editor's selection toolbar. - POST /mcp: MCP over Streamable HTTP with personal API tokens; read tokens search and read pages, write tokens also create and update them. - Web app chat panel (Ctrl+J), workspace AI settings, an admin AI page, OpenAPI, generated clients, migration and translations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
25 lines
942 B
TypeScript
25 lines
942 B
TypeScript
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
import { markdownToEditorHTML, renderMarkdown } from "./markdown";
|
|
|
|
describe("renderMarkdown", () => {
|
|
it("links citations outside code and strips scripts", () => {
|
|
const html = renderMarkdown("Use the **form** [1][2].\n\n`a[3]`\n\n<script>alert(1)</script>", true);
|
|
expect(html).toContain('<a href="#cite-1" class="dw-cite" data-cite="1">1</a>');
|
|
expect(html).toContain('data-cite="2"');
|
|
expect(html).toContain("<code>a[3]</code>");
|
|
expect(html).not.toContain("<script");
|
|
});
|
|
|
|
it("leaves citations alone without the flag", () => {
|
|
expect(renderMarkdown("x [1]")).toContain("x [1]");
|
|
});
|
|
|
|
it("makes editor HTML from lists and headings", () => {
|
|
const html = markdownToEditorHTML("## Title\n\n- one\n- two\n");
|
|
expect(html).toContain("<h2>Title</h2>");
|
|
expect(html).toContain("<li>one</li>");
|
|
});
|
|
});
|