Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/modules/paste.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
/**
Expand Down
7 changes: 7 additions & 0 deletions types/configs/editor-config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down