@@ -3,13 +3,15 @@ import $ from 'jquery';
33import 'ui/html_editor' ;
44import fx from 'common/core/animation/fx' ;
55
6+ import nativePointerMock from '../../../helpers/nativePointerMock.js' ;
67import { checkLink , prepareEmbedValue , prepareTableValue } from './utils.js' ;
78
89const TOOLBAR_CLASS = 'dx-htmleditor-toolbar' ;
910const TOOLBAR_WRAPPER_CLASS = 'dx-htmleditor-toolbar-wrapper' ;
1011const TOOLBAR_FORMAT_WIDGET_CLASS = 'dx-htmleditor-toolbar-format' ;
1112const TOOLBAR_MULTILINE_CLASS = 'dx-toolbar-multiline' ;
1213const TOOLBAR_FORMAT_BUTTON_ACTIVE_CLASS = 'dx-format-active' ;
14+ const HTML_EDITOR_CONTENT_CLASS = 'dx-htmleditor-content' ;
1315const DROPDOWNMENU_CLASS = 'dx-dropdownmenu-button' ;
1416const DROPDOWNEDITOR_ICON_CLASS = 'dx-dropdowneditor-icon' ;
1517const BUTTON_CONTENT_CLASS = 'dx-button-content' ;
@@ -25,6 +27,8 @@ const LIST_ITEM_CLASS = 'dx-list-item';
2527
2628const BLACK_PIXEL = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQYGWNgYmL6DwABFgEGpP/tHAAAAABJRU5ErkJggg==' ;
2729
30+ const ENTER_KEY_CODE = 13 ;
31+
2832const { test, module : testModule } = QUnit ;
2933
3034function getToolbar ( $container ) {
@@ -146,6 +150,39 @@ export default function() {
146150 . trigger ( 'dxclick' ) ;
147151 } ) ;
148152
153+ test ( 'header format should be reset after moving to next line (T1315504)' , function ( assert ) {
154+ const $htmlEditor = $ ( '#htmlEditor' ) . dxHtmlEditor ( {
155+ value : '<p>test</p>' ,
156+ toolbar : {
157+ items : [ {
158+ name : 'header' ,
159+ acceptedValues : [ false , 1 , 2 , 3 , 4 , 5 ] ,
160+ options : {
161+ opened : true
162+ } ,
163+ } ] ,
164+ multiline : false
165+ } ,
166+ } ) ;
167+ const htmlEditor = $htmlEditor . dxHtmlEditor ( 'instance' ) ;
168+ const $formatWidget = $htmlEditor . find ( `.${ TOOLBAR_FORMAT_WIDGET_CLASS } ` ) ;
169+ const $content = $htmlEditor . find ( `.${ HTML_EDITOR_CONTENT_CLASS } ` ) ;
170+ htmlEditor . setSelection ( 4 , 0 ) ;
171+
172+ $ ( `.${ LIST_ITEM_CLASS } ` )
173+ . last ( )
174+ . trigger ( 'dxclick' ) ;
175+
176+
177+ const value = $formatWidget . find ( `.${ INPUT_CLASS } ` ) . val ( ) ;
178+ assert . strictEqual ( value , 'Heading 5' , 'Header format is applied' ) ;
179+
180+ nativePointerMock ( ) . simulateEvent ( $content . get ( 0 ) , 'keydown' , { keyCode : ENTER_KEY_CODE } ) ;
181+
182+ const newValue = $formatWidget . find ( `.${ INPUT_CLASS } ` ) . val ( ) ;
183+ assert . strictEqual ( newValue , 'Normal text' , 'Header format is reset' ) ;
184+ } ) ;
185+
149186 test ( 'adaptive menu should be hidden after selecting formatting' , function ( assert ) {
150187 const done = assert . async ( ) ;
151188 const instance = $ ( '#htmlEditor' ) . dxHtmlEditor ( {
0 commit comments