Skip to content

Commit

Permalink
feat: use html2Canvas to save image
Browse files Browse the repository at this point in the history
  • Loading branch information
yzh990918 committed Jun 15, 2023
1 parent 75b67e2 commit e782915
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 196 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"@astrojs/vercel": "^3.2.2",
"@mapbox/rehype-prism": "^0.8.0",
"@nanostores/solid": "^0.3.2",
"@resvg/resvg-wasm": "^2.3.1",
"@solid-primitives/clipboard": "^1.5.4",
"@solid-primitives/keyboard": "^1.1.0",
"@solid-primitives/scheduled": "^1.3.2",
Expand Down Expand Up @@ -55,7 +54,6 @@
"remark-math": "^5.1.1",
"remark-parse": "^10.0.1",
"remark-rehype": "^10.1.0",
"satori": "^0.10.1",
"solid-emoji-picker": "^0.2.0",
"solid-js": "1.6.12",
"solid-transition-group": "^0.2.2",
Expand All @@ -71,6 +69,7 @@
"@unocss/preset-icons": "^0.50.6",
"@unocss/preset-typography": "^0.50.6",
"eslint-plugin-astro": "^0.24.0",
"html2canvas": "^1.4.1",
"lint-staged": "^13.2.2",
"punycode": "^2.3.0",
"simple-git-hooks": "^2.8.1",
Expand Down
148 changes: 31 additions & 117 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 29 additions & 12 deletions src/components/main/Continuous.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,35 @@ export default (props: Props) => {
return (
<>
<div class="scroll-list relative flex flex-col h-full overflow-y-scroll" ref={scrollRef!}>
<For each={props.messages()}>
{(message, index) => (
<div class="border-b border-base">
<MessageItem
conversationId={props.conversationId}
message={message}
handleStreaming={handleStreamableTextUpdate}
index={index()}
/>
</div>
)}
</For>
<div class="w-full max-w-screen-xl">
<For each={props.messages()}>
{(message, index) => (
<div class="border-b border-base">
<MessageItem
conversationId={props.conversationId}
message={message}
handleStreaming={handleStreamableTextUpdate}
index={index()}
/>
</div>
)}
</For>
</div>
{/* use for html2Canvas */}
<div id="message_list_wrapper" class="w-full max-w-screen-xl m-auto clipped hidden">
<For each={props.messages().filter(item => item.isSelected)}>
{(message, index) => (
<div class="border-b border-base">
<MessageItem
conversationId={props.conversationId}
message={message}
handleStreaming={handleStreamableTextUpdate}
index={index()}
/>
</div>
)}
</For>
</div>
</div>
<Show when={!isScrollBottom() && !$isSendBoxFocus()}>
<div
Expand Down
2 changes: 1 addition & 1 deletion src/components/main/MessageItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default (props: Props) => {

return (
<div
class="p-6 break-words group relative"
class="p-6 break-words group relative bg-base"
classList={{
'bg-base-100': props.message.role === 'user',
}}
Expand Down
Loading

0 comments on commit e782915

Please sign in to comment.