@rulab/adminjs-components 0.0.13 → 0.1.0-alpha.10
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/LICENSE +21 -21
- package/dist/components/ColorStatus/ColorStatusEdit.d.ts +5 -0
- package/dist/components/ColorStatus/ColorStatusEdit.js +58 -0
- package/dist/components/ColorStatus/ColorStatusList.d.ts +4 -0
- package/dist/components/ColorStatus/ColorStatusList.js +7 -0
- package/dist/components/ColorStatus/ColorStatusShow.d.ts +4 -0
- package/dist/components/ColorStatus/ColorStatusShow.js +9 -0
- package/dist/components/ColorStatus/index.d.ts +3 -0
- package/dist/components/ColorStatus/index.js +3 -0
- package/dist/components/ColorStatus/styles.d.ts +5 -0
- package/dist/components/ColorStatus/styles.js +25 -0
- package/dist/components/ColorStatus/types.d.ts +5 -0
- package/dist/components/ColorStatus/types.js +1 -0
- package/dist/components/Editor/Editor.d.ts +11 -0
- package/dist/components/Editor/Editor.js +33 -0
- package/dist/components/Editor/EditorList.d.ts +9 -0
- package/dist/components/Editor/EditorList.js +10 -0
- package/dist/components/Editor/EditorShow.d.ts +9 -0
- package/dist/components/Editor/EditorShow.js +10 -0
- package/dist/components/Editor/config.d.ts +29 -0
- package/dist/components/Editor/config.js +26 -3
- package/dist/components/Editor/index.d.ts +3 -0
- package/dist/components/Editor/index.js +3 -1
- package/dist/components/Editor/styles.d.ts +6 -0
- package/dist/components/Editor/styles.js +140 -59
- package/dist/components/Slug/SlugEdit.d.ts +5 -0
- package/dist/components/Slug/SlugEdit.js +27 -0
- package/dist/components/Slug/SlugFeature.d.ts +7 -0
- package/dist/components/Slug/SlugFeature.js +21 -0
- package/dist/components/Slug/index.d.ts +1 -0
- package/dist/components/Slug/index.js +1 -0
- package/dist/components/Slug/styles.d.ts +4 -0
- package/dist/components/{CustomSlug → Slug}/styles.js +14 -9
- package/dist/components/StringList/SortableList/SortableList.d.ts +18 -0
- package/dist/components/StringList/SortableList/{SortableList.jsx → SortableList.js} +13 -19
- package/dist/components/StringList/SortableList/components/SortableItem/DragHandle.d.ts +7 -0
- package/dist/components/StringList/SortableList/components/SortableItem/DragHandle.js +8 -0
- package/dist/components/StringList/SortableList/components/SortableItem/SortableItem.d.ts +8 -0
- package/dist/components/StringList/SortableList/components/SortableItem/{SortableItem.jsx → SortableItem.js} +7 -11
- package/dist/components/StringList/SortableList/components/SortableItem/styles.d.ts +2 -0
- package/dist/components/StringList/SortableList/components/SortableItem/styles.js +18 -18
- package/dist/components/StringList/SortableList/components/SortableItem/types.d.ts +6 -0
- package/dist/components/StringList/SortableList/components/index.d.ts +2 -0
- package/dist/components/StringList/SortableList/index.d.ts +1 -0
- package/dist/components/StringList/SortableList/styles.d.ts +1 -0
- package/dist/components/StringList/SortableList/styles.js +6 -6
- package/dist/components/StringList/StringList.d.ts +8 -0
- package/dist/components/StringList/StringList.js +60 -0
- package/dist/components/StringList/StringListShow.d.ts +7 -0
- package/dist/components/StringList/StringListShow.js +14 -0
- package/dist/components/StringList/constants.d.ts +1 -0
- package/dist/components/StringList/constants.js +1 -0
- package/dist/components/StringList/index.d.ts +2 -0
- package/dist/components/StringList/index.js +2 -1
- package/dist/components/StringList/styles.d.ts +8 -0
- package/dist/components/StringList/styles.js +28 -11
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.js +9 -2
- package/dist/index.d.ts +2 -44
- package/dist/index.js +2 -757
- package/dist/scripts/fix-import-extensions.d.ts +1 -0
- package/dist/scripts/fix-import-extensions.js +39 -0
- package/dist/utils/bundle-component.d.ts +2 -0
- package/dist/utils/bundle-component.js +8 -0
- package/{src/utils/index.ts → dist/utils/index.d.ts} +0 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/parseHtml.d.ts +1 -0
- package/dist/utils/parseHtml.js +37 -0
- package/dist/utils/slugifyImport.d.ts +3 -0
- package/dist/utils/slugifyImport.js +1 -1
- package/dist/utils/slugifyTitle.d.ts +1 -0
- package/dist/utils/slugifyTitle.js +3 -3
- package/package.json +14 -8
- package/src/components/ColorStatus/ColorStatusEdit.d.ts +5 -0
- package/src/components/ColorStatus/ColorStatusEdit.js +58 -0
- package/src/components/ColorStatus/ColorStatusEdit.tsx +94 -94
- package/src/components/ColorStatus/ColorStatusList.d.ts +4 -0
- package/src/components/ColorStatus/ColorStatusList.js +7 -0
- package/src/components/ColorStatus/ColorStatusList.tsx +20 -20
- package/src/components/ColorStatus/ColorStatusShow.d.ts +4 -0
- package/src/components/ColorStatus/ColorStatusShow.js +9 -0
- package/src/components/ColorStatus/ColorStatusShow.tsx +23 -23
- package/src/components/ColorStatus/index.d.ts +3 -0
- package/src/components/ColorStatus/index.js +3 -0
- package/src/components/ColorStatus/index.ts +3 -3
- package/src/components/ColorStatus/styles.d.ts +5 -0
- package/src/components/ColorStatus/styles.js +25 -0
- package/src/components/ColorStatus/styles.ts +30 -30
- package/src/components/ColorStatus/types.d.ts +5 -0
- package/src/components/ColorStatus/types.js +1 -0
- package/src/components/ColorStatus/types.ts +5 -5
- package/src/components/Editor/Editor.d.ts +8 -0
- package/src/components/Editor/Editor.js +36 -0
- package/src/components/Editor/Editor.jsx +49 -49
- package/src/components/Editor/EditorList.d.ts +6 -0
- package/src/components/Editor/EditorList.js +11 -0
- package/src/components/Editor/EditorList.jsx +22 -22
- package/src/components/Editor/EditorShow.d.ts +6 -0
- package/src/components/Editor/EditorShow.js +13 -0
- package/src/components/Editor/EditorShow.jsx +24 -24
- package/src/components/Editor/config.d.ts +29 -0
- package/src/components/Editor/config.js +34 -0
- package/src/components/Editor/config.ts +35 -35
- package/src/components/Editor/index.d.ts +3 -0
- package/src/components/Editor/index.js +3 -0
- package/src/components/Editor/index.ts +3 -3
- package/src/components/Editor/styles.d.ts +6 -0
- package/src/components/Editor/styles.js +145 -0
- package/src/components/Editor/styles.ts +151 -151
- package/src/components/Slug/SlugEdit.d.ts +5 -0
- package/src/components/Slug/SlugEdit.js +27 -0
- package/src/components/{CustomSlug/CustomSlug.tsx → Slug/SlugEdit.tsx} +68 -68
- package/src/components/Slug/SlugFeature.d.ts +7 -0
- package/src/components/Slug/SlugFeature.js +21 -0
- package/src/components/Slug/SlugFeature.ts +30 -0
- package/src/components/Slug/index.d.ts +1 -0
- package/src/components/Slug/index.js +1 -0
- package/src/components/Slug/index.ts +1 -0
- package/src/components/Slug/styles.d.ts +4 -0
- package/src/components/Slug/styles.js +20 -0
- package/src/components/{CustomSlug → Slug}/styles.ts +24 -24
- package/src/components/StringList/SortableList/SortableList.d.ts +18 -0
- package/src/components/StringList/SortableList/SortableList.js +37 -0
- package/src/components/StringList/SortableList/SortableList.tsx +98 -98
- package/src/components/StringList/SortableList/components/SortableItem/DragHandle.d.ts +7 -0
- package/src/components/StringList/SortableList/components/SortableItem/DragHandle.js +8 -0
- package/src/components/StringList/SortableList/components/SortableItem/DragHandle.tsx +20 -20
- package/src/components/StringList/SortableList/components/SortableItem/SortableItem.d.ts +8 -0
- package/src/components/StringList/SortableList/components/SortableItem/SortableItem.js +28 -0
- package/src/components/StringList/SortableList/components/SortableItem/SortableItem.tsx +59 -59
- package/src/components/StringList/SortableList/components/SortableItem/styles.d.ts +2 -0
- package/src/components/StringList/SortableList/components/SortableItem/styles.js +20 -0
- package/src/components/StringList/SortableList/components/SortableItem/styles.ts +22 -22
- package/src/components/StringList/SortableList/components/SortableItem/types.d.ts +6 -0
- package/src/components/StringList/SortableList/components/SortableItem/types.js +1 -0
- package/src/components/StringList/SortableList/components/SortableItem/types.ts +7 -7
- package/src/components/StringList/SortableList/components/index.d.ts +2 -0
- package/src/components/StringList/SortableList/components/index.js +2 -0
- package/src/components/StringList/SortableList/components/index.ts +2 -2
- package/src/components/StringList/SortableList/index.d.ts +1 -0
- package/src/components/StringList/SortableList/index.js +1 -0
- package/src/components/StringList/SortableList/index.ts +1 -1
- package/src/components/StringList/SortableList/styles.d.ts +1 -0
- package/src/components/StringList/SortableList/styles.js +8 -0
- package/src/components/StringList/SortableList/styles.ts +9 -9
- package/src/components/StringList/StringList.d.ts +8 -0
- package/src/components/StringList/StringList.js +60 -0
- package/src/components/StringList/StringList.tsx +136 -136
- package/src/components/StringList/StringListShow.d.ts +7 -0
- package/src/components/StringList/StringListShow.js +14 -0
- package/src/components/StringList/StringListShow.tsx +37 -37
- package/src/components/StringList/constants.d.ts +1 -0
- package/src/components/StringList/constants.js +1 -0
- package/src/components/StringList/constants.ts +1 -1
- package/src/components/StringList/index.d.ts +2 -0
- package/src/components/StringList/index.js +2 -0
- package/src/components/StringList/index.ts +2 -2
- package/src/components/StringList/styles.d.ts +8 -0
- package/src/components/StringList/styles.js +33 -0
- package/src/components/StringList/styles.ts +41 -41
- package/src/components/index.d.ts +7 -0
- package/src/components/index.js +10 -0
- package/src/components/index.ts +10 -9
- package/dist/bundle.js +0 -8
- package/dist/components/CustomSlug/CustomSlug.jsx +0 -29
- package/dist/components/CustomSlug/index.js +0 -1
- package/dist/components/StringList/SortableList/components/SortableItem/DragHandle.jsx +0 -10
- package/dist/components/StringList/StringList.jsx +0 -67
- package/dist/editorFeature.js +0 -16
- package/dist/index.cjs +0 -784
- package/dist/index.d.cts +0 -44
- package/dist/index.d.mts +0 -8
- package/dist/index.mjs +0 -37
- package/src/components/CustomSlug/index.ts +0 -1
- package/src/index.ts +0 -2
- package/src/types.d.ts +0 -3
- package/src/utils/parseHtml.ts +0 -56
- package/src/utils/slugifyImport.ts +0 -4
- package/src/utils/slugifyTitle.ts +0 -11
- package/tsconfig.json +0 -17
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Roman Daud
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Roman Daud
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
|
+
import Select from "react-select";
|
|
3
|
+
import chroma from "chroma-js";
|
|
4
|
+
import { ColorStatusWrapper, Label } from "./styles.js";
|
|
5
|
+
const dot = (color = "transparent") => ({
|
|
6
|
+
alignItems: "center",
|
|
7
|
+
display: "flex",
|
|
8
|
+
":before": {
|
|
9
|
+
backgroundColor: color,
|
|
10
|
+
borderRadius: 10,
|
|
11
|
+
content: '" "',
|
|
12
|
+
display: "block",
|
|
13
|
+
marginRight: 8,
|
|
14
|
+
height: 10,
|
|
15
|
+
width: 10,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
const colorStyles = {
|
|
19
|
+
control: (styles) => ({ ...styles, backgroundColor: "white" }),
|
|
20
|
+
option: (styles, { data, isDisabled, isFocused, isSelected }) => {
|
|
21
|
+
const color = chroma(data.color);
|
|
22
|
+
return {
|
|
23
|
+
...styles,
|
|
24
|
+
backgroundColor: isSelected
|
|
25
|
+
? data.color
|
|
26
|
+
: isFocused
|
|
27
|
+
? color.alpha(0.1).css()
|
|
28
|
+
: undefined,
|
|
29
|
+
color: isSelected
|
|
30
|
+
? chroma.contrast(color, "white") > 2
|
|
31
|
+
? "white"
|
|
32
|
+
: "black"
|
|
33
|
+
: data.color,
|
|
34
|
+
":active": {
|
|
35
|
+
...styles[":active"],
|
|
36
|
+
backgroundColor: isSelected ? data.color : color.alpha(0.3).css(),
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
input: (styles) => ({ ...styles, ...dot() }),
|
|
41
|
+
placeholder: (styles) => ({ ...styles, ...dot("#ccc") }),
|
|
42
|
+
singleValue: (styles, { data }) => ({ ...styles, ...dot(data.color) }),
|
|
43
|
+
};
|
|
44
|
+
const ColorStatus = ({ property, record, onChange }) => {
|
|
45
|
+
const availableValues = property.availableValues;
|
|
46
|
+
const currentOption = availableValues.find((item) => item.value === record.params[property.path]);
|
|
47
|
+
const [selectOption, setCurrentOption] = useState(currentOption);
|
|
48
|
+
const handleSelectChange = (option) => {
|
|
49
|
+
setCurrentOption(option);
|
|
50
|
+
};
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
onChange(property.path, selectOption?.value);
|
|
53
|
+
}, [selectOption]);
|
|
54
|
+
return (React.createElement(ColorStatusWrapper, null,
|
|
55
|
+
React.createElement(Label, null, property.path),
|
|
56
|
+
React.createElement(Select, { className: "basic-single", classNamePrefix: "select", defaultValue: selectOption ?? availableValues[0], onChange: handleSelectChange, isClearable: true, name: "color", options: availableValues, styles: colorStyles })));
|
|
57
|
+
};
|
|
58
|
+
export default ColorStatus;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ColorStatusBadge } from "./styles.js";
|
|
3
|
+
const ColorStatusList = ({ property, record }) => {
|
|
4
|
+
const currentOption = property.availableValues?.find((item) => item.value === record.params[property.path]);
|
|
5
|
+
return (React.createElement(ColorStatusBadge, { color: currentOption.color }, record.params[property.path]));
|
|
6
|
+
};
|
|
7
|
+
export default ColorStatusList;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ColorStatusBadgeWrapper, ColorStatusBadge, ShowLabel } from "./styles.js";
|
|
3
|
+
const ColorStatusShow = ({ property, record }) => {
|
|
4
|
+
const currentOption = property.availableValues?.find((item) => item.value === record.params[property.path]);
|
|
5
|
+
return (React.createElement(ColorStatusBadgeWrapper, null,
|
|
6
|
+
React.createElement(ShowLabel, null, property.path),
|
|
7
|
+
React.createElement(ColorStatusBadge, { color: currentOption.color }, record.params[property.path])));
|
|
8
|
+
};
|
|
9
|
+
export default ColorStatusShow;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { styled } from "@adminjs/design-system/styled-components";
|
|
2
|
+
export const ColorStatusWrapper = styled.div `
|
|
3
|
+
margin-bottom: 24px;
|
|
4
|
+
`;
|
|
5
|
+
export const Label = styled.div `
|
|
6
|
+
font-size: 12px;
|
|
7
|
+
margin-bottom: 8px;
|
|
8
|
+
`;
|
|
9
|
+
export const ShowLabel = styled.div `
|
|
10
|
+
font-size: 12px;
|
|
11
|
+
margin-bottom: 8px;
|
|
12
|
+
color: rgb(137, 138, 154);
|
|
13
|
+
`;
|
|
14
|
+
export const ColorStatusBadgeWrapper = styled.div `
|
|
15
|
+
margin-bottom: 20px;
|
|
16
|
+
`;
|
|
17
|
+
export const ColorStatusBadge = styled.div `
|
|
18
|
+
background-color: ${(props) => props.color};
|
|
19
|
+
width: fit-content;
|
|
20
|
+
padding: 5px 10px;
|
|
21
|
+
border-radius: 20px;
|
|
22
|
+
font-size: 12px;
|
|
23
|
+
color: white;
|
|
24
|
+
white-space: nowrap;
|
|
25
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default Editor;
|
|
2
|
+
declare function Editor({ property, record, onChangeAdmin, editorId }: {
|
|
3
|
+
property: any;
|
|
4
|
+
record: any;
|
|
5
|
+
onChangeAdmin: any;
|
|
6
|
+
editorId: any;
|
|
7
|
+
}): React.FunctionComponentElement<{
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
theme: import("styled-components").DefaultTheme | ((outerTheme?: import("styled-components").DefaultTheme | undefined) => import("styled-components").DefaultTheme);
|
|
10
|
+
}>;
|
|
11
|
+
import React from "react";
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
import { StyledLabel, StyledEditor, StyledEditorWrapper } from "./styles.js";
|
|
6
|
+
import { EDITOR_TOOLS } from "./config.js";
|
|
7
|
+
const Editor = ({ property, record, onChangeAdmin, editorId }) => {
|
|
8
|
+
const [jsonData, setJsonData] = useState();
|
|
9
|
+
const isSavedData = Boolean(record.params[property.path]);
|
|
10
|
+
const ref = useRef();
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
onChangeAdmin(property.path, jsonData);
|
|
13
|
+
}, [jsonData]);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!ref.current) {
|
|
16
|
+
const editor = new EditorJS({
|
|
17
|
+
holder: editorId,
|
|
18
|
+
tools: EDITOR_TOOLS,
|
|
19
|
+
data: isSavedData ? JSON.parse(record.params[property.path]) : "",
|
|
20
|
+
async onChange(api, event) {
|
|
21
|
+
const data = await api.saver.save();
|
|
22
|
+
setJsonData(JSON.stringify(data));
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
ref.current = editor;
|
|
26
|
+
}
|
|
27
|
+
return () => {
|
|
28
|
+
ref?.current?.destroy?.();
|
|
29
|
+
};
|
|
30
|
+
}, []);
|
|
31
|
+
return (React.createElement(ThemeProvider, { theme: theme }, React.createElement(StyledLabel, null, property.path), React.createElement(StyledEditorWrapper, null, React.createElement(StyledEditor, { id: editorId }))));
|
|
32
|
+
};
|
|
33
|
+
export default Editor;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default EditorList;
|
|
2
|
+
declare function EditorList({ property, record }: {
|
|
3
|
+
property: any;
|
|
4
|
+
record: any;
|
|
5
|
+
}): React.FunctionComponentElement<{
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
theme: import("styled-components").DefaultTheme | ((outerTheme?: import("styled-components").DefaultTheme | undefined) => import("styled-components").DefaultTheme);
|
|
8
|
+
}>;
|
|
9
|
+
import React from "react";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { theme } from "@adminjs/design-system";
|
|
3
|
+
import { ThemeProvider } from "styled-components";
|
|
4
|
+
import { parseHtml } from "../../utils/parseHtml.js";
|
|
5
|
+
import { StyledEditorViewWrapper } from "./styles.js";
|
|
6
|
+
const EditorList = ({ property, record }) => {
|
|
7
|
+
const htmlContent = parseHtml(record.params[property.path]);
|
|
8
|
+
return (React.createElement(ThemeProvider, { theme: theme }, React.createElement(StyledEditorViewWrapper, null, htmlContent && (React.createElement("div", { dangerouslySetInnerHTML: { __html: htmlContent } })))));
|
|
9
|
+
};
|
|
10
|
+
export default EditorList;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default EditorShow;
|
|
2
|
+
declare function EditorShow({ property, record }: {
|
|
3
|
+
property: any;
|
|
4
|
+
record: any;
|
|
5
|
+
}): React.FunctionComponentElement<{
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
theme: import("styled-components").DefaultTheme | ((outerTheme?: import("styled-components").DefaultTheme | undefined) => import("styled-components").DefaultTheme);
|
|
8
|
+
}>;
|
|
9
|
+
import React from "react";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ThemeProvider } from "styled-components";
|
|
3
|
+
import { theme } from "@adminjs/design-system";
|
|
4
|
+
import { parseHtml } from "../../utils/parseHtml.js";
|
|
5
|
+
import { StyledEditorShowWrapper, StyledShowLabel } from "./styles.js";
|
|
6
|
+
const EditorShow = ({ property, record }) => {
|
|
7
|
+
const htmlContent = parseHtml(record.params[property.path]);
|
|
8
|
+
return (React.createElement(ThemeProvider, { theme: theme }, React.createElement(StyledEditorShowWrapper, null, React.createElement(StyledShowLabel, null, property.path), htmlContent && (React.createElement("div", { dangerouslySetInnerHTML: { __html: htmlContent } })))));
|
|
9
|
+
};
|
|
10
|
+
export default EditorShow;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import Quote from "@editorjs/quote";
|
|
2
|
+
import Table from "@editorjs/table";
|
|
3
|
+
export declare const EDITOR_TOOLS: {
|
|
4
|
+
paragraph: {
|
|
5
|
+
class: any;
|
|
6
|
+
inlineToolbar: boolean;
|
|
7
|
+
};
|
|
8
|
+
list: {
|
|
9
|
+
class: any;
|
|
10
|
+
inlineToolbar: boolean;
|
|
11
|
+
};
|
|
12
|
+
header: {
|
|
13
|
+
class: any;
|
|
14
|
+
config: {
|
|
15
|
+
placeholder: string;
|
|
16
|
+
levels: number[];
|
|
17
|
+
defaultLevel: number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
table: {
|
|
21
|
+
class: typeof Table;
|
|
22
|
+
inlineToolbar: boolean;
|
|
23
|
+
};
|
|
24
|
+
quote: {
|
|
25
|
+
class: typeof Quote;
|
|
26
|
+
inlineToolbar: boolean;
|
|
27
|
+
};
|
|
28
|
+
audioPlayer: any;
|
|
29
|
+
};
|
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
import Header from "@editorjs/header";
|
|
2
|
-
import Paragraph from "@editorjs/paragraph";
|
|
3
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";
|
|
4
8
|
export const EDITOR_TOOLS = {
|
|
5
9
|
paragraph: {
|
|
6
10
|
class: Paragraph,
|
|
7
11
|
inlineToolbar: true,
|
|
8
12
|
},
|
|
9
|
-
list:
|
|
10
|
-
|
|
13
|
+
list: {
|
|
14
|
+
class: List,
|
|
15
|
+
inlineToolbar: true,
|
|
16
|
+
},
|
|
17
|
+
header: {
|
|
18
|
+
class: Header,
|
|
19
|
+
config: {
|
|
20
|
+
placeholder: "Enter a header",
|
|
21
|
+
levels: [2, 3, 4],
|
|
22
|
+
defaultLevel: 2,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
table: {
|
|
26
|
+
class: Table,
|
|
27
|
+
inlineToolbar: true,
|
|
28
|
+
},
|
|
29
|
+
quote: {
|
|
30
|
+
class: Quote,
|
|
31
|
+
inlineToolbar: true,
|
|
32
|
+
},
|
|
33
|
+
audioPlayer: AudioPlayer,
|
|
11
34
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const StyledLabel: any;
|
|
2
|
+
export declare const StyledShowLabel: any;
|
|
3
|
+
export declare const StyledEditorWrapper: any;
|
|
4
|
+
export declare const StyledEditorViewWrapper: any;
|
|
5
|
+
export declare const StyledEditorShowWrapper: any;
|
|
6
|
+
export declare const StyledEditor: any;
|
|
@@ -1,64 +1,145 @@
|
|
|
1
1
|
import { Box } from "@adminjs/design-system";
|
|
2
2
|
import { styled } from "@adminjs/design-system/styled-components";
|
|
3
|
-
export const
|
|
4
|
-
font-size: 12px;
|
|
5
|
-
margin-bottom: 8px;
|
|
3
|
+
export const StyledLabel = styled.div `
|
|
4
|
+
font-size: 12px;
|
|
5
|
+
margin-bottom: 8px;
|
|
6
|
+
text-transform: capitalize;
|
|
6
7
|
`;
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
export const StyledShowLabel = styled(StyledLabel) `
|
|
9
|
+
color: rgb(137, 138, 154);
|
|
10
|
+
font-weight: 300;
|
|
10
11
|
`;
|
|
11
|
-
export const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
12
|
+
export const StyledEditorWrapper = styled(Box) `
|
|
13
|
+
padding: 12px;
|
|
14
|
+
margin-bottom: 24px;
|
|
15
|
+
border: 1px solid rgb(187, 195, 203);
|
|
16
|
+
`;
|
|
17
|
+
export const StyledEditorViewWrapper = styled(Box) `
|
|
18
|
+
h1,
|
|
19
|
+
h2,
|
|
20
|
+
h3 {
|
|
21
|
+
margin-bottom: 5px;
|
|
22
|
+
font-weight: bold;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
h1 {
|
|
26
|
+
font-size: 18px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
h2 {
|
|
30
|
+
font-size: 16px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
h3 {
|
|
34
|
+
font-size: 14px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
p {
|
|
38
|
+
margin-bottom: 8px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
ol,
|
|
42
|
+
ul {
|
|
43
|
+
margin-left: 20px;
|
|
44
|
+
margin-bottom: 8px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
ol {
|
|
48
|
+
list-style: auto;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
ul {
|
|
52
|
+
list-style: inherit;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
table,
|
|
56
|
+
audio {
|
|
57
|
+
margin: 16px 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
table,
|
|
61
|
+
th,
|
|
62
|
+
td {
|
|
63
|
+
border: 1px solid;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
th {
|
|
67
|
+
font-weight: bold;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
th,
|
|
71
|
+
td {
|
|
72
|
+
padding: 4px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
blockquote {
|
|
76
|
+
display: block;
|
|
77
|
+
padding: 5px 8px;
|
|
78
|
+
width: fit-content;
|
|
79
|
+
border-radius: 4px;
|
|
80
|
+
background-color: #e6e6e6;
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
export const StyledEditorShowWrapper = styled(StyledEditorViewWrapper) `
|
|
84
|
+
margin-bottom: 24px;
|
|
85
|
+
`;
|
|
86
|
+
export const StyledEditor = styled.div `
|
|
87
|
+
audio,
|
|
88
|
+
.cdx-block,
|
|
89
|
+
.ce-header {
|
|
90
|
+
padding-left: 58px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
input {
|
|
94
|
+
margin-left: 58px;
|
|
95
|
+
width: auto;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.cdx-list {
|
|
99
|
+
padding-left: 85px;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.ce-block__content {
|
|
103
|
+
width: 100%;
|
|
104
|
+
max-width: none;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.ce-toolbar__content {
|
|
108
|
+
max-width: none;
|
|
109
|
+
left: 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.ce-toolbar__actions {
|
|
113
|
+
left: 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
h1.ce-header {
|
|
117
|
+
font-size: 22px;
|
|
118
|
+
font-weight: bold;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
h2.ce-header {
|
|
122
|
+
font-size: 20px;
|
|
123
|
+
font-weight: bold;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
h3.ce-header {
|
|
127
|
+
font-size: 18px;
|
|
128
|
+
font-weight: bold;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
h4.ce-header {
|
|
132
|
+
font-size: 16px;
|
|
133
|
+
font-weight: bold;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
h5.ce-header {
|
|
137
|
+
font-size: 15px;
|
|
138
|
+
font-weight: bold;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
h6.ce-header {
|
|
142
|
+
font-size: 14px;
|
|
143
|
+
font-weight: bold;
|
|
144
|
+
}
|
|
64
145
|
`;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { useEffect, useState, } from "react";
|
|
2
|
+
import { ThemeProvider } from "styled-components";
|
|
3
|
+
import { theme } from "@adminjs/design-system";
|
|
4
|
+
import { slugifyTitle } from "../../utils/index.js";
|
|
5
|
+
import { StyledCustomInput, StyledGenerateButton, StyledInputWrapper, StyledLabel, } from "./styles.js";
|
|
6
|
+
const SlugEdit = ({ property, record, resource, onChange, }) => {
|
|
7
|
+
const [inputValue, setInputValue] = useState(record.params.slug);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
onChange(property.path, inputValue);
|
|
10
|
+
}, [inputValue]);
|
|
11
|
+
return (React.createElement(ThemeProvider, { theme: theme },
|
|
12
|
+
React.createElement(StyledLabel, { htmlFor: "customSlug" }, property.path),
|
|
13
|
+
React.createElement(StyledInputWrapper, null,
|
|
14
|
+
React.createElement(StyledCustomInput, { id: property.path, name: property.path, value: inputValue, onChange: handleInput }),
|
|
15
|
+
React.createElement(StyledGenerateButton, { variant: "outlined", onClick: generateSlug }, "Generate Slug"))));
|
|
16
|
+
function handleInput(e) {
|
|
17
|
+
setInputValue(e.target.value);
|
|
18
|
+
}
|
|
19
|
+
function generateSlug(e) {
|
|
20
|
+
e.preventDefault();
|
|
21
|
+
const slugSource = record.params[property.props.sourceField ?? resource.titleProperty.name];
|
|
22
|
+
if (slugSource) {
|
|
23
|
+
setInputValue(slugifyTitle(slugSource));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export default SlugEdit;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { buildFeature } from "adminjs";
|
|
2
|
+
import { bundleComponent } from "../../utils/bundle-component.js";
|
|
3
|
+
const COMPONENT_NAME = 'Slug';
|
|
4
|
+
const SlugFeature = (config) => {
|
|
5
|
+
const { componentLoader, key } = config;
|
|
6
|
+
const slugFeature = () => {
|
|
7
|
+
const editComponent = bundleComponent(componentLoader, COMPONENT_NAME, 'SlugEdit.js');
|
|
8
|
+
return buildFeature({
|
|
9
|
+
properties: {
|
|
10
|
+
[key]: {
|
|
11
|
+
isVisible: { show: false, edit: true, list: false, filter: false },
|
|
12
|
+
components: {
|
|
13
|
+
edit: editComponent,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
return slugFeature();
|
|
20
|
+
};
|
|
21
|
+
export default SlugFeature;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./SlugFeature.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./SlugFeature.js";
|