Astro에 통합하기

설치 및 기본 사용로 시작. 아래 예제는 Astro를 사용하여 Univer Pdf를 컨테이너에 마운트합니다.

일반 <script> 요소를 사용하여 브라우저에서 직접 편집기를 초기화합니다. 처음에는 astro:page-load에서 다시로드하고 있습니다. ClientRouter를 사용하면 astro:before-swap 이전에 인스턴스를 분해합니다. 편집기가 Astro frontmatter에서 가져 오기를 유지합니다. Astro 내비게이션 이벤트를 참조하십시오.

통합 단계

  1. mount() / astro:page-load의 Univer 인스턴스를 만듭니다.
  2. astro:before-swap에서 인스턴스의 처리.

플러그인 설정

UniverUIPlugin

  • container
    string | HTMLElement
    편집기를 마운트할 DOM 요소 또는 요소 ID입니다.

UniverLicensePlugin

  • license
    string
    클라이언트 라이선스 파일의 내용입니다.

예제 코드

Astro
<div id="univer-pdfs" style="height: 600px"></div><script>  import { UniverLicensePlugin } from '@univerjs-pro/license'  import { UniverPdfsPlugin } from '@univerjs-pro/pdfs'  import { UniverPdfsUIPlugin } from '@univerjs-pro/pdfs-ui'  import PdfsUIkoKR from '@univerjs-pro/pdfs-ui/locale/ko-KR'  import { LocaleType, mergeLocales, Univer } from '@univerjs/core'  import { FUniver } from '@univerjs/core/facade'  import DesignkoKR from '@univerjs/design/locale/ko-KR'  import { UniverUIPlugin } from '@univerjs/ui'  import UIkoKR from '@univerjs/ui/locale/ko-KR'  import '@univerjs/design/lib/index.css'  import '@univerjs/ui/lib/index.css'  import '@univerjs-pro/pdfs-ui/lib/index.css'  import '@univerjs-pro/pdfs/facade'  let univerInstance: Univer | undefined  function mount() {    const container = document.getElementById('univer-pdfs')    if (!container || univerInstance) return    const univer = new Univer({      locale: LocaleType.KO_KR,      locales: {        [LocaleType.KO_KR]: mergeLocales(          DesignkoKR,          UIkoKR,          PdfsUIkoKR,        ),      },    })    univer.registerPlugin(UniverLicensePlugin, {      license: 'your license.txt',    })    univer.registerPlugin(UniverUIPlugin, { container })    univer.registerPlugin(UniverPdfsPlugin)    univer.registerPlugin(UniverPdfsUIPlugin)    const univerAPI = FUniver.newAPI(univer)    univerAPI.createPdf({ name: 'Untitled PDF' })    univerInstance = univer  }  function dispose() {    univerInstance?.dispose()    univerInstance = undefined  }  mount()  document.addEventListener('astro:page-load', mount)  document.addEventListener('astro:before-swap', dispose)</script>

이 가이드는 어떠셨나요?

© 2026 DreamNum Co., Ltd.