示例代码
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum=1.0,minimum=1.0,user-scalable=0" /> </head> <body> <div id="editor" style="width: 500px; height: 300px;"></div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/ace/ace.js"></script> <script> // 初始化编辑器 const editor = ace.edit("editor"); editor.setTheme("ace/theme/monokai"); editor.session.setMode("ace/mode/javascript"); // 示例代码 editor.setValue(`function hello() { console.log("Hello World"); } // 这是一条注释 const message = "Ace.js 选择示例";`); // 监听选择事件 editor.getSelection().on("changeSelection", () => { const range = editor.getSelectionRange(); // 开始行和结束行(转为人类可读的 1 基索引) const start = range.start.row + 1; const end = range.end.row + 1; console.log(`选中范围:第 ${start} 行 - 第 ${end} 行`); }); </script> </body> </html>
网友回复
如何在linux系统中同时能安装运行apk的安卓应用?
python有没有离线验证码识别ocr库?
各家的ai图生视频及文生视频的api价格谁最便宜?
openai、gemini、qwen3-vl、Doubao-Seed-1.6在ui截图视觉定位这款哪家更强更准?
如何在linux上创建一个沙箱隔离的目录让python使用?
pywebview如何使用浏览器自带语音识别与webspeech 的api?
pywebview如何禁用浏览器的右键菜单?
即梦ai的agent生成的儿童故事视频为啥没有配音与声音台词?
php子域名可获取主域名的session会话信息吗?
nginx如何支持php-fpm的流式请求openai api输出的设置?