Skip to content

Latest commit

 

History

History

ui-adapter-web-component

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

@univerjs/ui-adapter-web-component

npm version license downloads

@univerjs/ui-adapter-web-component adapts Univer UI services for Web Component integrations.

Package Overview

Package UMD global CSS Locales Facade entry Worker entry
@univerjs/ui-adapter-web-component UniverUiAdapterWebComponent No No No No

Installation

pnpm add @univerjs/ui-adapter-web-component
# or
npm install @univerjs/ui-adapter-web-component

Usage

Start with the integration setup for your document type, including its required plugins, styles, and locale resources. The snippet below assumes that setup is complete.

import { UniverWebComponentAdapterPlugin } from '@univerjs/ui-adapter-web-component';

univer.registerPlugin(UniverWebComponentAdapterPlugin);

Register custom elements with the web-component framework option. Runtime props are assigned to the created element as DOM properties, which supports object values such as data and extraProps.

class MyPopup extends HTMLElement {
    set data(value: { label?: string } | undefined) {
        this.textContent = value?.label ?? '';
    }
}

univerAPI.registerComponent('my-popup', MyPopup, { framework: 'web-component' });

Resources