d6d1195abd
Move every SERVER ProseMirror->Markdown path off the editor-ext markdown layer
(`htmlToMarkdown`, a second turndown-based converter) onto the canonical
`@docmost/prosemirror-markdown` package.
- `ExportService.exportPage` (page/space markdown export) and
`collaboration.util.jsonToMarkdown` (used by page.controller's markdown
responses and the AI public-share chat tool) now serialize DIRECTLY from
ProseMirror JSON via `convertProseMirrorToMarkdown` — no HTML intermediate, no
`<colgroup>` scrub (the converter emits GFM tables directly).
This is the SAME serializer the git-sync vault writer feeds, so an exported page
BODY is byte-identical to its vault representation: no more export-md vs vault-md
drift. The HTML export path is unchanged (still `jsonToHtml`).
Emitted markdown moves to the canonical forms: callouts `> [!type]` (not
`:::type`), inline footnotes `^[…]` (not `[^id]`), lossless images
` <!--img {…}-->` (editor-ext dropped width/height/align).
Fixtures-first: export-markdown.spec asserts those canonical forms and the
export==vault-by-construction equality (both call the package converter). The
one deliberate export/vault delta — export prepends the page title as an H1
while the vault carries it in frontmatter — is pinned by a test.
Test infra: declare the `@docmost/prosemirror-markdown` workspace dep; teach
jest to load its ESM build (babel-jest) and stub `@tiptap/react` (server code
imports editor-ext, whose node views reference React renderers only used in a
live browser editor — never on the server).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
14 lines
715 B
JavaScript
14 lines
715 B
JavaScript
// Jest stub for @tiptap/react. The server export/import code paths transitively
|
|
// import editor-ext, whose node extensions reference `ReactNodeViewRenderer`
|
|
// inside `addNodeView()` — code that only runs inside a live browser editor and
|
|
// is NEVER invoked on the server. The real module eagerly pulls react-dom, which
|
|
// throws `navigator is not defined` under jest's node environment. This stub
|
|
// supplies the named exports the extensions bind at import time; if any were
|
|
// actually called on the server that would (correctly) surface as a test error.
|
|
module.exports = {
|
|
ReactNodeViewRenderer: () => () => ({}),
|
|
NodeViewWrapper: () => null,
|
|
NodeViewContent: () => null,
|
|
ReactRenderer: class {},
|
|
};
|