FDocumentQuote
Facade object for a single docs quote block.
Access
Access through:
FDocument.getQuotes()FDocument.getQuote()FDocument.getQuoteAt()FDocument.findQuoteByText()FDocument.findQuotes()FDocument.insertQuote()
Example
const fDocument = univerAPI.getActiveDocument()const quotes = fDocument.getQuotes()console.log(quotes)const quote = fDocument.findQuoteByText('Decision')console.log(quote?.getText())if (quote) { console.log(quote.getStyle()) quote.setStyle({ lineColor: '#5B5FC7', textColor: '#242424' }) console.log(quote.describe())}Setup
Register @univerjs-pro/docs-quote or a preset that includes it. In plugin mode, import @univerjs-pro/docs-quote/facade. Additional methods below require their listed plugin packages. See Facade setup.
@univerjs-pro/docs-quote
FDocumentQuote.describe
Returns an agent-friendly description of the quote.
describe(): IDocsQuoteInfo | nullReturns
The quote id, range, text, and style, or null if it no longer exists.
Examples
const fDocument = univerAPI.getActiveDocument()const quote = fDocument.findQuoteByText('Decision')if (quote) { console.log(quote.describe())}Types: IDocsQuoteInfo
Package: @univerjs-pro/docs-quote · Type definitions
FDocumentQuote.getId
Returns the quote block id.
getId(): stringReturns
The quote block range id.
Examples
const fDocument = univerAPI.getActiveDocument(); const quotes = fDocument.getQuotes();
// Get the id of the first quote. if (quotes.length > 0) { const quote = quotes[0]; console.log(quote.getId()); }
**Package:** [`@univerjs-pro/docs-quote`](/reference/packages/plugins/univerjs-pro/docs-quote) · [Type definitions](https://unpkg.com/@univerjs-pro/docs-quote@1.0.0-rc.0/lib/types/facade/f-document-quote.d.ts)### `FDocumentQuote.getRange` [#getrange]Returns the quote block range in the document data stream.```typescriptgetRange(): IDocsQuoteRange | nullReturns
The quote range, or null if it no longer exists.
Examples
const fDocument = univerAPI.getActiveDocument()const quotes = fDocument.getQuotes()// Get the range of the first quote.if (quotes.length > 0) { const quote = quotes[0] console.log(quote.getRange())}Types: IDocsQuoteRange
Package: @univerjs-pro/docs-quote · Type definitions
FDocumentQuote.getStyle
Returns both user-editable Quote colors as one serializable object.
getStyle(): IDocsQuoteStyleReturns
The current left-line color and first effective text color.
Examples
const quote = univerAPI.getActiveDocument()?.findQuoteByText('Decision')if (!quote) { throw new Error('Quote not found')}console.log(JSON.stringify(quote.getStyle(), null, 2))Types: IDocsQuoteStyle
Package: @univerjs-pro/docs-quote · Type definitions
FDocumentQuote.getText
Returns plain text inside the quote.
getText(): stringReturns
The quote text with block tokens removed.
Examples
const fDocument = univerAPI.getActiveDocument()const quote = fDocument.findQuoteByText('Decision')if (quote) { console.log(quote.getText())}Package: @univerjs-pro/docs-quote · Type definitions
FDocumentQuote.remove
Removes this quote block and its content.
remove(): booleanReturns
Whether the quote block was removed.
Examples
const fDocument = univerAPI.getActiveDocument()const quote = fDocument.findQuoteByText('Decision')if (quote) { const success = quote.remove() console.log(success)}Package: @univerjs-pro/docs-quote · Type definitions
FDocumentQuote.setLineColor
Sets the color of the Quote's left rule through the Quote style command.
setLineColor(lineColor: string): booleanParameters
lineColor— Required.
Package: @univerjs-pro/docs-quote · Type definitions
FDocumentQuote.setStyle
Updates one or both Quote colors as one command and one undo history entry. Omitted colors retain their current values.
setStyle(style: Partial<IDocsQuoteStyle>): booleanParameters
style— Required. The left-line color, text color, or both.
Returns
Whether the style command succeeded.
Examples
const quote = univerAPI.getActiveDocument()?.findQuoteByText('Decision')if (!quote) { throw new Error('Quote not found')}const updated = quote.setStyle({ lineColor: '#5B5FC7', textColor: '#242424',})console.log({ updated, style: quote.getStyle() })Types: Partial · IDocsQuoteStyle
Package: @univerjs-pro/docs-quote · Type definitions
FDocumentQuote.setTextColor
Applies one text color to all text in this Quote through the Quote style command.
setTextColor(textColor: string): booleanParameters
textColor— Required.
Package: @univerjs-pro/docs-quote · Type definitions
FDocumentQuote.unwrap
Unwraps this quote by removing only the quote block formatting.
unwrap(): booleanReturns
Whether the quote block formatting was removed.
Examples
const fDocument = univerAPI.getActiveDocument()const quote = fDocument.findQuoteByText('Decision')if (quote) { const success = quote.unwrap() console.log(success)}Package: @univerjs-pro/docs-quote · Type definitions
你觉得这篇文档如何?