@team-monolith/cds 1.51.2 → 1.52.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 +6 -2
- package/dist/patterns/LexicalEditor/Plugins.d.ts +1 -0
- package/dist/patterns/LexicalEditor/Plugins.js +4 -2
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/ProblemSelectNode.d.ts +1 -4
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectBox/SelectBoxComponent.d.ts +1 -1
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectBox/SelectBoxEdit.d.ts +3 -2
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectBox/SelectBoxView.d.ts +1 -1
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectComponent.js +2 -1
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SettingForm/FormSelection.js +16 -16
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SettingForm/SettingForm.js +25 -3
- package/dist/patterns/LexicalEditor/nodes/SheetInputNode/InputComponent.d.ts +7 -0
- package/dist/patterns/LexicalEditor/nodes/SheetInputNode/InputComponent.js +84 -0
- package/dist/patterns/LexicalEditor/nodes/SheetInputNode/SettingForm.d.ts +11 -0
- package/dist/patterns/LexicalEditor/nodes/SheetInputNode/SettingForm.js +93 -0
- package/dist/patterns/LexicalEditor/nodes/SheetInputNode/SheetInputNode.d.ts +33 -0
- package/dist/patterns/LexicalEditor/nodes/SheetInputNode/SheetInputNode.js +77 -0
- package/dist/patterns/LexicalEditor/nodes/SheetInputNode/index.d.ts +1 -0
- package/dist/patterns/LexicalEditor/nodes/SheetInputNode/index.js +1 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SelectBox/SelectBoxComponent.d.ts +18 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SelectBox/SelectBoxComponent.js +80 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SelectBox/SelectBoxEdit.d.ts +9 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SelectBox/SelectBoxEdit.js +7 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SelectBox/SelectBoxView.d.ts +9 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SelectBox/SelectBoxView.js +22 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SelectBox/index.d.ts +2 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SelectBox/index.js +2 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SelectComponent.d.ts +9 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SelectComponent.js +82 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SettingForm/FormAllowMultipleAnswers.d.ts +6 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SettingForm/FormAllowMultipleAnswers.js +10 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SettingForm/FormSelection.d.ts +11 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SettingForm/FormSelection.js +86 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SettingForm/SettingForm.d.ts +13 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SettingForm/SettingForm.js +170 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SettingForm/index.d.ts +1 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/SettingForm/index.js +1 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/index.d.ts +1 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SelectComponent/index.js +1 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SheetSelectNode.d.ts +43 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/SheetSelectNode.js +82 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/index.d.ts +1 -0
- package/dist/patterns/LexicalEditor/nodes/SheetSelectNode/index.js +1 -0
- package/dist/patterns/LexicalEditor/nodes/{ProblemSelectNode/SettingForm → insertImageDialog}/InsertImageDialog.d.ts +4 -1
- package/dist/patterns/LexicalEditor/nodes/{ProblemSelectNode/SettingForm → insertImageDialog}/InsertImageDialog.js +4 -4
- package/dist/patterns/LexicalEditor/nodes/{ProblemSelectNode/SettingForm → insertImageDialog}/InsertImageUploadedDialogBody.d.ts +1 -1
- package/dist/patterns/LexicalEditor/nodes/{ProblemSelectNode/SettingForm → insertImageDialog}/InsertImageUploadedDialogBody.js +5 -5
- package/dist/patterns/LexicalEditor/nodes/{ProblemSelectNode/SettingForm → insertImageDialog}/InsertImageUriDialogBody.d.ts +1 -1
- package/dist/patterns/LexicalEditor/nodes/{ProblemSelectNode/SettingForm → insertImageDialog}/InsertImageUriDialogBody.js +4 -4
- package/dist/patterns/LexicalEditor/nodes/insertImageDialog/index.d.ts +1 -0
- package/dist/patterns/LexicalEditor/nodes/insertImageDialog/index.js +1 -0
- package/dist/patterns/LexicalEditor/plugins/ComponentAdderPlugin/ComponentAdderPlugin.d.ts +1 -0
- package/dist/patterns/LexicalEditor/plugins/ComponentAdderPlugin/ComponentAdderPlugin.js +6 -2
- package/dist/patterns/LexicalEditor/plugins/ComponentAdderPlugin/useContextMenuOptions.d.ts +1 -0
- package/dist/patterns/LexicalEditor/plugins/ComponentAdderPlugin/useContextMenuOptions.js +38 -2
- package/dist/patterns/LexicalEditor/plugins/ComponentPickerMenuPlugin/ComponentPickerMenuPlugin.d.ts +2 -0
- package/dist/patterns/LexicalEditor/plugins/ComponentPickerMenuPlugin/ComponentPickerMenuPlugin.js +56 -4
- package/dist/patterns/LexicalEditor/plugins/SheetInputPlugin/index.d.ts +5 -0
- package/dist/patterns/LexicalEditor/plugins/SheetInputPlugin/index.js +20 -0
- package/dist/patterns/LexicalEditor/plugins/SheetSelectPlugin/index.d.ts +5 -0
- package/dist/patterns/LexicalEditor/plugins/SheetSelectPlugin/index.js +20 -0
- package/dist/patterns/LexicalEditor/theme.d.ts +2 -0
- package/dist/patterns/LexicalEditor/theme.js +14 -0
- package/package.json +1 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { $applyNodeReplacement, DecoratorNode, } from "lexical";
|
|
3
|
+
import { addClassNamesToElement } from "@lexical/utils";
|
|
4
|
+
import { SelectComponent } from "./SelectComponent";
|
|
5
|
+
/**
|
|
6
|
+
* selections는 Selection타입의 배열로서 객관식 정보를 담고 있습니다.
|
|
7
|
+
* selected는 선택한 답의 value를 담고 있습니다.(view mode에서만 노출)
|
|
8
|
+
*/
|
|
9
|
+
export class SheetSelectNode extends DecoratorNode {
|
|
10
|
+
isInline() {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
static getType() {
|
|
14
|
+
return "sheet-select";
|
|
15
|
+
}
|
|
16
|
+
getSelections() {
|
|
17
|
+
return this.__selections;
|
|
18
|
+
}
|
|
19
|
+
getSelected() {
|
|
20
|
+
return this.__selected;
|
|
21
|
+
}
|
|
22
|
+
getAllowMultipleAnswers() {
|
|
23
|
+
return this.__allowMultipleAnswers;
|
|
24
|
+
}
|
|
25
|
+
setSelections(selections) {
|
|
26
|
+
const self = this.getWritable();
|
|
27
|
+
self.__selections = selections;
|
|
28
|
+
}
|
|
29
|
+
setSelected(selected) {
|
|
30
|
+
const self = this.getWritable();
|
|
31
|
+
self.__selected = selected;
|
|
32
|
+
}
|
|
33
|
+
setAllowMultipleAnswers(allowMultipleAnswers) {
|
|
34
|
+
const self = this.getWritable();
|
|
35
|
+
self.__allowMultipleAnswers = allowMultipleAnswers;
|
|
36
|
+
}
|
|
37
|
+
static clone(node) {
|
|
38
|
+
return new SheetSelectNode(node.__selections, node.__selected, node.__allowMultipleAnswers, node.__key);
|
|
39
|
+
}
|
|
40
|
+
constructor(selections, selected, allowMultipleAnswers, key) {
|
|
41
|
+
super(key);
|
|
42
|
+
this.__selections = selections;
|
|
43
|
+
this.__selected = selected;
|
|
44
|
+
this.__allowMultipleAnswers = allowMultipleAnswers;
|
|
45
|
+
}
|
|
46
|
+
createDOM(config) {
|
|
47
|
+
// Define the DOM element here
|
|
48
|
+
const root = document.createElement("div");
|
|
49
|
+
addClassNamesToElement(root, config.theme.sheetSelect);
|
|
50
|
+
return root;
|
|
51
|
+
}
|
|
52
|
+
updateDOM() {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
static importJSON(serializedNode) {
|
|
56
|
+
return $createSheetSelectNode({
|
|
57
|
+
key: serializedNode.key,
|
|
58
|
+
selections: serializedNode.selections,
|
|
59
|
+
selected: serializedNode.selected,
|
|
60
|
+
allowMultipleAnswers: serializedNode.allowMultipleAnswers,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
exportJSON() {
|
|
64
|
+
return {
|
|
65
|
+
type: "sheet-select",
|
|
66
|
+
version: 1,
|
|
67
|
+
selections: this.__selections,
|
|
68
|
+
selected: this.__selected,
|
|
69
|
+
allowMultipleAnswers: this.__allowMultipleAnswers,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
decorate() {
|
|
73
|
+
return (_jsx(SelectComponent, { selections: this.__selections, selected: this.__selected, allowMultipleAnswers: this.__allowMultipleAnswers, nodeKey: this.__key }));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export function $createSheetSelectNode(payload) {
|
|
77
|
+
const { selections, selected, key, allowMultipleAnswers } = payload;
|
|
78
|
+
return $applyNodeReplacement(new SheetSelectNode(selections, selected, allowMultipleAnswers, key));
|
|
79
|
+
}
|
|
80
|
+
export function $isSheetSelectNode(node) {
|
|
81
|
+
return node instanceof SheetSelectNode;
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SheetSelectNode";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SheetSelectNode";
|
|
@@ -12,10 +12,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/reac
|
|
|
12
12
|
import { useContext, useRef, useState } from "react";
|
|
13
13
|
import styled from "@emotion/styled";
|
|
14
14
|
import { css, useTheme } from "@emotion/react";
|
|
15
|
-
import { ImageFillIcon, LinkIcon, UploadLineIcon } from "
|
|
16
|
-
import { AlertDialog, AlertDialogContent, AlertDialogTitle, } from "
|
|
17
|
-
import Button from "
|
|
18
|
-
import { CodleDesignSystemContext } from "
|
|
15
|
+
import { ImageFillIcon, LinkIcon, UploadLineIcon } from "../../../../icons";
|
|
16
|
+
import { AlertDialog, AlertDialogContent, AlertDialogTitle, } from "../../../../components/AlertDialog";
|
|
17
|
+
import Button from "../../../../components/Button";
|
|
18
|
+
import { CodleDesignSystemContext } from "../../../../CodleDesignSystemProvider";
|
|
19
19
|
import { InsertImageUriDialogBody } from "./InsertImageUriDialogBody";
|
|
20
20
|
import { InsertImageUploadedDialogBody } from "./InsertImageUploadedDialogBody";
|
|
21
21
|
import { useForm } from "react-hook-form";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ImageProps } from "../ProblemSelectNode";
|
|
2
1
|
import { Control, UseFormSetValue, UseFormWatch } from "react-hook-form";
|
|
2
|
+
import { ImageProps } from "./InsertImageDialog";
|
|
3
3
|
export interface InsertImageUploadedDialogBodyProps {
|
|
4
4
|
control: Control<ImageProps, any>;
|
|
5
5
|
watch: UseFormWatch<ImageProps>;
|
|
@@ -10,11 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
11
|
import { useContext, useRef } from "react";
|
|
12
12
|
import styled from "@emotion/styled";
|
|
13
|
-
import { CodleDesignSystemContext } from "
|
|
14
|
-
import { AlertDialogActions, AlertDialogContent, } from "
|
|
15
|
-
import Button from "
|
|
16
|
-
import { RefreshLineIcon } from "
|
|
17
|
-
import Input from "
|
|
13
|
+
import { CodleDesignSystemContext } from "../../../../CodleDesignSystemProvider";
|
|
14
|
+
import { AlertDialogActions, AlertDialogContent, } from "../../../../components/AlertDialog";
|
|
15
|
+
import Button from "../../../../components/Button";
|
|
16
|
+
import { RefreshLineIcon } from "../../../../icons";
|
|
17
|
+
import Input from "../../../../components/Input";
|
|
18
18
|
import { Controller, } from "react-hook-form";
|
|
19
19
|
export function InsertImageUploadedDialogBody(props) {
|
|
20
20
|
const { control, watch, setValue } = props;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ImageProps } from "../ProblemSelectNode";
|
|
2
1
|
import { Control, UseFormWatch } from "react-hook-form";
|
|
2
|
+
import { ImageProps } from "./InsertImageDialog";
|
|
3
3
|
export interface InsertImageUriDialogBodyProps {
|
|
4
4
|
control: Control<ImageProps, any>;
|
|
5
5
|
watch: UseFormWatch<ImageProps>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import styled from "@emotion/styled";
|
|
3
|
-
import { AlertDialogActions, AlertDialogContent, } from "
|
|
4
|
-
import Input from "
|
|
5
|
-
import { LinkIcon } from "
|
|
6
|
-
import Button from "
|
|
3
|
+
import { AlertDialogActions, AlertDialogContent, } from "../../../../components/AlertDialog";
|
|
4
|
+
import Input from "../../../../components/Input";
|
|
5
|
+
import { LinkIcon } from "../../../../icons";
|
|
6
|
+
import Button from "../../../../components/Button";
|
|
7
7
|
import { Controller } from "react-hook-form";
|
|
8
8
|
export function InsertImageUriDialogBody(props) {
|
|
9
9
|
const { control, watch } = props;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./InsertImageDialog";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./InsertImageDialog";
|
|
@@ -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, isQuizEnabled } = props;
|
|
57
|
+
const { anchorElem, isSheetEnabled, isQuizEnabled } = props;
|
|
58
58
|
const theme = useTheme();
|
|
59
59
|
const [editor] = useLexicalComposerContext();
|
|
60
60
|
const [nodeKey, setNodeKey] = useState(null);
|
|
@@ -137,7 +137,10 @@ 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({
|
|
141
|
+
isSheetEnabled,
|
|
142
|
+
isQuizEnabled,
|
|
143
|
+
});
|
|
141
144
|
const filteredOptions = options.filter((option) => {
|
|
142
145
|
if (!query) {
|
|
143
146
|
return true;
|
|
@@ -197,6 +200,7 @@ export function ComponentAdderPlugin(props) {
|
|
|
197
200
|
editor,
|
|
198
201
|
theme,
|
|
199
202
|
setImageOpen,
|
|
203
|
+
isSheetEnabled,
|
|
200
204
|
isQuizEnabled,
|
|
201
205
|
});
|
|
202
206
|
setOptions(baseOptions);
|
|
@@ -4,5 +4,6 @@
|
|
|
4
4
|
import { LexicalEditor, LexicalNode } from "lexical";
|
|
5
5
|
import { ComponentDrawerOption, ComponentPickerOption } from "../ComponentPickerMenuPlugin";
|
|
6
6
|
export declare function useContextMenuOptions(props: {
|
|
7
|
+
isSheetEnabled: boolean;
|
|
7
8
|
isQuizEnabled: boolean;
|
|
8
9
|
}): (editor: LexicalEditor, node: LexicalNode, setImageOpen: (open: boolean) => void) => (ComponentPickerOption | ComponentDrawerOption)[];
|
|
@@ -15,6 +15,8 @@ import { useTheme } from "@emotion/react";
|
|
|
15
15
|
import { css } from "@emotion/css";
|
|
16
16
|
import { $isProblemInputNode } from "../../nodes";
|
|
17
17
|
import { $isProblemSelectNode, } from "../../nodes/ProblemSelectNode";
|
|
18
|
+
import { $isSheetInputNode } from "../../nodes/SheetInputNode";
|
|
19
|
+
import { $isSheetSelectNode, } from "../../nodes/SheetSelectNode";
|
|
18
20
|
function getParagraphContextMenuOptions(editor, node, setOpen) {
|
|
19
21
|
return [
|
|
20
22
|
new ComponentPickerOption("본문", {
|
|
@@ -197,6 +199,28 @@ function getProblemSelectContextMenuOptions(node) {
|
|
|
197
199
|
}),
|
|
198
200
|
];
|
|
199
201
|
}
|
|
202
|
+
function getSheetInputContextMenuOptions(node) {
|
|
203
|
+
return [
|
|
204
|
+
new ComponentPickerOption("블록 삭제", {
|
|
205
|
+
icon: _jsx(CloseFillIcon, {}),
|
|
206
|
+
keywords: [],
|
|
207
|
+
onSelect: () => {
|
|
208
|
+
node.remove();
|
|
209
|
+
},
|
|
210
|
+
}),
|
|
211
|
+
];
|
|
212
|
+
}
|
|
213
|
+
function getSheetSelectContextMenuOptions(node) {
|
|
214
|
+
return [
|
|
215
|
+
new ComponentPickerOption("블록 삭제", {
|
|
216
|
+
icon: _jsx(CloseFillIcon, {}),
|
|
217
|
+
keywords: [],
|
|
218
|
+
onSelect: () => {
|
|
219
|
+
node.remove();
|
|
220
|
+
},
|
|
221
|
+
}),
|
|
222
|
+
];
|
|
223
|
+
}
|
|
200
224
|
function getColoredQuoteContextMenuOptions(editor, theme, node) {
|
|
201
225
|
return [
|
|
202
226
|
new ComponentPickerOption("회색", {
|
|
@@ -271,7 +295,7 @@ function getColoredQuoteContextMenuOptions(editor, theme, node) {
|
|
|
271
295
|
];
|
|
272
296
|
}
|
|
273
297
|
export function useContextMenuOptions(props) {
|
|
274
|
-
const { isQuizEnabled } = props;
|
|
298
|
+
const { isSheetEnabled, isQuizEnabled } = props;
|
|
275
299
|
const theme = useTheme();
|
|
276
300
|
return (editor, node, setImageOpen) => {
|
|
277
301
|
if ($isProblemInputNode(node)) {
|
|
@@ -280,6 +304,12 @@ export function useContextMenuOptions(props) {
|
|
|
280
304
|
else if ($isProblemSelectNode(node)) {
|
|
281
305
|
return getProblemSelectContextMenuOptions(node);
|
|
282
306
|
}
|
|
307
|
+
else if ($isSheetInputNode(node)) {
|
|
308
|
+
return getSheetInputContextMenuOptions(node);
|
|
309
|
+
}
|
|
310
|
+
else if ($isSheetSelectNode(node)) {
|
|
311
|
+
return getSheetSelectContextMenuOptions(node);
|
|
312
|
+
}
|
|
283
313
|
else if (node instanceof ParagraphNode) {
|
|
284
314
|
return getParagraphContextMenuOptions(editor, node, setImageOpen);
|
|
285
315
|
}
|
|
@@ -294,7 +324,13 @@ export function useContextMenuOptions(props) {
|
|
|
294
324
|
}
|
|
295
325
|
else {
|
|
296
326
|
return [
|
|
297
|
-
...getBaseOptions({
|
|
327
|
+
...getBaseOptions({
|
|
328
|
+
editor,
|
|
329
|
+
theme,
|
|
330
|
+
setImageOpen,
|
|
331
|
+
isSheetEnabled,
|
|
332
|
+
isQuizEnabled,
|
|
333
|
+
}),
|
|
298
334
|
new ComponentPickerOption("블록 삭제", {
|
|
299
335
|
icon: _jsx(CloseFillIcon, {}),
|
|
300
336
|
keywords: [],
|
package/dist/patterns/LexicalEditor/plugins/ComponentPickerMenuPlugin/ComponentPickerMenuPlugin.d.ts
CHANGED
|
@@ -34,8 +34,10 @@ export declare function getBaseOptions(props: {
|
|
|
34
34
|
editor: LexicalEditor;
|
|
35
35
|
theme: Theme;
|
|
36
36
|
setImageOpen: (open: boolean) => void;
|
|
37
|
+
isSheetEnabled: boolean;
|
|
37
38
|
isQuizEnabled: boolean;
|
|
38
39
|
}): (ComponentPickerOption | ComponentDrawerOption)[];
|
|
39
40
|
export declare function ComponentPickerMenuPlugin(props: {
|
|
41
|
+
isSheetEnabled: boolean;
|
|
40
42
|
isQuizEnabled: boolean;
|
|
41
43
|
}): JSX.Element;
|
package/dist/patterns/LexicalEditor/plugins/ComponentPickerMenuPlugin/ComponentPickerMenuPlugin.js
CHANGED
|
@@ -21,12 +21,14 @@ import * as ReactDOM from "react-dom";
|
|
|
21
21
|
import { css as cssToClassName } from "@emotion/css";
|
|
22
22
|
import { ComponentPickerMenuList } from "./ComponentPickerMenuList";
|
|
23
23
|
import { InsertImageDialog } from "../ImagesPlugin/InsertImageDialog";
|
|
24
|
-
import { TextIcon, H1Icon, H2Icon, H3Icon, ListUnorderedIcon, ListOrderedIcon, DoubleQuotesLIcon, CodeViewIcon, SeparatorIcon, ImageLineIcon, InputMethodLineIcon, ListRadioIcon, LayoutColumnLineIcon, } from "../../../../icons";
|
|
24
|
+
import { TextIcon, H1Icon, H2Icon, H3Icon, ListUnorderedIcon, ListOrderedIcon, DoubleQuotesLIcon, CodeViewIcon, SeparatorIcon, ImageLineIcon, InputMethodLineIcon, ListRadioIcon, LayoutColumnLineIcon, FileList2LineIcon, } from "../../../../icons";
|
|
25
25
|
import { ZINDEX } from "../../../../utils/zIndex";
|
|
26
26
|
import { css, useTheme } from "@emotion/react";
|
|
27
27
|
import { INSERT_PROBLEM_INPUT_COMMAND } from "../ProblemInputPlugin";
|
|
28
28
|
import { INSERT_PROBLEM_SELECT_COMMAND } from "../ProblemSelectPlugin";
|
|
29
29
|
import { INSERT_LAYOUT_COMMAND } from "../LayoutPlugin";
|
|
30
|
+
import { INSERT_SHEET_SELECT_COMMAND } from "../SheetSelectPlugin";
|
|
31
|
+
import { INSERT_SHEET_INPUT_COMMAND } from "../SheetInputPlugin";
|
|
30
32
|
// import useModal from "../../hooks/useModal";
|
|
31
33
|
// import catTypingGif from "../../images/cat-typing.gif";
|
|
32
34
|
// import { INSERT_IMAGE_COMMAND, InsertImageDialog } from "../ImagesPlugin";
|
|
@@ -67,6 +69,51 @@ function getDynamicOptions(editor, queryString) {
|
|
|
67
69
|
}
|
|
68
70
|
return options;
|
|
69
71
|
}
|
|
72
|
+
function getSheetContextOptions(editor, theme) {
|
|
73
|
+
return [
|
|
74
|
+
new ComponentPickerOption("선택형 입력 칸", {
|
|
75
|
+
icon: _jsx(ListRadioIcon, { color: theme.color.foreground.primary }),
|
|
76
|
+
keywords: ["sheet select", "선택형 입력"],
|
|
77
|
+
onSelect: () => editor.dispatchCommand(INSERT_SHEET_SELECT_COMMAND, {
|
|
78
|
+
selections: [
|
|
79
|
+
{
|
|
80
|
+
show: {
|
|
81
|
+
image: null,
|
|
82
|
+
text: "",
|
|
83
|
+
},
|
|
84
|
+
value: "1",
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
selected: [],
|
|
88
|
+
allowMultipleAnswers: false,
|
|
89
|
+
}),
|
|
90
|
+
}),
|
|
91
|
+
new ComponentPickerOption("단답형 입력 칸", {
|
|
92
|
+
icon: _jsx(InputMethodLineIcon, { color: theme.color.foreground.primary }),
|
|
93
|
+
keywords: ["sheet short input", "단답형 입력"],
|
|
94
|
+
onSelect: () => editor.dispatchCommand(INSERT_SHEET_INPUT_COMMAND, {
|
|
95
|
+
multiline: false,
|
|
96
|
+
value: "",
|
|
97
|
+
placeholder: "",
|
|
98
|
+
}),
|
|
99
|
+
}),
|
|
100
|
+
new ComponentPickerOption("서술형 입력 칸", {
|
|
101
|
+
icon: _jsx(FileList2LineIcon, { color: theme.color.foreground.primary }),
|
|
102
|
+
keywords: ["sheet long input", "서술형 입력"],
|
|
103
|
+
onSelect: () => editor.dispatchCommand(INSERT_SHEET_INPUT_COMMAND, {
|
|
104
|
+
multiline: true,
|
|
105
|
+
value: "",
|
|
106
|
+
placeholder: "",
|
|
107
|
+
}),
|
|
108
|
+
}),
|
|
109
|
+
new ComponentDrawerOption("활동지 메뉴구분선", (_jsx("div", { css: css `
|
|
110
|
+
width: 100%;
|
|
111
|
+
height: 1px;
|
|
112
|
+
background: ${theme.color.background.neutralAltActive};
|
|
113
|
+
margin: 4px 0;
|
|
114
|
+
` }))),
|
|
115
|
+
];
|
|
116
|
+
}
|
|
70
117
|
function getQuizContextOptions(editor, theme) {
|
|
71
118
|
return [
|
|
72
119
|
new ComponentPickerOption("주관식 입력 칸", {
|
|
@@ -103,7 +150,7 @@ function getQuizContextOptions(editor, theme) {
|
|
|
103
150
|
});
|
|
104
151
|
},
|
|
105
152
|
}),
|
|
106
|
-
new ComponentDrawerOption("메뉴구분선", (_jsx("div", { css: css `
|
|
153
|
+
new ComponentDrawerOption("퀴즈 메뉴구분선", (_jsx("div", { css: css `
|
|
107
154
|
width: 100%;
|
|
108
155
|
height: 1px;
|
|
109
156
|
background: ${theme.color.background.neutralAltActive};
|
|
@@ -112,7 +159,7 @@ function getQuizContextOptions(editor, theme) {
|
|
|
112
159
|
];
|
|
113
160
|
}
|
|
114
161
|
export function getBaseOptions(props) {
|
|
115
|
-
const { editor, theme, setImageOpen, isQuizEnabled } = props;
|
|
162
|
+
const { editor, theme, setImageOpen, isSheetEnabled, isQuizEnabled } = props;
|
|
116
163
|
const baseOptions = [
|
|
117
164
|
new ComponentPickerOption("본문", {
|
|
118
165
|
icon: _jsx(TextIcon, {}),
|
|
@@ -202,6 +249,10 @@ export function getBaseOptions(props) {
|
|
|
202
249
|
if (isQuizEnabled || isDevMode) {
|
|
203
250
|
baseOptions.unshift(...getQuizContextOptions(editor, theme));
|
|
204
251
|
}
|
|
252
|
+
// isSheetEnabled이거나 devMode이면 활동지 컨텍스트 메뉴를 꼭대기에 추가합니다.
|
|
253
|
+
if (isSheetEnabled || isDevMode) {
|
|
254
|
+
baseOptions.unshift(...getSheetContextOptions(editor, theme));
|
|
255
|
+
}
|
|
205
256
|
// devMode이면 칼럼 컨텍스트 메뉴를 추가합니다.
|
|
206
257
|
if (isDevMode) {
|
|
207
258
|
baseOptions.push(new ComponentPickerOption("칼럼", {
|
|
@@ -213,7 +264,7 @@ export function getBaseOptions(props) {
|
|
|
213
264
|
return baseOptions;
|
|
214
265
|
}
|
|
215
266
|
export function ComponentPickerMenuPlugin(props) {
|
|
216
|
-
const { isQuizEnabled } = props;
|
|
267
|
+
const { isSheetEnabled, isQuizEnabled } = props;
|
|
217
268
|
const [editor] = useLexicalComposerContext();
|
|
218
269
|
const theme = useTheme();
|
|
219
270
|
const [queryString, setQueryString] = useState(null);
|
|
@@ -226,6 +277,7 @@ export function ComponentPickerMenuPlugin(props) {
|
|
|
226
277
|
editor,
|
|
227
278
|
theme,
|
|
228
279
|
setImageOpen: setOpen,
|
|
280
|
+
isSheetEnabled,
|
|
229
281
|
isQuizEnabled,
|
|
230
282
|
});
|
|
231
283
|
if (!queryString) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { LexicalCommand } from "lexical";
|
|
3
|
+
import { SheetInputPayload } from "../../nodes/SheetInputNode";
|
|
4
|
+
export declare const INSERT_SHEET_INPUT_COMMAND: LexicalCommand<SheetInputPayload>;
|
|
5
|
+
export default function SheetInputPlugin(): JSX.Element | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
2
|
+
import { $insertNodeToNearestRoot } from "@lexical/utils";
|
|
3
|
+
import { COMMAND_PRIORITY_EDITOR, createCommand, } from "lexical";
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
import { $createSheetInputNode, SheetInputNode, } from "../../nodes/SheetInputNode";
|
|
6
|
+
export const INSERT_SHEET_INPUT_COMMAND = createCommand("INSERT_SHEET_INPUT_COMMAND");
|
|
7
|
+
export default function SheetInputPlugin() {
|
|
8
|
+
const [editor] = useLexicalComposerContext();
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (!editor.hasNodes([SheetInputNode])) {
|
|
11
|
+
throw new Error("SheetInputNode: SheetInputNode not registered on editor");
|
|
12
|
+
}
|
|
13
|
+
editor.registerCommand(INSERT_SHEET_INPUT_COMMAND, (payload) => {
|
|
14
|
+
const sheetInputNode = $createSheetInputNode(payload);
|
|
15
|
+
$insertNodeToNearestRoot(sheetInputNode);
|
|
16
|
+
return true;
|
|
17
|
+
}, COMMAND_PRIORITY_EDITOR);
|
|
18
|
+
}, [editor]);
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { LexicalCommand } from "lexical";
|
|
3
|
+
import { SheetSelectPayload } from "../../nodes/SheetSelectNode";
|
|
4
|
+
export declare const INSERT_SHEET_SELECT_COMMAND: LexicalCommand<SheetSelectPayload>;
|
|
5
|
+
export default function SheetSelectPlugin(): JSX.Element | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
2
|
+
import { $insertNodeToNearestRoot } from "@lexical/utils";
|
|
3
|
+
import { COMMAND_PRIORITY_EDITOR, createCommand, } from "lexical";
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
import { $createSheetSelectNode, SheetSelectNode, } from "../../nodes/SheetSelectNode";
|
|
6
|
+
export const INSERT_SHEET_SELECT_COMMAND = createCommand("INSERT_SHEET_SELECT_COMMAND");
|
|
7
|
+
export default function SheetSelectPlugin() {
|
|
8
|
+
const [editor] = useLexicalComposerContext();
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (!editor.hasNodes([SheetSelectNode])) {
|
|
11
|
+
throw new Error("SheetSelectNode: SheetSelectNode not registered on editor");
|
|
12
|
+
}
|
|
13
|
+
editor.registerCommand(INSERT_SHEET_SELECT_COMMAND, (payload) => {
|
|
14
|
+
const sheetSelectNode = $createSheetSelectNode(payload);
|
|
15
|
+
$insertNodeToNearestRoot(sheetSelectNode);
|
|
16
|
+
return true;
|
|
17
|
+
}, COMMAND_PRIORITY_EDITOR);
|
|
18
|
+
}, [editor]);
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
@@ -262,6 +262,20 @@ export function getTheme(theme, editable) {
|
|
|
262
262
|
flex: 1;
|
|
263
263
|
gap: 4px;
|
|
264
264
|
margin-bottom: 8px;
|
|
265
|
+
`,
|
|
266
|
+
sheetSelect: css `
|
|
267
|
+
display: flex;
|
|
268
|
+
flex-direction: column;
|
|
269
|
+
flex: 1;
|
|
270
|
+
gap: 4px;
|
|
271
|
+
margin-bottom: 8px;
|
|
272
|
+
`,
|
|
273
|
+
sheetInput: css `
|
|
274
|
+
display: flex;
|
|
275
|
+
flex-direction: column;
|
|
276
|
+
flex: 1;
|
|
277
|
+
gap: 4px;
|
|
278
|
+
margin-bottom: 8px;
|
|
265
279
|
`,
|
|
266
280
|
layoutContainer: css `
|
|
267
281
|
display: grid;
|