Skip to content

Commit 9365f06

Browse files
committed
feat(extension-placeholder): export PlaceholderRenderProps
Expose the placeholder callback argument shape as a public type so apps can type handlers without duplicating or inferring from PlaceholderOptions Made-with: Cursor
1 parent ccf4bec commit 9365f06

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export type { PlaceholderOptions } from './placeholder'
1+
export type { PlaceholderOptions, PlaceholderRenderProps } from './placeholder'
22
export { Placeholder } from './placeholder'

packages/extension-placeholder/src/placeholder.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@ import type { EditorState, Transaction } from '@tiptap/pm/state'
55
import { Plugin, PluginKey } from '@tiptap/pm/state'
66
import { Decoration, DecorationSet } from '@tiptap/pm/view'
77

8+
/** Arguments passed to the `placeholder` callback when it is a function. */
9+
export interface PlaceholderRenderProps {
10+
editor: Editor
11+
node: ProseMirrorNode
12+
pos: number
13+
hasAnchor: boolean
14+
/** Parent node type name (e.g. 'doc', 'listItem', 'blockquote'). Safe during apply(). */
15+
parentName: string
16+
}
17+
818
export interface PlaceholderOptions {
919
emptyEditorClass: string
1020
emptyNodeClass: string
11-
placeholder:
12-
| ((props: {
13-
editor: Editor
14-
node: ProseMirrorNode
15-
pos: number
16-
hasAnchor: boolean
17-
/** Parent node type name (e.g. 'doc', 'listItem', 'blockquote'). Safe during apply(). */
18-
parentName: string
19-
}) => string)
20-
| string
21+
placeholder: ((props: PlaceholderRenderProps) => string) | string
2122
showOnlyWhenEditable: boolean
2223
}
2324

0 commit comments

Comments
 (0)