Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions frontend/src/app/(navfooter)/new/NewScratchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,18 +391,18 @@ export default function NewScratchForm({
valueVersion={valueVersion}
onChange={setAsm}
extensions={basicSetup}
placeholder="Place your GAS-compatible assembly code here."
/>
</div>
<div className="flex h-[200px] flex-col">
<FormLabel small="(any typedefs, structs, and declarations you would like to include go here; typically generated with m2ctx.py)">
Context
</FormLabel>
<FormLabel small="(optional)">Context</FormLabel>
<CodeMirror
className="w-full flex-1 overflow-hidden rounded border border-[color:var(--g500)] bg-[color:var(--g200)] [&_.cm-editor]:h-full"
value={context}
valueVersion={valueVersion}
onChange={setContext}
extensions={[basicSetup, cpp()]}
placeholder="Add any typedefs, structs, and declarations here."
/>
</div>

Expand Down
4 changes: 4 additions & 0 deletions frontend/src/components/Editor/CodeMirror.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
cursor: text;
}

:global(.cm-placeholder) {
font-style: italic;
}

:global(.cm-gutters),
:global(.cm-content),
:global(.cm-tooltip-hover) {
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/Editor/CodeMirror.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "react";

import { type Extension, EditorState } from "@codemirror/state";
import { EditorView } from "@codemirror/view";
import { EditorView, placeholder } from "@codemirror/view";
import clsx from "clsx";
import { useDebouncedCallback } from "use-debounce";

Expand Down Expand Up @@ -49,6 +49,7 @@ export interface Props {
className?: string;
viewRef?: RefObject<EditorView | null>;
extensions: Extension; // const
placeholder?: string;
}

export default function CodeMirror({
Expand All @@ -60,6 +61,7 @@ export default function CodeMirror({
className,
viewRef: viewRefProp,
extensions,
placeholder: placeholderText,
}: Props) {
const { ref: el, width } = useSize<HTMLDivElement>();

Expand Down Expand Up @@ -96,6 +98,7 @@ export default function CodeMirror({
state: EditorState.create({
doc: valueRef.current,
extensions: [
placeholder(placeholderText || ""),
EditorState.transactionExtender.of(
({ docChanged, newDoc, newSelection }) => {
// value / onChange
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/Scratch/Scratch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ export default function Scratch({
}}
onSelectedLineChange={setSelectedSourceLine}
extensions={cmExtensionsSource}
placeholder="Write the code for the function you are matching here."
/>
</Tab>
);
Expand All @@ -322,6 +323,7 @@ export default function Scratch({
setScratch({ context: value });
}}
extensions={cmExtensionsContext}
placeholder="Add your typedefs, structs, and declarations here."
/>
</Tab>
);
Expand Down