Skip to content

Commit 0f8ac70

Browse files
authored
Merge pull request #4006 from processing/cm6-color-picker-import
[codemirror6] Fix color picker to work in Javascript
2 parents 5129e12 + fcc47fd commit 0f8ac70

File tree

3 files changed

+56
-79
lines changed

3 files changed

+56
-79
lines changed

client/modules/IDE/components/Editor/stateUtils.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import {
3737
indentLess
3838
} from '@codemirror/commands';
3939
import { lintGutter } from '@codemirror/lint';
40-
import { color as colorPicker } from '@uiw/codemirror-extensions-color';
4140
import {
4241
expandAbbreviation,
4342
abbreviationTracker
@@ -52,6 +51,7 @@ import { JSHINT } from 'jshint';
5251
import { HTMLHint } from 'htmlhint';
5352
import { CSSLint } from 'csslint';
5453
import { emmetConfig } from '@emmetio/codemirror6-plugin';
54+
import { color as colorPicker } from '@connieye/codemirror-color-picker';
5555

5656
import p5JavaScript from './p5JavaScript';
5757
import { tidyCodeWithPrettier } from './tidier';
@@ -336,13 +336,19 @@ export function createNewFileState(filename, document, settings) {
336336
// Misc extensions
337337
indentOnInput(),
338338
bracketMatching(),
339-
colorPicker,
340339
errorDecorationStateField,
341340

342341
// Setup the event listeners on the CodeMirror instance.
343342
EditorView.updateListener.of(onViewUpdate)
344343
];
345344

345+
// Only enable the color picker for Javascript and CSS, which
346+
// have both been tested.
347+
const fileMode = getFileMode(filename);
348+
if (fileMode === 'javascript' || fileMode === 'css') {
349+
extensions.push(colorPicker);
350+
}
351+
346352
const fileLanguage = getFileLanguage(filename);
347353
const fileLinter = getFileLinter(filename, onUpdateLinting);
348354
const fileEmmetConfig = getFileEmmetConfig(filename);

package-lock.json

Lines changed: 46 additions & 75 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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@
229229
"@codemirror/lint": "^6.8.5",
230230
"@codemirror/search": "^6.5.11",
231231
"@codemirror/state": "^6.5.2",
232-
"@codemirror/view": "^6.36.5",
232+
"@codemirror/view": "^6.40.0",
233+
"@connieye/codemirror-color-picker": "^1.0.3",
233234
"@emmetio/codemirror-plugin": "^1.2.4",
234235
"@emmetio/codemirror6-plugin": "^0.4.0",
235236
"@gatsbyjs/webpack-hot-middleware": "^2.25.3",
@@ -240,7 +241,6 @@
240241
"@redux-devtools/log-monitor": "^4.0.2",
241242
"@reduxjs/toolkit": "^1.9.3",
242243
"@types/express": "^5.0.3",
243-
"@uiw/codemirror-extensions-color": "^4.23.12",
244244
"acorn": "^8.14.1",
245245
"acorn-walk": "^8.3.4",
246246
"async": "^3.2.3",

0 commit comments

Comments
 (0)