BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

Converting blocks to plain text

Open ClementEXWiki opened this issue 10 months ago • 4 comments

In the same vein as editor.blocksToMarkdownLossy and editor.blocksToHTMLLossy, it would be nice to have a editor.blocksToPlainTextLossy converter.

The goal would be to allow converting a set of blocks to plain text, without any particular formatting. Use cases are various, the current one I have is to extract plain text from blocks to make a summary.

Would that be possible? Thanks :)

ClementEXWiki avatar Mar 14 '25 14:03 ClementEXWiki

It isn't super clear what a plaintext representation should look like, at least markdown tries to preserve some of the structure of the document.

Could you not just strip markdown formatting from the markdown representation?

nperez0111 avatar Mar 14 '25 15:03 nperez0111

Actually stripping markdown would be a good solution too. But I think it would be nice to have an adapter doing the equivalent thing without the overhead of re-parsing the markdown output and then stripping informations from it.

Basically the output I would expect from such a converter would be equivalent to a stripped markdown version: you just get plaintext, without any formatting. Things that can't be displayed as pure text such as tables could use the markdown representation as it's visually human readable without knowing anything about any syntax.

ClementEXWiki avatar Mar 17 '25 10:03 ClementEXWiki

Makes sense. A quick workaround could also be to export to HTML and use something like textContent to get the plain text content.

If the current situation is a blocker for you, let us know and we can prioritize this!

YousefED avatar Mar 17 '25 10:03 YousefED

That's a good idea, but I think some things like tables would be absolutely unreadable if we do that.

Note that it is not a priority at all, just a thing that would be nice to have :)

In the meantime, stripping markdown is a perfectly acceptable compromise.

ClementEXWiki avatar Mar 17 '25 10:03 ClementEXWiki