Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions packages/ui/src/components/EmbeddedHTML.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!--
// Copyright © 2026 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->

<script lang="ts">
import { onDestroy } from 'svelte'
import EmbeddedPDF from './EmbeddedPDF.svelte'
import Loading from './Loading.svelte'

export let src: string
export let name: string
export let fit: boolean = false
export let css: string | undefined = undefined

let iframeSrc: string | undefined

async function loadFile (src: string): Promise<void> {
if (iframeSrc !== undefined) {
URL.revokeObjectURL(iframeSrc)
iframeSrc = undefined
}

const response = await fetch(src)
const blob = await response.blob()
iframeSrc = URL.createObjectURL(blob)
}

$: void loadFile(src)

onDestroy(() => {
if (iframeSrc !== undefined) {
URL.revokeObjectURL(iframeSrc)
}
})
</script>

{#if iframeSrc}
<EmbeddedPDF src={iframeSrc} {name} {fit} {css} />
{:else}
<Loading />
{/if}
1 change: 1 addition & 0 deletions packages/ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ export { default as CodeForm } from './components/CodeForm.svelte'
export { default as CodeInput } from './components/CodeInput.svelte'
export { default as TimeLeft } from './components/TimeLeft.svelte'
export { default as SectionEmpty } from './components/SectionEmpty.svelte'
export { default as EmbeddedHTML } from './components/EmbeddedHTML.svelte'
export { default as EmbeddedPDF } from './components/EmbeddedPDF.svelte'
export { default as NestedMenu } from './components/NestedMenu.svelte'
export { default as NestedDropdown } from './components/NestedDropdown.svelte'
Expand Down
4 changes: 2 additions & 2 deletions plugins/print-resources/src/components/DOCXViewer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { getMetadata } from '@hcengineering/platform'
import presentation, { getFileUrl } from '@hcengineering/presentation'
import { convertToHTML } from '@hcengineering/print'
import { EmbeddedPDF, Spinner, themeStore } from '@hcengineering/ui'
import { EmbeddedHTML, Spinner, themeStore } from '@hcengineering/ui'

export let value: Ref<Blob>
export let name: string
Expand Down Expand Up @@ -270,7 +270,7 @@
<Spinner size="medium" />
</div>
{:else}
<EmbeddedPDF {src} {name} {css} />
<EmbeddedHTML {src} {name} {css} />
{/if}
{/if}

Expand Down
Loading