Web Component に統合する
まずインストールと基本的な使い方を参照してください。以下は Web Component を使い、高さを明示したコンテナーに Univer Bases をマウントする例です。
統合手順
connectedCallbackで Univer を初期化します。disconnectedCallbackで Univer を破棄します。
サンプルコード
TypeScript
import { UniverBasesPlugin } from '@univerjs-pro/bases'import { UniverBasesUIPlugin } from '@univerjs-pro/bases-ui'import BasesUIjaJP from '@univerjs-pro/bases-ui/locale/ja-JP'import BasesjaJP from '@univerjs-pro/bases/locale/ja-JP'import { UniverProFormulaEnginePlugin } from '@univerjs-pro/engine-formula'import { UniverLicensePlugin } from '@univerjs-pro/license'import { LocaleType, mergeLocales, Univer, UniverInstanceType } from '@univerjs/core'import DesignjaJP from '@univerjs/design/locale/ja-JP'import { UniverRenderEnginePlugin } from '@univerjs/engine-render'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/bases-ui/lib/index.css'class UniverEditorElement extends HTMLElement { private univer?: Univer connectedCallback() { const container = this const univer = new Univer({ locale: LocaleType.JA_JP, locales: { [LocaleType.JA_JP]: mergeLocales( DesignjaJP, UIjaJP, BasesjaJP, BasesUIjaJP, ), }, }) univer.registerPlugin(UniverLicensePlugin, { license: 'your license.txt', }) univer.registerPlugin(UniverRenderEnginePlugin) univer.registerPlugin(UniverUIPlugin, { container }) univer.registerPlugin(UniverProFormulaEnginePlugin) univer.registerPlugin(UniverBasesPlugin) univer.registerPlugin(UniverBasesUIPlugin) univer.createUnit(UniverInstanceType.UNIVER_BASE, {}) this.univer = univer } disconnectedCallback() { this.univer?.dispose() this.univer = undefined }}customElements.define('univer-bases-editor', UniverEditorElement)HTML
<univer-bases-editor style="display: block; height: 600px"></univer-bases-editor>このガイドはいかがですか?