-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Labels
Description
When pasting HTML content, the sanitizer strips attributes from elements before they reach the tool's onPaste method, even when the tool's static get sanitize() explicitly allows those attributes.
Steps to reproduce:
- Create a custom Block Tool with pasteConfig for P tags and sanitize rules to preserve style:
class MyTool {
static get pasteConfig() {
return {
tags: ['P', 'DIV']
};
}
static get sanitize() {
return {
p: {
style: true
}
};
}
static get pasteConfig() {
return {
tags: ['P', 'DIV', 'SPAN', 'PRE', 'CODE', 'BR']
};
}
onPaste(event) {
if (event.type === 'tag') {
const element = event.detail.data;
console.log('Received element:', element.outerHTML);
console.log('Style attribute:', element.getAttribute('style'));
}
}
}- Sanitizer rules at Editor config level:
sanitizer: {
br: true,
b: true,
i: true,
a: {
href: true
}
}-
Copy content from Google Docs that has paragraph indentation (which comes as CSS text-indent: 36pt or margin-left: 36pt in the clipboard HTML)
-
Paste into Editor.js
Expected behavior:
<p style="text-indent: 36pt;">Lorem ipsum...</p>Actual behavior
<p><span>Lorem ipsum...</span></p>Version: "@editorjs/editorjs": "^2.29.0",
Reactions are currently unavailable