Skip to content

Commit 92e8e04

Browse files
committed
!!!TASK: Simplify legacy autoparagraph: false mode
The outer tag is not removed anymore - instead youll get a span. You should switch to the new isInline mode
1 parent 2c72e4c commit 92e8e04

File tree

3 files changed

+1
-52
lines changed

3 files changed

+1
-52
lines changed

packages/neos-ui-ckeditor5-bindings/src/cleanupContentBeforeCommit.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,5 @@ export const cleanupContentBeforeCommit = content => {
44
if (content.match(/^<([a-z][a-z0-9]*)\b[^>]*>&nbsp;<\/\1>$/)) {
55
return '';
66
}
7-
8-
// We remove opening and closing span tags that are produced by the `DisabledAutoparagraphMode` plugin
9-
if (content.startsWith('<span>') && content.endsWith('</span>')) {
10-
const contentWithoutOuterSpan = content
11-
.replace(/^<span>/, '')
12-
.replace(/<\/span>$/, '');
13-
14-
if (contentWithoutOuterSpan.includes('<span>')) {
15-
// In case there is still a span tag, we can be sure that the previously trimmed ones were belonging together,
16-
// as it could be the case that multiple root paragraph/span elements were inserted into the ckeditor
17-
// (which is currently not prevented if the html is modified from outside), so we will preserve the output.
18-
return content;
19-
}
20-
return contentWithoutOuterSpan;
21-
}
227
return content;
238
};

packages/neos-ui-ckeditor5-bindings/src/cleanupContentBeforeCommit.spec.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,3 @@ test('remove empty nbsp', () => {
88
assertCleanedUpContent('<p>&nbsp;</p>', '');
99
assertCleanedUpContent('<span>&nbsp;</span>', '');
1010
})
11-
12-
describe('ckeditor DisabledAutoparagraphMode hack, cleanup outer spans', () => {
13-
test('noop', () => {
14-
assertCleanedUpContent('<p></p>', '<p></p>');
15-
16-
assertCleanedUpContent('', '');
17-
18-
assertCleanedUpContent('<span><span>foo</span></span>', '<span><span>foo</span></span>');
19-
})
20-
21-
test('cleanup single root <span>', () => {
22-
assertCleanedUpContent('<span></span>', '');
23-
assertCleanedUpContent('<span>foo</span>', 'foo');
24-
})
25-
26-
test('cleanup multiple root <span>', () => {
27-
assertCleanedUpContent('<span>foo</span><span>bar</span>', '<span>foo</span><span>bar</span>');
28-
})
29-
30-
test('cleanup <span> root after other root', () => {
31-
// in the case you had multiple paragraphs and a headline and switched to autoparagraph: false
32-
assertCleanedUpContent('<h1>foo</h1><span>bar</span>', '<h1>foo</h1><span>bar</span>');
33-
})
34-
})

packages/neos-ui-ckeditor5-bindings/src/manifest.config.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,6 @@ const addPlugin = (Plugin, isEnabled) => (ckEditorConfiguration, options) => {
3333
return ckEditorConfiguration;
3434
};
3535

36-
// If the editable is a span or a heading, we automatically disable paragraphs and enable the soft break mode
37-
// Also possible to force this behavior with `autoparagraph: false`
38-
const disableAutoparagraph = (editorOptions, {propertyDomNode}) =>
39-
editorOptions?.autoparagraph === false ||
40-
propertyDomNode.tagName === 'SPAN' ||
41-
propertyDomNode.tagName === 'H1' ||
42-
propertyDomNode.tagName === 'H2' ||
43-
propertyDomNode.tagName === 'H3' ||
44-
propertyDomNode.tagName === 'H4' ||
45-
propertyDomNode.tagName === 'H5' ||
46-
propertyDomNode.tagName === 'H6';
47-
4836
//
4937
// Create richtext editing toolbar registry
5038
//
@@ -103,7 +91,7 @@ export default ckEditorRegistry => {
10391
config.set('essentials', addPlugin(Essentials));
10492
config.set('paragraph', addPlugin(Paragraph));
10593
// @deprecated
106-
config.set('disabledAutoparagraphMode', addPlugin(DisabledAutoparagraphMode, disableAutoparagraph));
94+
config.set('disabledAutoparagraphMode', addPlugin(DisabledAutoparagraphMode, (editorOptions) => editorOptions?.autoparagraph === false));
10795
config.set('sub', addPlugin(Sub, $get('formatting.sub')));
10896
config.set('sup', addPlugin(Sup, $get('formatting.sup')));
10997
config.set('bold', addPlugin(Bold, $get('formatting.strong')));

0 commit comments

Comments
 (0)