@univerjs/uniscript
TypeScript icon, indicating that this package has built-in type declarations

0.1.11 • Public • Published

@univerjs/uniscript

npm version license CSS Included i18n

Introduction

@univerjs/uniscript uses the DSL (Domain-Specific Language) provided by @univerjs/facade and creates a code editor for Users to write code for operating Univer's data structures and business logic.

Users can write business logic in the code editor to meet more flexible business requirements. For instance, as shown in the illustration, users can write a Uniscript to read identity card numbers from a selected area and validate their legality, and mark the background of invalid identity card numbers with red.

:::caution The Uniscript is currently in the experimental stage, and it is not recommended to use it in production environments. You can refer to the Roadmap to understand the iteration plan of Uniscript. :::

:::tip Indeed, Uniscript's Domain-Specific Language (DSL) is a set of Facade APIs that encapsulate the internal implementation details of Univer. This API is defined here. :::

Usage

Installation

# Using npm
npm install @univerjs/uniscript

# Using pnpm
pnpm add @univerjs/uniscript

Get the Editor Instance

The @univerjs/uniscript uses Monaco Editor as its code editor. You can obtain an instance of the editor through the following method:

const editor = univer.__getInjector().get(ScriptEditorService).getEditorInstance();

Or inject ScriptEditorService into your module to obtain the editor instance.

export class YourModule {
  constructor(
    @Inject(ScriptEditorService) private readonly _scriptEditorService
  ) {}

  private _getEditor() {
    return this._scriptEditorService.getEditorInstance();
  }
}

Dependencies (0)

    Dev Dependencies (13)

    Package Sidebar

    Install

    npm i @univerjs/uniscript

    Homepage

    univer.ai

    Weekly Downloads

    106

    Version

    0.1.11

    License

    Apache-2.0

    Unpacked Size

    43.7 kB

    Total Files

    20

    Last publish

    Collaborators

    • yuhongz
    • wbfsa
    • jikkai
    • wendellhu95
    • mengshukeji