Hello stackOverflow community, this is my first question here and I'm wondering how to enable the Search Box in an Ace Editor.
I have a current demo of the project here. So far the editor has Emmet and Autocomplete. The next feature I need is the search box showing when the user presses CTRL+F in the editor.
Here is the code I used to configure the editor:
let e = document.querySelector("#editor");
let editor = ace.edit(e);
let langTools = ace.require("ace/ext/language_tools");
let Emmet = require("ace/ext/emmet");
ace.config.set("basePath", "path");
ace.config.loadModule("ace/ext/searchbox", function(m) {m.Search(editor)});
editor.getSession().setMode("ace/mode/html");
editor.setOptions({
minLines: 24,
maxLines: 24,
enableBasicAutocompletion: true,
enableSnippets: true,
enableLiveAutocompletion: true,
enableEmmet: true
});
editor.session.setUseWrapMode(true);
editor.session.on("change", function () {
window.onbeforeunload = function () {
return "Changes you made might not be saved";
};
var unloadListener = function () {
return "Changes you made might not be saved";
};
window.addEventListener("beforeunload", unloadListener);
editor.execCommand("find")
});
Can someone please help me to figure out what scripts to import and how to enable it? Thanks.
ace.config.set("basePath", "path");
is probably a mistake ext-searchbox.js file is located at /path/ext-searchbox.js on your site