FUniverSheetsUIMixin

GitHubEdit on GitHub
packages@univerjs/sheets-ui

APIs

customizeColumnHeader

Deprecated use same API in FWorkbook and FWorkSheet.

Signature

customizeColumnHeader(cfg: IColumnsHeaderCfgParam): void

customizeRowHeader

Deprecated use same API in FWorkbook and FWorkSheet.

Signature

customizeRowHeader(cfg: IRowsHeaderCfgParam): void

getProtectedRangeShadowStrategy

Get the current global strategy for showing the protected range shadow.

Signature

getProtectedRangeShadowStrategy(): 'always' | 'non-editable' | 'non-viewable' | 'none'

Returns

  • ('always' | 'non-editable' | 'non-viewable' | 'none') — The current shadow strategy

Examples

const currentStrategy = univerAPI.getProtectedRangeShadowStrategy()
console.log(currentStrategy) // 'none', 'always', 'non-editable', or 'non-viewable'

getProtectedRangeShadowStrategy$

Get an observable of the global strategy for showing the protected range shadow. This allows you to listen for strategy changes across all workbooks.

Signature

getProtectedRangeShadowStrategy$(): Observable<'always' | 'non-editable' | 'non-viewable' | 'none'>

Returns

  • (Observable<'always' | 'non-editable' | 'non-viewable' | 'none'>) — An observable that emits the current shadow strategy

Examples

const subscription = univerAPI.getProtectedRangeShadowStrategy$().subscribe((strategy) => {
  console.log('Global strategy changed to:', strategy)
  // Update UI or perform other actions
})

// Later, unsubscribe to clean up
subscription.unsubscribe()

getSheetHooks

Get sheet hooks.

Deprecated use univerAPI.addEvent as instead.

Signature

getSheetHooks(): FSheetHooks

Returns

  • (FSheetHooks) — FSheetHooks instance

pasteIntoSheet

Paste clipboard data or custom data into the active sheet at the current selection position.

Signature

pasteIntoSheet(htmlContent?: string, textContent?: string, files?: File[]): Promise<boolean>

Parameters

  • htmlContent (string) — - The HTML content from the clipboard or custom data.
  • textContent (string) — - The plain text content from the clipboard or custom data.
  • files (File[]) — - The files from the clipboard or custom data.

Returns

  • (Promise<boolean>) — A promise that resolves to true if the paste operation was successful, otherwise false.

Examples

// Listen for the paste event and call the pasteIntoSheet method
document.addEventListener('paste', async (event) => {
  const htmlContent = event.clipboardData.getData('text/html')
  const textContent = event.clipboardData.getData('text/plain')
  const files = Array.from(event.clipboardData.items)
    .map(item => item.kind === 'file' ? item.getAsFile() : undefined)
    .filter(Boolean)
  await univerAPI.pasteIntoSheet(htmlContent, textContent, files)
})

// Or paste custom data
univerAPI.pasteIntoSheet('<b>Bold Text</b>', 'Bold Text')

registerSheetColumnHeaderExtension

Register sheet column header render extensions.

Signature

registerSheetColumnHeaderExtension(unitId: string, extensions?: SheetExtension[]): IDisposable

Parameters

  • unitId (string) — The unit id of the spreadsheet.
  • extensions (SheetExtension[]) — The extensions to register.

Returns

  • (IDisposable) — The disposable instance.

registerSheetMainExtension

Register sheet main render extensions.

Signature

registerSheetMainExtension(unitId: string, extensions?: SheetExtension[]): IDisposable

Parameters

  • unitId (string) — The unit id of the spreadsheet.
  • extensions (SheetExtension[]) — The extensions to register.

Returns

  • (IDisposable) — The disposable instance.

registerSheetRowHeaderExtension

Register sheet row header render extensions.

Signature

registerSheetRowHeaderExtension(unitId: string, extensions?: SheetExtension[]): IDisposable

Parameters

  • unitId (string) — The unit id of the spreadsheet.
  • extensions (SheetExtension[]) — The extensions to register.

Returns

  • (IDisposable) — The disposable instance.

setPermissionDialogVisible

Set visibility of unauthorized pop-up window

Signature

setPermissionDialogVisible(visible: boolean): void

Parameters

  • visible (boolean) — - visibility of unauthorized pop-up window

Examples

const univerAPI = FUniver.newAPI(univer)
univerAPI.setPermissionDialogVisible(false)

setProtectedRangeShadowStrategy

Set the global strategy for showing the protected range shadow. This will apply to all workbooks in the current Univer instance.

Signature

setProtectedRangeShadowStrategy(strategy: 'always' | 'non-editable' | 'non-viewable' | 'none'): void

Parameters

  • strategy ('always' | 'non-editable' | 'non-viewable' | 'none') — - The shadow strategy to apply - 'always': Show shadow for all protected ranges - 'non-editable': Only show shadow for ranges that cannot be edited - 'non-viewable': Only show shadow for ranges that cannot be viewed - 'none': Never show shadow for protected ranges

Examples

// Always show shadows (default)
univerAPI.setProtectedRangeShadowStrategy('always')

// Only show shadows for non-editable ranges
univerAPI.setProtectedRangeShadowStrategy('non-editable')

// Only show shadows for non-viewable ranges
univerAPI.setProtectedRangeShadowStrategy('non-viewable')

// Never show shadows
univerAPI.setProtectedRangeShadowStrategy('none')