@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
56 lines • 1.92 kB
TypeScript
import type { SlateElement, YooEditor, YooptaPathIndex } from '../types';
export type ToggleBlockOptions = {
/**
* Position of the block to toggle
* @default editor.path.current
*/
at?: YooptaPathIndex;
/**
* Scope of the toggle operation:
* - 'auto': automatically determine from context (default)
* - 'block': transform the entire block (Paragraph → Heading)
* - 'element': insert element in current leaf with injectElementsFromPlugins
*
* @default 'auto'
*/
scope?: 'auto' | 'block' | 'element';
/**
* Whether to preserve existing content
* - true: keep text and transfer to new block/element
* - false: start with empty content
* @default true
*/
preserveContent?: boolean;
/**
* Focus after toggle
* @default false
*/
focus?: boolean;
/**
* Custom element structure created with editor.y()
* If provided, this will be used instead of default structure
*/
elements?: SlateElement;
};
/**
* Toggle block type or insert element in leaf with injectElementsFromPlugins
*
* Behavior depends on scope:
* - scope: 'block' → transforms the block (Paragraph → Heading)
* - scope: 'element' → inserts element in current leaf with injectElementsFromPlugins
* - scope: 'auto' → automatically determines based on context
*
* @example
* // Transform block
* editor.toggleBlock('Heading', { preserveContent: true });
*
* // Insert element in leaf
* editor.toggleBlock('Paragraph', { scope: 'element', preserveContent: false });
*
* // With custom structure
* editor.toggleBlock('Accordion', {
* elements: editor.y('accordion-list', { ... })
* });
*/
export declare function toggleBlock(editor: YooEditor, type: string, options?: ToggleBlockOptions): string;
//# sourceMappingURL=toggleBlock.d.ts.map