@univerjs/uniscript 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/README.md +40 -2
  2. package/package.json +12 -12
package/README.md CHANGED
@@ -5,12 +5,50 @@
5
5
 
6
6
  ## Introduction
7
7
 
8
- > Univer uniscript package. This package add scripting feature to univer.
8
+ ![](./assets//uniscript.jpeg)
9
+
10
+ `@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.
11
+
12
+ 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.
13
+
14
+ :::caution
15
+ 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](https://univer.ai/en-us/guides/roadmap/) to understand the iteration plan of Uniscript.
16
+ :::
17
+
18
+ :::tip
19
+ 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](https://univer.ai/en-us/guides/facade/).
20
+ :::
9
21
 
10
22
  ## Usage
11
23
 
12
24
  ### Installation
13
25
 
14
26
  ```shell
15
- npm i @univerjs/uniscript
27
+ # Using npm
28
+ npm install @univerjs/uniscript
29
+
30
+ # Using pnpm
31
+ pnpm add @univerjs/uniscript
32
+ ```
33
+
34
+ ### Get the Editor Instance
35
+
36
+ The `@univerjs/uniscript` uses [Monaco Editor](https://microsoft.github.io/monaco-editor/) as its code editor. You can obtain an instance of the editor through the following method:
37
+
38
+ ```ts
39
+ const editor = univer.__getInjector().get(ScriptEditorService).getEditorInstance();
40
+ ```
41
+
42
+ Or inject `ScriptEditorService` into your module to obtain the editor instance.
43
+
44
+ ```ts
45
+ export class YourModule {
46
+ constructor(
47
+ @Inject(ScriptEditorService) private readonly _scriptEditorService
48
+ ) {}
49
+
50
+ private _getEditor() {
51
+ return this._scriptEditorService.getEditorInstance();
52
+ }
53
+ }
16
54
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/uniscript",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "description": "UI component library for building exceptional Univer.",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -55,11 +55,11 @@
55
55
  "monaco-editor": ">=0.44.0",
56
56
  "react": ">=16.9.0",
57
57
  "rxjs": ">=7.0.0",
58
- "@univerjs/core": "0.1.1",
59
- "@univerjs/design": "0.1.1",
60
- "@univerjs/facade": "0.1.1",
61
- "@univerjs/ui": "0.1.1",
62
- "@univerjs/sheets": "0.1.1"
58
+ "@univerjs/core": "0.1.2",
59
+ "@univerjs/design": "0.1.2",
60
+ "@univerjs/facade": "0.1.2",
61
+ "@univerjs/ui": "0.1.2",
62
+ "@univerjs/sheets": "0.1.2"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@types/react": "^18.2.57",
@@ -70,12 +70,12 @@
70
70
  "typescript": "^5.3.3",
71
71
  "vite": "^5.1.4",
72
72
  "vitest": "^1.3.1",
73
- "@univerjs/core": "0.1.1",
74
- "@univerjs/design": "0.1.1",
75
- "@univerjs/facade": "0.1.1",
76
- "@univerjs/sheets": "0.1.1",
77
- "@univerjs/shared": "0.1.1",
78
- "@univerjs/ui": "0.1.1"
73
+ "@univerjs/core": "0.1.2",
74
+ "@univerjs/design": "0.1.2",
75
+ "@univerjs/facade": "0.1.2",
76
+ "@univerjs/shared": "0.1.2",
77
+ "@univerjs/sheets": "0.1.2",
78
+ "@univerjs/ui": "0.1.2"
79
79
  },
80
80
  "scripts": {
81
81
  "test": "vitest run",