Skip to content

Commit

Permalink
update the use of the url fetch for images
Browse files Browse the repository at this point in the history
  • Loading branch information
blackforestboi committed Mar 5, 2024
1 parent e4db3c1 commit 0882c27
Show file tree
Hide file tree
Showing 9 changed files with 375 additions and 205 deletions.
2 changes: 1 addition & 1 deletion external/@worldbrain/storex-hub
3 changes: 2 additions & 1 deletion src/annotations/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import type { AnalyticsCoreInterface } from '@worldbrain/memex-common/lib/analyt
import type { PKMSyncBackgroundModule } from 'src/pkm-integrations/background'
import type { ImageSupportInterface } from '@worldbrain/memex-common/lib/image-support/types'
import type { AuthBackground } from 'src/authentication/background'
import { ImageSupportBackground } from 'src/image-support/background'

interface TabArg {
tab: Tabs.Tab
Expand Down Expand Up @@ -60,7 +61,7 @@ export default class DirectLinkingBackground {
preAnnotationDelete(params: {
annotationUrl: string
}): Promise<void>
imageSupport: ImageSupportInterface
imageSupport: ImageSupportBackground
},
) {
this.socialBg = options.socialBg
Expand Down
9 changes: 2 additions & 7 deletions src/annotations/components/AnnotationEditable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export default class AnnotationEditable extends React.Component<Props, State> {
this.props.highlightColorSettings,
)

const defaultHighlightSettings = highlightColorSettings.find(
const defaultHighlightSettings = highlightColorSettings?.find(
(setting) => setting.id === 'default',
)
if (defaultHighlightSettings?.color) {
Expand Down Expand Up @@ -452,11 +452,7 @@ export default class AnnotationEditable extends React.Component<Props, State> {
/>
</HighlightEditContainer>
) : (
<Markdown
imageSupport={this.props.imageSupport}
isHighlight
pageUrl={this.props.pageUrl}
>
<Markdown isHighlight pageUrl={this.props.pageUrl}>
{this.state.isTruncatedHighlight
? this.state.truncatedTextHighlight
: this.props.body}
Expand Down Expand Up @@ -847,7 +843,6 @@ export default class AnnotationEditable extends React.Component<Props, State> {
<NoteText
contextLocation={this.props.contextLocation}
getYoutubePlayer={this.props.getYoutubePlayer}
imageSupport={this.props.imageSupport}
>
{comment}
{/* {this.state.isTruncatedNote
Expand Down
5 changes: 4 additions & 1 deletion src/copy-paster/background/template-data-fetchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,10 @@ export function getTemplateDataFetchers({
}

async function convertHTMLintoMarkdown(inputHtml, imageSupport) {
const html = await replaceImgSrcWithFunctionOutput(inputHtml, imageSupport)
const html = await replaceImgSrcWithFunctionOutput(
inputHtml,
process.env.NODE_ENV,
)
if (html) {
let turndownService = new TurndownService({
headingStyle: 'atx',
Expand Down
6 changes: 1 addition & 5 deletions src/markdown-preview/markdown-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,7 @@ export class MarkdownPreview extends React.Component<Props, State> {

private renderEditor() {
if (this.state.showPreview) {
return (
<Markdown imageSupport={this.props.imageSupport}>
{this.props.value}
</Markdown>
)
return <Markdown>{this.props.value}</Markdown>
}

return this.props.renderInput({
Expand Down
Loading

0 comments on commit 0882c27

Please sign in to comment.