mirror of
https://github.com/tinymce/tinymce.git
synced 2025-07-30 12:56:42 +00:00
TINY-10955: Remove whitespaces between comment elements. (#9728)
* TINY-10955: Remove whitespaces between comment elements. * TINY-10955: Improved readability, improved changelog.
This commit is contained in:
6
.changes/unreleased/tinymce-TINY-10955-2024-06-24.yaml
Normal file
6
.changes/unreleased/tinymce-TINY-10955-2024-06-24.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
project: tinymce
|
||||
kind: Fixed
|
||||
body: Sequential html comments would in some cases generate unwanted elements.
|
||||
time: 2024-06-24T17:40:05.135911183+02:00
|
||||
custom:
|
||||
Issue: TINY-10955
|
@ -1,4 +1,5 @@
|
||||
import { Arr, Fun, Obj, Type } from '@ephox/katamari';
|
||||
import { NodeTypes } from '@ephox/sugar';
|
||||
|
||||
import * as TransparentElements from '../../content/TransparentElements';
|
||||
import * as NodeType from '../../dom/NodeType';
|
||||
@ -212,6 +213,8 @@ const whitespaceCleaner = (root: AstNode, schema: Schema, settings: DomParserSet
|
||||
|
||||
if (text.length === 0) {
|
||||
node.remove();
|
||||
} else if (text === ' ' && node.prev && node.prev.type === NodeTypes.COMMENT && node.next && node.next.type === NodeTypes.COMMENT) {
|
||||
node.remove();
|
||||
} else {
|
||||
node.value = text;
|
||||
}
|
||||
|
@ -502,6 +502,17 @@ describe('browser.tinymce.core.EditorTest', () => {
|
||||
TinyAssertions.assertContent(editor, '<p><img src="data:image/gif;base64,R0"></p>');
|
||||
});
|
||||
|
||||
// eslint-disable-next-line mocha/no-exclusive-tests
|
||||
it.only('TINY-10955: multiple comments will not cause unexpected newlines', () => {
|
||||
const editor = hook.editor();
|
||||
editor.setContent('<div>A</div><!--Comment1--><!--Comment2--><div>B</div>');
|
||||
TinyAssertions.assertRawContent(editor, '<div>A</div><!--Comment1--><!--Comment2--><div>B</div>');
|
||||
editor.setContent('<div>A</div> <!--Comment1--> <!--Comment2--> <div>B</div>');
|
||||
TinyAssertions.assertRawContent(editor, '<div>A</div><!--Comment1--><!--Comment2--><div>B</div>');
|
||||
editor.setContent('<div>A</div>\n<!--Comment1-->\n<!--Comment2-->\n<div>B</div>');
|
||||
TinyAssertions.assertRawContent(editor, '<div>A</div><!--Comment1--><!--Comment2--><div>B</div>');
|
||||
});
|
||||
|
||||
context('hasPlugin', () => {
|
||||
const checkWithoutManager = (title: string, plugins: string, plugin: string, expected: boolean) => {
|
||||
const editor = hook.editor();
|
||||
|
Reference in New Issue
Block a user