adding onPasteHTML config

This commit is contained in:
George Kovats 2023-02-20 18:58:55 -05:00
parent 07b1ce2aca
commit 093dfe8e22
2 changed files with 11 additions and 0 deletions

View file

@ -202,6 +202,10 @@ export default class Paste extends Module {
htmlData = '<p>' + (htmlData.trim() ? htmlData : plainData) + '</p>';
}
if (_.isFunction(this.config.onPasteHTML)) {
htmlData = String(this.config.onPasteHTML(htmlData) || htmlData);
}
/** Add all tags that can be substituted to sanitizer configuration */
const toolsTags = Object.keys(this.toolsTags).reduce((result, tag) => {
/**

View file

@ -94,6 +94,13 @@ export interface EditorConfig {
*/
onChange?(api: API, event: CustomEvent): void;
/**
* On Paste hook for parsing HTML before sanitization
* @param {string} html Input pasted HTML
* @returns {string} cleaned / updated HTML
*/
onPasteHTML?(html: string): string;
/**
* Defines default toolbar for all tools.
*/