Skip to content
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

HTML <style> tags are being stripped #966

Open
Melonking906 opened this issue Dec 10, 2024 · 2 comments
Open

HTML <style> tags are being stripped #966

Melonking906 opened this issue Dec 10, 2024 · 2 comments

Comments

@Melonking906
Copy link

Melonking906 commented Dec 10, 2024

I have been unable to get a fresh install of SCEditor to stop stripping out <style> tags.

I have tested allowedTags: ["style"] in the editor options; I have also tried with default format and with xhtml format. In all cases, style is stripped when switching between source and non source modes.

@Melonking906
Copy link
Author

I've created a work around with two text boxes, one for SCEditor and one for CSS that does not use SCEditor. When CSS is typed into the css box it auto injects it into the SCEditor for WYSIWYG support. Its a nice solution for my situation, however would still be nice to have inbuilt style support.

@live627
Copy link
Collaborator

live627 commented Dec 15, 2024

I have some code that may be what you look for

sceditor.plugins.styleshet = function() {
	let base = this,
		editor;

	base.init = function () {
		editor = this;
	};

	base.signalReady = function() {
		editor.addStyleshet = path =>
		{
			const iframe = editor.getContentAreaContainer();
			const el = iframe.contentDocument.createElement('link');
			el.type = 'text/css';
			el.href = path;

			iframe.contentDocument.head.appendChild(el);
		};
	};
}

allowedTags tells DOMPurify to not remove tags such as <iframe>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants