Procházet zdrojové kódy

Aligned command names to our convention.

Piotrek Koszuliński před 5 roky
rodič
revize
8ce8a8a53b

+ 2 - 2
packages/ckeditor5-html-embed/docs/features/html-embed.md

@@ -48,8 +48,8 @@ Note: it's mentioned in the config.htmlEmbed.* options so if we'll decide to ren
 
 The {@link module:html-embed/htmlembed~HtmlEmbed} plugin registers:
 * the UI button component (`'htmlEmbed'`),
-* the `'htmlEmbedUpdate'` command implemented by {@link module:html-embed/htmlembedupdatecommand~HtmlEmbedUpdateCommand}.
-* the `'htmlEmbedInsert'` command implemented by {@link module:html-embed/htmlembedinsertcommand~HtmlEmbedInsertCommand}.
+* the `'updateHtmlEmbed'` command implemented by {@link module:html-embed/updatehtmlembedcommand~UpdateHtmlEmbedCommand}.
+* the `'insertHtmlEmbed'` command implemented by {@link module:html-embed/inserthtmlembedcommand~InsertHtmlEmbedCommand}.
 
 The command can be executed using the {@link module:core/editor/editor~Editor#execute `editor.execute()`} method:
 

+ 1 - 1
packages/ckeditor5-html-embed/lang/contexts.json

@@ -1,7 +1,7 @@
 {
   "Insert HTML": "Toolbar button tooltip for the HTML embed feature.",
   "HTML snippet": "The HTML snippet.",
-  "Paste the raw code here.": "A placeholder that will be displayed in the raw HTML textarea field.",
+  "Paste raw HTML here...": "A placeholder that will be displayed in the raw HTML textarea field.",
   "Edit source": "A label of a button that switches the HTML embed to the source editing mode.",
   "Save changes": "A label of a button that saves the HTML embed content and navigates back to the preview.",
   "Cancel": "A label of a button that discards changes in the HTML embed content and navigates back to the preview."

+ 7 - 7
packages/ckeditor5-html-embed/src/htmlembedediting.js

@@ -12,8 +12,8 @@ import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/html
 import UpcastWriter from '@ckeditor/ckeditor5-engine/src/view/upcastwriter';
 import { logWarning } from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 import { toWidget } from '@ckeditor/ckeditor5-widget/src/utils';
-import HtmlEmbedInsertCommand from './htmlembedinsertcommand';
-import HtmlEmbedUpdateCommand from './htmlembedupdatecommand';
+import InsertHtmlEmbedCommand from './inserthtmlembedcommand';
+import UpdateHtmlEmbedCommand from './updatehtmlembedcommand';
 import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
 
 import pencilIcon from '@ckeditor/ckeditor5-core/theme/icons/pencil.svg';
@@ -77,8 +77,8 @@ export default class HtmlEmbedEditing extends Plugin {
 			allowAttributes: [ 'value' ]
 		} );
 
-		editor.commands.add( 'htmlEmbedUpdate', new HtmlEmbedUpdateCommand( editor ) );
-		editor.commands.add( 'htmlEmbedInsert', new HtmlEmbedInsertCommand( editor ) );
+		editor.commands.add( 'updateHtmlEmbed', new UpdateHtmlEmbedCommand( editor ) );
+		editor.commands.add( 'insertHtmlEmbed', new InsertHtmlEmbedCommand( editor ) );
 
 		this._setupConversion();
 	}
@@ -131,7 +131,7 @@ export default class HtmlEmbedEditing extends Plugin {
 			model: 'rawHtml',
 			view: ( modelElement, { writer } ) => {
 				const widgetLabel = t( 'HTML snippet' );
-				const placeholder = t( 'Paste the raw code here.' );
+				const placeholder = t( 'Paste raw HTML here...' );
 
 				const widgetView = writer.createContainerElement( 'div', {
 					class: 'raw-html-embed'
@@ -160,7 +160,7 @@ export default class HtmlEmbedEditing extends Plugin {
 					root.readOnly = editor.isReadOnly;
 
 					// When focusing the "edit source" element, the model selection must be updated.
-					// If we do not do it, the `htmlEmbedUpdate` command will fail because it
+					// If we do not do it, the `updateHtmlEmbed` command will fail because it
 					// searches the `rawHtml` element based on selection.
 					root.addEventListener( 'focus', () => {
 						editor.model.change( writer => {
@@ -169,7 +169,7 @@ export default class HtmlEmbedEditing extends Plugin {
 					} );
 
 					root.addEventListener( 'input', () => {
-						editor.execute( 'htmlEmbedUpdate', root.value );
+						editor.execute( 'updateHtmlEmbed', root.value );
 					} );
 
 					return root;

+ 2 - 2
packages/ckeditor5-html-embed/src/htmlembedui.js

@@ -24,7 +24,7 @@ export default class HtmlEmbedUI extends Plugin {
 
 		// Add the `htmlEmbed` button to feature components.
 		editor.ui.componentFactory.add( 'htmlEmbed', locale => {
-			const command = editor.commands.get( 'htmlEmbedInsert' );
+			const command = editor.commands.get( 'insertHtmlEmbed' );
 			const view = new ButtonView( locale );
 
 			view.set( {
@@ -37,7 +37,7 @@ export default class HtmlEmbedUI extends Plugin {
 
 			// Execute the command.
 			this.listenTo( view, 'execute', () => {
-				editor.execute( 'htmlEmbedInsert' );
+				editor.execute( 'insertHtmlEmbed' );
 				editor.editing.view.focus();
 
 				const widgetWrapper = editor.editing.view.document.selection.getSelectedElement();

+ 4 - 4
packages/ckeditor5-html-embed/src/htmlembedinsertcommand.js → packages/ckeditor5-html-embed/src/inserthtmlembedcommand.js

@@ -4,7 +4,7 @@
  */
 
 /**
- * @module html-embed/htmlembedinsertcommand
+ * @module html-embed/inserthtmlembedcommand
  */
 
 import Command from '@ckeditor/ckeditor5-core/src/command';
@@ -13,15 +13,15 @@ import { findOptimalInsertionPosition } from '@ckeditor/ckeditor5-widget/src/uti
 /**
  * The insert raw HTML element command.
  *
- * The command is registered by {@link module:html-embed/htmlembedediting~HtmlEmbedEditing} as `'htmlEmbedInsert'`.
+ * The command is registered by {@link module:html-embed/htmlembedediting~HtmlEmbedEditing} as `'insertHtmlEmbed'`.
  *
  * To insert the raw HTML element at the current selection, execute the command:
  *
- *		editor.execute( 'htmlEmbedInsert' );
+ *		editor.execute( 'insertHtmlEmbed' );
  *
  * @extends module:core/command~Command
  */
-export default class HtmlEmbedInsertCommand extends Command {
+export default class InsertHtmlEmbedCommand extends Command {
 	/**
 	 * @inheritDoc
 	 */

+ 4 - 4
packages/ckeditor5-html-embed/src/htmlembedupdatecommand.js → packages/ckeditor5-html-embed/src/updatehtmlembedcommand.js

@@ -4,7 +4,7 @@
  */
 
 /**
- * @module html-embed/htmlembedupdatecommand
+ * @module html-embed/updatehtmlembedcommand
  */
 
 import Command from '@ckeditor/ckeditor5-core/src/command';
@@ -12,15 +12,15 @@ import Command from '@ckeditor/ckeditor5-core/src/command';
 /**
  * The update raw HTML value command.
  *
- * The command is registered by {@link module:html-embed/htmlembedediting~HtmlEmbedEditing} as `'htmlEmbedUpdate'`.
+ * The command is registered by {@link module:html-embed/htmlembedediting~HtmlEmbedEditing} as `'updateHtmlEmbed'`.
  *
  * To update the value of the raw HTML element at the current selection, execute the command:
  *
- *		editor.execute( 'htmlEmbedUpdate', '<b>HTML.</b>' );
+ *		editor.execute( 'updateHtmlEmbed', '<b>HTML.</b>' );
  *
  * @extends module:core/command~Command
  */
-export default class HtmlEmbedUpdateCommand extends Command {
+export default class UpdateHtmlEmbedCommand extends Command {
 	/**
 	 * @inheritDoc
 	 */

+ 7 - 7
packages/ckeditor5-html-embed/tests/htmlembedediting.js

@@ -8,8 +8,8 @@
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 import HtmlEmbedEditing from '../src/htmlembedediting';
 import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
-import HtmlEmbedUpdateCommand from '../src/htmlembedupdatecommand';
-import HtmlEmbedInsertCommand from '../src/htmlembedinsertcommand';
+import UpdateHtmlEmbedCommand from '../src/updatehtmlembedcommand';
+import InsertHtmlEmbedCommand from '../src/inserthtmlembedcommand';
 import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { isWidget } from '@ckeditor/ckeditor5-widget/src/utils';
 
@@ -60,12 +60,12 @@ describe( 'HtmlEmbedEditing', () => {
 	} );
 
 	describe( 'commands', () => {
-		it( 'should register htmlEmbedUpdate command', () => {
-			expect( editor.commands.get( 'htmlEmbedUpdate' ) ).to.be.instanceOf( HtmlEmbedUpdateCommand );
+		it( 'should register updateHtmlEmbed command', () => {
+			expect( editor.commands.get( 'updateHtmlEmbed' ) ).to.be.instanceOf( UpdateHtmlEmbedCommand );
 		} );
 
-		it( 'should register htmlEmbedInsert command', () => {
-			expect( editor.commands.get( 'htmlEmbedInsert' ) ).to.be.instanceOf( HtmlEmbedInsertCommand );
+		it( 'should register insertHtmlEmbed command', () => {
+			expect( editor.commands.get( 'insertHtmlEmbed' ) ).to.be.instanceOf( InsertHtmlEmbedCommand );
 		} );
 	} );
 
@@ -277,7 +277,7 @@ describe( 'HtmlEmbedEditing', () => {
 				const viewHtmlContainer = widget.getChild( 1 );
 				const sourceElement = viewHtmlContainer.getChild( 1 );
 
-				expect( sourceElement.getAttribute( 'placeholder' ) ).to.equal( 'Paste the raw code here.' );
+				expect( sourceElement.getAttribute( 'placeholder' ) ).to.equal( 'Paste raw HTML here...' );
 			} );
 
 			it( 'should update the edit source element when the `value` attribute has changed', () => {

+ 4 - 4
packages/ckeditor5-html-embed/tests/htmlembedui.js

@@ -45,17 +45,17 @@ describe( 'HtmlEmbedEditing', () => {
 		expect( htmlEmbedView.isToggleable ).to.be.false;
 	} );
 
-	it( 'should execute htmlEmbedInsert command on model execute event', () => {
+	it( 'should execute insertHtmlEmbed command on model execute event', () => {
 		const executeSpy = testUtils.sinon.spy( editor, 'execute' );
 
 		htmlEmbedView.fire( 'execute' );
 
 		sinon.assert.calledOnce( executeSpy );
-		sinon.assert.calledWithExactly( executeSpy, 'htmlEmbedInsert' );
+		sinon.assert.calledWithExactly( executeSpy, 'insertHtmlEmbed' );
 	} );
 
-	it( 'should bind model to htmlEmbedInsert command', () => {
-		const command = editor.commands.get( 'htmlEmbedInsert' );
+	it( 'should bind model to insertHtmlEmbed command', () => {
+		const command = editor.commands.get( 'insertHtmlEmbed' );
 
 		expect( htmlEmbedView.isEnabled ).to.be.true;
 

+ 2 - 2
packages/ckeditor5-html-embed/tests/htmlembedinsertcommand.js → packages/ckeditor5-html-embed/tests/inserthtmlembedcommand.js

@@ -11,7 +11,7 @@ import HtmlEmbedEditing from '../src/htmlembedediting';
 import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 
-describe( 'HtmlEmbedInsertCommand', () => {
+describe( 'InsertHtmlEmbedCommand', () => {
 	let editor, model, editorElement, command;
 
 	testUtils.createSinonSandbox();
@@ -27,7 +27,7 @@ describe( 'HtmlEmbedInsertCommand', () => {
 			.then( newEditor => {
 				editor = newEditor;
 				model = editor.model;
-				command = editor.commands.get( 'htmlEmbedInsert' );
+				command = editor.commands.get( 'insertHtmlEmbed' );
 			} );
 	} );
 

+ 2 - 2
packages/ckeditor5-html-embed/tests/manual/htmlembed.html

@@ -99,7 +99,7 @@
             </tr>
 
             <tr>
-                <td class="file high" data-value="htmlembedinsertcommand.js">htmlembedinsertcommand.js</td>
+                <td class="file high" data-value="inserthtmlembedcommand.js">inserthtmlembedcommand.js</td>
                 <td data-value="100" class="pic high">
                     <div class="chart">
                         <div class="cover-fill cover-full" style="width: 100%"></div>
@@ -135,7 +135,7 @@
             </tr>
 
             <tr>
-                <td class="file high" data-value="htmlembedupdatecommand.js">htmlembedupdatecommand.js</td>
+                <td class="file high" data-value="updatehtmlembedcommand.js">updatehtmlembedcommand.js</td>
                 <td data-value="100" class="pic high">
                     <div class="chart">
                         <div class="cover-fill cover-full" style="width: 100%"></div>

+ 2 - 2
packages/ckeditor5-html-embed/tests/htmlembedupdatecommand.js → packages/ckeditor5-html-embed/tests/updatehtmlembedcommand.js

@@ -11,7 +11,7 @@ import HtmlEmbedEditing from '../src/htmlembedediting';
 import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 
-describe( 'HtmlEmbedUpdateCommand', () => {
+describe( 'UpdateHtmlEmbedCommand', () => {
 	let editor, model, editorElement, command;
 
 	testUtils.createSinonSandbox();
@@ -27,7 +27,7 @@ describe( 'HtmlEmbedUpdateCommand', () => {
 			.then( newEditor => {
 				editor = newEditor;
 				model = editor.model;
-				command = editor.commands.get( 'htmlEmbedUpdate' );
+				command = editor.commands.get( 'updateHtmlEmbed' );
 			} );
 	} );