@team-monolith/cds 1.67.1 → 1.67.2
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/convertToMarkdown.d.ts +2 -1
- package/dist/patterns/LexicalEditor/convertToMarkdown.js +2 -2
- package/dist/patterns/LexicalEditor/plugins/MarkdownTransformers/index.d.ts +2 -0
- package/dist/patterns/LexicalEditor/plugins/MarkdownTransformers/index.js +34 -0
- package/package.json +1 -1
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { SerializedEditorState } from "lexical";
|
|
2
|
-
|
|
2
|
+
import { Transformer } from "@lexical/markdown";
|
|
3
|
+
export declare function convertToMarkdown(serializedLexical: SerializedEditorState, transformers?: Transformer[]): string;
|
|
@@ -2,7 +2,7 @@ import { createEditor } from "lexical";
|
|
|
2
2
|
import { $convertToMarkdownString } from "@lexical/markdown";
|
|
3
3
|
import { CODLE_TRANSFORMERS } from "./plugins/MarkdownTransformers";
|
|
4
4
|
import { nodes } from "./nodes";
|
|
5
|
-
export function convertToMarkdown(serializedLexical) {
|
|
5
|
+
export function convertToMarkdown(serializedLexical, transformers) {
|
|
6
6
|
// Create a Lexical editor instance
|
|
7
7
|
const editor = createEditor({
|
|
8
8
|
nodes,
|
|
@@ -15,7 +15,7 @@ export function convertToMarkdown(serializedLexical) {
|
|
|
15
15
|
// Convert the Lexical editor state to Markdown string
|
|
16
16
|
let markdown = "";
|
|
17
17
|
editor.update(() => {
|
|
18
|
-
markdown = $convertToMarkdownString(CODLE_TRANSFORMERS);
|
|
18
|
+
markdown = $convertToMarkdownString(transformers !== null && transformers !== void 0 ? transformers : CODLE_TRANSFORMERS);
|
|
19
19
|
});
|
|
20
20
|
return markdown;
|
|
21
21
|
}
|
|
@@ -9,4 +9,6 @@ import { ElementTransformer, TextMatchTransformer, Transformer } from "@lexical/
|
|
|
9
9
|
export declare const HR: ElementTransformer;
|
|
10
10
|
export declare const IMAGE: TextMatchTransformer;
|
|
11
11
|
export declare const TABLE: ElementTransformer;
|
|
12
|
+
export declare const IMAGE_LLM: TextMatchTransformer;
|
|
12
13
|
export declare const CODLE_TRANSFORMERS: Array<Transformer>;
|
|
14
|
+
export declare const LLM_TRANSFORMERS: Array<Transformer>;
|
|
@@ -188,6 +188,29 @@ const SHEET_INPUT = {
|
|
|
188
188
|
regExp: /a^/,
|
|
189
189
|
replace: () => { },
|
|
190
190
|
};
|
|
191
|
+
// LLM에게 의미없는 이미지 URL을 제공하지 않습니다.
|
|
192
|
+
export const IMAGE_LLM = {
|
|
193
|
+
dependencies: [ImageNode],
|
|
194
|
+
export: (node) => {
|
|
195
|
+
if (!$isImageNode(node)) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
return `![${node.getAltText()}]()`;
|
|
199
|
+
},
|
|
200
|
+
importRegExp: /!(?:\[([^[]*)\])(?:\(([^(]+)\))/,
|
|
201
|
+
regExp: /!(?:\[([^[]*)\])(?:\(([^(]+)\))$/,
|
|
202
|
+
replace: (textNode, match) => {
|
|
203
|
+
const [, altText, src] = match;
|
|
204
|
+
const imageNode = $createImageNode({
|
|
205
|
+
altText,
|
|
206
|
+
maxWidth: 800,
|
|
207
|
+
src,
|
|
208
|
+
});
|
|
209
|
+
textNode.replace(imageNode);
|
|
210
|
+
},
|
|
211
|
+
trigger: ")",
|
|
212
|
+
type: "text-match",
|
|
213
|
+
};
|
|
191
214
|
export const CODLE_TRANSFORMERS = [
|
|
192
215
|
TABLE,
|
|
193
216
|
HR,
|
|
@@ -196,5 +219,16 @@ export const CODLE_TRANSFORMERS = [
|
|
|
196
219
|
...ELEMENT_TRANSFORMERS,
|
|
197
220
|
...TEXT_FORMAT_TRANSFORMERS,
|
|
198
221
|
...TEXT_MATCH_TRANSFORMERS,
|
|
222
|
+
];
|
|
223
|
+
// LLM에 전달하기 위한 용도로 사용되는 Transformer들의 모음입니다.
|
|
224
|
+
// Export 만을 지원하기도 합니다.
|
|
225
|
+
export const LLM_TRANSFORMERS = [
|
|
226
|
+
TABLE,
|
|
227
|
+
HR,
|
|
228
|
+
IMAGE_LLM,
|
|
229
|
+
CHECK_LIST,
|
|
230
|
+
...ELEMENT_TRANSFORMERS,
|
|
231
|
+
...TEXT_FORMAT_TRANSFORMERS,
|
|
232
|
+
...TEXT_MATCH_TRANSFORMERS,
|
|
199
233
|
SHEET_INPUT,
|
|
200
234
|
];
|