Skip to content

feat(content): make adding HTML easy to find in the Content Editor - #1353

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:feature/editor-add-html
Oct 22, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:feature/editor-add-html

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Content Editor feedback item 14: "Add HTML anywhere in the text, as in Webflow". The HTML block already existed (#1260), but only behind the toolbar's text-less </> icon, so it went unnoticed.

  • Toolbar: the HTML block button now reads Add HTML next to its icon. Its accessible name and hint stay "Add an HTML block".
  • On an empty line, a small menu appears beside the cursor: Add · HTML · Table · Image. It puts an HTML block, a table or an image on that line, as Webflow offers between blocks.
    • It is @tiptap/react/menus' FloatingMenu. Its @tiptap/extension-floating-menu is an optional dependency of @tiptap/react and is already in yarn.lock, so no package is added.
    • onEmptyLine decides where it shows: an empty top-level paragraph, in a page with something on it. An empty page shows its placeholder there instead.
    • Its buttons keep the editor's focus (mousedown prevented), so the block goes in where the cursor is.

Not in this PR (possible follow-ups):

  • a sandboxed preview of an HTML block (today it shows its code);
  • the Content Agent writing HTML blocks, which needs a decision on the writer's output.

Related issue

Content Editor feedback round (no issue).

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Open a draft in the Content Editor. The toolbar shows Add HTML, and it opens the HTML block dialog.
  2. Click at the end of the H1 and press Enter. Next to the cursor, Add · HTML · Table · Image shows. HTML opens the dialog and the block goes on that line; Table puts a table there.
  3. On an empty page (no H1 yet), the menu doesn't show; the placeholder does.
  4. yarn test covers onEmptyLine with a real editor (_toolbar.test.ts) and the toolbar's label.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Also run: yarn test (2633 tests pass) and yarn build. Checked in the browser: the menu shows next to the empty line and opens the HTML block dialog.

🤖 Generated with Claude Code

The HTML block was behind a text-less </> icon. The toolbar's button now
reads "Add HTML", and on an empty line between the page's blocks a small
menu offers what can go there, as Webflow does: an HTML block, a table or
an image on that line. It uses @tiptap/react's own FloatingMenu (already
installed with it), and stays off an empty page, which shows its
placeholder there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

@gkhngyk this makes the HTML block easy to find: an 'Add HTML' label on the toolbar button, and an 'Add · HTML · Table · Image' menu on an empty line, using @tiptap/react's FloatingMenu (optional dep, already in yarn.lock; no new package). It touches the editor's page.test.tsx and en.json like #1347–#1351, in other places.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. One optional nit.

  1. _toolbar.tsx:167 with web/messages/en.json:3628: the button now shows "Add HTML", but its accessible name is still "Add an HTML block". Someone using voice control who says "click Add HTML" won't match it (WCAG 2.5.3, label in name). Make the label contain the visible words, e.g. "Add HTML block".

Checked, and fine:

  • HTML goes through the same paths. The menu's HTML opens the existing HtmlBlockDialog. Its code is stored base64-encoded in data-html-block, shown as text in the editor and never run. Table and Image use the toolbar's own commands. A paste still goes through cleanHtml with keepHtmlBlocks: false, so a page pasted from elsewhere can't plant an HTML block, and every save is checked again by sanitizeDraftHtml.
  • No new package. @tiptap/[email protected] is an optional dependency of @tiptap/react and is already in yarn.lock. Its peer @floating-ui/dom is there too (1.8.0). package.json doesn't change, so a frozen-lockfile install on Node 20 is unaffected.

Merge notes

Tested on top of main together with #1353, #1347, #1348, #1350 and #1351: web and server tests, tsc, lint and Prettier pass.

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