-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Needs to replace HTML into TrustedHTML in elementFromString function. #5559
Comments
Also in VueJS there is an update referring to issue described:
|
I'm not familiar with this web API and it looks to be non-standard. So I'm unsure that we really need to support it. It also is unclear what you want to do and what you would want changed |
This would need to be changed by prosemirror, our base library. This looks like a lot of work to implement, I have no plans on supporting this at this time unless it is actually supported by other browsers. |
TipTap doesn't work in environments where a Trusted Types policy is enforced. It has nothing to do with browser support. |
It is also only a draft W3C spec, so I'm not going to spend the time on a non web standard just because you ask for it |
#5561. I fixed it. I didn't take much time to fix. I guess there will be some code clean up. Hope you'll do that easily. |
@nperez0111 I also had same issue and seems @rafaelhovhannisyan24(thank you) fixed it on this pr - #5561 |
Affected Packages
core
Version(s)
2.6.6
Bug Description
const policy = window.trustedTypes.createPolicy('tiptap', {
createHTML: (input) => input,
createScript: (input) => input,
createScriptURL: (input) => input,
});
export function elementFromString(value: string): HTMLElement {
// add a wrapper to preserve leading and trailing whitespace
const wrappedValue = policy.createHTML(
<body>${value}</body>
)const html = new window.DOMParser().parseFromString(wrappedValue, 'text/html').body
return removeWhitespaces(html)
}
Browser Used
Chrome
Code Example URL
No response
Expected Behavior
While using it on platform which has Trusted Types security concerns, Tiptap throughs following issue:
index.js:60354 This document requires 'TrustedHTML' assignment.
TypeError: Failed to execute 'parseFromString' on 'DOMParser': This document requires 'TrustedHTML' assignment. at elementFromString
Additional Context (Optional)
No response
Dependency Updates
The text was updated successfully, but these errors were encountered: