File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
packages/extension-placeholder/src Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @tiptap/extension-placeholder " : patch
3
+ ---
4
+
5
+ feat(placeholder): do not show placeholder on atom nodes by default
Original file line number Diff line number Diff line change @@ -63,6 +63,15 @@ export interface PlaceholderOptions {
63
63
* @default false
64
64
*/
65
65
includeChildren : boolean
66
+
67
+ /**
68
+ * **Controls if the placeholder should be shown for atom nodes.**
69
+ *
70
+ * If true, the placeholder will be shown for atom nodes.
71
+ * If false, the placeholder will not be shown for atom nodes.
72
+ * @default false
73
+ */
74
+ showWhenAtom : boolean ;
66
75
}
67
76
68
77
/**
@@ -81,6 +90,7 @@ export const Placeholder = Extension.create<PlaceholderOptions>({
81
90
showOnlyWhenEditable : true ,
82
91
showOnlyCurrent : true ,
83
92
includeChildren : false ,
93
+ showWhenAtom : false ,
84
94
}
85
95
} ,
86
96
@@ -103,8 +113,9 @@ export const Placeholder = Extension.create<PlaceholderOptions>({
103
113
doc . descendants ( ( node , pos ) => {
104
114
const hasAnchor = anchor >= pos && anchor <= pos + node . nodeSize
105
115
const isEmpty = ! node . isLeaf && isNodeEmpty ( node )
116
+ const isContentEditable = this . options . showWhenAtom ? ! node . type . isAtom : true ;
106
117
107
- if ( ( hasAnchor || ! this . options . showOnlyCurrent ) && isEmpty ) {
118
+ if ( ( hasAnchor || ! this . options . showOnlyCurrent ) && isEmpty && isContentEditable ) {
108
119
const classes = [ this . options . emptyNodeClass ]
109
120
110
121
if ( isEmptyDoc ) {
You can’t perform that action at this time.
0 commit comments