UNPKG

notion-helper

Version:

A library of functions for working more easily with the Notion API

64 lines 3.12 kB
/** * Builds a Rich Text Object. See: https://developers.notion.com/reference/rich-text * @param {(string|Object)} input - The text content or input object. If string, the input can be normal text or an equation. If object, it can be a text, equation, or mention object. * @param {Object} [options] - Options for configuring the rich text object * @param {Object} [options.annotations] - Options for the Annotation object * @param {boolean} [options.annotations.bold] - Bold text * @param {boolean} [options.annotations.italic] - Italic text * @param {boolean} [options.annotations.strikethrough] - Strikethrough text * @param {boolean} [options.annotations.underline] - Underlined text * @param {boolean} [options.annotations.code] - Code-style text * @param {string} [options.annotations.color] - String specifying the text's color or background color. Options: "blue", "brown", "default", "gray", "green", "orange", "pink", "purple", "red", "yellow". All except "default" can also be used as a background color with "[color]_background" - example: "blue_background". See: https://developers.notion.com/reference/rich-text#the-annotation-object * @param {string} [options.url] - The URL for this object, if any. Creates a clickable link. * @param {string} [options.type="text"] - An optional type for the Rich Text Object. Supports text, equation, and mention. * @returns {Array<Object>} - Array with a single Rich Text Object * * @example * // Simple text * buildRichTextObj("Hello World") * * // Text with URL * buildRichTextObj("Watch this very important video", { url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ" }) * * // Text with annotations * buildRichTextObj("Bold and brown", { * annotations: { bold: true, color: "brown" } * }) * * // Text with URL and annotations * buildRichTextObj("Bold blue link", { * url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", * annotations: { bold: true, color: "blue" } * }) * * // Equation * buildRichTextObj("E = mc^2", { type: "equation" }) * * // Mention * buildRichTextObj({ type: "user", user: { id: "user_id" } }, { type: "mention" }) */ export function buildRichTextObj(input: (string | Object), options?: { annotations?: { bold?: boolean | undefined; italic?: boolean | undefined; strikethrough?: boolean | undefined; underline?: boolean | undefined; code?: boolean | undefined; color?: string | undefined; } | undefined; url?: string | undefined; type?: string | undefined; }, ...args: any[]): Array<Object>; /** * Enforces Rich Text format for content. * @param {string|Object|Array} content - The content to be enforced as Rich Text. * @returns {Array} An array of Rich Text Objects. */ export function enforceRichText(content: string | Object | any[]): any[]; /** * Enforces a single Rich Text Object format. * @param {string|Object} obj - The object to be enforced as a Rich Text Object. * @returns {Object} A Rich Text Object. */ export function enforceRichTextObject(obj: string | Object): Object; //# sourceMappingURL=rich-text.d.mts.map