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

feat(sql lab): enable ACE editor search in SQL editors #19328

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ class AceEditorWrapper extends React.PureComponent<Props, State> {
}

onEditorLoad(editor: any) {
editor.commands.removeCommand('find');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you get a chance to look at why they removed find command previously?

We may face side effect by adding it again?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The editor originally trapped the find command, but it wasn't working.
So, we removed it to offer basic search functionality using the browser.
This re-enables search within the editor with a plugin, which is far better at searching


editor.commands.addCommand({
name: 'runQuery',
bindKey: { win: 'Alt-enter', mac: 'Alt-enter' },
Expand Down
4 changes: 3 additions & 1 deletion superset-frontend/src/components/AsyncAceEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const aceModuleLoaders = {
'theme/textmate': () => import('brace/theme/textmate'),
'theme/github': () => import('brace/theme/github'),
'ext/language_tools': () => import('brace/ext/language_tools'),
'ext/searchbox': () => import('brace/ext/searchbox'),
};

export type AceModule = keyof typeof aceModuleLoaders;
Expand Down Expand Up @@ -164,10 +165,11 @@ export const SQLEditor = AsyncAceEditor([
'mode/sql',
'theme/github',
'ext/language_tools',
'ext/searchbox',
]);

export const FullSQLEditor = AsyncAceEditor(
['mode/sql', 'theme/github', 'ext/language_tools'],
['mode/sql', 'theme/github', 'ext/language_tools', 'ext/searchbox'],
{
// a custom placeholder in SQL lab for less jumpy re-renders
placeholder: () => {
Expand Down
1 change: 1 addition & 0 deletions superset-frontend/src/types/brace.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ declare module 'brace/mode/javascript';
declare module 'brace/theme/textmate';
declare module 'brace/theme/github';
declare module 'brace/ext/language_tools';
declare module 'brace/ext/searchbox';