-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TASK: Apply suggestion from code review
- Loading branch information
Showing
5 changed files
with
40 additions
and
49 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
packages/neos-ui-ckeditor5-bindings/src/cleanupContentBeforeCommit.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/neos-ui-ckeditor5-bindings/src/plugins/cleanupNeosInlineWrapper.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* We remove opening and closing span tags that are produced by the inlineMode plugin | ||
* | ||
* @private only exported for testing | ||
* @param {String} content | ||
*/ | ||
export const cleanupNeosInlineWrapper = content => { | ||
if (content.includes('<neos-inline-wrapper>')) { | ||
let contentWithoutOuterInlineWrapper = content; | ||
|
||
if (content.startsWith('<neos-inline-wrapper>') && content.endsWith('</neos-inline-wrapper>')) { | ||
contentWithoutOuterInlineWrapper = content | ||
.replace(/^<neos-inline-wrapper>/, '') | ||
.replace(/<\/neos-inline-wrapper>$/, ''); | ||
} | ||
|
||
if (contentWithoutOuterInlineWrapper.includes('<neos-inline-wrapper>')) { | ||
// in the case, multiple root paragraph elements were inserted into the ckeditor (wich is currently not prevented if the html is modified from outside) | ||
// we have multiple root elements of type <neos-inline-wrapper>. We will convert all of them into spans. | ||
return content | ||
.replace(/<neos-inline-wrapper>/g, '<span>') | ||
.replace(/<\/neos-inline-wrapper>/g, '</span>'); | ||
} | ||
return contentWithoutOuterInlineWrapper; | ||
} | ||
return content; | ||
}; |
2 changes: 1 addition & 1 deletion
2
...5-bindings/src/plugins/inlineMode.spec.js → .../plugins/cleanupNeosInlineWrapper.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters