Quote Block
You can insert and format quoted text in a document with a quote block, which carries its own styling so that a quotation reads differently from the content around it.
Introduction
In Univer Docs, a quote block provides the following:
- A distinct style for quoted text.
- Rich content nested inside the block.
- A quick exit from quote formatting when you are on an empty paragraph.
Plugin mode
Installation
Shell
pnpm add @univerjs-pro/docs-quote @univerjs-pro/docs-quote-uiShell
npm install @univerjs-pro/docs-quote @univerjs-pro/docs-quote-uiShell
yarn add @univerjs-pro/docs-quote @univerjs-pro/docs-quote-uiShell
bun add @univerjs-pro/docs-quote @univerjs-pro/docs-quote-uiUsage
TypeScript
import { UniverDocsQuotePlugin } from '@univerjs-pro/docs-quote'import { UniverDocsQuoteUIPlugin } from '@univerjs-pro/docs-quote-ui'import DocsQuoteUIEnUS from '@univerjs-pro/docs-quote-ui/locale/en-US'import { LocaleType, mergeLocales, Univer } from '@univerjs/core'import '@univerjs-pro/docs-quote-ui/lib/index.css'const univer = new Univer({ locale: LocaleType.EN_US, locales: { [LocaleType.EN_US]: mergeLocales( DocsQuoteUIEnUS, ), },})univer.registerPlugin(UniverDocsQuotePlugin)univer.registerPlugin(UniverDocsQuoteUIPlugin)If you use a commercial license, configure it as described in Using License in Client.
Mobile support
Configure the mobile editor first. In the plugin-mode setup described on this page, replace the desktop registration below with the mobile export from the same package, and do so before opening a document. Keep the model plugins, styles, locales, and Facade imports, and do not register both variants.
| Package | Desktop registration | Mobile registration |
|---|---|---|
@univerjs-pro/docs-quote-ui | UniverDocsQuoteUIPlugin | UniverDocsQuoteMobileUIPlugin |
Facade API
Import the facade before using any of the following APIs:
TypeScript
import '@univerjs-pro/docs-quote/facade'Get all quote blocks
TypeScript
const doc = univerAPI.getActiveDocument()const quotes = doc?.getQuotes() ?? []Insert a quote block
TypeScript
const doc = univerAPI.getActiveDocument()const quote = doc?.insertQuote({ startOffset: 12, endOffset: 35,})Set the quote line color
TypeScript
const quote = univerAPI.getActiveDocument()?.getQuote('quote-block-id')quote?.setLineColor('#5B5FC7')Set the quote text color
TypeScript
const quote = univerAPI.getActiveDocument()?.getQuote('quote-block-id')quote?.setTextColor('#242424')How is this guide?