editor.js/types/api/caret.d.ts
Peter Savchenko 23858e0025
fix(conversion): restore caret after conversion though the Inline Toolbar and API (#2699)
* fix caret loosing after caret

* Refactor convert method to return Promise in Blocks API

* changelog upd

* Fix missing semicolon in blocks.cy.ts and BlockTunes.cy.ts

* add test for inline toolbar conversion

* Fix missing semicolon in InlineToolbar.cy.ts

* add test for toolbox shortcut

* api caret.setToBlock now can accept block api or index or id

* eslint fix

* Refactor test descriptions in caret.cy.ts

* rm tsconfig change

* lint

* lint

* Update CHANGELOG.md
2024-04-29 22:24:31 +03:00

68 lines
1.7 KiB
TypeScript

import { BlockAPI } from "./block";
/**
* Describes Editor`s caret API
*/
export interface Caret {
/**
* Sets caret to the first Block
*
* @param {string} position - position where to set caret
* @param {number} offset - caret offset
*
* @return {boolean}
*/
setToFirstBlock(position?: 'end'|'start'|'default', offset?: number): boolean;
/**
* Sets caret to the last Block
*
* @param {string} position - position where to set caret
* @param {number} offset - caret offset
*
* @return {boolean}
*/
setToLastBlock(position?: 'end'|'start'|'default', offset?: number): boolean;
/**
* Sets caret to the previous Block
*
* @param {string} position - position where to set caret
* @param {number} offset - caret offset
*
* @return {boolean}
*/
setToPreviousBlock(position?: 'end'|'start'|'default', offset?: number): boolean;
/**
* Sets caret to the next Block
*
* @param {string} position - position where to set caret
* @param {number} offset - caret offset
*
* @return {boolean}
*/
setToNextBlock(position?: 'end'|'start'|'default', offset?: number): boolean;
/**
* Sets caret to the Block by passed index
*
* @param blockOrIdOrIndex - BlockAPI or Block id or Block index
* @param position - position where to set caret
* @param offset - caret offset
*
* @return {boolean}
*/
setToBlock(blockOrIdOrIndex: BlockAPI | BlockAPI['id'] | number, position?: 'end'|'start'|'default', offset?: number): boolean;
/**
* Sets caret to the Editor
*
* @param {boolean} atEnd - if true, set Caret to the end of the Editor
*
* @return {boolean}
*/
focus(atEnd?: boolean): boolean;
}