-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#1640 Remove react-codemirror2 and upgrade to codemirror 6 #1641
Conversation
ec1941a
to
aa0784e
Compare
@@ -111,7 +119,7 @@ | |||
}, | |||
"jest": { | |||
"transformIgnorePatterns": [ | |||
"node_modules/(?!d3-*)" | |||
"/node_modules/(?!(lezer-r|d3|d3-array|d3-axis|d3-brush|d3-chord|d3-color|d3-contour|d3-delaunay|d3-dispatch|d3-drag|d3-dsv|d3-ease|d3-fetch|d3-force|d3-format|d3-geo|d3-hierarchy|d3-interpolate|d3-path|d3-polygon|d3-quadtree|d3-random|d3-scale|d3-scale-chromatic|d3-selection|d3-shape|d3-time|d3-time-format|d3-timer|d3-transition|d3-zoom)/)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d3-*
in following config didn't work. So I had to specify all d3 packages in the config.
transformIgnorePatterns": [
"/node_modules/(?!(d3-*|lezer-r)/)"
],
canvas_modules/harness/cypress/e2e/properties/expression-control.cy.js
Outdated
Show resolved
Hide resolved
08f6922
to
3c92086
Compare
let cursor = this.editor.getCursor(); | ||
const somethingSelected = this.editor.viewState.state.selection.ranges.some((r) => !r.empty); | ||
let cursor = this.editor.viewState.state.selection.main.head; | ||
if (cursor === 0 && !somethingSelected) { // TODO: Doesn't work when I explicitly set the cursor to 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When nothing is selected, cursor is set to the end of the line. But this if
loop doesn't work when I explicitly set the cursor to line 0, char 0 -
Screen.Recording.2024-02-08.at.4.08.46.PM.mov
Signed-off-by: Neha Gokhale <[email protected]>
Signed-off-by: Neha Gokhale <[email protected]>
Signed-off-by: Neha Gokhale <[email protected]>
Signed-off-by: Neha Gokhale <[email protected]>
Signed-off-by: Neha Gokhale <[email protected]>
Signed-off-by: Neha Gokhale <[email protected]>
Signed-off-by: Neha Gokhale <[email protected]>
Signed-off-by: Neha Gokhale <[email protected]>
Signed-off-by: Neha Gokhale <[email protected]>
Signed-off-by: Neha Gokhale <[email protected]>
Signed-off-by: Neha Gokhale <[email protected]>
Signed-off-by: Neha Gokhale <[email protected]>
Signed-off-by: Neha Gokhale <[email protected]>
Signed-off-by: Neha Gokhale <[email protected]>
3c92086
to
6a69e53
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When accessing the state is this documented? I'm thinking we need to either add 1 method to get the state to make sure it returns something or add optional chaining.
@@ -55,7 +63,7 @@ | |||
"@rollup/plugin-babel": "5.3.0", | |||
"@rollup/plugin-commonjs": "21.0.1", | |||
"@rollup/plugin-json": "4.1.0", | |||
"@rollup/plugin-node-resolve": "13.0.6", | |||
"@rollup/plugin-node-resolve": "^13.0.6", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason you changed the devDependencies? These should stay static since consuming applications wouldn't install them.
} | ||
|
||
onChange(newValue) { | ||
const value = (typeof newValue === "string") ? newValue : newValue.toString(); | ||
let cursor = this.editor.getCursor(); | ||
const somethingSelected = this.editor.viewState.state.selection.ranges.some((r) => !r.empty); | ||
let cursor = this.editor.viewState.state.selection.main.head; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are both of these internal to CodeMirror? We probably should add optional chaining in case CodeMirror changes the code and these objects don't exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add a new method which will return this.editor?.viewState?.state
Getting the state.doc
, state.selection
, state.replaceSelection
is documented in this migration guide - https://codemirror.net/docs/migration/
|
||
const pxPerChar = 8.5; | ||
const pxPerLine = 26; | ||
const defaultCharPerLine = 30; | ||
const maxLineHeight = 15 * pxPerLine; // 20 lines | ||
const minLineHeight = 4 * pxPerLine; // 4 lines | ||
|
||
const editable = new Compartment; // eslint-disable-line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason you define this here and not as a class variable?
canvas_modules/harness/package.json
Outdated
@@ -47,7 +47,7 @@ | |||
"carbon-components": "10.56.0", | |||
"carbon-components-react": "7.56.0", | |||
"carbon-icons": "7.0.7", | |||
"codemirror": "5.58.2", | |||
"codemirror": "6.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be removed now. This should come from common-canvas.
Signed-off-by: Neha Gokhale <[email protected]>
const somethingSelected = this.editor.viewState.state.selection.ranges.some((r) => !r.empty); | ||
let cursor = this.editor.viewState.state.selection.main.head; | ||
const somethingSelected = this.getCodemirrorState()?.selection.ranges.some((r) => !r.empty); | ||
let cursor = this.getCodemirrorState()?.selection.main.head; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't really help protect us. It would have to be this.getCodemirrorState()?.selection?.main?.head
Anything that has methods would have to change the object first, then call the method.
Is everything your using documented? If so, maybe we're safe to use it without optional chaining.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything after this.getCodemirrorState()?
is documented in migration guide and reference manual.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
Fixes: #1640
Release notes documentation -
Major version upgrade from
Codemirror 5.x
to Codemirror 6.x. This affects the code editor in Expression control.Gruntfile changes -
We're No longer exporting
lib/codemirror.css
andaddon/hint/show-hint.css
files.If your application is using following grunt config, please remove this grunt config.
Also remove following stylesheets from your application's index.js file -
CSS Changes -
Since we're no longer exporting
lib/codemirror.css
file, if you create a new Codemirror 6.x instance in your application, elyra-canvas codemirror CSS from this file will no longer be imported into your classnames. Please ensure all custom CSS overrides works fine in your application.Codemirror 6.x creates a rather different DOM structure for the editor. If you're writing custom CSS for the editor, you'll probably have to change it a bit. Class names roughly correspond like this:
Please make any other changes in class names as required after inspecting "Elements" tab in the browser.
Autocompletions -
Expression control supports following languages -
Autocompletions will start showing up as soon as you start typing in the code editor. They can also show up using
ctrl + space
key combination. Autocompletions will show language specific keywords, custom keywords specified here, and field names from the expression builder table.Jest tests failures -
If you notice several jest unit tests are failing with this error -
Please add this config in your
package.json
file to fix jest tests -Developer's Certificate of Origin 1.1