8
0
Эх сурвалжийг харах

Merge branch 'i/7794' into i/7802

panr 5 жил өмнө
parent
commit
49af6258bf

+ 1 - 1
packages/ckeditor5-image/lang/contexts.json

@@ -20,5 +20,5 @@
 	"Update": "The label of submit form button if image src URL input has value",
 	"Update": "The label of submit form button if image src URL input has value",
 	"Cancel": "The label of cancel form button",
 	"Cancel": "The label of cancel form button",
 	"Insert image via URL": "The input label for the Insert image via URL form",
 	"Insert image via URL": "The input label for the Insert image via URL form",
-	"Paste the image source URL": "The tip label below the Insert image via URL form"
+	"Paste the image source URL.": "The tip label below the Insert image via URL form"
 }
 }

+ 1 - 1
packages/ckeditor5-image/src/imageupload/imageuploadui.js

@@ -104,7 +104,7 @@ export default class ImageUploadUI extends Plugin {
 		function onSubmit() {
 		function onSubmit() {
 			const selectedElement = editor.model.document.selection.getSelectedElement();
 			const selectedElement = editor.model.document.selection.getSelectedElement();
 
 
-			if ( selectedElement && isImage( selectedElement ) ) {
+			if ( isImage( selectedElement ) ) {
 				editor.model.change( writer => {
 				editor.model.change( writer => {
 					writer.setAttribute( 'src', imageUploadView.imageURLInputValue, selectedElement );
 					writer.setAttribute( 'src', imageUploadView.imageURLInputValue, selectedElement );
 					writer.removeAttribute( 'srcset', selectedElement );
 					writer.removeAttribute( 'srcset', selectedElement );

+ 17 - 9
packages/ckeditor5-image/src/imageupload/utils.js

@@ -11,6 +11,7 @@
 
 
 import LabeledFieldView from '@ckeditor/ckeditor5-ui/src/labeledfield/labeledfieldview';
 import LabeledFieldView from '@ckeditor/ckeditor5-ui/src/labeledfield/labeledfieldview';
 import { createLabeledInputText } from '@ckeditor/ckeditor5-ui/src/labeledfield/utils';
 import { createLabeledInputText } from '@ckeditor/ckeditor5-ui/src/labeledfield/utils';
+import { attachLinkToDocumentation } from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 
 
 /**
 /**
  * Creates a regular expression used to test for image files.
  * Creates a regular expression used to test for image files.
@@ -127,14 +128,21 @@ export function prepareIntegrations( editor ) {
 		} else if ( editor.ui.componentFactory.has( key ) ) {
 		} else if ( editor.ui.componentFactory.has( key ) ) {
 			object[ key ] = editor.ui.componentFactory.create( key );
 			object[ key ] = editor.ui.componentFactory.create( key );
 		} else {
 		} else {
-			// Console.warn should be enough because missing integration doesn't break the editor.
-			console.warn(
-				'It looks like integration "' + key + '" doesn\'t exist. ' +
-				'What may have happened: ' +
-				'\n- you passed the invalid integration name in the `image.upload.panel.items`,' +
-				'\n- integration component wasn\'t properly registered by the plugin,' +
-				'\n- the plugin that registers the component wasn\'t installed in the editor.'
-			);
+			/**
+			 * The specified name of the view cannot be created by the
+			 * {@link module:ui/componentfactory~ComponentFactory component factory}.
+			 *
+			 * Check whether:
+			 * * you passed the proper integration name as the
+			 *    `{@link module:image/imageupload~ImageUploadPanelConfig#items image.upload.panel.items}`,
+			 * * the plugin that registers the component was loaded to the editor,
+			 * * integration component was properly registered by the plugin.
+			 *
+			 * @error image-upload-integrations-invalid-view
+			 */
+			console.warn( attachLinkToDocumentation(
+				'image-upload-integrations-invalid-view: Trying to use a view that does not exist.'
+			), { key } );
 		}
 		}
 
 
 		return object;
 		return object;
@@ -156,7 +164,7 @@ export function createLabeledInputView( locale ) {
 		label: t( 'Insert image via URL' )
 		label: t( 'Insert image via URL' )
 	} );
 	} );
 	labeledInputView.fieldView.placeholder = 'https://example.com/src/image.png';
 	labeledInputView.fieldView.placeholder = 'https://example.com/src/image.png';
-	labeledInputView.infoText = t( 'Paste the image source URL' );
+	labeledInputView.infoText = t( 'Paste the image source URL.' );
 
 
 	return labeledInputView;
 	return labeledInputView;
 }
 }

+ 3 - 2
packages/ckeditor5-image/tests/imageupload/utils.js

@@ -79,7 +79,8 @@ describe( 'Upload utils', () => {
 			editorElement.remove();
 			editorElement.remove();
 		} );
 		} );
 
 
-		it( 'should return only "insertImageViaUrl" integration and throw warning about missing integration', async () => {
+		it( 'should return only "insertImageViaUrl" integration and throw warning' +
+			'for "image-upload-integrations-invalid-view" error', async () => {
 			const editorElement = document.createElement( 'div' );
 			const editorElement = document.createElement( 'div' );
 			document.body.appendChild( editorElement );
 			document.body.appendChild( editorElement );
 
 
@@ -108,7 +109,7 @@ describe( 'Upload utils', () => {
 			expect( Object.values( prepareIntegrations( editor ) ).length ).to.equal( 1 );
 			expect( Object.values( prepareIntegrations( editor ) ).length ).to.equal( 1 );
 
 
 			sinon.assert.calledOnce( consoleWarn );
 			sinon.assert.calledOnce( consoleWarn );
-			expect( /Integration "openCKFinder" doesn't exist/gmi.test( consoleWarn.args[ 0 ][ 0 ] ) ).to.be.true;
+			expect( /image-upload-integrations-invalid-view/gmi.test( consoleWarn.args[ 0 ][ 0 ] ) ).to.be.true;
 
 
 			editor.destroy();
 			editor.destroy();
 			editorElement.remove();
 			editorElement.remove();