From 1de3b913a1ce35a539e6eff631bb4a3bbb9614c9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 May 2026 15:35:03 +0000 Subject: [PATCH 1/3] build(deps): bump slackapi/slack-github-action from 3.0.1 to 3.0.3 Bumps [slackapi/slack-github-action](https://github.com/slackapi/slack-github-action) from 3.0.1 to 3.0.3. - [Release notes](https://github.com/slackapi/slack-github-action/releases) - [Changelog](https://github.com/slackapi/slack-github-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/slackapi/slack-github-action/compare/v3.0.1...v3.0.3) --- updated-dependencies: - dependency-name: slackapi/slack-github-action dependency-version: 3.0.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/notify.yml | 2 +- .github/workflows/publish.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/notify.yml b/.github/workflows/notify.yml index 6162e6e4cb..55d04ea1a7 100644 --- a/.github/workflows/notify.yml +++ b/.github/workflows/notify.yml @@ -28,7 +28,7 @@ jobs: permissions: {} steps: - name: Send Slack release notification - uses: slackapi/slack-github-action@v3.0.1 + uses: slackapi/slack-github-action@v3.0.3 with: webhook: ${{ secrets.SLACK_WEBHOOK_URL }} webhook-type: webhook-trigger diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index dbe15e64bb..79c0835710 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -147,7 +147,7 @@ jobs: steps: - name: Send Slack notification - uses: slackapi/slack-github-action@v3.0.1 + uses: slackapi/slack-github-action@v3.0.3 with: webhook: ${{ secrets.SLACK_WEBHOOK_URL }} webhook-type: webhook-trigger @@ -168,7 +168,7 @@ jobs: steps: - name: Send Slack failure notification - uses: slackapi/slack-github-action@v3.0.1 + uses: slackapi/slack-github-action@v3.0.3 with: webhook: ${{ secrets.SLACK_WEBHOOK_URL }} webhook-type: webhook-trigger From a8a5857c407315b4d117643e83de3c4c646fe4ac Mon Sep 17 00:00:00 2001 From: Giorgio Garofalo Date: Thu, 30 Apr 2026 18:01:42 -0700 Subject: [PATCH 2/3] fix(extension-mathematics): honor empty-string latex in updateBlockMath `updateBlockMath` used a falsy fallback (`latex || node.attrs.latex`) that ignored an explicit `latex: ''` and left the node unchanged. The command now uses `latex ?? node.attrs.latex`, mirroring `updateInlineMath`, so callers can clear the rendered LaTeX while still preserving the "no value passed" case. The command type signature is also relaxed to mark `latex` optional, matching `updateInlineMath`. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../fix-update-block-math-empty-latex.md | 5 ++ .../__tests__/blockMath.spec.ts | 61 ++++++++++++++++++- .../src/extensions/BlockMath.ts | 4 +- 3 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 .changeset/fix-update-block-math-empty-latex.md diff --git a/.changeset/fix-update-block-math-empty-latex.md b/.changeset/fix-update-block-math-empty-latex.md new file mode 100644 index 0000000000..28a30ebb7b --- /dev/null +++ b/.changeset/fix-update-block-math-empty-latex.md @@ -0,0 +1,5 @@ +--- +"@tiptap/extension-mathematics": patch +--- + +Fix `updateBlockMath` silently ignoring `latex: ''`. The command used a falsy fallback (`latex || node.attrs.latex`) that treated an explicit empty string the same as `undefined`, leaving the node unchanged. It now uses `latex ?? node.attrs.latex`, matching `updateInlineMath`, so callers can clear the rendered LaTeX while preserving the "no value passed" case. diff --git a/packages/extension-mathematics/__tests__/blockMath.spec.ts b/packages/extension-mathematics/__tests__/blockMath.spec.ts index 2621bc0af1..e88d4eb0bf 100644 --- a/packages/extension-mathematics/__tests__/blockMath.spec.ts +++ b/packages/extension-mathematics/__tests__/blockMath.spec.ts @@ -5,7 +5,7 @@ import Paragraph from '@tiptap/extension-paragraph' import Text from '@tiptap/extension-text' import { afterEach, describe, expect, it } from 'vitest' -import { BlockMath } from '../src/index.js' +import { BlockMath, InlineMath } from '../src/index.js' describe('BlockMath', () => { let editor: Editor @@ -99,4 +99,63 @@ describe('BlockMath', () => { }) }) }) + + describe('updateBlockMath', () => { + function createEditor(latex: string) { + return new Editor({ + extensions: [Document, Paragraph, Text, BlockMath], + content: { + type: 'doc', + content: [{ type: 'blockMath', attrs: { latex } }], + }, + }) + } + + it('clears the latex attribute when given an empty string', () => { + editor = createEditor('x^2') + + editor.commands.updateBlockMath({ latex: '', pos: 0 }) + + expect(editor.state.doc.firstChild?.attrs.latex).toBe('') + }) + + it('keeps the existing latex when no latex option is provided', () => { + editor = createEditor('x^2') + + editor.commands.updateBlockMath({ pos: 0 }) + + expect(editor.state.doc.firstChild?.attrs.latex).toBe('x^2') + }) + + it('matches updateInlineMath behavior for empty-string and missing latex', () => { + const blockEditor = createEditor('x^2') + blockEditor.commands.updateBlockMath({ latex: '', pos: 0 }) + const blockEmpty = blockEditor.state.doc.firstChild?.attrs.latex + blockEditor.commands.updateBlockMath({ pos: 0 }) + const blockUnchanged = blockEditor.state.doc.firstChild?.attrs.latex + blockEditor.destroy() + + const inlineEditor = new Editor({ + extensions: [Document, Paragraph, Text, InlineMath], + content: { + type: 'doc', + content: [ + { + type: 'paragraph', + content: [{ type: 'inlineMath', attrs: { latex: 'x^2' } }], + }, + ], + }, + }) + const inlinePos = 1 + inlineEditor.commands.updateInlineMath({ latex: '', pos: inlinePos }) + const inlineEmpty = inlineEditor.state.doc.nodeAt(inlinePos)?.attrs.latex + inlineEditor.commands.updateInlineMath({ pos: inlinePos }) + const inlineUnchanged = inlineEditor.state.doc.nodeAt(inlinePos)?.attrs.latex + inlineEditor.destroy() + + expect(blockEmpty).toBe(inlineEmpty) + expect(blockUnchanged).toBe(inlineUnchanged) + }) + }) }) diff --git a/packages/extension-mathematics/src/extensions/BlockMath.ts b/packages/extension-mathematics/src/extensions/BlockMath.ts index bc10017708..156c956b28 100644 --- a/packages/extension-mathematics/src/extensions/BlockMath.ts +++ b/packages/extension-mathematics/src/extensions/BlockMath.ts @@ -55,7 +55,7 @@ declare module '@tiptap/core' { * @param options - Options for updating block math. * @returns ReturnType */ - updateBlockMath: (options?: { latex: string; pos?: number }) => ReturnType + updateBlockMath: (options?: { latex?: string; pos?: number }) => ReturnType } } } @@ -157,7 +157,7 @@ export const BlockMath = Node.create({ tr.setNodeMarkup(pos, this.type, { ...node.attrs, - latex: latex || node.attrs.latex, + latex: latex ?? node.attrs.latex, }) return true From ea2aec20a656228e0cc451e04444a03ba173f9c2 Mon Sep 17 00:00:00 2001 From: Giorgio Garofalo Date: Tue, 5 May 2026 12:18:18 -0700 Subject: [PATCH 3/3] fix(extension-mathematics): keep updateBlockMath latex required in public type Revert the earlier relaxation of the `updateBlockMath` option type from `latex: string` to `latex?: string`. Allowing `undefined` would have introduced an effectively no-op call shape with no semantic value, while also broadening the public API surface. The runtime body still uses `latex ?? node.attrs.latex` defensively, so the empty-string fix is preserved for callers that pass `latex: ''`. The matching test that exercised the no-latex shape is removed and the parity test is trimmed to the empty-string case the bug actually covers. Co-Authored-By: Claude Opus 4.7 (1M context) --- .changeset/fix-update-block-math-empty-latex.md | 2 +- .../__tests__/blockMath.spec.ts | 15 +-------------- .../src/extensions/BlockMath.ts | 2 +- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/.changeset/fix-update-block-math-empty-latex.md b/.changeset/fix-update-block-math-empty-latex.md index 28a30ebb7b..ddc01e315d 100644 --- a/.changeset/fix-update-block-math-empty-latex.md +++ b/.changeset/fix-update-block-math-empty-latex.md @@ -2,4 +2,4 @@ "@tiptap/extension-mathematics": patch --- -Fix `updateBlockMath` silently ignoring `latex: ''`. The command used a falsy fallback (`latex || node.attrs.latex`) that treated an explicit empty string the same as `undefined`, leaving the node unchanged. It now uses `latex ?? node.attrs.latex`, matching `updateInlineMath`, so callers can clear the rendered LaTeX while preserving the "no value passed" case. +Fix `updateBlockMath` silently ignoring `latex: ''`. The command used a falsy fallback (`latex || node.attrs.latex`) that treated an explicit empty string the same as `undefined`, leaving the node unchanged. It now uses `latex ?? node.attrs.latex`, so callers can clear the rendered LaTeX with an empty string. diff --git a/packages/extension-mathematics/__tests__/blockMath.spec.ts b/packages/extension-mathematics/__tests__/blockMath.spec.ts index e88d4eb0bf..2bb5a83566 100644 --- a/packages/extension-mathematics/__tests__/blockMath.spec.ts +++ b/packages/extension-mathematics/__tests__/blockMath.spec.ts @@ -119,20 +119,10 @@ describe('BlockMath', () => { expect(editor.state.doc.firstChild?.attrs.latex).toBe('') }) - it('keeps the existing latex when no latex option is provided', () => { - editor = createEditor('x^2') - - editor.commands.updateBlockMath({ pos: 0 }) - - expect(editor.state.doc.firstChild?.attrs.latex).toBe('x^2') - }) - - it('matches updateInlineMath behavior for empty-string and missing latex', () => { + it('matches updateInlineMath behavior when clearing latex with an empty string', () => { const blockEditor = createEditor('x^2') blockEditor.commands.updateBlockMath({ latex: '', pos: 0 }) const blockEmpty = blockEditor.state.doc.firstChild?.attrs.latex - blockEditor.commands.updateBlockMath({ pos: 0 }) - const blockUnchanged = blockEditor.state.doc.firstChild?.attrs.latex blockEditor.destroy() const inlineEditor = new Editor({ @@ -150,12 +140,9 @@ describe('BlockMath', () => { const inlinePos = 1 inlineEditor.commands.updateInlineMath({ latex: '', pos: inlinePos }) const inlineEmpty = inlineEditor.state.doc.nodeAt(inlinePos)?.attrs.latex - inlineEditor.commands.updateInlineMath({ pos: inlinePos }) - const inlineUnchanged = inlineEditor.state.doc.nodeAt(inlinePos)?.attrs.latex inlineEditor.destroy() expect(blockEmpty).toBe(inlineEmpty) - expect(blockUnchanged).toBe(inlineUnchanged) }) }) }) diff --git a/packages/extension-mathematics/src/extensions/BlockMath.ts b/packages/extension-mathematics/src/extensions/BlockMath.ts index 156c956b28..3da6bccde2 100644 --- a/packages/extension-mathematics/src/extensions/BlockMath.ts +++ b/packages/extension-mathematics/src/extensions/BlockMath.ts @@ -55,7 +55,7 @@ declare module '@tiptap/core' { * @param options - Options for updating block math. * @returns ReturnType */ - updateBlockMath: (options?: { latex?: string; pos?: number }) => ReturnType + updateBlockMath: (options?: { latex: string; pos?: number }) => ReturnType } } }