@team-monolith/cds 1.62.0 → 1.63.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,24 +1,11 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { LexicalComposer, } from "@lexical/react/LexicalComposer";
3
- import { HeadingNode, QuoteNode } from "@lexical/rich-text";
4
- import { TableCellNode, TableNode, TableRowNode } from "@lexical/table";
5
- import { ListItemNode, ListNode } from "@lexical/list";
6
- import { CodeHighlightNode, CodeNode } from "@lexical/code";
7
- import { AutoLinkNode, LinkNode } from "@lexical/link";
8
- import { ImageNode } from "./nodes/ImageNode";
9
- import { HorizontalRuleNode } from "@lexical/react/LexicalHorizontalRuleNode";
10
3
  import { getTheme } from "./theme";
11
4
  import { useTheme } from "@emotion/react";
12
5
  import Plugins from "./Plugins";
13
- import { ColoredQuoteNode, ProblemInputNode } from "./nodes";
6
+ import { nodes } from "./nodes";
14
7
  import { LexicalCustomConfigContext } from "./LexicalCustomConfigContext";
15
- import { ProblemSelectNode } from "./nodes/ProblemSelectNode";
16
- import { LayoutContainerNode } from "./nodes/LayoutContainerNode";
17
- import { LayoutItemNode } from "./nodes/LayoutItemNode";
18
8
  import _ from "lodash";
19
- import { SheetSelectNode } from "./nodes/SheetSelectNode";
20
- import { SheetInputNode } from "./nodes/SheetInputNode";
21
- import { SelfEvaluationNode } from "./nodes/SelfEvaluationNode";
22
9
  function validateValue(value) {
23
10
  var _a, _b;
24
11
  if (value && typeof value !== "object") {
@@ -60,35 +47,7 @@ export function LexicalEditor(props) {
60
47
  const initialConfig = {
61
48
  namespace: "CodleLexicalEditor",
62
49
  onError: (error) => console.error(error),
63
- nodes: [
64
- ProblemInputNode,
65
- ProblemSelectNode,
66
- HeadingNode,
67
- ListNode,
68
- ListItemNode,
69
- QuoteNode,
70
- CodeNode,
71
- CodeHighlightNode,
72
- TableNode,
73
- TableCellNode,
74
- TableRowNode,
75
- AutoLinkNode,
76
- LinkNode,
77
- ImageNode,
78
- HorizontalRuleNode,
79
- ColoredQuoteNode,
80
- LayoutContainerNode,
81
- LayoutItemNode,
82
- SheetSelectNode,
83
- SheetInputNode,
84
- SelfEvaluationNode,
85
- {
86
- replace: QuoteNode,
87
- with: (_node) => {
88
- return new ColoredQuoteNode("grey");
89
- },
90
- },
91
- ],
50
+ nodes,
92
51
  // 마운트 된 이후 editable 수정해도 theme에 반영되지 않음 유의
93
52
  theme: getTheme(theme, editable),
94
53
  editorState: validateValue(value) ? JSON.stringify(value) : undefined,
@@ -0,0 +1,2 @@
1
+ import { SerializedEditorState } from "lexical";
2
+ export declare function convertToMarkdown(serializedLexical: SerializedEditorState): string;
@@ -0,0 +1,21 @@
1
+ import { createEditor } from "lexical";
2
+ import { $convertToMarkdownString } from "@lexical/markdown";
3
+ import { CODLE_TRANSFORMERS } from "./plugins/MarkdownTransformers";
4
+ import { nodes } from "./nodes";
5
+ export function convertToMarkdown(serializedLexical) {
6
+ // Create a Lexical editor instance
7
+ const editor = createEditor({
8
+ nodes,
9
+ });
10
+ // Update the editor state with the serialized Lexical state
11
+ editor.update(() => {
12
+ const editorState = editor.parseEditorState(serializedLexical);
13
+ editor.setEditorState(editorState);
14
+ });
15
+ // Convert the Lexical editor state to Markdown string
16
+ let markdown = "";
17
+ editor.update(() => {
18
+ markdown = $convertToMarkdownString(CODLE_TRANSFORMERS);
19
+ });
20
+ return markdown;
21
+ }
@@ -1,2 +1,3 @@
1
1
  export * from "./LexicalEditor";
2
2
  export * from "./plugins/MarkdownTransformers";
3
+ export * from "./convertToMarkdown";
@@ -1,2 +1,3 @@
1
1
  export * from "./LexicalEditor";
2
2
  export * from "./plugins/MarkdownTransformers";
3
+ export * from "./convertToMarkdown";
@@ -1,3 +1,4 @@
1
1
  export * from "./ColoredQuoteNode";
2
2
  export * from "./ImageNode";
3
3
  export * from "./ProblemInputNode";
4
+ export * from "./nodes";
@@ -1,3 +1,4 @@
1
1
  export * from "./ColoredQuoteNode";
2
2
  export * from "./ImageNode";
3
3
  export * from "./ProblemInputNode";
4
+ export * from "./nodes";
@@ -0,0 +1,19 @@
1
+ import { HorizontalRuleNode } from "@lexical/react/LexicalHorizontalRuleNode";
2
+ import { ColoredQuoteNode } from "./ColoredQuoteNode";
3
+ import { ImageNode } from "./ImageNode";
4
+ import { LayoutContainerNode } from "./LayoutContainerNode";
5
+ import { LayoutItemNode } from "./LayoutItemNode";
6
+ import { ProblemInputNode } from "./ProblemInputNode";
7
+ import { ProblemSelectNode } from "./ProblemSelectNode";
8
+ import { SelfEvaluationNode } from "./SelfEvaluationNode";
9
+ import { SheetInputNode } from "./SheetInputNode";
10
+ import { SheetSelectNode } from "./SheetSelectNode";
11
+ import { HeadingNode, QuoteNode } from "@lexical/rich-text";
12
+ import { TableCellNode, TableNode, TableRowNode } from "@lexical/table";
13
+ import { ListItemNode, ListNode } from "@lexical/list";
14
+ import { CodeHighlightNode, CodeNode } from "@lexical/code";
15
+ import { LinkNode } from "@lexical/link";
16
+ export declare const nodes: (typeof ColoredQuoteNode | typeof QuoteNode | typeof ImageNode | typeof ProblemInputNode | typeof LayoutContainerNode | typeof LayoutItemNode | typeof ProblemSelectNode | typeof SelfEvaluationNode | typeof SheetInputNode | typeof SheetSelectNode | typeof HeadingNode | typeof ListNode | typeof ListItemNode | typeof CodeNode | typeof CodeHighlightNode | typeof TableNode | typeof TableCellNode | typeof TableRowNode | typeof LinkNode | typeof HorizontalRuleNode | {
17
+ replace: typeof QuoteNode;
18
+ with: () => ColoredQuoteNode;
19
+ })[];
@@ -0,0 +1,44 @@
1
+ import { HorizontalRuleNode } from "@lexical/react/LexicalHorizontalRuleNode";
2
+ import { ColoredQuoteNode } from "./ColoredQuoteNode";
3
+ import { ImageNode } from "./ImageNode";
4
+ import { LayoutContainerNode } from "./LayoutContainerNode";
5
+ import { LayoutItemNode } from "./LayoutItemNode";
6
+ import { ProblemInputNode } from "./ProblemInputNode";
7
+ import { ProblemSelectNode } from "./ProblemSelectNode";
8
+ import { SelfEvaluationNode } from "./SelfEvaluationNode";
9
+ import { SheetInputNode } from "./SheetInputNode";
10
+ import { SheetSelectNode } from "./SheetSelectNode";
11
+ import { HeadingNode, QuoteNode } from "@lexical/rich-text";
12
+ import { TableCellNode, TableNode, TableRowNode } from "@lexical/table";
13
+ import { ListItemNode, ListNode } from "@lexical/list";
14
+ import { CodeHighlightNode, CodeNode } from "@lexical/code";
15
+ import { AutoLinkNode, LinkNode } from "@lexical/link";
16
+ export const nodes = [
17
+ ProblemInputNode,
18
+ ProblemSelectNode,
19
+ HeadingNode,
20
+ ListNode,
21
+ ListItemNode,
22
+ QuoteNode,
23
+ CodeNode,
24
+ CodeHighlightNode,
25
+ TableNode,
26
+ TableCellNode,
27
+ TableRowNode,
28
+ AutoLinkNode,
29
+ LinkNode,
30
+ ImageNode,
31
+ HorizontalRuleNode,
32
+ ColoredQuoteNode,
33
+ LayoutContainerNode,
34
+ LayoutItemNode,
35
+ SheetSelectNode,
36
+ SheetInputNode,
37
+ SelfEvaluationNode,
38
+ {
39
+ replace: QuoteNode,
40
+ with: () => {
41
+ return new ColoredQuoteNode("grey");
42
+ },
43
+ },
44
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-monolith/cds",
3
- "version": "1.62.0",
3
+ "version": "1.63.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": false,