Astro に統合する

インストールと基本的な使い方 で起動します。以下の例では、Astroを使用して、明示的な高さを持つコンテナに Univer Pdf をマウントします。

<script> エレメントを使用して、エディタを直接ブラウザで初期化します。 astro:page-loadで最初のロードと再び初期化します. ClientRouter を使って, astro:before-swap 前にあるインスタンスのディスポース. エディタは Astro フロントマッターからインポートします. 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 PdfsUIjaJP from '@univerjs-pro/pdfs-ui/locale/ja-JP'  import { LocaleType, mergeLocales, Univer } from '@univerjs/core'  import { FUniver } from '@univerjs/core/facade'  import DesignjaJP from '@univerjs/design/locale/ja-JP'  import { UniverUIPlugin } from '@univerjs/ui'  import UIjaJP from '@univerjs/ui/locale/ja-JP'  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.JA_JP,      locales: {        [LocaleType.JA_JP]: mergeLocales(          DesignjaJP,          UIjaJP,          PdfsUIjaJP,        ),      },    })    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.