Skip to content

Commit 92ad0c4

Browse files
committed
fix(react): restore contained prop lost during rebase
Re-apply contained mode support in the React wrapper: - Add contained to ReactProps interface with JSDoc - Destructure and pass to SuperDoc config unconditionally - Add to useEffect dep array so toggling triggers rebuild - Apply flex layout on wrapper for toolbar + editor coexistence
1 parent ff81abb commit 92ad0c4

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

packages/react/src/SuperDocEditor.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function SuperDocEditorInner(props: SuperDocEditorProps, ref: ForwardedRef<Super
3838
id,
3939
renderLoading,
4040
hideToolbar = false,
41+
contained = false,
4142
className,
4243
style,
4344
// Callbacks (stored in ref to avoid triggering rebuilds)
@@ -149,6 +150,7 @@ function SuperDocEditorInner(props: SuperDocEditorProps, ref: ForwardedRef<Super
149150
...(!hideToolbar && toolbarContainerRef.current ? { toolbar: `#${CSS.escape(toolbarId)}` } : {}),
150151
documentMode,
151152
role,
153+
contained,
152154
...(documentProp != null ? { document: documentProp } : {}),
153155
...(user ? { user } : {}),
154156
...(users ? { users } : {}),
@@ -224,17 +226,26 @@ function SuperDocEditorInner(props: SuperDocEditorProps, ref: ForwardedRef<Super
224226
// initial values - use getInstance() methods to change them at runtime.
225227
// Note: restProps is intentionally excluded to avoid rebuilds on every render.
226228
// documentMode is handled separately via setDocumentMode() for efficiency.
227-
}, [documentProp, user, users, modules, role, hideToolbar, containerId, toolbarId]);
229+
}, [documentProp, user, users, modules, role, hideToolbar, contained, containerId, toolbarId]);
228230

229231
const wrapperClassName = ['superdoc-wrapper', className].filter(Boolean).join(' ');
230232
const hideWhenLoading: CSSProperties | undefined = isLoading ? { display: 'none' } : undefined;
231233

234+
const wrapperStyle: CSSProperties = {
235+
...style,
236+
...(contained && { display: 'flex', flexDirection: 'column' as const }),
237+
};
238+
232239
return (
233-
<div className={wrapperClassName} style={style}>
240+
<div className={wrapperClassName} style={wrapperStyle}>
234241
{!hideToolbar && (
235242
<div ref={toolbarContainerRef} id={toolbarId} className='superdoc-toolbar-container' style={hideWhenLoading} />
236243
)}
237-
<div id={containerId} className='superdoc-editor-container' style={hideWhenLoading} />
244+
<div
245+
id={containerId}
246+
className='superdoc-editor-container'
247+
style={{ ...hideWhenLoading, ...(contained && { flex: 1, minHeight: 0 }) }}
248+
/>
238249
{isLoading && !hasError && renderLoading && <div className='superdoc-loading-container'>{renderLoading()}</div>}
239250
{hasError && <div className='superdoc-error-container'>Failed to load editor. Check console for details.</div>}
240251
</div>

packages/react/src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ interface ReactProps {
136136
/** Hide the toolbar container. When true, no toolbar is rendered. @default false */
137137
hideToolbar?: boolean;
138138

139+
/** Enable contained mode for fixed-height container embedding. When true, SuperDoc
140+
* fits within its parent's height and scrolls internally. @default false */
141+
contained?: boolean;
142+
139143
/** Additional CSS class name for the wrapper element */
140144
className?: string;
141145

0 commit comments

Comments
 (0)