Skip to content

Commit e782915

Browse files
committed
feat: use html2Canvas to save image
1 parent 75b67e2 commit e782915

File tree

8 files changed

+85
-196
lines changed

8 files changed

+85
-196
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"@astrojs/vercel": "^3.2.2",
2323
"@mapbox/rehype-prism": "^0.8.0",
2424
"@nanostores/solid": "^0.3.2",
25-
"@resvg/resvg-wasm": "^2.3.1",
2625
"@solid-primitives/clipboard": "^1.5.4",
2726
"@solid-primitives/keyboard": "^1.1.0",
2827
"@solid-primitives/scheduled": "^1.3.2",
@@ -55,7 +54,6 @@
5554
"remark-math": "^5.1.1",
5655
"remark-parse": "^10.0.1",
5756
"remark-rehype": "^10.1.0",
58-
"satori": "^0.10.1",
5957
"solid-emoji-picker": "^0.2.0",
6058
"solid-js": "1.6.12",
6159
"solid-transition-group": "^0.2.2",
@@ -71,6 +69,7 @@
7169
"@unocss/preset-icons": "^0.50.6",
7270
"@unocss/preset-typography": "^0.50.6",
7371
"eslint-plugin-astro": "^0.24.0",
72+
"html2canvas": "^1.4.1",
7473
"lint-staged": "^13.2.2",
7574
"punycode": "^2.3.0",
7675
"simple-git-hooks": "^2.8.1",

pnpm-lock.yaml

Lines changed: 31 additions & 117 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/main/Continuous.tsx

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,35 @@ export default (props: Props) => {
3838
return (
3939
<>
4040
<div class="scroll-list relative flex flex-col h-full overflow-y-scroll" ref={scrollRef!}>
41-
<For each={props.messages()}>
42-
{(message, index) => (
43-
<div class="border-b border-base">
44-
<MessageItem
45-
conversationId={props.conversationId}
46-
message={message}
47-
handleStreaming={handleStreamableTextUpdate}
48-
index={index()}
49-
/>
50-
</div>
51-
)}
52-
</For>
41+
<div class="w-full max-w-screen-xl">
42+
<For each={props.messages()}>
43+
{(message, index) => (
44+
<div class="border-b border-base">
45+
<MessageItem
46+
conversationId={props.conversationId}
47+
message={message}
48+
handleStreaming={handleStreamableTextUpdate}
49+
index={index()}
50+
/>
51+
</div>
52+
)}
53+
</For>
54+
</div>
55+
{/* use for html2Canvas */}
56+
<div id="message_list_wrapper" class="w-full max-w-screen-xl m-auto clipped hidden">
57+
<For each={props.messages().filter(item => item.isSelected)}>
58+
{(message, index) => (
59+
<div class="border-b border-base">
60+
<MessageItem
61+
conversationId={props.conversationId}
62+
message={message}
63+
handleStreaming={handleStreamableTextUpdate}
64+
index={index()}
65+
/>
66+
</div>
67+
)}
68+
</For>
69+
</div>
5370
</div>
5471
<Show when={!isScrollBottom() && !$isSendBoxFocus()}>
5572
<div

src/components/main/MessageItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default (props: Props) => {
106106

107107
return (
108108
<div
109-
class="p-6 break-words group relative"
109+
class="p-6 break-words group relative bg-base"
110110
classList={{
111111
'bg-base-100': props.message.role === 'user',
112112
}}

0 commit comments

Comments
 (0)