Repository navigation
ordered lists - #10
Conversation
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/yousefed/blocknote/CwhvdLQePyutyu6xuzW3do3aixFV |
Phew! :)
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.
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.
Oops! I'll flip that one in intellij somewhere. Sorry again about the branch mixup |
|
Ok! I'm merging this so the code formatting is fixed :) Let's judge the |
…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.
…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.
…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.
* 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.
Sweet! I'll keep the commit on
main. Have now also protected that branch :)I think it might be better to set the
positionattribute onBlockinstead ofContent. This is more inline with the rest of the codebase (all relevant attributes are on theBlocklevel). However, you'd probably need to use a hack like this; https://stackoverflow.com/a/42035304/194651 (or alternatively, set adata-*dom attribute using decorations?)I applied some codeformatting (this is done automatically when using the prettier plugin for vscode).
Does
skipdo anything atm btw?