@team-monolith/cds 1.92.0 → 1.93.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.
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- export type TagColor = "default" | "red" | "teal" | "orange" | "blue" | "green" | "yellow" | "black";
2
+ export type TagColor = "default" | "red" | "teal" | "orange" | "blue" | "green" | "yellow" | "black" | "ai";
3
3
  export interface TagProps {
4
4
  className?: string;
5
5
  component?: React.ElementType;
@@ -63,6 +63,10 @@ const COLOR_TO_STYLE = (theme, color) => ({
63
63
  background: ${theme.color.container.obsidianContainer};
64
64
  color: ${theme.color.container.obsidianOnContainer};
65
65
  `,
66
+ ai: css `
67
+ background: linear-gradient(94deg, #5898ff 5.24%, #c673e4 96.99%);
68
+ color: ${theme.color.container.obsidianOnContainer};
69
+ `,
66
70
  })[color];
67
71
  /**
68
72
  * [피그마](https://www.figma.com/file/yhrRFizzmhPoHdw9FbYow2/Codle-PD-Kit---Components?type=design&node-id=42-869&t=HZXCHP0r0tbvMA6v-0)
@@ -35,6 +35,7 @@ import { SheetInputPlugin } from "./plugins/SheetInputPlugin";
35
35
  import { SelfEvaluationPlugin } from "./plugins/SelfEvaluationPlugin";
36
36
  import { FilePlugin } from "./plugins/FilePlugin";
37
37
  import { DragDropPastePlugin } from "./plugins/DragDropPastePlugin";
38
+ import { ParagraphPlaceholderPlugin } from "./plugins/ParagraphPlaceholderPlugin";
38
39
  export function Plugins(props) {
39
40
  const { className, contentEditableClassName, onChange, isSheetEnabled, isQuizEnabled, showFileUpload, } = props;
40
41
  const isEditable = useLexicalEditable();
@@ -49,7 +50,7 @@ export function Plugins(props) {
49
50
  onChange === null || onChange === void 0 ? void 0 : onChange(editorState.toJSON());
50
51
  },
51
52
  // ignore 하지 않으면 Form에서 수정하지 않았는데 Dirty로 처리됨.
52
- ignoreSelectionChange: true }), _jsx(AutoFocusPlugin, {}), isEditable && (_jsxs(_Fragment, { children: [_jsx(TabIndentationPlugin, {}), _jsx(ComponentPickerMenuPlugin, { isSheetEnabled: isSheetEnabled, isQuizEnabled: isQuizEnabled, showFileUpload: showFileUpload }), _jsx(MarkdownShortcutPlugin, { transformers: CUSTOM_TRANSFORMERS }), _jsx(HistoryPlugin, {})] })), floatingAnchorElem && isEditable && (_jsxs(_Fragment, { children: [_jsx(ComponentAdderPlugin, { anchorElem: floatingAnchorElem, isSheetEnabled: isSheetEnabled, isQuizEnabled: isQuizEnabled, showFileUpload: showFileUpload }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem, isLinkEditMode: isLinkEditMode, setIsLinkEditMode: setIsLinkEditMode })] })), !isEditable && _jsx(ClickableLinkPlugin, {}), _jsx(ListPlugin, {}), _jsx(HorizontalRulePlugin, {}), _jsx(ImagesPlugin, {}), _jsx(FilePlugin, {}), _jsx(TablePlugin, {}), _jsx(LinkPlugin, {}), _jsx(ListMaxIndentLevelPlugin, { maxDepth: 5 }), _jsx(ProblemInputPlugin, {}), _jsx(ProblemSelectPlugin, {}), _jsx(LayoutPlugin, {}), _jsx(SheetSelectPlugin, {}), _jsx(SheetInputPlugin, {}), _jsx(SelfEvaluationPlugin, {})] }));
53
+ ignoreSelectionChange: true }), _jsx(AutoFocusPlugin, {}), isEditable && (_jsxs(_Fragment, { children: [_jsx(TabIndentationPlugin, {}), _jsx(ComponentPickerMenuPlugin, { isSheetEnabled: isSheetEnabled, isQuizEnabled: isQuizEnabled, showFileUpload: showFileUpload }), _jsx(MarkdownShortcutPlugin, { transformers: CUSTOM_TRANSFORMERS }), _jsx(HistoryPlugin, {}), _jsx(ParagraphPlaceholderPlugin, { placeholder: "\uBA85\uB839\uC5B4 \uC0AC\uC6A9 \uC2DC\uC5D0\uB294 '/'\uB97C \uB204\uB974\uC138\uC694. \uBE14\uB85D\uC5D0 \uB9C8\uC6B0\uC2A4\uB97C \uC62C\uB824 \uB098\uD0C0\uB098\uB294 '+'\uB97C \uD074\uB9AD\uD558\uBA74 \uC544\uB798\uC5D0 \uBE14\uB85D\uC744 \uCD94\uAC00\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4." })] })), floatingAnchorElem && isEditable && (_jsxs(_Fragment, { children: [_jsx(ComponentAdderPlugin, { anchorElem: floatingAnchorElem, isSheetEnabled: isSheetEnabled, isQuizEnabled: isQuizEnabled, showFileUpload: showFileUpload }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem, isLinkEditMode: isLinkEditMode, setIsLinkEditMode: setIsLinkEditMode })] })), !isEditable && _jsx(ClickableLinkPlugin, {}), _jsx(ListPlugin, {}), _jsx(HorizontalRulePlugin, {}), _jsx(ImagesPlugin, {}), _jsx(FilePlugin, {}), _jsx(TablePlugin, {}), _jsx(LinkPlugin, {}), _jsx(ListMaxIndentLevelPlugin, { maxDepth: 5 }), _jsx(ProblemInputPlugin, {}), _jsx(ProblemSelectPlugin, {}), _jsx(LayoutPlugin, {}), _jsx(SheetSelectPlugin, {}), _jsx(SheetInputPlugin, {}), _jsx(SelfEvaluationPlugin, {})] }));
53
54
  }
54
55
  const ScrollArea = styled.div `
55
56
  min-height: 150px;
@@ -0,0 +1,6 @@
1
+ type ParagraphPlaceholderPluginProps = {
2
+ placeholder: string;
3
+ hideOnEmptyEditor?: boolean;
4
+ };
5
+ export declare const ParagraphPlaceholderPlugin: ({ placeholder, }: ParagraphPlaceholderPluginProps) => null;
6
+ export {};
@@ -0,0 +1,53 @@
1
+ import { useEffect, useMemo, useRef } from "react";
2
+ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
3
+ import { $getSelection, $isParagraphNode, $isRangeSelection } from "lexical";
4
+ import { css as cssToClassName } from "@emotion/css";
5
+ import { useTheme } from "@emotion/react";
6
+ const getPlaceholderClassName = (theme) => cssToClassName `
7
+ &::before {
8
+ position: absolute;
9
+ content: attr(data-placeholder);
10
+ color: ${theme.color.foreground.neutralBaseDisabled};
11
+ pointer-events: none;
12
+ }
13
+ `;
14
+ export const ParagraphPlaceholderPlugin = ({ placeholder, }) => {
15
+ const [editor] = useLexicalComposerContext();
16
+ const paragraphRef = useRef(null);
17
+ const theme = useTheme();
18
+ const placeholderClassName = useMemo(() => getPlaceholderClassName(theme), [theme]);
19
+ useEffect(() => {
20
+ const removeUpdateListener = editor.registerUpdateListener(({ editorState }) => {
21
+ editorState.read(() => {
22
+ // 기존에 있던 placeholder를 제거합니다.
23
+ if (paragraphRef.current) {
24
+ paragraphRef.current.removeAttribute("data-placeholder");
25
+ paragraphRef.current.classList.remove(placeholderClassName);
26
+ paragraphRef.current = null;
27
+ }
28
+ const selection = $getSelection();
29
+ // selection이 없거나, collapsed 상태(anchor와 focus가 같은 경우)가 아니면
30
+ // placeholder를 추가하지 않습니다.
31
+ if (!selection ||
32
+ !$isRangeSelection(selection) ||
33
+ !selection.isCollapsed()) {
34
+ return false;
35
+ }
36
+ const focusedNode = selection.focus.getNode();
37
+ if (!$isParagraphNode(focusedNode) || !focusedNode.isEmpty())
38
+ return false;
39
+ const el = editor.getElementByKey(focusedNode.getKey());
40
+ if (el instanceof HTMLParagraphElement) {
41
+ paragraphRef.current = el;
42
+ paragraphRef.current.setAttribute("data-placeholder", placeholder);
43
+ paragraphRef.current.classList.add(placeholderClassName);
44
+ }
45
+ return false;
46
+ });
47
+ });
48
+ return () => {
49
+ removeUpdateListener();
50
+ };
51
+ }, [editor, placeholder, placeholderClassName]);
52
+ return null;
53
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-monolith/cds",
3
- "version": "1.92.0",
3
+ "version": "1.93.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": false,