FDocumentCallout
Facade object for a single docs callout block.
Access
Access through:
FDocument.getCallouts()FDocument.getCallout()FDocument.getCalloutAt()FDocument.findCalloutByText()FDocument.findCallouts()FDocument.insertCallout()
Example
const fDocument = univerAPI.getActiveDocument()const callouts = fDocument.getCallouts()console.log(callouts)const callout = fDocument.findCalloutByText('Important')console.log(callout?.getText())if (callout) { console.log(callout.getStyle()) callout.setBackgroundColor('#FFF4E5') callout.setBorder({ color: '#E6A23C', width: 2 }) callout.setTextColor('#5C3B00') console.log(callout.describe())}Setup
Register @univerjs-pro/docs-callout or a preset that includes it. In plugin mode, import @univerjs-pro/docs-callout/facade. Additional methods below require their listed plugin packages. See Facade setup.
@univerjs-pro/docs-callout
FDocumentCallout.describe
Returns an agent-friendly description of the callout.
describe(): IDocsCalloutInfo | nullReturns
The callout id, range, text, config, and compact style, or null if it no longer exists.
Examples
const fDocument = univerAPI.getActiveDocument()const callout = fDocument.findCalloutByText('Important')if (callout) { console.log(callout.describe())}Types: IDocsCalloutInfo
Package: @univerjs-pro/docs-callout · Type definitions
FDocumentCallout.getConfig
Returns the normalized callout visual config.
getConfig(): IDocsCalloutConfigReturns
The callout config, falling back to default config when metadata is missing.
Examples
const fDocument = univerAPI.getActiveDocument()const callout = fDocument.findCalloutByText('Important')if (callout) { console.log(callout.getConfig())}Types: IDocsCalloutConfig
Package: @univerjs-pro/docs-callout · Type definitions
FDocumentCallout.getId
Returns the callout block id.
getId(): stringReturns
The callout block range id.
Examples
const fDocument = univerAPI.getActiveDocument()const callouts = fDocument.getCallouts()// Get the id of the first callout.if (callouts.length > 0) { const callout = callouts[0] console.log(callout.getId())}Package: @univerjs-pro/docs-callout · Type definitions
FDocumentCallout.getRange
Returns the callout block range in the document data stream.
getRange(): IDocsCalloutRange | nullReturns
The callout range, or null if it no longer exists.
Examples
const fDocument = univerAPI.getActiveDocument()const callouts = fDocument.getCallouts()// Get the range of the first callout.if (callouts.length > 0) { const callout = callouts[0] console.log(callout.getRange())}Types: IDocsCalloutRange
Package: @univerjs-pro/docs-callout · Type definitions
FDocumentCallout.getStyle
Returns the Callout colors and border as one compact, serializable object.
This is preferable to getConfig() for agents that only need appearance and should not modify layout metadata.
getStyle(): IDocsCalloutStyleReturns
The current background, border, and first effective text color.
Examples
const fDocument = univerAPI.getActiveDocument()const callout = fDocument?.findCalloutByText('Important')if (!callout) { throw new Error('Callout not found')}const style = callout.getStyle()console.log(JSON.stringify(style, null, 2))Types: IDocsCalloutStyle
Package: @univerjs-pro/docs-callout · Type definitions
FDocumentCallout.getText
Returns plain text inside the callout.
getText(): stringReturns
The callout text with block tokens removed.
Examples
const fDocument = univerAPI.getActiveDocument()const callout = fDocument.findCalloutByText('Important')if (callout) { console.log(callout.getText())}Package: @univerjs-pro/docs-callout · Type definitions
FDocumentCallout.remove
Removes this callout block and its content.
remove(): booleanReturns
Whether the callout block was removed.
Examples
const fDocument = univerAPI.getActiveDocument()const callout = fDocument.findCalloutByText('Important')if (callout) { const success = callout.remove() console.log(success)}Package: @univerjs-pro/docs-callout · Type definitions
FDocumentCallout.resetTextColor
Restores the inherited document text color for all text in this Callout.
resetTextColor(): booleanReturns
Whether the text style command succeeded.
Examples
const callout = univerAPI.getActiveDocument()?.findCalloutByText('Important')const reset = callout?.resetTextColor() ?? falseconsole.log({ reset })Package: @univerjs-pro/docs-callout · Type definitions
FDocumentCallout.setBackgroundColor
Sets only the Callout background color through the command pipeline.
setBackgroundColor(backgroundColor: string): booleanParameters
backgroundColor— Required. A CSS color value supported by Univer, such as#FFF4E5.
Returns
Whether the update command succeeded.
Examples
const callout = univerAPI.getActiveDocument()?.findCalloutByText('Important')const updated = callout?.setBackgroundColor('#FFF4E5') ?? falseconsole.log({ updated })Package: @univerjs-pro/docs-callout · Type definitions
FDocumentCallout.setBorder
Updates one or more border properties as a single undoable Callout config command. Omitted properties retain their current values.
setBorder(border: Partial<IDocsCalloutBorderStyle>): booleanParameters
border— Required. Border color, line style, or width.
Returns
Whether the update command succeeded.
Examples
import { DashStyleType } from '@univerjs/core'const callout = univerAPI.getActiveDocument()?.findCalloutByText('Important')if (!callout) { throw new Error('Callout not found')}const updated = callout.setBorder({ color: '#E6A23C', opacity: 0.75, style: DashStyleType.DASH, width: 2,})console.log({ updated, style: callout.getStyle() })Types: Partial · IDocsCalloutBorderStyle
Package: @univerjs-pro/docs-callout · Type definitions
FDocumentCallout.setIcon
Updates only the callout icon.
setIcon(icon: string): booleanParameters
icon— Required. The emoji or text icon to display.
Returns
Whether the update command succeeded.
Examples
const fDocument = univerAPI.getActiveDocument()const callout = fDocument.findCalloutByText('Important')if (callout) { const success = callout.setIcon('💡') console.log(success)}Package: @univerjs-pro/docs-callout · Type definitions
FDocumentCallout.setIconVisible
Shows or hides the callout icon without changing document paragraph layout.
setIconVisible(showIcon: boolean): booleanParameters
showIcon— Required.
Package: @univerjs-pro/docs-callout · Type definitions
FDocumentCallout.setTextColor
Applies one text color to all text in this Callout through the document command pipeline.
setTextColor(value: string): booleanParameters
value— Required. A CSS color value supported by Univer.
Returns
Whether the text style command succeeded.
Examples
const callout = univerAPI.getActiveDocument()?.findCalloutByText('Important')const updated = callout?.setTextColor('#5C3B00') ?? falseconsole.log({ updated })Package: @univerjs-pro/docs-callout · Type definitions
FDocumentCallout.unwrap
Unwraps this callout by removing only the callout block formatting.
unwrap(): booleanReturns
Whether the callout block formatting was removed.
Examples
const fDocument = univerAPI.getActiveDocument()const callout = fDocument.findCalloutByText('Important')if (callout) { const success = callout.unwrap() console.log(success)}Package: @univerjs-pro/docs-callout · Type definitions
FDocumentCallout.updateConfig
Updates the callout layout and icon config.
updateConfig(config: Partial<IDocsCalloutConfig>): booleanParameters
config— Required. Partial config, such as icon or border radius.
Returns
Whether the update command succeeded.
Examples
const fDocument = univerAPI.getActiveDocument()const callout = fDocument.findCalloutByText('Important')if (callout) { const success = callout.updateConfig({ borderRadius: 12 }) console.log(success)}Types: Partial · IDocsCalloutConfig
Package: @univerjs-pro/docs-callout · Type definitions
你觉得这篇文档如何?