@tntd/codemirror

0.0.5 • Public • Published

tntd codemirror组件

安装

$ npm install @tntd/codemirror --save

使用

import CodeMirror from "@tntd/codemirror";

// 导入对应的主题和mode文件
import 'codemirror/theme/3024-day.css';
import 'codemirror/mode/javascript/javascript.js';

<CodeMirror
	mode='javascript'
	theme='night'
	value="789"
	onChange={(value) => {
		console.log(value)
	}}
	lineNumbers={true}
	placeholder="请输入你的内容"
/>

API

参数 说明 类型 默认值 是否必须
mode 当前语言模式 string
theme 主题 String,预置了day、night day
value 内容 string
autofocus 自动聚焦 boolean true
tabSize 缩进 int 4
height 编辑器高度 int 300
placeholder 内容 string 请输入...
readOnly 是否只读 boolean false
lineNumbers 是否显示行数字 boolean true
firstLineNumber 是否显示行数字 int 1
indentWithTabs - boolean true
smartIndent - boolean true

回调事件

参数 说明 类型 默认值 是否必须
onChange 内容变化时的回调 function(text)
onBlur 时区焦点时的回调 function
onScroll 滚动回调 function
onRefresh 刷新回调 function
onKeydown 按键回调 function
onKeypress 按键回调 function
onKeyup 按键回调 function
onCut 剪切回调 function
onCopy 复制回调 function
onPaste 粘贴回调 function
onDblClick 双击回调 function

Dependents (0)

Package Sidebar

Install

npm i @tntd/codemirror

Weekly Downloads

0

Version

0.0.5

License

MIT

Unpacked Size

11.2 kB

Total Files

5

Last publish

Collaborators

  • kobingogo
  • mcfly001
  • z337198954
  • td-tnt
  • bruceliu68
  • bernardzhang
  • mizy
  • zhouzefei
  • xiaofei.wang
  • anthonyli
  • popoqaq
  • ezios