Skip to content

Bridge Module

The Bridge module mainly involves the API at the plugin application level, such as (accessing persistent data/getting current multidimensional table theme information, etc.), The way to obtain it is:

typescript
const bridge = bitable.bridge;
const bridge = bitable.bridge;

onThemeChange

typescript
onThemeChange(callback: (ev: IEventCbCtx<ThemeModeCtx>) => void): () => void;
onThemeChange(callback: (ev: IEventCbCtx<ThemeModeCtx>) => void): () => void;

Listen for theme changes

getPersonalBaseToken

typescript
getPersonalBaseToken: () => Promise<string>;
getPersonalBaseToken: () => Promise<string>;

Get PersonalBaseToken

getData

typescript
getData(): Promise<unknown>;
getData(): Promise<unknown>;

Read persistent data

setData

typescript
setData(data: Record<string, unknown>): Promise<void>;
setData(data: Record<string, unknown>): Promise<void>;

Write persistent data, it needs to be written in the form of an object key:value

getBitableUrl

typescript
getBitableUrl(options: GetBitableUrlOptions): Promise<string>;
getBitableUrl(options: GetBitableUrlOptions): Promise<string>;

Generate a multidimensional table link, where the type parameter of GetBitableUrlOptions is defined as:

typescript
type GetBitableUrlOptions = {
  tableId: string,
  viewId: string,
  // Open the table when recordId is empty, open the card when it is not empty
  recordId?: string,
  fieldId?: string,
}
type GetBitableUrlOptions = {
  tableId: string,
  viewId: string,
  // Open the table when recordId is empty, open the card when it is not empty
  recordId?: string,
  fieldId?: string,
}

getUserId

typescript
getUserId(): Promise<string>;
getUserId(): Promise<string>;

Get the current user ID

getTheme

typescript
getTheme(): Promise<ThemeModeType>;
getTheme(): Promise<ThemeModeType>;

Get the current theme, where the ThemeModeType type is defined as follows:

typescript
declare enum ThemeModeType {
  LIGHT = "LIGHT",
  DARK = "DARK"
}
declare enum ThemeModeType {
  LIGHT = "LIGHT",
  DARK = "DARK"
}

getLocale

typescript
getLocale(): Promise<Locale>;
getLocale(): Promise<Locale>;

Get the Locale information, where the Locale type is defined as follows:

typescript
type Locale = 'zh-CN' | 'zh-TW' | 'zh-HK' | 'en-US' | 'ja-JP' | 'fr-FR' | 'hi-IN' | 'id-ID' | 'it-IT' | 'ko-KR' | 'pt-BR' | 'ru-RU' | 'th-TH' | 'vi-VN' | 'de-DE' | 'es-ES';
type Locale = 'zh-CN' | 'zh-TW' | 'zh-HK' | 'en-US' | 'ja-JP' | 'fr-FR' | 'hi-IN' | 'id-ID' | 'it-IT' | 'ko-KR' | 'pt-BR' | 'ru-RU' | 'th-TH' | 'vi-VN' | 'de-DE' | 'es-ES';

getLanguage

typescript
getLanguage(): Promise<Language>;
getLanguage(): Promise<Language>;

Get the current language information, where the Language type is defined as follows:

typescript
type Language = 'zh' | 'zh-TW' | 'zh-HK' | 'en' | 'ja' | 'fr' | 'hi' | 'id' | 'it' | 'ko' | 'pt' | 'ru' | 'th' | 'vi' | 'de' | 'es';
type Language = 'zh' | 'zh-TW' | 'zh-HK' | 'en' | 'ja' | 'fr' | 'hi' | 'id' | 'it' | 'ko' | 'pt' | 'ru' | 'th' | 'vi' | 'de' | 'es';

getTenantKey

typescript
getTenantKey(): Promise<string>;
getTenantKey(): Promise<string>;

Get the Id of the current tenant

getEnv

typescript
getEnv(): Promise<Env>;
getEnv(): Promise<Env>;

Get the current environment information, where the Env type is defined as follows:

typescript
type Product = 'lark' | 'feishu';
interface Env {
  product: Product;
}
type Product = 'lark' | 'feishu';
interface Env {
  product: Product;
}

getInstanceId

typescript
getInstanceId(): Promise<string>;
getInstanceId(): Promise<string>;

Get the current plugin instance Id