How to control the execution order of inputTransformation event listeners?
I've written a simple plugin that strips all <span> and <div> elements from pasted HTML. I do this because when people paste content from sources like Google Docs or MS Word, lots of empty spans and divs can be created. However, I want to ensure that my plugin's event listener executes after all others. I see that I can set a priority for the subscriber, which defaults to "normal". But, if I change it to "lower" or "lowest", it doesn't execute at all.
Here's the code:
this.editor.plugins
.get("ClipboardPipeline")
.on("inputTransformation", (evt, data) => {
const writer = new UpcastWriter(data.content);
// Scan all divs and spans and save them for later removal.
let elementsToUnwrap = [];
const range = writer.createRangeIn( data.content );
for (const value of range) {
if (value.item.is( 'element', 'span') || value.item.is( 'element', 'div')) {
// We can't just unwrap it here, as it seems to affect the scan
// for other elements.
elementsToUnwrap.push(value.item);
}
}
for (const item of elementsToUnwrap) {
writer.unwrapElement(item);
}
});
I believe my event listener is executing before the Paste from Office plugin.
Any updates on this? Even I am facing similar issue
There has been no activity on this issue for the past year. We've marked it as stale and will close it in 30 days. We understand it may still be relevant, so if you're interested in the solution, leave a comment or reaction under this issue.
We've closed your issue due to inactivity. We understand that the issue may still be relevant. If so, feel free to open a new one (and link this issue to it).