Skip to content

Add replace #1552

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

Merged
merged 34 commits into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9f4e1ad
Implemented replace functionality
SundeepChand Aug 6, 2020
e402d07
Implemented replace & replace all feature
SundeepChand Aug 6, 2020
52e6461
Fixed styling of keyboard shortcuts overlay
SundeepChand Aug 7, 2020
ad7975b
Updated test snapshot
SundeepChand Aug 16, 2020
feb4b9e
Modified replace feature, bug fixes needed
SundeepChand Aug 28, 2020
328616f
Fixed bug in replace using regexp
SundeepChand Sep 1, 2020
aeea0c3
Added a separate replace all button
SundeepChand Sep 1, 2020
eda8ca3
Removed Replace All from Edit menu
SundeepChand Sep 1, 2020
8f90bf2
Updated find & replace popup layout
SundeepChand Sep 9, 2020
4ad52d3
Modified find popup design
SundeepChand Sep 15, 2020
dc356b2
Added text-highlighting in replace
SundeepChand Sep 17, 2020
62c788c
[#1519] Minor styling changes
catarak Sep 18, 2020
e89f2ef
Improved replace UX
SundeepChand Sep 26, 2020
741fdaa
Removed redundant code
SundeepChand Sep 26, 2020
f5f1c1b
Removed more redundant files
SundeepChand Sep 26, 2020
1812c2b
Added translations to codemirror-search
SundeepChand Oct 7, 2020
4813f88
Minor fix
SundeepChand Oct 7, 2020
d65b432
Updated spanish keys
SundeepChand Oct 8, 2020
f0737cd
Merge branch 'develop' into add-replace
catarak Oct 26, 2020
6addf4b
[#1519] highlight find matches when focused on search
catarak Oct 30, 2020
d350090
[#1519] Update replace UX to match VSC
catarak Oct 30, 2020
ba3f388
bugfix: show replace-field when replace is clicked
SundeepChand Oct 31, 2020
cd734d6
Fixed case-insensitive button functionaliy & Removed merge conflict
SundeepChand Oct 31, 2020
6349f51
Merge branch 'develop' into add-replace
SundeepChand Oct 31, 2020
41c65db
Changed parseQuery to the older version
SundeepChand Nov 2, 2020
fca364f
Minor bug-fix
SundeepChand Nov 2, 2020
376f8f7
[#1519] Updating icons for search with theming
catarak Nov 2, 2020
379973e
Minor bug fix in No result text
SundeepChand Nov 3, 2020
8e8dcf9
Minor styling changes in high-contrast mode
SundeepChand Nov 3, 2020
10ee0af
[#1519] Update selection highlight colors
catarak Nov 5, 2020
1756620
[#1519] Update replace keyboard shortcut to match VSC
catarak Nov 5, 2020
900028c
[#1519] Update replace keyboard shortcut in Nav
catarak Nov 5, 2020
0761e6d
[#1519] Update Nav snapshot
catarak Nov 5, 2020
f0783d6
[#1519] Update pixel measurements to rems
catarak Nov 6, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion client/components/Nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { setAllAccessibleOutput, setLanguage } from '../modules/IDE/actions/pref
import { logoutUser } from '../modules/User/actions';

import getConfig from '../utils/getConfig';
import { metaKeyName, } from '../utils/metaKey';
import { metaKeyName, metaKey } from '../utils/metaKey';
import { getIsUserOwner } from '../modules/IDE/selectors/users';

import CaretLeftIcon from '../images/left-arrow.svg';
Expand Down Expand Up @@ -42,6 +42,7 @@ class Nav extends React.PureComponent {
this.handleFindNext = this.handleFindNext.bind(this);
this.handleRun = this.handleRun.bind(this);
this.handleFindPrevious = this.handleFindPrevious.bind(this);
this.handleReplace = this.handleReplace.bind(this);
this.handleStop = this.handleStop.bind(this);
this.handleStartAccessible = this.handleStartAccessible.bind(this);
this.handleStopAccessible = this.handleStopAccessible.bind(this);
Expand Down Expand Up @@ -134,6 +135,11 @@ class Nav extends React.PureComponent {
this.setDropdown('none');
}

handleReplace() {
this.props.cmController.showReplace();
this.setDropdown('none');
}

handleAddFile() {
this.props.newFile(this.props.rootFile.id);
this.setDropdown('none');
Expand Down Expand Up @@ -251,6 +257,7 @@ class Nav extends React.PureComponent {
}

renderProjectMenu(navDropdownState) {
const replaceCommand = metaKey === 'Ctrl' ? `${metaKeyName}+H` : `${metaKeyName}+⌥+F`;
return (
<ul className="nav__items-left">
<li className="nav__item-logo">
Expand Down Expand Up @@ -416,6 +423,16 @@ class Nav extends React.PureComponent {
<span className="nav__keyboard-shortcut">{'\u21E7'}+{metaKeyName}+G</span>
</button>
</li>
<li className="nav__dropdown-item">
<button
onClick={this.handleReplace}
onFocus={this.handleFocusForEdit}
onBlur={this.handleBlur}
>
{this.props.t('Nav.Edit.Replace')}
<span className="nav__keyboard-shortcut">{replaceCommand}</span>
</button>
</li>
</ul>
</li>
<li className={navDropdownState.sketch}>
Expand Down Expand Up @@ -777,6 +794,7 @@ Nav.propTypes = {
showFind: PropTypes.func,
findNext: PropTypes.func,
findPrev: PropTypes.func,
showReplace: PropTypes.func,
getContent: PropTypes.func
}),
startSketch: PropTypes.func.isRequired,
Expand Down
3 changes: 2 additions & 1 deletion client/components/__test__/Nav.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ describe('Nav', () => {
tidyCode: jest.fn(),
showFind: jest.fn(),
findNext: jest.fn(),
findPrev: jest.fn()
findPrev: jest.fn(),
showReplace: jest.fn(),
},
startSketch: jest.fn(),
stopSketch: jest.fn(),
Expand Down
11 changes: 11 additions & 0 deletions client/components/__test__/__snapshots__/Nav.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ exports[`Nav renders correctly 1`] = `
</span>
</button>
</li>
<li
class="nav__dropdown-item"
>
<button>
<span
class="nav__keyboard-shortcut"
>
⌃+H
</span>
</button>
</li>
</ul>
</li>
<li
Expand Down
14 changes: 11 additions & 3 deletions client/modules/IDE/components/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import 'codemirror/addon/search/match-highlighter';
import 'codemirror/addon/search/jump-to-line';
import 'codemirror/addon/edit/matchbrackets';
import 'codemirror/addon/edit/closebrackets';
import 'codemirror/addon/selection/mark-selection';

import { JSHINT } from 'jshint';
import { CSSLint } from 'csslint';
Expand All @@ -37,7 +38,7 @@ import Timer from '../components/Timer';
import EditorAccessibility from '../components/EditorAccessibility';
import { metaKey, } from '../../../utils/metaKey';

import search from '../../../utils/codemirror-search';
import '../../../utils/codemirror-search';

import beepUrl from '../../../sounds/audioAlert.mp3';
import UnsavedChangesDotIcon from '../../../images/unsaved-changes-dot.svg';
Expand All @@ -55,8 +56,6 @@ import * as UserActions from '../../User/actions';
import * as ToastActions from '../actions/toast';
import * as ConsoleActions from '../actions/console';

search(CodeMirror);

const beautifyCSS = beautifyJS.css;
const beautifyHTML = beautifyJS.html;

Expand Down Expand Up @@ -86,6 +85,7 @@ class Editor extends React.Component {
this.showFind = this.showFind.bind(this);
this.findNext = this.findNext.bind(this);
this.findPrev = this.findPrev.bind(this);
this.showReplace = this.showReplace.bind(this);
this.getContent = this.getContent.bind(this);
}

Expand All @@ -106,6 +106,7 @@ class Editor extends React.Component {
highlightSelectionMatches: true, // highlight current search match
matchBrackets: true,
autoCloseBrackets: this.props.autocloseBracketsQuotes,
styleSelectedText: true,
lint: {
onUpdateLinting: ((annotations) => {
this.props.hideRuntimeErrorWarning();
Expand All @@ -122,6 +123,7 @@ class Editor extends React.Component {

delete this._cm.options.lint.options.errors;

const replaceCommand = metaKey === 'Ctrl' ? `${metaKey}-H` : `${metaKey}-Option-F`;
this._cm.setOption('extraKeys', {
Tab: (cm) => {
// might need to specify and indent more?
Expand All @@ -137,6 +139,7 @@ class Editor extends React.Component {
[`${metaKey}-F`]: 'findPersistent',
[`${metaKey}-G`]: 'findNext',
[`Shift-${metaKey}-G`]: 'findPrev',
replaceCommand: 'replace',
});

this.initializeDocuments(this.props.files);
Expand Down Expand Up @@ -170,6 +173,7 @@ class Editor extends React.Component {
showFind: this.showFind,
findNext: this.findNext,
findPrev: this.findPrev,
showReplace: this.showReplace,
getContent: this.getContent
});
}
Expand Down Expand Up @@ -283,6 +287,10 @@ class Editor extends React.Component {
this._cm.execCommand('findPersistent');
}

showReplace() {
this._cm.execCommand('replace');
}

tidyCode() {
const beautifyOptions = {
indent_size: INDENTATION_AMOUNT,
Expand Down
9 changes: 8 additions & 1 deletion client/modules/IDE/components/KeyboardShortcutModal.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { metaKeyName, } from '../../../utils/metaKey';
import { metaKeyName, metaKey } from '../../../utils/metaKey';

function KeyboardShortcutModal() {
const { t } = useTranslation();
const replaceCommand = metaKey === 'Ctrl' ? `${metaKeyName} + H` : `${metaKeyName} + ⌥ + F`;
return (
<div className="keyboard-shortcuts">
<h3 className="keyboard-shortcuts__title">{t('KeyboardShortcuts.CodeEditing.CodeEditing')}</h3>
Expand Down Expand Up @@ -33,6 +34,12 @@ function KeyboardShortcutModal() {
</span>
<span>{t('KeyboardShortcuts.CodeEditing.FindPreviousTextMatch')}</span>
</li>
<li className="keyboard-shortcut-item">
<span className="keyboard-shortcut__command">
{replaceCommand}
</span>
<span>{t('KeyboardShortcuts.CodeEditing.ReplaceTextMatch')}</span>
</li>
<li className="keyboard-shortcut-item">
<span className="keyboard-shortcut__command">
{metaKeyName} + [
Expand Down
6 changes: 6 additions & 0 deletions client/styles/abstracts/_placeholders.scss
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,15 @@
text-decoration: none;
color: getThemifyVariable('inactive-text-color');
cursor: pointer;
& g, & path {
fill: getThemifyVariable('inactive-text-color');
}
&:hover {
text-decoration: none;
color: getThemifyVariable('heavy-text-color');
& g, & path {
fill: getThemifyVariable('heavy-text-color');
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions client/styles/abstracts/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ $base-font-size: 12;

//colors
$p5js-pink: #ed225d;
$p5js-pink-opacity: #ed225d80;
$processing-blue: #007BBB;
$p5js-active-pink: #f10046;
$white: #fff;
Expand Down
Loading