Index: src/index.tsx IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP <+>import {useCallback, useState, useEffect} from 'react';\nimport {Container, Row, Col} from '@gravity-ui/uikit';\n\nimport {CallOut} from './callout';\nimport {InputArea} from './input-area';\nimport {OutputArea} from './output-area';\n\nimport {useTabs} from './useTabs';\nimport {generateMD, generateHTML, generateTokens} from './generators';\nimport persistRestore from './persistRestore';\n\nimport './styles.css';\n\n(window as any).MonacoEnvironment = {\n getWorker: (_, label: string) => {\n if (label === 'json') {\n return new Worker(\n new URL('monaco-editor/esm/vs/language/json/json.worker?worker', 'monaco-worker'),\n );\n }\n return new Worker(new URL('monaco-editor/esm/vs/editor/editor.worker?worker', 'monaco-worker'));\n },\n};\n\nconst App = () => {\n return(<>\n \n \n \n \n )\n};\n\nexport type PlaygroundProperties = {\n content?: string;\n persistRestore?: boolean;\n}\n\nfunction Playground(props: PlaygroundProperties) {\n const persist = useCallback(persistRestore.persist, []);\n const restore = useCallback(persistRestore.restore, []);\n const content = props?.persistRestore ? restore() : props?.content\n const [input, setInput] = useState(content ?? '');\n const [generated, setGenerated] = useState(input);\n\n const generate = useCallback((active: string) => {\n if (active === 'markdown') {\n setGenerated(generateMD(input));\n } else if (active === 'html') {\n setGenerated(generateHTML(input));\n } else if (active === 'tokens') {\n setGenerated(generateTokens(input));\n } else if (active === 'preview') {\n setGenerated(generateHTML(input));\n } else {\n setGenerated(input);\n }\n }, [input]);\n\n const [\n inputItems,\n inputActive,\n handleSetInputAreaTabActive\n ] = useTabs({\n items: [ { id: 'input', title: 'input' } ],\n initial: 'input',\n });\n\n const [\n outputItems,\n outputActive,\n handleSetOutputAreaTabActive\n ] = useTabs({\n items: [\n { id: 'preview', title: 'html preview' },\n { id: 'html', title: 'html' },\n { id: 'markdown', title: 'markdown' },\n { id: 'tokens', title: 'tokens' },\n ],\n initial: 'preview',\n onSetActive: generate,\n });\n\n const handleInputChange = (input?: string) => {\n setInput(input || '');\n };\n\n useEffect(() => {\n generate(outputActive);\n\n if (props?.persistRestore) {\n persist(input);\n }\n }, [input]);\n\n return (\n \n \n \n \n \n );\n}\n\nexport {App, Playground};\nexport default {App, Playground};\n Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/src/index.tsx b/src/index.tsx --- a/src/index.tsx (revision 1b817c8baa5594a7eebd8914f41c6217dd16432f) +++ b/src/index.tsx (date 1695408924783) @@ -33,6 +33,7 @@ export type PlaygroundProperties = { content?: string; + tabs?: { id: string, title: string }[]; persistRestore?: boolean; } @@ -71,7 +72,7 @@ outputActive, handleSetOutputAreaTabActive ] = useTabs({ - items: [ + items: props?.tabs || [ { id: 'preview', title: 'html preview' }, { id: 'html', title: 'html' }, { id: 'markdown', title: 'markdown' }, Index: src/input-area.tsx IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP <+>import {useRef} from 'react'\nimport {Tabs, TabsProps, Card, Row, Col} from '@gravity-ui/uikit';\n\nimport Editor from '@monaco-editor/react';\nimport type {editor as EditorTypes} from 'monaco-editor';\n\nexport type InputAreaProps = {\n handleSelectTab: (active: string) => void;\n tabItems: TabsProps['items'];\n tabActive: string;\n\n handleInputChange: (input?: string) => void;\n input: string;\n}\n\nfunction InputArea(props: InputAreaProps) {\n const monacoRef = useRef(null);\n\n const {tabActive, tabItems, input, handleInputChange, handleSelectTab} = props;\n\n const editorOptions = {minimap: {enabled: false}, lineNumbers: \"off\" as const};\n\n const lines = monacoRef?.current?.getModel()?.getLineCount() ?? 10; \n const height = `${lines * 16}px`;\n\n const handleOnMount = (editor) => {\n monacoRef.current = editor;\n }\n\n return (\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n );\n}\n\nexport {InputArea};\nexport default {InputArea};\n Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/src/input-area.tsx b/src/input-area.tsx --- a/src/input-area.tsx (revision 1b817c8baa5594a7eebd8914f41c6217dd16432f) +++ b/src/input-area.tsx (date 1695408752627) @@ -36,7 +36,7 @@ - + Index: src/output-area.tsx IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP <+>import {Row, Col, Card, Tabs, TabsProps, TextArea} from '@gravity-ui/uikit';\n\nexport type OutputAreaProps = {\n handleSelectTab: (active: string) => void;\n tabItems: TabsProps['items'];\n tabActive: string;\n\n handleInputChange?: (input: string) => void;\n output: string;\n};\n\nfunction OutputArea(props: OutputAreaProps) {\n let {output, tabItems, tabActive, handleSelectTab, handleInputChange} = props;\n\n if (!handleInputChange) {\n handleInputChange = () => {}\n }\n\n return (\n \n \n \n \n \n \n \n \n {tabActive === 'preview'\n ? \n
\n
\n : \n }\n \n
\n
\n \n );\n}\n\nexport {OutputArea};\nexport default {OutputArea};\n Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/src/output-area.tsx b/src/output-area.tsx --- a/src/output-area.tsx (revision 1b817c8baa5594a7eebd8914f41c6217dd16432f) +++ b/src/output-area.tsx (date 1695408752630) @@ -31,8 +31,8 @@ {tabActive === 'preview' - ? -
+ ? +
: