Giter Club home page Giter Club logo

bp-script-editor's Introduction

组件使用文档

  1. 安装依赖
npm i @byteplan/bp-script-editor 
yarn add @byteplan/bp-script-editor 
pnpm i @byteplan/bp-script-editor 
  1. 代码示例
import Editor from '@byteplan/bp-script-editor';

<Editor
  completions={completions}
  onValueChange={onValueChange}
  keywords={keywordsConfig.keywords}
  keywordsColor={keywordsConfig.color}
  placeholderThemes={placeholderThemes}
  functions={localFunctions}
  ref={editorRef}
  height="calc(100vh - 48px)"
  mode={mode}
  defaultValue="hello world"
  hintPaths={hintPaths}
/>
  1. 属性说明
属性 说明 数据格式
completions 自动补全定义的数据 CompletionsType[]
keywords 关键字 string[]
keywordsColor 关键字颜色 支持#ffffff或white格式 string
keywordsClassName 关键字类名 string
height 高度 string
width 宽度 string
placeholderThemes 占位符类型主题 PlaceholderThemesType
defaultValue 默认值 string
functions 函数 CompletionsType[]
mode 模式 code | name
hintPaths 代码提示 [HintPathType]
onValueChange 值改变的回调 (value: string) => void
  1. 方法
名称 说明 参数
insertText 插入文本 (text, isTemplate) => void,有类似${}这样的占位符,需要把isTemplate设置为true
clearText 清空文本 () => void
setText 设置文本 (text) => void,会把编辑器的内容使用text替换掉

CompletionsType

   template: string; // 自动插入时补全的文本
   label: string;    // 要匹配的文本
   detail: string;   // 描述
   type: string;     // 类型

PlaceholderThemesType

   [K: string]: CommonPlaceholderTheme;

CommonPlaceholderTheme

    textColor: string;
    backgroudColor: string;
    borderColor: string;

CompletionsType

    template: string;
    label: string;
    detail: string;
    type: string;

HintPathType

    label: string;
    detail: string;
    type: 'function' | 'keyword' | 'variable' | 'text' | 'property';
    template: string;
    children?: HintPathType[];

bp-script-editor's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.