/
githubmirror
/
docusaurus
Обзор
Документация
Войти
/
githubmirror
/
docusaurus
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/docusaurus-theme-live-codeblock/src/theme/CodeBlock/index.tsx
38 строк
1 KB
Neel Bansal
feat(theme-live-codeblock): reset button + wire `position` prop (#11675)
19 фев 2026, 19:41
Не верифицирован
19 фев 2026, 19:41
49619fd
Код
Авторство
О чём код?
/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import React, {type ReactNode} from 'react'; import type {Props as CodeBlockProps} from '@theme/CodeBlock'; import OriginalCodeBlock from '@theme-init/CodeBlock'; import LiveCodeBlock from '@theme/LiveCodeBlock'; // TODO Docusaurus v4: remove special case // see packages/docusaurus-mdx-loader/src/remark/mdx1Compat/codeCompatPlugin.ts // we can just use the metastring instead declare module '@theme/CodeBlock' { interface Props { live?: boolean; } } function isLiveCodeBlock( props: CodeBlockProps, ): props is {live: true; children: string | undefined} { return ( !!props.live && (typeof props.children === 'undefined' || typeof props.children === 'string') ); } export default function CodeBlockEnhancer(props: CodeBlockProps): ReactNode { return isLiveCodeBlock(props) ? ( <LiveCodeBlock {...props} /> ) : ( <OriginalCodeBlock {...props} /> ); }