Skip to content

ordered lists - #10

Merged
YousefED merged 1 commit into
mainfrom
ordered-lists
Mar 8, 2022
Merged

YousefED merged 1 commit into
mainfrom
ordered-lists

Conversation

@YousefED

@YousefED YousefED commented Mar 8, 2022

Copy link
Copy Markdown
Collaborator

Sweet! I'll keep the commit on main. Have now also protected that branch :)

I think it might be better to set the position attribute on Block instead of Content. This is more inline with the rest of the codebase (all relevant attributes are on the Block level). However, you'd probably need to use a hack like this; https://stackoverflow.com/a/42035304/194651 (or alternatively, set a data-* dom attribute using decorations?)

I applied some codeformatting (this is done automatically when using the prettier plugin for vscode).

Does skip do anything atm btw?

@vercel

vercel Bot commented Mar 8, 2022

Copy link
Copy Markdown

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/yousefed/blocknote/CwhvdLQePyutyu6xuzW3do3aixFV
✅ Preview: https://blocknote-git-ordered-lists-yousefed.vercel.app

@YousefED
YousefED requested a review from DAlperin March 8, 2022 12:47
@YousefED YousefED changed the title code formatting ordered lists Mar 8, 2022
@DAlperin

DAlperin commented Mar 8, 2022

Copy link
Copy Markdown
Contributor

now also protected that branch

Phew! :)

I think it might be better to set the position attribute on Block instead of Content

I agree, that's how it originally worked but I ran into the problem described in the stackoverflow thread. I like the idea of setting a css variable on the parent and then referencing it. I'll try that.

Does skip do anything atm btw?

Technically yes though it's value is likely limited right now. I think it gives us a tiny performance boost if we choose to expand the schema so that a tcblock can have multiple children offshoots. For now though I think it only saves us 5ish iterations or so per loop. If it adds too much ambiguity then it's probably fine to cut for now.

this is done automatically when using the prettier plugin for vscode

Oops! I'll flip that one in intellij somewhere.

Sorry again about the branch mixup

@YousefED
YousefED merged commit 0696eaf into main Mar 8, 2022
@YousefED

YousefED commented Mar 8, 2022

Copy link
Copy Markdown
Collaborator Author

Ok! I'm merging this so the code formatting is fixed :) Let's judge the skip when the we've fixed the nested lists :)

@nperez0111
nperez0111 deleted the ordered-lists branch October 21, 2025 07:31
YousefED added a commit that referenced this pull request Nov 23, 2026
…down

The markdown export writes a figure with a caption as raw HTML, and the
line feeds of the caption were in that text as they are. The markdown parse
ends a raw HTML block at an empty line. Thus, a caption with an empty line
split the figure: the rest of the caption became a paragraph, and a file
block with such a caption read back as paragraphs.

Now `serializeMediaFigure` writes each line feed of the caption as `
`,
so the figure stays on one line. This is the same for a file, an image, a
video and an audio figure. The HTML parse reads a line feed in text as a
space, thus the caption reads back with one space in place of the line
feeds. A caption on one line gives the same markdown as before.
YousefED added a commit that referenced this pull request Nov 25, 2026
…down

The markdown export writes a figure with a caption as raw HTML, and the
line feeds of the caption were in that text as they are. The markdown parse
ends a raw HTML block at an empty line. Thus, a caption with an empty line
split the figure: the rest of the caption became a paragraph, and a file
block with such a caption read back as paragraphs.

Now `serializeMediaFigure` writes each line feed of the caption as `
`,
so the figure stays on one line. This is the same for a file, an image, a
video and an audio figure. The HTML parse reads a line feed in text as a
space, thus the caption reads back with one space in place of the line
feeds. A caption on one line gives the same markdown as before.
nperez0111 pushed a commit that referenced this pull request Nov 25, 2026
…down

The markdown export writes a figure with a caption as raw HTML, and the
line feeds of the caption were in that text as they are. The markdown parse
ends a raw HTML block at an empty line. Thus, a caption with an empty line
split the figure: the rest of the caption became a paragraph, and a file
block with such a caption read back as paragraphs.

Now `serializeMediaFigure` writes each line feed of the caption as `
`,
so the figure stays on one line. This is the same for a file, an image, a
video and an audio figure. The HTML parse reads a line feed in text as a
space, thus the caption reads back with one space in place of the line
feeds. A caption on one line gives the same markdown as before.
nperez0111 pushed a commit that referenced this pull request Nov 25, 2026
* fix(core): a file block with a caption stays one block in external HTML

The external HTML of a file block with a caption was a `div` with the link
and the caption in a paragraph. An image, a video or an audio block without
a preview, with a caption, had the same form. The HTML parse and the
markdown parse read that as two paragraphs: the file block was lost.

Now `createLinkWithCaption` calls `createFigureWithCaption`. The export is a
figure with the link and a `figcaption`, the form of an image with a
caption. The new function `parseLinkFigure` reads that figure with
`parseFigureElement`. The file parse rule calls it and gives one file block.
The markdown export calls it too, and keeps the figure as HTML with the
function that writes an image with a caption.

`parseLinkFigure` reads only the form that the export writes: the link, then
the `figcaption`, each with only text in it, and no other content. Each
other figure gives the same blocks and the same markdown as before, thus no
text is lost. A figure with a link and without a caption is not a file
block, because the export of a file block without a caption is a link in a
paragraph. A figure with only a link does not tell the block type. Thus, an
image, a video or an audio block without a preview reads back as a file
block.

Test changes: 4 HTML and 4 markdown export snapshots change from the `div`
form to the figure form. The snapshot of `@blocknote/server-util` changes
too: its image without a preview reads back as one file block.

* fix(react): a React file block with a caption stays one block in external HTML

`LinkWithCaption` wrote a `div` with the link and the caption in a
paragraph, as the core helper did. The parse read that as two paragraphs.

Now `LinkWithCaption` renders `FigureWithCaption` when the block has a
caption. The export is the same figure as the export of the core block, and
the file parse rule reads it back as one file block.

Test changes: 4 HTML export snapshots change from the `div` form to the
figure form.

* fix(core): a figure caption with a line feed stays one figure in markdown

The markdown export writes a figure with a caption as raw HTML, and the
line feeds of the caption were in that text as they are. The markdown parse
ends a raw HTML block at an empty line. Thus, a caption with an empty line
split the figure: the rest of the caption became a paragraph, and a file
block with such a caption read back as paragraphs.

Now `serializeMediaFigure` writes each line feed of the caption as `
`,
so the figure stays on one line. This is the same for a file, an image, a
video and an audio figure. The HTML parse reads a line feed in text as a
space, thus the caption reads back with one space in place of the line
feeds. A caption on one line gives the same markdown as before.

This branch was successfully deployed

1 active deployment
Preview — c90f4303 Deployed Mar 8, 2022 by vercel[bot]
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.

2 participants