mirror of
https://github.com/codex-team/editor.js
synced 2024-06-10 09:52:36 +02:00
Improve typings (#602)
This commit is contained in:
parent
8ca49fa6f5
commit
b89f756a03
6
dist/codex-editor.js
vendored
6
dist/codex-editor.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "codex.editor",
|
||||
"version": "2.7.31",
|
||||
"version": "2.7.32",
|
||||
"description": "CodeX Editor. Native JS, based on API and Open Source",
|
||||
"main": "dist/codex-editor.js",
|
||||
"types": "./types/index.d.ts",
|
||||
|
|
6
types/index.d.ts
vendored
6
types/index.d.ts
vendored
|
@ -11,13 +11,15 @@ import {Blocks, Caret, Events, Listeners, Notifier, Sanitizer, Saver, Selection,
|
|||
* Interfaces used for development
|
||||
*/
|
||||
export {
|
||||
Tool,
|
||||
ToolConstructable,
|
||||
BaseTool,
|
||||
BaseToolConstructable,
|
||||
InlineTool,
|
||||
InlineToolConstructable,
|
||||
BlockToolConstructable,
|
||||
BlockTool,
|
||||
BlockToolData,
|
||||
Tool,
|
||||
ToolConstructable,
|
||||
ToolboxConfig,
|
||||
ToolSettings,
|
||||
ToolConfig,
|
||||
|
|
18
types/tools/block-tool.d.ts
vendored
18
types/tools/block-tool.d.ts
vendored
|
@ -1,6 +1,6 @@
|
|||
import {PasteConfig, SanitizerConfig} from '../configs';
|
||||
import {BlockToolData} from './block-tool-data';
|
||||
import {Tool, ToolConstructable} from './tool';
|
||||
import {BaseTool, BaseToolConstructable} from './tool';
|
||||
import {ToolConfig} from './tool-config';
|
||||
import {API} from '../index';
|
||||
import {PasteEvent} from './paste-events';
|
||||
|
@ -8,18 +8,12 @@ import {PasteEvent} from './paste-events';
|
|||
* Describe Block Tool object
|
||||
* @see {@link docs/tools.md}
|
||||
*/
|
||||
export interface BlockTool extends Tool {
|
||||
export interface BlockTool extends BaseTool {
|
||||
/**
|
||||
* Sanitizer rules description
|
||||
*/
|
||||
sanitize?: SanitizerConfig;
|
||||
|
||||
/**
|
||||
* Return Tool's main block-wrapper
|
||||
* @return {HTMLElement}
|
||||
*/
|
||||
render(): HTMLElement;
|
||||
|
||||
/**
|
||||
* Process Tool's element in DOM and return raw data
|
||||
* @param {HTMLElement} block - element created by {@link BlockTool#render} function
|
||||
|
@ -47,10 +41,14 @@ export interface BlockTool extends Tool {
|
|||
*/
|
||||
merge?(blockData: BlockToolData): void;
|
||||
|
||||
onPaste?(event: PasteEvent);
|
||||
/**
|
||||
* On paste callback. Fired when pasted content can be substituted by a Tool
|
||||
* @param {PasteEvent} event
|
||||
*/
|
||||
onPaste?(event: PasteEvent): void;
|
||||
}
|
||||
|
||||
export interface BlockToolConstructable extends ToolConstructable {
|
||||
export interface BlockToolConstructable extends BaseToolConstructable {
|
||||
/**
|
||||
* Tool's Toolbox settings
|
||||
*/
|
||||
|
|
7
types/tools/index.d.ts
vendored
7
types/tools/index.d.ts
vendored
|
@ -1,3 +1,7 @@
|
|||
import {BlockTool, BlockToolConstructable} from './block-tool';
|
||||
import {InlineTool, InlineToolConstructable} from './inline-tool';
|
||||
import {BaseTool, BaseToolConstructable} from './tool';
|
||||
|
||||
export * from './block-tool';
|
||||
export * from './block-tool-data';
|
||||
export * from './inline-tool';
|
||||
|
@ -5,3 +9,6 @@ export * from './tool';
|
|||
export * from './tool-config';
|
||||
export * from './tool-settings';
|
||||
export * from './paste-events';
|
||||
|
||||
export type Tool = BaseTool | BlockTool | InlineTool;
|
||||
export type ToolConstructable = BaseToolConstructable | BlockToolConstructable | InlineToolConstructable;
|
||||
|
|
10
types/tools/inline-tool.d.ts
vendored
10
types/tools/inline-tool.d.ts
vendored
|
@ -1,8 +1,12 @@
|
|||
import {Tool, ToolConstructable} from './tool';
|
||||
import {BaseTool, BaseToolConstructable} from './tool';
|
||||
/**
|
||||
* Base structure for the Inline Toolbar Tool
|
||||
*/
|
||||
export interface InlineTool extends Tool {
|
||||
export interface InlineTool extends BaseTool {
|
||||
/**
|
||||
* Shortcut for Tool
|
||||
* @type {string}
|
||||
*/
|
||||
shortcut?: string;
|
||||
|
||||
/**
|
||||
|
@ -30,4 +34,4 @@ export interface InlineTool extends Tool {
|
|||
clear?(): void;
|
||||
}
|
||||
|
||||
export interface InlineToolConstructable extends ToolConstructable {}
|
||||
export interface InlineToolConstructable extends BaseToolConstructable {}
|
||||
|
|
2
types/tools/tool-settings.d.ts
vendored
2
types/tools/tool-settings.d.ts
vendored
|
@ -1,5 +1,5 @@
|
|||
import {ToolConfig} from './tool-config';
|
||||
import {ToolConstructable} from './tool';
|
||||
import {ToolConstructable} from './index';
|
||||
|
||||
/**
|
||||
* Tool's Toolbox settings
|
||||
|
|
10
types/tools/tool.d.ts
vendored
10
types/tools/tool.d.ts
vendored
|
@ -5,7 +5,7 @@ import {SanitizerConfig} from '../configs';
|
|||
/**
|
||||
* Abstract interface of all Tools
|
||||
*/
|
||||
export interface Tool {
|
||||
export interface BaseTool {
|
||||
/**
|
||||
* Tool`s render method
|
||||
* For inline Tools returns inline toolbar button
|
||||
|
@ -14,11 +14,7 @@ export interface Tool {
|
|||
render(): HTMLElement;
|
||||
}
|
||||
|
||||
export interface ToolConstructable {
|
||||
/**
|
||||
* Tool name
|
||||
*/
|
||||
name: string;
|
||||
export interface BaseToolConstructable {
|
||||
|
||||
/**
|
||||
* Define Tool type as Inline
|
||||
|
@ -33,7 +29,7 @@ export interface ToolConstructable {
|
|||
/**
|
||||
* Describe constructor parameters
|
||||
*/
|
||||
new (config: {api: API}): Tool;
|
||||
new (config: {api: API}): BaseTool;
|
||||
|
||||
/**
|
||||
* Tool`s prepare method. Can be async
|
||||
|
|
Loading…
Reference in a new issue