Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit 051b326

Browse files
authored
Merge pull request #36 from ckeditor/t/ckeditor5/578
Fix: Replaced nested editable's `.ck-editable` class with `.ck-editor__editable` + `.ck-editor__nested-editable` to stop Grammarly throwing errors. Closes ckeditor/ckeditor5#578. BREAKING CHANGE: The `.ck-editable` class is no longer available. Use the `.ck-editor__nested-editable` class instead.
2 parents 3d2714d + 031b5f8 commit 051b326

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/utils.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export function setHighlightHandling( element, writer, add, remove ) {
109109
*
110110
* @param {module:engine/view/element~Element} element
111111
* @param {String|Function} labelOrCreator
112-
* * @param {module:engine/view/writer~Writer} writer
112+
* @param {module:engine/view/writer~Writer} writer
113113
*/
114114
export function setLabel( element, labelOrCreator, writer ) {
115115
writer.setCustomProperty( labelSymbol, labelOrCreator, element );
@@ -133,16 +133,17 @@ export function getLabel( element ) {
133133

134134
/**
135135
* Adds functionality to provided {module:engine/view/editableelement~EditableElement} to act as a widget's editable:
136-
* * adds `ck-editable` CSS class,
136+
* * adds `ck-editor__editable` and `ck-editor__nested-editable` CSS classes,
137137
* * sets `contenteditable` as `true` when {module:engine/view/editableelement~EditableElement#isReadOnly} is `false`
138138
* otherwise set `false`,
139-
* * adds `ck-editable_focused` CSS class when editable is focused and removes it when it's blurred.
139+
* * adds `ck-editor__nested-editable_focused` CSS class when editable is focused and removes it when it's blurred.
140140
*
141141
* @param {module:engine/view/editableelement~EditableElement} editable
142+
* @param {module:engine/view/writer~Writer} writer
142143
* @returns {module:engine/view/editableelement~EditableElement} Returns same element that was provided in `editable` param.
143144
*/
144145
export function toWidgetEditable( editable, writer ) {
145-
writer.addClass( [ 'ck', 'ck-editable' ], editable );
146+
writer.addClass( [ 'ck', 'ck-editor__editable', 'ck-editor__nested-editable' ], editable );
146147

147148
// Set initial contenteditable value.
148149
writer.setAttribute( 'contenteditable', editable.isReadOnly ? 'false' : 'true', editable );
@@ -154,9 +155,9 @@ export function toWidgetEditable( editable, writer ) {
154155

155156
editable.on( 'change:isFocused', ( evt, property, is ) => {
156157
if ( is ) {
157-
writer.addClass( 'ck-editable_focused', editable );
158+
writer.addClass( 'ck-editor__nested-editable_focused', editable );
158159
} else {
159-
writer.removeClass( 'ck-editable_focused', editable );
160+
writer.removeClass( 'ck-editor__nested-editable_focused', editable );
160161
}
161162
} );
162163

tests/utils.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ describe( 'widget utils', () => {
139139
} );
140140

141141
it( 'should add proper class', () => {
142-
expect( element.hasClass( 'ck' ) ).to.be.true;
143-
expect( element.hasClass( 'ck-editable' ) ).to.be.true;
142+
expect( element.hasClass( 'ck', 'ck-editor__editable', 'ck-editor__nested-editable' ) ).to.be.true;
144143
} );
145144

146145
it( 'should add proper contenteditable value when element is read-only - initialization', () => {
@@ -162,10 +161,10 @@ describe( 'widget utils', () => {
162161

163162
it( 'should add proper class when element is focused', () => {
164163
element.isFocused = true;
165-
expect( element.hasClass( 'ck-editable_focused' ) ).to.be.true;
164+
expect( element.hasClass( 'ck-editor__nested-editable_focused' ) ).to.be.true;
166165

167166
element.isFocused = false;
168-
expect( element.hasClass( 'ck-editable_focused' ) ).to.be.false;
167+
expect( element.hasClass( 'ck-editor__nested-editable_focused' ) ).to.be.false;
169168
} );
170169
} );
171170

0 commit comments

Comments
 (0)