Skip to content

feat: Table of Contents and Child Pages Component - #298

Closed
Shadowfita wants to merge 11 commits into
docmost:mainfrom
Shadowfita:Table-of-Contents
Closed

Shadowfita wants to merge 11 commits into
docmost:mainfrom
Shadowfita:Table-of-Contents

Conversation

@Shadowfita

Copy link
Copy Markdown
Contributor

This pull request adds a feature complete table of contents/child pages component that resolves #204 and resolves #95 .

Please see #241 for previous discussions.

image

image

@CLAassistant

CLAassistant commented Jan 10, 2025 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@thevops

thevops commented Jan 16, 2025

Copy link
Copy Markdown

Hi 👋
Table of content is a very useful feature. I'm looking forward to have it 🤞

@Jacopo-DeAngelis

Copy link
Copy Markdown

Hi @Shadowfita, could you check the Contributor License Agreement? This feature would be very useful

@Shadowfita

Copy link
Copy Markdown
Contributor Author

Hi @Shadowfita, could you check the Contributor License Agreement? This feature would be very useful

Oh weird, I had completed it previously. I'll check it out in the morning.

@Scrub000

Copy link
Copy Markdown

Is it possible to export the table of contents?

@GOvEy1nw

GOvEy1nw commented Apr 2, 2025

Copy link
Copy Markdown

Is this still to be added please? Could really do with this feature.

@Philipinho

Copy link
Copy Markdown
Member

Closing as we now have table of contents integrated #981.
I will consider supporting child pages node in the future.

@Philipinho

Copy link
Copy Markdown
Member

For child pages, see #1462.

vvzvlad pushed a commit to vvzvlad/gitmost that referenced this pull request Jul 3, 2026
…he server (docmost#298)

Page/space export (Markdown & HTML, both via jsonToHtml -> generateHTML) crashed with
"Export failed:undefined" on any page carrying a `comment` mark. Root cause:
comment.renderHTML returned a LIVE DOM node (document.createElement + a click listener)
whenever a global `document` existed — and the in-process MCP module injects a jsdom
global.window+global.document into the Node server, defeating the old
`typeof document === "undefined"` guard. The server export runs happy-dom's
DOMSerializer, which crashes appending the foreign jsdom node
(NodeUtility.isInclusiveAncestor -> "Cannot read properties of undefined (reading
'length')"). comment is the only extension returning a live node.

Fix: widen the guard with an isNodeRuntime check (process.versions.node) so on any Node
runtime renderHTML returns the plain, serializable spec array — even when MCP injected
jsdom globals. The browser branch (createElement + click -> ACTIVE_COMMENT_EVENT) is
untouched, so in-editor comment interactivity is preserved (Vite defines only
process.env as a member-expression substitution, no `process` object in the browser
bundle, so isNodeRuntime is false there). The mcp schema mirror already returns a spec
array and is not on the export path (tiptapExtensions imports Comment from
@docmost/editor-ext), so no mirror change is needed.

Also: export-modal now reads the real error text from the response Blob
(responseType:'blob' made err.response.data.message always undefined) so a failed export
shows the server's message instead of "undefined".

Adds a regression test that runs the real jsonToHtml on a comment-marked doc with
jsdom globals injected (reproduces the crash on the unpatched code, passes after).

closes docmost#298

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
vvzvlad pushed a commit to vvzvlad/gitmost that referenced this pull request Jul 3, 2026
…e isNodeRuntime guard (F1)

The whole fix's correctness rests on isNodeRuntime being false in the browser (so the
interactive live-DOM comment branch still runs), and that is NOT covered by any test
(client vitest runs under jsdom->node where isNodeRuntime is true). Document it: Vite
substitutes only process.env, not the bare process object, so typeof process is
undefined in the client bundle; do not add a process polyfill without revisiting this
guard, or comment interactivity dies silently.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
vvzvlad pushed a commit to vvzvlad/gitmost that referenced this pull request Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Table of Content macro [Feature Request] Table of Contents and Table of Child Pages

7 participants