|
33 | 33 | } |
34 | 34 | EOF |
35 | 35 | |
| 36 | + - run: | |
| 37 | + cat <<EOF > lexical-cli-render-tsx.ts |
| 38 | + import { EmojiNode } from "./src/nodes/EmojiNode"; |
| 39 | + import { TextNode, $getRoot, $selectAll } from "lexical"; |
| 40 | + import { createHeadlessEditor } from "@lexical/headless"; |
| 41 | + import { $generateHtmlFromNodes } from "@lexical/html"; |
| 42 | + import { JSDOM } from 'jsdom'; |
| 43 | + import { HeadingNode, QuoteNode } from "@lexical/rich-text"; |
| 44 | + import { LinkNode } from "@lexical/link"; |
| 45 | + import { HashtagNode } from "@lexical/hashtag"; |
| 46 | + import { ListNode, ListItemNode } from "@lexical/list"; |
| 47 | + let input : string = "", html : string = ""; |
| 48 | + const editor = createHeadlessEditor({ |
| 49 | + editable: false, |
| 50 | + nodes: [TextNode, HeadingNode, QuoteNode, LinkNode, HashtagNode, ListNode, ListItemNode, EmojiNode], |
| 51 | + onError: (error) => { throw error;}, |
| 52 | + }); |
| 53 | + const dom = new JSDOM(); |
| 54 | + global.window = dom.window; |
| 55 | + global.document = dom.window.document; |
| 56 | + process.stdin.on("data", (chunk) => { input += chunk; }); |
| 57 | + process.stdin.on("end", async () => |
| 58 | + { |
| 59 | + try |
| 60 | + { |
| 61 | + const editorStateJson = JSON.parse(input).editorState; |
| 62 | + const editorState = editor.parseEditorState(editorStateJson); |
| 63 | + editor.setEditorState(editorState); |
| 64 | + editor.update(() => { html = $generateHtmlFromNodes(editor, $selectAll()); }); |
| 65 | + console.log(html); |
| 66 | + } |
| 67 | + catch (error) |
| 68 | + { |
| 69 | + console.error("Error processing EditorState JSON:", error); |
| 70 | + process.exit(1); |
| 71 | + } |
| 72 | + }); |
| 73 | + EOF |
| 74 | + |
36 | 75 | - run: npm install |
37 | 76 |
|
38 | 77 | #- run: | |
|
0 commit comments