Bläddra i källkod

Added "goToPreviousRestrictedEditingRegion" and "goToNextRestrictedEditingRegion" commands in the RestrictedEditingEditing plugin.

Aleksander Nowodzinski 6 år sedan
förälder
incheckning
4577604bd8

+ 5 - 0
packages/ckeditor5-restricted-editing/src/restrictededitingediting.js

@@ -9,6 +9,7 @@
 
 
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
 import Matcher from '@ckeditor/ckeditor5-engine/src/view/matcher';
 import Matcher from '@ckeditor/ckeditor5-engine/src/view/matcher';
+import RestrictedEditingNavigationCommand from './restrictededitingnavigationcommand';
 
 
 const HIGHLIGHT_CLASS = 'ck-restricted-editing-exception_selected';
 const HIGHLIGHT_CLASS = 'ck-restricted-editing-exception_selected';
 
 
@@ -29,6 +30,10 @@ export default class RestrictedEditingEditing extends Plugin {
 	init() {
 	init() {
 		const editor = this.editor;
 		const editor = this.editor;
 
 
+		// Commands that allow navigation in the content.
+		editor.commands.add( 'goToPreviousRestrictedEditingRegion', new RestrictedEditingNavigationCommand( editor, 'backward' ) );
+		editor.commands.add( 'goToNextRestrictedEditingRegion', new RestrictedEditingNavigationCommand( editor, 'forward' ) );
+
 		let createdMarkers = 0;
 		let createdMarkers = 0;
 
 
 		editor.conversion.for( 'upcast' ).add( upcastHighlightToMarker( {
 		editor.conversion.for( 'upcast' ).add( upcastHighlightToMarker( {

+ 9 - 0
packages/ckeditor5-restricted-editing/tests/restrictededitingediting.js

@@ -9,6 +9,7 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
 import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
 
 
 import RestrictedEditingEditing from './../src/restrictededitingediting';
 import RestrictedEditingEditing from './../src/restrictededitingediting';
+import RestrictedEditingNavigationCommand from '../src/restrictededitingnavigationcommand';
 import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
 import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
 import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
 import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
@@ -41,6 +42,14 @@ describe( 'RestrictedEditingEditing', () => {
 		it( 'should be loaded', () => {
 		it( 'should be loaded', () => {
 			expect( editor.plugins.get( RestrictedEditingEditing ) ).to.be.instanceOf( RestrictedEditingEditing );
 			expect( editor.plugins.get( RestrictedEditingEditing ) ).to.be.instanceOf( RestrictedEditingEditing );
 		} );
 		} );
+
+		it( 'adds a "goToPreviousRestrictedEditingRegion" command', () => {
+			expect( editor.commands.get( 'goToPreviousRestrictedEditingRegion' ) ).to.be.instanceOf( RestrictedEditingNavigationCommand );
+		} );
+
+		it( 'adds a "goToNextRestrictedEditingRegion" command', () => {
+			expect( editor.commands.get( 'goToNextRestrictedEditingRegion' ) ).to.be.instanceOf( RestrictedEditingNavigationCommand );
+		} );
 	} );
 	} );
 
 
 	describe( 'conversion', () => {
 	describe( 'conversion', () => {