@@ -46,33 +46,33 @@ export type ReactInlineContentImplementation<
4646// Function that adds a wrapper with necessary classes and attributes to the
4747// component returned from a custom inline content's 'render' function, to
4848// ensure no data is lost on internal copy & paste.
49- export function reactWrapInInlineContentStructure <
49+ export function InlineContentWrapper <
5050 IType extends string ,
5151 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 (
5959 // Creates inline content section element
6060 < NodeViewWrapper
6161 as = { "span" }
6262 // Sets inline content section class
6363 className = { "bn-inline-content-section" }
6464 // Sets content type attribute
65- data-inline-content-type = { inlineContentType }
65+ data-inline-content-type = { props . inlineContentType }
6666 // Adds props as HTML attributes in kebab-case with "data-" prefix. Skips
6767 // props set to their default values.
6868 { ...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 )
7171 . map ( ( [ prop , value ] ) => {
7272 return [ camelToDataKebab ( prop ) , value ] ;
7373 } )
7474 ) } >
75- { element }
75+ { props . children }
7676 </ NodeViewWrapper >
7777 ) ;
7878}
@@ -134,30 +134,30 @@ export function createReactInlineContentSpec<
134134 // TODO: needed?
135135 addNodeView ( ) {
136136 const editor = this . options . editor ;
137-
138137 return ( props ) =>
139138 ReactNodeViewRenderer (
140139 ( props : NodeViewProps ) => {
141140 // hacky, should export `useReactNodeView` from tiptap to get access to ref
142141 const ref = ( NodeViewContent ( { } ) as any ) . ref ;
143142
144143 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 >
159160 ) ;
160- return < FullContent /> ;
161161 } ,
162162 {
163163 className : "bn-ic-react-node-view-renderer" ,
0 commit comments