Skip to content

Options ​

fei-editor 配置项列表说明

editor选项 ​

选项名类型默认值可选值备注
selectionStylestring"line""line", "text"选择样式
highlightActiveLinebooleantruetrue, false高亮当前行
highlightSelectedWordbooleantruetrue, false高亮选中单词
readOnlybooleanfalsetrue, false只读模式
cursorStylestring"ace""ace", "slim", "smooth", "wide"光标样式
mergeUndoDeltasbooleantruetrue, false合并撤销操作
behavioursEnabledbooleantruetrue, false启用行为
wrapBehavioursEnabledbooleantruetrue, false启用换行行为
autoScrollEditorIntoViewbooleanfalsetrue, false自动滚动到视图
keyboardHandlerstringnullnull, "vim", "emacs"键盘处理器
placeholderstringnullstring占位符文本

renderer选项 ​

选项名类型默认值可选值备注
classNamestring"ace_editor"stringCSS类名
themestring"ace/theme/textmate"string主题
modestring"ace/mode/text"string模式
fontSizenumber12number字体大小
fontFamilystring"Monaco, Menlo, 'Ubuntu Mono', monospace"string字体族
maxLinesnumberInfinitynumber最大行数
minLinesnumber1number最小行数
showLineNumbersbooleantruetrue, false显示行号
showGutterbooleantruetrue, false显示行号栏
showPrintMarginbooleantruetrue, false显示打印边距
printMarginColumnnumber80number打印边距列数
printMarginbooleantruetrue, false打印边距
fadeFoldWidgetsbooleanfalsetrue, false淡出折叠小部件
showFoldWidgetsbooleantruetrue, false显示折叠小部件
showInvisiblesbooleanfalsetrue, false显示不可见字符
displayIndentGuidesbooleantruetrue, false显示缩进指南
highlightGutterLinebooleantruetrue, false高亮行号栏行
animatedScrollbooleanfalsetrue, false动画滚动
maxPixelHeightnumber0number最大像素高度
scrollPastEndbooleanfalsetrue, false滚动超过末尾
fixedWidthGutterbooleanfalsetrue, false固定宽度行号栏
wrapbooleanfalsetrue, false自动换行
wrapMethodstring"auto""auto", "code", "text"换行方法
indentedSoftWrapbooleantruetrue, false缩进软换行
hScrollBarAlwaysVisiblebooleanfalsetrue, false水平滚动条始终可见
vScrollBarAlwaysVisiblebooleanfalsetrue, false垂直滚动条始终可见
fontLigaturesbooleanfalsetrue, false字体连字
mouseWheelScrollSpeednumber1number鼠标滚轮滚动速度
dragDelaynumber0number拖拽延迟
dragEnabledbooleantruetrue, false启用拖拽
focusTimoutnumber0number焦点超时
tooltipFollowsMousebooleanfalsetrue, false工具提示跟随鼠标
firstLineNumbernumber1number第一行行号
overwritebooleanfalsetrue, false覆盖模式
newLineModestring"auto""auto", "unix", "windows"换行模式
useWorkerbooleantruetrue, false使用Web Worker
useSoftTabsbooleantruetrue, false使用软制表符
tabSizenumber4number制表符大小
wrapModebooleanfalsetrue, false换行模式
foldStylestring"markbegin""markbegin", "markbeginend", "manual"折叠样式
pathstring""string路径
relativeLineNumbersbooleanfalsetrue, false相对行号

mouseHandler选项 ​

选项名类型默认值可选值备注
dragDelaynumber0number拖拽延迟
dragEnabledbooleantruetrue, false启用拖拽
focusTimoutnumber0number焦点超时
tooltipFollowsMousebooleanfalsetrue, false工具提示跟随鼠标

session选项 ​

选项名类型默认值可选值备注
firstLineNumbernumber1number第一行行号
overwritebooleanfalsetrue, false覆盖模式
newLineModestring"auto""auto", "unix", "windows"换行模式
useWorkerbooleantruetrue, false使用Web Worker
useSoftTabsbooleantruetrue, false使用软制表符
tabSizenumber4number制表符大小
wrapModebooleanfalsetrue, false换行模式
foldStylestring"markbegin""markbegin", "markbeginend", "manual"折叠样式
pathstring""string路径
relativeLineNumbersbooleanfalsetrue, false相对行号

扩展选项 ​

代码补全 ​

javascript
{
  enableBasicAutocompletion: true,    // 启用基本自动补全
  enableSnippets: true,               // 启用代码片段
  enableLiveAutocompletion: true,     // 启用实时自动补全
  enableEmmet: true,                  // 启用Emmet
  completers: []                      // 自定义补全器
}

搜索和替换 ​

javascript
{
  wrap: true,                         // 循环搜索
  caseSensitive: false,               // 区分大小写
  wholeWord: false,                   // 全词匹配
  regExp: false,                      // 正则表达式
  skipCurrent: false                  // 跳过当前匹配
}

键盘快捷键 ​

javascript
{
  keyboardHandler: "ace/keyboard/vim", // Vim模式
  // 或
  keyboardHandler: "ace/keyboard/emacs" // Emacs模式
}

自定义主题 ​

javascript
{
  theme: "ace/theme/monokai",         // 主题路径
  // 或自定义主题
  theme: {
    name: "custom",
    styles: {
      ".ace_editor": {
        "background-color": "#1e1e1e",
        "color": "#d4d4d4"
      }
    }
  }
}

使用示例 ​

vue
<template>
  <fei-editor
    v-model="code"
    :options="editorOptions"
    @init="onEditorInit"
  />
</template>

<script setup>
import { ref } from 'vue'

const code = ref('console.log("Hello World!")')

const editorOptions = ref({
  // 编辑器选项
  selectionStyle: "line",
  highlightActiveLine: true,
  readOnly: false,
  cursorStyle: "ace",
  
  // 渲染器选项
  fontSize: 14,
  fontFamily: "Monaco, Menlo, 'Ubuntu Mono', monospace",
  showLineNumbers: true,
  showGutter: true,
  showPrintMargin: false,
  wrap: true,
  
  // 会话选项
  tabSize: 2,
  useSoftTabs: true,
  useWorker: true,
  
  // 扩展选项
  enableBasicAutocompletion: true,
  enableSnippets: true,
  enableLiveAutocompletion: true
})

const onEditorInit = (editor) => {
  console.log('Editor initialized with options:', editorOptions.value)
}
</script>

基于 MIT 许可发布