Skip to content

fix(tiptap): properly interpret Markdown on paste#1459

Open
yaaax wants to merge 4 commits intomainfrom
1439-permettre-de-coller-des-balises-html-dans-léditeur-riche

Hidden character warning

The head ref may contain hidden characters: "1439-permettre-de-coller-des-balises-html-dans-l\u00e9diteur-riche"
Open

fix(tiptap): properly interpret Markdown on paste#1459
yaaax wants to merge 4 commits intomainfrom
1439-permettre-de-coller-des-balises-html-dans-léditeur-riche

Conversation

@yaaax
Copy link
Copy Markdown
Collaborator

@yaaax yaaax commented Mar 31, 2026

  • use marked instance in tiptap editor instead of the separate marked package
  • disable paste rules in order to correctly handle extensions callback already handling paste (e.g. HeadingExtension)
  • Also handle drop
  • New HeadingExtension handling headings realignment in transformPastedHTML callback. Now even copy-pasted HTML content gets its headings realigned

closes #1439

Avant de merger la pull request, s’assurer que :

  • Les checks GitHub passent (lint...).
  • Les tests Cypress ont été lancés en local (dans le cas d’une correction de bug ou d’une nouvelle fonctionnalité).

@yaaax yaaax linked an issue Mar 31, 2026 that may be closed by this pull request
@yaaax yaaax requested review from AdrienMuzyczka, bellangerq, benoitdequick, emma11y and hissalht and removed request for emma11y and hissalht March 31, 2026 15:44
@hissalht hissalht temporarily deployed to ara-1439-permettre-de-c-hwlrux March 31, 2026 15:46 Inactive
@yaaax yaaax self-assigned this Mar 31, 2026
@yaaax yaaax removed their assignment Mar 31, 2026
@yaaax yaaax force-pushed the 1439-permettre-de-coller-des-balises-html-dans-léditeur-riche branch from d40b153 to cba9cb4 Compare March 31, 2026 19:48
@hissalht hissalht temporarily deployed to ara-1439-permettre-de-c-hwlrux March 31, 2026 19:48 Inactive
yaaax added 2 commits April 1, 2026 09:50
* use a simple heuristic (rollback). Not perfect but simple and "good
  enough"
* use marked instance in tiptap editor instead of the separate marked
  package
* disable paste rules in order to correctly handle extensions callback
  already handling paste (e.g. HeadingExtension)
* Also handle drop
* New HeadingExtension handling headings realignment in
  `transformPastedHTML` callback. Now even copy-pasted HTML content gets
  its headings realigned
* Use transformPasted callback in ImageImportPlugin to strip pasted images out (from HTML, meaning also after Markdown parsed into HTML
@yaaax yaaax force-pushed the 1439-permettre-de-coller-des-balises-html-dans-léditeur-riche branch from cba9cb4 to 5a8ec54 Compare April 1, 2026 07:54
@hissalht hissalht temporarily deployed to ara-1439-permettre-de-c-hwlrux April 1, 2026 07:54 Inactive
@hissalht hissalht temporarily deployed to ara-1439-permettre-de-c-hwlrux April 1, 2026 12:57 Inactive
Copy link
Copy Markdown
Collaborator

@bellangerq bellangerq left a comment

Choose a reason for hiding this comment

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

Ça fonctionne nickel, bravo 👏🏼

function getHeadingLevel(el: Element) {
const tag = el.tagName; // e.g. "H1", "H2"
if (/^H[1-6]$/.test(tag)) {
return parseInt(tag[1], 10);
Copy link
Copy Markdown
Collaborator

@bellangerq bellangerq Apr 3, 2026

Choose a reason for hiding this comment

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

Préférence personnelle mais je trouve :

Number(tag[1])

un poil plus clair.

private handleDrop(
view: EditorView,
dragEvent: DragEvent,
_slice: Slice,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ce paramètre n'a pas l'air d'être utilisé.

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.

Permettre de coller des balises HTML dans l'éditeur riche

4 participants