-
-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add image renderer Add error handle Fix: https://linear.app/affine-design/issue/AFF-854/chat-panel-ui:-图片应该是裁剪而不是拉伸 https://linear.app/affine-design/issue/AFF-856/chat-panel-ui-action-的-toggle-点击位置需要更大
- Loading branch information
Showing
7 changed files
with
316 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import './action-wrapper.js'; | ||
|
||
import type { EditorHost } from '@blocksuite/block-std'; | ||
import { ShadowlessElement, WithDisposable } from '@blocksuite/block-std'; | ||
import { css, html, nothing } from 'lit'; | ||
import { customElement, property } from 'lit/decorators.js'; | ||
import { repeat } from 'lit/directives/repeat.js'; | ||
|
||
import { createTextRenderer } from '../../messages/text.js'; | ||
@customElement('chat-text') | ||
export class ChatText extends WithDisposable(ShadowlessElement) { | ||
static override styles = css` | ||
.images-container { | ||
display: flex; | ||
gap: 12px; | ||
} | ||
.image-container { | ||
border-radius: 4px; | ||
width: 155px; | ||
height: 129px; | ||
overflow: hidden; | ||
position: relative; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
img { | ||
max-width: 100%; | ||
max-height: 100%; | ||
width: auto; | ||
height: auto; | ||
} | ||
} | ||
`; | ||
@property({ attribute: false }) | ||
host!: EditorHost; | ||
|
||
@property({ attribute: false }) | ||
blobs?: Blob[]; | ||
|
||
@property({ attribute: false }) | ||
text!: string; | ||
|
||
protected override render() { | ||
const { blobs, text } = this; | ||
return html`${blobs | ||
? html`<div class="images-container"> | ||
${repeat( | ||
blobs, | ||
blob => blob, | ||
blob => { | ||
return html`<div class="image-container"> | ||
<img src="${URL.createObjectURL(blob)}" /> | ||
</div>`; | ||
} | ||
)} | ||
</div>` | ||
: nothing}${createTextRenderer(this.host)(text)}`; | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'chat-text': ChatText; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
ba8db96
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Size Report
Bundles
Packages