@team-monolith/cds 1.49.2 → 1.49.4
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/LexicalEditor.js +5 -4
- package/dist/patterns/LexicalEditor/nodes/LayoutContainerNode.js +0 -2
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/ProblemSelectNode.d.ts +1 -1
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/ProblemSelectNode.js +3 -3
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectComponent.js +2 -6
- package/dist/patterns/LexicalEditor/plugins/ComponentPickerMenuPlugin/ComponentPickerMenuPlugin.js +6 -5
- package/dist/patterns/LexicalEditor/theme.d.ts +3 -1
- package/dist/patterns/LexicalEditor/theme.js +9 -1
- package/package.json +1 -1
|
@@ -33,14 +33,14 @@ function validateValue(value) {
|
|
|
33
33
|
return true;
|
|
34
34
|
}
|
|
35
35
|
/** undefined value를 제외한 객체 일치 여부를 판단합니다. */
|
|
36
|
-
function
|
|
36
|
+
function isCleanlyEqual(oldObj, newObj) {
|
|
37
37
|
const cleanedOldObj = getCleanObject(oldObj);
|
|
38
38
|
const cleanedNewObj = getCleanObject(newObj);
|
|
39
39
|
return _.isEqual(cleanedOldObj, cleanedNewObj);
|
|
40
40
|
}
|
|
41
41
|
/** 객체 내에 undefined value를 갖는 key를 재귀적으로 모두 제거합니다. */
|
|
42
42
|
function getCleanObject(obj) {
|
|
43
|
-
const newObj =
|
|
43
|
+
const newObj = Object.assign({}, obj);
|
|
44
44
|
for (const key in newObj) {
|
|
45
45
|
if (newObj[key] === undefined) {
|
|
46
46
|
delete newObj[key];
|
|
@@ -83,7 +83,8 @@ export function LexicalEditor(props) {
|
|
|
83
83
|
},
|
|
84
84
|
},
|
|
85
85
|
],
|
|
86
|
-
theme
|
|
86
|
+
// 마운트 된 이후 editable 수정해도 theme에 반영되지 않음 유의
|
|
87
|
+
theme: getTheme(theme, editable),
|
|
87
88
|
editorState: validateValue(value) ? JSON.stringify(value) : undefined,
|
|
88
89
|
editable: editable,
|
|
89
90
|
};
|
|
@@ -94,7 +95,7 @@ export function LexicalEditor(props) {
|
|
|
94
95
|
*/
|
|
95
96
|
const onChangeHandler = onChange
|
|
96
97
|
? (blocks) => {
|
|
97
|
-
if (!
|
|
98
|
+
if (!isCleanlyEqual(value, blocks)) {
|
|
98
99
|
onChange(blocks);
|
|
99
100
|
}
|
|
100
101
|
}
|
|
@@ -29,8 +29,6 @@ export class LayoutContainerNode extends ElementNode {
|
|
|
29
29
|
}
|
|
30
30
|
createDOM(config) {
|
|
31
31
|
const dom = document.createElement("div");
|
|
32
|
-
dom.style.display = "grid";
|
|
33
|
-
dom.style.gap = "24px";
|
|
34
32
|
dom.style.gridTemplateColumns = this.__templateColumns;
|
|
35
33
|
if (typeof config.theme.layoutContainer === "string") {
|
|
36
34
|
addClassNamesToElement(dom, config.theme.layoutContainer);
|
|
@@ -22,7 +22,7 @@ export type ProblemSelectPayload = {
|
|
|
22
22
|
selections: Selection[];
|
|
23
23
|
} | {
|
|
24
24
|
selections: SelectionWithoutSolution[];
|
|
25
|
-
hasMultipleSolutions
|
|
25
|
+
hasMultipleSolutions: boolean;
|
|
26
26
|
});
|
|
27
27
|
export type SerializedProblemSelectNode = Spread<ProblemSelectPayload, SerializedLexicalNode>;
|
|
28
28
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { DecoratorNode, } from "lexical";
|
|
2
|
+
import { $applyNodeReplacement, DecoratorNode, } from "lexical";
|
|
3
3
|
import { addClassNamesToElement } from "@lexical/utils";
|
|
4
4
|
import { SelectComponent } from "./SelectComponent";
|
|
5
5
|
/**
|
|
@@ -77,11 +77,11 @@ export class ProblemSelectNode extends DecoratorNode {
|
|
|
77
77
|
export function $createProblemSelectNode(payload) {
|
|
78
78
|
if ("hasMultipleSolutions" in payload) {
|
|
79
79
|
const { selections, selected, key, hasMultipleSolutions } = payload;
|
|
80
|
-
return new ProblemSelectNode(selections, selected, hasMultipleSolutions, key);
|
|
80
|
+
return $applyNodeReplacement(new ProblemSelectNode(selections, selected, hasMultipleSolutions, key));
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
83
|
const { selections, selected, key } = payload;
|
|
84
|
-
return new ProblemSelectNode(selections, selected, undefined, key);
|
|
84
|
+
return $applyNodeReplacement(new ProblemSelectNode(selections, selected, undefined, key));
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
export function $isProblemSelectNode(node) {
|
|
@@ -19,12 +19,8 @@ export function SelectComponent(props) {
|
|
|
19
19
|
const isEditable = useLexicalEditable();
|
|
20
20
|
const { freezeProblemNode, showQuizSolution } = useContext(LexicalCustomConfigContext);
|
|
21
21
|
const showMultipleSolutions = hasMultipleSolutions ||
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return [s.isAnswer];
|
|
25
|
-
}
|
|
26
|
-
return [];
|
|
27
|
-
}).length > 1;
|
|
22
|
+
(hasMultipleSolutions === undefined &&
|
|
23
|
+
selections.filter((s) => "isAnswer" in s && s.isAnswer).length > 1);
|
|
28
24
|
// view
|
|
29
25
|
if (!isEditable) {
|
|
30
26
|
return (_jsxs(_Fragment, { children: [showMultipleSolutions && (_jsxs(Alert, { children: [_jsx(AlarmWarningFillIcon, { css: css `
|
package/dist/patterns/LexicalEditor/plugins/ComponentPickerMenuPlugin/ComponentPickerMenuPlugin.js
CHANGED
|
@@ -196,8 +196,13 @@ export function getBaseOptions(props) {
|
|
|
196
196
|
onSelect: () => setImageOpen(true),
|
|
197
197
|
}),
|
|
198
198
|
];
|
|
199
|
-
//
|
|
199
|
+
// devMode 여부를 로컬스토리지에서 가져옵니다.
|
|
200
200
|
const isDevMode = localStorage.getItem("devMode") === "true";
|
|
201
|
+
// isQuizEnabled이거나 devMode이면 퀴즈 컨텍스트 메뉴를 꼭대기에 추가합니다.
|
|
202
|
+
if (isQuizEnabled || isDevMode) {
|
|
203
|
+
baseOptions.unshift(...getQuizContextOptions(editor, theme));
|
|
204
|
+
}
|
|
205
|
+
// devMode이면 칼럼 컨텍스트 메뉴를 추가합니다.
|
|
201
206
|
if (isDevMode) {
|
|
202
207
|
baseOptions.push(new ComponentPickerOption("칼럼", {
|
|
203
208
|
icon: _jsx(LayoutColumnLineIcon, {}),
|
|
@@ -205,10 +210,6 @@ export function getBaseOptions(props) {
|
|
|
205
210
|
onSelect: () => editor.dispatchCommand(INSERT_LAYOUT_COMMAND, "1fr 1fr"),
|
|
206
211
|
}));
|
|
207
212
|
}
|
|
208
|
-
// isQuizEnabled이거나 로컬스토리지 devMode가 true이면 퀴즈 컨텍스트 메뉴를 추가합니다.
|
|
209
|
-
if (isQuizEnabled || isDevMode) {
|
|
210
|
-
return [...getQuizContextOptions(editor, theme), ...baseOptions];
|
|
211
|
-
}
|
|
212
213
|
return baseOptions;
|
|
213
214
|
}
|
|
214
215
|
export function ComponentPickerMenuPlugin(props) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Theme } from "@emotion/react";
|
|
2
|
-
export declare function getTheme(theme: Theme): {
|
|
2
|
+
export declare function getTheme(theme: Theme, editable: boolean): {
|
|
3
3
|
paragraph: string;
|
|
4
4
|
quote: string;
|
|
5
5
|
coloredQuote: {
|
|
@@ -30,4 +30,6 @@ export declare function getTheme(theme: Theme): {
|
|
|
30
30
|
};
|
|
31
31
|
problemInput: string;
|
|
32
32
|
problemSelect: string;
|
|
33
|
+
layoutContainer: string;
|
|
34
|
+
layoutItem: string | false;
|
|
33
35
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { css } from "@emotion/css";
|
|
2
|
-
export function getTheme(theme) {
|
|
2
|
+
export function getTheme(theme, editable) {
|
|
3
3
|
return {
|
|
4
4
|
paragraph: css `
|
|
5
5
|
color: ${theme.color.foreground.neutralBase};
|
|
@@ -260,5 +260,13 @@ export function getTheme(theme) {
|
|
|
260
260
|
gap: 4px;
|
|
261
261
|
margin-bottom: 8px;
|
|
262
262
|
`,
|
|
263
|
+
layoutContainer: css `
|
|
264
|
+
display: grid;
|
|
265
|
+
gap: 24px;
|
|
266
|
+
`,
|
|
267
|
+
layoutItem: editable &&
|
|
268
|
+
css `
|
|
269
|
+
border: 1px dashed ${theme.color.background.neutralAltActive};
|
|
270
|
+
`,
|
|
263
271
|
};
|
|
264
272
|
}
|