@rulab/adminjs-components 0.2.1 → 0.2.3

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.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # adminjs-components
2
2
 
3
+ <a id="top"></a>
4
+
3
5
  Prebuilt AdminJS components and features for common UI needs: colored status
4
6
  badges, slug and UUID generation, Editor.js content, sortable string lists, tabs
5
7
  layout, and record preview.
@@ -46,6 +48,14 @@ You can also pass `componentLoader` into every feature instead of calling
46
48
 
47
49
  ## Components and features
48
50
 
51
+ - [ColorStatus](#colorstatus)
52
+ - [Slug](#slug)
53
+ - [UUID](#uuid)
54
+ - [Editor](#editor)
55
+ - [StringList](#stringlist)
56
+ - [Tabs](#tabs)
57
+ - [Preview](#preview)
58
+
49
59
  ### ColorStatus
50
60
 
51
61
  Renders a colored badge in edit/list/show based on a list of available values.
@@ -68,6 +78,8 @@ features: [
68
78
  ]
69
79
  ```
70
80
 
81
+ [Back to top](#top)
82
+
71
83
  ### Slug
72
84
 
73
85
  Generates a slug from another field and stores it in the target property.
@@ -85,6 +97,8 @@ features: [
85
97
  ]
86
98
  ```
87
99
 
100
+ [Back to top](#top)
101
+
88
102
  ### UUID
89
103
 
90
104
  Adds a UUID field with a "Generate UUID" button in edit view.
@@ -101,10 +115,12 @@ features: [
101
115
  ]
102
116
  ```
103
117
 
118
+ [Back to top](#top)
119
+
104
120
  ### Editor
105
121
 
106
122
  Editor.js field for rich content. Supports optional image upload via
107
- `@adminjs/upload` provider.
123
+ `@adminjs/upload` provider, plus built-in audio and video blocks.
108
124
 
109
125
  ```ts
110
126
  import { EditorFeature } from "@rulab/adminjs-components";
@@ -123,6 +139,8 @@ features: [
123
139
  ]
124
140
  ```
125
141
 
142
+ [Back to top](#top)
143
+
126
144
  ### StringList
127
145
 
128
146
  Sortable list stored as a single string (comma-separated by default).
@@ -139,6 +157,8 @@ features: [
139
157
  ]
140
158
  ```
141
159
 
160
+ [Back to top](#top)
161
+
142
162
  ### Tabs
143
163
 
144
164
  Groups edit/show fields into tabs based on property `props.tab` or
@@ -163,6 +183,8 @@ properties: {
163
183
  },
164
184
  ```
165
185
 
186
+ [Back to top](#top)
187
+
166
188
  ### Preview
167
189
 
168
190
  Adds a record action that renders an iframe preview. The `url` can include
@@ -179,6 +201,8 @@ features: [
179
201
  ]
180
202
  ```
181
203
 
204
+ [Back to top](#top)
205
+
182
206
  ## Utilities
183
207
 
184
208
  - `setComponentLoader(loader)` and `getComponentLoader()` to reuse a single
@@ -44,6 +44,11 @@ export const Editor = ({ property, record, resource, onChange, onChangeAdmin, ed
44
44
  const init = async () => {
45
45
  const { default: EditorJS } = await import("@editorjs/editorjs");
46
46
  const tools = { ...EDITOR_TOOLS };
47
+ if (typeof window !== "undefined") {
48
+ // @ts-ignore
49
+ const videoModule = await import("simple-video-editorjs");
50
+ tools.video = videoModule.default ?? videoModule;
51
+ }
47
52
  if (uploadAction && resourceId) {
48
53
  const { default: ImageTool } = await import("@editorjs/image");
49
54
  const api = new ApiClient();
@@ -20,12 +20,20 @@ const tableParser = (block) => {
20
20
  }
21
21
  };
22
22
  const audioPlayerParser = (block) => {
23
- return `<audio controls src={${block.data.src}} />`;
23
+ return `<audio controls src="${block.data.src}"></audio>`;
24
+ };
25
+ const videoParser = (block) => {
26
+ const controls = block.data.controls === false ? "" : " controls";
27
+ const autoplay = block.data.autoplay ? " autoplay" : "";
28
+ const muted = block.data.muted ? " muted" : "";
29
+ const caption = block.data.caption ? `<figcaption>${block.data.caption}</figcaption>` : "";
30
+ return `<figure><video src="${block.data.url}"${controls}${autoplay}${muted}></video>${caption}</figure>`;
24
31
  };
25
32
  export const parseHtml = (jsonData) => {
26
33
  const edjsParser = edjsHTML({
27
34
  table: tableParser,
28
35
  audioPlayer: audioPlayerParser,
36
+ video: videoParser,
29
37
  });
30
38
  try {
31
39
  const data = edjsParser.parse(JSON.parse(jsonData));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulab/adminjs-components",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Prebuilt AdminJS features for common UI needs.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -51,6 +51,7 @@
51
51
  "editorjs-audio-player": "~0.0.3",
52
52
  "editorjs-html": "~3.4.3",
53
53
  "react-select": "^5.8.0",
54
+ "simple-video-editorjs": "~1.4.9",
54
55
  "slugify": "^1.6.6"
55
56
  },
56
57
  "peerDependencies": {