Skip to content

Commit 4b1605b

Browse files
authored
fix(dependencies): update Tiptap to patched release (#7431)
1 parent fd8c0d0 commit 4b1605b

4 files changed

Lines changed: 96 additions & 87 deletions

File tree

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/dirty-on-open.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
* "Adding different instances of a keyed plugin (suggestion$)".
99
*
1010
* 2. A markdown file authored outside the editor (e.g. the former Monaco editor) is rarely in the
11-
* editor's canonical serialization. On open, a deferred view-plugin transaction re-serializes the
12-
* doc to canonical markdown and emits one update — which, compared against the raw saved bytes,
13-
* falsely marks the file dirty ("unsaved changes"). The fix normalizes the dirty-check baseline to
14-
* the canonical form; this asserts that normalized form equals what the live editor emits.
11+
* editor's canonical serialization. The dirty-check baseline must use that canonical form so any
12+
* mount-time update remains clean.
1513
*/
1614

1715
import { sleep } from '@sim/utils/helpers'
@@ -79,28 +77,30 @@ describe('normalizeMarkdownContent — dirty-on-open baseline', () => {
7977
})
8078
})
8179

82-
describe('baseline neutralizes the mount-time dirty signal', () => {
83-
it('the editor mount serialization equals the normalized baseline (so isDirty stays false)', async () => {
80+
describe('baseline neutralizes mount-time dirty signals', () => {
81+
it('mounting never produces content that differs from the normalized baseline', async () => {
8482
const raw = '# H\n\n* bullet\n\n| a | b |\n| --- | --- |\n| 1 | 2 |\n\n> quote\n'
8583
const { frontmatter, body } = splitFrontmatter(raw)
84+
const canonical = normalizeMarkdownContent(raw)
8685
host = document.createElement('div')
8786
document.body.appendChild(host)
8887

89-
let emitted: string | null = null
88+
let dirtyUpdate: string | null = null
9089
editor = new Editor({
9190
element: host,
9291
extensions: createMarkdownEditorExtensions({ placeholder: 'x' }),
9392
content: parseMarkdownToDoc(body),
9493
onUpdate: ({ editor }) => {
95-
emitted = applyFrontmatter(frontmatter, postProcessSerializedMarkdown(editor.getMarkdown()))
94+
const content = applyFrontmatter(
95+
frontmatter,
96+
postProcessSerializedMarkdown(editor.getMarkdown())
97+
)
98+
if (content !== canonical) dirtyUpdate = content
9699
},
97100
})
98101

99102
await sleep(30)
100103

101-
// The deferred mount transaction re-serializes to canonical markdown; the baseline must match it
102-
// exactly, so `content === savedContent` and the file is never falsely dirty on open.
103-
expect(emitted).not.toBeNull()
104-
expect(emitted).toBe(normalizeMarkdownContent(raw))
104+
expect(dirtyUpdate).toBeNull()
105105
})
106106
})

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/raw-markdown-snippet-view.test.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@
99
* back to markdown.
1010
*/
1111

12+
import { act, createElement } from 'react'
1213
import { sleep } from '@sim/utils/helpers'
1314
import { Editor } from '@tiptap/core'
15+
import { EditorContent } from '@tiptap/react'
16+
import { createRoot, type Root } from 'react-dom/client'
1417
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
1518
import { createMarkdownEditorExtensions } from './editor-extensions'
1619

1720
let editor: Editor | null = null
21+
let root: Root | null = null
22+
let host: HTMLElement | null = null
1823

1924
beforeEach(() => {
2025
// The live extension set's placeholder viewport-tracking and suggestion popups use these; jsdom
@@ -32,16 +37,25 @@ beforeEach(() => {
3237
})
3338

3439
afterEach(() => {
40+
if (root) act(() => root?.unmount())
3541
editor?.destroy()
3642
editor = null
43+
root = null
44+
host?.remove()
45+
host = null
3746
})
3847

3948
function mount(markdown: string): Editor {
40-
return new Editor({
49+
const mountedEditor = new Editor({
4150
extensions: createMarkdownEditorExtensions({ placeholder: '' }),
4251
content: markdown,
4352
contentType: 'markdown',
4453
})
54+
host = document.createElement('div')
55+
document.body.appendChild(host)
56+
root = createRoot(host)
57+
act(() => root?.render(createElement(EditorContent, { editor: mountedEditor })))
58+
return mountedEditor
4559
}
4660

4761
function posOf(ed: Editor, typeName: string): number {
@@ -54,16 +68,11 @@ function posOf(ed: Editor, typeName: string): number {
5468

5569
/** React node views flush on a microtask after mount, so DOM assertions need one tick. */
5670
function nextTick(): Promise<void> {
57-
return sleep(0)
71+
return act(async () => {
72+
await sleep(0)
73+
})
5874
}
5975

60-
// The hover "Raw HTML"/"Footnote" badge is rendered by `RawBlockView` through
61-
// `ReactNodeViewRenderer`, which only flushes its React portal once `@tiptap/react`'s
62-
// `contentComponent` is set — that requires mounting through `<EditorContent>` (a real React render
63-
// tree), which this repo's tests don't do for this directory (no `@testing-library/react` installed
64-
// here) and constructing a plain `new Editor()` doesn't provide. What IS verifiable and matters more
65-
// at this level — the node renders with the correct wrapper class and holds the exact raw source
66-
// text — is covered below; the badge itself is decorative chrome, checked manually.
6776
describe('raw markdown snippet node views (live editor)', () => {
6877
it('renders a raw HTML block with the correct wrapper class and exact raw source', async () => {
6978
editor = mount('<details><summary>More</summary>\n\nbody\n\n</details>')

apps/sim/package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -129,21 +129,21 @@
129129
"@t3-oss/env-nextjs": "0.13.4",
130130
"@tanstack/react-query": "5.90.8",
131131
"@tanstack/react-virtual": "3.13.24",
132-
"@tiptap/core": "3.26.1",
133-
"@tiptap/extension-code": "3.26.1",
134-
"@tiptap/extension-code-block": "3.26.1",
135-
"@tiptap/extension-collaboration": "3.26.1",
136-
"@tiptap/extension-collaboration-caret": "3.26.1",
137-
"@tiptap/extension-image": "3.26.1",
138-
"@tiptap/extension-list": "3.26.1",
139-
"@tiptap/extension-placeholder": "3.26.1",
140-
"@tiptap/extension-paragraph": "3.26.1",
141-
"@tiptap/extension-table": "3.26.1",
142-
"@tiptap/markdown": "3.26.1",
143-
"@tiptap/pm": "3.26.1",
144-
"@tiptap/react": "3.26.1",
145-
"@tiptap/starter-kit": "3.26.1",
146-
"@tiptap/suggestion": "3.26.1",
132+
"@tiptap/core": "3.30.5",
133+
"@tiptap/extension-code": "3.30.5",
134+
"@tiptap/extension-code-block": "3.30.5",
135+
"@tiptap/extension-collaboration": "3.30.5",
136+
"@tiptap/extension-collaboration-caret": "3.30.5",
137+
"@tiptap/extension-image": "3.30.5",
138+
"@tiptap/extension-list": "3.30.5",
139+
"@tiptap/extension-placeholder": "3.30.5",
140+
"@tiptap/extension-paragraph": "3.30.5",
141+
"@tiptap/extension-table": "3.30.5",
142+
"@tiptap/markdown": "3.30.5",
143+
"@tiptap/pm": "3.30.5",
144+
"@tiptap/react": "3.30.5",
145+
"@tiptap/starter-kit": "3.30.5",
146+
"@tiptap/suggestion": "3.30.5",
147147
"@tiptap/y-tiptap": "3.0.7",
148148
"@trigger.dev/core": "4.5.12",
149149
"@trigger.dev/sdk": "4.5.12",

0 commit comments

Comments
 (0)