Documentation Center

IO.setPreprocessHTMLPasteFunction

This function can be useful when you want to modify content copied, for example from Microsoft Word, before pasting it.

Description

Set a new function for preprocessing HTML before pasting.

The following example adds custom text to the clipboard content before it is pasted into a document.
IO.setPreprocessHTMLPasteFunction(function(htmlContent) {
	var div = document.createElement('div');
	div.textContent = "This text was added in preprocess";
	htmlContent.appendChild(div);	
	return htmlContent;
});

The preprocessing function will be executed whenever the clipboard contents are treated as HTML. This happens when pasting from external sources, including Microsoft Office, and when pasting from one editor instance to another.

Content pasted from external sources is cached, meaning that if the same content is pasted before and after using the setPreprocessHTMLPasteFunction to set a preprocessing function, the pasted content will be the same as before and the preprocessing function will not be executed.

Syntax

IO.setPrepocessHTMLPasteFunction(preprocessHTMLPaste : Function)

Arguments

preprocessHTMLFunction
Function. The new preprocess function. This function has a single argument: the HTML content from the clipboard as an HTMLElement. It should return the contents to be pasted, as an HTMLElement object.