Skip to content

Plugin API

Topher Anselmo edited this page Oct 16, 2023 · 8 revisions

tmcp.addItem(itemOptions)

Adds a static search result to TMCP. The interface for the itemOptions object is as follows:

{
  // What shows up in the search results
  text: string;

  // What happens when the user hits enter on this result
  action?: () => any;

  // When true, will prevent the window from hiding while
  // the user is viewing this item's display
  keepOpen?: boolean;

  // Absolute path to an icon to display next to the item
  // (If omitted, the plugin icon will be used)
  icon?: string;

  // When provided, will show addditional information in
  // a panel on the right side of the window
  display?: {
    type: 'markdown' | 'html';
    content: string;
  };
}

tmcp.addSetting(settingOptions)

Adds an item to the settings section for this plugin. Can be used to add user toggleable settings to your plugin. The interface for the settingsOptions object is as follows:

{
  // The label that appears above this setting
  text: string;

  // Optional small text that appears below the setting
  help?: string;

  // The type of setting to use
  // 'boolean' - Renders a checkbox, and has a boolean value
  // 'select' - Renders a select drop down box, and has a string value
  // 'number' - Renders a number input, and has an integer value
  // 'string' - Renders a text input, and has a string value
  type: 'boolean' | 'select' | 'number' | 'string';

  // The default value for this setting (depending on the type)
  value: any;

  // When the type is `select`, these are the options that will show
  // in the drop down. The default value should be one of these.
  options?: string[];

  // When the type is `number`, these are the minimum and maximum values
  min?: number;
  max?: number;
}

Clone this wiki locally