|
|
@@ -9,7 +9,7 @@ import { getData as getModelData, setData as setModelData } from '@ckeditor/cked
|
|
|
import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
|
|
|
import { getCode } from '@ckeditor/ckeditor5-utils/src/keyboard';
|
|
|
import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
|
|
|
-import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
|
|
|
+import { assertEqualMarkup, expectToThrowCKEditorError } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
|
|
|
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
|
|
|
import BoldEditing from '@ckeditor/ckeditor5-basic-styles/src/bold/boldediting';
|
|
|
import StrikethroughEditing from '@ckeditor/ckeditor5-basic-styles/src/strikethrough/strikethroughediting';
|
|
|
@@ -22,6 +22,7 @@ import RestrictedEditingModeNavigationCommand from '../src/restrictededitingmode
|
|
|
import ItalicEditing from '@ckeditor/ckeditor5-basic-styles/src/italic/italicediting';
|
|
|
import BlockQuoteEditing from '@ckeditor/ckeditor5-block-quote/src/blockquoteediting';
|
|
|
import TableEditing from '@ckeditor/ckeditor5-table/src/tableediting';
|
|
|
+import Command from '@ckeditor/ckeditor5-core/src/command';
|
|
|
|
|
|
describe( 'RestrictedEditingModeEditing', () => {
|
|
|
let editor, model;
|
|
|
@@ -63,6 +64,46 @@ describe( 'RestrictedEditingModeEditing', () => {
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
+ describe( 'enableCommand()', () => {
|
|
|
+ let plugin, command;
|
|
|
+
|
|
|
+ class FakeCommand extends Command {
|
|
|
+ refresh() {
|
|
|
+ this.isEnabled = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ beforeEach( async () => {
|
|
|
+ editor = await VirtualTestEditor.create( { plugins: [ Paragraph, RestrictedEditingModeEditing ] } );
|
|
|
+ model = editor.model;
|
|
|
+
|
|
|
+ plugin = editor.plugins.get( RestrictedEditingModeEditing );
|
|
|
+ command = new FakeCommand( editor );
|
|
|
+ editor.commands.add( 'fakeCommand', command );
|
|
|
+
|
|
|
+ setModelData( editor.model, '<paragraph>[]foo bar baz qux</paragraph>' );
|
|
|
+ addExceptionMarker( 4, 7, model.document.getRoot().getChild( 0 ) );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should throw if non-existing command is being enabled', () => {
|
|
|
+ expectToThrowCKEditorError(
|
|
|
+ () => {
|
|
|
+ plugin.enableCommand( 'foo' );
|
|
|
+ },
|
|
|
+ /^restricted-editing-command-not-found/,
|
|
|
+ editor
|
|
|
+ );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should enable the command globally', () => {
|
|
|
+ expect( command.isEnabled ).to.be.false;
|
|
|
+
|
|
|
+ plugin.enableCommand( 'fakeCommand' );
|
|
|
+
|
|
|
+ expect( command.isEnabled ).to.be.true;
|
|
|
+ } );
|
|
|
+ } );
|
|
|
+
|
|
|
describe( 'conversion', () => {
|
|
|
beforeEach( async () => {
|
|
|
editor = await VirtualTestEditor.create( { plugins: [ Paragraph, TableEditing, RestrictedEditingModeEditing ] } );
|