🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis
Socket
Book a DemoInstallSign in
Socket

@dsyx/custom-syntax-editor

Package Overview
Dependencies
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dsyx/custom-syntax-editor

react自定义语法编辑器

latest
npmnpm
Version
1.0.5
Version published
Maintainers
4
Created
Source

@dsyx/custom-syntax-editor

React自定义语法编辑器

Usage

安装

npm install @dsyx/custom-syntax-editor

使用

import CustomEditor from "@dsyx/custom-syntax-editor";

const keywords = [
	// groovy 关键词
	"as", "catch", "def", "enum", "for", "import", "new", "super", "throws", "while",
	"assert", "class", "default", "extends", "goto", "in", "null", "switch", "trait", "break",
	"const", "do", "false", "if", "instanceof", "package", "this", "true", "case", "continue", "else",
	"finally", "implements", "interface", "return", "throw", "try",
	// java 关键词
	"abstract", "transient", "int", "strictfp", "synchronized", "boolean", "char", "do",
	"final", "private", "short", "void", "double", "long", "protected", "static", "volatile",
	"byte", "float", "native", "public",
	// JDK 常用类
	"System", "Runtime", "String", "StringBuffer", "StringBuilder", "Date", "DateFormat",
	"SimpleDateFormat", "Calendar", "GregorianGalendar", "Math", "Integer", "Double", "Float",
	"Boolean", "List", "HashMap", "Map", "ArrayList", "Arrays", "Random", "Iterator"
];

const Demo = props => {
	
	const getCode = (code) => {
		console.log(code);
	};

    return (
       <CustomEditor
			defaultCode="" // 默认""
			readOnly={false} // 默认false
			height="400px" // 默认300px
			theme="night" // 默认day
			activeLine={true} // 默认true
			fold={true} // 默认true
			keywords={keywords} // 默认[]
			onChange={getCode}
		/>
    )
};

ReactDOM.render(
    <Demo />,
    document.getElementById('root')
);

编辑器效果

Image text

props参数:

参数类型默认值是否必填说明
defaultCodestring""非必填初始化赋值
readOnlybooleanfalse非必填设置只读
heightnumber300非必填编辑器高度
themestring"day"非必填主题:"day"和"night"
activeLinebooleantrue非必填当前行选中标识
indentUnitnumber4非必填tab按几个空格缩进
foldbooleantrue非必填代码折叠
keywordsarray[]非必填自定义提示关键词
onChangefunction非必填返回code
Ctrl+F键盘事件-内置自动格式化代码

Keywords

dsyx

FAQs

Package last updated on 18 Nov 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