Skip to content

Commit

Permalink
hide some settings on the public website playground (facebook#1667)
Browse files Browse the repository at this point in the history
  • Loading branch information
acywatson authored Apr 13, 2022
1 parent d01ac3f commit c023ed4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
3 changes: 2 additions & 1 deletion packages/lexical-playground/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import LexicalComposer from '@lexical/react/LexicalComposer';
import * as React from 'react';

import {isPlayground} from './appSettings';
import {SettingsContext, useSettings} from './context/SettingsContext';
import {SharedHistoryContext} from './context/SharedHistoryContext';
import Editor from './Editor';
Expand Down Expand Up @@ -43,7 +44,7 @@ function App(): React$Node {
<Editor />
</div>
<Settings />
<TestRecorderPlugin />
{isPlayground && <TestRecorderPlugin />}
{measureTypingPerf && <TypingPerfPlugin />}
</SharedHistoryContext>
</LexicalComposer>
Expand Down
27 changes: 15 additions & 12 deletions packages/lexical-playground/src/Settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import * as React from 'react';
import {useMemo, useState} from 'react';

import {isPlayground} from './appSettings';
import {useSettings} from './context/SettingsContext';
import Switch from './ui/Switch';

Expand Down Expand Up @@ -47,7 +48,7 @@ export default function Settings(): React$Node {
/>
{showSettings ? (
<div className="switches">
{isRichText && (
{isRichText && isPlayground && (
<Switch
onClick={() => {
setOption('isCollab', !isCollab);
Expand All @@ -57,17 +58,19 @@ export default function Settings(): React$Node {
text="Collaboration"
/>
)}
<Switch
onClick={() => {
if (isSplitScreen) {
window.parent.location.href = `http://localhost:${port}/${search}`;
} else {
window.location.href = `http://localhost:${port}/split/${search}`;
}
}}
checked={isSplitScreen}
text="Split Screen"
/>
{isPlayground && (
<Switch
onClick={() => {
if (isSplitScreen) {
window.parent.location.href = `http://localhost:${port}/${search}`;
} else {
window.location.href = `http://localhost:${port}/split/${search}`;
}
}}
checked={isSplitScreen}
text="Split Screen"
/>
)}
<Switch
onClick={() => setOption('measureTypingPerf', !measureTypingPerf)}
checked={measureTypingPerf}
Expand Down
3 changes: 3 additions & 0 deletions packages/lexical-playground/src/appSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ export const DEFAULT_SETTINGS: Settings = {
showNestedEditorTreeView: false,
showTreeView: true,
};

export const isPlayground =
window.location.hostname === 'playground.lexical.dev';
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ ${steps.map(formatStep).join(`\n`)}
return [button, output];
}

export default function TreeViewPlugin(): React$Node {
export default function TestRecorderPlugin(): React$Node {
const [editor] = useLexicalComposerContext();
const [testRecorderButton, testRecorderOutput] = useTestRecorder(editor);

Expand Down

0 comments on commit c023ed4

Please sign in to comment.