@team-monolith/cds 0.28.0 → 0.29.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.
- package/dist/components/Button.d.ts +1 -1
- package/dist/components/Button.js +14 -12
- package/dist/components/SquareButton.js +13 -12
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/patterns/ReactEditorJS/FormEditorJS.d.ts +8 -0
- package/dist/patterns/ReactEditorJS/FormEditorJS.js +133 -0
- package/dist/patterns/ReactEditorJS/Layout.d.ts +6 -0
- package/dist/patterns/ReactEditorJS/Layout.js +14 -0
- package/dist/patterns/ReactEditorJS/ReactEditorJS.d.ts +11 -0
- package/dist/patterns/ReactEditorJS/ReactEditorJS.js +137 -0
- package/dist/patterns/ReactEditorJS/customTools/block/Callout.d.ts +40 -0
- package/dist/patterns/ReactEditorJS/customTools/block/Callout.js +135 -0
- package/dist/patterns/ReactEditorJS/customTools/block/Delimiter.d.ts +10 -0
- package/dist/patterns/ReactEditorJS/customTools/block/Delimiter.js +50 -0
- package/dist/patterns/ReactEditorJS/customTools/block/Header.d.ts +60 -0
- package/dist/patterns/ReactEditorJS/customTools/block/Header.js +179 -0
- package/dist/patterns/ReactEditorJS/customTools/block/Image.d.ts +21 -0
- package/dist/patterns/ReactEditorJS/customTools/block/Image.js +84 -0
- package/dist/patterns/ReactEditorJS/customTools/block/NestedList.d.ts +28 -0
- package/dist/patterns/ReactEditorJS/customTools/block/NestedList.js +134 -0
- package/dist/patterns/ReactEditorJS/customTools/block/Quote.d.ts +40 -0
- package/dist/patterns/ReactEditorJS/customTools/block/Quote.js +135 -0
- package/dist/patterns/ReactEditorJS/customTools/block/Raw.d.ts +26 -0
- package/dist/patterns/ReactEditorJS/customTools/block/Raw.js +119 -0
- package/dist/patterns/ReactEditorJS/customTools/block/Table.d.ts +10 -0
- package/dist/patterns/ReactEditorJS/customTools/block/Table.js +67 -0
- package/dist/patterns/ReactEditorJS/customTools/index.d.ts +16 -0
- package/dist/patterns/ReactEditorJS/customTools/index.js +16 -0
- package/dist/patterns/ReactEditorJS/customTools/inline/Bold.d.ts +52 -0
- package/dist/patterns/ReactEditorJS/customTools/inline/Bold.js +92 -0
- package/dist/patterns/ReactEditorJS/customTools/inline/InlineCode.d.ts +4 -0
- package/dist/patterns/ReactEditorJS/customTools/inline/InlineCode.js +32 -0
- package/dist/patterns/ReactEditorJS/customTools/inline/Italic.d.ts +48 -0
- package/dist/patterns/ReactEditorJS/customTools/inline/Italic.js +88 -0
- package/dist/patterns/ReactEditorJS/customTools/inline/StrikeThrough.d.ts +4 -0
- package/dist/patterns/ReactEditorJS/customTools/inline/StrikeThrough.js +32 -0
- package/dist/patterns/ReactEditorJS/customTools/inline/Underline.d.ts +4 -0
- package/dist/patterns/ReactEditorJS/customTools/inline/Underline.js +32 -0
- package/dist/patterns/ReactEditorJS/customTools/tunes/Delete.d.ts +30 -0
- package/dist/patterns/ReactEditorJS/customTools/tunes/Delete.js +40 -0
- package/dist/patterns/ReactEditorJS/customTools/tunes/MoveDown.d.ts +34 -0
- package/dist/patterns/ReactEditorJS/customTools/tunes/MoveDown.js +62 -0
- package/dist/patterns/ReactEditorJS/customTools/tunes/MoveUp.d.ts +34 -0
- package/dist/patterns/ReactEditorJS/customTools/tunes/MoveUp.js +72 -0
- package/dist/patterns/ReactEditorJS/i18n.d.ts +127 -0
- package/dist/patterns/ReactEditorJS/i18n.js +127 -0
- package/dist/patterns/ReactEditorJS/index.d.ts +2 -0
- package/dist/patterns/ReactEditorJS/index.js +2 -0
- package/dist/patterns/ReactEditorJS/tools.d.ts +78 -0
- package/dist/patterns/ReactEditorJS/tools.js +104 -0
- package/dist/patterns/SegmentedControl/SegmentedControlButton.js +1 -1
- package/dist/patterns/SegmentedControl/SegmentedControlGroup.js +1 -1
- package/package.json +15 -1
- package/dist/components/Popover.d.ts +0 -16
- package/dist/components/Popover.js +0 -40
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { PolymorphicProps } from "@mui/base";
|
|
3
|
-
export type ButtonColor = "primary" | "grey" | "danger" | "textNeutral" | "textDanger" | "textPrimary" | "black";
|
|
3
|
+
export type ButtonColor = "primary" | "grey" | "danger" | "textNeutral" | "textDanger" | "textPrimary" | "black" | "white";
|
|
4
4
|
export type ButtonSize = "large" | "medium" | "small" | "xsmall";
|
|
5
5
|
export interface ButtonOwnProps<RootComponentType extends React.ElementType> {
|
|
6
6
|
className?: string;
|
|
@@ -46,19 +46,21 @@ var COLOR_TO_BUTTON_STYLE = function (theme, color, disabled) {
|
|
|
46
46
|
? css(templateObject_21 || (templateObject_21 = __makeTemplateObject(["\n background: none;\n color: ", ";\n "], ["\n background: none;\n color: ", ";\n "])), theme.color.foreground.primaryDisabled) : css(templateObject_23 || (templateObject_23 = __makeTemplateObject(["\n background: none;\n color: ", ";\n ", "\n "], ["\n background: none;\n color: ", ";\n ", "\n "])), theme.color.foreground.primary, HOVER(css(templateObject_22 || (templateObject_22 = __makeTemplateObject(["\n background: ", ";\n color: ", ";\n "], ["\n background: ", ";\n color: ", ";\n "])), theme.color.background.neutralAltActive, theme.color.foreground.primary)))),
|
|
47
47
|
black: css(templateObject_28 || (templateObject_28 = __makeTemplateObject(["\n ", "\n "], ["\n ", "\n "])), disabled
|
|
48
48
|
? css(templateObject_25 || (templateObject_25 = __makeTemplateObject(["\n background: ", ";\n color: ", ";\n "], ["\n background: ", ";\n color: ", ";\n "])), theme.color.background.blackDisabled, theme.color.foreground.neutralAltDisabled) : css(templateObject_27 || (templateObject_27 = __makeTemplateObject(["\n background: ", ";\n color: ", ";\n ", "\n "], ["\n background: ", ";\n color: ", ";\n ", "\n "])), theme.color.background.black, theme.color.foreground.neutralAlt, HOVER(css(templateObject_26 || (templateObject_26 = __makeTemplateObject(["\n background: ", ";\n color: ", ";\n "], ["\n background: ", ";\n color: ", ";\n "])), theme.color.background.blackActive, theme.color.foreground.neutralAlt)))),
|
|
49
|
+
white: css(templateObject_32 || (templateObject_32 = __makeTemplateObject(["\n ", "\n "], ["\n ", "\n "])), disabled
|
|
50
|
+
? css(templateObject_29 || (templateObject_29 = __makeTemplateObject(["\n background: ", ";\n color: ", ";\n "], ["\n background: ", ";\n color: ", ";\n "])), theme.color.background.neutralAltDisabled, theme.color.foreground.neutralBaseDisabled) : css(templateObject_31 || (templateObject_31 = __makeTemplateObject(["\n background: ", ";\n color: ", ";\n ", "\n "], ["\n background: ", ";\n color: ", ";\n ", "\n "])), theme.color.background.neutralBase, theme.color.foreground.neutralBase, HOVER(css(templateObject_30 || (templateObject_30 = __makeTemplateObject(["\n background: ", ";\n color: ", ";\n "], ["\n background: ", ";\n color: ", ";\n "])), theme.color.background.neutralAltActive, theme.color.foreground.neutralBase)))),
|
|
49
51
|
})[color];
|
|
50
52
|
};
|
|
51
53
|
var SIZE_TO_BUTTON_STYLE = {
|
|
52
|
-
large: css(
|
|
53
|
-
medium: css(
|
|
54
|
-
small: css(
|
|
55
|
-
xsmall: css(
|
|
54
|
+
large: css(templateObject_33 || (templateObject_33 = __makeTemplateObject(["\n padding: 16px 20px;\n gap: 10px;\n\n svg {\n width: 24px;\n height: 24px;\n }\n "], ["\n padding: 16px 20px;\n gap: 10px;\n\n svg {\n width: 24px;\n height: 24px;\n }\n "]))),
|
|
55
|
+
medium: css(templateObject_34 || (templateObject_34 = __makeTemplateObject(["\n padding: 14px 16px;\n gap: 8px;\n\n svg {\n width: 20px;\n height: 20px;\n }\n "], ["\n padding: 14px 16px;\n gap: 8px;\n\n svg {\n width: 20px;\n height: 20px;\n }\n "]))),
|
|
56
|
+
small: css(templateObject_35 || (templateObject_35 = __makeTemplateObject(["\n padding: 10px 12px;\n gap: 8px;\n\n svg {\n width: 16px;\n height: 16px;\n }\n "], ["\n padding: 10px 12px;\n gap: 8px;\n\n svg {\n width: 16px;\n height: 16px;\n }\n "]))),
|
|
57
|
+
xsmall: css(templateObject_36 || (templateObject_36 = __makeTemplateObject(["\n padding: 6px 8px;\n gap: 4px;\n\n svg {\n width: 12px;\n height: 12px;\n }\n "], ["\n padding: 6px 8px;\n gap: 4px;\n\n svg {\n width: 12px;\n height: 12px;\n }\n "]))),
|
|
56
58
|
};
|
|
57
59
|
var SIZE_TO_LABEL_STYLE = {
|
|
58
|
-
large: css(
|
|
59
|
-
medium: css(
|
|
60
|
-
small: css(
|
|
61
|
-
xsmall: css(
|
|
60
|
+
large: css(templateObject_37 || (templateObject_37 = __makeTemplateObject(["\n font-size: 20px;\n line-height: 24px;\n "], ["\n font-size: 20px;\n line-height: 24px;\n "]))),
|
|
61
|
+
medium: css(templateObject_38 || (templateObject_38 = __makeTemplateObject(["\n font-size: 18px;\n line-height: 20px;\n "], ["\n font-size: 18px;\n line-height: 20px;\n "]))),
|
|
62
|
+
small: css(templateObject_39 || (templateObject_39 = __makeTemplateObject(["\n font-size: 14px;\n line-height: 16px;\n "], ["\n font-size: 14px;\n line-height: 16px;\n "]))),
|
|
63
|
+
xsmall: css(templateObject_40 || (templateObject_40 = __makeTemplateObject(["\n font-size: 14px;\n line-height: 16px;\n "], ["\n font-size: 14px;\n line-height: 16px;\n "]))),
|
|
62
64
|
};
|
|
63
65
|
/**
|
|
64
66
|
* [피그마](https://www.figma.com/file/yhrRFizzmhPoHdw9FbYow2/Codle-PD-Kit---Components?type=design&node-id=20-173&t=cXcCv3QijbX7MkoC-0)
|
|
@@ -67,15 +69,15 @@ var Button = React.forwardRef(function Button(props, ref) {
|
|
|
67
69
|
var className = props.className, _a = props.component, Component = _a === void 0 ? "button" : _a, disabled = props.disabled, color = props.color, size = props.size, startIcon = props.startIcon, endIcon = props.endIcon, label = props.label, fullWidth = props.fullWidth, other = __rest(props, ["className", "component", "disabled", "color", "size", "startIcon", "endIcon", "label", "fullWidth"]);
|
|
68
70
|
var theme = useTheme();
|
|
69
71
|
return (_jsxs(Component, __assign({ type: "button" }, other, { className: className, ref: ref, css: [
|
|
70
|
-
css(
|
|
71
|
-
? css(
|
|
72
|
+
css(templateObject_43 || (templateObject_43 = __makeTemplateObject(["\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n\n border: none;\n border-radius: 8px;\n\n ", "\n\n font-family: ", ";\n text-decoration: none;\n\n width: ", ";\n "], ["\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n\n border: none;\n border-radius: 8px;\n\n ", "\n\n font-family: ", ";\n text-decoration: none;\n\n width: ", ";\n "])), disabled
|
|
73
|
+
? css(templateObject_41 || (templateObject_41 = __makeTemplateObject(["\n cursor: default;\n pointer-events: none;\n "], ["\n cursor: default;\n pointer-events: none;\n "]))) : css(templateObject_42 || (templateObject_42 = __makeTemplateObject(["\n cursor: pointer;\n "], ["\n cursor: pointer;\n "]))), theme.fontFamily.ui, fullWidth ? "100%" : "auto"),
|
|
72
74
|
COLOR_TO_BUTTON_STYLE(theme, color, Boolean(disabled)),
|
|
73
75
|
SIZE_TO_BUTTON_STYLE[size],
|
|
74
76
|
], disabled: disabled }, { children: [startIcon, _jsx(Label, __assign({ size: size }, { children: label })), endIcon] })));
|
|
75
77
|
});
|
|
76
|
-
var Label = styled.span(
|
|
78
|
+
var Label = styled.span(templateObject_44 || (templateObject_44 = __makeTemplateObject(["\n font-weight: 400;\n white-space: nowrap;\n ", "\n"], ["\n font-weight: 400;\n white-space: nowrap;\n ", "\n"])), function (_a) {
|
|
77
79
|
var size = _a.size;
|
|
78
80
|
return SIZE_TO_LABEL_STYLE[size];
|
|
79
81
|
});
|
|
80
82
|
export default Button;
|
|
81
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18, templateObject_19, templateObject_20, templateObject_21, templateObject_22, templateObject_23, templateObject_24, templateObject_25, templateObject_26, templateObject_27, templateObject_28, templateObject_29, templateObject_30, templateObject_31, templateObject_32, templateObject_33, templateObject_34, templateObject_35, templateObject_36, templateObject_37, templateObject_38, templateObject_39, templateObject_40;
|
|
83
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18, templateObject_19, templateObject_20, templateObject_21, templateObject_22, templateObject_23, templateObject_24, templateObject_25, templateObject_26, templateObject_27, templateObject_28, templateObject_29, templateObject_30, templateObject_31, templateObject_32, templateObject_33, templateObject_34, templateObject_35, templateObject_36, templateObject_37, templateObject_38, templateObject_39, templateObject_40, templateObject_41, templateObject_42, templateObject_43, templateObject_44;
|
|
@@ -37,28 +37,29 @@ var COLOR_TO_BUTTON_STYLE = function (theme, color) {
|
|
|
37
37
|
primary: css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n background: ", ";\n border: none;\n color: ", ";\n\n ", "\n &:disabled {\n background: ", ";\n }\n "], ["\n background: ", ";\n border: none;\n color: ", ";\n\n ", "\n &:disabled {\n background: ", ";\n }\n "])), theme.color.background.primary, theme.color.foreground.neutralAlt, HOVER(css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n background: ", ";\n "], ["\n background: ", ";\n "])), theme.color.background.primaryActive)), theme.color.background.primaryDisabled),
|
|
38
38
|
icon: css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n background: none;\n border: none;\n color: ", ";\n\n ", "\n &:disabled {\n background: none;\n color: ", ";\n }\n "], ["\n background: none;\n border: none;\n color: ", ";\n\n ", "\n &:disabled {\n background: none;\n color: ", ";\n }\n "])), theme.color.foreground.neutralBase, HOVER(css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n background: ", ";\n color: ", ";\n "], ["\n background: ", ";\n color: ", ";\n "])), theme.color.background.neutralAltActive, theme.color.foreground.neutralBase)), theme.color.foreground.neutralBaseDisabled),
|
|
39
39
|
black: css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n background: ", ";\n border: none;\n color: ", ";\n ", "\n &:disabled {\n background: ", ";\n color: ", ";\n }\n "], ["\n background: ", ";\n border: none;\n color: ", ";\n ", "\n &:disabled {\n background: ", ";\n color: ", ";\n }\n "])), theme.color.background.black, theme.color.foreground.neutralAlt, HOVER(css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n background: ", ";\n color: ", ";\n "], ["\n background: ", ";\n color: ", ";\n "])), theme.color.background.blackActive, theme.color.foreground.neutralAlt)), theme.color.background.blackDisabled, theme.color.foreground.neutralAltDisabled),
|
|
40
|
+
white: css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n background: ", ";\n border: none;\n color: ", ";\n ", "\n &:disabled {\n background: ", ";\n color: ", ";\n }\n "], ["\n background: ", ";\n border: none;\n color: ", ";\n ", "\n &:disabled {\n background: ", ";\n color: ", ";\n }\n "])), theme.color.background.neutralBase, theme.color.foreground.neutralBase, HOVER(css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n background: ", ";\n color: ", ";\n "], ["\n background: ", ";\n color: ", ";\n "])), theme.color.background.neutralAltActive, theme.color.foreground.neutralBase)), theme.color.background.neutralAltDisabled, theme.color.foreground.neutralBaseDisabled),
|
|
40
41
|
})[color];
|
|
41
42
|
};
|
|
42
43
|
var SIZE_TO_BUTTON_STYLE = {
|
|
43
|
-
large: css(
|
|
44
|
-
medium: css(
|
|
45
|
-
small: css(
|
|
46
|
-
xsmall: css(
|
|
44
|
+
large: css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n width: 56px;\n height: 56px;\n padding: 16px;\n\n svg {\n width: 24px;\n height: 24px;\n }\n "], ["\n width: 56px;\n height: 56px;\n padding: 16px;\n\n svg {\n width: 24px;\n height: 24px;\n }\n "]))),
|
|
45
|
+
medium: css(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n width: 48px;\n height: 48px;\n padding: 14px;\n\n svg {\n width: 20px;\n height: 20px;\n }\n "], ["\n width: 48px;\n height: 48px;\n padding: 14px;\n\n svg {\n width: 20px;\n height: 20px;\n }\n "]))),
|
|
46
|
+
small: css(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n width: 36px;\n height: 36px;\n padding: 10px;\n\n svg {\n width: 16px;\n height: 16px;\n }\n "], ["\n width: 36px;\n height: 36px;\n padding: 10px;\n\n svg {\n width: 16px;\n height: 16px;\n }\n "]))),
|
|
47
|
+
xsmall: css(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n width: 28px;\n height: 28px;\n padding: 8px;\n\n svg {\n width: 12px;\n height: 12px;\n }\n "], ["\n width: 28px;\n height: 28px;\n padding: 8px;\n\n svg {\n width: 12px;\n height: 12px;\n }\n "]))),
|
|
47
48
|
};
|
|
48
49
|
var SIZE_TO_LABEL_STYLE = {
|
|
49
|
-
large: css(
|
|
50
|
-
medium: css(
|
|
51
|
-
small: css(
|
|
52
|
-
xsmall: css(
|
|
50
|
+
large: css(templateObject_17 || (templateObject_17 = __makeTemplateObject(["\n font-size: 18px;\n line-height: 28px;\n "], ["\n font-size: 18px;\n line-height: 28px;\n "]))),
|
|
51
|
+
medium: css(templateObject_18 || (templateObject_18 = __makeTemplateObject(["\n font-size: 18px;\n line-height: 28px;\n "], ["\n font-size: 18px;\n line-height: 28px;\n "]))),
|
|
52
|
+
small: css(templateObject_19 || (templateObject_19 = __makeTemplateObject(["\n font-size: 18px;\n line-height: 28px;\n "], ["\n font-size: 18px;\n line-height: 28px;\n "]))),
|
|
53
|
+
xsmall: css(templateObject_20 || (templateObject_20 = __makeTemplateObject(["\n font-size: 14px;\n line-height: 22px;\n "], ["\n font-size: 14px;\n line-height: 22px;\n "]))),
|
|
53
54
|
};
|
|
54
55
|
/**
|
|
55
56
|
* [피그마](https://www.figma.com/file/yhrRFizzmhPoHdw9FbYow2/Codle-PD-Kit---Components?type=design&node-id=22-374&t=kTLv3t86qtGalHSS-0)
|
|
56
57
|
*/
|
|
57
58
|
var SquareButton = React.forwardRef(function SquareButton(props, ref) {
|
|
58
59
|
var className = props.className, _a = props.component, Component = _a === void 0 ? "span" : _a, disabled = props.disabled, color = props.color, size = props.size, icon = props.icon, label = props.label, fullWidth = props.fullWidth, onClick = props.onClick, other = __rest(props, ["className", "component", "disabled", "color", "size", "icon", "label", "fullWidth", "onClick"]);
|
|
59
|
-
return (_jsxs(Component, __assign({}, other, { ref: ref, className: className, css: css(
|
|
60
|
+
return (_jsxs(Component, __assign({}, other, { ref: ref, className: className, css: css(templateObject_21 || (templateObject_21 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n\n width: ", ";\n "], ["\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n\n width: ", ";\n "])), fullWidth ? "100%" : "fit-content") }, { children: [_jsx(Button, __assign({ type: "button", color: color, size: size, disabled: disabled, fullWidth: fullWidth, onClick: onClick }, { children: icon })), label && (_jsx(Label, __assign({ disabled: disabled, size: size }, { children: label })))] })));
|
|
60
61
|
});
|
|
61
|
-
var Button = styled.button(
|
|
62
|
+
var Button = styled.button(templateObject_22 || (templateObject_22 = __makeTemplateObject(["\n border-radius: 8px;\n cursor: pointer;\n &:disabled {\n cursor: default;\n }\n ", "\n ", "\n ", "\n"], ["\n border-radius: 8px;\n cursor: pointer;\n &:disabled {\n cursor: default;\n }\n ", "\n ", "\n ", "\n"])), function (_a) {
|
|
62
63
|
var theme = _a.theme, color = _a.color;
|
|
63
64
|
return COLOR_TO_BUTTON_STYLE(theme, color);
|
|
64
65
|
}, function (_a) {
|
|
@@ -68,7 +69,7 @@ var Button = styled.button(templateObject_20 || (templateObject_20 = __makeTempl
|
|
|
68
69
|
var fullWidth = _a.fullWidth;
|
|
69
70
|
return fullWidth && "width: 100%;";
|
|
70
71
|
});
|
|
71
|
-
var Label = styled.span(
|
|
72
|
+
var Label = styled.span(templateObject_23 || (templateObject_23 = __makeTemplateObject(["\n font-weight: 400;\n color: ", ";\n ", "\n"], ["\n font-weight: 400;\n color: ", ";\n ", "\n"])), function (_a) {
|
|
72
73
|
var theme = _a.theme, disabled = _a.disabled;
|
|
73
74
|
return disabled
|
|
74
75
|
? theme.color.foreground.neutralBaseDisabled
|
|
@@ -78,4 +79,4 @@ var Label = styled.span(templateObject_21 || (templateObject_21 = __makeTemplate
|
|
|
78
79
|
return SIZE_TO_LABEL_STYLE[size];
|
|
79
80
|
});
|
|
80
81
|
export default SquareButton;
|
|
81
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18, templateObject_19, templateObject_20, templateObject_21;
|
|
82
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18, templateObject_19, templateObject_20, templateObject_21, templateObject_22, templateObject_23;
|
package/dist/index.d.ts
CHANGED
|
@@ -12,8 +12,6 @@ export { default as Pagination } from "./components/Pagination";
|
|
|
12
12
|
export * from "./components/Pagination";
|
|
13
13
|
export { default as PinInput } from "./components/PinInput";
|
|
14
14
|
export * from "./components/PinInput";
|
|
15
|
-
export { default as Popover } from "./components/Popover";
|
|
16
|
-
export * from "./components/Popover";
|
|
17
15
|
export { default as RadioInput } from "./components/RadioInput";
|
|
18
16
|
export * from "./components/RadioInput";
|
|
19
17
|
export { default as SquareButton } from "./components/SquareButton";
|
package/dist/index.js
CHANGED
|
@@ -12,8 +12,6 @@ export { default as Pagination } from "./components/Pagination";
|
|
|
12
12
|
export * from "./components/Pagination";
|
|
13
13
|
export { default as PinInput } from "./components/PinInput";
|
|
14
14
|
export * from "./components/PinInput";
|
|
15
|
-
export { default as Popover } from "./components/Popover";
|
|
16
|
-
export * from "./components/Popover";
|
|
17
15
|
export { default as RadioInput } from "./components/RadioInput";
|
|
18
16
|
export * from "./components/RadioInput";
|
|
19
17
|
export { default as SquareButton } from "./components/SquareButton";
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
49
|
+
import { Controller } from "react-hook-form";
|
|
50
|
+
import { createReactEditorJS } from "react-editor-js";
|
|
51
|
+
import { useCallback, useRef } from "react";
|
|
52
|
+
import TOOLS from "./tools";
|
|
53
|
+
import I18n from "./i18n";
|
|
54
|
+
import Layout from "./Layout";
|
|
55
|
+
import * as Sentry from "@sentry/react";
|
|
56
|
+
/** useForm에서 사용되는 ReactEditorJS 컴포넌트입니다. */
|
|
57
|
+
export function FormEditorJS(props) {
|
|
58
|
+
var _this = this;
|
|
59
|
+
var className = props.className, name = props.name, control = props.control, _a = props.readOnly, readOnly = _a === void 0 ? false : _a;
|
|
60
|
+
var ReactEditorJS = createReactEditorJS();
|
|
61
|
+
var editorCore = useRef(null);
|
|
62
|
+
var handleInitialize = useCallback(function (instance) { return __awaiter(_this, void 0, void 0, function () {
|
|
63
|
+
var e_1;
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
switch (_a.label) {
|
|
66
|
+
case 0:
|
|
67
|
+
_a.trys.push([0, 2, , 3]);
|
|
68
|
+
return [4 /*yield*/, instance.dangerouslyLowLevelInstance.isReady];
|
|
69
|
+
case 1:
|
|
70
|
+
_a.sent();
|
|
71
|
+
editorCore.current = instance;
|
|
72
|
+
return [3 /*break*/, 3];
|
|
73
|
+
case 2:
|
|
74
|
+
e_1 = _a.sent();
|
|
75
|
+
Sentry.captureException(e_1);
|
|
76
|
+
return [3 /*break*/, 3];
|
|
77
|
+
case 3: return [2 /*return*/];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}); }, []);
|
|
81
|
+
var handleSave = useCallback(function (onChange) { return __awaiter(_this, void 0, void 0, function () {
|
|
82
|
+
var _this = this;
|
|
83
|
+
var _a;
|
|
84
|
+
return __generator(this, function (_b) {
|
|
85
|
+
if (!editorCore.current) {
|
|
86
|
+
return [2 /*return*/];
|
|
87
|
+
}
|
|
88
|
+
// 저장 전에 isReady 상태를 기다리기
|
|
89
|
+
// https://github.com/codex-team/editor.js/issues/1136
|
|
90
|
+
(_a = editorCore.current.dangerouslyLowLevelInstance.isReady) === null || _a === void 0 ? void 0 : _a.then(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
91
|
+
var savedData;
|
|
92
|
+
var _a;
|
|
93
|
+
return __generator(this, function (_b) {
|
|
94
|
+
switch (_b.label) {
|
|
95
|
+
case 0: return [4 /*yield*/, ((_a = editorCore.current) === null || _a === void 0 ? void 0 : _a.save())];
|
|
96
|
+
case 1:
|
|
97
|
+
savedData = _b.sent();
|
|
98
|
+
if (savedData) {
|
|
99
|
+
onChange(savedData.blocks);
|
|
100
|
+
}
|
|
101
|
+
return [2 /*return*/];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}); });
|
|
105
|
+
return [2 /*return*/];
|
|
106
|
+
});
|
|
107
|
+
}); }, []);
|
|
108
|
+
// readOnly가 변경되면 ReactEditorJS를 다시 마운트하기 위해 key를 변경합니다.
|
|
109
|
+
// readOnly 모드에서는 onChange를 전달할 수 없어서 케이스를 분리합니다.
|
|
110
|
+
if (readOnly) {
|
|
111
|
+
return (_jsx(Controller, { name: name, control: control, render: function (_a) {
|
|
112
|
+
var value = _a.field.value;
|
|
113
|
+
return (_jsx(Layout, __assign({ className: className }, { children: _jsx(ReactEditorJS, { onInitialize: handleInitialize, tools: TOOLS, defaultValue: {
|
|
114
|
+
blocks: value,
|
|
115
|
+
}, i18n: I18n, readOnly: true }, "readOnly") })));
|
|
116
|
+
} }));
|
|
117
|
+
}
|
|
118
|
+
return (_jsx(Controller, { name: name, control: control, render: function (_a) {
|
|
119
|
+
var _b = _a.field, onChange = _b.onChange, value = _b.value;
|
|
120
|
+
return (_jsx(Layout, __assign({ className: className }, { children: _jsx(ReactEditorJS, { onInitialize: handleInitialize, tools: TOOLS, inlineToolbar: [
|
|
121
|
+
"bold",
|
|
122
|
+
"italic",
|
|
123
|
+
"underline",
|
|
124
|
+
"strikeThrough",
|
|
125
|
+
"inlineCode",
|
|
126
|
+
"link",
|
|
127
|
+
], tunes: ["moveUp", "delete", "moveDown"],
|
|
128
|
+
// onChange를 사용하므로 value를 사용하면 안됩니다.(defaultValue 사용이 highly recommended)
|
|
129
|
+
defaultValue: {
|
|
130
|
+
blocks: value,
|
|
131
|
+
}, placeholder: "\uB0B4\uC6A9\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694.", onChange: function () { return handleSave(onChange); }, i18n: I18n }, "editable") })));
|
|
132
|
+
} }));
|
|
133
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const Layout: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: import("react").ElementType<any> | undefined;
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
6
|
+
export default Layout;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import { css } from "@emotion/react";
|
|
6
|
+
import styled from "@emotion/styled";
|
|
7
|
+
import { hexToCSSFilter } from "hex-to-css-filter";
|
|
8
|
+
import { CalloutStyle, DelimiterStyle, HeaderStyle, NestedListStyle, QuoteStyle, RawStyle, } from "./customTools";
|
|
9
|
+
var Layout = styled.div(function (_a) {
|
|
10
|
+
var theme = _a.theme;
|
|
11
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: auto;\n margin-top: 8px;\n border: 1px solid ", ";\n border-radius: 8px;\n padding: 32px 74px 32px 16px;\n .codex-editor__redactor {\n padding-bottom: 0 !important;\n }\n .ce-block {\n margin-left: 55px;\n }\n .ce-block__content {\n margin: 0;\n max-width: unset;\n }\n .ce-toolbar__content {\n position: unset;\n }\n .ce-toolbar__actions {\n left: -5px;\n }\n .ce-paragraph {\n font-family: ", ";\n font-weight: 400;\n font-size: 16px;\n line-height: 24px;\n padding: 0 0 8px;\n }\n\n ", "\n ", "\n ", "\n ", "\n ", "\n ", " \n\n // block tool \uC2A4\uD0C0\uC77C\n .ce-popover-item__icon img {\n width: 18px;\n height: 18px;\n }\n\n // inline tool \uC2A4\uD0C0\uC77C\n .ce-conversion-tool img {\n width: 18px;\n height: 18px;\n }\n .ce-inline-toolbar__buttons {\n gap: 4px;\n .ce-inline-tool--active img {\n // color\uB97C editorjs\uC5D0\uC11C\uB294 active icon\uC744 svg color: #388ae5\uB85C \uBCC0\uACBD\uD569\uB2C8\uB2E4.\n // cds color\uC778 primary\uB85C \uBCC0\uACBD\uD569\uB2C8\uB2E4.\n filter: ", ";\n }\n }\n .ce-inline-toolbar__dropdown {\n padding: 8px 4px;\n gap: 4px;\n }\n .ce-inline-toolbar__dropdown-content img {\n margin-left: 4px;\n width: 18px;\n height: 18px;\n }\n .ce-inline-tool {\n padding: 8px 4px;\n img {\n width: 18px;\n height: 18px;\n }\n }\n "], ["\n width: auto;\n margin-top: 8px;\n border: 1px solid ", ";\n border-radius: 8px;\n padding: 32px 74px 32px 16px;\n .codex-editor__redactor {\n padding-bottom: 0 !important;\n }\n .ce-block {\n margin-left: 55px;\n }\n .ce-block__content {\n margin: 0;\n max-width: unset;\n }\n .ce-toolbar__content {\n position: unset;\n }\n .ce-toolbar__actions {\n left: -5px;\n }\n .ce-paragraph {\n font-family: ", ";\n font-weight: 400;\n font-size: 16px;\n line-height: 24px;\n padding: 0 0 8px;\n }\n\n ", "\n ", "\n ", "\n ", "\n ", "\n ", " \n\n // block tool \uC2A4\uD0C0\uC77C\n .ce-popover-item__icon img {\n width: 18px;\n height: 18px;\n }\n\n // inline tool \uC2A4\uD0C0\uC77C\n .ce-conversion-tool img {\n width: 18px;\n height: 18px;\n }\n .ce-inline-toolbar__buttons {\n gap: 4px;\n .ce-inline-tool--active img {\n // color\uB97C editorjs\uC5D0\uC11C\uB294 active icon\uC744 svg color: #388ae5\uB85C \uBCC0\uACBD\uD569\uB2C8\uB2E4.\n // cds color\uC778 primary\uB85C \uBCC0\uACBD\uD569\uB2C8\uB2E4.\n filter: ", ";\n }\n }\n .ce-inline-toolbar__dropdown {\n padding: 8px 4px;\n gap: 4px;\n }\n .ce-inline-toolbar__dropdown-content img {\n margin-left: 4px;\n width: 18px;\n height: 18px;\n }\n .ce-inline-tool {\n padding: 8px 4px;\n img {\n width: 18px;\n height: 18px;\n }\n }\n "])), theme.color.background.neutralAlt, theme.fontFamily.ui, HeaderStyle(theme), NestedListStyle, QuoteStyle(theme), CalloutStyle(theme), RawStyle(theme), DelimiterStyle(theme), hexToCSSFilter(theme.color.foreground.primary).filter);
|
|
12
|
+
});
|
|
13
|
+
export default Layout;
|
|
14
|
+
var templateObject_1;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface ReactEditorJSProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
/** 읽기모드 여부(preview 여부) */
|
|
5
|
+
readOnly?: boolean;
|
|
6
|
+
/** 에디터의 블록데이터 */
|
|
7
|
+
blocks: any;
|
|
8
|
+
/** 데이터가 변경되었을 때 실행될 콜백 */
|
|
9
|
+
onChange?: (blocks: any) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function ReactEditorJS(props: ReactEditorJSProps): JSX.Element;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
49
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
50
|
+
import { createReactEditorJS } from "react-editor-js";
|
|
51
|
+
import * as Sentry from "@sentry/react";
|
|
52
|
+
import Layout from "./Layout";
|
|
53
|
+
import TOOLS from "./tools";
|
|
54
|
+
import I18n from "./i18n";
|
|
55
|
+
export function ReactEditorJS(props) {
|
|
56
|
+
var _this = this;
|
|
57
|
+
var className = props.className, _a = props.readOnly, readOnly = _a === void 0 ? false : _a, blocks = props.blocks, onChange = props.onChange;
|
|
58
|
+
var ReactEditorJS = createReactEditorJS();
|
|
59
|
+
var editorCore = useRef(null);
|
|
60
|
+
var handleInitialize = useCallback(function (instance) { return __awaiter(_this, void 0, void 0, function () {
|
|
61
|
+
var e_1;
|
|
62
|
+
return __generator(this, function (_a) {
|
|
63
|
+
switch (_a.label) {
|
|
64
|
+
case 0:
|
|
65
|
+
_a.trys.push([0, 2, , 3]);
|
|
66
|
+
return [4 /*yield*/, instance.dangerouslyLowLevelInstance.isReady];
|
|
67
|
+
case 1:
|
|
68
|
+
_a.sent();
|
|
69
|
+
editorCore.current = instance;
|
|
70
|
+
return [3 /*break*/, 3];
|
|
71
|
+
case 2:
|
|
72
|
+
e_1 = _a.sent();
|
|
73
|
+
Sentry.captureException(e_1);
|
|
74
|
+
return [3 /*break*/, 3];
|
|
75
|
+
case 3: return [2 /*return*/];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}); }, []);
|
|
79
|
+
var handleSave = useCallback(function (onChange) { return __awaiter(_this, void 0, void 0, function () {
|
|
80
|
+
var _this = this;
|
|
81
|
+
var _a;
|
|
82
|
+
return __generator(this, function (_b) {
|
|
83
|
+
if (!editorCore.current || readOnly) {
|
|
84
|
+
return [2 /*return*/];
|
|
85
|
+
}
|
|
86
|
+
// 저장 전에 isReady 상태를 기다리기
|
|
87
|
+
// https://github.com/codex-team/editor.js/issues/1136
|
|
88
|
+
(_a = editorCore.current.dangerouslyLowLevelInstance.isReady) === null || _a === void 0 ? void 0 : _a.then(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
89
|
+
var savedData;
|
|
90
|
+
var _a;
|
|
91
|
+
return __generator(this, function (_b) {
|
|
92
|
+
switch (_b.label) {
|
|
93
|
+
case 0: return [4 /*yield*/, ((_a = editorCore.current) === null || _a === void 0 ? void 0 : _a.save())];
|
|
94
|
+
case 1:
|
|
95
|
+
savedData = _b.sent();
|
|
96
|
+
if (savedData) {
|
|
97
|
+
onChange(savedData.blocks);
|
|
98
|
+
}
|
|
99
|
+
return [2 /*return*/];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}); });
|
|
103
|
+
return [2 /*return*/];
|
|
104
|
+
});
|
|
105
|
+
}); }, []);
|
|
106
|
+
// blocks가 변경될 때 preview가 다시 렌더링되게 하려면 controlled component를 위한 "value"인자를 전달하는 것이 올바른 방법이지만
|
|
107
|
+
// controlled를 위해 "defaultValue" 대신 "value"를 사용하면 불필요하게 많이 리렌더링 되고, 그에 따른 오류가 발생합니다.
|
|
108
|
+
// 따라서, highly recommended인 "defaultValue" 사용을 유지하고 blocks가 변경될 때마다
|
|
109
|
+
// useEffect를 사용하여 editorCore의 render 메서드를 호출하여 리렌더링을 수행하도록 구현합니다.
|
|
110
|
+
useEffect(function () {
|
|
111
|
+
if (!editorCore.current || !readOnly) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
editorCore.current.render({
|
|
115
|
+
blocks: blocks,
|
|
116
|
+
});
|
|
117
|
+
}, [blocks, readOnly]);
|
|
118
|
+
// readOnly가 변경되면 ReactEditorJS를 다시 마운트하기 위해 key를 변경합니다.
|
|
119
|
+
// readOnly 모드에서는 onChange를 전달할 수 없어서 케이스를 분리합니다.
|
|
120
|
+
if (readOnly) {
|
|
121
|
+
return (_jsx(Layout, __assign({ className: className }, { children: _jsx(ReactEditorJS, { onInitialize: handleInitialize, tools: TOOLS, defaultValue: {
|
|
122
|
+
blocks: blocks,
|
|
123
|
+
}, i18n: I18n, readOnly: true }, "readOnly") })));
|
|
124
|
+
}
|
|
125
|
+
return (_jsx(Layout, __assign({ className: className }, { children: _jsx(ReactEditorJS, { onInitialize: handleInitialize, tools: TOOLS, inlineToolbar: [
|
|
126
|
+
"bold",
|
|
127
|
+
"italic",
|
|
128
|
+
"underline",
|
|
129
|
+
"strikeThrough",
|
|
130
|
+
"inlineCode",
|
|
131
|
+
"link",
|
|
132
|
+
], tunes: ["moveUp", "delete", "moveDown"],
|
|
133
|
+
// onChange를 사용하므로 value를 사용하면 안됩니다.(defaultValue 사용이 highly recommended)
|
|
134
|
+
defaultValue: {
|
|
135
|
+
blocks: blocks,
|
|
136
|
+
}, onChange: function () { return handleSave(onChange); }, i18n: I18n }, "editable") })));
|
|
137
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { BlockTool } from "@editorjs/editorjs";
|
|
2
|
+
import { Theme } from "@emotion/react";
|
|
3
|
+
type COLOR_TYPE = "grey" | "red" | "yellow" | "blue" | "green";
|
|
4
|
+
type DATA_TYPE = {
|
|
5
|
+
color: COLOR_TYPE;
|
|
6
|
+
text: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const CalloutStyle: (theme: Theme) => import("@emotion/utils").SerializedStyles;
|
|
9
|
+
export declare class Callout implements BlockTool {
|
|
10
|
+
api: any;
|
|
11
|
+
config: any;
|
|
12
|
+
readOnly: any;
|
|
13
|
+
private _wrapper;
|
|
14
|
+
constructor({ api, config, readOnly, data }: any);
|
|
15
|
+
createWrapper(data: DATA_TYPE): HTMLDivElement;
|
|
16
|
+
get colors(): string[];
|
|
17
|
+
get defaultColor(): string;
|
|
18
|
+
get color(): COLOR_TYPE;
|
|
19
|
+
set data(data: DATA_TYPE);
|
|
20
|
+
save(): {
|
|
21
|
+
color: COLOR_TYPE;
|
|
22
|
+
text: string;
|
|
23
|
+
};
|
|
24
|
+
render(): HTMLDivElement;
|
|
25
|
+
renderSettings(): {
|
|
26
|
+
name: string;
|
|
27
|
+
icon: string;
|
|
28
|
+
label: any;
|
|
29
|
+
isActive: boolean;
|
|
30
|
+
closeOnActivate: boolean;
|
|
31
|
+
onActivate: () => void;
|
|
32
|
+
}[];
|
|
33
|
+
static get isReadOnlySupported(): boolean;
|
|
34
|
+
static get enableLineBreaks(): boolean;
|
|
35
|
+
static get toolbox(): {
|
|
36
|
+
icon: string;
|
|
37
|
+
title: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export {};
|