MuckRock / documentcloud-frontend

DocumentCloud's front end source code - Please report bugs, issues and feature requests to info@documentcloud.org
https://www.documentcloud.org
GNU Affero General Public License v3.0
15 stars 5 forks source link

HTML/Markdown editor #572

Open eyeseast opened 3 weeks ago

eyeseast commented 3 weeks ago

Some fields allow (some) HTML. We should have a way to edit that text, without just asking people to write HTML from scratch.

The current site has an HtmlField component. We probably need something similar.

It would be very nice if we could turn the server-sent HTML into Markdown for editing, and then back into HTML to save.

eyeseast commented 3 weeks ago

Some options:

Thomas Wilburn wrote a converter: https://github.com/Chalkbeat/powertoys/blob/main/paraphrase/htmlToMarkdown.js

Showdown has an undocumented HTML to markdown converter: https://github.com/showdownjs/showdown/blob/master/src/converter.js#L360

CommonMark probably does it, but can't find documentation right now. There are a bunch of libraries on NPM that might work but I don't want to dig through that pile.

Tom MacWright has more options here: https://macwright.com/2024/01/28/dont-use-marked