Files
FOF-ACE-Editor/js/Ace.js
2025-08-16 16:14:03 +08:00

70 lines
2.5 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* @Author: Qiang 1841747216@qq.com
* @Date: 2025-08-12 11:20:26
* @LastEditors: Qiang 1841747216@qq.com
* @LastEditTime: 2025-08-14 17:35:58
* @FilePath: \编辑器\AceEditor\js\Ace.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
define(['ace/ace', 'ace/mode-css', 'ace/mode-javascript', 'ace/ext-language_tools'], function () {
EditSession = ace.require("ace/edit_session").EditSession;
UndoManager = ace.require("ace/undomanager").UndoManager;
let languageTools = ace.require("ace/ext/language_tools");
let snippetManager = SnippetManager = ace.require("ace/snippets").snippetManager;
let WorkerClient = ace.require("ace/worker/worker_client").WorkerClient;
Range = ace.require("ace/range").Range;
Renderer = ace.require("ace/virtual_renderer").VirtualRenderer;
// 初始化编辑器Ace
EDITOR = ace.edit("editor", {
mode: "ace/mode/javascript",
// mode: "ace/mode/html",
theme: "ace/theme/monokai",
selectionStyle: "css",
useSoftTabs: true,
navigateWithinSoftTabs: true,
enableMultiselect: true,
animatedScroll: true,
//光标样式
cursorStyle: "slim",
//启用实时自动完成功能 (比如:智能代码提示)
enableBasicAutocompletion: true,
enableSnippets: true,
enableLiveAutocompletion: true,
//Emmet插件提示器
enableEmmet: true,
nableSnippets: true,
// 设置编辑器下方显示空白
scrollPastEnd: 0.25
});
window.editorObj = EDITOR;
EDITOR.setHighlightActiveLine(true);
EDITOR.setShowPrintMargin(false);
// 设置tab间距
EDITOR.getSession().setTabSize(4);
// 自动换行
EDITOR.getSession().setUseWrapMode(true);
// 换行
EDITOR.setOption("setUseWrapMode ", "true")
// 监听编辑器失去焦点事件
EDITOR.on("blur", function () {
// console.log("编辑器失去了焦点");
// window.parent.editorMain.gui.designPanel.ActiveTabType = "designFocus";
});
// 如果你想监听获得焦点的事件也可以加上 focus
EDITOR.on("focus", function () {
//console.log("编辑器获得了焦点");
// window.parent.editorMain.gui.designPanel.ActiveTabType = "editorCodeFocus";
// window.parent.editorMain.gui.designPanel.ActiveTabElementID = window.parentElementID;
// window.parent.editorMain.gui.designPanel.ActiveTab = window;
});
window.editorObj.focus();//主动获得焦点
// 监听窗口大小变化事件
window.addEventListener("resize", (event) => {
});
// window.iniAceEditorFun()
return {
}
})