Skip to content

Commit

Permalink
chore: f
Browse files Browse the repository at this point in the history
  • Loading branch information
Saul-Mirone committed Dec 15, 2024
1 parent 3f3e8c5 commit cf7d4f1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/components/src/image-block/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface ImageBlockConfig {
uploadPlaceholderText: string
captionPlaceholderText: string
onUpload: (file: File) => Promise<string>
proxyDomURL?: (url: string) => Promise<string>
proxyDomURL?: (url: string) => Promise<string> | string
}

export const defaultImageBlockConfig: ImageBlockConfig = {
Expand Down
11 changes: 8 additions & 3 deletions packages/components/src/image-block/view/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ export const imageBlockView = $view(
if (!proxyDomURL) {
dom.src = node.attrs.src
} else {
proxyDomURL(node.attrs.src).then((url) => {
dom.src = url
})
const proxiedURL = proxyDomURL(node.attrs.src)
if (typeof proxiedURL === 'string') {
dom.src = proxiedURL
} else {
proxiedURL.then((url) => {
dom.src = url
})
}
}
dom.ratio = node.attrs.ratio
dom.caption = node.attrs.caption
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/image-inline/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface InlineImageConfig {
confirmButton: () => ReturnType<typeof html>
uploadPlaceholderText: string
onUpload: (file: File) => Promise<string>
proxyDomURL?: (url: string) => Promise<string>
proxyDomURL?: (url: string) => Promise<string> | string
}

export const defaultInlineImageConfig: InlineImageConfig = {
Expand Down
11 changes: 8 additions & 3 deletions packages/components/src/image-inline/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ export const inlineImageView = $view(
if (!proxyDomURL) {
dom.src = node.attrs.src
} else {
proxyDomURL(node.attrs.src).then((url) => {
dom.src = url
})
const proxiedURL = proxyDomURL(node.attrs.src)
if (typeof proxiedURL === 'string') {
dom.src = proxiedURL
} else {
proxiedURL.then((url) => {
dom.src = url
})
}
}
dom.alt = node.attrs.alt
dom.title = node.attrs.title
Expand Down

0 comments on commit cf7d4f1

Please sign in to comment.