Skip to content

Commit 1f21a9b

Browse files
authored
Merge pull request #1907 from ameybhavsar24/fix-#1867
Fixes #1867 - Color picker feature
2 parents 740a171 + 6ecef5c commit 1f21a9b

File tree

8 files changed

+3849
-3189
lines changed

8 files changed

+3849
-3189
lines changed

client/modules/IDE/components/Editor.jsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import 'codemirror/addon/search/jump-to-line';
2929
import 'codemirror/addon/edit/matchbrackets';
3030
import 'codemirror/addon/edit/closebrackets';
3131
import 'codemirror/addon/selection/mark-selection';
32+
import 'codemirror-colorpicker';
3233

3334
import { JSHINT } from 'jshint';
3435
import { CSSLint } from 'csslint';
@@ -124,6 +125,10 @@ class Editor extends React.Component {
124125
'-W041': false,
125126
esversion: 7
126127
}
128+
},
129+
colorpicker: {
130+
type: 'sketch',
131+
mode: 'edit'
127132
}
128133
});
129134

@@ -149,7 +154,12 @@ class Editor extends React.Component {
149154
[`${metaKey}-F`]: 'findPersistent',
150155
[`${metaKey}-G`]: 'findPersistentNext',
151156
[`Shift-${metaKey}-G`]: 'findPersistentPrev',
152-
[replaceCommand]: 'replace'
157+
[replaceCommand]: 'replace',
158+
// Cassie Tarakajian: If you don't set a default color, then when you
159+
// choose a color, it deletes characters inline. This is a
160+
// hack to prevent that.
161+
[`${metaKey}-K`]: (cm, event) =>
162+
cm.state.colorpicker.popup_color_picker({ length: 0 })
153163
});
154164

155165
this.initializeDocuments(this.props.files);

client/modules/IDE/components/KeyboardShortcutModal.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ function KeyboardShortcutModal() {
6161
<span className="keyboard-shortcut__command">{metaKeyName} + /</span>
6262
<span>{t('KeyboardShortcuts.CodeEditing.CommentLine')}</span>
6363
</li>
64+
<li className="keyboard-shortcut-item">
65+
<span className="keyboard-shortcut__command">{metaKeyName} + K</span>
66+
<span>{t('KeyboardShortcuts.CodeEditing.ColorPicker')}</span>
67+
</li>
6468
</ul>
6569
<h3 className="keyboard-shortcuts__title">General</h3>
6670
<ul className="keyboard-shortcuts__list">

client/modules/IDE/components/Toolbar.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class Toolbar extends React.Component {
135135
onClick={() => {
136136
if (canEditProjectName) {
137137
this.props.showEditProjectName();
138-
setTimeout(() => this.projectNameInput.focus(), 0);
138+
setTimeout(() => this.projectNameInput.focus(), 100);
139139
}
140140
}}
141141
disabled={!canEditProjectName}

client/modules/IDE/components/Toolbar.unit.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('<ToolbarComponent />', () => {
5353
await waitFor(() => expect(props.showEditProjectName).toHaveBeenCalled());
5454
});
5555

56-
it('non-owner can\t switch to sketch editing mode', async () => {
56+
it("non-owner can't switch to sketch editing mode", async () => {
5757
const props = renderComponent({ currentUser: 'not-me' });
5858
const sketchName = screen.getByLabelText('Edit sketch name');
5959

client/styles/main.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
@import 'node_modules/codemirror/lib/codemirror';
1010
@import 'node_modules/codemirror/addon/lint/lint';
11+
@import 'node_modules/codemirror-colorpicker/addon/codemirror-colorpicker';
1112
@import 'node_modules/dropzone/dist/dropzone';
1213
@import 'node_modules/primer-tooltips/build/build';
1314

0 commit comments

Comments
 (0)