Skip to content
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

preserve ctrl-f for macOS for moving forward #759

Merged
merged 2 commits into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 3 additions & 12 deletions packages/graphiql/src/components/QueryEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { GraphQLSchema } from 'graphql';
import MD from 'markdown-it';
import { normalizeWhitespace } from '../utility/normalizeWhitespace';
import onHasCompletion from '../utility/onHasCompletion';
import commonKeys from '../utility/commonKeys';

const md = new MD();
const AUTO_COMPLETE_AFTER_KEY = /^[a-zA-Z0-9_@(]$/;
Expand Down Expand Up @@ -148,17 +149,7 @@ export class QueryEditor extends React.Component {
}
},

// Persistent search box in Query Editor
'Cmd-F': 'findPersistent',
'Ctrl-F': 'findPersistent',
'Cmd-G': 'findPersistent',
'Ctrl-G': 'findPersistent',

// Editor improvements
'Ctrl-Left': 'goSubwordLeft',
'Ctrl-Right': 'goSubwordRight',
'Alt-Left': 'goGroupLeft',
'Alt-Right': 'goGroupRight',
...commonKeys,
},
});

Expand Down Expand Up @@ -197,7 +188,7 @@ export class QueryEditor extends React.Component {
this.editor.off('change', this._onEdit);
this.editor.off('keyup', this._onKeyUp);
this.editor.off('hasCompletion', this._onHasCompletion);
this.editor = null;
this.editor = null;
}
}

Expand Down
15 changes: 2 additions & 13 deletions packages/graphiql/src/components/ResultViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import commonKeys from '../utility/commonKeys';

/**
* ResultViewer
Expand Down Expand Up @@ -86,19 +87,7 @@ export class ResultViewer extends React.Component {
},
gutters: ['CodeMirror-foldgutter'],
info: Boolean(this.props.ResultsTooltip || this.props.ImagePreview),
extraKeys: {
// Persistent search box in Query Editor
'Cmd-F': 'findPersistent',
'Ctrl-F': 'findPersistent',
'Cmd-G': 'findPersistent',
'Ctrl-G': 'findPersistent',

// Editor improvements
'Ctrl-Left': 'goSubwordLeft',
'Ctrl-Right': 'goSubwordRight',
'Alt-Left': 'goGroupLeft',
'Alt-Right': 'goGroupRight',
},
extraKeys: commonKeys,
});
}

Expand Down
13 changes: 2 additions & 11 deletions packages/graphiql/src/components/VariableEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import React from 'react';
import PropTypes from 'prop-types';

import onHasCompletion from '../utility/onHasCompletion';
import commonKeys from '../utility/commonKeys';

/**
* VariableEditor
Expand Down Expand Up @@ -132,17 +133,7 @@ export class VariableEditor extends React.Component {
}
},

// Persistent search box in Query Editor
'Cmd-F': 'findPersistent',
'Ctrl-F': 'findPersistent',
'Cmd-G': 'findPersistent',
'Ctrl-G': 'findPersistent',

// Editor improvements
'Ctrl-Left': 'goSubwordLeft',
'Ctrl-Right': 'goSubwordRight',
'Alt-Left': 'goGroupLeft',
'Alt-Right': 'goGroupRight',
...commonKeys,
},
});

Expand Down
16 changes: 16 additions & 0 deletions packages/graphiql/src/utility/commonKeys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const isMacOs = window.navigator.platform === 'MacIntel';

const commonKeys = {
// Persistent search box in Query Editor
[isMacOs ? 'Cmd-F' : 'Ctrl-F']: 'findPersistent',
'Cmd-G': 'findPersistent',
'Ctrl-G': 'findPersistent',

// Editor improvements
'Ctrl-Left': 'goSubwordLeft',
'Ctrl-Right': 'goSubwordRight',
'Alt-Left': 'goGroupLeft',
'Alt-Right': 'goGroupRight',
};

export default commonKeys;