Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
163 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
8fa67f9
Add JSON syntax linting to CodeMirror v6 editor
Geethegreat Jan 29, 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
9a37d7e
Fix CSS linter highlight range in CodeMirror v6
VaibhavNarayann Feb 20, 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
fcc47fd
Import my modified colorpicker library
khanniie Mar 17, 2026
34de741
refactor: use jsonParseLinter from @codemirror/lang-json
Geethegreat Mar 22, 2026
f5c7c14
add back kind labels and ghost previews to hinter
raclim Mar 23, 2026
0e25543
add keyboard behavior and custom UI for hinter dropdown
raclim Mar 23, 2026
3cc073e
refactor contextaware and analyzer utils to adapt to cm6
raclim Mar 23, 2026
4be55d1
integrate context awareness and ghost text
raclim Mar 23, 2026
e77e2a6
update func name, add ghost text util
raclim Mar 23, 2026
5931f13
add styling for hinter
raclim Mar 23, 2026
997e50f
fix:Emmet expands abbrevations when text is pasted
Nishthajain7 Feb 22, 2026
0f8ac70
Merge pull request #4006 from processing/cm6-color-picker-import
raclim Mar 24, 2026
474fa20
fix color picker selecting wrong line
KaiDevrim Mar 21, 2026
d411d2d
tweak wording
raclim Mar 27, 2026
b5e6852
Merge pull request #4043 from processing/autocomplete-hinter-parity
khanniie Apr 2, 2026
bdff696
merge upstream/develop-codemirror-v6 to resolve conflicts
Geethegreat Apr 3, 2026
0bfda9c
Merge pull request #3825 from Geethegreat/json-lint
khanniie Apr 3, 2026
477aad6
Merge branch 'develop' into develop-codemirror-v6
khanniie Apr 10, 2026
38773a6
Update package-lock.json
khanniie Apr 10, 2026
dd02f07
Add back reference url for p5 v2 change
khanniie Apr 10, 2026
2258399
merge
khanniie Apr 10, 2026
0b40206
merge??
khanniie Apr 10, 2026
957a9c6
Migrated to ESlint
Nishthajain7 Mar 9, 2026
bac3fbe
Resolved Merge Conflicts
Nishthajain7 Apr 10, 2026
80b2e8e
add reference url to useEffect and clean up comments
khanniie Apr 10, 2026
3d020a5
Merge pull request #3836 from Nishthajain7/migarte-to-eslint
khanniie Apr 10, 2026
67e6674
Merge branch 'develop-codemirror-v6' of https://github.com/processing…
khanniie Apr 10, 2026
b7a4de9
cleanup imports
khanniie Apr 10, 2026
4cdace3
Revert "cleanup imports"
khanniie Apr 10, 2026
bd83142
fix: scope CM6 Tidy keymap per file state (#4093)
dimssu Apr 23, 2026
3006204
fix:Right arrow key navigation after auto-closing brackets
Nishthajain7 Apr 29, 2026
cc2e99e
fix tidy code keyboard shortcut key
skyash-dev May 29, 2026
34599a4
Merge pull request #4134 from skyash-dev/fix/tidy-code-shortcut
khanniie May 29, 2026
c30490e
Merge branch 'develop-codemirror-v6' into fix/issue-4093-tidy-cm6
khanniie May 29, 2026
07099b4
Merge pull request #4097 from dimssu/fix/issue-4093-tidy-cm6
khanniie May 29, 2026
8a945b9
Merge pull request #4101 from Nishthajain7/auto-closing
khanniie May 29, 2026
7a75318
Merge branch 'develop' into develop-codemirror-v6
khanniie May 30, 2026
26864e3
update codemirror after merge from develop
khanniie May 30, 2026
0f7c0df
Update package-lock.json
khanniie May 30, 2026
2bca8a6
Merge pull request #3919 from VaibhavNarayann/fix-css-linter-highlight
khanniie May 30, 2026
f8da086
Update index.jsx
khanniie May 30, 2026
919a3a0
Merge branch 'develop-codemirror-v6' of https://github.com/processing…
khanniie May 30, 2026
7768f93
Merge pull request #4027 from Nishthajain7/expand-abbrevations
khanniie May 30, 2026
18e7820
Merge branch 'develop-codemirror-v6' of https://github.com/processing…
khanniie May 30, 2026
612aa71
Add back some changes lost in the merge
khanniie May 30, 2026
c13114e
fix tidier tests within stateutils
khanniie May 30, 2026
10d0d03
Add more checks to if we show the hinter or not
khanniie May 30, 2026
32979ce
Add log for tidier to debugging
khanniie May 30, 2026
5a9a5d9
test a fix for tidier
khanniie May 30, 2026
0ba170e
add another debugging statement
khanniie May 30, 2026
b37921a
testing further fixes to tidier
khanniie May 30, 2026
1e21512
remove debug logs now that problem is fixed
khanniie May 30, 2026
618a043
fix: restored p5.js keyword highlighting for CM6 #3868
parthjadhao01 Jun 1, 2026
76cef81
refactor: move p5 highlight logic into p5JavaScript.js
parthjadhao01 Jun 2, 2026
cb96dcb
Merge pull request #4141 from parthjadhao01/fix/p5-syntax-highlightin…
khanniie Jun 2, 2026
dafb44f
code cleanup
khanniie Jun 3, 2026
b1c13fc
Merge branch 'develop-codemirror-v6' into feature/color-picker-keybind
khanniie Jun 3, 2026
fd27d23
Merge pull request #4028 from AlexanderORuban/feature/color-picker-ke…
khanniie Jun 3, 2026
291d438
fix errors from merge conflict resolution
khanniie Jun 3, 2026
38b8bdf
move linters into a new file to reduce file size of stateUtils
khanniie Jun 3, 2026
ebc26b3
fix: restore CM6 editor visual consistency with CM5 #4144
parthjadhao01 Jun 3, 2026
74fa674
cleanup TODOs
khanniie Jun 3, 2026
a747e17
more cleanup
khanniie Jun 3, 2026
644ec1f
Update completionPreview.js
khanniie Jun 3, 2026
762add5
fix: remove !important flags from fold gutter alignment
parthjadhao01 Jun 3, 2026
2d8e9ba
Merge pull request #4147 from parthjadhao01/fix/cm6-editor-visual-con…
khanniie Jun 3, 2026
3587ee3
Merge branch 'develop-codemirror-v6' of https://github.com/processing…
khanniie Jun 3, 2026
63e21c6
big file move, cleaning up the folder structure
khanniie Jun 4, 2026
f780f9b
Rename stateUtils to fileState for a more descriptive filename
khanniie Jun 4, 2026
3d3749b
Merge branch 'develop' into develop-codemirror-v6
khanniie Jun 4, 2026
4d7fa39
remove random debug log
khanniie Jun 4, 2026
2fc474f
Update package-lock.json
khanniie Jun 4, 2026
beac848
fix bug where font looked too big
khanniie Jun 5, 2026
7b5c55a
Add getFileMode() tests
Jun 5, 2026
b9f7515
Remove autocomplete tests
Jun 5, 2026
cd981ef
Remove unnecessary console.log()
Jun 5, 2026
88d53a2
Clean up unused variables
Jun 6, 2026
3eefb4c
fix stale react state in cm6 update listener
skyash-dev Jun 6, 2026
e056124
fix ctrl/cmd+enter inserting blank line in cm6
skyash-dev Jun 6, 2026
0d979a7
Merge pull request #4158 from skyash-dev/fix/cm6-ctrl-enter-run-sketch
khanniie Jun 6, 2026
161d129
Merge pull request #4067 from mmendieta2/develop-codemirror-v6
khanniie Jun 6, 2026
206e716
refactor
skyash-dev Jun 6, 2026
2baece9
Merge pull request #4156 from skyash-dev/fix/cm6-stale-react-state
khanniie Jun 6, 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
Loading