Open Orgoth opened 8 months ago
If I disable the pasteStore and paste the xml as text "ctrl + shift + v" only the text is getting inserted.
If I disable __insertByType within defaultPasteProcess, the HTML/XML is getting pasted more or less how I would expect it. "ctrl + shift + v"
This is the result, which thunderbird creates, when pasting the xml/html. "ctrl + shift + v"
<p><ruleset name="pcsg-generated-ruleset"><br>
<description>Created with the PHP Coding Standard Generator.<a class="moz-txt-link-freetext" href="http://edorian.github.com/php-coding-standard-generator/" id="ext-element-59" target="_blank">http://edorian.github.com/php-coding-standard-generator/</a></description><br>
<rule ref="Generic.Classes.DuplicateClassName"/><br>
<rule ref="Generic.CodeAnalysis.EmptyStatement"/><br>
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/><br>
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/><br>
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/><br>
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/><br>
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/><br>
<rule ref="Generic.ControlStructures.InlineControlStructure"/><br>
<rule ref="Generic.Formatting.DisallowMultipleStatements"/><br>
<rule ref="Generic.Formatting.MultipleStatementAlignment"/><br>
</ruleset><br> </p>
I have now dealt with the ClipboardEvent and I think that it can be distinguished well via the types. If Types only contains text/plain, then it should always be inserted with the specialchar treatment. I think that it would also make sense if the "beforePasteInsert" event is also passed the ClipboardEvent so that the developer has the option of evaluating it and specifying his logic.
const result = editor.e.fire('beforePasteInsert', html);
const result = editor.e.fire('beforePasteInsert', html, e);
Example:
me.messageEditor.events.on('beforePasteInsert',function(html,e){
let clipBoard = e.clipboardData;
if( !clipBoard.getData('text/html') && clipBoard.getData('text/plain') ){
html = html.replaceAll(/<br\s*\/?>/gmi,"\n");
html = me.htmlspecialchars(html);
html = html.replaceAll(/\n/gm,"<br>");
html = html.replaceAll(/ /gm," ");
}
console.log(html);
return html;
});
Jodit Version: 4.0.18
Browser: Chrome/IE/Safary/FF OS: Linux Is React App: False
Code
Expected behavior:
If the HTML/XML is copied from a page with extra styles, then these are not copied either, instead it is converted and the content is inserted as if the option "Insert only text" had been selected.
Actual behavior: https://xdsoft.net/jodit/
Keep
Insert as Text
This is what ckeditor created when pasting "ctrl+v"