@rulab/adminjs-components 0.0.13 → 0.1.0-alpha.2

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 (71) hide show
  1. package/LICENSE +21 -21
  2. package/dist/index.cjs +10 -762
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +10 -21
  5. package/dist/index.d.ts +10 -21
  6. package/dist/index.js +3 -754
  7. package/dist/index.js.map +1 -0
  8. package/package.json +12 -8
  9. package/src/components/ColorStatus/ColorStatusEdit.tsx +94 -94
  10. package/src/components/ColorStatus/ColorStatusList.tsx +20 -20
  11. package/src/components/ColorStatus/ColorStatusShow.tsx +23 -23
  12. package/src/components/ColorStatus/index.ts +3 -3
  13. package/src/components/ColorStatus/styles.ts +30 -30
  14. package/src/components/ColorStatus/types.ts +5 -5
  15. package/src/components/Editor/Editor.jsx +49 -49
  16. package/src/components/Editor/EditorList.jsx +22 -22
  17. package/src/components/Editor/EditorShow.jsx +24 -24
  18. package/src/components/Editor/config.ts +35 -35
  19. package/src/components/Editor/index.ts +3 -3
  20. package/src/components/Editor/styles.ts +151 -151
  21. package/src/components/{CustomSlug/CustomSlug.tsx → Slug/SlugEdit.tsx} +68 -68
  22. package/src/components/Slug/SlugFeature.ts +30 -0
  23. package/src/components/Slug/index.ts +1 -0
  24. package/src/components/{CustomSlug → Slug}/styles.ts +24 -24
  25. package/src/components/StringList/SortableList/SortableList.tsx +98 -98
  26. package/src/components/StringList/SortableList/components/SortableItem/DragHandle.tsx +20 -20
  27. package/src/components/StringList/SortableList/components/SortableItem/SortableItem.tsx +59 -59
  28. package/src/components/StringList/SortableList/components/SortableItem/styles.ts +22 -22
  29. package/src/components/StringList/SortableList/components/SortableItem/types.ts +7 -7
  30. package/src/components/StringList/SortableList/components/index.ts +2 -2
  31. package/src/components/StringList/SortableList/index.ts +1 -1
  32. package/src/components/StringList/SortableList/styles.ts +9 -9
  33. package/src/components/StringList/StringList.tsx +136 -136
  34. package/src/components/StringList/StringListShow.tsx +37 -37
  35. package/src/components/StringList/constants.ts +1 -1
  36. package/src/components/StringList/index.ts +2 -2
  37. package/src/components/StringList/styles.ts +41 -41
  38. package/src/components/index.ts +10 -9
  39. package/dist/bundle.js +0 -8
  40. package/dist/components/CustomSlug/CustomSlug.jsx +0 -29
  41. package/dist/components/CustomSlug/index.js +0 -1
  42. package/dist/components/CustomSlug/styles.js +0 -15
  43. package/dist/components/Editor/config.js +0 -11
  44. package/dist/components/Editor/index.js +0 -1
  45. package/dist/components/Editor/styles.js +0 -64
  46. package/dist/components/StringList/SortableList/SortableList.jsx +0 -43
  47. package/dist/components/StringList/SortableList/components/SortableItem/DragHandle.jsx +0 -10
  48. package/dist/components/StringList/SortableList/components/SortableItem/SortableItem.jsx +0 -32
  49. package/dist/components/StringList/SortableList/components/SortableItem/styles.js +0 -20
  50. package/dist/components/StringList/SortableList/components/SortableItem/types.js +0 -1
  51. package/dist/components/StringList/SortableList/components/index.js +0 -2
  52. package/dist/components/StringList/SortableList/index.js +0 -1
  53. package/dist/components/StringList/SortableList/styles.js +0 -8
  54. package/dist/components/StringList/StringList.jsx +0 -67
  55. package/dist/components/StringList/index.js +0 -1
  56. package/dist/components/StringList/styles.js +0 -16
  57. package/dist/components/index.js +0 -3
  58. package/dist/editorFeature.js +0 -16
  59. package/dist/index.d.mts +0 -8
  60. package/dist/index.mjs +0 -37
  61. package/dist/utils/index.js +0 -1
  62. package/dist/utils/slugifyImport.js +0 -3
  63. package/dist/utils/slugifyTitle.js +0 -10
  64. package/src/components/CustomSlug/index.ts +0 -1
  65. package/src/index.ts +0 -2
  66. package/src/types.d.ts +0 -3
  67. package/src/utils/index.ts +0 -3
  68. package/src/utils/parseHtml.ts +0 -56
  69. package/src/utils/slugifyImport.ts +0 -4
  70. package/src/utils/slugifyTitle.ts +0 -11
  71. package/tsconfig.json +0 -17
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./components/index.js\";\r\nexport { parseHtml } from \"./utils/parseHtml.js\";\r\n"],"mappings":"AAAA,cAAc;AACd,SAAS,iBAAiB;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulab/adminjs-components",
3
- "version": "0.0.13",
3
+ "version": "0.1.0-alpha.2",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -12,15 +12,11 @@
12
12
  "repository": {
13
13
  "url": "https://github.com/rulab/adminjs-components"
14
14
  },
15
- "scripts": {
16
- "build": "tsup src/index.ts --format cjs,esm --dts",
17
- "lint": "tsc"
18
- },
19
15
  "dependencies": {
20
16
  "@adminjs/design-system": "^4.1.1",
21
17
  "@dnd-kit/core": "^6.1.0",
22
18
  "@dnd-kit/sortable": "^8.0.0",
23
- "@editorjs/editorjs": "^2.30.2",
19
+ "@editorjs/editorjs": "2.30.2",
24
20
  "@editorjs/header": "^2.8.7",
25
21
  "@editorjs/list": "^1.9.0",
26
22
  "@editorjs/paragraph": "^2.11.6",
@@ -46,5 +42,13 @@
46
42
  "engines": {
47
43
  "node": ">=18"
48
44
  },
49
- "packageManager": "pnpm@8.15.6"
50
- }
45
+ "files": [
46
+ "dist",
47
+ "src/components"
48
+ ],
49
+ "packageManager": "pnpm@8.15.6",
50
+ "scripts": {
51
+ "build": "tsup src/index.ts --format cjs,esm --dts",
52
+ "lint": "tsc"
53
+ }
54
+ }
@@ -1,94 +1,94 @@
1
- import React, { FC, useState, useEffect } from "react";
2
-
3
- import { EditPropertyProps } from "adminjs";
4
- import Select, { MultiValue, SingleValue, StylesConfig } from "react-select";
5
- import chroma from "chroma-js";
6
-
7
- import { ColorStatusWrapper, Label } from "./styles";
8
-
9
- import type { AvailableValueType } from "./types";
10
-
11
- type ColorStatusTypes = Omit<EditPropertyProps, "where" | "resource">;
12
-
13
- const dot = (color = "transparent") => ({
14
- alignItems: "center",
15
- display: "flex",
16
-
17
- ":before": {
18
- backgroundColor: color,
19
- borderRadius: 10,
20
- content: '" "',
21
- display: "block",
22
- marginRight: 8,
23
- height: 10,
24
- width: 10,
25
- },
26
- });
27
-
28
- const colorStyles: StylesConfig<AvailableValueType> = {
29
- control: (styles) => ({ ...styles, backgroundColor: "white" }),
30
- option: (styles, { data, isDisabled, isFocused, isSelected }) => {
31
- const color = chroma(data.color);
32
- return {
33
- ...styles,
34
- backgroundColor: isSelected
35
- ? data.color
36
- : isFocused
37
- ? color.alpha(0.1).css()
38
- : undefined,
39
- color: isSelected
40
- ? chroma.contrast(color, "white") > 2
41
- ? "white"
42
- : "black"
43
- : data.color,
44
-
45
- ":active": {
46
- ...styles[":active"],
47
- backgroundColor: isSelected ? data.color : color.alpha(0.3).css(),
48
- },
49
- };
50
- },
51
- input: (styles) => ({ ...styles, ...dot() }),
52
- placeholder: (styles) => ({ ...styles, ...dot("#ccc") }),
53
- singleValue: (styles, { data }) => ({ ...styles, ...dot(data.color) }),
54
- };
55
-
56
- const ColorStatus: FC<ColorStatusTypes> = ({ property, record, onChange }) => {
57
- const availableValues = property.availableValues as AvailableValueType[];
58
-
59
- const currentOption = availableValues.find(
60
- (item) => item.value === record.params[property.path],
61
- ) as AvailableValueType;
62
-
63
- const [selectOption, setCurrentOption] = useState<
64
- SingleValue<AvailableValueType> | undefined
65
- >(currentOption);
66
-
67
- const handleSelectChange = (
68
- option: SingleValue<AvailableValueType> | MultiValue<AvailableValueType>,
69
- ) => {
70
- setCurrentOption(option as SingleValue<AvailableValueType>);
71
- };
72
-
73
- useEffect(() => {
74
- onChange(property.path, selectOption?.value);
75
- }, [selectOption]);
76
-
77
- return (
78
- <ColorStatusWrapper>
79
- <Label>{property.path}</Label>
80
- <Select
81
- className="basic-single"
82
- classNamePrefix="select"
83
- defaultValue={selectOption ?? availableValues[0]}
84
- onChange={handleSelectChange}
85
- isClearable={true}
86
- name="color"
87
- options={availableValues}
88
- styles={colorStyles}
89
- />
90
- </ColorStatusWrapper>
91
- );
92
- };
93
-
94
- export default ColorStatus;
1
+ import React, { FC, useState, useEffect } from "react";
2
+
3
+ import { EditPropertyProps } from "adminjs";
4
+ import Select, { MultiValue, SingleValue, StylesConfig } from "react-select";
5
+ import chroma from "chroma-js";
6
+
7
+ import { ColorStatusWrapper, Label } from "./styles";
8
+
9
+ import type { AvailableValueType } from "./types";
10
+
11
+ type ColorStatusTypes = Omit<EditPropertyProps, "where" | "resource">;
12
+
13
+ const dot = (color = "transparent") => ({
14
+ alignItems: "center",
15
+ display: "flex",
16
+
17
+ ":before": {
18
+ backgroundColor: color,
19
+ borderRadius: 10,
20
+ content: '" "',
21
+ display: "block",
22
+ marginRight: 8,
23
+ height: 10,
24
+ width: 10,
25
+ },
26
+ });
27
+
28
+ const colorStyles: StylesConfig<AvailableValueType> = {
29
+ control: (styles) => ({ ...styles, backgroundColor: "white" }),
30
+ option: (styles, { data, isDisabled, isFocused, isSelected }) => {
31
+ const color = chroma(data.color);
32
+ return {
33
+ ...styles,
34
+ backgroundColor: isSelected
35
+ ? data.color
36
+ : isFocused
37
+ ? color.alpha(0.1).css()
38
+ : undefined,
39
+ color: isSelected
40
+ ? chroma.contrast(color, "white") > 2
41
+ ? "white"
42
+ : "black"
43
+ : data.color,
44
+
45
+ ":active": {
46
+ ...styles[":active"],
47
+ backgroundColor: isSelected ? data.color : color.alpha(0.3).css(),
48
+ },
49
+ };
50
+ },
51
+ input: (styles) => ({ ...styles, ...dot() }),
52
+ placeholder: (styles) => ({ ...styles, ...dot("#ccc") }),
53
+ singleValue: (styles, { data }) => ({ ...styles, ...dot(data.color) }),
54
+ };
55
+
56
+ const ColorStatus: FC<ColorStatusTypes> = ({ property, record, onChange }) => {
57
+ const availableValues = property.availableValues as AvailableValueType[];
58
+
59
+ const currentOption = availableValues.find(
60
+ (item) => item.value === record.params[property.path],
61
+ ) as AvailableValueType;
62
+
63
+ const [selectOption, setCurrentOption] = useState<
64
+ SingleValue<AvailableValueType> | undefined
65
+ >(currentOption);
66
+
67
+ const handleSelectChange = (
68
+ option: SingleValue<AvailableValueType> | MultiValue<AvailableValueType>,
69
+ ) => {
70
+ setCurrentOption(option as SingleValue<AvailableValueType>);
71
+ };
72
+
73
+ useEffect(() => {
74
+ onChange(property.path, selectOption?.value);
75
+ }, [selectOption]);
76
+
77
+ return (
78
+ <ColorStatusWrapper>
79
+ <Label>{property.path}</Label>
80
+ <Select
81
+ className="basic-single"
82
+ classNamePrefix="select"
83
+ defaultValue={selectOption ?? availableValues[0]}
84
+ onChange={handleSelectChange}
85
+ isClearable={true}
86
+ name="color"
87
+ options={availableValues}
88
+ styles={colorStyles}
89
+ />
90
+ </ColorStatusWrapper>
91
+ );
92
+ };
93
+
94
+ export default ColorStatus;
@@ -1,20 +1,20 @@
1
- import React, { FC } from "react";
2
- import { ShowPropertyProps } from "adminjs";
3
-
4
- import { ColorStatusBadge } from "./styles";
5
-
6
- import type { AvailableValueType } from "./types";
7
-
8
- const ColorStatusList: FC<ShowPropertyProps> = ({ property, record }) => {
9
- const currentOption = property.availableValues?.find(
10
- (item) => item.value === record.params[property.path],
11
- ) as AvailableValueType;
12
-
13
- return (
14
- <ColorStatusBadge color={currentOption.color}>
15
- {record.params[property.path]}
16
- </ColorStatusBadge>
17
- );
18
- };
19
-
20
- export default ColorStatusList;
1
+ import React, { FC } from "react";
2
+ import { ShowPropertyProps } from "adminjs";
3
+
4
+ import { ColorStatusBadge } from "./styles";
5
+
6
+ import type { AvailableValueType } from "./types";
7
+
8
+ const ColorStatusList: FC<ShowPropertyProps> = ({ property, record }) => {
9
+ const currentOption = property.availableValues?.find(
10
+ (item) => item.value === record.params[property.path],
11
+ ) as AvailableValueType;
12
+
13
+ return (
14
+ <ColorStatusBadge color={currentOption.color}>
15
+ {record.params[property.path]}
16
+ </ColorStatusBadge>
17
+ );
18
+ };
19
+
20
+ export default ColorStatusList;
@@ -1,23 +1,23 @@
1
- import React, { FC } from "react";
2
- import { ShowPropertyProps } from "adminjs";
3
-
4
- import { ColorStatusBadgeWrapper, ColorStatusBadge, ShowLabel } from "./styles";
5
-
6
- import type { AvailableValueType } from "./types";
7
-
8
- const ColorStatusShow: FC<ShowPropertyProps> = ({ property, record }) => {
9
- const currentOption = property.availableValues?.find(
10
- (item) => item.value === record.params[property.path],
11
- ) as AvailableValueType;
12
-
13
- return (
14
- <ColorStatusBadgeWrapper>
15
- <ShowLabel>{property.path}</ShowLabel>
16
- <ColorStatusBadge color={currentOption.color}>
17
- {record.params[property.path]}
18
- </ColorStatusBadge>
19
- </ColorStatusBadgeWrapper>
20
- );
21
- };
22
-
23
- export default ColorStatusShow;
1
+ import React, { FC } from "react";
2
+ import { ShowPropertyProps } from "adminjs";
3
+
4
+ import { ColorStatusBadgeWrapper, ColorStatusBadge, ShowLabel } from "./styles";
5
+
6
+ import type { AvailableValueType } from "./types";
7
+
8
+ const ColorStatusShow: FC<ShowPropertyProps> = ({ property, record }) => {
9
+ const currentOption = property.availableValues?.find(
10
+ (item) => item.value === record.params[property.path],
11
+ ) as AvailableValueType;
12
+
13
+ return (
14
+ <ColorStatusBadgeWrapper>
15
+ <ShowLabel>{property.path}</ShowLabel>
16
+ <ColorStatusBadge color={currentOption.color}>
17
+ {record.params[property.path]}
18
+ </ColorStatusBadge>
19
+ </ColorStatusBadgeWrapper>
20
+ );
21
+ };
22
+
23
+ export default ColorStatusShow;
@@ -1,3 +1,3 @@
1
- export * from "./ColorStatusEdit.js";
2
- export * from "./ColorStatusShow.js";
3
- export * from "./ColorStatusList.js";
1
+ export * from "./ColorStatusEdit.js";
2
+ export * from "./ColorStatusShow.js";
3
+ export * from "./ColorStatusList.js";
@@ -1,30 +1,30 @@
1
- import { styled } from "@adminjs/design-system/styled-components";
2
-
3
- export const ColorStatusWrapper = styled.div`
4
- margin-bottom: 24px;
5
- `;
6
-
7
- export const Label = styled.div`
8
- font-size: 12px;
9
- margin-bottom: 8px;
10
- `;
11
-
12
- export const ShowLabel = styled.div`
13
- font-size: 12px;
14
- margin-bottom: 8px;
15
- color: rgb(137, 138, 154);
16
- `;
17
-
18
- export const ColorStatusBadgeWrapper = styled.div`
19
- margin-bottom: 20px;
20
- `;
21
-
22
- export const ColorStatusBadge = styled.div`
23
- background-color: ${(props: any) => props.color};
24
- width: fit-content;
25
- padding: 5px 10px;
26
- border-radius: 20px;
27
- font-size: 12px;
28
- color: white;
29
- white-space: nowrap;
30
- `;
1
+ import { styled } from "@adminjs/design-system/styled-components";
2
+
3
+ export const ColorStatusWrapper = styled.div`
4
+ margin-bottom: 24px;
5
+ `;
6
+
7
+ export const Label = styled.div`
8
+ font-size: 12px;
9
+ margin-bottom: 8px;
10
+ `;
11
+
12
+ export const ShowLabel = styled.div`
13
+ font-size: 12px;
14
+ margin-bottom: 8px;
15
+ color: rgb(137, 138, 154);
16
+ `;
17
+
18
+ export const ColorStatusBadgeWrapper = styled.div`
19
+ margin-bottom: 20px;
20
+ `;
21
+
22
+ export const ColorStatusBadge = styled.div`
23
+ background-color: ${(props: any) => props.color};
24
+ width: fit-content;
25
+ padding: 5px 10px;
26
+ border-radius: 20px;
27
+ font-size: 12px;
28
+ color: white;
29
+ white-space: nowrap;
30
+ `;
@@ -1,5 +1,5 @@
1
- export type AvailableValueType = {
2
- value: string;
3
- label: string;
4
- color: string;
5
- };
1
+ export type AvailableValueType = {
2
+ value: string;
3
+ label: string;
4
+ color: string;
5
+ };
@@ -1,49 +1,49 @@
1
- import React, { memo, useState, useEffect, useRef } from "react";
2
- import { ThemeProvider } from "styled-components";
3
- import EditorJS from "@editorjs/editorjs";
4
- import { theme } from "@adminjs/design-system";
5
-
6
- import { StyledLabel, StyledEditor, StyledEditorWrapper } from "./styles";
7
-
8
- import { EDITOR_TOOLS } from "./config";
9
-
10
- const Editor = ({ property, record, onChangeAdmin, editorId }) => {
11
- const [jsonData, setJsonData] = useState();
12
- const isSavedData = Boolean(record.params[property.path]);
13
-
14
- const ref = useRef();
15
-
16
- useEffect(() => {
17
- onChangeAdmin(property.path, jsonData);
18
- }, [jsonData]);
19
-
20
- useEffect(() => {
21
- if (!ref.current) {
22
- const editor = new EditorJS({
23
- holder: editorId,
24
- tools: EDITOR_TOOLS,
25
- data: isSavedData ? JSON.parse(record.params[property.path]) : "",
26
- async onChange(api, event) {
27
- const data = await api.saver.save();
28
- setJsonData(JSON.stringify(data));
29
- },
30
- });
31
- ref.current = editor;
32
- }
33
-
34
- return () => {
35
- ref?.current?.destroy?.();
36
- };
37
- }, []);
38
-
39
- return (
40
- <ThemeProvider theme={theme}>
41
- <StyledLabel>{property.path}</StyledLabel>
42
- <StyledEditorWrapper>
43
- <StyledEditor id={editorId} />
44
- </StyledEditorWrapper>
45
- </ThemeProvider>
46
- );
47
- };
48
-
49
- export default Editor;
1
+ import React, { memo, useState, useEffect, useRef } from "react";
2
+ import { ThemeProvider } from "styled-components";
3
+ import EditorJS from "@editorjs/editorjs";
4
+ import { theme } from "@adminjs/design-system";
5
+
6
+ import { StyledLabel, StyledEditor, StyledEditorWrapper } from "./styles";
7
+
8
+ import { EDITOR_TOOLS } from "./config";
9
+
10
+ const Editor = ({ property, record, onChangeAdmin, editorId }) => {
11
+ const [jsonData, setJsonData] = useState();
12
+ const isSavedData = Boolean(record.params[property.path]);
13
+
14
+ const ref = useRef();
15
+
16
+ useEffect(() => {
17
+ onChangeAdmin(property.path, jsonData);
18
+ }, [jsonData]);
19
+
20
+ useEffect(() => {
21
+ if (!ref.current) {
22
+ const editor = new EditorJS({
23
+ holder: editorId,
24
+ tools: EDITOR_TOOLS,
25
+ data: isSavedData ? JSON.parse(record.params[property.path]) : "",
26
+ async onChange(api, event) {
27
+ const data = await api.saver.save();
28
+ setJsonData(JSON.stringify(data));
29
+ },
30
+ });
31
+ ref.current = editor;
32
+ }
33
+
34
+ return () => {
35
+ ref?.current?.destroy?.();
36
+ };
37
+ }, []);
38
+
39
+ return (
40
+ <ThemeProvider theme={theme}>
41
+ <StyledLabel>{property.path}</StyledLabel>
42
+ <StyledEditorWrapper>
43
+ <StyledEditor id={editorId} />
44
+ </StyledEditorWrapper>
45
+ </ThemeProvider>
46
+ );
47
+ };
48
+
49
+ export default Editor;
@@ -1,22 +1,22 @@
1
- import React from "react";
2
-
3
- import { theme } from "@adminjs/design-system";
4
- import { ThemeProvider } from "styled-components";
5
- import { parseHtml } from "../../utils/parseHtml";
6
- import { StyledEditorViewWrapper } from "./styles";
7
-
8
- const EditorList = ({ property, record }) => {
9
- const htmlContent = parseHtml(record.params[property.path]);
10
-
11
- return (
12
- <ThemeProvider theme={theme}>
13
- <StyledEditorViewWrapper>
14
- {htmlContent && (
15
- <div dangerouslySetInnerHTML={{ __html: htmlContent }} />
16
- )}
17
- </StyledEditorViewWrapper>
18
- </ThemeProvider>
19
- );
20
- };
21
-
22
- export default EditorList;
1
+ import React from "react";
2
+
3
+ import { theme } from "@adminjs/design-system";
4
+ import { ThemeProvider } from "styled-components";
5
+ import { parseHtml } from "../../utils/parseHtml";
6
+ import { StyledEditorViewWrapper } from "./styles";
7
+
8
+ const EditorList = ({ property, record }) => {
9
+ const htmlContent = parseHtml(record.params[property.path]);
10
+
11
+ return (
12
+ <ThemeProvider theme={theme}>
13
+ <StyledEditorViewWrapper>
14
+ {htmlContent && (
15
+ <div dangerouslySetInnerHTML={{ __html: htmlContent }} />
16
+ )}
17
+ </StyledEditorViewWrapper>
18
+ </ThemeProvider>
19
+ );
20
+ };
21
+
22
+ export default EditorList;
@@ -1,24 +1,24 @@
1
- import React from "react";
2
- import { ThemeProvider } from "styled-components";
3
- import { theme } from "@adminjs/design-system";
4
-
5
- import { parseHtml } from "../../utils/parseHtml";
6
-
7
- import { StyledEditorShowWrapper, StyledShowLabel } from "./styles";
8
-
9
- const EditorShow = ({ property, record }) => {
10
- const htmlContent = parseHtml(record.params[property.path]);
11
-
12
- return (
13
- <ThemeProvider theme={theme}>
14
- <StyledEditorShowWrapper>
15
- <StyledShowLabel>{property.path}</StyledShowLabel>
16
- {htmlContent && (
17
- <div dangerouslySetInnerHTML={{ __html: htmlContent }} />
18
- )}
19
- </StyledEditorShowWrapper>
20
- </ThemeProvider>
21
- );
22
- };
23
-
24
- export default EditorShow;
1
+ import React from "react";
2
+ import { ThemeProvider } from "styled-components";
3
+ import { theme } from "@adminjs/design-system";
4
+
5
+ import { parseHtml } from "../../utils/parseHtml";
6
+
7
+ import { StyledEditorShowWrapper, StyledShowLabel } from "./styles";
8
+
9
+ const EditorShow = ({ property, record }) => {
10
+ const htmlContent = parseHtml(record.params[property.path]);
11
+
12
+ return (
13
+ <ThemeProvider theme={theme}>
14
+ <StyledEditorShowWrapper>
15
+ <StyledShowLabel>{property.path}</StyledShowLabel>
16
+ {htmlContent && (
17
+ <div dangerouslySetInnerHTML={{ __html: htmlContent }} />
18
+ )}
19
+ </StyledEditorShowWrapper>
20
+ </ThemeProvider>
21
+ );
22
+ };
23
+
24
+ export default EditorShow;
@@ -1,35 +1,35 @@
1
- import Header from "@editorjs/header";
2
- import List from "@editorjs/list";
3
- import Paragraph from "@editorjs/paragraph";
4
- import Quote from "@editorjs/quote";
5
- import Table from "@editorjs/table";
6
- // @ts-ignore
7
- import AudioPlayer from "editorjs-audio-player";
8
-
9
- export const EDITOR_TOOLS = {
10
- paragraph: {
11
- class: Paragraph,
12
- inlineToolbar: true,
13
- },
14
- list: {
15
- class: List,
16
- inlineToolbar: true,
17
- },
18
- header: {
19
- class: Header,
20
- config: {
21
- placeholder: "Enter a header",
22
- levels: [2, 3, 4],
23
- defaultLevel: 2,
24
- },
25
- },
26
- table: {
27
- class: Table,
28
- inlineToolbar: true,
29
- },
30
- quote: {
31
- class: Quote,
32
- inlineToolbar: true,
33
- },
34
- audioPlayer: AudioPlayer,
35
- };
1
+ import Header from "@editorjs/header";
2
+ import List from "@editorjs/list";
3
+ import Paragraph from "@editorjs/paragraph";
4
+ import Quote from "@editorjs/quote";
5
+ import Table from "@editorjs/table";
6
+ // @ts-ignore
7
+ import AudioPlayer from "editorjs-audio-player";
8
+
9
+ export const EDITOR_TOOLS = {
10
+ paragraph: {
11
+ class: Paragraph,
12
+ inlineToolbar: true,
13
+ },
14
+ list: {
15
+ class: List,
16
+ inlineToolbar: true,
17
+ },
18
+ header: {
19
+ class: Header,
20
+ config: {
21
+ placeholder: "Enter a header",
22
+ levels: [2, 3, 4],
23
+ defaultLevel: 2,
24
+ },
25
+ },
26
+ table: {
27
+ class: Table,
28
+ inlineToolbar: true,
29
+ },
30
+ quote: {
31
+ class: Quote,
32
+ inlineToolbar: true,
33
+ },
34
+ audioPlayer: AudioPlayer,
35
+ };