File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
js/__internal/ui/html_editor/matchers
testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ import { isString } from '@js/core/utils/type' ;
2+
13function getListType ( matches ) {
24 const prefix = matches [ 1 ] ;
35 return prefix . match ( / \S + \. / ) ? 'ordered' : 'bullet' ;
@@ -29,6 +31,11 @@ const getMatcher = (quill) => {
2931 const ops = delta . ops . slice ( ) ;
3032
3133 const insertOperation = ops [ 0 ] ;
34+
35+ if ( ! isString ( insertOperation . insert ) ) {
36+ return delta ;
37+ }
38+
3239 insertOperation . insert = insertOperation . insert . replace ( / ^ \s + / , '' ) ;
3340 const listDecoratorMatches = insertOperation . insert . match ( / ^ ( \S + ) \s + / ) ;
3441 const indent = listDecoratorMatches && getIndent ( node , msStyleAttributeName ) ;
Original file line number Diff line number Diff line change @@ -65,6 +65,33 @@ export default function() {
6565 assert . strictEqual ( instance . option ( 'value' ) , prepareTableValue ( value ) ) ;
6666 assert . strictEqual ( markup , value ) ;
6767 } ) ;
68+
69+ [ 'MsoListParagraphCxSpFirst' , 'MsoListParagraphCxSpMiddle' , 'MsoListParagraphCxSpLast' ] . forEach ( className => {
70+ test ( `editor should not throw error for ${ className } class with allowSoftLineBreak (T1292587)` , function ( assert ) {
71+ const spy = sinon . spy ( console , 'error' ) ;
72+ const value = `<p class="${ className } "><br><br></p>` ;
73+
74+ try {
75+ $ ( '#htmlEditor' ) . dxHtmlEditor ( { value } ) . dxHtmlEditor ( 'instance' ) ;
76+
77+ assert . strictEqual ( spy . called , false , 'No console error was thrown' ) ;
78+ } finally {
79+ spy . restore ( ) ;
80+ }
81+ } ) ;
82+
83+ test ( `editor should preserve double <br> in list paragraph for ${ className } class (T1292587)` , function ( assert ) {
84+ const value = `<p class="${ className } "><br><br></p>` ;
85+ const htmlEditor = $ ( '#htmlEditor' ) . dxHtmlEditor ( {
86+ value
87+ } ) . dxHtmlEditor ( 'instance' ) ;
88+
89+ const markup = htmlEditor . option ( 'value' ) ;
90+ const $markup = $ ( '<div>' ) . html ( markup ) ;
91+
92+ assert . strictEqual ( $markup . find ( 'br' ) . length , 2 , 'Two soft breaks preserved' ) ;
93+ } ) ;
94+ } ) ;
6895 } ) ;
6996
7097 testModule ( 'runtime editing' , moduleConfig , function ( ) {
You can’t perform that action at this time.
0 commit comments