@team-monolith/cds 1.8.4 → 1.8.5
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/patterns/LexicalEditor/nodes/ProblemInputNode/Form/FormAnswer.js +5 -7
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/InputComponent.d.ts +7 -2
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/InputComponent.js +15 -8
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/ProblemInputNode.js +1 -4
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ import Tooltip from "../../../../../components/Tooltip";
|
|
|
11
11
|
export function FormAnswer(props) {
|
|
12
12
|
const { index, control, onDelete, disabled } = props;
|
|
13
13
|
const theme = useTheme();
|
|
14
|
-
const TextTypeDropdown = (_jsx(Controller, { name: `answers.${index}.textType`, control: control, render: ({ field }) => (_jsx(Dropdown, Object.assign({ label:
|
|
14
|
+
const TextTypeDropdown = (_jsx(Controller, { name: `answers.${index}.textType`, control: control, render: ({ field: { value, onChange } }) => (_jsx(Dropdown, Object.assign({ label: value === "normal" ? "일반 텍스트" : "코드 텍스트", size: "xsmall", color: "textNeutral", closeOnItemClick: true, disabled: disabled, buttonCss: css `
|
|
15
15
|
${disabled && `color: ${theme.color.foreground.neutralAlt};`}
|
|
16
16
|
> span {
|
|
17
17
|
font-weight: 700;
|
|
@@ -25,14 +25,12 @@ export function FormAnswer(props) {
|
|
|
25
25
|
vertical: "top",
|
|
26
26
|
horizontal: "center",
|
|
27
27
|
},
|
|
28
|
-
} }, { children:
|
|
29
|
-
|
|
30
|
-
} }))
|
|
31
|
-
field.onChange("code");
|
|
32
|
-
} })) }))) }));
|
|
28
|
+
} }, { children: _jsx(DropdownItem, { index: 0, label: value === "normal" ? "코드 텍스트" : "일반 텍스트", onClick: () => {
|
|
29
|
+
onChange(value === "normal" ? "code" : "normal");
|
|
30
|
+
} }) }))) }));
|
|
33
31
|
return (_jsx(Controller, { name: `answers.${index}.value`, control: control, rules: {
|
|
34
32
|
required: "정답을 입력해주세요.",
|
|
35
|
-
}, render: ({ field: {
|
|
33
|
+
}, render: ({ field: { value, onChange }, fieldState: { invalid, error }, }) => (_jsx(Input, { size: "small", color: invalid ? "activeDanger" : "default", onChange: onChange, disabled: disabled, value: value, hintIcon: invalid ? _jsx(ErrorWarningFillIcon, {}) : undefined, hintText: error === null || error === void 0 ? void 0 : error.message, placeholder: "\uC548\uB155\uD558\uC138\uC694", fullWidth: true, css: css `
|
|
36
34
|
> div {
|
|
37
35
|
padding: 4px 12px;
|
|
38
36
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Answer } from "./ProblemInputNode";
|
|
2
|
+
import { NodeKey } from "lexical";
|
|
2
3
|
export declare function InputComponent(props: {
|
|
3
|
-
|
|
4
|
+
answers: Answer[];
|
|
5
|
+
showCharacterCount: boolean;
|
|
6
|
+
placeholder: string;
|
|
7
|
+
response: string;
|
|
8
|
+
nodeKey: NodeKey;
|
|
4
9
|
}): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -12,21 +12,19 @@ import Button from "../../../../components/Button";
|
|
|
12
12
|
import Tooltip from "../../../../components/Tooltip";
|
|
13
13
|
import { FormAnswer, FormCharacterCount, FormPlaceholder } from "./Form";
|
|
14
14
|
import useLexicalEditable from "@lexical/react/useLexicalEditable";
|
|
15
|
+
import { $isProblemInputNode, } from "./ProblemInputNode";
|
|
15
16
|
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
17
|
+
import { $getNodeByKey } from "lexical";
|
|
16
18
|
export function InputComponent(props) {
|
|
17
19
|
const theme = useTheme();
|
|
18
|
-
const {
|
|
20
|
+
const { answers, showCharacterCount, placeholder, response, nodeKey } = props;
|
|
19
21
|
const [editor] = useLexicalComposerContext();
|
|
20
|
-
const answers = node.getAnswers();
|
|
21
|
-
const showCharacterCount = node.getShowCharacterCount();
|
|
22
|
-
const placeholder = node.getPlaceholder();
|
|
23
|
-
const response = node.getResponse();
|
|
24
22
|
const [settingOpen, setSettingOpen] = useState(false);
|
|
25
23
|
const [multiAnswerDisabled, setMultiAnswerDisabled] = useState(showCharacterCount);
|
|
26
24
|
const isEditable = useLexicalEditable();
|
|
27
|
-
const { control, handleSubmit
|
|
25
|
+
const { control, handleSubmit } = useForm({
|
|
28
26
|
defaultValues: {
|
|
29
|
-
answers
|
|
27
|
+
answers,
|
|
30
28
|
showCharacterCount,
|
|
31
29
|
placeholder,
|
|
32
30
|
},
|
|
@@ -38,6 +36,10 @@ export function InputComponent(props) {
|
|
|
38
36
|
});
|
|
39
37
|
const onSettingSubmit = (data) => {
|
|
40
38
|
editor.update(() => {
|
|
39
|
+
const node = $getNodeByKey(nodeKey);
|
|
40
|
+
if (!$isProblemInputNode(node)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
41
43
|
node.setAnswers(data.answers);
|
|
42
44
|
node.setShowCharacterCount(data.showCharacterCount);
|
|
43
45
|
node.setPlaceholder(data.placeholder);
|
|
@@ -45,9 +47,14 @@ export function InputComponent(props) {
|
|
|
45
47
|
setSettingOpen(false);
|
|
46
48
|
};
|
|
47
49
|
// 학생 view
|
|
50
|
+
// TODO: "글자 수대로" 옵션시에 글자 수대로 입력칸을 표시해야 합니다.
|
|
48
51
|
if (!isEditable) {
|
|
49
|
-
return (_jsx(Input, { size: "small", placeholder:
|
|
52
|
+
return (_jsx(Input, { size: "small", placeholder: placeholder || "여기에 입력하세요.", value: response, onChange: (e) => {
|
|
50
53
|
editor.update(() => {
|
|
54
|
+
const node = $getNodeByKey(nodeKey);
|
|
55
|
+
if (!$isProblemInputNode(node)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
51
58
|
node.setResponse(e.target.value);
|
|
52
59
|
});
|
|
53
60
|
}, color: "default", css: css `
|
|
@@ -83,11 +83,8 @@ export class ProblemInputNode extends DecoratorNode {
|
|
|
83
83
|
response: this.__response,
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
-
// TODO: 이 노드의 selected가 제대로 동작하지 않습니다.
|
|
87
|
-
// nodeKey를 전달하고 getNodeByKey로 노드를 찾는 것이 일반적이나
|
|
88
|
-
// 현재 이 노드가 selected가 제대로 동작하지 않아서 노드를 직접 전달했습니다.
|
|
89
86
|
decorate() {
|
|
90
|
-
return _jsx(InputComponent, {
|
|
87
|
+
return (_jsx(InputComponent, { answers: this.__answers, showCharacterCount: this.__showCharacterCount, placeholder: this.__placeholder, response: this.__response, nodeKey: this.getKey() }));
|
|
91
88
|
}
|
|
92
89
|
}
|
|
93
90
|
export function $createProblemInputNode({ showCharacterCount, placeholder, answers, response, key, }) {
|