🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

tq-ace-editor

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tq-ace-editor

基于ace editor二次封装

latest
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

安装

npm install tq-ace-editor
// or
yarn tq-ace-editor

使用

局部引用

<template>
  <Editor />
</template>
<script>
  import Editor from 'tq-ace-editor'
  export default {
    components: { Editor }
  }
</script>

全局引入

// main.js
import Editor from 'tq-ace-editor'
Vue.component('Editor',Editor)

示例

<template>
  <Editor
    height="80vh"
    width="100%"
    ref="editor"
    v-model="content"
    :options="aceOption"
    lang="sh"
    @init="editorInit"
    theme="tomorrow_night_bright"/>
</template>
<script>
  import Editor from 'tq-ace-editor'
  export default {
    data() {
      return {
        content: '',
        aceOption: {
          enableBasicAutocompletion: true,
          enableSnippets: true,
          enableLiveAutocompletion: true,
          tabSize: 6,
          fontSize: 14
        }
      }
    },
    components: { Editor },
    methods: {
      editorInit() {
        require('brace/ext/language_tools')
        require('brace/mode/sh')
        require('brace/theme/tomorrow_night_bright')
        require('brace/snippets/sh')
      }
    }
  }
</script>

hook

名称说明类型默认值
init编辑器初始化钩子,当初始化完成后触发fn-

属性

名称说明类型默认值
value编辑器内容String-
lang编辑器语言Stringtext
theme编辑器主题名Stringchrome
height编辑器高度String100%
width编辑器宽度String100%
options编辑器配置项Object{}

options 选项

editor选项

选项名值类型默认值可选值备注
selectionStyleStringtextline/text选中样式
highlightActiveLineBooleantrue-高亮当前行
highlightSelectedWordBooleantrue-高亮选中文本
readOnlyBooleanfalse-是否只读
cursorStyleStringaceace/slim/smooth/wide光标样式
mergeUndoDeltasString/Booleanfalsealways合并撤销
behavioursEnabledBooleantrue-启用行为
wrapBehavioursEnabledBooleantrue-启用换行
autoScrollEditorIntoViewBooleanfalse-启用滚动
copyWithEmptySelectionBooleantrue-复制空格
useSoftTabsBooleanfalse-使用软标签
navigateWithinSoftTabsBooleanfalse-软标签跳转
enableMultiselectBooleanfalse-选中多处

renderer选项

选项名值类型默认值可选值备注
hScrollBarAlwaysVisibleBooleanfalse-纵向滚动条始终可见
vScrollBarAlwaysVisibleBooleanfalse-横向滚动条始终可见
highlightGutterLineBooleantrue-高亮边线
animatedScrollBooleanfalse-滚动动画
showInvisiblesBooleanfalse-显示不可见字符
showPrintMarginBoolean true-显示打印边距
printMarginColumnNumber80-设置页边距
printMarginBoolean/Numberfalse-显示并设置页边距
fadeFoldWidgetsBooleanfalse-淡入折叠部件
showFoldWidgetsBooleantrue-显示折叠部件
showLineNumbersBooleantrue-显示行号
showGutterBooleantrue-显示行号区域
displayIndentGuidesBooleantrue-显示参考线
fontSizeNumber/Stringinherit-设置字号
fontFamilyStringinherit-设置字体
maxLinesNumber--至多行数
minLinesNumber--至少行数
scrollPastEndBoolean/Number0-滚动位置
fixedWidthGutterBooleanfalse-固定行号区域宽度
themeString--主题引用路径,例如"ace/theme/textmate"

mouseHandler选项

选项名值类型默认值可选值备注
scrollSpeedNumber--滚动速度
dragDelayNumber--拖拽延时
dragEnabledBooleantrue-是否启用拖动
focusTimoutNumber--聚焦超时
tooltipFollowsMouseBooleanfalse-鼠标提示

session选项

选项名值类型默认值可选值备注
firstLineNumberNumber1-起始行号
overwriteBoolean--重做
newLineModeStringautoauto/unix/windows新开行模式
useWorkerBoolean--使用辅助对象
useSoftTabsBoolean--使用软标签
tabSizeNumber--标签大小
wrapBoolean--换行
foldStyleString-markbegin/markbeginend/manual折叠样式
modeString--代码匹配模式,例如“ace/mode/text"

扩展选项

选项名值类型默认值可选值备注
enableBasicAutocompletionBoolean--启用基本自动完成
enableLiveAutocompletionBoolean--启用实时自动完成
enableSnippetsBoolean--启用代码段
enableEmmetBoolean--启用Emmet
useElasticTabstopsBoolean--使用弹性制表位

主题

使用主题的时候记得一定要先引主题再使用!require('brace/theme/主题名')

主题列表 * ambiance
* chaos
* chrome
* clouds
* clouds_midnight
* cobalt
* crimson_editor
* dawn
* dracula
* dreamweaver
* eclipse
* github
* gob
* gruvbox
* idle_fingers
* iplastic
* katzenmilch
* kr_theme
* kuroir
* merbivore
* merbivore_soft
* monokai
* mono_industrial
* pastel_on_dark
* solarized_dark
* solarized_light
* sqlserver
* terminal
* textmate
* tomorrow
* tomorrow_night
* tomorrow_night_blue
* tomorrow_night_bright
* tomorrow_night_eighties
* twilight
* vibrant_ink
* xcode

语言

使用主题的时候记得一定要先引主题再使用!require('brace/mode/语言名')

语言列表 * abap
* abc
* actionscript
* ada
* apache_conf
* applescript
* asciidoc
* assembly_x86
* autohotkey
* batchfile
* bro
* c9search
* cirru
* clojure
* cobol
* coffee
* coldfusion
* csharp
* csound_document
* csound_orchestra
* csound_score
* css
* curly
* c_cpp
* d
* dart
* diff
* django
* dockerfile
* dot
* drools
* eiffel
* ejs
* elixir
* elm
* erlang
* forth
* fortran
* ftl
* gcode
* gherkin
* gitignore
* glsl
* gobstones
* golang
* graphqlschema
* groovy
* haml
* handlebars
* haskell
* haskell_cabal
* haxe
* hjson
* html
* html_elixir
* html_ruby
* ini
* io
* jack
* jade
* java
* javascript
* json
* jsoniq
* jsp
* jssm
* jsx
* julia
* kotlin
* latex
* lean
* less
* liquid
* lisp
* livescript
* live_script
* logiql
* lsl
* lua
* luapage
* lucene
* makefile
* markdown
* mask
* matlab
* mavens_mate_log
* maze
* mel
* mipsassembler
* mips_assembler
* mushcode
* mysql
* nix
* nsis
* objectivec
* ocaml
* pascal
* perl
* pgsql
* php
* pig
* plain_text
* powershell
* praat
* prolog
* properties
* protobuf
* python
* r
* razor
* rdoc
* red
* rhtml
* rst
* ruby
* rust
* sass
* scad
* scala
* scheme
* scss
* sh
* sjs
* smarty
* snippets
* soy_template
* space
* sparql
* sql
* sqlserver
* stylus
* svg
* swift
* swig
* tcl
* test.
* tex
* text
* textile
* toml
* tsx
* turtle
* twig
* typescript
* vala
* vbscript
* velocity
* verilog
* vhdl
* wollok
* xml
* xquery
* yaml

其他

要使用语言或者主题时,记得都要require一下相关的文件才能使用!记得切换npm仓库为私有仓库不然无法下载这个包!

FAQs

Package last updated on 26 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts