From 0b0fa35f8d229ac7e27d0c5dade9cc8d7cd231b9 Mon Sep 17 00:00:00 2001 From: George Berezhnoy Date: Wed, 12 Jun 2019 20:36:41 +0300 Subject: [PATCH] Add API shorthands types (#800) --- docs/CHANGELOG.md | 9 +++++---- types/index.d.ts | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 8ad2a6cf..dfcd183c 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -3,10 +3,11 @@ ### 2.14 -- `Fix` *Config* — User config now has higher priority than internal settings -- `New` — Ability to work with Block Actions and Inline Toolbar from the keyboard by Tab. -- `Fix` — Fix error thrown by click on the empty editor after `blocks.clear()` method calling -- `Fix` — Fix placeholder property appearance. Now you can assign it via `placeholder` property of EditorConfig. +- `Fix` *Config* — User config now has higher priority than internal settings [#771](https://github.com/codex-team/editor.js/issues/771) +- `New` — Ability to work with Block Actions and Inline Toolbar from the keyboard by Tab. [#705](https://github.com/codex-team/editor.js/issues/705) +- `Fix` — Fix error thrown by click on the empty editor after `blocks.clear()` method calling [#761](https://github.com/codex-team/editor.js/issues/761) +- `Fix` — Fix placeholder property appearance. Now you can assign it via `placeholder` property of EditorConfig. [#714](https://github.com/codex-team/editor.js/issues/714) +- `Fix` — Add API shorthands to TS types [#788](https://github.com/codex-team/editor.js/issues/788) ### 2.13 diff --git a/types/index.d.ts b/types/index.d.ts index 3ea80daf..d27ad631 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -6,6 +6,7 @@ import {EditorConfig} from './configs'; import {Blocks, Caret, Events, Listeners, Notifier, Sanitizer, Saver, Selection, Styles, Toolbar, InlineToolbar} from './api'; +import {OutputData} from "./data-formats/output-data"; /** * Interfaces used for development @@ -74,6 +75,48 @@ declare class EditorJS { public inlineToolbar: InlineToolbar; constructor(configuration?: EditorConfig|string); + /** + * API shorthands + */ + + /** + * @see Saver.save + */ + save(): Promise; + + /** + * @see Blocks.clear + */ + clear(): void; + + /** + * @see Blocks.render + */ + render(data: OutputData): Promise; + + /** + * @see Caret.focus + */ + focus(atEnd?: boolean): boolean; + + /** + * @see Events.on + */ + on(eventName: string, callback: (data?: any) => void): void; + + /** + * @see Events.off + */ + off(eventName: string, callback: (data?: any) => void): void; + + /** + * @see Events.emit + */ + emit(eventName: string, data: any): void; + + /** + * Destroy Editor instance and related DOM elements + */ public destroy(): void; }