editor.js/types/api/blocks.d.ts
Peter Savchenko 63eeec0f3b
Release / 2.18 (#1181)
Co-authored-by: George Berezhnoy <gohabereg@users.noreply.github.com>
Co-authored-by: Georgy Berezhnoy <gohabereg@gmail.com>
Co-authored-by: tasuku-s <tasuku@freemind.co.jp>
Co-authored-by: Athul Anil Kumar <athul7744@outlook.com>
Co-authored-by: Taly <vitalik7tv@yandex.ru>
Co-authored-by: flaming-cl <51183663+flaming-cl@users.noreply.github.com>
Co-authored-by: Nguyen Ngoc Son <sonnn.se@gmail.com>
Co-authored-by: Sisir Das K <37764463+sis-dk@users.noreply.github.com>
Co-authored-by: Sisir <sisir@hellosivi.com>
2020-06-03 11:17:29 +03:00

102 lines
2.3 KiB
TypeScript

import {OutputData} from '../data-formats/output-data';
import {BlockToolData, ToolConfig} from '../tools';
import {BlockAPI} from './block';
/**
* Describes methods to manipulate with Editor`s blocks
*/
export interface Blocks {
/**
* Remove all blocks from Editor zone
*/
clear(): void;
/**
* Render passed data
* @param {OutputData} data
* @return {Promise<void>}
*/
render(data: OutputData): Promise<void>;
/**
* Render passed HTML string
* @param {string} data
* @return {Promise<void>}
*/
renderFromHTML(data: string): Promise<void>;
/**
* Removes current Block
* @param {number} index - index of a block to delete
*/
delete(index?: number): void;
/**
* Swaps two Blocks
* @param {number} fromIndex - block to swap
* @param {number} toIndex - block to swap with
* @deprecated — use 'move' instead
*/
swap(fromIndex: number, toIndex: number): void;
/**
* Moves a block to a new index
* @param {number} toIndex - index where the block is moved to
* @param {number} fromIndex - block to move
*/
move(toIndex: number, fromIndex?: number): void;
/**
* Returns Block holder by Block index
* @param {number} index
* @returns {HTMLElement}
*/
getBlockByIndex(index: number): BlockAPI;
/**
* Returns current Block index
* @returns {number}
*/
getCurrentBlockIndex(): number;
/**
* Mark Block as stretched
* @param {number} index - Block to mark
* @param {boolean} status - stretch status
*
* @deprecated Use BlockAPI interface to stretch Blocks
*/
stretchBlock(index: number, status?: boolean): void;
/**
* Returns Blocks count
* @return {number}
*/
getBlocksCount(): number;
/**
* Insert new Initial Block after current Block
*
* @deprecated
*/
insertNewBlock(): void;
/**
* Insert new Block
*
* @param {string} type — Tool name
* @param {BlockToolData} data — Tool data to insert
* @param {ToolConfig} config — Tool config
* @param {number?} index — index where to insert new Block
* @param {boolean?} needToFocus - flag to focus inserted Block
*/
insert(
type?: string,
data?: BlockToolData,
config?: ToolConfig,
index?: number,
needToFocus?: boolean,
): void;
}