@team-monolith/cds 1.8.5 → 1.8.6
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/InputComponent.d.ts +3 -3
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/InputComponent.js +34 -143
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/ProblemInputNode.d.ts +14 -13
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/ProblemInputNode.js +24 -27
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/{Form/FormAnswer.d.ts → SettingForm/FormSolution.d.ts} +1 -1
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/{Form/FormAnswer.js → SettingForm/FormSolution.js} +3 -3
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/SettingForm/SettingForm.d.ts +10 -0
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/SettingForm/SettingForm.js +149 -0
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/{Form → SettingForm}/index.d.ts +2 -1
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/{Form → SettingForm}/index.js +2 -1
- package/dist/patterns/LexicalEditor/plugins/ComponentPickerMenuPlugin/ComponentPickerMenuPlugin.js +2 -2
- package/package.json +1 -1
- /package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/{Form → SettingForm}/FormCharacterCount.d.ts +0 -0
- /package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/{Form → SettingForm}/FormCharacterCount.js +0 -0
- /package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/{Form → SettingForm}/FormPlaceholder.d.ts +0 -0
- /package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/{Form → SettingForm}/FormPlaceholder.js +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Solution } from "./ProblemInputNode";
|
|
2
2
|
import { NodeKey } from "lexical";
|
|
3
3
|
export declare function InputComponent(props: {
|
|
4
|
-
|
|
4
|
+
solutions: Solution[];
|
|
5
5
|
showCharacterCount: boolean;
|
|
6
6
|
placeholder: string;
|
|
7
|
-
|
|
7
|
+
answer: string;
|
|
8
8
|
nodeKey: NodeKey;
|
|
9
9
|
}): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -1,179 +1,70 @@
|
|
|
1
|
-
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
2
13
|
/** @jsxImportSource @emotion/react */
|
|
3
|
-
import { css
|
|
4
|
-
import {
|
|
5
|
-
import { useForm, useFieldArray } from "react-hook-form";
|
|
14
|
+
import { css } from "@emotion/react";
|
|
15
|
+
import { useState } from "react";
|
|
6
16
|
import Input from "../../../../components/Input";
|
|
7
17
|
import SquareButton from "../../../../components/SquareButton";
|
|
8
|
-
import {
|
|
18
|
+
import { Settings3FillIcon } from "../../../../icons";
|
|
9
19
|
import styled from "@emotion/styled";
|
|
10
|
-
import
|
|
11
|
-
import Button from "../../../../components/Button";
|
|
12
|
-
import Tooltip from "../../../../components/Tooltip";
|
|
13
|
-
import { FormAnswer, FormCharacterCount, FormPlaceholder } from "./Form";
|
|
20
|
+
import SettingForm from "./SettingForm";
|
|
14
21
|
import useLexicalEditable from "@lexical/react/useLexicalEditable";
|
|
15
22
|
import { $isProblemInputNode, } from "./ProblemInputNode";
|
|
16
23
|
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
17
24
|
import { $getNodeByKey } from "lexical";
|
|
18
25
|
export function InputComponent(props) {
|
|
19
|
-
const
|
|
20
|
-
const {
|
|
26
|
+
const { answer } = props, settingFormProps = __rest(props, ["answer"]);
|
|
27
|
+
const { placeholder, nodeKey } = settingFormProps;
|
|
21
28
|
const [editor] = useLexicalComposerContext();
|
|
22
29
|
const [settingOpen, setSettingOpen] = useState(false);
|
|
23
|
-
const [multiAnswerDisabled, setMultiAnswerDisabled] = useState(showCharacterCount);
|
|
24
30
|
const isEditable = useLexicalEditable();
|
|
25
|
-
const { control, handleSubmit } = useForm({
|
|
26
|
-
defaultValues: {
|
|
27
|
-
answers,
|
|
28
|
-
showCharacterCount,
|
|
29
|
-
placeholder,
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
const { fields, append, remove, update } = useFieldArray({
|
|
33
|
-
control,
|
|
34
|
-
name: "answers",
|
|
35
|
-
keyName: "uid",
|
|
36
|
-
});
|
|
37
|
-
const onSettingSubmit = (data) => {
|
|
38
|
-
editor.update(() => {
|
|
39
|
-
const node = $getNodeByKey(nodeKey);
|
|
40
|
-
if (!$isProblemInputNode(node)) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
node.setAnswers(data.answers);
|
|
44
|
-
node.setShowCharacterCount(data.showCharacterCount);
|
|
45
|
-
node.setPlaceholder(data.placeholder);
|
|
46
|
-
});
|
|
47
|
-
setSettingOpen(false);
|
|
48
|
-
};
|
|
49
31
|
// 학생 view
|
|
50
32
|
// TODO: "글자 수대로" 옵션시에 글자 수대로 입력칸을 표시해야 합니다.
|
|
51
33
|
if (!isEditable) {
|
|
52
|
-
return (_jsx(Input, { size: "small", placeholder: placeholder || "여기에 입력하세요.", value:
|
|
34
|
+
return (_jsx(Input, { size: "small", placeholder: placeholder || "여기에 입력하세요.", value: answer, onChange: (e) => {
|
|
53
35
|
editor.update(() => {
|
|
54
36
|
const node = $getNodeByKey(nodeKey);
|
|
55
37
|
if (!$isProblemInputNode(node)) {
|
|
56
38
|
return;
|
|
57
39
|
}
|
|
58
|
-
node.
|
|
40
|
+
node.setAnswer(e.target.value);
|
|
59
41
|
});
|
|
60
42
|
}, color: "default", css: css `
|
|
61
43
|
width: 300px;
|
|
62
44
|
` }));
|
|
63
45
|
}
|
|
64
46
|
// 교사 edit view
|
|
65
|
-
return (_jsxs(
|
|
47
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", Object.assign({ css: css `
|
|
66
48
|
display: flex;
|
|
67
49
|
align-items: center;
|
|
68
50
|
gap: 4px;
|
|
69
|
-
` }, { children: [_jsx(
|
|
70
|
-
// 수정모드에서는 입력칸 수정을 허용하지 않습니다.
|
|
71
|
-
}, color: "default", css: css `
|
|
72
|
-
width: 300px;
|
|
73
|
-
` }), _jsx(SquareButton, { size: "small", color: "icon", icon: _jsx(Settings3FillIcon, {}), onClick: () => {
|
|
51
|
+
` }, { children: [_jsx(VirtualInput, Object.assign({ onClick: () => setSettingOpen(true) }, { children: "\uC8FC\uAD00\uC2DD \uC785\uB825 \uCE78" })), _jsx(SquareButton, { size: "small", color: "icon", icon: _jsx(Settings3FillIcon, {}), onClick: () => {
|
|
74
52
|
setSettingOpen(true);
|
|
75
|
-
} })] })), settingOpen && (
|
|
76
|
-
width: 12px;
|
|
77
|
-
height: 12px;
|
|
78
|
-
` }), "\uC8FC\uAD00\uC2DD \uC785\uB825 \uCE78"] }), _jsxs(Content, { children: [_jsxs(Left, { children: [_jsxs(FormArea, { children: [_jsx(Label, { children: "\uC815\uB2F5" }), fields
|
|
79
|
-
.map((field, index) => ({
|
|
80
|
-
field,
|
|
81
|
-
index,
|
|
82
|
-
}))
|
|
83
|
-
.filter(({ field }) => !field.destroyed)
|
|
84
|
-
.map(({ field, index }) => (_jsx(FormAnswer, { index: index, control: control, disabled: index !== 0 && multiAnswerDisabled, onDelete: index !== 0
|
|
85
|
-
? () => {
|
|
86
|
-
if (field.value) {
|
|
87
|
-
update(index, Object.assign(Object.assign({}, field), { destroyed: true }));
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
remove(index);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
: undefined }, field.uid)))] }), _jsx(Button, { color: "grey", size: "small", startIcon: _jsx(AddFillIcon, {}), label: "\uBCF5\uC218 \uC815\uB2F5 \uCD94\uAC00", disabled: multiAnswerDisabled, onClick: () => {
|
|
94
|
-
append({
|
|
95
|
-
textType: "normal",
|
|
96
|
-
value: "",
|
|
97
|
-
});
|
|
98
|
-
} }), _jsxs("div", Object.assign({ css: css `
|
|
99
|
-
display: flex;
|
|
100
|
-
gap: 4px;
|
|
101
|
-
` }, { children: [_jsx(AlarmWarningFillIcon, { color: theme.color.foreground.neutralBaseDisabled, css: css `
|
|
102
|
-
width: 14px;
|
|
103
|
-
height: 14px;
|
|
104
|
-
` }), _jsxs(Label, { children: ["\uB744\uC5B4\uC4F0\uAE30, \uC54C\uD30C\uBCB3\uC758 \uB300\uC18C\uBB38\uC790 \uAD6C\uBD84\uAE4C\uC9C0 \uC77C\uCE58\uD574\uC57C \uC815\uB2F5\uC73C\uB85C \uCC98\uB9AC\uB429\uB2C8\uB2E4.", _jsx("br", {}), "\uAC00\uB2A5\uD55C \uC815\uB2F5\uC744 \uBAA8\uB450 \uCD94\uAC00\uD574\uC57C \uC6D0\uD65C\uD558\uAC8C \uC790\uB3D9 \uCC44\uC810\uD560 \uC218 \uC788\uC5B4\uC694."] })] }))] }), _jsxs(Right, { children: [_jsxs(FormArea, { children: [_jsxs(Label, { children: ["\uC785\uB825 \uCE78", _jsx(Tooltip, Object.assign({ text: _jsxs("span", { children: ["\uC608\uB97C \uB4E4\uC5B4 \uC815\uB2F5\uC774 '\uAE00\uC790 \uC218'\uC774\uACE0", _jsx("br", {}), _jsx("b", { children: "\uAE00\uC790 \uC218\uB300\uB85C" }), " \uC635\uC158\uC744 \uC120\uD0DD\uD588\uB2E4\uBA74", _jsx("br", {}), "\uC785\uB825 \uCE78\uC774 '\u2610\u2610 \u2610' \uCC98\uB7FC \uD45C\uC2DC\uB429\uB2C8\uB2E4."] }), placement: "top" }, { children: _jsx(QuestionFillIcon, { css: css `
|
|
105
|
-
width: 12px;
|
|
106
|
-
height: 12px;
|
|
107
|
-
` }) }))] }), _jsx(FormCharacterCount, { control: control, setMultiAnswerDisabled: setMultiAnswerDisabled })] }), _jsxs(FormArea, { children: [_jsxs(Label, { children: ["\uC790\uB9AC \uD45C\uC2DC\uC790", _jsx(Tooltip, Object.assign({ text: _jsx("span", { children: "\uC785\uB825 \uCE78\uC5D0 \uAE30\uBCF8\uC73C\uB85C \uB178\uCD9C\uB418\uB294 \uD14D\uC2A4\uD2B8\uC785\uB2C8\uB2E4." }), placement: "top" }, { children: _jsx(QuestionFillIcon, { css: css `
|
|
108
|
-
width: 12px;
|
|
109
|
-
height: 12px;
|
|
110
|
-
` }) }))] }), _jsx(FormPlaceholder, { control: control })] })] })] }), _jsxs(Buttons, { children: [_jsx(Button, { color: "grey", size: "xsmall", label: "\uB2EB\uAE30", onClick: () => {
|
|
111
|
-
setSettingOpen(false);
|
|
112
|
-
} }), _jsx(Button, { color: "primary", size: "xsmall", label: "\uC774\uB300\uB85C \uB123\uAE30", type: "submit" })] })] })))] })));
|
|
53
|
+
} })] })), settingOpen && (_jsx(SettingForm, Object.assign({}, settingFormProps, { onClose: () => setSettingOpen(false) })))] }));
|
|
113
54
|
}
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
border: 1px solid ${theme.color.background.neutralAltActive};
|
|
120
|
-
background: ${theme.color.background.neutralBase};
|
|
121
|
-
box-shadow: ${shadows.shadow08};
|
|
122
|
-
`);
|
|
123
|
-
const Title = styled.div(({ theme }) => css `
|
|
124
|
-
display: flex;
|
|
125
|
-
padding: 8px 12px;
|
|
126
|
-
gap: 4px;
|
|
127
|
-
align-items: center;
|
|
128
|
-
color: ${theme.color.foreground.neutralBase};
|
|
129
|
-
/* Default/Label/12px-Md */
|
|
130
|
-
font-family: ${theme.fontFamily.ui};
|
|
131
|
-
font-size: 12px;
|
|
132
|
-
font-style: normal;
|
|
133
|
-
font-weight: 500;
|
|
134
|
-
line-height: 16px; /* 133.333% */
|
|
135
|
-
`);
|
|
136
|
-
const Content = styled.div(({ theme }) => css `
|
|
137
|
-
display: flex;
|
|
138
|
-
border-top: 1px solid ${theme.color.background.neutralAltActive};
|
|
139
|
-
border-bottom: 1px solid ${theme.color.background.neutralAltActive};
|
|
140
|
-
`);
|
|
141
|
-
const Left = styled.div `
|
|
142
|
-
display: flex;
|
|
143
|
-
flex-direction: column;
|
|
144
|
-
padding: 12px;
|
|
145
|
-
gap: 12px;
|
|
146
|
-
flex: 1;
|
|
147
|
-
`;
|
|
148
|
-
const FormArea = styled.div `
|
|
149
|
-
display: flex;
|
|
150
|
-
flex-direction: column;
|
|
151
|
-
gap: 8px;
|
|
152
|
-
`;
|
|
153
|
-
const Right = styled.div `
|
|
154
|
-
display: flex;
|
|
155
|
-
box-sizing: border-box;
|
|
156
|
-
width: 240px;
|
|
157
|
-
flex-direction: column;
|
|
158
|
-
padding: 12px;
|
|
159
|
-
gap: 12px;
|
|
160
|
-
`;
|
|
161
|
-
const Label = styled.div(({ theme }) => css `
|
|
162
|
-
display: flex;
|
|
163
|
-
gap: 4px;
|
|
55
|
+
const VirtualInput = styled.div(({ theme }) => css `
|
|
56
|
+
box-sizing: border-box;
|
|
57
|
+
height: 36px;
|
|
58
|
+
width: 300px;
|
|
59
|
+
padding: 8px 16px;
|
|
164
60
|
align-items: center;
|
|
61
|
+
border-radius: 8px;
|
|
62
|
+
background: ${theme.color.background.neutralAlt};
|
|
63
|
+
cursor: pointer;
|
|
165
64
|
color: ${theme.color.foreground.neutralBaseDisabled};
|
|
166
|
-
/* Default/Label/12px-Md */
|
|
167
65
|
font-family: ${theme.fontFamily.ui};
|
|
168
|
-
font-size:
|
|
66
|
+
font-size: 14px;
|
|
169
67
|
font-style: normal;
|
|
170
|
-
font-weight:
|
|
171
|
-
line-height:
|
|
68
|
+
font-weight: 400;
|
|
69
|
+
line-height: 20px; /* 142.857% */
|
|
172
70
|
`);
|
|
173
|
-
const Buttons = styled.div `
|
|
174
|
-
display: flex;
|
|
175
|
-
padding: 12px;
|
|
176
|
-
justify-content: flex-end;
|
|
177
|
-
align-items: center;
|
|
178
|
-
gap: 8px;
|
|
179
|
-
`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DecoratorNode, EditorConfig, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from "lexical";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
|
-
export interface
|
|
3
|
+
export interface Solution {
|
|
4
4
|
textType: "normal" | "code";
|
|
5
5
|
value: string;
|
|
6
6
|
destroyed?: boolean;
|
|
@@ -8,36 +8,37 @@ export interface Answer {
|
|
|
8
8
|
export interface ProblemInputPayload {
|
|
9
9
|
showCharacterCount: boolean;
|
|
10
10
|
placeholder: string;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
solutions: Solution[];
|
|
12
|
+
answer: string;
|
|
13
13
|
key?: NodeKey;
|
|
14
14
|
}
|
|
15
15
|
export type SerializedProblemInputNode = Spread<ProblemInputPayload, SerializedLexicalNode>;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* solutions는 Solution타입의 배열로서 정답을 담고 있습니다. (교사용)
|
|
18
|
+
* answer는 학생이 입력한 답을 담고 있습니다.(학생용)
|
|
19
19
|
*/
|
|
20
20
|
export declare class ProblemInputNode extends DecoratorNode<ReactNode> {
|
|
21
|
-
|
|
21
|
+
__solutions: Solution[];
|
|
22
22
|
__showCharacterCount: boolean;
|
|
23
23
|
__placeholder: string;
|
|
24
|
-
|
|
24
|
+
__answer: string;
|
|
25
|
+
isInline(): boolean;
|
|
25
26
|
static getType(): string;
|
|
26
|
-
|
|
27
|
+
getSolutions(): Solution[];
|
|
27
28
|
getShowCharacterCount(): boolean;
|
|
28
29
|
getPlaceholder(): string;
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
getAnswer(): string;
|
|
31
|
+
setSolutions(solutions: Solution[]): void;
|
|
31
32
|
setShowCharacterCount(showCharacterCount: boolean): void;
|
|
32
33
|
setPlaceholder(placeholder: string): void;
|
|
33
|
-
|
|
34
|
+
setAnswer(answer: string): void;
|
|
34
35
|
static clone(node: ProblemInputNode): ProblemInputNode;
|
|
35
|
-
constructor(showCharacterCount: boolean, placeholder: string,
|
|
36
|
+
constructor(showCharacterCount: boolean, placeholder: string, solutions: Solution[], answer: string, key?: NodeKey);
|
|
36
37
|
createDOM(config: EditorConfig): HTMLElement;
|
|
37
38
|
updateDOM(): boolean;
|
|
38
39
|
static importJSON(serializedNode: SerializedProblemInputNode): ProblemInputNode;
|
|
39
40
|
exportJSON(): SerializedProblemInputNode;
|
|
40
41
|
decorate(): ReactNode;
|
|
41
42
|
}
|
|
42
|
-
export declare function $createProblemInputNode({ showCharacterCount, placeholder,
|
|
43
|
+
export declare function $createProblemInputNode({ showCharacterCount, placeholder, solutions, answer, key, }: ProblemInputPayload): ProblemInputNode;
|
|
43
44
|
export declare function $isProblemInputNode(node: LexicalNode | null | undefined): node is ProblemInputNode;
|
|
@@ -3,15 +3,18 @@ import { $applyNodeReplacement, DecoratorNode, } from "lexical";
|
|
|
3
3
|
import { addClassNamesToElement } from "@lexical/utils";
|
|
4
4
|
import { InputComponent } from "./InputComponent";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* solutions는 Solution타입의 배열로서 정답을 담고 있습니다. (교사용)
|
|
7
|
+
* answer는 학생이 입력한 답을 담고 있습니다.(학생용)
|
|
8
8
|
*/
|
|
9
9
|
export class ProblemInputNode extends DecoratorNode {
|
|
10
|
+
isInline() {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
10
13
|
static getType() {
|
|
11
14
|
return "problem-input";
|
|
12
15
|
}
|
|
13
|
-
|
|
14
|
-
return this.
|
|
16
|
+
getSolutions() {
|
|
17
|
+
return this.__solutions;
|
|
15
18
|
}
|
|
16
19
|
getShowCharacterCount() {
|
|
17
20
|
return this.__showCharacterCount;
|
|
@@ -19,12 +22,12 @@ export class ProblemInputNode extends DecoratorNode {
|
|
|
19
22
|
getPlaceholder() {
|
|
20
23
|
return this.__placeholder;
|
|
21
24
|
}
|
|
22
|
-
|
|
23
|
-
return this.
|
|
25
|
+
getAnswer() {
|
|
26
|
+
return this.__answer;
|
|
24
27
|
}
|
|
25
|
-
|
|
28
|
+
setSolutions(solutions) {
|
|
26
29
|
const self = this.getWritable();
|
|
27
|
-
self.
|
|
30
|
+
self.__solutions = solutions;
|
|
28
31
|
}
|
|
29
32
|
setShowCharacterCount(showCharacterCount) {
|
|
30
33
|
const self = this.getWritable();
|
|
@@ -34,25 +37,19 @@ export class ProblemInputNode extends DecoratorNode {
|
|
|
34
37
|
const self = this.getWritable();
|
|
35
38
|
self.__placeholder = placeholder;
|
|
36
39
|
}
|
|
37
|
-
|
|
40
|
+
setAnswer(answer) {
|
|
38
41
|
const self = this.getWritable();
|
|
39
|
-
self.
|
|
42
|
+
self.__answer = answer;
|
|
40
43
|
}
|
|
41
44
|
static clone(node) {
|
|
42
|
-
return
|
|
43
|
-
showCharacterCount: node.__showCharacterCount,
|
|
44
|
-
placeholder: node.__placeholder,
|
|
45
|
-
answers: node.__answers,
|
|
46
|
-
response: node.__response,
|
|
47
|
-
key: node.__key,
|
|
48
|
-
});
|
|
45
|
+
return new ProblemInputNode(node.__showCharacterCount, node.__placeholder, node.__solutions, node.__answer, node.__key);
|
|
49
46
|
}
|
|
50
|
-
constructor(showCharacterCount, placeholder,
|
|
47
|
+
constructor(showCharacterCount, placeholder, solutions, answer, key) {
|
|
51
48
|
super(key);
|
|
52
|
-
this.__answers = answers;
|
|
53
49
|
this.__showCharacterCount = showCharacterCount;
|
|
54
50
|
this.__placeholder = placeholder;
|
|
55
|
-
this.
|
|
51
|
+
this.__solutions = solutions;
|
|
52
|
+
this.__answer = answer;
|
|
56
53
|
}
|
|
57
54
|
createDOM(config) {
|
|
58
55
|
// Define the DOM element here
|
|
@@ -66,10 +63,10 @@ export class ProblemInputNode extends DecoratorNode {
|
|
|
66
63
|
static importJSON(serializedNode) {
|
|
67
64
|
const node = $createProblemInputNode({
|
|
68
65
|
key: serializedNode.key,
|
|
69
|
-
|
|
66
|
+
solutions: serializedNode.solutions,
|
|
70
67
|
showCharacterCount: serializedNode.showCharacterCount,
|
|
71
68
|
placeholder: serializedNode.placeholder,
|
|
72
|
-
|
|
69
|
+
answer: serializedNode.answer,
|
|
73
70
|
});
|
|
74
71
|
return node;
|
|
75
72
|
}
|
|
@@ -79,16 +76,16 @@ export class ProblemInputNode extends DecoratorNode {
|
|
|
79
76
|
type: "problem-input",
|
|
80
77
|
showCharacterCount: this.__showCharacterCount,
|
|
81
78
|
placeholder: this.__placeholder,
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
solutions: this.__solutions,
|
|
80
|
+
answer: this.__answer,
|
|
84
81
|
};
|
|
85
82
|
}
|
|
86
83
|
decorate() {
|
|
87
|
-
return (_jsx(InputComponent, {
|
|
84
|
+
return (_jsx(InputComponent, { solutions: this.__solutions, showCharacterCount: this.__showCharacterCount, placeholder: this.__placeholder, answer: this.__answer, nodeKey: this.getKey() }));
|
|
88
85
|
}
|
|
89
86
|
}
|
|
90
|
-
export function $createProblemInputNode({ showCharacterCount, placeholder,
|
|
91
|
-
return $applyNodeReplacement(new ProblemInputNode(showCharacterCount, placeholder,
|
|
87
|
+
export function $createProblemInputNode({ showCharacterCount, placeholder, solutions, answer, key, }) {
|
|
88
|
+
return $applyNodeReplacement(new ProblemInputNode(showCharacterCount, placeholder, solutions, answer, key));
|
|
92
89
|
}
|
|
93
90
|
export function $isProblemInputNode(node) {
|
|
94
91
|
return node instanceof ProblemInputNode;
|
|
@@ -6,4 +6,4 @@ export interface FormAnswerProps {
|
|
|
6
6
|
onDelete?: () => void;
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
}
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function FormSolution(props: FormAnswerProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -8,10 +8,10 @@ import Input from "../../../../../components/Input";
|
|
|
8
8
|
import { AlertFillIcon, DeleteBinLineIcon, ErrorWarningFillIcon, } from "../../../../../icons";
|
|
9
9
|
import SquareButton from "../../../../../components/SquareButton";
|
|
10
10
|
import Tooltip from "../../../../../components/Tooltip";
|
|
11
|
-
export function
|
|
11
|
+
export function FormSolution(props) {
|
|
12
12
|
const { index, control, onDelete, disabled } = props;
|
|
13
13
|
const theme = useTheme();
|
|
14
|
-
const TextTypeDropdown = (_jsx(Controller, { name: `
|
|
14
|
+
const TextTypeDropdown = (_jsx(Controller, { name: `solutions.${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;
|
|
@@ -28,7 +28,7 @@ export function FormAnswer(props) {
|
|
|
28
28
|
} }, { children: _jsx(DropdownItem, { index: 0, label: value === "normal" ? "코드 텍스트" : "일반 텍스트", onClick: () => {
|
|
29
29
|
onChange(value === "normal" ? "code" : "normal");
|
|
30
30
|
} }) }))) }));
|
|
31
|
-
return (_jsx(Controller, { name: `
|
|
31
|
+
return (_jsx(Controller, { name: `solutions.${index}.value`, control: control, rules: {
|
|
32
32
|
required: "정답을 입력해주세요.",
|
|
33
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 `
|
|
34
34
|
> div {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Solution } from "../ProblemInputNode";
|
|
2
|
+
import { NodeKey } from "lexical";
|
|
3
|
+
export interface SettingFormProps {
|
|
4
|
+
solutions: Solution[];
|
|
5
|
+
showCharacterCount: boolean;
|
|
6
|
+
placeholder: string;
|
|
7
|
+
nodeKey: NodeKey;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
}
|
|
10
|
+
export default function SettingForm(props: SettingFormProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { css, useTheme } from "@emotion/react";
|
|
4
|
+
import styled from "@emotion/styled";
|
|
5
|
+
import shadows from "../../../../../foundation/shadows";
|
|
6
|
+
import { AddFillIcon, AlarmWarningFillIcon, InputMethodLineIcon, QuestionFillIcon, } from "../../../../../icons";
|
|
7
|
+
import { useFieldArray, useForm, } from "react-hook-form";
|
|
8
|
+
import { $isProblemInputNode, } from "../ProblemInputNode";
|
|
9
|
+
import { FormSolution } from "./FormSolution";
|
|
10
|
+
import Button from "../../../../../components/Button";
|
|
11
|
+
import Tooltip from "../../../../../components/Tooltip";
|
|
12
|
+
import { FormCharacterCount } from "./FormCharacterCount";
|
|
13
|
+
import { FormPlaceholder } from "./FormPlaceholder";
|
|
14
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
15
|
+
import { $getNodeByKey } from "lexical";
|
|
16
|
+
import { useState } from "react";
|
|
17
|
+
export default function SettingForm(props) {
|
|
18
|
+
const { solutions, showCharacterCount, placeholder, nodeKey, onClose } = props;
|
|
19
|
+
const [editor] = useLexicalComposerContext();
|
|
20
|
+
//fixme: multiAnswerDisabled 삭제
|
|
21
|
+
const [multiAnswerDisabled, setMultiAnswerDisabled] = useState(showCharacterCount);
|
|
22
|
+
const { control, handleSubmit } = useForm({
|
|
23
|
+
defaultValues: {
|
|
24
|
+
solutions,
|
|
25
|
+
showCharacterCount,
|
|
26
|
+
placeholder,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
const theme = useTheme();
|
|
30
|
+
const { fields, append, remove, update } = useFieldArray({
|
|
31
|
+
control,
|
|
32
|
+
name: "solutions",
|
|
33
|
+
keyName: "uid",
|
|
34
|
+
});
|
|
35
|
+
const onSettingSubmit = (data) => {
|
|
36
|
+
editor.update(() => {
|
|
37
|
+
const node = $getNodeByKey(nodeKey);
|
|
38
|
+
if (!$isProblemInputNode(node)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
node.setSolutions(data.solutions);
|
|
42
|
+
node.setShowCharacterCount(data.showCharacterCount);
|
|
43
|
+
node.setPlaceholder(data.placeholder);
|
|
44
|
+
});
|
|
45
|
+
onClose();
|
|
46
|
+
};
|
|
47
|
+
return (_jsxs(Form, Object.assign({ onSubmit: handleSubmit(onSettingSubmit) }, { children: [_jsxs(Title, { children: [_jsx(InputMethodLineIcon, { css: css `
|
|
48
|
+
width: 12px;
|
|
49
|
+
height: 12px;
|
|
50
|
+
` }), "\uC8FC\uAD00\uC2DD \uC785\uB825 \uCE78"] }), _jsxs(Content, { children: [_jsxs(Left, { children: [_jsxs(FormArea, { children: [_jsx(Label, { children: "\uC815\uB2F5" }), fields
|
|
51
|
+
.map((field, index) => ({
|
|
52
|
+
field,
|
|
53
|
+
index,
|
|
54
|
+
}))
|
|
55
|
+
.filter(({ field }) => !field.destroyed)
|
|
56
|
+
.map(({ field, index }) => (_jsx(FormSolution, { index: index, control: control, disabled: index !== 0 && multiAnswerDisabled, onDelete: index !== 0
|
|
57
|
+
? () => {
|
|
58
|
+
if (field.value) {
|
|
59
|
+
update(index, Object.assign(Object.assign({}, field), { destroyed: true }));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
remove(index);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
: undefined }, field.uid)))] }), _jsx(Button, { color: "grey", size: "small", startIcon: _jsx(AddFillIcon, {}), label: "\uBCF5\uC218 \uC815\uB2F5 \uCD94\uAC00", disabled: multiAnswerDisabled, onClick: () => {
|
|
66
|
+
append({
|
|
67
|
+
textType: "normal",
|
|
68
|
+
value: "",
|
|
69
|
+
});
|
|
70
|
+
} }), _jsxs("div", Object.assign({ css: css `
|
|
71
|
+
display: flex;
|
|
72
|
+
gap: 4px;
|
|
73
|
+
` }, { children: [_jsx(AlarmWarningFillIcon, { color: theme.color.foreground.neutralBaseDisabled, css: css `
|
|
74
|
+
width: 14px;
|
|
75
|
+
height: 14px;
|
|
76
|
+
` }), _jsxs(Label, { children: ["\uB744\uC5B4\uC4F0\uAE30, \uC54C\uD30C\uBCB3\uC758 \uB300\uC18C\uBB38\uC790 \uAD6C\uBD84\uAE4C\uC9C0 \uC77C\uCE58\uD574\uC57C \uC815\uB2F5\uC73C\uB85C \uCC98\uB9AC\uB429\uB2C8\uB2E4.", _jsx("br", {}), "\uAC00\uB2A5\uD55C \uC815\uB2F5\uC744 \uBAA8\uB450 \uCD94\uAC00\uD574\uC57C \uC6D0\uD65C\uD558\uAC8C \uC790\uB3D9 \uCC44\uC810\uD560 \uC218 \uC788\uC5B4\uC694."] })] }))] }), _jsxs(Right, { children: [_jsxs(FormArea, { children: [_jsxs(Label, { children: ["\uC785\uB825 \uCE78", _jsx(Tooltip, Object.assign({ text: _jsxs("span", { children: ["\uC608\uB97C \uB4E4\uC5B4 \uC815\uB2F5\uC774 '\uAE00\uC790 \uC218'\uC774\uACE0", _jsx("br", {}), _jsx("b", { children: "\uAE00\uC790 \uC218\uB300\uB85C" }), " \uC635\uC158\uC744 \uC120\uD0DD\uD588\uB2E4\uBA74", _jsx("br", {}), "\uC785\uB825 \uCE78\uC774 '\u2610\u2610 \u2610' \uCC98\uB7FC \uD45C\uC2DC\uB429\uB2C8\uB2E4."] }), placement: "top" }, { children: _jsx(QuestionFillIcon, { css: css `
|
|
77
|
+
width: 12px;
|
|
78
|
+
height: 12px;
|
|
79
|
+
` }) }))] }), _jsx(FormCharacterCount, { control: control, setMultiAnswerDisabled: setMultiAnswerDisabled })] }), _jsxs(FormArea, { children: [_jsxs(Label, { children: ["\uC790\uB9AC \uD45C\uC2DC\uC790", _jsx(Tooltip, Object.assign({ text: _jsx("span", { children: "\uC785\uB825 \uCE78\uC5D0 \uAE30\uBCF8\uC73C\uB85C \uB178\uCD9C\uB418\uB294 \uD14D\uC2A4\uD2B8\uC785\uB2C8\uB2E4." }), placement: "top" }, { children: _jsx(QuestionFillIcon, { css: css `
|
|
80
|
+
width: 12px;
|
|
81
|
+
height: 12px;
|
|
82
|
+
` }) }))] }), _jsx(FormPlaceholder, { control: control })] })] })] }), _jsxs(Buttons, { children: [_jsx(Button, { color: "grey", size: "xsmall", label: "\uB2EB\uAE30", onClick: onClose }), _jsx(Button, { color: "primary", size: "xsmall", label: "\uC774\uB300\uB85C \uB123\uAE30", type: "submit" })] })] })));
|
|
83
|
+
}
|
|
84
|
+
const Form = styled.form(({ theme }) => css `
|
|
85
|
+
display: flex;
|
|
86
|
+
width: 620px;
|
|
87
|
+
flex-direction: column;
|
|
88
|
+
border-radius: 6px;
|
|
89
|
+
border: 1px solid ${theme.color.background.neutralAltActive};
|
|
90
|
+
background: ${theme.color.background.neutralBase};
|
|
91
|
+
box-shadow: ${shadows.shadow08};
|
|
92
|
+
`);
|
|
93
|
+
const Title = styled.div(({ theme }) => css `
|
|
94
|
+
display: flex;
|
|
95
|
+
padding: 8px 12px;
|
|
96
|
+
gap: 4px;
|
|
97
|
+
align-items: center;
|
|
98
|
+
color: ${theme.color.foreground.neutralBase};
|
|
99
|
+
/* Default/Label/12px-Md */
|
|
100
|
+
font-family: ${theme.fontFamily.ui};
|
|
101
|
+
font-size: 12px;
|
|
102
|
+
font-style: normal;
|
|
103
|
+
font-weight: 500;
|
|
104
|
+
line-height: 16px; /* 133.333% */
|
|
105
|
+
`);
|
|
106
|
+
const Content = styled.div(({ theme }) => css `
|
|
107
|
+
display: flex;
|
|
108
|
+
border-top: 1px solid ${theme.color.background.neutralAltActive};
|
|
109
|
+
border-bottom: 1px solid ${theme.color.background.neutralAltActive};
|
|
110
|
+
`);
|
|
111
|
+
const Left = styled.div `
|
|
112
|
+
display: flex;
|
|
113
|
+
flex-direction: column;
|
|
114
|
+
padding: 12px;
|
|
115
|
+
gap: 12px;
|
|
116
|
+
flex: 1;
|
|
117
|
+
`;
|
|
118
|
+
const FormArea = styled.div `
|
|
119
|
+
display: flex;
|
|
120
|
+
flex-direction: column;
|
|
121
|
+
gap: 8px;
|
|
122
|
+
`;
|
|
123
|
+
const Right = styled.div `
|
|
124
|
+
display: flex;
|
|
125
|
+
box-sizing: border-box;
|
|
126
|
+
width: 240px;
|
|
127
|
+
flex-direction: column;
|
|
128
|
+
padding: 12px;
|
|
129
|
+
gap: 12px;
|
|
130
|
+
`;
|
|
131
|
+
const Label = styled.div(({ theme }) => css `
|
|
132
|
+
display: flex;
|
|
133
|
+
gap: 4px;
|
|
134
|
+
align-items: center;
|
|
135
|
+
color: ${theme.color.foreground.neutralBaseDisabled};
|
|
136
|
+
/* Default/Label/12px-Md */
|
|
137
|
+
font-family: ${theme.fontFamily.ui};
|
|
138
|
+
font-size: 12px;
|
|
139
|
+
font-style: normal;
|
|
140
|
+
font-weight: 500;
|
|
141
|
+
line-height: 16px; /* 133.333% */
|
|
142
|
+
`);
|
|
143
|
+
const Buttons = styled.div `
|
|
144
|
+
display: flex;
|
|
145
|
+
padding: 12px;
|
|
146
|
+
justify-content: flex-end;
|
|
147
|
+
align-items: center;
|
|
148
|
+
gap: 8px;
|
|
149
|
+
`;
|
package/dist/patterns/LexicalEditor/plugins/ComponentPickerMenuPlugin/ComponentPickerMenuPlugin.js
CHANGED
|
@@ -71,7 +71,7 @@ function getQuizContextOptions(editor, theme) {
|
|
|
71
71
|
icon: _jsx(InputMethodLineIcon, { color: theme.color.foreground.primary }),
|
|
72
72
|
keywords: ["short answer", "short answer input", "주관식", "주관식 입력"],
|
|
73
73
|
onSelect: () => editor.dispatchCommand(INSERT_SHORT_ANSWER_COMMAND, {
|
|
74
|
-
|
|
74
|
+
solutions: [
|
|
75
75
|
{
|
|
76
76
|
textType: "normal",
|
|
77
77
|
value: "",
|
|
@@ -79,7 +79,7 @@ function getQuizContextOptions(editor, theme) {
|
|
|
79
79
|
],
|
|
80
80
|
showCharacterCount: false,
|
|
81
81
|
placeholder: "",
|
|
82
|
-
|
|
82
|
+
answer: "",
|
|
83
83
|
}),
|
|
84
84
|
}),
|
|
85
85
|
new ComponentPickerOption("객관식 입력 칸", {
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/{Form → SettingForm}/FormPlaceholder.js
RENAMED
|
File without changes
|