Skip to content

Commit ad03630

Browse files
committed
...
1 parent b1fd910 commit ad03630

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

.github/workflows/buildbug.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,45 @@ jobs:
3333
}
3434
EOF
3535
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+
3675
- run: npm install
3776

3877
#- run: |

lexical-cli-render-tsx.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
1+
import { EmojiNode } from "./src/nodes/EmojiNode";
12
import { TextNode, $getRoot, $selectAll } from "lexical";
23
import { createHeadlessEditor } from "@lexical/headless";
34
import { $generateHtmlFromNodes } from "@lexical/html";
45
import { JSDOM } from 'jsdom';
5-
66
import { HeadingNode, QuoteNode } from "@lexical/rich-text";
77
import { LinkNode } from "@lexical/link";
88
import { HashtagNode } from "@lexical/hashtag";
99
import { ListNode, ListItemNode } from "@lexical/list";
10-
11-
import { EmojiNode } from "./src/nodes/EmojiNode";
12-
1310
let input : string = "", html : string = "";
1411
const editor = createHeadlessEditor({
1512
editable: false,
1613
nodes: [TextNode, HeadingNode, QuoteNode, LinkNode, HashtagNode, ListNode, ListItemNode, EmojiNode],
1714
onError: (error) => { throw error;},
1815
});
19-
2016
const dom = new JSDOM();
2117
global.window = dom.window;
2218
global.document = dom.window.document;
23-
2419
process.stdin.on("data", (chunk) => { input += chunk; });
2520
process.stdin.on("end", async () =>
2621
{

0 commit comments

Comments
 (0)