UNPKG

@yoopta/editor

Version:

<h2 align="center">Yoopta-Editor v1 🎉</h2> <p align="center">Yoopta-Editor - is an open source notion-like editor 💥</p> <div align="center"> <img width="574" alt="Screen Shot 2023-01-25 at 16 04 29" src="https://user-images.githubusercontent.com/2909311

79 lines • 2.11 kB
import type { YooEditor } from '../types'; import type { DeleteElementOptions } from './types'; /** * Delete element from a block * * @param editor - YooEditor instance * @param options - Delete options * * @example Delete block element by path * ```typescript * editor.deleteElement({ * blockId: 'accordion-1', * type: 'accordion-list-item', * path: [0, 1] * }); * ``` * * @example Delete block element by type * ```typescript * // Deletes first accordion-list-item found in selection * editor.deleteElement({ * blockId: 'accordion-1', * type: 'accordion-list-item' * }); * ``` * * @example Delete inline element (remove link wrapper, keep text) * ```typescript * // Before: "Hello <link>world</link>!" * editor.deleteElement({ * blockId: 'paragraph-1', * type: 'link', * mode: 'unwrap' // Keep "world", remove link * }); * // After: "Hello world!" * ``` * * @example Delete inline element (remove entirely) * ```typescript * // Before: "Hello <mention>@John</mention>!" * editor.deleteElement({ * blockId: 'paragraph-1', * type: 'mention', * mode: 'remove' // Remove mention entirely * }); * // After: "Hello !" * ``` * * @example Delete with custom matcher * ```typescript * editor.deleteElement({ * blockId: 'accordion-1', * type: 'accordion-list-item', * match: (element) => element.props?.id === 'item-5' * }); * ``` * * @example Delete link at current selection * ```typescript * // User has cursor inside link, wants to remove link * editor.deleteElement({ * blockId: 'paragraph-1', * type: 'link', * mode: 'unwrap' * }); * ``` * * @example Delete all links in selection with matcher * ```typescript * editor.deleteElement({ * blockId: 'paragraph-1', * type: 'link', * match: (element) => element.props?.url.includes('old-domain.com'), * mode: 'unwrap' * }); * ``` */ export declare function deleteElement(editor: YooEditor, options: DeleteElementOptions): void; //# sourceMappingURL=deleteElement.d.ts.map