Can we abandon html-janitor and change to anything else (i.e. sanitize-html) #2184
Replies: 3 comments 2 replies
-
Just an additional note, I also notice that there is current standing issue related to TABLE seen at the comment of the code below, which is pretty similar to what I've been experiencing right now. editor.js/src/components/modules/paste.ts Line 563 in a8026e6 And to mention some other paste issues like list items, or other complex html structures. Well, the idea is NOT to entertain those complex html structures, but to avoid with unnecessary fixes while the html-janitor is actually not actively maintained. |
Beta Was this translation helpful? Give feedback.
-
let me see what I can do, I'm forking out the next branch and working it on my local first. |
Beta Was this translation helpful? Give feedback.
-
Adding my support to move to a different janitor! I am having a different problem also caused by html-janitor (I believe) onPaste, I want to keep " " even when it is in between elements, ie: some text some more text. I've noticed this works fine when I am pasting within a block that I specify in pasteConfig... but if it's an inline paste... it gets stripped every time. I am 90% sure it is due to this part of the html-janitor: Source: https://github.com/guardian/html-janitor/blob/master/src/html-janitor.js Any advice or workarounds appreciated... but otherwise I am hoping that if you switch to a new janitor, it removing white space like this becomes something we can specify. Thanks!! |
Beta Was this translation helpful? Give feedback.
-
Background
I've been spending hours looking at the code while writing a custom Tool that can process the following tag (usually for highlightjs).
And I've been using this piece of code to populate editorjs with HTML input.
But because of I want to let the end-users choose the language they want using a dropdown, I had to customize the code plugin at https://github.com/editor-js/code. Just so that the code looks like this:
![image](https://user-images.githubusercontent.com/12979499/204076763-be32c811-6774-4ece-a3fe-33fd20b4a39c.png)
Issue
It was amazing actually, parsing data was okay, everything works perfectly as expected. Except, digging further deep down, it seems like I can't easily parse HTML so that the drop down reads correctly from the HTML. No matter what HTML I put in, the CODE tag was stripped out including its attributes. I found out that the code was using a component to sanitize the HTML tags and attributes, relying on https://github.com/guardian/html-janitor.
And guess what? The code maintainer has archived this code and wasn't updated for years.
What I have tried
Play around with sanitize and onPaste method. This code
return { code: true }
doesn't work,return { code: { 'class': true } }
not working also.Idea
Instead of relying on this old component, why don't we use a component that's actively maintained like https://www.npmjs.com/package/sanitize-html? Or any other active component (you suggest)?
I do believe there will be a major breaking change especially dealing with plugins created by amazing people here separately.
Beta Was this translation helpful? Give feedback.
All reactions