@team-monolith/cds 1.11.2 → 1.12.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/patterns/LexicalEditor/nodes/ProblemInputNode/InputComponent.js +12 -18
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/SegmentedInput.js +9 -22
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/ProblemSelectNode.d.ts +3 -3
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/ProblemSelectNode.js +1 -0
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectBox.js +1 -3
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectComponent.d.ts +1 -1
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectComponent.js +6 -1
- package/dist/patterns/LexicalEditor/plugins/ComponentPickerMenuPlugin/ComponentPickerMenuPlugin.js +1 -0
- package/package.json +1 -1
|
@@ -38,29 +38,23 @@ export function InputComponent(props) {
|
|
|
38
38
|
const lexicalCustomConfig = useContext(LexicalCustomConfigContext);
|
|
39
39
|
// "** ***" 같은 형태입니다.
|
|
40
40
|
const answerFormat = solutions[0].value;
|
|
41
|
+
const handleChange = (value) => {
|
|
42
|
+
setAnswerInput(value);
|
|
43
|
+
editor.update(() => {
|
|
44
|
+
const node = $getNodeByKey(nodeKey);
|
|
45
|
+
if (!$isProblemInputNode(node)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
node.setAnswer(value);
|
|
49
|
+
});
|
|
50
|
+
};
|
|
41
51
|
// 학생 view
|
|
42
52
|
if (!isEditable) {
|
|
43
53
|
if (showCharacterNumber) {
|
|
44
|
-
return (_jsx(SegmentedInput, { readOnly: lexicalCustomConfig.freezeProblemNode, answerFormat: answerFormat, placeholder: placeholder || "여기에 입력하세요.", value: answerInput, onChange:
|
|
45
|
-
setAnswerInput(value);
|
|
46
|
-
editor.update(() => {
|
|
47
|
-
const node = $getNodeByKey(nodeKey);
|
|
48
|
-
if (!$isProblemInputNode(node)) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
node.setAnswer(value);
|
|
52
|
-
});
|
|
53
|
-
} }));
|
|
54
|
+
return (_jsx(SegmentedInput, { readOnly: lexicalCustomConfig.freezeProblemNode, answerFormat: answerFormat, placeholder: placeholder || "여기에 입력하세요.", value: answerInput, onChange: handleChange }));
|
|
54
55
|
}
|
|
55
56
|
return (_jsx(TextInput, { readOnly: lexicalCustomConfig.freezeProblemNode, size: "small", color: "default", placeholder: placeholder || "여기에 입력하세요.", value: answerInput, onChange: (e) => {
|
|
56
|
-
|
|
57
|
-
editor.update(() => {
|
|
58
|
-
const node = $getNodeByKey(nodeKey);
|
|
59
|
-
if (!$isProblemInputNode(node)) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
node.setAnswer(e.target.value);
|
|
63
|
-
});
|
|
57
|
+
handleChange(e.target.value);
|
|
64
58
|
}, fullWidth: true }));
|
|
65
59
|
}
|
|
66
60
|
// 교사 edit view
|
|
@@ -4,14 +4,6 @@ import { css } from "@emotion/react";
|
|
|
4
4
|
import styled from "@emotion/styled";
|
|
5
5
|
import { InputBase } from "../../../../components/InputBase";
|
|
6
6
|
import { useRef, useState } from "react";
|
|
7
|
-
function getDiffIndex(short, long) {
|
|
8
|
-
for (let i = 0; i < short.length; i++) {
|
|
9
|
-
if (short[i] !== long[i]) {
|
|
10
|
-
return i;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return short.length;
|
|
14
|
-
}
|
|
15
7
|
/**
|
|
16
8
|
* SOT는 value이고, 그 value는 숨겨진 input에 작성됩니다.
|
|
17
9
|
* 그리고 그 value는 split되어 segmented input에 표시됩니다.
|
|
@@ -29,28 +21,21 @@ export default function SegmentedInput(props) {
|
|
|
29
21
|
const hiddenRef = useRef(null);
|
|
30
22
|
return (_jsxs(Container, { children: [_jsx("input", { type: "input", ref: hiddenRef, value: splitedValues.join(""), readOnly: readOnly, onKeyDown: (e) => {
|
|
31
23
|
if (e.key === "ArrowLeft") {
|
|
32
|
-
if (focusedIndex
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
24
|
+
if (focusedIndex !== null && focusedIndex > 0) {
|
|
36
25
|
setFocusedIndex(focusedIndex - 1);
|
|
37
26
|
}
|
|
38
27
|
}
|
|
39
28
|
else if (e.key === "ArrowRight") {
|
|
40
|
-
if (focusedIndex
|
|
41
|
-
focusedIndex
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
29
|
+
if (focusedIndex !== null &&
|
|
30
|
+
focusedIndex < despacedFormat.length - 1) {
|
|
45
31
|
setFocusedIndex(focusedIndex + 1);
|
|
46
32
|
}
|
|
47
33
|
}
|
|
48
34
|
}, onChange: (event) => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
setFocusedIndex(diffIndex);
|
|
35
|
+
var _a;
|
|
36
|
+
onChange(event.target.value);
|
|
37
|
+
const selectionStart = (_a = hiddenRef.current) === null || _a === void 0 ? void 0 : _a.selectionStart;
|
|
38
|
+
setFocusedIndex(selectionStart ? selectionStart - 1 : null);
|
|
54
39
|
}, onBlur: (e) => {
|
|
55
40
|
setFocusedIndex(null);
|
|
56
41
|
const eventValue = e.target.value;
|
|
@@ -68,6 +53,8 @@ export default function SegmentedInput(props) {
|
|
|
68
53
|
readOnly,
|
|
69
54
|
onFocus: () => {
|
|
70
55
|
var _a, _b;
|
|
56
|
+
if (readOnly)
|
|
57
|
+
return;
|
|
71
58
|
setFocusedIndex(i);
|
|
72
59
|
(_a = hiddenRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
73
60
|
(_b = hiddenRef.current) === null || _b === void 0 ? void 0 : _b.setSelectionRange(i, i);
|
|
@@ -15,7 +15,7 @@ export interface Selection {
|
|
|
15
15
|
export interface ProblemSelectPayload {
|
|
16
16
|
selections: Selection[];
|
|
17
17
|
selected: string[];
|
|
18
|
-
hasMultipleAnswers
|
|
18
|
+
hasMultipleAnswers: boolean;
|
|
19
19
|
key?: NodeKey;
|
|
20
20
|
}
|
|
21
21
|
export type SerializedProblemSelectNode = Spread<ProblemSelectPayload, SerializedLexicalNode>;
|
|
@@ -26,7 +26,7 @@ export type SerializedProblemSelectNode = Spread<ProblemSelectPayload, Serialize
|
|
|
26
26
|
export declare class ProblemSelectNode extends DecoratorNode<ReactNode> {
|
|
27
27
|
__selections: Selection[];
|
|
28
28
|
__selected: string[];
|
|
29
|
-
__hasMultipleAnswers: boolean
|
|
29
|
+
__hasMultipleAnswers: boolean;
|
|
30
30
|
isInline(): boolean;
|
|
31
31
|
static getType(): string;
|
|
32
32
|
getSelections(): Selection[];
|
|
@@ -34,7 +34,7 @@ export declare class ProblemSelectNode extends DecoratorNode<ReactNode> {
|
|
|
34
34
|
setSelections(selections: Selection[]): void;
|
|
35
35
|
setSelected(selected: string[]): void;
|
|
36
36
|
static clone(node: ProblemSelectNode): ProblemSelectNode;
|
|
37
|
-
constructor(selections: Selection[], selected: string[], hasMultipleAnswers
|
|
37
|
+
constructor(selections: Selection[], selected: string[], hasMultipleAnswers: boolean, key?: NodeKey);
|
|
38
38
|
createDOM(config: EditorConfig): HTMLElement;
|
|
39
39
|
updateDOM(): boolean;
|
|
40
40
|
static importJSON(serializedNode: SerializedProblemSelectNode): ProblemSelectNode;
|
|
@@ -44,9 +44,7 @@ const Index = styled.div(({ theme, isSelected }) => css `
|
|
|
44
44
|
width: 20px;
|
|
45
45
|
height: 20px;
|
|
46
46
|
padding: 4px;
|
|
47
|
-
|
|
48
|
-
-webkit-user-select: none; /* Safari */
|
|
49
|
-
-ms-user-select: none; /* IE 10 and IE 11 */
|
|
47
|
+
|
|
50
48
|
user-select: none; /* Standard syntax */
|
|
51
49
|
|
|
52
50
|
justify-content: center;
|
|
@@ -4,6 +4,6 @@ import { Selection } from "./ProblemSelectNode";
|
|
|
4
4
|
export declare function SelectComponent(props: {
|
|
5
5
|
selections: Selection[];
|
|
6
6
|
selected: string[];
|
|
7
|
-
hasMultipleAnswers
|
|
7
|
+
hasMultipleAnswers: boolean;
|
|
8
8
|
nodeKey: NodeKey;
|
|
9
9
|
}): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -54,7 +54,12 @@ export function SelectComponent(props) {
|
|
|
54
54
|
if (!$isProblemSelectNode(node)) {
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
if (hasMultipleAnswers) {
|
|
58
|
+
node.setSelected([...selected, selection.value]);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
node.setSelected([selection.value]);
|
|
62
|
+
}
|
|
58
63
|
});
|
|
59
64
|
}
|
|
60
65
|
}, fullWidth: true }, index)))] }));
|