Skip to content

Commit c97b093

Browse files
Python indentation marker (#237)
# What's Changed? - Added and styled indentation markers in the codemirror editor ## Screenshots <img width="337" alt="Screenshot 2022-10-17 at 10 37 00" src="https://user-images.githubusercontent.com/88904316/196144184-b4034590-e3a0-4065-9b53-e1df339aaf3d.png"> <img width="348" alt="Screenshot 2022-10-17 at 10 37 47" src="https://user-images.githubusercontent.com/88904316/196144305-0b6a3d9b-7eab-4076-a095-ba171668b334.png"> closes #218 Co-authored-by: loiswells97 <[email protected]> Co-authored-by: Lois Wells <[email protected]>
1 parent 09b665b commit c97b093

File tree

6 files changed

+25
-0
lines changed

6 files changed

+25
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1414
- Cookie banner on the editor site (#206) but not in the embedded viewer (#231)
1515
- Unit tests for login button and 'useProject' hook (#211)
1616
- Script for Google Tag Manager to be used on the standalone editor site (#225)
17+
- Indentation markers in the editor (#237)
1718

1819
### Changed
1920

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@react-three/drei": "^9.7.1",
2121
"@react-three/fiber": "^8.0.13",
2222
"@reduxjs/toolkit": "^1.6.2",
23+
"@replit/codemirror-indentation-markers": "^6.1.0",
2324
"@rpf/sauce": "https://github.com/RaspberryPiFoundation/sauce-design-system.git#next",
2425
"axios": "^0.24.0",
2526
"codemirror": "^6.0.1",

src/components/Editor/EditorPanel/EditorPanel.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { basicSetup } from 'codemirror'
99
import { EditorView, keymap } from '@codemirror/view'
1010
import { EditorState } from '@codemirror/state'
1111
import { defaultKeymap, indentWithTab } from '@codemirror/commands'
12+
import { indentationMarkers } from '@replit/codemirror-indentation-markers'
1213

1314
import { html } from '@codemirror/lang-html'
1415
import { css } from '@codemirror/lang-css'
@@ -71,6 +72,7 @@ const EditorPanel = ({
7172
mode,
7273
onUpdate,
7374
editorTheme,
75+
indentationMarkers()
7476
],
7577
});
7678

src/components/Editor/editorDarkTheme.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ export const editorDarkTheme = EditorView.theme({
2222
"&.cm-focused .cm-cursor": {
2323
borderLeftColor: "white"
2424
},
25+
".cm-line .cm-indentation-marker": {
26+
'background': 'none',
27+
'border-left': '1px solid grey',
28+
"&.active": {
29+
'background': 'none',
30+
'border-left': '1px solid lightgrey',
31+
}
32+
},
2533
".ͼb": {color: "#FF00A4"},
2634
".ͼc": {color: "#1498D0"},
2735
".ͼd": {color: "#1498D0"},

src/components/Editor/editorLightTheme.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,12 @@ export const editorLightTheme = EditorView.theme({
1414
"color": "black",
1515
"background-color": "white"
1616
},
17+
".cm-line .cm-indentation-marker": {
18+
'background': 'none',
19+
'border-left': '1px solid lightgrey',
20+
"&.active": {
21+
'background': 'none',
22+
'border-left': '1px solid grey',
23+
}
24+
},
1725
}, {dark: false})

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,6 +2401,11 @@
24012401
redux-thunk "^2.4.1"
24022402
reselect "^4.1.5"
24032403

2404+
"@replit/codemirror-indentation-markers@^6.1.0":
2405+
version "6.1.0"
2406+
resolved "https://registry.yarnpkg.com/@replit/codemirror-indentation-markers/-/codemirror-indentation-markers-6.1.0.tgz#53ca559f25609c90e2e905624bb0aa57c7b3041a"
2407+
integrity sha512-x+9cWXUy60UdS1geFzaELXvchbHvsGjjwB+hQ+p9kOQ4Q3BH1Y2tC46OA6YLx0Lu2BoA1OEdvFsX3V2Af04yeA==
2408+
24042409
"@rollup/plugin-node-resolve@^7.1.1":
24052410
version "7.1.3"
24062411
resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-7.1.3.tgz#80de384edfbd7bfc9101164910f86078151a3eca"

0 commit comments

Comments
 (0)