@team-monolith/cds 1.45.0 → 1.46.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/dist/patterns/LexicalEditor/LexicalEditor.d.ts +2 -0
- package/dist/patterns/LexicalEditor/LexicalEditor.js +2 -2
- package/dist/patterns/LexicalEditor/Plugins.d.ts +1 -0
- package/dist/patterns/LexicalEditor/Plugins.js +2 -2
- package/dist/patterns/LexicalEditor/plugins/ComponentAdderPlugin/ComponentAdderPlugin.d.ts +1 -0
- package/dist/patterns/LexicalEditor/plugins/ComponentAdderPlugin/ComponentAdderPlugin.js +8 -3
- package/dist/patterns/LexicalEditor/plugins/ComponentAdderPlugin/useContextMenuOptions.d.ts +3 -1
- package/dist/patterns/LexicalEditor/plugins/ComponentAdderPlugin/useContextMenuOptions.js +3 -2
- package/dist/patterns/LexicalEditor/plugins/ComponentPickerMenuPlugin/ComponentPickerMenuPlugin.d.ts +9 -2
- package/dist/patterns/LexicalEditor/plugins/ComponentPickerMenuPlugin/ComponentPickerMenuPlugin.js +12 -6
- package/package.json +1 -1
|
@@ -12,6 +12,8 @@ export interface LexicalEditorProps {
|
|
|
12
12
|
/** freeze. 문제 블록을 수정하지 못하도록 함
|
|
13
13
|
*/
|
|
14
14
|
freezeProblemNode?: boolean;
|
|
15
|
+
/** 퀴즈 노드가 허용되는지 여부. false가 디폴트이고, 전달하지 않아도 로컬스토리지 devMode로도 노출시킬 수 있습니다. */
|
|
16
|
+
isQuizEnabled?: boolean;
|
|
15
17
|
/** 외부에서 플러그인을 주입하는 경우 활용함 */
|
|
16
18
|
children?: JSX.Element | string | (JSX.Element | string)[];
|
|
17
19
|
}
|
|
@@ -30,7 +30,7 @@ function validateValue(value) {
|
|
|
30
30
|
return true;
|
|
31
31
|
}
|
|
32
32
|
export function LexicalEditor(props) {
|
|
33
|
-
const { className, contentEditableClassName, value, onChange, editable = true, freezeProblemNode, children, } = props;
|
|
33
|
+
const { className, contentEditableClassName, value, onChange, editable = true, freezeProblemNode, isQuizEnabled = false, children, } = props;
|
|
34
34
|
const theme = useTheme();
|
|
35
35
|
const initialConfig = {
|
|
36
36
|
namespace: "CodleLexicalEditor",
|
|
@@ -63,5 +63,5 @@ export function LexicalEditor(props) {
|
|
|
63
63
|
editorState: validateValue(value) ? JSON.stringify(value) : undefined,
|
|
64
64
|
editable: editable,
|
|
65
65
|
};
|
|
66
|
-
return (_jsx(LexicalCustomConfigContext.Provider, Object.assign({ value: { freezeProblemNode: freezeProblemNode !== null && freezeProblemNode !== void 0 ? freezeProblemNode : false } }, { children: _jsxs(LexicalComposer, Object.assign({ initialConfig: initialConfig }, { children: [_jsx(Plugins, { className: className, contentEditableClassName: contentEditableClassName, onChange: onChange }), _jsx(_Fragment, { children: children })] })) })));
|
|
66
|
+
return (_jsx(LexicalCustomConfigContext.Provider, Object.assign({ value: { freezeProblemNode: freezeProblemNode !== null && freezeProblemNode !== void 0 ? freezeProblemNode : false } }, { children: _jsxs(LexicalComposer, Object.assign({ initialConfig: initialConfig }, { children: [_jsx(Plugins, { className: className, contentEditableClassName: contentEditableClassName, onChange: onChange, isQuizEnabled: isQuizEnabled }), _jsx(_Fragment, { children: children })] })) })));
|
|
67
67
|
}
|
|
@@ -8,5 +8,6 @@ export interface PluginsProps {
|
|
|
8
8
|
className?: string;
|
|
9
9
|
contentEditableClassName?: string;
|
|
10
10
|
onChange?: (blocks: SerializedEditorState<SerializedLexicalNode>) => void;
|
|
11
|
+
isQuizEnabled: boolean;
|
|
11
12
|
}
|
|
12
13
|
export default function Plugins(props: PluginsProps): ReactElement;
|
|
@@ -30,7 +30,7 @@ import styled from "@emotion/styled";
|
|
|
30
30
|
import ProblemInputPlugin from "./plugins/ProblemInputPlugin";
|
|
31
31
|
import ProblemSelectPlugin from "./plugins/ProblemSelectPlugin";
|
|
32
32
|
export default function Plugins(props) {
|
|
33
|
-
const { className, contentEditableClassName, onChange } = props;
|
|
33
|
+
const { className, contentEditableClassName, onChange, isQuizEnabled } = props;
|
|
34
34
|
const isEditable = useLexicalEditable();
|
|
35
35
|
const [floatingAnchorElem, setFloatingAnchorElem] = useState(null);
|
|
36
36
|
const [isLinkEditMode, setIsLinkEditMode] = useState(false);
|
|
@@ -43,7 +43,7 @@ export default function Plugins(props) {
|
|
|
43
43
|
onChange === null || onChange === void 0 ? void 0 : onChange(editorState.toJSON());
|
|
44
44
|
},
|
|
45
45
|
// ignore 하지 않으면 Form에서 수정하지 않았는데 Dirty로 처리됨.
|
|
46
|
-
ignoreSelectionChange: true }), _jsx(AutoFocusPlugin, {}), isEditable && (_jsxs(_Fragment, { children: [_jsx(TabIndentationPlugin, {}), _jsx(ComponentPickerMenuPlugin, {}), _jsx(MarkdownShortcutPlugin, { transformers: CODLE_TRANSFORMERS }), _jsx(HistoryPlugin, {})] })), floatingAnchorElem && isEditable && (_jsxs(_Fragment, { children: [_jsx(ComponentAdderPlugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem, isLinkEditMode: isLinkEditMode, setIsLinkEditMode: setIsLinkEditMode })] })), !isEditable && _jsx(LexicalClickableLinkPlugin, {}), _jsx(ListPlugin, {}), _jsx(HorizontalRulePlugin, {}), _jsx(ImagesPlugin, {}), _jsx(TablePlugin, {}), _jsx(LinkPlugin, {}), _jsx(ListMaxIndentLevelPlugin, { maxDepth: 5 }), _jsx(ProblemInputPlugin, {}), _jsx(ProblemSelectPlugin, {})] }));
|
|
46
|
+
ignoreSelectionChange: true }), _jsx(AutoFocusPlugin, {}), isEditable && (_jsxs(_Fragment, { children: [_jsx(TabIndentationPlugin, {}), _jsx(ComponentPickerMenuPlugin, { isQuizEnabled: isQuizEnabled }), _jsx(MarkdownShortcutPlugin, { transformers: CODLE_TRANSFORMERS }), _jsx(HistoryPlugin, {})] })), floatingAnchorElem && isEditable && (_jsxs(_Fragment, { children: [_jsx(ComponentAdderPlugin, { anchorElem: floatingAnchorElem, isQuizEnabled: isQuizEnabled }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem, isLinkEditMode: isLinkEditMode, setIsLinkEditMode: setIsLinkEditMode })] })), !isEditable && _jsx(LexicalClickableLinkPlugin, {}), _jsx(ListPlugin, {}), _jsx(HorizontalRulePlugin, {}), _jsx(ImagesPlugin, {}), _jsx(TablePlugin, {}), _jsx(LinkPlugin, {}), _jsx(ListMaxIndentLevelPlugin, { maxDepth: 5 }), _jsx(ProblemInputPlugin, {}), _jsx(ProblemSelectPlugin, {})] }));
|
|
47
47
|
}
|
|
48
48
|
const ScrollArea = styled.div `
|
|
49
49
|
min-height: 150px;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
/// <reference types="react" />
|
|
7
7
|
export interface ComponentAdderPluginProps {
|
|
8
8
|
anchorElem: HTMLElement;
|
|
9
|
+
isQuizEnabled: boolean;
|
|
9
10
|
}
|
|
10
11
|
export declare const COMPONENT_ADDER_MENU_CLASSNAME = "component-adder-menu";
|
|
11
12
|
export declare function ComponentAdderPlugin(props: ComponentAdderPluginProps): JSX.Element | null;
|
|
@@ -54,7 +54,7 @@ function getTextUpToAnchor(selection) {
|
|
|
54
54
|
return anchorNode.getTextContent().slice(0, anchorOffset);
|
|
55
55
|
}
|
|
56
56
|
export function ComponentAdderPlugin(props) {
|
|
57
|
-
const { anchorElem } = props;
|
|
57
|
+
const { anchorElem, isQuizEnabled } = props;
|
|
58
58
|
const theme = useTheme();
|
|
59
59
|
const [editor] = useLexicalComposerContext();
|
|
60
60
|
const [nodeKey, setNodeKey] = useState(null);
|
|
@@ -137,7 +137,7 @@ export function ComponentAdderPlugin(props) {
|
|
|
137
137
|
return newResolves.filter((newResolve) => resolves.indexOf(newResolve) === -1);
|
|
138
138
|
});
|
|
139
139
|
});
|
|
140
|
-
const getContextMenuOptions = useContextMenuOptions();
|
|
140
|
+
const getContextMenuOptions = useContextMenuOptions({ isQuizEnabled });
|
|
141
141
|
const filteredOptions = options.filter((option) => {
|
|
142
142
|
if (!query) {
|
|
143
143
|
return true;
|
|
@@ -193,7 +193,12 @@ export function ComponentAdderPlugin(props) {
|
|
|
193
193
|
yield promise;
|
|
194
194
|
setNodeKey(newNodeKey);
|
|
195
195
|
}
|
|
196
|
-
const baseOptions = getBaseOptions(
|
|
196
|
+
const baseOptions = getBaseOptions({
|
|
197
|
+
editor,
|
|
198
|
+
theme,
|
|
199
|
+
setImageOpen,
|
|
200
|
+
isQuizEnabled,
|
|
201
|
+
});
|
|
197
202
|
setOptions(baseOptions);
|
|
198
203
|
setPlusOrMenu("plus");
|
|
199
204
|
}), onMenuClick: () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -3,4 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { LexicalEditor, LexicalNode } from "lexical";
|
|
5
5
|
import { ComponentDrawerOption, ComponentPickerOption } from "../ComponentPickerMenuPlugin";
|
|
6
|
-
export declare function useContextMenuOptions(
|
|
6
|
+
export declare function useContextMenuOptions(props: {
|
|
7
|
+
isQuizEnabled: boolean;
|
|
8
|
+
}): (editor: LexicalEditor, node: LexicalNode, setImageOpen: (open: boolean) => void) => (ComponentPickerOption | ComponentDrawerOption)[];
|
|
@@ -270,7 +270,8 @@ function getColoredQuoteContextMenuOptions(editor, theme, node) {
|
|
|
270
270
|
}),
|
|
271
271
|
];
|
|
272
272
|
}
|
|
273
|
-
export function useContextMenuOptions() {
|
|
273
|
+
export function useContextMenuOptions(props) {
|
|
274
|
+
const { isQuizEnabled } = props;
|
|
274
275
|
const theme = useTheme();
|
|
275
276
|
return (editor, node, setImageOpen) => {
|
|
276
277
|
if ($isProblemInputNode(node)) {
|
|
@@ -293,7 +294,7 @@ export function useContextMenuOptions() {
|
|
|
293
294
|
}
|
|
294
295
|
else {
|
|
295
296
|
return [
|
|
296
|
-
...getBaseOptions(editor, theme, setImageOpen),
|
|
297
|
+
...getBaseOptions({ editor, theme, setImageOpen, isQuizEnabled }),
|
|
297
298
|
new ComponentPickerOption("블록 삭제", {
|
|
298
299
|
icon: _jsx(CloseFillIcon, {}),
|
|
299
300
|
keywords: [],
|
package/dist/patterns/LexicalEditor/plugins/ComponentPickerMenuPlugin/ComponentPickerMenuPlugin.d.ts
CHANGED
|
@@ -30,5 +30,12 @@ export declare class ComponentPickerOption extends MenuOption {
|
|
|
30
30
|
onSelect: (queryString: string) => void;
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
export declare function getBaseOptions(
|
|
34
|
-
|
|
33
|
+
export declare function getBaseOptions(props: {
|
|
34
|
+
editor: LexicalEditor;
|
|
35
|
+
theme: Theme;
|
|
36
|
+
setImageOpen: (open: boolean) => void;
|
|
37
|
+
isQuizEnabled: boolean;
|
|
38
|
+
}): (ComponentPickerOption | ComponentDrawerOption)[];
|
|
39
|
+
export declare function ComponentPickerMenuPlugin(props: {
|
|
40
|
+
isQuizEnabled: boolean;
|
|
41
|
+
}): JSX.Element;
|
package/dist/patterns/LexicalEditor/plugins/ComponentPickerMenuPlugin/ComponentPickerMenuPlugin.js
CHANGED
|
@@ -111,7 +111,8 @@ function getQuizContextOptions(editor, theme) {
|
|
|
111
111
|
` }))),
|
|
112
112
|
];
|
|
113
113
|
}
|
|
114
|
-
export function getBaseOptions(
|
|
114
|
+
export function getBaseOptions(props) {
|
|
115
|
+
const { editor, theme, setImageOpen, isQuizEnabled } = props;
|
|
115
116
|
const baseOptions = [
|
|
116
117
|
new ComponentPickerOption("본문", {
|
|
117
118
|
icon: _jsx(TextIcon, {}),
|
|
@@ -195,14 +196,14 @@ export function getBaseOptions(editor, theme, setImageOpen) {
|
|
|
195
196
|
onSelect: () => setImageOpen(true),
|
|
196
197
|
}),
|
|
197
198
|
];
|
|
198
|
-
//
|
|
199
|
-
|
|
200
|
-
if (localStorage.getItem("devMode") === "true") {
|
|
199
|
+
// isQuizEnabled이거나 로컬스토리지 devMode가 true이면 퀴즈 컨텍스트 메뉴를 추가합니다.
|
|
200
|
+
if (isQuizEnabled || localStorage.getItem("devMode") === "true") {
|
|
201
201
|
return [...getQuizContextOptions(editor, theme), ...baseOptions];
|
|
202
202
|
}
|
|
203
203
|
return baseOptions;
|
|
204
204
|
}
|
|
205
|
-
export function ComponentPickerMenuPlugin() {
|
|
205
|
+
export function ComponentPickerMenuPlugin(props) {
|
|
206
|
+
const { isQuizEnabled } = props;
|
|
206
207
|
const [editor] = useLexicalComposerContext();
|
|
207
208
|
const theme = useTheme();
|
|
208
209
|
const [queryString, setQueryString] = useState(null);
|
|
@@ -211,7 +212,12 @@ export function ComponentPickerMenuPlugin() {
|
|
|
211
212
|
minLength: 0,
|
|
212
213
|
});
|
|
213
214
|
const options = useMemo(() => {
|
|
214
|
-
const baseOptions = getBaseOptions(
|
|
215
|
+
const baseOptions = getBaseOptions({
|
|
216
|
+
editor,
|
|
217
|
+
theme,
|
|
218
|
+
setImageOpen: setOpen,
|
|
219
|
+
isQuizEnabled,
|
|
220
|
+
});
|
|
215
221
|
if (!queryString) {
|
|
216
222
|
return baseOptions;
|
|
217
223
|
}
|