Skip to content

Commit 39007b4

Browse files
author
Chuck Kosman
committed
Monaco code editor
1 parent 8d1d5a9 commit 39007b4

3 files changed

Lines changed: 73 additions & 60 deletions

File tree

components/locations/Field.tsx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import React, { useState, useEffect } from "react";
22
import { FieldAppSDK } from "@contentful/app-sdk";
33
import { useSDK } from "@contentful/react-apps-toolkit";
4-
import Editor from "react-simple-code-editor";
5-
import { highlight, languages } from "prismjs";
6-
import "prismjs/components/prism-css";
7-
import "prismjs/themes/prism.css";
4+
import Editor from "@monaco-editor/react";
85

96
const CONTENT_FIELD_ID = "css";
107

@@ -24,16 +21,12 @@ const Field = () => {
2421
return (
2522
<>
2623
<Editor
27-
value={css}
28-
onValueChange={(css) => {
29-
setCss(css);
30-
contentField.setValue(css);
31-
}}
32-
highlight={(css) => highlight(css, languages.css, "css")}
33-
padding={10}
34-
style={{
35-
fontFamily: '"Fira code", "Fira Mono", monospace',
36-
fontSize: 14,
24+
height="100vh"
25+
defaultValue={css}
26+
defaultLanguage="css"
27+
onChange={(value, event) => {
28+
setCss(value);
29+
contentField.setValue(value);
3730
}}
3831
/>
3932
</>

package-lock.json

Lines changed: 64 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@
1616
"@contentful/f36-components": "4.45.0",
1717
"@contentful/f36-tokens": "4.0.2",
1818
"@contentful/react-apps-toolkit": "1.2.16",
19-
"@types/prismjs": "^1.26.0",
19+
"@monaco-editor/react": "^4.5.1",
2020
"next": "13.4.8",
21-
"prismjs": "^1.29.0",
2221
"react": "18.2.0",
23-
"react-dom": "18.2.0",
24-
"react-simple-code-editor": "^0.13.1"
22+
"react-dom": "18.2.0"
2523
},
2624
"devDependencies": {
2725
"@contentful/app-scripts": "1.10.2",

0 commit comments

Comments
 (0)