dorfteich/packages/shared/src/editor-schema/plain-text.test.ts
Claude Sonnet 5 b89aa6bed0
Some checks failed
CD / Build and push images (push) Successful in 1m50s
CI / Lint, typecheck, test (push) Failing after 52s
CI / Auth e2e pack (push) Successful in 1m47s
CI / Build container images (push) Has been skipped
CD / Deploy to Test (push) Successful in 8s
CD / Smoke tests against Test (push) Successful in 1m5s
CD / Promote to Int (push) Successful in 10s
Add editor document schema in packages/shared (#24)
ProseMirror schema (headings 1-4, lists incl. task lists, blockquote,
code block, tables via prosemirror-tables, images, hard breaks; bold/
italic/code/strikethrough/link marks) plus docToMarkdown, markdownToDoc,
docToPlainText, docToHtml, and extractOutline built on it. Markdown
parsing extends markdown-it's default preset with a token-stream
transform for GFM task lists and table-cell paragraph wrapping.
docToHtml hand-rolls escaping and link-protocol allowlisting with zero
DOM dependencies, so it runs in the API/collab server as well as the
browser.

Node names `wikilink` and `plugin_block` are reserved for later stories.

Closes #24
2026-07-05 21:59:12 +02:00

17 lines
603 B
TypeScript

import { describe, expect, it } from 'vitest';
import { markdownToDoc } from './markdown';
import { docToPlainText } from './plain-text';
describe('docToPlainText (issue #24)', () => {
it('strips formatting and joins blocks with blank lines', () => {
const doc = markdownToDoc('# Title\n\nA **bold** paragraph.\n\n- One\n- Two');
expect(docToPlainText(doc)).toBe('Title\n\nA bold paragraph.\n\nOne\n\nTwo');
});
it('falls back to alt text for images', () => {
const doc = markdownToDoc('![A pond at dusk](file-1)');
expect(docToPlainText(doc)).toBe('A pond at dusk');
});
});