Skip to content

feat(frontend): save project descriptions as HTML alongside markdown (#90) - #1002

Merged
github-actions[bot] merged 1 commit into
Smartdevs17:mainfrom
sandrawillow001-afk:feat/rich-text-editor-html-90
Sep 29, 2026
Merged

github-actions[bot] merged 1 commit into
Smartdevs17:mainfrom
sandrawillow001-afk:feat/rich-text-editor-html-90

Conversation

@sandrawillow001-afk

@sandrawillow001-afk sandrawillow001-afk commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Coordination note. Issue #90 is currently assigned to @Tsammie. This PR implements the same subject matter; please coordinate with them before merging so the effort is not duplicated.

Closes #90.

What already existed

The rich text editor from #795 (components/markdown/RichTextEditor.tsx) already covered three of the four acceptance criteria — rich text editing, formatting and image support — storing markdown as the source of truth.

Gap closed: "save as HTML"

  • lib/markdown/to-html.ts — markdown → HTML serializer covering the subset the editor can produce: headings, bold/italic/strikethrough, inline and fenced code, links, images, lists, block quotes and rules.
  • lib/projects/work-description.ts — builds the on-chain workDescription payload with both description (markdown) and descriptionHtml. Both /dashboard/projects/new and /[locale]/dashboard/projects/new now call this helper, so the contract shape stays in sync.
  • Editor — an HTML toggle next to Preview that shows the generated HTML with a Copy HTML button.

Security posture

The conversion is dependency-free and never passes raw HTML through: every text run is escaped (<script> → &lt;script&gt;), only http:/https:/mailto: URLs are emitted, and javascript:, data:, vbscript: and protocol-relative URLs are dropped. External links get rel="noopener noreferrer"; images get loading="lazy".

Why not react-markdown for this

The preview renders through react-markdown, but the project has no markdown stringifier dependency (rehype-stringify), and adding one purely for this feature would be a heavier change than it warrants.

Verification

cd frontend
npx vitest run lib/markdown lib/projects   # 40 passed
npx eslint lib/markdown lib/projects components/markdown/RichTextEditor.tsx \
  app/dashboard/projects/new/page.tsx                                        # clean
npx tsc --noEmit | grep -cE 'lib/markdown|lib/projects|RichTextEditor|projects/new/page'  # 0

Finding not addressed here (pre-existing, worth a follow-up)

The frontend component test suite cannot run on main: @testing-library/react, @testing-library/user-event and @testing-library/jest-dom are imported by ~8 test files (including vitest.setup.ts) and by the merged #795 editor test, but are not declared in frontend/package.json, and vitest.config.ts never sets setupFiles, so vitest.setup.ts is dead. I kept this PR free of test-infrastructure churn; declaring those devDependencies and wiring setupFiles: ['./vitest.setup.ts'] is a separate change (it unblocks those files, though ~5 of them then fail for unrelated pre-existing reasons).


🤖 Generated with Codebuff

…martdevs17#90)

The rich text editor (issue Smartdevs17#795) stored descriptions as markdown only, so the
"save as HTML" acceptance criterion was unmet and consumers that cannot render
markdown had nothing to display.

- lib/markdown/to-html.ts: dependency-free markdown -> HTML serializer covering
  the subset the editor produces (headings, emphasis, strikethrough, inline and
  fenced code, links, images, lists, quotes, rules). Raw HTML is never passed
  through and only http/https/mailto URLs are emitted, so hostile input cannot
  introduce markup or script.
- lib/projects/work-description.ts: builds the on-chain `workDescription`
  payload with both `description` (markdown) and `descriptionHtml`, used by
  /dashboard/projects/new and its localized variant so the shape stays in sync.
- RichTextEditor: add an HTML view toggle with Copy HTML, alongside the existing
  preview toggle.
- docs: document the HTML rendition, the payload shape and the security posture.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@vercel

vercel Bot commented Sep 29, 2026

Copy link
Copy Markdown

@sandrawillow001-afk is attempting to deploy a commit to the smartdevs17's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
github-actions Bot merged commit b3e714f into Smartdevs17:main Sep 29, 2026
16 of 38 checks passed
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.

Frontend: Add rich text editor for project descriptions

1 participant