@@ -6,7 +6,6 @@ import {toaster} from '@gravity-ui/uikit/toaster-singleton-react-18';
6
6
7
7
import {
8
8
type DirectiveSyntaxValue ,
9
- type EscapeConfig ,
10
9
type FileUploadHandler ,
11
10
type MarkdownEditorMode ,
12
11
MarkdownEditorView ,
@@ -30,21 +29,15 @@ import {YfmHtmlBlock} from '../../src/extensions/additional/YfmHtmlBlock';
30
29
import { getSanitizeYfmHtmlBlock } from '../../src/extensions/additional/YfmHtmlBlock/utils' ;
31
30
import type { CodeEditor } from '../../src/markup' ;
32
31
import { ToolbarsPreset } from '../../src/modules/toolbars/types' ;
33
- import { VERSION } from '../../src/version' ;
34
32
import { getPlugins } from '../defaults/md-plugins' ;
35
33
import useYfmHtmlBlockStyles from '../hooks/useYfmHtmlBlockStyles' ;
36
- import { block } from '../utils/cn' ;
37
34
import { randomDelay } from '../utils/delay' ;
38
35
import { parseInsertedUrlAsImage } from '../utils/imageUrl' ;
39
36
import { debouncedUpdateLocation as updateLocation } from '../utils/location' ;
40
37
41
- import { WysiwygSelection } from './PMSelection' ;
42
- import { WysiwygDevTools } from './ProseMirrorDevTools' ;
38
+ import { PlaygroundLayout , b } from './PlaygroundLayout' ;
43
39
import { SplitModePreview } from './SplitModePreview' ;
44
40
45
- import './Playground.scss' ;
46
-
47
- const b = block ( 'playground' ) ;
48
41
const fileUploadHandler : FileUploadHandler = async ( file ) => {
49
42
console . info ( '[Playground] Uploading file: ' + file . name ) ;
50
43
await randomDelay ( 1000 , 3000 ) ;
@@ -76,7 +69,6 @@ export type PlaygroundProps = {
76
69
renderPreviewDefined ?: boolean ;
77
70
height ?: CSSProperties [ 'height' ] ;
78
71
markupConfigExtensions ?: Extension [ ] ;
79
- escapeConfig ?: EscapeConfig ;
80
72
wysiwygCommandMenuConfig ?: wysiwygToolbarConfigs . WToolbarItemData [ ] ;
81
73
markupToolbarConfig ?: ToolbarGroupData < CodeEditor > [ ] ;
82
74
toolbarsPreset ?: ToolbarsPreset ;
@@ -132,7 +124,6 @@ export const Playground = React.memo<PlaygroundProps>((props) => {
132
124
markupConfigExtensions,
133
125
markupToolbarConfig,
134
126
placeholderOptions,
135
- escapeConfig,
136
127
enableSubmitInPreview,
137
128
hidePreviewAfterSubmit,
138
129
needToSetDimensionsForUploadedImages,
@@ -167,7 +158,6 @@ export const Playground = React.memo<PlaygroundProps>((props) => {
167
158
{
168
159
preset : 'full' ,
169
160
wysiwygConfig : {
170
- escapeConfig,
171
161
placeholderOptions : placeholderOptions ,
172
162
extensions : ( builder ) => {
173
163
builder
@@ -304,107 +294,96 @@ export const Playground = React.memo<PlaygroundProps>((props) => {
304
294
} , [ mdEditor ] ) ;
305
295
306
296
return (
307
- < div className = { b ( ) } >
308
- < div className = { b ( 'header' ) } >
309
- Markdown Editor Playground
310
- < span className = { b ( 'version' ) } > { VERSION } </ span >
311
- </ div >
312
- < div className = { b ( 'actions' ) } >
313
- < DropdownMenu
314
- size = "s"
315
- switcher = {
316
- < Button size = "s" view = "flat" >
317
- isEmpty: { String ( mdEditor . isEmpty ( ) ) }
318
- </ Button >
319
- }
320
- >
321
- < DropdownMenu . Item
322
- text = "Clear"
323
- action = { ( ) => {
324
- mdEditor . clear ( ) ;
325
- mdEditor . focus ( ) ;
326
- } }
327
- />
328
- < DropdownMenu . Item
329
- text = "Append"
330
- action = { ( ) => {
331
- mdEditor . append ( '> append' ) ;
332
- mdEditor . focus ( ) ;
333
- } }
334
- />
335
- < DropdownMenu . Item
336
- text = "Prepend"
337
- action = { ( ) => {
338
- mdEditor . prepend ( '> prepend' ) ;
339
- mdEditor . focus ( ) ;
340
- } }
341
- />
342
- < DropdownMenu . Item
343
- text = "Replace"
344
- action = { ( ) => {
345
- mdEditor . replace ( '> replace' ) ;
346
- mdEditor . focus ( ) ;
347
- } }
348
- />
349
- < DropdownMenu . Item
350
- text = "Move cursor to start"
351
- action = { ( ) => {
352
- mdEditor . moveCursor ( 'start' ) ;
353
- mdEditor . focus ( ) ;
354
- } }
355
- />
356
- < DropdownMenu . Item
357
- text = "Move cursor to end"
358
- action = { ( ) => {
359
- mdEditor . moveCursor ( 'end' ) ;
360
- mdEditor . focus ( ) ;
361
- } }
362
- />
363
- < DropdownMenu . Item
364
- text = "Move to line"
365
- action = { ( ) => {
366
- mdEditor . moveCursor ( { line : 115 } ) ;
367
- mdEditor . focus ( ) ;
368
- } }
369
- />
370
- </ DropdownMenu >
371
- { mdEditor . currentMode === 'markup' && (
372
- < MoveToLine
373
- onClick = { ( line ) => {
374
- if ( typeof line !== 'number' || Number . isNaN ( line ) ) return ;
375
- mdEditor . moveCursor ( { line} ) ;
376
- mdEditor . focus ( ) ;
377
- } }
378
- />
379
- ) }
380
- </ div >
381
- < hr />
382
- < React . StrictMode >
383
- < div className = { b ( 'editor' ) } style = { { height : height ?? 'initial' } } >
384
- < MarkdownEditorView
385
- autofocus
386
- toaster = { toaster }
387
- className = { b ( 'editor-view' ) }
388
- stickyToolbar = { Boolean ( stickyToolbar ) }
389
- toolbarsPreset = { toolbarsPreset }
390
- wysiwygToolbarConfig = { wysiwygToolbarConfig }
391
- markupToolbarConfig = { markupToolbarConfig }
392
- settingsVisible = { settingsVisible }
393
- editor = { mdEditor }
394
- enableSubmitInPreview = { enableSubmitInPreview }
395
- hidePreviewAfterSubmit = { hidePreviewAfterSubmit }
396
- />
397
- < WysiwygDevTools editor = { mdEditor } />
398
- < WysiwygSelection editor = { mdEditor } className = { b ( 'pm-selection' ) } />
399
- </ div >
400
- </ React . StrictMode >
401
-
402
- < hr />
403
-
404
- < div className = { b ( 'preview' ) } >
405
- { editorMode === 'wysiwyg' && < pre className = { b ( 'markup' ) } > { mdRaw } </ pre > }
406
- </ div >
407
- </ div >
297
+ < PlaygroundLayout
298
+ editor = { mdEditor }
299
+ viewHeight = { height }
300
+ view = { ( { className} ) => (
301
+ < MarkdownEditorView
302
+ autofocus
303
+ toaster = { toaster }
304
+ className = { className }
305
+ stickyToolbar = { Boolean ( stickyToolbar ) }
306
+ toolbarsPreset = { toolbarsPreset }
307
+ wysiwygToolbarConfig = { wysiwygToolbarConfig }
308
+ markupToolbarConfig = { markupToolbarConfig }
309
+ settingsVisible = { settingsVisible }
310
+ editor = { mdEditor }
311
+ enableSubmitInPreview = { enableSubmitInPreview }
312
+ hidePreviewAfterSubmit = { hidePreviewAfterSubmit }
313
+ />
314
+ ) }
315
+ actions = { ( ) => (
316
+ < >
317
+ < DropdownMenu
318
+ size = "s"
319
+ switcher = {
320
+ < Button size = "s" view = "flat" >
321
+ isEmpty: { String ( mdEditor . isEmpty ( ) ) }
322
+ </ Button >
323
+ }
324
+ >
325
+ < DropdownMenu . Item
326
+ text = "Clear"
327
+ action = { ( ) => {
328
+ mdEditor . clear ( ) ;
329
+ mdEditor . focus ( ) ;
330
+ } }
331
+ />
332
+ < DropdownMenu . Item
333
+ text = "Append"
334
+ action = { ( ) => {
335
+ mdEditor . append ( '> append' ) ;
336
+ mdEditor . focus ( ) ;
337
+ } }
338
+ />
339
+ < DropdownMenu . Item
340
+ text = "Prepend"
341
+ action = { ( ) => {
342
+ mdEditor . prepend ( '> prepend' ) ;
343
+ mdEditor . focus ( ) ;
344
+ } }
345
+ />
346
+ < DropdownMenu . Item
347
+ text = "Replace"
348
+ action = { ( ) => {
349
+ mdEditor . replace ( '> replace' ) ;
350
+ mdEditor . focus ( ) ;
351
+ } }
352
+ />
353
+ < DropdownMenu . Item
354
+ text = "Move cursor to start"
355
+ action = { ( ) => {
356
+ mdEditor . moveCursor ( 'start' ) ;
357
+ mdEditor . focus ( ) ;
358
+ } }
359
+ />
360
+ < DropdownMenu . Item
361
+ text = "Move cursor to end"
362
+ action = { ( ) => {
363
+ mdEditor . moveCursor ( 'end' ) ;
364
+ mdEditor . focus ( ) ;
365
+ } }
366
+ />
367
+ < DropdownMenu . Item
368
+ text = "Move to line"
369
+ action = { ( ) => {
370
+ mdEditor . moveCursor ( { line : 115 } ) ;
371
+ mdEditor . focus ( ) ;
372
+ } }
373
+ />
374
+ </ DropdownMenu >
375
+ { mdEditor . currentMode === 'markup' && (
376
+ < MoveToLine
377
+ onClick = { ( line ) => {
378
+ if ( typeof line !== 'number' || Number . isNaN ( line ) ) return ;
379
+ mdEditor . moveCursor ( { line} ) ;
380
+ mdEditor . focus ( ) ;
381
+ } }
382
+ />
383
+ ) }
384
+ </ >
385
+ ) }
386
+ />
408
387
) ;
409
388
} ) ;
410
389
0 commit comments