Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
84b135b
Split off hinter functionality into a separate file
khanniie Jan 24, 2025
10da30e
update docstring in hinter
khanniie Jan 24, 2025
44e5cfc
move csslint to hint file
khanniie Jan 28, 2025
850845a
fix bug where i forgot to pass in the cm instance to hide the hinter
khanniie Jan 31, 2025
4d9b05f
Merge pull request #3327 from processing/connie-editor-conversion-hin…
khanniie Jan 31, 2025
0651ccf
Moves the tidier code and file mode out of editor file
khanniie Feb 7, 2025
f7cbcab
Merge pull request #3335 from processing/connie-editor-conversion-uti…
raclim Feb 7, 2025
dc1b51d
Merge branch 'develop' into connie-develop
khanniie Mar 7, 2025
249e728
Merge branch 'develop' into connie-develop
khanniie Mar 28, 2025
fe0d19f
fix Exiting Multi-Line Cursor Doesnt Return to the Original Cursor
Vishawdeep-Singh Dec 24, 2024
ce37415
remove extra console log
raclim Feb 7, 2025
c1102d9
pull out codemirror test
khanniie Feb 14, 2025
2c917a2
Convert editor file to functional
khanniie Feb 28, 2025
55bb4a5
change CM fifle to a useCodeMirror custom hook
khanniie Mar 7, 2025
7c822b1
fix codemirror file debounce bug
khanniie Mar 23, 2025
1e575f9
fix codemirrorr bug with debouncer again
khanniie Mar 23, 2025
107e9bf
only useeffect on file id change
khanniie Mar 23, 2025
e45d265
switches from using usePrevious to an existing hook
khanniie Mar 23, 2025
0ac3234
moves document management to the cm file
khanniie Mar 23, 2025
f3f7ab4
fix test error
khanniie Mar 24, 2025
6d7ef6d
fix mobile bug
khanniie Mar 28, 2025
ea815f7
adds comments, removes a logic block that wasn't doing anything
khanniie Mar 28, 2025
36c4129
add TODO
khanniie Mar 28, 2025
9fd608d
Merge pull request #3352 from processing/connie-editor-conversion-spl…
raclim Mar 28, 2025
172d573
merge develop into cm-develop
khanniie May 30, 2025
52a3b53
merge old develop branch into connie's cm develop branch
khanniie Jul 6, 2025
5d3d93d
codemirror v5 -> v6
khanniie May 23, 2025
619f1c4
Update codemirror.js
khanniie May 30, 2025
2e85808
remove unused cm5 styles
khanniie May 30, 2025
c12d18a
remove cm5 plugins
khanniie May 30, 2025
f8f6dab
git didnt track the file case rename so i renamed it back
khanniie May 30, 2025
ec5eb21
update comments tracking TODOs
khanniie May 30, 2025
d2269a1
fix getfilemode not exported
khanniie May 30, 2025
4f35218
fix the nonscrolling issue
khanniie Jul 4, 2025
0cf467a
Update codemirror.js
khanniie Jul 6, 2025
d6ef821
fix consoleinput for cm v6
khanniie Jul 7, 2025
b1890c8
remove leftover console log
khanniie Jul 7, 2025
422ed0f
add ts support for tests to fix testing errors
khanniie Jul 7, 2025
f8a57d5
update comment docs
khanniie Jul 7, 2025
d2071f7
Add back teardown function
khanniie Jul 10, 2025
d7cd4f5
Merge pull request #3500 from processing/connie-codemirror-upgrade
raclim Jul 11, 2025
4f358b4
Merge branch 'develop' into develop-codemirror-v6
khanniie Jul 11, 2025
9cbbd8b
adds initial autocomplete
khanniie Jul 12, 2025
c3d0872
extend js with p5 js
khanniie Jul 18, 2025
456737a
finishes hinter script, implements it
khanniie Aug 9, 2025
e5699d5
finish autocomplete MVP
khanniie Aug 9, 2025
5b9163e
Delete p5-hinter-cm6.js
khanniie Aug 9, 2025
2b82810
fix leftover path
khanniie Aug 9, 2025
9f04f17
fix name casing
khanniie Aug 10, 2025
eae004b
Merge pull request #3582 from processing/cm6-autocomplete
raclim Sep 5, 2025
7290b04
Merge branch 'develop' into develop-codemirror-v6
khanniie Sep 15, 2025
09a052f
initial commit adding search functionality
khanniie Sep 4, 2025
597f180
cleanup references to search and find
khanniie Sep 4, 2025
004f890
Update Nav.unit.test.jsx.snap
khanniie Sep 11, 2025
7b58f6d
Merge pull request #3639 from processing/cm6-search-and-find
raclim Sep 19, 2025
8308700
Merge branch 'develop' into develop-codemirror-v6
khanniie Jan 6, 2026
1b095e9
Update package-lock.json
khanniie Jan 6, 2026
67c11b6
update editor.scss to use new classes
khanniie Dec 12, 2025
387ef02
add highlight styles
khanniie Dec 19, 2025
6b2ad75
more highlight fixes
khanniie Jan 6, 2026
0e599ca
Update package-lock.json
khanniie Jan 9, 2026
84972b0
clean up unused files
khanniie Jan 9, 2026
adacb96
Update documentation, remove dead code
khanniie Jan 9, 2026
f409be4
Update main.scss
khanniie Jan 9, 2026
1892d92
removed unused import
khanniie Jan 9, 2026
f5c1710
Merge pull request #3783 from processing/cm6-themes-v2
raclim Jan 13, 2026
8ff2e7b
fix error console
khanniie Feb 1, 2026
18124f3
Add documentation
khanniie Feb 1, 2026
996dcb4
small cleanup
khanniie Feb 2, 2026
963c02d
Merge pull request #3832 from processing/cm6-fix-error-console
raclim Feb 3, 2026
4003761
Add tests for tidier.js
Geethegreat Feb 14, 2026
fc6c488
Convert tidier.js to TypeScript && test coverage of tidier.ts
kashish00208 Feb 16, 2026
abae1b3
Merge pull request #3887 from Geethegreat/tidy-prettier-tests
raclim Feb 20, 2026
e42215e
add beneficial test cases for empty strings and syntax errors in tidi…
kashish00208 Feb 20, 2026
1fcd33d
Merge branch 'develop-codemirror-v6' into kashish00208/develop-codemi…
kashish00208 Feb 20, 2026
67c3954
Convert tidier.test.js to tidier.test.ts and finalize ts migration
kashish00208 Feb 20, 2026
8d66da7
test: update to strict formatting checks with exact newlines
kashish00208 Feb 26, 2026
a79f6fb
Merge pull request #3899 from kashish00208/develop-codemirror-v6
khanniie Mar 1, 2026
bab93d6
fix tidier imports and tests
khanniie Mar 1, 2026
5129e12
fix import
khanniie Mar 8, 2026
52539e0
fix: correct label htmlFor attributes in AccountForm (resolves #3945)
Mar 19, 2026
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
13 changes: 0 additions & 13 deletions client/modules/IDE/actions/ide.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,23 +236,10 @@ export function hideErrorModal() {
};
}

export function hideRuntimeErrorWarning() {
return {
type: ActionTypes.HIDE_RUNTIME_ERROR_WARNING
};
}

export function showRuntimeErrorWarning() {
return {
type: ActionTypes.SHOW_RUNTIME_ERROR_WARNING
};
}

export function startSketch() {
return (dispatch, getState) => {
dispatch(clearConsole());
dispatch(startVisualSketch());
dispatch(showRuntimeErrorWarning());
const state = getState();
dispatchMessage({
type: MessageTypes.SKETCH,
Expand Down
179 changes: 98 additions & 81 deletions client/modules/IDE/components/ConsoleInput.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import PropTypes from 'prop-types';
import React, { useRef, useEffect, useState } from 'react';
import CodeMirror from 'codemirror';
import React, { useRef, useEffect } from 'react';
import { EditorState } from '@codemirror/state';
import { EditorView, highlightSpecialChars, keymap } from '@codemirror/view';
import {
bracketMatching,
syntaxHighlighting,
defaultHighlightStyle
} from '@codemirror/language';
import { closeBrackets, closeBracketsKeymap } from '@codemirror/autocomplete';
import { defaultKeymap, history, historyKeymap } from '@codemirror/commands';
import { javascript } from '@codemirror/lang-javascript';

import { useDispatch } from 'react-redux';
import { Encode } from 'console-feed';

Expand All @@ -11,31 +21,24 @@ import { dispatchMessage, MessageTypes } from '../../../utils/dispatcher';
// heavily inspired by
// https://github.com/codesandbox/codesandbox-client/blob/92a1131f4ded6f7d9c16945dc7c18aa97c8ada27/packages/app/src/app/components/Preview/DevTools/Console/Input/index.tsx

// TODO(connie): Add theme support?
function ConsoleInput({ theme, fontSize }) {
const [commandHistory, setCommandHistory] = useState([]);
const [commandCursor, setCommandCursor] = useState(-1);
const commandHistory = useRef([]);
const commandCursor = useRef(-1);
const codemirrorContainer = useRef(null);
const cmInstance = useRef(null);
const cmView = useRef(null);
const dispatch = useDispatch();

useEffect(() => {
cmInstance.current = CodeMirror(codemirrorContainer.current, {
theme: `p5-${theme}`,
scrollbarStyle: null,
keymap: 'sublime',
mode: 'javascript',
inputStyle: 'contenteditable'
});
}, []);

useEffect(() => {
const handleEnterKey = (cm, e) => {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
e.stopPropagation();

const value = cm.getValue().trim();
if (value === '') return;
const enterKeymap = {
key: 'Enter',
shiftKey: () => false, // Treat like a normal Enter key press if the Shift key is held down.
preventDefault: true,
stopPropogation: true,
run: (view) => {
const value = view.state.doc.toString().trim();
if (value === '' || view.state.selection.main.empty === false)
return false;

const messages = [
{ log: Encode({ method: 'command', data: [value] }) }
Expand All @@ -48,77 +51,91 @@ function ConsoleInput({ theme, fontSize }) {
});

dispatch(dispatchConsoleEvent(consoleEvent));
cm.setValue('');
setCommandHistory([value, ...commandHistory]);
setCommandCursor(-1);
}
};

if (cmInstance.current) {
cmInstance.current.on('keydown', handleEnterKey);
}

return () => {
if (cmInstance.current) {
cmInstance.current.off('keydown', handleEnterKey);
view.dispatch({
changes: { from: 0, to: view.state.doc.length, insert: '' }
});
commandHistory.current.unshift(value);
commandCursor.current = -1;
return true;
}
};
}, [commandHistory]);

useEffect(() => {
const handleUpArrowKey = (cm, e) => {
if (e.key === 'ArrowUp') {
const lineNumber = cm.getDoc().getCursor().line;
if (lineNumber !== 0) return;
const upArrowKeymap = {
key: 'ArrowUp',
run: (view) => {
// Just let the cursor go up if we have a multiline input
// and the cursor isn't at the first line.
const currentLine = view.state.doc.lineAt(
view.state.selection.main.head
).number;
// CM lines are 1-indexed, so the first line is 1.
if (currentLine > 1) return false;

const newCursor = Math.min(
commandCursor + 1,
commandHistory.length - 1
commandCursor.current + 1,
commandHistory.current.length - 1
);
cm.setValue(commandHistory[newCursor] || '');
const cursorPos = cm.getDoc().getLine(0).length - 1;
cm.getDoc().setCursor({ line: 0, ch: cursorPos });
setCommandCursor(newCursor);
}
};

if (cmInstance.current) {
cmInstance.current.on('keydown', handleUpArrowKey);
}

return () => {
if (cmInstance.current) {
cmInstance.current.off('keydown', handleUpArrowKey);
const newValue = commandHistory.current[newCursor] || '';
view.dispatch({
changes: { from: 0, to: view.state.doc.length, insert: newValue }
});
const newCursorPos = newValue.length;
view.dispatch({
selection: { anchor: newCursorPos, head: newCursorPos }
});
commandCursor.current = newCursor;
return true;
}
};
}, [commandCursor, commandHistory]);

useEffect(() => {
const handleArrowDownKey = (cm, e) => {
if (e.key === 'ArrowDown') {
const lineNumber = cm.getDoc().getCursor().line;
const lineCount = cm.lineCount();
if (lineNumber + 1 !== lineCount) return;

const newCursor = Math.max(commandCursor - 1, -1);
cm.setValue(commandHistory[newCursor] || '');
const newLine = cm.getDoc().getLine(lineCount - 1);
const cursorPos = newLine ? newLine.length - 1 : 1;
cm.getDoc().setCursor({ line: lineCount - 1, ch: cursorPos });
setCommandCursor(newCursor);
const downArrowKeymap = {
key: 'ArrowDown',
run: (view) => {
// Just let the cursor go down if we have a multiline input
// and the cursor isn't at the last line.
const currentLine = view.state.doc.lineAt(
view.state.selection.main.head
).number;
const docLength = view.state.doc.lines;
if (currentLine !== docLength) return false;

const newCursor = Math.max(commandCursor.current - 1, -1);
const newValue = commandHistory.current[newCursor] || '';
view.dispatch({
changes: { from: 0, to: view.state.doc.length, insert: newValue }
});
const newCursorPos = newValue.length;
view.dispatch({
selection: { anchor: newCursorPos, head: newCursorPos }
});
commandCursor.current = newCursor;
return true;
}
};

if (cmInstance.current) {
cmInstance.current.on('keydown', handleArrowDownKey);
}

return () => {
if (cmInstance.current) {
cmInstance.current.off('keydown', handleArrowDownKey);
}
};
}, [commandCursor, commandHistory]);
const cmState = EditorState.create({
extensions: [
history(),
highlightSpecialChars(),
bracketMatching(),
closeBrackets(),
syntaxHighlighting(defaultHighlightStyle),
javascript(),
keymap.of([
enterKeymap,
upArrowKeymap,
downArrowKeymap,
...defaultKeymap,
...closeBracketsKeymap,
...historyKeymap
])
]
});
cmView.current = new EditorView({
state: cmState,
parent: codemirrorContainer.current
});
}, []);

return (
<div className="console__input">
Expand Down
Loading