@devtools-ui/code-editor 0.4.1--canary.62.3837 → 0.4.1-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +92 -0
  2. package/package.json +7 -7
package/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # @devtools-ui/code-editor
2
+
3
+ ## Overview
4
+
5
+ `@devtools-ui/code-editor` is a component package designed to be leveraged by a [Player-UI assets plugin](https://player-ui.github.io/next/plugins).
6
+
7
+ It provides a `CodeEditor` component that can be used to edit JSON content and call an expression on changes.
8
+
9
+ ## Installation
10
+
11
+ To install `@devtools-ui/code-editor`, you can use pnpm or yarn:
12
+
13
+ ```sh
14
+ pnpm i @devtools-ui/code-editor
15
+ ```
16
+
17
+ or
18
+
19
+ ```sh
20
+ yarn add @devtools-ui/code-editor
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ You can leverage this asset through the `@devtools-ui/plugin`:
26
+
27
+ ```ts
28
+ import { CodeEditor } from "@devtools-ui/plugin";
29
+
30
+ // and use it to define your Player-UI content:
31
+ myFlow = {
32
+ id: "my_flow",
33
+ views: [<CodeEditor />],
34
+ };
35
+ ```
36
+
37
+ For more information on how to author Player-UI content using DSL, please check our [Player-UI docs](https://player-ui.github.io/next/dsl#tsxjsx-content-authoring-player-dsl).
38
+
39
+ Or, your can leverage this asset in your own plugin:
40
+
41
+ ```ts
42
+ // TransformPlugin.ts
43
+ import type { Player, PlayerPlugin } from "@player-ui/player";
44
+ import { AssetTransformPlugin } from "@player-ui/asset-transform-plugin";
45
+ import { code-editorTransform } from "@devtools-ui/code-editor";
46
+
47
+ export class TransformsPlugin implements PlayerPlugin {
48
+ name = "my-plugin-transforms";
49
+
50
+ apply(player: Player) {
51
+ player.registerPlugin(
52
+ new AssetTransformPlugin([
53
+ [{ type: "code-editor" }, code-editorTransform],
54
+ ])
55
+ );
56
+ }
57
+ }
58
+ ```
59
+
60
+ ```ts
61
+ // AssetRegistryPlugin.ts
62
+ import React from "react";
63
+ import type { Player } from "@player-ui/player";
64
+ import type {
65
+ ExtendedPlayerPlugin,
66
+ ReactPlayer,
67
+ ReactPlayerPlugin,
68
+ } from "@player-ui/react";
69
+ import { AssetProviderPlugin } from "@player-ui/asset-provider-plugin-react";
70
+ import { TransformsPlugin } from "./TransformPlugin";
71
+ import { CodeEditorAsset, CodeEditorComponent } from "@devtools-ui/code-editor";
72
+
73
+ export class AssetsRegistryPlugin
74
+ implements ReactPlayerPlugin, ExtendedPlayerPlugin<[CodeEditorAsset]>
75
+ {
76
+ name = "my-plugin";
77
+
78
+ applyReact(reactPlayer: ReactPlayer) {
79
+ reactPlayer.registerPlugin(
80
+ new AssetProviderPlugin([["code-editor", CodeEditorComponent]])
81
+ );
82
+ }
83
+
84
+ apply(player: Player) {
85
+ player.registerPlugin(new TransformsPlugin());
86
+ }
87
+ }
88
+ ```
89
+
90
+ ## Contributing
91
+
92
+ We welcome contributions to `@devtools-ui/code-editor`!
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
+ "sideEffects": false,
3
+ "files": [
4
+ "dist",
5
+ "src",
6
+ "types"
7
+ ],
2
8
  "name": "@devtools-ui/code-editor",
3
- "version": "0.4.1--canary.62.3837",
9
+ "version": "0.4.1-next.0",
4
10
  "main": "dist/cjs/index.cjs",
5
11
  "module": "dist/index.legacy-esm.js",
6
12
  "types": "types/index.d.ts",
7
- "sideEffects": false,
8
13
  "exports": {
9
14
  "./package.json": "./package.json",
10
15
  "./dist/index.css": "./dist/index.css",
@@ -14,11 +19,6 @@
14
19
  "default": "./dist/cjs/index.cjs"
15
20
  }
16
21
  },
17
- "files": [
18
- "dist",
19
- "src",
20
- "types"
21
- ],
22
22
  "dependencies": {
23
23
  "@chakra-ui/react": "^2.8.2",
24
24
  "@codemirror/lang-json": "^6.0.1",