Răsfoiți Sursa

Rename nonRestricted attribute to restrictedEditingException.

Maciej Gołaszewski 6 ani în urmă
părinte
comite
35973cafc9

+ 7 - 7
packages/ckeditor5-restricted-editing/src/restricteddocumentcommand.js

@@ -20,9 +20,9 @@ export default class RestrictedDocumentCommand extends Command {
 		const model = this.editor.model;
 		const doc = model.document;
 
-		this.value = !!doc.selection.getAttribute( 'nonRestricted' );
+		this.value = !!doc.selection.getAttribute( 'restrictedEditingException' );
 
-		this.isEnabled = model.schema.checkAttributeInSelection( doc.selection, 'nonRestricted' );
+		this.isEnabled = model.schema.checkAttributeInSelection( doc.selection, 'restrictedEditingException' );
 	}
 
 	/**
@@ -35,20 +35,20 @@ export default class RestrictedDocumentCommand extends Command {
 		const valueToSet = ( options.forceValue === undefined ) ? !this.value : options.forceValue;
 
 		model.change( writer => {
-			const ranges = model.schema.getValidRanges( selection.getRanges(), 'nonRestricted' );
+			const ranges = model.schema.getValidRanges( selection.getRanges(), 'restrictedEditingException' );
 
 			if ( selection.isCollapsed ) {
 				if ( valueToSet ) {
-					writer.setSelectionAttribute( 'nonRestricted', true );
+					writer.setSelectionAttribute( 'restrictedEditingException', true );
 				} else {
-					writer.removeSelectionAttribute( 'nonRestricted' );
+					writer.removeSelectionAttribute( 'restrictedEditingException' );
 				}
 			} else {
 				for ( const range of ranges ) {
 					if ( valueToSet ) {
-						writer.setAttribute( 'nonRestricted', valueToSet, range );
+						writer.setAttribute( 'restrictedEditingException', valueToSet, range );
 					} else {
-						writer.removeAttribute( 'nonRestricted', range );
+						writer.removeAttribute( 'restrictedEditingException', range );
 					}
 				}
 			}

+ 2 - 2
packages/ckeditor5-restricted-editing/src/restricteddocumentediting.js

@@ -27,10 +27,10 @@ export default class RestrictedDocumentEditing extends Plugin {
 	init() {
 		const editor = this.editor;
 
-		editor.model.schema.extend( '$text', { allowAttributes: [ 'nonRestricted' ] } );
+		editor.model.schema.extend( '$text', { allowAttributes: [ 'restrictedEditingException' ] } );
 
 		editor.conversion.attributeToElement( {
-			model: 'nonRestricted',
+			model: 'restrictedEditingException',
 			view: {
 				name: 'span',
 				classes: 'ck-non-restricted'

+ 22 - 22
packages/ckeditor5-restricted-editing/tests/restricteddocumentcommand.js

@@ -18,7 +18,7 @@ describe( 'RestrictedDocumentCommand', () => {
 				editor = newEditor;
 				model = editor.model;
 
-				command = new RestrictedDocumentCommand( editor, 'nonRestricted' );
+				command = new RestrictedDocumentCommand( editor );
 
 				model.schema.register( 'p', { inheritAllFrom: '$block' } );
 				model.schema.register( 'h1', { inheritAllFrom: '$block' } );
@@ -27,7 +27,7 @@ describe( 'RestrictedDocumentCommand', () => {
 					isObject: true
 				} );
 
-				editor.model.schema.extend( '$text', { allowAttributes: [ 'nonRestricted' ] } );
+				editor.model.schema.extend( '$text', { allowAttributes: [ 'restrictedEditingException' ] } );
 			} );
 	} );
 
@@ -40,7 +40,7 @@ describe( 'RestrictedDocumentCommand', () => {
 	describe( 'value', () => {
 		it( 'is true when collapsed selection has the attribute', () => {
 			model.change( writer => {
-				writer.setSelectionAttribute( 'nonRestricted', true );
+				writer.setSelectionAttribute( 'restrictedEditingException', true );
 			} );
 
 			expect( command.value ).to.be.true;
@@ -48,24 +48,24 @@ describe( 'RestrictedDocumentCommand', () => {
 
 		it( 'is false when collapsed selection does not have the attribute', () => {
 			model.change( writer => {
-				writer.setSelectionAttribute( 'nonRestricted', true );
+				writer.setSelectionAttribute( 'restrictedEditingException', true );
 			} );
 
 			model.change( writer => {
-				writer.removeSelectionAttribute( 'nonRestricted' );
+				writer.removeSelectionAttribute( 'restrictedEditingException' );
 			} );
 
 			expect( command.value ).to.be.false;
 		} );
 
 		it( 'is true when selection is inside text with attribute', () => {
-			setData( model, '<p><$text nonRestricted="true">fo[]o</$text></p><h1>bar</h1>' );
+			setData( model, '<p><$text restrictedEditingException="true">fo[]o</$text></p><h1>bar</h1>' );
 
 			expect( command.value ).to.be.true;
 		} );
 
 		it( 'is true when selection is on text with attribute', () => {
-			setData( model, '<p>foo[<$text nonRestricted="true">bar</$text>]baz</p>' );
+			setData( model, '<p>foo[<$text restrictedEditingException="true">bar</$text>]baz</p>' );
 
 			expect( command.value ).to.be.true;
 		} );
@@ -76,7 +76,7 @@ describe( 'RestrictedDocumentCommand', () => {
 			model.schema.register( 'x', { inheritAllFrom: '$block' } );
 
 			model.schema.addAttributeCheck( ( ctx, attributeName ) => {
-				if ( ctx.endsWith( 'x $text' ) && attributeName == 'nonRestricted' ) {
+				if ( ctx.endsWith( 'x $text' ) && attributeName == 'restrictedEditingException' ) {
 					return false;
 				}
 			} );
@@ -114,15 +114,15 @@ describe( 'RestrictedDocumentCommand', () => {
 
 				command.execute();
 
-				expect( model.document.selection.hasAttribute( 'nonRestricted' ) ).to.be.true;
+				expect( model.document.selection.hasAttribute( 'restrictedEditingException' ) ).to.be.true;
 			} );
 
 			it( 'should remove selection attribute if text has non-restricted attribute', () => {
-				setData( model, '<p>abc<$text nonRestricted="true">foo[]bar</$text>baz</p>' );
+				setData( model, '<p>abc<$text restrictedEditingException="true">foo[]bar</$text>baz</p>' );
 
 				command.execute();
 
-				expect( model.document.selection.hasAttribute( 'nonRestricted' ) ).to.be.false;
+				expect( model.document.selection.hasAttribute( 'restrictedEditingException' ) ).to.be.false;
 			} );
 		} );
 
@@ -142,53 +142,53 @@ describe( 'RestrictedDocumentCommand', () => {
 
 				command.execute();
 
-				expect( getData( model ) ).to.equal( '<p>foo[<$text nonRestricted="true">bar</$text>]baz</p>' );
+				expect( getData( model ) ).to.equal( '<p>foo[<$text restrictedEditingException="true">bar</$text>]baz</p>' );
 			} );
 
 			it( 'should add attribute on selected text if part of selected text have attribute already', () => {
-				setData( model, '<p>[foo<$text nonRestricted="true">bar</$text>]baz</p>' );
+				setData( model, '<p>[foo<$text restrictedEditingException="true">bar</$text>]baz</p>' );
 
 				command.execute();
 
-				expect( getData( model ) ).to.equal( '<p>[<$text nonRestricted="true">foobar</$text>]baz</p>' );
+				expect( getData( model ) ).to.equal( '<p>[<$text restrictedEditingException="true">foobar</$text>]baz</p>' );
 			} );
 
 			it( 'should remove attribute only from selected part of non-restricted text', () => {
-				setData( model, '<p><$text nonRestricted="true">foo[bar]baz</$text></p>' );
+				setData( model, '<p><$text restrictedEditingException="true">foo[bar]baz</$text></p>' );
 
 				command.execute();
 
 				expect( getData( model ) ).to.equal(
-					'<p><$text nonRestricted="true">foo</$text>[bar]<$text nonRestricted="true">baz</$text></p>'
+					'<p><$text restrictedEditingException="true">foo</$text>[bar]<$text restrictedEditingException="true">baz</$text></p>'
 				);
 			} );
 
 			it( 'should remove attribute from selected text if all text contains attribute', () => {
-				setData( model, '<p>abc[<$text nonRestricted="true">foo]bar</$text>baz</p>' );
+				setData( model, '<p>abc[<$text restrictedEditingException="true">foo]bar</$text>baz</p>' );
 
 				command.execute();
 
-				expect( getData( model ) ).to.equal( '<p>abc[foo]<$text nonRestricted="true">bar</$text>baz</p>' );
+				expect( getData( model ) ).to.equal( '<p>abc[foo]<$text restrictedEditingException="true">bar</$text>baz</p>' );
 			} );
 
 			it( 'should add attribute on selected text if execute parameter was set to true', () => {
-				setData( model, '<p>abc<$text nonRestricted="true">foob[ar</$text>x]yz</p>' );
+				setData( model, '<p>abc<$text restrictedEditingException="true">foob[ar</$text>x]yz</p>' );
 
 				expect( command.value ).to.be.true;
 
 				command.execute( { forceValue: true } );
 
 				expect( command.value ).to.be.true;
-				expect( getData( model ) ).to.equal( '<p>abc<$text nonRestricted="true">foob[arx</$text>]yz</p>' );
+				expect( getData( model ) ).to.equal( '<p>abc<$text restrictedEditingException="true">foob[arx</$text>]yz</p>' );
 			} );
 
 			it( 'should remove attribute on selected nodes if execute parameter was set to false', () => {
-				setData( model, '<p>a[bc<$text nonRestricted="true">fo]obar</$text>xyz</p>' );
+				setData( model, '<p>a[bc<$text restrictedEditingException="true">fo]obar</$text>xyz</p>' );
 
 				command.execute( { forceValue: false } );
 
 				expect( command.value ).to.be.false;
-				expect( getData( model ) ).to.equal( '<p>a[bcfo]<$text nonRestricted="true">obar</$text>xyz</p>' );
+				expect( getData( model ) ).to.equal( '<p>a[bcfo]<$text restrictedEditingException="true">obar</$text>xyz</p>' );
 			} );
 		} );
 	} );

+ 6 - 6
packages/ckeditor5-restricted-editing/tests/restricteddocumentediting.js

@@ -35,12 +35,12 @@ describe( 'RestrictedDocumentEditing', () => {
 	} );
 
 	it( 'should set proper schema rules', () => {
-		expect( model.schema.checkAttribute( [ '$root', '$text' ], 'nonRestricted' ) ).to.be.true;
+		expect( model.schema.checkAttribute( [ '$root', '$text' ], 'restrictedEditingException' ) ).to.be.true;
 
-		expect( model.schema.checkAttribute( [ '$block', '$text' ], 'nonRestricted' ) ).to.be.true;
-		expect( model.schema.checkAttribute( [ '$clipboardHolder', '$text' ], 'nonRestricted' ) ).to.be.true;
+		expect( model.schema.checkAttribute( [ '$block', '$text' ], 'restrictedEditingException' ) ).to.be.true;
+		expect( model.schema.checkAttribute( [ '$clipboardHolder', '$text' ], 'restrictedEditingException' ) ).to.be.true;
 
-		expect( model.schema.checkAttribute( [ '$block' ], 'nonRestricted' ) ).to.be.false;
+		expect( model.schema.checkAttribute( [ '$block' ], 'restrictedEditingException' ) ).to.be.false;
 	} );
 
 	it( 'should register command', () => {
@@ -55,7 +55,7 @@ describe( 'RestrictedDocumentEditing', () => {
 				editor.setData( '<p>foo <span class="ck-non-restricted">bar</span> baz</p>' );
 
 				expect( getModelData( model, { withoutSelection: true } ) )
-					.to.equal( '<paragraph>foo <$text nonRestricted="true">bar</$text> baz</paragraph>' );
+					.to.equal( '<paragraph>foo <$text restrictedEditingException="true">bar</$text> baz</paragraph>' );
 			} );
 		} );
 
@@ -64,7 +64,7 @@ describe( 'RestrictedDocumentEditing', () => {
 				const expectedView = '<p>foo <span class="ck-non-restricted">bar</span> baz</p>';
 
 				setModelData( editor.model,
-					'<paragraph>foo <$text nonRestricted="true">bar</$text> baz</paragraph>'
+					'<paragraph>foo <$text restrictedEditingException="true">bar</$text> baz</paragraph>'
 				);
 
 				expect( editor.getData() ).to.equal( expectedView );