-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ts, types, ts config, update js to ts
- Loading branch information
Showing
12 changed files
with
1,912 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
import { API, HTMLPasteEvent, PasteConfig, ToolConfig } from '@editorjs/editorjs'; | ||
|
||
/** | ||
* Base Paragraph Block for the Editor.js. | ||
* Represents a regular text block | ||
* | ||
* @author CodeX ([email protected]) | ||
* @copyright CodeX 2018 | ||
* @license The MIT License (MIT) | ||
*/ | ||
/** | ||
* @typedef {object} ParagraphConfig | ||
* @property {string} placeholder - placeholder for the empty paragraph | ||
* @property {boolean} preserveBlank - Whether or not to keep blank paragraphs when saving editor data | ||
*/ | ||
interface ParagraphConfig extends ToolConfig { | ||
/** | ||
* Placeholder for the empty paragraph | ||
*/ | ||
placeholder?: string; | ||
/** | ||
* Whether or not to keep blank paragraphs when saving editor data | ||
*/ | ||
preserveBlank?: boolean; | ||
} | ||
/** | ||
* @typedef {object} ParagraphData | ||
* @description Tool's input and output data format | ||
* @property {string} text — Paragraph's content. Can include HTML tags: <a><b><i> | ||
*/ | ||
interface ParagraphData { | ||
text: string; | ||
} | ||
interface ParagraphParams { | ||
data: ParagraphData; | ||
config: ParagraphConfig; | ||
api: API; | ||
readOnly: boolean; | ||
} | ||
export default class Paragraph { | ||
/** | ||
* Default placeholder for Paragraph Tool | ||
* | ||
* @returns {string} | ||
* @class | ||
*/ | ||
static get DEFAULT_PLACEHOLDER(): string; | ||
api: API; | ||
readOnly: boolean; | ||
private _CSS; | ||
private _placeholder; | ||
private _data; | ||
private _element; | ||
private _preserveBlank; | ||
/** | ||
* Render plugin`s main Element and fill it with saved data | ||
* | ||
* @param {object} params - constructor params | ||
* @param {ParagraphData} params.data - previously saved data | ||
* @param {ParagraphConfig} params.config - user config for Tool | ||
* @param {object} params.api - editor.js api | ||
* @param {boolean} readOnly - read only mode flag | ||
*/ | ||
constructor({ data, config, api, readOnly }: ParagraphParams); | ||
/** | ||
* Check if text content is empty and set empty string to inner html. | ||
* We need this because some browsers (e.g. Safari) insert <br> into empty contenteditanle elements | ||
* | ||
* @param {KeyboardEvent} e - key up event | ||
*/ | ||
onKeyUp(e: KeyboardEvent): void; | ||
/** | ||
* Create Tool's view | ||
* | ||
* @returns {HTMLDivElement} | ||
* @private | ||
*/ | ||
drawView(): HTMLDivElement; | ||
/** | ||
* Return Tool's view | ||
* | ||
* @returns {HTMLDivElement} | ||
*/ | ||
render(): HTMLDivElement; | ||
/** | ||
* Method that specified how to merge two Text blocks. | ||
* Called by Editor.js by backspace at the beginning of the Block | ||
* | ||
* @param {ParagraphData} data | ||
* @public | ||
*/ | ||
merge(data: ParagraphData): void; | ||
/** | ||
* Validate Paragraph block data: | ||
* - check for emptiness | ||
* | ||
* @param {ParagraphData} savedData — data received after saving | ||
* @returns {boolean} false if saved data is not correct, otherwise true | ||
* @public | ||
*/ | ||
validate(savedData: ParagraphData): boolean; | ||
/** | ||
* Extract Tool's data from the view | ||
* | ||
* @param {HTMLDivElement} toolsContent - Paragraph tools rendered view | ||
* @returns {ParagraphData} - saved data | ||
* @public | ||
*/ | ||
save(toolsContent: HTMLDivElement): ParagraphData; | ||
/** | ||
* On paste callback fired from Editor. | ||
* | ||
* @param {HTMLPasteEvent} event - event with pasted data | ||
*/ | ||
onPaste(event: HTMLPasteEvent): void; | ||
/** | ||
* Enable Conversion Toolbar. Paragraph can be converted to/from other tools | ||
*/ | ||
static get conversionConfig(): { | ||
export: string; | ||
import: string; | ||
}; | ||
/** | ||
* Sanitizer rules | ||
*/ | ||
static get sanitize(): { | ||
text: { | ||
br: boolean; | ||
}; | ||
}; | ||
/** | ||
* Returns true to notify the core that read-only mode is supported | ||
* | ||
* @returns {boolean} | ||
*/ | ||
static get isReadOnlySupported(): boolean; | ||
/** | ||
* Used by Editor paste handling API. | ||
* Provides configuration to handle P tags. | ||
* | ||
* @returns {PasteConfig} | ||
*/ | ||
static get pasteConfig(): PasteConfig; | ||
/** | ||
* Icon and title for displaying at the Toolbox | ||
* | ||
* @returns {{icon: string, title: string}} | ||
*/ | ||
static get toolbox(): { | ||
icon: string; | ||
title: string; | ||
}; | ||
} | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* Create a DocumentFragment and fill it with HTML from a string | ||
* | ||
* @param {string} htmlString - A string of valid HTML | ||
* @returns {DocumentFragment} | ||
*/ | ||
export default function makeFragment(htmlString: string): DocumentFragment; |
Oops, something went wrong.