Set the html contents to be pasted. It is used to correct and set the clipboard data in the beforePaste event.
Parameters:
Name | Type | Description |
|---|---|---|
| html | String | HTML DATA to paste into the editor |
editor.setEventListener('beforePaste', function(data) {
var html = data.clipboardData.html;
var text = data.clipboardData.text;
var data = html ? html : getHTMLString(text);
// Process the data to be pasted.
editor.setContentsToPaste('<h1>Synap Editor</h1>' + data);
});
/**
* Converts plaintext to an HTML string.
* @param text {string}
* @returns {string}
*/
function getHTMLString(text) {
return (text || '').split(/r\n|\r|\n/).map(txt => `<p style="margin: 0px;">${txt}</p>`).join('');
} |