mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 13:48:34 +00:00
Merge pull request #581 from roipoussiere/line_wrap
editor: enable line wrapping
This commit is contained in:
commit
0862827a51
@ -88,12 +88,7 @@ const highlightField = StateField.define({
|
|||||||
provide: (f) => EditorView.decorations.from(f),
|
provide: (f) => EditorView.decorations.from(f),
|
||||||
});
|
});
|
||||||
|
|
||||||
const staticExtensions = [
|
const staticExtensions = [javascript(), highlightField, flashField];
|
||||||
javascript(),
|
|
||||||
highlightField,
|
|
||||||
flashField,
|
|
||||||
javascriptLanguage.data.of({ autocomplete: strudelAutocomplete }),
|
|
||||||
];
|
|
||||||
|
|
||||||
export default function CodeMirror({
|
export default function CodeMirror({
|
||||||
value,
|
value,
|
||||||
@ -104,6 +99,7 @@ export default function CodeMirror({
|
|||||||
keybindings,
|
keybindings,
|
||||||
isLineNumbersDisplayed,
|
isLineNumbersDisplayed,
|
||||||
isAutoCompletionEnabled,
|
isAutoCompletionEnabled,
|
||||||
|
isLineWrappingEnabled,
|
||||||
fontSize = 18,
|
fontSize = 18,
|
||||||
fontFamily = 'monospace',
|
fontFamily = 'monospace',
|
||||||
options,
|
options,
|
||||||
@ -149,8 +145,12 @@ export default function CodeMirror({
|
|||||||
_extensions.push(autocompletion({ override: [] }));
|
_extensions.push(autocompletion({ override: [] }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isLineWrappingEnabled) {
|
||||||
|
_extensions.push(EditorView.lineWrapping);
|
||||||
|
}
|
||||||
|
|
||||||
return _extensions;
|
return _extensions;
|
||||||
}, [keybindings, isAutoCompletionEnabled]);
|
}, [keybindings, isAutoCompletionEnabled, isLineWrappingEnabled]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ fontSize, fontFamily }} className="w-full">
|
<div style={{ fontSize, fontFamily }} className="w-full">
|
||||||
|
|||||||
@ -364,7 +364,15 @@ const fontFamilyOptions = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function SettingsTab({ scheduler }) {
|
function SettingsTab({ scheduler }) {
|
||||||
const { theme, keybindings, isLineNumbersDisplayed, isAutoCompletionEnabled, fontSize, fontFamily } = useSettings();
|
const {
|
||||||
|
theme,
|
||||||
|
keybindings,
|
||||||
|
isLineNumbersDisplayed,
|
||||||
|
isAutoCompletionEnabled,
|
||||||
|
isLineWrappingEnabled,
|
||||||
|
fontSize,
|
||||||
|
fontFamily,
|
||||||
|
} = useSettings();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="text-foreground p-4 space-y-4">
|
<div className="text-foreground p-4 space-y-4">
|
||||||
@ -407,7 +415,7 @@ function SettingsTab({ scheduler }) {
|
|||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
<div className="grid grid-cols-1 md:grid-cols-4 gap-4">
|
||||||
<FormItem label="Keybindings">
|
<FormItem label="Keybindings">
|
||||||
<ButtonGroup
|
<ButtonGroup
|
||||||
value={keybindings}
|
value={keybindings}
|
||||||
@ -425,6 +433,11 @@ function SettingsTab({ scheduler }) {
|
|||||||
onChange={(cbEvent) => settingsMap.setKey('isAutoCompletionEnabled', cbEvent.target.checked)}
|
onChange={(cbEvent) => settingsMap.setKey('isAutoCompletionEnabled', cbEvent.target.checked)}
|
||||||
value={isAutoCompletionEnabled}
|
value={isAutoCompletionEnabled}
|
||||||
/>
|
/>
|
||||||
|
<Checkbox
|
||||||
|
label="Enable line wrapping"
|
||||||
|
onChange={(cbEvent) => settingsMap.setKey('isLineWrappingEnabled', cbEvent.target.checked)}
|
||||||
|
value={isLineWrappingEnabled}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<FormItem label="Reset Settings">
|
<FormItem label="Reset Settings">
|
||||||
<button
|
<button
|
||||||
|
|||||||
@ -105,7 +105,15 @@ export function Repl({ embedded = false }) {
|
|||||||
const [lastShared, setLastShared] = useState();
|
const [lastShared, setLastShared] = useState();
|
||||||
const [pending, setPending] = useState(true);
|
const [pending, setPending] = useState(true);
|
||||||
|
|
||||||
const { theme, keybindings, fontSize, fontFamily, isLineNumbersDisplayed, isAutoCompletionEnabled } = useSettings();
|
const {
|
||||||
|
theme,
|
||||||
|
keybindings,
|
||||||
|
fontSize,
|
||||||
|
fontFamily,
|
||||||
|
isLineNumbersDisplayed,
|
||||||
|
isAutoCompletionEnabled,
|
||||||
|
isLineWrappingEnabled,
|
||||||
|
} = useSettings();
|
||||||
|
|
||||||
const { code, setCode, scheduler, evaluate, activateCode, isDirty, activeCode, pattern, started, stop, error } =
|
const { code, setCode, scheduler, evaluate, activateCode, isDirty, activeCode, pattern, started, stop, error } =
|
||||||
useStrudel({
|
useStrudel({
|
||||||
@ -273,6 +281,7 @@ export function Repl({ embedded = false }) {
|
|||||||
keybindings={keybindings}
|
keybindings={keybindings}
|
||||||
isLineNumbersDisplayed={isLineNumbersDisplayed}
|
isLineNumbersDisplayed={isLineNumbersDisplayed}
|
||||||
isAutoCompletionEnabled={isAutoCompletionEnabled}
|
isAutoCompletionEnabled={isAutoCompletionEnabled}
|
||||||
|
isLineWrappingEnabled={isLineWrappingEnabled}
|
||||||
fontSize={fontSize}
|
fontSize={fontSize}
|
||||||
fontFamily={fontFamily}
|
fontFamily={fontFamily}
|
||||||
onChange={handleChangeCode}
|
onChange={handleChangeCode}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ export const defaultSettings = {
|
|||||||
keybindings: 'codemirror',
|
keybindings: 'codemirror',
|
||||||
isLineNumbersDisplayed: true,
|
isLineNumbersDisplayed: true,
|
||||||
isAutoCompletionEnabled: false,
|
isAutoCompletionEnabled: false,
|
||||||
|
isLineWrappingEnabled: false,
|
||||||
theme: 'strudelTheme',
|
theme: 'strudelTheme',
|
||||||
fontFamily: 'monospace',
|
fontFamily: 'monospace',
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
@ -23,6 +24,7 @@ export function useSettings() {
|
|||||||
isZen: [true, 'true'].includes(state.isZen) ? true : false,
|
isZen: [true, 'true'].includes(state.isZen) ? true : false,
|
||||||
isLineNumbersDisplayed: [true, 'true'].includes(state.isLineNumbersDisplayed) ? true : false,
|
isLineNumbersDisplayed: [true, 'true'].includes(state.isLineNumbersDisplayed) ? true : false,
|
||||||
isAutoCompletionEnabled: [true, 'true'].includes(state.isAutoCompletionEnabled) ? true : false,
|
isAutoCompletionEnabled: [true, 'true'].includes(state.isAutoCompletionEnabled) ? true : false,
|
||||||
|
isLineWrappingEnabled: [true, 'true'].includes(state.isLineWrappingEnabled) ? true : false,
|
||||||
fontSize: Number(state.fontSize),
|
fontSize: Number(state.fontSize),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user