@elice/material-quiz 1.240718.0-trasncript.2 → 1.240718.1
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/cjs/components/eb-sortable/EbDraggable.js +33 -42
- package/cjs/components/eb-sortable/EbDroppable.js +20 -27
- package/cjs/components/markdown-editor/index.d.ts +2 -1
- package/cjs/components/markdown-editor/index.js +10 -19
- package/cjs/components/material-quiz/MaterialQuiz.js +83 -114
- package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.js +29 -36
- package/cjs/components/material-quiz/MaterialQuizInfo.js +149 -151
- package/cjs/components/material-quiz/MaterialQuizSelectMultiple.js +127 -175
- package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.js +286 -360
- package/cjs/components/material-quiz/MaterialQuizSelectOne.js +126 -172
- package/cjs/components/material-quiz/MaterialQuizShimmer.js +39 -46
- package/cjs/components/material-quiz/MaterialQuizText.js +115 -163
- package/cjs/components/material-quiz/QuizResultBadge.js +22 -32
- package/cjs/components/material-quiz/QuizSubmitStatusText.js +16 -21
- package/cjs/components/material-quiz/constants/color.js +5 -5
- package/cjs/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
- package/cjs/components/material-quiz/context/MaterialQuizContext.js +93 -156
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +161 -259
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +100 -134
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +101 -130
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +52 -64
- package/cjs/components/material-quiz/material-quiz-group/context/context.js +1 -5
- package/cjs/components/material-quiz-edit/MaterialQuizEdit.js +36 -47
- package/cjs/components/material-quiz-edit/MaterialQuizEditContent.js +232 -280
- package/cjs/components/material-quiz-edit/context.js +2 -8
- package/cjs/components/material-quiz-edit/options/OptionEditor.js +46 -70
- package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.js +148 -174
- package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +149 -175
- package/cjs/components/material-quiz-edit/options/OptionSelectOne.js +144 -164
- package/cjs/components/material-quiz-edit/options/OptionText.js +82 -90
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroup.js +8 -9
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +112 -156
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +196 -288
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +75 -88
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +92 -108
- package/cjs/components/material-quiz-edit/utils/checkTwoDimensionArray.js +1 -5
- package/cjs/components/material-quiz-edit/utils/editValue.js +12 -21
- package/cjs/components/shared/QuestionBox.js +165 -198
- package/cjs/components/shared/QuizDraggbleDroppedOption.js +12 -11
- package/cjs/components/shared/QuizDraggbleDummyOption.js +16 -23
- package/cjs/components/shared/QuizDraggbleOption.js +59 -65
- package/cjs/components/shared/StyledMarkdown.js +1 -5
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +7 -13
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -24
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +68 -59
- package/cjs/components/shared/question-radio/QuestionRadio.js +7 -13
- package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/cjs/components/shared/question-radio/QuestionRadioContext.js +17 -24
- package/cjs/components/shared/question-radio/QuestionRadioOption.js +59 -52
- package/cjs/components/shared/utils/getQuestionStatusStyle.js +9 -7
- package/cjs/components/shared/utils/mergeRefs.js +6 -15
- package/cjs/constant/element.js +3 -3
- package/cjs/helpers/index.js +10 -8
- package/cjs/hooks/useCaculatePassage.js +20 -21
- package/es/components/eb-sortable/EbDraggable.js +33 -37
- package/es/components/eb-sortable/EbDroppable.js +20 -22
- package/es/components/markdown-editor/index.d.ts +2 -1
- package/es/components/markdown-editor/index.js +10 -15
- package/es/components/material-quiz/MaterialQuiz.js +83 -109
- package/es/components/material-quiz/MaterialQuizAnswerExplanation.js +29 -32
- package/es/components/material-quiz/MaterialQuizInfo.js +150 -148
- package/es/components/material-quiz/MaterialQuizSelectMultiple.js +127 -171
- package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.js +287 -356
- package/es/components/material-quiz/MaterialQuizSelectOne.js +126 -168
- package/es/components/material-quiz/MaterialQuizShimmer.js +39 -42
- package/es/components/material-quiz/MaterialQuizText.js +115 -158
- package/es/components/material-quiz/QuizResultBadge.js +22 -27
- package/es/components/material-quiz/QuizSubmitStatusText.js +16 -17
- package/es/components/material-quiz/constants/color.js +5 -5
- package/es/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
- package/es/components/material-quiz/context/MaterialQuizContext.js +94 -153
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +161 -253
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +100 -129
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +101 -125
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +52 -60
- package/es/components/material-quiz/material-quiz-group/context/context.js +1 -1
- package/es/components/material-quiz-edit/MaterialQuizEdit.js +36 -43
- package/es/components/material-quiz-edit/MaterialQuizEditContent.js +229 -272
- package/es/components/material-quiz-edit/context.js +2 -4
- package/es/components/material-quiz-edit/options/OptionEditor.js +46 -64
- package/es/components/material-quiz-edit/options/OptionSelectMultiple.js +148 -170
- package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +149 -171
- package/es/components/material-quiz-edit/options/OptionSelectOne.js +144 -159
- package/es/components/material-quiz-edit/options/OptionText.js +82 -86
- package/es/components/material-quiz-edit/options/options-group/OptionGroup.js +8 -9
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +112 -151
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +197 -283
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +75 -83
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +92 -103
- package/es/components/material-quiz-edit/utils/checkTwoDimensionArray.js +1 -5
- package/es/components/material-quiz-edit/utils/editValue.js +12 -17
- package/es/components/shared/QuestionBox.js +165 -192
- package/es/components/shared/QuizDraggbleDroppedOption.js +12 -11
- package/es/components/shared/QuizDraggbleDummyOption.js +16 -19
- package/es/components/shared/QuizDraggbleOption.js +59 -61
- package/es/components/shared/StyledMarkdown.js +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckbox.js +7 -9
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -20
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +68 -54
- package/es/components/shared/question-radio/QuestionRadio.js +7 -9
- package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/es/components/shared/question-radio/QuestionRadioContext.js +17 -20
- package/es/components/shared/question-radio/QuestionRadioOption.js +59 -47
- package/es/components/shared/utils/getQuestionStatusStyle.js +9 -7
- package/es/components/shared/utils/mergeRefs.js +6 -15
- package/es/constant/element.js +3 -3
- package/es/helpers/index.js +10 -8
- package/es/hooks/useCaculatePassage.js +20 -21
- package/package.json +15 -12
- package/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -423
- package/cjs/components/material-quiz/index.js +0 -9
- package/cjs/components/material-quiz/locales/index.js +0 -13
- package/cjs/components/material-quiz-edit/index.js +0 -7
- package/cjs/components/material-quiz-edit/locales/index.js +0 -13
- package/cjs/components/shared/index.js +0 -19
- package/cjs/constant/index.js +0 -9
- package/cjs/hooks/index.js +0 -7
- package/es/_virtual/_rollupPluginBabelHelpers.js +0 -408
- package/es/components/material-quiz/index.js +0 -2
- package/es/components/material-quiz/locales/index.js +0 -4
- package/es/components/material-quiz-edit/index.js +0 -1
- package/es/components/material-quiz-edit/locales/index.js +0 -4
- package/es/components/shared/index.js +0 -7
- package/es/constant/index.js +0 -1
- package/es/hooks/index.js +0 -1
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
5
|
var React = require('react');
|
|
7
6
|
var designTokens = require('@elice/design-tokens');
|
|
8
7
|
var styled = require('styled-components');
|
|
@@ -10,16 +9,12 @@ var color = require('../../material-quiz/constants/color.js');
|
|
|
10
9
|
var getQuestionStatusStyle = require('../utils/getQuestionStatusStyle.js');
|
|
11
10
|
var QuestionRadioContext = require('./QuestionRadioContext.js');
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
16
|
-
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
17
|
-
|
|
18
|
-
var StyledQuestionRadioOption = styled__default.default.div.withConfig({
|
|
12
|
+
const StyledQuestionRadioOption = styled.div.withConfig({
|
|
19
13
|
componentId: "sc-cy66me-0"
|
|
20
|
-
})(["display:flex;align-items:center;padding:0.875rem 1rem;border-radius:8px;background-color:", ";overflow-x:auto;&:not(:last-of-type){margin-bottom:1rem;}&:hover,& *:hover{cursor:", ";}", ""],
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
})(["display:flex;align-items:center;padding:0.875rem 1rem;border-radius:8px;background-color:", ";overflow-x:auto;&:not(:last-of-type){margin-bottom:1rem;}&:hover,& *:hover{cursor:", ";}", ""], ({
|
|
15
|
+
checked,
|
|
16
|
+
status
|
|
17
|
+
}) => {
|
|
23
18
|
switch (status) {
|
|
24
19
|
case 'correct':
|
|
25
20
|
return color.CORRECT_BACKGROUND_COLOR;
|
|
@@ -30,18 +25,17 @@ var StyledQuestionRadioOption = styled__default.default.div.withConfig({
|
|
|
30
25
|
default:
|
|
31
26
|
return checked ? designTokens.base.color.primary1 : designTokens.base.color.navy6;
|
|
32
27
|
}
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
var StyledQuestionRadioInput = styled__default.default.input.withConfig({
|
|
28
|
+
}, ({
|
|
29
|
+
disabled
|
|
30
|
+
}) => disabled ? 'not-allowed' : 'pointer', ({
|
|
31
|
+
isAnswer
|
|
32
|
+
}) => isAnswer ? `border: 3px solid ${designTokens.base.color.green5}` : '');
|
|
33
|
+
const StyledQuestionRadioInput = styled.input.withConfig({
|
|
41
34
|
componentId: "sc-cy66me-1"
|
|
42
|
-
})(["flex:none;margin:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;position:relative;border-radius:50%;width:1rem;height:1rem;margin-right:0.875rem;border:2px solid ", ";", ""],
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
})(["flex:none;margin:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;position:relative;border-radius:50%;width:1rem;height:1rem;margin-right:0.875rem;border:2px solid ", ";", ""], ({
|
|
36
|
+
checked,
|
|
37
|
+
status
|
|
38
|
+
}) => {
|
|
45
39
|
switch (status) {
|
|
46
40
|
case 'correct':
|
|
47
41
|
return designTokens.base.color.green9;
|
|
@@ -50,10 +44,11 @@ var StyledQuestionRadioInput = styled__default.default.input.withConfig({
|
|
|
50
44
|
default:
|
|
51
45
|
return checked ? designTokens.base.color.primary6 : designTokens.base.color.gray3;
|
|
52
46
|
}
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
}, ({
|
|
48
|
+
status,
|
|
49
|
+
checked
|
|
50
|
+
}) => {
|
|
51
|
+
let bgColor;
|
|
57
52
|
switch (status) {
|
|
58
53
|
case 'correct':
|
|
59
54
|
bgColor = designTokens.base.color.green9;
|
|
@@ -65,45 +60,57 @@ var StyledQuestionRadioInput = styled__default.default.input.withConfig({
|
|
|
65
60
|
bgColor = checked ? designTokens.base.color.primary6 : status ? designTokens.base.color.gray3 : 'transparent';
|
|
66
61
|
break;
|
|
67
62
|
}
|
|
68
|
-
return
|
|
63
|
+
return `
|
|
64
|
+
&:after {
|
|
65
|
+
content: '';
|
|
66
|
+
position: absolute;
|
|
67
|
+
top: 50%;
|
|
68
|
+
left: 50%;
|
|
69
|
+
transform: translate(-50%, -50%);
|
|
70
|
+
width: 70%;
|
|
71
|
+
height: 70%;
|
|
72
|
+
border-radius: 50%;
|
|
73
|
+
background-color: ${bgColor};
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
69
76
|
});
|
|
70
|
-
|
|
77
|
+
const StyledLabel = styled.label.withConfig({
|
|
71
78
|
componentId: "sc-cy66me-2"
|
|
72
79
|
})(["word-break:break-all;margin-right:0.875rem;font-size:", ";line-height:24px;", ""], designTokens.base.size.body3, getQuestionStatusStyle.getQuestionStatusStyle());
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
const QuestionRadioOption = React.memo(({
|
|
81
|
+
value,
|
|
82
|
+
status,
|
|
83
|
+
isAnswer,
|
|
84
|
+
children
|
|
85
|
+
}) => {
|
|
86
|
+
const {
|
|
87
|
+
selectedValue,
|
|
88
|
+
disabled,
|
|
89
|
+
onSelect
|
|
90
|
+
} = QuestionRadioContext.useQuestionRadioContext();
|
|
91
|
+
return React.createElement(StyledQuestionRadioOption, {
|
|
83
92
|
isAnswer: isAnswer,
|
|
84
93
|
disabled: disabled,
|
|
85
94
|
checked: selectedValue === value,
|
|
86
|
-
onClick:
|
|
95
|
+
onClick: e => {
|
|
87
96
|
e.preventDefault();
|
|
88
97
|
if (disabled) {
|
|
89
98
|
return;
|
|
90
99
|
}
|
|
91
100
|
onSelect(value);
|
|
92
101
|
},
|
|
93
|
-
status: status
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
})]
|
|
106
|
-
});
|
|
102
|
+
status: status
|
|
103
|
+
}, React.createElement(StyledQuestionRadioInput, {
|
|
104
|
+
id: value,
|
|
105
|
+
type: "radio",
|
|
106
|
+
readOnly: true,
|
|
107
|
+
checked: selectedValue === value,
|
|
108
|
+
status: status
|
|
109
|
+
}), React.createElement(StyledLabel, {
|
|
110
|
+
htmlFor: value,
|
|
111
|
+
checked: selectedValue === value,
|
|
112
|
+
status: status
|
|
113
|
+
}, children));
|
|
107
114
|
});
|
|
108
115
|
|
|
109
116
|
exports.default = QuestionRadioOption;
|
|
@@ -8,9 +8,10 @@ var color = require('../../material-quiz/constants/color.js');
|
|
|
8
8
|
* Get shared question custom style depend on checked, status values.
|
|
9
9
|
*/
|
|
10
10
|
function getQuestionStatusStyle() {
|
|
11
|
-
return styled.css(["&,& p,& p.elicemd.elicemd--theme-dark{color:", ";table tbody > tr:nth-child(odd) > td{background-color:", ";}}"],
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
return styled.css(["&,& p,& p.elicemd.elicemd--theme-dark{color:", ";table tbody > tr:nth-child(odd) > td{background-color:", ";}}"], ({
|
|
12
|
+
checked,
|
|
13
|
+
status
|
|
14
|
+
}) => {
|
|
14
15
|
switch (status) {
|
|
15
16
|
case 'correct':
|
|
16
17
|
return color.CORRECT_TEXT_COLOR;
|
|
@@ -19,10 +20,11 @@ function getQuestionStatusStyle() {
|
|
|
19
20
|
default:
|
|
20
21
|
return checked ? designTokens.base.color.primary6 : designTokens.base.color.navy0;
|
|
21
22
|
}
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
}, ({
|
|
24
|
+
checked,
|
|
25
|
+
status
|
|
26
|
+
}) => {
|
|
27
|
+
return checked || status !== 'answer' ? `rgba(0, 0, 0, 0.08);` : null;
|
|
26
28
|
});
|
|
27
29
|
}
|
|
28
30
|
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const mergeRefs = (...refs) => element => refs.forEach(ref => {
|
|
4
|
+
if (typeof ref === 'function') {
|
|
5
|
+
ref(element);
|
|
6
|
+
} else if (ref && typeof ref === 'object') {
|
|
7
|
+
ref.current = element;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
return refs.forEach(function (ref) {
|
|
11
|
-
if (typeof ref === 'function') {
|
|
12
|
-
ref(element);
|
|
13
|
-
} else if (ref && _rollupPluginBabelHelpers.typeof(ref) === 'object') {
|
|
14
|
-
ref.current = element;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
};
|
|
9
|
+
});
|
|
19
10
|
|
|
20
11
|
exports.mergeRefs = mergeRefs;
|
package/cjs/constant/element.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const MATERIAL_QUIZ_CONTAINER_ID = 'MATERIAL_QUIZ_CONTAINER_ID';
|
|
4
|
+
const MATERIAL_QUIZ_PASSIVE_ID = 'MATERIAL_QUIZ_PASSIVE_ID';
|
|
5
|
+
const MATERIAL_QUIZ_ANSWER_ID = 'MATERIAL_QUIZ_ANSWER_ID';
|
|
6
6
|
|
|
7
7
|
exports.MATERIAL_QUIZ_ANSWER_ID = MATERIAL_QUIZ_ANSWER_ID;
|
|
8
8
|
exports.MATERIAL_QUIZ_CONTAINER_ID = MATERIAL_QUIZ_CONTAINER_ID;
|
package/cjs/helpers/index.js
CHANGED
|
@@ -22,11 +22,12 @@ function getQuizResultStatus(materialQuizResponse) {
|
|
|
22
22
|
}
|
|
23
23
|
return exports.QuizResultStatus.NotSubmitted;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const getOptionStatus = ({
|
|
26
|
+
isSelected,
|
|
27
|
+
isActive,
|
|
28
|
+
materialQuizResponse
|
|
29
|
+
}) => {
|
|
30
|
+
const status = getQuizResultStatus(materialQuizResponse);
|
|
30
31
|
if (isActive) {
|
|
31
32
|
return;
|
|
32
33
|
}
|
|
@@ -43,8 +44,9 @@ var getOptionStatus = function getOptionStatus(_ref) {
|
|
|
43
44
|
function checkUserLectureTestEnded(lecture) {
|
|
44
45
|
return (lecture === null || lecture === void 0 ? void 0 : lecture.testAdmissionStatus) === types.enums.TestAdmissionStatus.Completed;
|
|
45
46
|
}
|
|
46
|
-
function shouldResetOptions(
|
|
47
|
-
|
|
47
|
+
function shouldResetOptions({
|
|
48
|
+
materialQuizResponse
|
|
49
|
+
}) {
|
|
48
50
|
// when score is given(correct, wrong), reset selected option in order to select options from scratch
|
|
49
51
|
// score condition
|
|
50
52
|
// normal quiz - score is always given(not a null) as long as a user submits the answer
|
|
@@ -52,7 +54,7 @@ function shouldResetOptions(_ref2) {
|
|
|
52
54
|
return [(materialQuizResponse === null || materialQuizResponse === void 0 ? void 0 : materialQuizResponse.score) !== null].every(Boolean);
|
|
53
55
|
}
|
|
54
56
|
function getQuizResult(materialQuizResponse) {
|
|
55
|
-
|
|
57
|
+
const status = getQuizResultStatus(materialQuizResponse);
|
|
56
58
|
switch (status) {
|
|
57
59
|
case exports.QuizResultStatus.Correct:
|
|
58
60
|
return true;
|
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
|
|
4
3
|
var React = require('react');
|
|
5
4
|
var reactUse = require('react-use');
|
|
6
5
|
var MaterialQuizContext = require('../components/material-quiz/context/MaterialQuizContext.js');
|
|
7
6
|
var element = require('../constant/element.js');
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
materialQuiz
|
|
12
|
-
vertical
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
questionDetailHeight
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
React.useEffect(
|
|
8
|
+
const useCaculatePassage = () => {
|
|
9
|
+
const {
|
|
10
|
+
materialQuiz,
|
|
11
|
+
vertical
|
|
12
|
+
} = MaterialQuizContext.useMaterialQuizState();
|
|
13
|
+
const {
|
|
14
|
+
setIsLongPassage,
|
|
15
|
+
setIsInitialLoading
|
|
16
|
+
} = MaterialQuizContext.useMaterialQuizDispatch();
|
|
17
|
+
const [questionRef, {
|
|
18
|
+
height: questionDetailHeight
|
|
19
|
+
}] = reactUse.useMeasure();
|
|
20
|
+
const [containerRef, {
|
|
21
|
+
height: containerHeight
|
|
22
|
+
}] = reactUse.useMeasure();
|
|
23
|
+
React.useEffect(() => {
|
|
25
24
|
var _a, _b;
|
|
26
|
-
|
|
25
|
+
const currentContainerHeight = vertical ? (_b = (_a = document.getElementById(element.MATERIAL_QUIZ_CONTAINER_ID)) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0 : containerHeight;
|
|
27
26
|
if (currentContainerHeight && questionDetailHeight && materialQuiz) {
|
|
28
27
|
setIsLongPassage(questionDetailHeight > currentContainerHeight);
|
|
29
28
|
// add timeout for forcing caculate layout and render in the parent
|
|
30
29
|
// finish before turning off loading
|
|
31
|
-
setTimeout(
|
|
30
|
+
setTimeout(() => {
|
|
32
31
|
setIsInitialLoading(false);
|
|
33
32
|
}, 300);
|
|
34
33
|
} else if (materialQuiz && !materialQuiz.questionDescription) {
|
|
@@ -36,8 +35,8 @@ var useCaculatePassage = function useCaculatePassage() {
|
|
|
36
35
|
}
|
|
37
36
|
}, [containerHeight, questionDetailHeight, materialQuiz, setIsLongPassage, vertical, setIsInitialLoading]);
|
|
38
37
|
return {
|
|
39
|
-
questionRef
|
|
40
|
-
containerRef
|
|
38
|
+
questionRef,
|
|
39
|
+
containerRef
|
|
41
40
|
};
|
|
42
41
|
};
|
|
43
42
|
|
|
@@ -1,106 +1,102 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import $ from 'jquery';
|
|
4
3
|
import 'jquery-ui/ui/widgets/draggable';
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var rootEl = React.useRef(null);
|
|
21
|
-
var onStartCallback = React.useCallback(function (event, ui) {
|
|
5
|
+
const EbDraggable = ({
|
|
6
|
+
children,
|
|
7
|
+
id,
|
|
8
|
+
disabled = false,
|
|
9
|
+
revert = true,
|
|
10
|
+
clone = false,
|
|
11
|
+
className,
|
|
12
|
+
onStart,
|
|
13
|
+
onStop,
|
|
14
|
+
onDrag,
|
|
15
|
+
onCreate
|
|
16
|
+
}) => {
|
|
17
|
+
const rootEl = React.useRef(null);
|
|
18
|
+
const onStartCallback = React.useCallback((event, ui) => {
|
|
22
19
|
if (onStart) {
|
|
23
20
|
return onStart(event, ui);
|
|
24
21
|
} else {
|
|
25
|
-
return
|
|
22
|
+
return () => {
|
|
26
23
|
return;
|
|
27
24
|
};
|
|
28
25
|
}
|
|
29
26
|
}, [onStart]);
|
|
30
|
-
|
|
27
|
+
const onStopCallback = React.useCallback((event, ui) => {
|
|
31
28
|
if (onStop) {
|
|
32
29
|
return onStop(event, ui);
|
|
33
30
|
} else {
|
|
34
|
-
return
|
|
31
|
+
return () => {
|
|
35
32
|
return;
|
|
36
33
|
};
|
|
37
34
|
}
|
|
38
35
|
}, [onStop]);
|
|
39
|
-
|
|
36
|
+
const onDragCallback = React.useCallback((event, ui) => {
|
|
40
37
|
if (onDrag) {
|
|
41
38
|
return onDrag(event, ui);
|
|
42
39
|
} else {
|
|
43
|
-
return
|
|
40
|
+
return () => {
|
|
44
41
|
return;
|
|
45
42
|
};
|
|
46
43
|
}
|
|
47
44
|
}, [onDrag]);
|
|
48
|
-
|
|
45
|
+
const onCreateCallback = React.useCallback((event, ui) => {
|
|
49
46
|
if (onCreate) {
|
|
50
47
|
return onCreate(event, ui);
|
|
51
48
|
} else {
|
|
52
|
-
return
|
|
49
|
+
return () => {
|
|
53
50
|
return;
|
|
54
51
|
};
|
|
55
52
|
}
|
|
56
53
|
}, [onCreate]);
|
|
57
|
-
React.useEffect(
|
|
54
|
+
React.useEffect(() => {
|
|
58
55
|
if (!rootEl.current) {
|
|
59
56
|
return;
|
|
60
57
|
}
|
|
61
|
-
|
|
58
|
+
const draggableEl = $(rootEl.current);
|
|
62
59
|
draggableEl.draggable(Object.assign(Object.assign(Object.assign(Object.assign({}, disabled ? {
|
|
63
|
-
disabled
|
|
60
|
+
disabled
|
|
64
61
|
} : null), revert ? {
|
|
65
|
-
revert
|
|
62
|
+
revert
|
|
66
63
|
} : null), clone ? {
|
|
67
64
|
helper: 'clone'
|
|
68
65
|
} : null), {
|
|
69
66
|
zIndex: 200,
|
|
70
67
|
revertDuration: 0,
|
|
71
|
-
start:
|
|
68
|
+
start: (event, ui) => {
|
|
72
69
|
if (!onStartCallback) {
|
|
73
70
|
return;
|
|
74
71
|
}
|
|
75
72
|
onStartCallback(event, ui);
|
|
76
73
|
},
|
|
77
|
-
stop:
|
|
74
|
+
stop: (event, ui) => {
|
|
78
75
|
if (!onStopCallback) {
|
|
79
76
|
return;
|
|
80
77
|
}
|
|
81
78
|
// draggableEl.draggable('cancel');
|
|
82
79
|
onStopCallback(event, ui);
|
|
83
80
|
},
|
|
84
|
-
drag:
|
|
81
|
+
drag: (event, ui) => {
|
|
85
82
|
onDragCallback(event, ui);
|
|
86
83
|
},
|
|
87
|
-
create:
|
|
84
|
+
create: (event, ui) => {
|
|
88
85
|
onCreateCallback(event, ui);
|
|
89
86
|
}
|
|
90
87
|
}));
|
|
91
|
-
return
|
|
88
|
+
return () => {
|
|
92
89
|
draggableEl.draggable('destroy');
|
|
93
90
|
};
|
|
94
91
|
}, [clone, disabled, onCreateCallback, onDragCallback, onStartCallback, onStopCallback, revert]);
|
|
95
|
-
return
|
|
92
|
+
return React.createElement("div", {
|
|
96
93
|
ref: rootEl,
|
|
97
94
|
id: id,
|
|
98
95
|
className: className,
|
|
99
96
|
style: {
|
|
100
97
|
cursor: disabled ? 'auto' : 'move'
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
});
|
|
98
|
+
}
|
|
99
|
+
}, children);
|
|
104
100
|
};
|
|
105
101
|
|
|
106
102
|
export { EbDraggable as default };
|
|
@@ -1,53 +1,51 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import $ from 'jquery';
|
|
4
3
|
import 'jquery-ui/ui/widgets/droppable';
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
const EbDroppable = ({
|
|
6
|
+
children,
|
|
7
|
+
id,
|
|
8
|
+
disabled = false,
|
|
9
|
+
accept,
|
|
10
|
+
className,
|
|
11
|
+
onDrop
|
|
12
|
+
}) => {
|
|
13
|
+
const rootEl = React.useRef(null);
|
|
14
|
+
const onDropCallback = React.useCallback((event, ui) => {
|
|
16
15
|
if (onDrop) {
|
|
17
16
|
return onDrop(event, ui);
|
|
18
17
|
} else {
|
|
19
|
-
return
|
|
18
|
+
return () => {
|
|
20
19
|
return;
|
|
21
20
|
};
|
|
22
21
|
}
|
|
23
22
|
}, [onDrop]);
|
|
24
|
-
React.useEffect(
|
|
23
|
+
React.useEffect(() => {
|
|
25
24
|
if (!rootEl.current) {
|
|
26
25
|
return;
|
|
27
26
|
}
|
|
28
|
-
|
|
27
|
+
const draggableEl = $(rootEl.current);
|
|
29
28
|
draggableEl.droppable(Object.assign(Object.assign(Object.assign({}, disabled ? {
|
|
30
|
-
disabled
|
|
29
|
+
disabled
|
|
31
30
|
} : null), accept ? {
|
|
32
|
-
accept
|
|
31
|
+
accept
|
|
33
32
|
} : null), {
|
|
34
|
-
drop:
|
|
33
|
+
drop: (event, ui) => {
|
|
35
34
|
if (!onDropCallback) {
|
|
36
35
|
return;
|
|
37
36
|
}
|
|
38
37
|
onDropCallback(event, ui);
|
|
39
38
|
}
|
|
40
39
|
}));
|
|
41
|
-
return
|
|
40
|
+
return () => {
|
|
42
41
|
draggableEl.droppable('destroy');
|
|
43
42
|
};
|
|
44
43
|
}, [accept, disabled, onDropCallback]);
|
|
45
|
-
return
|
|
44
|
+
return React.createElement("div", {
|
|
46
45
|
ref: rootEl,
|
|
47
46
|
id: id,
|
|
48
|
-
className: className
|
|
49
|
-
|
|
50
|
-
});
|
|
47
|
+
className: className
|
|
48
|
+
}, children);
|
|
51
49
|
};
|
|
52
50
|
|
|
53
51
|
export { EbDroppable as default };
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import type { EliceWysiwygEditorProps } from '@elice/wysiwyg';
|
|
2
|
-
export declare const MarkdownEditor: ({ value, onChange, ...props }: EliceWysiwygEditorProps) => JSX.Element;
|
|
3
|
+
export declare const MarkdownEditor: ({ value, onChange, ...props }: EliceWysiwygEditorProps) => React.JSX.Element;
|
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
1
|
import { __rest } from 'tslib';
|
|
3
|
-
import { jsx } from 'react/jsx-runtime';
|
|
4
2
|
import React from 'react';
|
|
5
3
|
import { useDebounce } from 'react-use';
|
|
6
4
|
import { EliceWysiwygEditor } from '@elice/wysiwyg';
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
6
|
+
const STATE_SYNC_DEBOUNCE_TIME = 50;
|
|
7
|
+
const MarkdownEditor = _a => {
|
|
8
|
+
var {
|
|
9
|
+
value,
|
|
10
|
+
onChange
|
|
11
|
+
} = _a,
|
|
12
12
|
props = __rest(_a, ["value", "onChange"]);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
__setValue = _React$useState2[1];
|
|
17
|
-
useDebounce(function () {
|
|
18
|
-
return __setValue(value);
|
|
19
|
-
}, STATE_SYNC_DEBOUNCE_TIME, [value]);
|
|
20
|
-
useDebounce(function () {
|
|
13
|
+
const [__value, __setValue] = React.useState(value);
|
|
14
|
+
useDebounce(() => __setValue(value), STATE_SYNC_DEBOUNCE_TIME, [value]);
|
|
15
|
+
useDebounce(() => {
|
|
21
16
|
if (__value !== value && typeof onChange === 'function') {
|
|
22
17
|
onChange(__value !== null && __value !== void 0 ? __value : '');
|
|
23
18
|
}
|
|
24
19
|
}, STATE_SYNC_DEBOUNCE_TIME, [__value]);
|
|
25
|
-
return
|
|
20
|
+
return React.createElement(EliceWysiwygEditor, Object.assign({
|
|
26
21
|
value: value,
|
|
27
22
|
onChange: __setValue
|
|
28
23
|
}, props));
|