@rulab/adminjs-components 0.0.12 → 0.0.13

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/dist/index.cjs CHANGED
@@ -160,45 +160,30 @@ var import_react4 = __toESM(require("react"), 1);
160
160
  var import_styled_components3 = require("styled-components");
161
161
  var import_design_system2 = require("@adminjs/design-system");
162
162
 
163
- // src/utils/slugifyImport.ts
164
- var import_slugify = __toESM(require("slugify"), 1);
165
- var slugifyImport_default = import_slugify.default;
166
-
167
- // src/utils/slugifyTitle.ts
168
- var slugifyTitle = (title) => {
169
- return slugifyImport_default(title, {
170
- replacement: "-",
171
- remove: /[*+~.()'"!:@]/g,
172
- lower: true,
173
- locale: "vi",
174
- trim: true
175
- });
176
- };
177
-
178
163
  // src/utils/parseHtml.ts
179
164
  var import_editorjs_html = __toESM(require("editorjs-html"), 1);
180
- var parseHtml = (jsonData) => {
181
- function tableParser(block) {
182
- const rows = block.data.content.map((row, index) => {
183
- const tableHtml = [];
184
- if (block.data.withHeadings && index === 0) {
185
- tableHtml.push(`<tr>${row.map((cell) => `<th>${cell}</th>`)}</tr>`);
186
- } else {
187
- tableHtml.push(`<tr>${row.map((cell) => `<td>${cell}</td>`)}</tr>`);
188
- }
189
- return tableHtml;
190
- });
191
- if (block.data.withHeadings) {
192
- const heading = rows[0];
193
- const [, ...content] = rows;
194
- return `<table><thead>${heading.join("")}</thead><tbody>${content.join("")}</tbody></table>`;
165
+ var tableParser = (block) => {
166
+ const rows = block.data.content.map((row, index) => {
167
+ const tableHtml = [];
168
+ if (block.data.withHeadings && index === 0) {
169
+ tableHtml.push(`<tr>${row.map((cell) => `<th>${cell}</th>`)}</tr>`);
195
170
  } else {
196
- return `<table><tbody>${rows.join("")}</tbody></table>`;
171
+ tableHtml.push(`<tr>${row.map((cell) => `<td>${cell}</td>`)}</tr>`);
197
172
  }
173
+ return tableHtml;
174
+ });
175
+ if (block.data.withHeadings) {
176
+ const heading = rows[0];
177
+ const [, ...content] = rows;
178
+ return `<table><thead>${heading.join("")}</thead><tbody>${content.join("")}</tbody></table>`;
179
+ } else {
180
+ return `<table><tbody>${rows.join("")}</tbody></table>`;
198
181
  }
199
- const audioPlayerParser = (block) => {
200
- return `<audio controls src={${block.data.src}} />`;
201
- };
182
+ };
183
+ var audioPlayerParser = (block) => {
184
+ return `<audio controls src={${block.data.src}} />`;
185
+ };
186
+ var parseHtml = (jsonData) => {
202
187
  const edjsParser = (0, import_editorjs_html.default)({
203
188
  table: tableParser,
204
189
  audioPlayer: audioPlayerParser
@@ -211,6 +196,21 @@ var parseHtml = (jsonData) => {
211
196
  }
212
197
  };
213
198
 
199
+ // src/utils/slugifyImport.ts
200
+ var import_slugify = __toESM(require("slugify"), 1);
201
+ var slugifyImport_default = import_slugify.default;
202
+
203
+ // src/utils/slugifyTitle.ts
204
+ var slugifyTitle = (title) => {
205
+ return slugifyImport_default(title, {
206
+ replacement: "-",
207
+ remove: /[*+~.()'"!:@]/g,
208
+ lower: true,
209
+ locale: "vi",
210
+ trim: true
211
+ });
212
+ };
213
+
214
214
  // src/components/CustomSlug/styles.ts
215
215
  var import_styled_components2 = require("@adminjs/design-system/styled-components");
216
216
  var import_design_system = require("@adminjs/design-system");
@@ -232,7 +232,12 @@ var StyledLabel = import_styled_components2.styled.div`
232
232
  `;
233
233
 
234
234
  // src/components/CustomSlug/CustomSlug.tsx
235
- var CustomSlug = ({ property, record, onChange }) => {
235
+ var CustomSlug = ({
236
+ property,
237
+ record,
238
+ resource,
239
+ onChange
240
+ }) => {
236
241
  const [inputValue, setInputValue] = (0, import_react4.useState)(record.params.slug);
237
242
  (0, import_react4.useEffect)(() => {
238
243
  onChange(property.path, inputValue);
@@ -251,9 +256,9 @@ var CustomSlug = ({ property, record, onChange }) => {
251
256
  }
252
257
  function generateSlug(e) {
253
258
  e.preventDefault();
254
- const title = record.params.title;
255
- if (title) {
256
- setInputValue(slugifyTitle(title));
259
+ const slugSource = record.params[property.props.sourceField ?? resource.titleProperty.name];
260
+ if (slugSource) {
261
+ setInputValue(slugifyTitle(slugSource));
257
262
  }
258
263
  }
259
264
  };
@@ -344,7 +349,7 @@ var StyledEditorViewWrapper = (0, import_styled_components4.styled)(import_desig
344
349
  display: block;
345
350
  padding: 5px 8px;
346
351
  width: fit-content;
347
- border-radius: 10px;
352
+ border-radius: 4px;
348
353
  background-color: #e6e6e6;
349
354
  }
350
355
  `;
@@ -414,17 +419,20 @@ var StyledEditor = import_styled_components4.styled.div`
414
419
 
415
420
  // src/components/Editor/config.ts
416
421
  var import_header = __toESM(require("@editorjs/header"), 1);
417
- var import_paragraph = __toESM(require("@editorjs/paragraph"), 1);
418
422
  var import_list = __toESM(require("@editorjs/list"), 1);
419
- var import_table = __toESM(require("@editorjs/table"), 1);
423
+ var import_paragraph = __toESM(require("@editorjs/paragraph"), 1);
420
424
  var import_quote = __toESM(require("@editorjs/quote"), 1);
425
+ var import_table = __toESM(require("@editorjs/table"), 1);
421
426
  var import_editorjs_audio_player = __toESM(require("editorjs-audio-player"), 1);
422
427
  var EDITOR_TOOLS = {
423
428
  paragraph: {
424
429
  class: import_paragraph.default,
425
430
  inlineToolbar: true
426
431
  },
427
- list: import_list.default,
432
+ list: {
433
+ class: import_list.default,
434
+ inlineToolbar: true
435
+ },
428
436
  header: {
429
437
  class: import_header.default,
430
438
  config: {
@@ -433,8 +441,14 @@ var EDITOR_TOOLS = {
433
441
  defaultLevel: 2
434
442
  }
435
443
  },
436
- table: import_table.default,
437
- quote: import_quote.default,
444
+ table: {
445
+ class: import_table.default,
446
+ inlineToolbar: true
447
+ },
448
+ quote: {
449
+ class: import_quote.default,
450
+ inlineToolbar: true
451
+ },
438
452
  audioPlayer: import_editorjs_audio_player.default
439
453
  };
440
454
 
@@ -468,8 +482,8 @@ var Editor = ({ property, record, onChangeAdmin, editorId }) => {
468
482
  var Editor_default = Editor;
469
483
 
470
484
  // src/components/Editor/EditorList.jsx
471
- var import_design_system5 = require("@adminjs/design-system");
472
485
  var import_react6 = __toESM(require("react"), 1);
486
+ var import_design_system5 = require("@adminjs/design-system");
473
487
  var import_styled_components6 = require("styled-components");
474
488
  var EditorList = ({ property, record }) => {
475
489
  const htmlContent = parseHtml(record.params[property.path]);
package/dist/index.d.cts CHANGED
@@ -8,7 +8,7 @@ declare const ColorStatusShow: FC<ShowPropertyProps>;
8
8
 
9
9
  declare const ColorStatusList: FC<ShowPropertyProps>;
10
10
 
11
- type CustomSlugTypes = Omit<EditPropertyProps, "where" | "resource">;
11
+ type CustomSlugTypes = Omit<EditPropertyProps, "where">;
12
12
  declare const CustomSlug: FC<CustomSlugTypes>;
13
13
 
14
14
  declare function Editor({ property, record, onChangeAdmin, editorId }: {
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ declare const ColorStatusShow: FC<ShowPropertyProps>;
8
8
 
9
9
  declare const ColorStatusList: FC<ShowPropertyProps>;
10
10
 
11
- type CustomSlugTypes = Omit<EditPropertyProps, "where" | "resource">;
11
+ type CustomSlugTypes = Omit<EditPropertyProps, "where">;
12
12
  declare const CustomSlug: FC<CustomSlugTypes>;
13
13
 
14
14
  declare function Editor({ property, record, onChangeAdmin, editorId }: {
package/dist/index.js CHANGED
@@ -118,45 +118,30 @@ import React4, {
118
118
  import { ThemeProvider } from "styled-components";
119
119
  import { theme } from "@adminjs/design-system";
120
120
 
121
- // src/utils/slugifyImport.ts
122
- import slugify from "slugify";
123
- var slugifyImport_default = slugify;
124
-
125
- // src/utils/slugifyTitle.ts
126
- var slugifyTitle = (title) => {
127
- return slugifyImport_default(title, {
128
- replacement: "-",
129
- remove: /[*+~.()'"!:@]/g,
130
- lower: true,
131
- locale: "vi",
132
- trim: true
133
- });
134
- };
135
-
136
121
  // src/utils/parseHtml.ts
137
122
  import edjsHTML from "editorjs-html";
138
- var parseHtml = (jsonData) => {
139
- function tableParser(block) {
140
- const rows = block.data.content.map((row, index) => {
141
- const tableHtml = [];
142
- if (block.data.withHeadings && index === 0) {
143
- tableHtml.push(`<tr>${row.map((cell) => `<th>${cell}</th>`)}</tr>`);
144
- } else {
145
- tableHtml.push(`<tr>${row.map((cell) => `<td>${cell}</td>`)}</tr>`);
146
- }
147
- return tableHtml;
148
- });
149
- if (block.data.withHeadings) {
150
- const heading = rows[0];
151
- const [, ...content] = rows;
152
- return `<table><thead>${heading.join("")}</thead><tbody>${content.join("")}</tbody></table>`;
123
+ var tableParser = (block) => {
124
+ const rows = block.data.content.map((row, index) => {
125
+ const tableHtml = [];
126
+ if (block.data.withHeadings && index === 0) {
127
+ tableHtml.push(`<tr>${row.map((cell) => `<th>${cell}</th>`)}</tr>`);
153
128
  } else {
154
- return `<table><tbody>${rows.join("")}</tbody></table>`;
129
+ tableHtml.push(`<tr>${row.map((cell) => `<td>${cell}</td>`)}</tr>`);
155
130
  }
131
+ return tableHtml;
132
+ });
133
+ if (block.data.withHeadings) {
134
+ const heading = rows[0];
135
+ const [, ...content] = rows;
136
+ return `<table><thead>${heading.join("")}</thead><tbody>${content.join("")}</tbody></table>`;
137
+ } else {
138
+ return `<table><tbody>${rows.join("")}</tbody></table>`;
156
139
  }
157
- const audioPlayerParser = (block) => {
158
- return `<audio controls src={${block.data.src}} />`;
159
- };
140
+ };
141
+ var audioPlayerParser = (block) => {
142
+ return `<audio controls src={${block.data.src}} />`;
143
+ };
144
+ var parseHtml = (jsonData) => {
160
145
  const edjsParser = edjsHTML({
161
146
  table: tableParser,
162
147
  audioPlayer: audioPlayerParser
@@ -169,6 +154,21 @@ var parseHtml = (jsonData) => {
169
154
  }
170
155
  };
171
156
 
157
+ // src/utils/slugifyImport.ts
158
+ import slugify from "slugify";
159
+ var slugifyImport_default = slugify;
160
+
161
+ // src/utils/slugifyTitle.ts
162
+ var slugifyTitle = (title) => {
163
+ return slugifyImport_default(title, {
164
+ replacement: "-",
165
+ remove: /[*+~.()'"!:@]/g,
166
+ lower: true,
167
+ locale: "vi",
168
+ trim: true
169
+ });
170
+ };
171
+
172
172
  // src/components/CustomSlug/styles.ts
173
173
  import { styled as styled2 } from "@adminjs/design-system/styled-components";
174
174
  import { Box, Button, Input } from "@adminjs/design-system";
@@ -190,7 +190,12 @@ var StyledLabel = styled2.div`
190
190
  `;
191
191
 
192
192
  // src/components/CustomSlug/CustomSlug.tsx
193
- var CustomSlug = ({ property, record, onChange }) => {
193
+ var CustomSlug = ({
194
+ property,
195
+ record,
196
+ resource,
197
+ onChange
198
+ }) => {
194
199
  const [inputValue, setInputValue] = useState2(record.params.slug);
195
200
  useEffect2(() => {
196
201
  onChange(property.path, inputValue);
@@ -209,9 +214,9 @@ var CustomSlug = ({ property, record, onChange }) => {
209
214
  }
210
215
  function generateSlug(e) {
211
216
  e.preventDefault();
212
- const title = record.params.title;
213
- if (title) {
214
- setInputValue(slugifyTitle(title));
217
+ const slugSource = record.params[property.props.sourceField ?? resource.titleProperty.name];
218
+ if (slugSource) {
219
+ setInputValue(slugifyTitle(slugSource));
215
220
  }
216
221
  }
217
222
  };
@@ -302,7 +307,7 @@ var StyledEditorViewWrapper = styled3(Box2)`
302
307
  display: block;
303
308
  padding: 5px 8px;
304
309
  width: fit-content;
305
- border-radius: 10px;
310
+ border-radius: 4px;
306
311
  background-color: #e6e6e6;
307
312
  }
308
313
  `;
@@ -372,17 +377,20 @@ var StyledEditor = styled3.div`
372
377
 
373
378
  // src/components/Editor/config.ts
374
379
  import Header from "@editorjs/header";
375
- import Paragraph from "@editorjs/paragraph";
376
380
  import List from "@editorjs/list";
377
- import Table from "@editorjs/table";
381
+ import Paragraph from "@editorjs/paragraph";
378
382
  import Quote from "@editorjs/quote";
383
+ import Table from "@editorjs/table";
379
384
  import AudioPlayer from "editorjs-audio-player";
380
385
  var EDITOR_TOOLS = {
381
386
  paragraph: {
382
387
  class: Paragraph,
383
388
  inlineToolbar: true
384
389
  },
385
- list: List,
390
+ list: {
391
+ class: List,
392
+ inlineToolbar: true
393
+ },
386
394
  header: {
387
395
  class: Header,
388
396
  config: {
@@ -391,8 +399,14 @@ var EDITOR_TOOLS = {
391
399
  defaultLevel: 2
392
400
  }
393
401
  },
394
- table: Table,
395
- quote: Quote,
402
+ table: {
403
+ class: Table,
404
+ inlineToolbar: true
405
+ },
406
+ quote: {
407
+ class: Quote,
408
+ inlineToolbar: true
409
+ },
396
410
  audioPlayer: AudioPlayer
397
411
  };
398
412
 
@@ -426,8 +440,8 @@ var Editor = ({ property, record, onChangeAdmin, editorId }) => {
426
440
  var Editor_default = Editor;
427
441
 
428
442
  // src/components/Editor/EditorList.jsx
429
- import { theme as theme3 } from "@adminjs/design-system";
430
443
  import React6 from "react";
444
+ import { theme as theme3 } from "@adminjs/design-system";
431
445
  import { ThemeProvider as ThemeProvider3 } from "styled-components";
432
446
  var EditorList = ({ property, record }) => {
433
447
  const htmlContent = parseHtml(record.params[property.path]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulab/adminjs-components",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -11,7 +11,10 @@ export const EDITOR_TOOLS = {
11
11
  class: Paragraph,
12
12
  inlineToolbar: true,
13
13
  },
14
- list: List,
14
+ list: {
15
+ class: List,
16
+ inlineToolbar: true,
17
+ },
15
18
  header: {
16
19
  class: Header,
17
20
  config: {
@@ -20,7 +23,13 @@ export const EDITOR_TOOLS = {
20
23
  defaultLevel: 2,
21
24
  },
22
25
  },
23
- table: Table,
24
- quote: Quote,
26
+ table: {
27
+ class: Table,
28
+ inlineToolbar: true,
29
+ },
30
+ quote: {
31
+ class: Quote,
32
+ inlineToolbar: true,
33
+ },
25
34
  audioPlayer: AudioPlayer,
26
35
  };