Skip to content

Commit 5b081d9

Browse files
hendrikebbersclaude
andcommitted
refactor(markdown-editor): type editor.storage.markdown via module augmentation
Adds a tiptap-markdown.d.ts that augments @tiptap/core's Storage interface, removing the two `(editor.storage as any).markdown.getMarkdown()` casts. The augmentation is internal to the build (not referenced from index.d.ts) so it does not leak to consumers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent fd3e921 commit 5b081d9

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

src/components/markdown-editor.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ export function MarkdownEditor({ value, onChange, placeholder }: MarkdownEditorP
115115
content: value,
116116
immediatelyRender: false,
117117
onUpdate: ({ editor: ed }) => {
118-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
119-
onChange((ed.storage as any).markdown.getMarkdown());
118+
onChange(ed.storage.markdown.getMarkdown());
120119
},
121120
editorProps: {
122121
attributes: {
@@ -127,8 +126,7 @@ export function MarkdownEditor({ value, onChange, placeholder }: MarkdownEditorP
127126

128127
useEffect(() => {
129128
if (!editor) return;
130-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
131-
const currentMarkdown = (editor.storage as any).markdown.getMarkdown();
129+
const currentMarkdown = editor.storage.markdown.getMarkdown();
132130
if (value !== currentMarkdown) {
133131
editor.commands.setContent(value);
134132
}

src/types/tiptap-markdown.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { MarkdownStorage } from "tiptap-markdown";
2+
3+
// Augment tiptap's Storage interface so editor.storage.markdown is typed.
4+
// See https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#storage
5+
declare module "@tiptap/core" {
6+
interface Storage {
7+
markdown: MarkdownStorage;
8+
}
9+
}
10+
11+
export {};

0 commit comments

Comments
 (0)