@@ -7,9 +7,11 @@ import {toaster} from '@gravity-ui/uikit/toaster-singleton-react-18';
77import {
88 MarkdownEditorMode ,
99 MarkdownEditorView ,
10+ MarkdownEditorViewProps ,
1011 MarkupString ,
1112 NumberInput ,
1213 RenderPreview ,
14+ UseMarkdownEditorProps ,
1315 logger ,
1416 markupToolbarConfigs ,
1517 useMarkdownEditor ,
@@ -59,6 +61,8 @@ const wCommandMenuConfig = wysiwygToolbarConfigs.wCommandMenuConfig.concat(
5961 wysiwygToolbarConfigs . wYfmHtmlBlockItemData ,
6062) ;
6163
64+ wCommandMenuConfig . unshift ( wysiwygToolbarConfigs . wGptItemData ) ;
65+
6266export type PlaygroundProps = {
6367 initial ?: MarkupString ;
6468 allowHTML ?: boolean ;
@@ -77,7 +81,20 @@ export type PlaygroundProps = {
7781 escapeConfig ?: EscapeConfig ;
7882 onChangeEditorType ?: ( mode : MarkdownEditorMode ) => void ;
7983 onChangeSplitModeEnabled ?: ( splitModeEnabled : boolean ) => void ;
80- } ;
84+ } & Pick <
85+ UseMarkdownEditorProps ,
86+ | 'needToSetDimensionsForUploadedImages'
87+ | 'extraExtensions'
88+ | 'renderPreview'
89+ | 'extensionOptions'
90+ > &
91+ Pick <
92+ MarkdownEditorViewProps ,
93+ | 'markupHiddenActionsConfig'
94+ | 'wysiwygHiddenActionsConfig'
95+ | 'markupToolbarConfig'
96+ | 'wysiwygToolbarConfig'
97+ > ;
8198
8299logger . setLogger ( {
83100 metrics : console . info ,
@@ -101,6 +118,9 @@ export const Playground = React.memo<PlaygroundProps>((props) => {
101118 stickyToolbar,
102119 renderPreviewDefined,
103120 height,
121+ extraExtensions,
122+ extensionOptions,
123+ wysiwygToolbarConfig,
104124 escapeConfig,
105125 } = props ;
106126 const [ editorMode , setEditorMode ] = React . useState < MarkdownEditorMode > (
@@ -145,8 +165,9 @@ export const Playground = React.memo<PlaygroundProps>((props) => {
145165 : undefined ,
146166 extensionOptions : {
147167 commandMenu : { actions : wCommandMenuConfig } ,
168+ ...extensionOptions ,
148169 } ,
149- extraExtensions : ( builder ) =>
170+ extraExtensions : ( builder ) => {
150171 builder
151172 . use ( Math , {
152173 loadRuntimeScript : ( ) => {
@@ -166,6 +187,7 @@ export const Playground = React.memo<PlaygroundProps>((props) => {
166187 ) ;
167188 } ,
168189 } )
190+ . use ( FoldingHeading )
169191 . use ( YfmHtmlBlock , {
170192 useConfig : useYfmHtmlBlockStyles ,
171193 sanitize : getSanitizeYfmHtmlBlock ( { options : defaultOptions } ) ,
@@ -178,8 +200,9 @@ export const Playground = React.memo<PlaygroundProps>((props) => {
178200 }
179201 </style
180202 ` ,
181- } )
182- . use ( FoldingHeading ) ,
203+ } ) ;
204+ if ( extraExtensions ) builder . use ( extraExtensions ) ;
205+ } ,
183206 } ) ;
184207
185208 useEffect ( ( ) => {
@@ -311,7 +334,7 @@ export const Playground = React.memo<PlaygroundProps>((props) => {
311334 toaster = { toaster }
312335 className = { b ( 'editor-view' ) }
313336 stickyToolbar = { Boolean ( stickyToolbar ) }
314- wysiwygToolbarConfig = { wToolbarConfig }
337+ wysiwygToolbarConfig = { wysiwygToolbarConfig ?? wToolbarConfig }
315338 markupToolbarConfig = { mToolbarConfig }
316339 settingsVisible = { settingsVisible }
317340 editor = { mdEditor }
0 commit comments