diff --git a/docs/src/editor/online-editor.tsx b/docs/src/editor/online-editor.tsx index a0abf79..f0d421b 100644 --- a/docs/src/editor/online-editor.tsx +++ b/docs/src/editor/online-editor.tsx @@ -197,3 +197,60 @@ export function OnlineEditorInput(props: ComponentProps<'div'>) { export function OnlineEditorOutput(props: ComponentProps<'div'>) { return
} + +export function OnlineEditorPageContent() { + let initCode = `\ +// ↓ ↓ ↓ Add support code if needed. ↑ ↑ ↑ Do not delete \`import ...\` ↑ + +// ↑ ↑ ↑ Add support code if needed. ↓ ↓ ↓ Do not delete the \`rules\` variable ↓ +let rules = [ + // ↓ ↓ ↓ Add rules and/or layers. ↑ ↑ ↑ Do not delete the \`rules\` variable ↑ + + rule('Playground').manipulators([ + map('⇪').toHyper().toIfAlone('⎋'), + { escape: toKey('caps_lock') }, + ]), + + // ↑ ↑ ↑ Add rules and/or layers. ↓ ↓ ↓ Do not delete \`]\` below ↓ +]\n` + return ( + + +
+ + +
+
+ ) +} + +function OnlineEditorPageHeader() { + let ctrl = useOnlineEditorCtrl() + function handleCopyJson() { + let text = ctrl.editors.output?.getValue() + if (text) { + void navigator.clipboard.writeText(text) + } + } + return ( +
+ + ? Import to Karabiner-Elements + + +
+ ) +} diff --git a/docs/src/pages/editor.tsx b/docs/src/pages/editor.tsx index 987c7de..f1e2ca0 100644 --- a/docs/src/pages/editor.tsx +++ b/docs/src/pages/editor.tsx @@ -1,63 +1,16 @@ -import { - OnlineEditorInput, - OnlineEditorOutput, - OnlineEditorProvider, - useOnlineEditorCtrl, -} from '@site/src/editor/online-editor' +import BrowserOnly from '@docusaurus/BrowserOnly' import Layout from '@theme/Layout' -let initCode = `\ -// ↓ ↓ ↓ Add support code if needed. ↑ ↑ ↑ Do not delete \`import ...\` ↑ - -// ↑ ↑ ↑ Add support code if needed. ↓ ↓ ↓ Do not delete the \`rules\` variable ↓ -let rules = [ - // ↓ ↓ ↓ Add rules and/or layers. ↑ ↑ ↑ Do not delete the \`rules\` variable ↑ - - rule('Playground').manipulators([ - map('⇪').toHyper().toIfAlone('⎋'), - { escape: toKey('caps_lock') }, - ]), - - // ↑ ↑ ↑ Add rules and/or layers. ↓ ↓ ↓ Do not delete \`]\` below ↓ -]\n` - export default function EditorPage() { return ( - - -
- - -
-
+ + {() => { + let OnlineEditorPageContent = + require('@site/src/editor/online-editor').OnlineEditorPageContent + return + }} +
) } - -function OnlineEditorHeader() { - let ctrl = useOnlineEditorCtrl() - function handleCopyJson() { - let text = ctrl.editors.output?.getValue() - if (text) { - void navigator.clipboard.writeText(text) - } - } - return ( -
- - ? Import to Karabiner-Elements - - -
- ) -}