-
Notifications
You must be signed in to change notification settings - Fork 84
[WC-3464] Rich text Tiptapeditor #2270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gjulivan
wants to merge
10
commits into
main
Choose a base branch
from
rich-text/tiptapeditor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+27,467
−18,538
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
16798bc
chore: updated version of rich text with tiptap
2898c83
chore: add i18, fix stylings, add help, fix table resize, fix image u…
13a8ffe
fix: styling and dimension and image drag and table indent and videos
3562bb4
fix: word paste clipboard
86c0588
fix: changelog
fb5b371
fix: border classnames
af5e376
test(rich-text): update e2e spec and screenshot
leonardomendix 42ddfe4
fix: add font icons version and fix css and fix readonly style
a21af6c
fix: unit test
30194b1
fix: update editor when attribute value changed
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+6.05 KB
(120%)
...web/e2e/RichText.spec.js-snapshots/bottomToolbarAdvancedMode-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+6.55 KB
(120%)
...rich-text-web/e2e/RichText.spec.js-snapshots/inlineBasicMode-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5.07 KB
(120%)
...ich-text-web/e2e/RichText.spec.js-snapshots/inlineCustomMode-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.82 KB
(110%)
...ch-text-web/e2e/RichText.spec.js-snapshots/insertImageDialog-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5.91 KB
(120%)
...-text-web/e2e/RichText.spec.js-snapshots/toolbarAdvancedMode-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+6.69 KB
(120%)
...ich-text-web/e2e/RichText.spec.js-snapshots/toolbarBasicMode-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+20 KB
(120%)
.../rich-text-web/e2e/RichText.spec.js-snapshots/viewCodeDialog-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
146 changes: 146 additions & 0 deletions
146
packages/pluggableWidgets/rich-text-web/e2e/RichTextWordPaste.spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| import { expect, test } from "@mendix/run-e2e/fixtures"; | ||
| import { waitForMendixApp } from "@mendix/run-e2e/mendix-helpers"; | ||
|
|
||
| /** | ||
| * Word clipboard HTML. The heading is the shape Word actually puts on the | ||
| * clipboard for a numbered heading: the number lives in an `mso-list:Ignore` | ||
| * span padded by a 7pt run of non-breaking spaces, wrapped in a downlevel-revealed | ||
| * conditional comment, and the indent is a `26.1pt` margin that carries an | ||
| * `mso-list` level alongside it. The bullet paragraph uses Word's symbol-font | ||
| * hack, where a middle dot in Symbol stands in for a real bullet character. | ||
| */ | ||
| const WORD_CLIPBOARD_HTML = `<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word"> | ||
| <head><meta name=Generator content="Microsoft Word 15"></head> | ||
| <body> | ||
| <div class=WordSection1> | ||
| <h1 style='margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;margin-left: | ||
| 26.1pt;mso-list:l0 level1 lfo1;tab-stops:list 26.1pt left .5in'><![if !supportLists]><span | ||
| style='mso-fareast-font-family:Arial;mso-bidi-font-family:Arial'><span | ||
| style='mso-list:Ignore'>2.<span style='font:7.0pt "Times New Roman"'> | ||
| </span></span></span><![endif]><span style='mso-bidi-font-family:Arial'>SCOPE | ||
| OF ESTIMATE<o:p></o:p></span></h1> | ||
| <p class=MsoListParagraph style='margin-left:72.0pt;text-indent:-18.0pt;mso-list:l1 level2 lfo2'><![if !supportLists]><span | ||
| style='font-family:Symbol'><span style='mso-list:Ignore'>·<span | ||
| style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span | ||
| style='mso-bidi-font-family:Arial'>Bulleted detail<o:p></o:p></span></p> | ||
| </div> | ||
| </body> | ||
| </html>`; | ||
|
|
||
| /** Pastes `text/html` into a contenteditable the way a real clipboard paste arrives. */ | ||
| async function pasteHtml(editor, html) { | ||
| await editor.click(); | ||
| await editor.evaluate((element, clipboardHtml) => { | ||
| const dataTransfer = new DataTransfer(); | ||
| dataTransfer.setData("text/html", clipboardHtml); | ||
| dataTransfer.setData("text/plain", element.textContent ?? ""); | ||
| element.dispatchEvent( | ||
| new ClipboardEvent("paste", { clipboardData: dataTransfer, bubbles: true, cancelable: true }) | ||
| ); | ||
| }, html); | ||
| } | ||
|
|
||
| /** Empties the editor so assertions only see the pasted content. */ | ||
| async function clearEditor(page, editor) { | ||
| await editor.click(); | ||
| await editor.selectText(); | ||
| await page.keyboard.press("Backspace"); | ||
| } | ||
|
|
||
| test.describe("RichText — pasting from Microsoft Word", () => { | ||
| test.describe.configure({ mode: "serial" }); | ||
|
|
||
| test("indents pasted Word content by its real level and keeps the list marker readable", async ({ page }) => { | ||
| await page.goto("/p/advanced"); | ||
| await waitForMendixApp(page); | ||
|
|
||
| const widget = page.locator(".mx-name-richText1"); | ||
| const editor = widget.locator(".tiptap"); | ||
| await editor.scrollIntoViewIfNeeded(); | ||
| await expect(editor).toBeVisible(); | ||
|
|
||
| await clearEditor(page, editor); | ||
| await pasteHtml(editor, WORD_CLIPBOARD_HTML); | ||
|
|
||
| // The heading survives as a heading and its number survives as text. | ||
| const heading = editor.locator("h1"); | ||
| await expect(heading).toHaveCount(1); | ||
| await expect(heading).toContainText("2. SCOPE OF ESTIMATE"); | ||
|
|
||
| // Level 1 emits `2em`. The bug under test emitted `20em` — the clamped | ||
| // maximum — for this same 26.1pt source margin. Asserted on the emitted | ||
| // value rather than the computed pixels, because `em` resolves against | ||
| // the heading's own font-size and so is not a fixed pixel count. | ||
| await expect(heading).toHaveAttribute("style", /margin-left:\s*2em/); | ||
| await expect(heading).not.toHaveAttribute("style", /margin-left:\s*20em/); | ||
|
|
||
| // The bullet paragraph is at Word level 2, and its symbol-font middle dot | ||
| // is now a real bullet character rather than a literal `·` in Symbol. | ||
| const bullet = editor.locator("p", { hasText: "Bulleted detail" }).first(); | ||
| await expect(bullet).toHaveAttribute("style", /margin-left:\s*4em/); | ||
| await expect(bullet).toContainText("• Bulleted detail"); | ||
| }); | ||
|
|
||
| test("leaves no Word markup residue in the editor output", async ({ page }) => { | ||
| await page.goto("/p/advanced"); | ||
| await waitForMendixApp(page); | ||
|
|
||
| const editor = page.locator(".mx-name-richText1 .tiptap"); | ||
| await editor.scrollIntoViewIfNeeded(); | ||
| await expect(editor).toBeVisible(); | ||
|
|
||
| await clearEditor(page, editor); | ||
| await pasteHtml(editor, WORD_CLIPBOARD_HTML); | ||
| await expect(editor.locator("h1")).toContainText("SCOPE OF ESTIMATE"); | ||
|
|
||
| const html = await editor.innerHTML(); | ||
|
|
||
| expect(html).not.toMatch(/mso-/i); | ||
| expect(html).not.toMatch(/Mso[A-Z]/); | ||
| expect(html).not.toContain("tab-stops"); | ||
| expect(html).not.toContain("supportLists"); | ||
| expect(html).not.toContain("o:p"); | ||
| // The 7pt tab filler and its run of non-breaking spaces are gone. | ||
| expect(html).not.toContain("7pt"); | ||
| // The number is text in the block, not a reconstructed list. | ||
| expect(html).not.toContain("<ol"); | ||
| }); | ||
|
|
||
| test("keeps Word indentation in class mode, where margins are not emitted", async ({ page }) => { | ||
| await page.goto("/p/classmode"); | ||
| await waitForMendixApp(page); | ||
|
|
||
| const editor = page.locator(".mx-name-richText1 .tiptap"); | ||
| await editor.scrollIntoViewIfNeeded(); | ||
| await expect(editor).toBeVisible(); | ||
|
|
||
| await clearEditor(page, editor); | ||
| await pasteHtml(editor, WORD_CLIPBOARD_HTML); | ||
|
|
||
| const heading = editor.locator("h1"); | ||
| await expect(heading).toContainText("2. SCOPE OF ESTIMATE"); | ||
| await expect(heading).toHaveAttribute("data-indent", "1"); | ||
| await expect(heading).toHaveClass(/indent-1/); | ||
|
|
||
| // Class mode expresses indentation through the class, never inline. | ||
| expect(await editor.innerHTML()).not.toMatch(/style="[^"]*margin-left/); | ||
| }); | ||
|
|
||
| test("indents a paste from a non-Word source from its margin alone", async ({ page }) => { | ||
| await page.goto("/p/advanced"); | ||
| await waitForMendixApp(page); | ||
|
|
||
| const editor = page.locator(".mx-name-richText1 .tiptap"); | ||
| await editor.scrollIntoViewIfNeeded(); | ||
| await expect(editor).toBeVisible(); | ||
|
|
||
| await clearEditor(page, editor); | ||
| await pasteHtml(editor, '<h1 style="margin-left: 64px">Plain heading</h1>'); | ||
|
|
||
| // The sanitizer does not run here — there are no Word markers — so the | ||
| // level comes from unit-aware margin parsing alone: 64px is two levels. | ||
| const heading = editor.locator("h1"); | ||
| await expect(heading).toContainText("Plain heading"); | ||
| await expect(heading).toHaveAttribute("style", /margin-left:\s*4em/); | ||
| }); | ||
| }); |
2 changes: 2 additions & 0 deletions
2
...ages/pluggableWidgets/rich-text-web/openspec/changes/add-cell-column-width/.openspec.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| schema: spec-driven | ||
| created: 2026-06-05 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.