@@ -46,33 +46,33 @@ export type ReactInlineContentImplementation<
46
46
// Function that adds a wrapper with necessary classes and attributes to the
47
47
// component returned from a custom inline content's 'render' function, to
48
48
// ensure no data is lost on internal copy & paste.
49
- export function reactWrapInInlineContentStructure <
49
+ export function InlineContentWrapper <
50
50
IType extends string ,
51
51
PSchema extends PropSchema
52
- > (
53
- element : JSX . Element ,
54
- inlineContentType : IType ,
55
- inlineContentProps : Props < PSchema > ,
56
- propSchema : PSchema
57
- ) {
58
- return ( ) => (
52
+ > ( props : {
53
+ children : JSX . Element ;
54
+ inlineContentType : IType ;
55
+ inlineContentProps : Props < PSchema > ;
56
+ propSchema : PSchema ;
57
+ } ) {
58
+ return (
59
59
// Creates inline content section element
60
60
< NodeViewWrapper
61
61
as = { "span" }
62
62
// Sets inline content section class
63
63
className = { "bn-inline-content-section" }
64
64
// Sets content type attribute
65
- data-inline-content-type = { inlineContentType }
65
+ data-inline-content-type = { props . inlineContentType }
66
66
// Adds props as HTML attributes in kebab-case with "data-" prefix. Skips
67
67
// props set to their default values.
68
68
{ ...Object . fromEntries (
69
- Object . entries ( inlineContentProps )
70
- . filter ( ( [ prop , value ] ) => value !== propSchema [ prop ] . default )
69
+ Object . entries ( props . inlineContentProps )
70
+ . filter ( ( [ prop , value ] ) => value !== props . propSchema [ prop ] . default )
71
71
. map ( ( [ prop , value ] ) => {
72
72
return [ camelToDataKebab ( prop ) , value ] ;
73
73
} )
74
74
) } >
75
- { element }
75
+ { props . children }
76
76
</ NodeViewWrapper >
77
77
) ;
78
78
}
@@ -134,30 +134,30 @@ export function createReactInlineContentSpec<
134
134
// TODO: needed?
135
135
addNodeView ( ) {
136
136
const editor = this . options . editor ;
137
-
138
137
return ( props ) =>
139
138
ReactNodeViewRenderer (
140
139
( props : NodeViewProps ) => {
141
140
// hacky, should export `useReactNodeView` from tiptap to get access to ref
142
141
const ref = ( NodeViewContent ( { } ) as any ) . ref ;
143
142
144
143
const Content = inlineContentImplementation . render ;
145
- const FullContent = reactWrapInInlineContentStructure (
146
- < Content
147
- contentRef = { ref }
148
- inlineContent = {
149
- nodeToCustomInlineContent (
150
- props . node ,
151
- editor . schema . inlineContentSchema ,
152
- editor . schema . styleSchema
153
- ) as any as InlineContentFromConfig < T , S > // TODO: fix cast
154
- }
155
- /> ,
156
- inlineContentConfig . type ,
157
- props . node . attrs as Props < T [ "propSchema" ] > ,
158
- inlineContentConfig . propSchema
144
+ return (
145
+ < InlineContentWrapper
146
+ inlineContentProps = { props . node . attrs as Props < T [ "propSchema" ] > }
147
+ inlineContentType = { inlineContentConfig . type }
148
+ propSchema = { inlineContentConfig . propSchema } >
149
+ < Content
150
+ contentRef = { ref }
151
+ inlineContent = {
152
+ nodeToCustomInlineContent (
153
+ props . node ,
154
+ editor . schema . inlineContentSchema ,
155
+ editor . schema . styleSchema
156
+ ) as any as InlineContentFromConfig < T , S > // TODO: fix cast
157
+ }
158
+ />
159
+ </ InlineContentWrapper >
159
160
) ;
160
- return < FullContent /> ;
161
161
} ,
162
162
{
163
163
className : "bn-ic-react-node-view-renderer" ,
0 commit comments