Skip to content

Commit e936bc7

Browse files
authored
Merge pull request #79 from xsnippet/ace-search
Enable search through snippet when focus within code editor
2 parents 28c612f + 687ab42 commit e936bc7

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/components/NewSnippet.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ class NewSnippet extends React.Component {
3636
document.getElementsByClassName('new-snippet-lang-header')[0]
3737
.setAttribute('style', `height:${newSnippetHeaderHeight}px`);
3838
};
39+
this.onEditorLoad = (editor) => {
40+
// we want to disable built-in find in favor of browser's one
41+
editor.commands.removeCommand('find');
42+
};
3943
this.postSnippet = this.postSnippet.bind(this);
4044
this.onSyntaxClick = this.onSyntaxClick.bind(this);
4145
this.onInputChange = this.onInputChange.bind(this);
@@ -122,6 +126,7 @@ class NewSnippet extends React.Component {
122126
height="100%"
123127
focus
124128
theme="textmate"
129+
onLoad={this.onEditorLoad}
125130
setOptions={{
126131
showFoldWidgets: false,
127132
useWorker: false,

src/components/Snippet.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class Snippet extends React.Component {
2121
this.copyClipboard = (e) => {
2222
copyToClipboard(e, 'embedded');
2323
};
24+
this.onEditorLoad = (editor) => {
25+
// we want to disable built-in find in favor of browser's one
26+
editor.commands.removeCommand('find');
27+
};
2428
}
2529

2630
componentDidMount() {
@@ -96,6 +100,7 @@ class Snippet extends React.Component {
96100
width="100%"
97101
height="100%"
98102
theme="textmate"
103+
onLoad={this.onEditorLoad}
99104
setOptions={{
100105
readOnly: true,
101106
highlightActiveLine: false,

0 commit comments

Comments
 (0)