Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close SourceEditing view on plugin disabling #17729

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/ckeditor5-source-editing/src/sourceediting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ export default class SourceEditing extends Plugin {
}
} );

this.on( 'change:isEnabled', ( evt, name, isEnabled ) => this._handleReadOnlyMode( !isEnabled ) );
this.on( 'change:isEnabled', ( evt, name, isEnabled ) => {
if ( !isEnabled && this.isSourceEditingMode ) {
this.isSourceEditingMode = isEnabled;
}
} );

this.listenTo( editor, 'change:isReadOnly', ( evt, name, isReadOnly ) => this._handleReadOnlyMode( isReadOnly ) );
}
Expand Down
9 changes: 2 additions & 7 deletions packages/ckeditor5-source-editing/tests/sourceediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,19 +422,14 @@ describe( 'SourceEditing', () => {
expect( textarea.readOnly ).to.be.false;
} );

it( 'should disable textarea if plugin is disabled', () => {
it( 'should close source editing mode if plugin is disabled', () => {
button.fire( 'execute' );

const domRoot = editor.editing.view.getDomRoot();
const textarea = domRoot.nextSibling.children[ 0 ];

plugin.forceDisabled( 'disablePlugin' );

expect( textarea.readOnly ).to.be.true;
expect( plugin.isSourceEditingMode ).to.be.false;

plugin.clearForceDisabled( 'disablePlugin' );

expect( textarea.readOnly ).to.be.false;
} );

it( 'should remember replaced roots', () => {
Expand Down
Loading