@team-monolith/cds 0.31.2 → 0.31.6

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.
@@ -6,9 +6,9 @@ export interface LexicalEditorProps {
6
6
  onChange: (blocks: SerializedEditorState<SerializedLexicalNode>) => void;
7
7
  /** editable. 수정 모드 / 읽기 모드 여부
8
8
  * initialConfig에 전달되므로 마운트 된 이후 수정해도 반영되지 않음
9
- */
9
+ */
10
10
  editable?: boolean;
11
11
  /** 외부에서 플러그인을 주입하는 경우 활용함 */
12
- children?: string | Element;
12
+ children?: JSX.Element | string | (JSX.Element | string)[];
13
13
  }
14
- export declare function LexicalEditor(props: LexicalEditorProps): JSX.Element;
14
+ export declare function LexicalEditor(props: LexicalEditorProps): import("react/jsx-runtime").JSX.Element;
@@ -11,7 +11,7 @@ import { getTheme } from "./theme";
11
11
  import { useTheme } from "@emotion/react";
12
12
  import Plugins from "./Plugins";
13
13
  export function LexicalEditor(props) {
14
- const { value, onChange, editable = true, children } = props;
14
+ const { className, value, onChange, editable = true, children } = props;
15
15
  const theme = useTheme();
16
16
  const initialConfig = {
17
17
  namespace: "CodleLexicalEditor",
@@ -35,5 +35,5 @@ export function LexicalEditor(props) {
35
35
  editorState: JSON.stringify(value),
36
36
  editable: editable,
37
37
  };
38
- return (_jsxs(LexicalComposer, Object.assign({ initialConfig: initialConfig }, { children: [_jsx(Plugins, { onChange: onChange }), _jsx(_Fragment, { children: children })] })));
38
+ return (_jsxs(LexicalComposer, Object.assign({ initialConfig: initialConfig }, { children: [_jsx(Plugins, { className: className, onChange: onChange }), _jsx(_Fragment, { children: children })] })));
39
39
  }
@@ -5,6 +5,7 @@
5
5
  import { ReactElement } from "react";
6
6
  import { SerializedEditorState, SerializedLexicalNode } from "lexical";
7
7
  export interface PluginsProps {
8
+ className?: string;
8
9
  onChange: (blocks: SerializedEditorState<SerializedLexicalNode>) => void;
9
10
  }
10
11
  export default function Plugins(props: PluginsProps): ReactElement;
@@ -28,7 +28,7 @@ import useLexicalEditable from "@lexical/react/useLexicalEditable";
28
28
  import ListMaxIndentLevelPlugin from "./plugins/ListMaxIndentLevelPlugin";
29
29
  import styled from "@emotion/styled";
30
30
  export default function Plugins(props) {
31
- const { onChange } = props;
31
+ const { className, onChange } = props;
32
32
  const isEditable = useLexicalEditable();
33
33
  const [floatingAnchorElem, setFloatingAnchorElem] = useState(null);
34
34
  const [isLinkEditMode, setIsLinkEditMode] = useState(false);
@@ -37,9 +37,9 @@ export default function Plugins(props) {
37
37
  setFloatingAnchorElem(_floatingAnchorElem);
38
38
  }
39
39
  };
40
- return (_jsxs(_Fragment, { children: [_jsx(RichTextPlugin, { contentEditable: _jsx(ScrollArea, { children: _jsx(FloatingAnchor, Object.assign({ ref: onRef }, { children: _jsx(StyledContentEditable, {}) })) }), placeholder: _jsx("div", { children: "\uB0B4\uC6A9\uC744 \uC785\uB825 \uD574 \uC8FC\uC138\uC694." }), ErrorBoundary: LexicalErrorBoundary }), _jsx(OnChangePlugin, { onChange: (editorState) => {
40
+ return (_jsxs(_Fragment, { children: [_jsx(RichTextPlugin, { contentEditable: _jsx(ScrollArea, Object.assign({ className: className }, { children: _jsx(FloatingAnchor, Object.assign({ ref: onRef }, { children: _jsx(StyledContentEditable, { isEditable: isEditable }) })) })), placeholder: _jsx("div", { children: "\uB0B4\uC6A9\uC744 \uC785\uB825 \uD574 \uC8FC\uC138\uC694." }), ErrorBoundary: LexicalErrorBoundary }), _jsx(OnChangePlugin, { onChange: (editorState) => {
41
41
  onChange(editorState.toJSON());
42
- } }), _jsx(HistoryPlugin, {}), _jsx(AutoFocusPlugin, {}), floatingAnchorElem && (_jsxs(_Fragment, { children: [_jsx(ComponentAdderPlugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem, isLinkEditMode: isLinkEditMode, setIsLinkEditMode: setIsLinkEditMode })] })), !isEditable && _jsx(LexicalClickableLinkPlugin, {}), _jsx(MarkdownShortcutPlugin, { transformers: CODLE_TRANSFORMERS }), _jsx(ComponentPickerMenuPlugin, {}), _jsx(ListPlugin, {}), _jsx(TabIndentationPlugin, {}), _jsx(HorizontalRulePlugin, {}), _jsx(ImagesPlugin, {}), _jsx(TablePlugin, {}), _jsx(LinkPlugin, {}), _jsx(ListMaxIndentLevelPlugin, { maxDepth: 5 })] }));
42
+ } }), _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 })] }));
43
43
  }
44
44
  const ScrollArea = styled.div `
45
45
  min-height: 150px;
@@ -49,12 +49,10 @@ const ScrollArea = styled.div `
49
49
  outline: 0;
50
50
  z-index: 0;
51
51
  overflow: auto;
52
- resize: vertical;
53
52
  `;
54
53
  const FloatingAnchor = styled.div `
55
54
  flex: auto;
56
55
  position: relative;
57
- resize: vertical;
58
56
  z-index: -1;
59
57
  `;
60
58
  const StyledContentEditable = styled(ContentEditable) `
@@ -63,7 +61,8 @@ const StyledContentEditable = styled(ContentEditable) `
63
61
  display: block;
64
62
  position: relative;
65
63
  outline: 0;
66
- padding: 8px 28px 40px 64px;
64
+ // ComponentAdder 위한 공간
65
+ ${({ isEditable }) => isEditable && "padding-left: 64px;"}
67
66
  min-height: 150px;
68
67
 
69
68
  hr {
@@ -1,2 +1,3 @@
1
1
  export * from "./LexicalEditor";
2
2
  export * from "./nodes/ImageNode";
3
+ export * from "./plugins/MarkdownTransformers";
@@ -1,2 +1,3 @@
1
1
  export * from "./LexicalEditor";
2
2
  export * from "./nodes/ImageNode";
3
+ export * from "./plugins/MarkdownTransformers";
@@ -74,7 +74,14 @@ export function ComponentAdderPlugin(props) {
74
74
  const nodes = selection.getNodes();
75
75
  const isAllNodesNotMatched = nodes.every((node) => {
76
76
  const nodeAndParents = [node, ...node.getParents()];
77
- return (nodeAndParents[nodeAndParents.length - 2].getKey() !== nodeKey);
77
+ const maybeTopNode = nodeAndParents[nodeAndParents.length - 2];
78
+ // 선택된 노드 자체가 Root Node라면
79
+ // maybeTopNode가 undefined가 됩니다.
80
+ // 다른 노드를 선택한 것으로 간주하고 true(not matched)를 반환합니다.
81
+ if (!maybeTopNode) {
82
+ return true;
83
+ }
84
+ return maybeTopNode.getKey() !== nodeKey;
78
85
  });
79
86
  if (isAllNodesNotMatched) {
80
87
  setQuery("");
@@ -1,8 +1,7 @@
1
- /// <reference types="react" />
2
1
  import { LexicalEditor } from "lexical";
3
2
  export interface InsertImageDialogProps {
4
3
  open: boolean;
5
4
  activeEditor: LexicalEditor;
6
5
  onClose: () => void;
7
6
  }
8
- export declare function InsertImageDialog(props: InsertImageDialogProps): JSX.Element;
7
+ export declare function InsertImageDialog(props: InsertImageDialogProps): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { InsertImagePayload } from ".";
3
2
  export interface InsertImageUploadedDialogBodyProps {
4
3
  onClick: (payload: InsertImagePayload) => void;
5
4
  }
6
- export declare function InsertImageUploadedDialogBody(props: InsertImageUploadedDialogBodyProps): JSX.Element;
5
+ export declare function InsertImageUploadedDialogBody(props: InsertImageUploadedDialogBodyProps): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { InsertImagePayload } from ".";
3
2
  export interface InsertImageUriDialogBodyProps {
4
3
  onClick: (payload: InsertImagePayload) => void;
5
4
  }
6
- export declare function InsertImageUriDialogBody(props: InsertImageUriDialogBodyProps): JSX.Element;
5
+ export declare function InsertImageUriDialogBody(props: InsertImageUriDialogBodyProps): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { EditorCore } from "@react-editor-js/core";
3
2
  export interface ReactEditorJSProps {
4
3
  className?: string;
@@ -13,4 +12,4 @@ export interface ReactEditorJSProps {
13
12
  /** 초기화시 콜백 */
14
13
  onInitialize?: (instance: EditorCore) => void;
15
14
  }
16
- export declare function ReactEditorJS(props: ReactEditorJSProps): JSX.Element;
15
+ export declare function ReactEditorJS(props: ReactEditorJSProps): import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-monolith/cds",
3
- "version": "0.31.2",
3
+ "version": "0.31.6",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": false,