Repository navigation
fix: export a file block without a caption as a paragraph - #3387
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/diagram-block
@blocknote/mantine
@blocknote/math-block
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
@blocknote/xl-typst-exporter
commit: |
|
The external HTML of a file block without a caption was a link alone. A link is inline content. Thus the HTML parse joined two adjacent links into one paragraph: two blocks became one block. Now the link of a file block without a caption is in a paragraph. The export of a file block with a caption was a block-level element (a div) already, and it does not change. Test changes: the HTML export snapshot of a file block without a caption shows the paragraph (one snapshot for the core test schema, one for the React test schema). New test in blocks/File/block.test.ts.
…locks The React file block (`ReactFileBlock`) has its own external HTML. For a block without a caption, it was a link alone, as it was for the file block of the core package. A link is inline content. Thus the HTML parse joined two adjacent links into one paragraph: two blocks became one block. Now the link of a React file block without a caption is in a paragraph, which is the same HTML as the file block of the core package gives. `LinkWithCaption` makes this paragraph when the caption is empty. The export of a file block with a caption does not change. The React image, video and audio blocks do not change.
b2af6a0 to
a090b29
Compare
Main has the new test layout (tests/src/integration, Node or browser tests, setupEditor) and the Knip audit. Conflicts in 21 files: - package.json: the devDependencies of main (knip, postcss), and the two of the lens (@vitest/coverage-v8, eslint-plugin-perfectionist). - packages/xl-ai/package.json: the dependencies of main (no headers-polyfill), and the text-lens exports and the Yjs 14 peers of the lens. - packages/xl-ai/vitestSetup.ts: the version of main (getTestOptionsHost works without a window too). - vite.config.ts: the lint config of main, and the lens plugins and the two lens overrides. The lens override also has the rule of main that forbids an import of a test file. - Table/block.ts: the colwidth helper of the lens, with the colspan limit of main (as in the merge of 21 November). - defaultBlocks.ts: the imports of the two sides. - createLinkWithCaption.ts: the version of the lens. Main has only the half without a caption (#3387); the lens also writes a figure for a caption. - math-block (3 files): the version of main (#3389, the reviewed form of the lens commit 82b18c6). The three test files of that lens commit stay. Three of their cases expect an merror for a formula that KaTeX renders in part (x \badcommand y). Main keeps the MathML of KaTeX for such a formula, thus these three cases fail. - BlockNoteEditor.test.ts (removed by main): the block ID tests of the lens move to BlockNoteEditor.node.test.ts (headless) and BlockNoteEditor.browser.test.ts (mounted), with setupEditor. - DiffVersioningExtension.test.ts, utils.test.ts: the setupEditor form of main, with the tests of the lens in that form. - v1BindingSnapshotDiff.test.ts: the version of main. The change of the lens (the second version is an edit that keeps the block ID) is now in v1BindingSnapshotDiff.fixture.ts. - tests/src/unit/... (5 files): main moved them to tests/src/integration. The new markdownSyntaxText copy snapshots are at the new path. The toggle round-trip case of the lens is in htmlRoundTripCases. The two noCaption snapshots of main and of the lens are equal. - pnpm-lock.yaml, playground/src/examples.gen.tsx: the files of main, then made again by pnpm install and vp run gen. The text-lens example has no ariakit and shadcn dependencies now (the template of main).
main has 91 new commits. Most core conflicts come from core fixes of this branch that went to main as separate pull requests, often in a changed form. For these files, the form of main is the reviewed one. Resolutions: - y/extensions/blockMatchNodes.ts and its browser test, y/utils.ts and its test: the files of main (#3380: blocks pair by ID only). - api/nodeConversions/blockToNode.ts: main (#3383). - api/parsers/html/util/nestedLists.ts and its snapshot: main (#3393, #3404). - blocks/File/block.ts, createLinkWithCaption.ts: main (#3401, #3387). - blocks/Image, Video, Audio: main (#3400). - CheckListItem/block.ts: main (#3388). NumberedListItem/block.ts: main (#3403). - api/exporters/markdown/htmlToMarkdown.ts and api/parsers/markdown/markdownToHtml.ts: main (#3385, #3392, #3394, #3391 and later commits). The parts of the branch that main does not have and that the lens needs come back in separate commits after this merge. - markdownExporter.ts, parseMarkdown.ts, ExportManager.ts, copyExtension.ts, SideMenu/dragging.ts merged without a conflict, but they used the API of the old markdown files of the branch (`escapes`, `target`): main. - serializeBlocksExternalHTML.ts merged without a conflict, but the merge had the toggle child order fix two times and did not compile: the form of main (#3388), with the white space placeholder of the branch. - exportParseEqualityTestInstances.ts: main (the toggle case of #3388). - vite.config.ts: main, with the lint rules of the lens. - tests/vite.config.browser.ts: main, with the lens files. - pnpm-lock.yaml: main, then `vp install`. main moved the shared test document to tests/src/fixtures/exporters (#3420). The lens test helper imports it from there, and the xl-ai build does not include the lens test helpers and benchmarks (a package build cannot read a file outside the package).
…own form The branch tested its own forms of three core fixes. main has the reviewed forms, with their own tests: - `blocks/File/externalHTML.browser.test.ts`: two adjacent file links stay two blocks, and a file link with a caption is one figure. main: #3387 (`fileLinks.browser.test.ts`) and #3401 (the figure snapshots). Three of its cases ("keeps two adjacent image / video / audio blocks without a preview and a caption apart") test the media part of the branch fix, which the queue did not file (it waited for #3337) and which the merge did not keep: main's media blocks are the reviewed form of #3400. These three cases fail on main. No lens test needs the media part. - `blocks/ListItem/CheckListItem/parse.browser.test.ts` ("reads a toggle list item with a check list child as a toggle"). main: #3388 (`toggleListItemWithCheckListChild` in the parse tests).
Summary
The HTML export of a file block without a caption was a link alone. A link is inline content. Thus the HTML parse joined two adjacent file blocks into one paragraph.
The
toExternalHTMLof the file block now puts the link into a<p>element when the block has no caption. The fix is the same for the file block of@blocknote/coreand forReactFileBlockof@blocknote/react(one commit for each).Testing
blocks/File/block.test.ts,blocks/File/block.test.tsx). The two tests fail onmain.<p>element, which has thedata-nameanddata-urlattributes.Notes
LinkWithCaptionis a public export of@blocknote/react. With an empty caption, it now gives a<p>with the link. Before, it gave a<div>with the link and an empty<p>.Summary by CodeRabbit