Astro에 통합하기
이 페이지는 설치 및 기본 사용에서 시작합니다. 예를 들어 Univer Base를 Astro 페이지에 마운트하면 컨테이너가 명시된 높이로 들어갑니다.
일반 <script>는 브라우저에서 직접 편집기를 초기화합니다. 처음 로드와 astro:page-load에서 초기화를 실행하고 클라이언트로 변환이 사용할 때 astro:before-swap 전에 ZXQXZ의 인스턴스를 분해합니다. 편집기가 Astro frontmatter에서 가져옵니다. Astro 내비게이션 이벤트를 참조하십시오.
통합 단계
mount()/astro:page-load에서 Univer를 초기화합니다.astro:before-swap에서 인스턴스의 처리.
플러그인 설정
UniverUIPlugin
containerstring | HTMLElement편집기를 마운트할 DOM 요소 또는 해당 요소의 ID입니다.
UniverLicensePlugin
licensestring클라이언트 라이선스 파일의 내용입니다.
예제 코드
Astro
<div id="univer-bases" style="height: 600px"></div><script> import { UniverBasesPlugin } from '@univerjs-pro/bases' import { UniverBasesUIPlugin } from '@univerjs-pro/bases-ui' import BasesUIkoKR from '@univerjs-pro/bases-ui/locale/ko-KR' import BaseskoKR from '@univerjs-pro/bases/locale/ko-KR' import { UniverProFormulaEnginePlugin } from '@univerjs-pro/engine-formula' import { UniverLicensePlugin } from '@univerjs-pro/license' import { LocaleType, mergeLocales, Univer, UniverInstanceType } from '@univerjs/core' import DesignkoKR from '@univerjs/design/locale/ko-KR' import { UniverRenderEnginePlugin } from '@univerjs/engine-render' 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/bases-ui/lib/index.css' let univerInstance: Univer | undefined function mount() { const container = document.getElementById('univer-bases') if (!container || univerInstance) return const univer = new Univer({ locale: LocaleType.KO_KR, locales: { [LocaleType.KO_KR]: mergeLocales( DesignkoKR, UIkoKR, BaseskoKR, BasesUIkoKR, ), }, }) 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, {}) univerInstance = univer } function dispose() { univerInstance?.dispose() univerInstance = undefined } mount() document.addEventListener('astro:page-load', mount) document.addEventListener('astro:before-swap', dispose)</script>이 가이드는 어떠셨나요?