From 3ca0dc31478a076145d1bc3d43de0a3e5826f149 Mon Sep 17 00:00:00 2001 From: Lauren Davidson <32903719+1aurend@users.noreply.github.com> Date: Thu, 1 Dec 2022 15:14:32 -0800 Subject: [PATCH] [WIP] Update react-ace --- client/package.json | 3 +- .../global/components/form/CodeArea/Ace.js | 26 +++++++++++--- .../global/components/form/CodeArea/index.js | 7 ++-- client/webpack/config/base.config.js | 10 +++++- client/yarn.lock | 34 +++++++++++-------- 5 files changed, 56 insertions(+), 24 deletions(-) diff --git a/client/package.json b/client/package.json index e4ae3f4871..9af6752b24 100644 --- a/client/package.json +++ b/client/package.json @@ -93,6 +93,7 @@ "@emotion/react": "^11.5.0", "@emotion/server": "^11.4.0", "@emotion/styled": "^11.3.0", + "ace-builds": "^1.14.0", "actioncable": "~5.0.2", "autolinker": "^1.x", "autoprefixer": "^9.0", @@ -141,7 +142,7 @@ "qs": "^6.0.0", "query-string": "^6.x", "react": "^16.13", - "react-ace": "^5.9.0", + "react-ace": "^10.1.0", "react-attr-converter": "^0.3.1", "react-beautiful-dnd": "^13.0.0", "react-collapse": "^5.0.0", diff --git a/client/src/global/components/form/CodeArea/Ace.js b/client/src/global/components/form/CodeArea/Ace.js index c5042226cd..210f937267 100644 --- a/client/src/global/components/form/CodeArea/Ace.js +++ b/client/src/global/components/form/CodeArea/Ace.js @@ -1,7 +1,23 @@ -import ace from "react-ace"; -import "brace/mode/css"; -import "brace/mode/javascript"; -import "brace/mode/html"; +import path from "path"; +import ace from "ace-builds/src-noconflict/ace"; +import editor from "react-ace"; import "./theme"; -export default ace; +/* We don't want to use this because it adds every build, but it does fix the basePath error. */ +// import "ace-builds/webpack-resolver"; + +ace.config.set("basePath", path.resolve(__dirname, "../../../../..")); + +import "ace-builds/src-noconflict/mode-html"; +import "ace-builds/src-noconflict/mode-css"; +import "ace-builds/src-noconflict/mode-javascript"; + +// import jsWorkerUrl from "ace-builds/src-noconflict/worker-javascript"; +// import htmlWorkerUrl from "ace-builds/src-noconflict/worker-html"; +import cssWorkerUrl from "ace-builds/src-noconflict/worker-css"; + +ace.config.setModuleUrl("ace/mode/css_worker", cssWorkerUrl); +// ace.config.setModuleUrl("ace/mode/javascript_worker", jsWorkerUrl); +// ace.config.setModuleUrl("ace/mode/html_worker", htmlWorkerUrl); + +export default editor; diff --git a/client/src/global/components/form/CodeArea/index.js b/client/src/global/components/form/CodeArea/index.js index 70707b0c63..bbdf851229 100644 --- a/client/src/global/components/form/CodeArea/index.js +++ b/client/src/global/components/form/CodeArea/index.js @@ -10,9 +10,10 @@ import Instructions from "../Instructions"; /* eslint-disable react/prop-types */ const CodeAreaInput = Loadable({ loader: () => - import(/* webpackChunkName: "ace-editor" */ "./Ace").then( - ace => ace.default - ), + import(/* webpackChunkName: "ace-editor" */ "./Ace").then(ace => { + console.log(ace); + return ace.default; + }), render(Editor, props) { return (