8
0
Pārlūkot izejas kodu

Merge branch t/upload-docs

Docs: New image upload docs.
Piotrek Koszuliński 7 gadi atpakaļ
vecāks
revīzija
fef982bdb8

+ 4 - 2
packages/ckeditor5-ckfinder/README.md

@@ -10,11 +10,13 @@ CKEditor 5's CKFinder integration
 [![Dependency Status](https://david-dm.org/ckeditor/ckeditor5-ckfinder/status.svg)](https://david-dm.org/ckeditor/ckeditor5-ckfinder)
 [![devDependency Status](https://david-dm.org/ckeditor/ckeditor5-ckfinder/dev-status.svg)](https://david-dm.org/ckeditor/ckeditor5-ckfinder?type=dev)
 
-The [CKFinder](https://ckeditor.com/ckfinder/) file browser integration for CKEditor 5.
+This package implements the [CKFinder feature](https://ckeditor.com/docs/ckeditor5/latest/features/ckfinder.html). This feature allows you to easily insert images as well as links to files into the editor content. It is a bridge between the CKEditor 5 WYSIWYG editor and the [CKFinder file manager and uploader](https://ckeditor.com/ckfinder).
 
 ## Documentation
 
-See the [`@ckeditor/ckeditor5-ckfinder` package](https://ckeditor.com/docs/ckeditor5/latest/api/ckfinder.html) page in [CKEditor 5 documentation](https://ckeditor.com/docs/ckeditor5/latest/).
+See the ["CKFinder integration" guide](https://ckeditor.com/docs/ckeditor5/latest/features/ckfinder.html) and the [plugin documentation](https://ckeditor.com/docs/ckeditor5/latest/api/ckfinder.html) to learn more about the integration.
+
+Check out the [comprehensive "Image upload" guide](https://ckeditor.com/docs/ckeditor5/latest/features/image-upload.html) to learn about other ways to upload images into CKEditor 5.
 
 ## License
 

+ 3 - 0
packages/ckeditor5-ckfinder/docs/_snippets/features/ckfinder-upload-only.html

@@ -0,0 +1,3 @@
+<div id="snippet-ckfinder-upload-only">
+	Use the toolbar button to insert an image.
+</div>

+ 26 - 0
packages/ckeditor5-ckfinder/docs/_snippets/features/ckfinder-upload-only.js

@@ -0,0 +1,26 @@
+/**
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* globals ClassicEditor, console, window, document */
+
+ClassicEditor
+	.create( document.querySelector( '#snippet-ckfinder-upload-only' ), {
+		toolbar: {
+			items: [
+				'imageUpload', '|', 'heading', '|', 'bold', 'italic', '|', 'undo', 'redo'
+			],
+			viewportTopOffset: 100
+		},
+		ckfinder: {
+			// eslint-disable-next-line max-len
+			uploadUrl: 'https://cksource.com/weuy2g4ryt278ywiue/core/connector/php/connector.php?command=QuickUpload&type=Files&responseType=json'
+		}
+	} )
+	.then( editor => {
+		window.editor = editor;
+	} )
+	.catch( err => {
+		console.error( err.stack );
+	} );

+ 1 - 1
packages/ckeditor5-ckfinder/docs/_snippets/features/ckfinder.html

@@ -1,3 +1,3 @@
 <div id="snippet-ckfinder">
-	Use toolbar button to insert image or link to a file.
+	Use the toolbar button to open the CKFinder file manager. Use the file manager's interface to insert an image or a link to a file.
 </div>

+ 5 - 3
packages/ckeditor5-ckfinder/docs/api/ckfinder.md

@@ -6,15 +6,17 @@ category: api-reference
 
 [![npm version](https://badge.fury.io/js/%40ckeditor%2Fckeditor5-ckfinder.svg)](https://www.npmjs.com/package/@ckeditor/ckeditor5-ckfinder)
 
-This package implements the {@link features/ckfinder CKFinder integration} feature for CKEditor 5. It lets you easily insert images & links to files. It integrates automatically with [CKFinder](https://ckeditor.com/ckfinder/).
+This package implements the {@link features/ckfinder CKFinder feature}. This feature allows you to easily insert images as well as links to files into the editor content. It is a bridge between the CKEditor 5 WYSIWYG editor and the [CKFinder file manager and uploader](https://ckeditor.com/ckfinder).
 
 ## Demo
 
-Check out the {@link features/ckfinder#demo demo in the CKFinder feature} guide.
+Check out the {@link features/ckfinder#demo demos} in the integration guide.
 
 ## Documentation
 
-See the {@link features/ckfinder CKFinder feature} guide and the {@link module:ckfinder/ckfinder~CKFinder} plugin documentation.
+See the {@link features/ckfinder "CKFinder integration" guide} and the {@link module:ckfinder/ckfinder~CKFinder plugin documentation} to learn more about the integration.
+
+Check out the {@link features/image-upload comprehensive "Image upload" guide} to learn about other ways to upload images into CKEditor 5.
 
 ## Installation
 

+ 82 - 20
packages/ckeditor5-ckfinder/docs/features/ckfinder.md

@@ -1,16 +1,49 @@
 ---
 category: features
+menu-title: CKFinder
 ---
 
 {@snippet features/build-ckfinder-source}
 
 # CKFinder integration
 
-This {@link module:ckfinder/ckfinder~CKFinder feature} allows you to easily insert images as well as links to files into the editor content. It is a bridge between the CKEditor 5 WYSIWYG editor and the [CKFinder](https://ckeditor.com/ckfinder) file manager and uploader.
+This feature allows you to easily insert images as well as links to files into the editor content. It is a bridge between the CKEditor 5 WYSIWYG editor and the [CKFinder](https://ckeditor.com/ckfinder) file manager and uploader.
+
+<info-box>
+	Check out the {@link features/image-upload comprehensive "Image upload" guide} to learn about other ways to upload images into CKEditor 5.
+</info-box>
+
+This feature can be used in the editor in two different ways:
+
+* [**As a server-side connector only**](#configuring-the-image-upload-only) ([demo](#image-upload-only)): In this scenario, images which are dropped or pasted into the editor are uploaded to a CKFinder server-side connector running on your server.
+* [**As a server and client-side file manager integration**](#configuring-the-full-integration) ([demo](#full-integration)): Images dropped and pasted directly into the editor are uploaded to the server (just like in the first option).
+
+	But there are more cool features available, for instance:
+
+	* **uploading** using the full user interface,
+	* **browsing** previously uploaded images,
+	* **editing** images (cropping, resizing, etc.),
+	* **organizing** or deleting images.
+
+	Check out the [CKFinder file manager website](https://ckeditor.com/ckfinder/) to learn more about features you can use in your project.
 
 ## Demo
 
-You can use the "Insert image or file" button in the toolbar to insert an image or a link to any other file. You can also paste the image directly into the editor content and it will be automatically [uploaded](#configuring-image-upload) to the server.
+### Image upload only
+
+This demo shows the integration where the file manager's server connector handles [the image upload](#configuring-the-full-integration) only:
+
+* Paste the image directly into the editor content and it will be automatically uploaded using the server—side connector.
+* Use the "Insert image" button in the toolbar to insert an image.
+
+{@snippet features/ckfinder-upload-only}
+
+### Full integration
+
+This demo shows the [full integration](#configuring-the-full-integration) with the CKFinder file manager:
+
+* Paste the image directly into the editor content and it will be automatically uploaded using the server—side connector.
+* Use the "Insert image or file" button in the toolbar to open the CKFinder file manager and insert an image or a link to any other file.
 
 {@snippet features/ckfinder}
 
@@ -26,7 +59,7 @@ To add this feature to your editor, install the [`@ckeditor/ckeditor5-ckfinder`]
 npm install --save @ckeditor/ckeditor5-ckfinder
 ```
 
-Then add `CKFinder` to your plugin list and [configure](#configuration) the feature (when necessary):
+Then add {@link module:ckfinder/ckfinder~CKFinder} to your plugin list and [configure](#configuration) the feature (when necessary). For instance:
 
 ```js
 import CKFinder from '@ckeditor/ckeditor5-ckfinder/src/ckfinder';
@@ -34,7 +67,7 @@ import CKFinder from '@ckeditor/ckeditor5-ckfinder/src/ckfinder';
 ClassicEditor
 	.create( document.querySelector( '#editor' ), {
 		plugins: [ CKFinder, ... ],
-		toolbar: [ 'ckfinder', ... ]
+		toolbar: [ 'ckfinder', 'imageUpload' ... ], // Depending on your preference.
 		ckfinder: {
 			// Feature configuration.
 		}
@@ -45,11 +78,13 @@ ClassicEditor
 
 ## Configuration
 
-The feature can be configured using the {@link module:ckfinder/ckfinder~CKFinderConfig `config.ckfinder`} object.
+The feature is configurable by using the {@link module:ckfinder/ckfinder~CKFinderConfig `config.ckfinder`} object.
 
-The file manager configuration can be passed through the {@link module:ckfinder/ckfinder~CKFinderConfig#options `config.ckfinder.options`} object. Check the {@link @ckfinder ckfinder3/#!/api/CKFinder.Config file manager documentation} for the complete list of options.
+### Configuring the image upload only
 
-For instance, the following code will configure the file manager to browse only the specified resource type (in this case: the images):
+This feature can upload images automatically to the server (e.g. when the image is dropped into the content) thanks to the {@link module:adapter-ckfinder/uploadadapter~CKFinderUploadAdapter CKFinder upload adapter}. All it requires is the correct {@link module:ckfinder/ckfinder~CKFinderConfig#uploadUrl `config.ckfinder.uploadUrl`} path.
+
+Assuming that the CKFinder server-side connector is {@link @ckfinder ckfinder3-php/quickstart.html#quickstart_installation_folders installed} (available) under `https://example.com/ckfinder/`, use the following {@link @ckfinder ckfinder3-php/commands.html#command_quick_upload quick upload} command URL to enable the image upload:
 
 ```js
 import CKFinder from '@ckeditor/ckeditor5-ckfinder/src/ckfinder';
@@ -57,28 +92,39 @@ import CKFinder from '@ckeditor/ckeditor5-ckfinder/src/ckfinder';
 ClassicEditor
 	.create( document.querySelector( '#editor' ), {
 		plugins: [ CKFinder, ... ],
-		toolbar: [ 'ckfinder', ... ]
+
+		// Enable the "Insert image" button in the toolbar.
+		toolbar: [ 'imageUpload', ... ],
+
 		ckfinder: {
-			options: {
-				resourceType: 'Images'
-			}
+			// Upload the images to the server using the CKFinder's QuickUpload command.
+			uploadUrl: 'https://example.com/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images&responseType=json'
 		}
 	} )
 	.then( ... )
 	.catch( ... );
 ```
 
-{@snippet features/ckfinder-options}
+See the **[demo of the image upload only](#image-upload-only)**.
 
-<info-box>
-	By default, the editor language is automatically passed to the file manager — the file manager "inherits" the language of the editor. This behavior can be changed by setting the `ckfinder.options.language` configuration option.
-</info-box>
+### Configuring the full integration
+
+To use both the image upload functionality and the CKFinder file manager user interface in your application, you must first load the CKFinder JavaScript library and then enable CKFinder integration in your editor instance.
 
-### Configuring image upload
+The easiest way to load CKFinder library include the `<script>` tag loading the `ckfinder.js` file first:
 
-This feature allows you to not only browse images, but also upload them automatically to the server (e.g. when the image is dropped into the content) thanks to the {@link module:adapter-ckfinder/uploadadapter~CKFinderUploadAdapter CKFinder upload adapter}. All it requires is the correct {@link module:ckfinder/ckfinder~CKFinderConfig#uploadUrl `config.ckfinder.uploadUrl`} path.
+```html
+<script src="https://example.com/ckfinder/ckfinder.js"></script>
+```
 
-Assuming that the CKFinder file manager is {@link @ckfinder ckfinder3-php/quickstart.html#quickstart_installation_folders installed} (accessible) under `https://example.com/ckfinder/`, use the following {@link @ckfinder ckfinder3-php/commands.html#command_quick_upload quick upload} command URL to enable the image upload:
+Then:
+
+* Make sure that the {@link module:ckfinder/ckfinder~CKFinder CKFinder plugin} for CKEditor 5 is enabled. See the [Installation](#installation) section.
+* In order to enable the automatic file upload to the server when an image is pasted or dropped into the editor content, remember to set the correct {@link module:ckfinder/ckfinder~CKFinderConfig#uploadUrl `config.ckfinder.uploadUrl`} path.
+* In order to display the toolbar button that opens the CKFinder file manager UI allowing users to choose files on the server, make sure `'ckfinder'` is present in your {@link module:core/editor/editorconfig~EditorConfig#toolbar `config.toolbar`}.
+* Additionally, you can use {@link module:ckfinder/ckfinder~CKFinderConfig#options `config.ckfinder.options`} to define {@link @ckfinder ckfinder3/#!/api/CKFinder.Config CKFinder's options}. For instance:
+	* You can define {@link @ckfinder ckfinder3/#!/api/CKFinder.Config-cfg-resourceType `options.resourceType`} to tell CKFinder the specified resource type can be browsed when the user uses the button.
+	* You can define {@link @ckfinder ckfinder3/#!/api/CKFinder.Config-cfg-resourceType `options.language`} to set the UI language of CKFinder. By default it will be set to the UI language of the editor.
 
 ```js
 import CKFinder from '@ckeditor/ckeditor5-ckfinder/src/ckfinder';
@@ -86,17 +132,27 @@ import CKFinder from '@ckeditor/ckeditor5-ckfinder/src/ckfinder';
 ClassicEditor
 	.create( document.querySelector( '#editor' ), {
 		plugins: [ CKFinder, ... ],
+
+		// Enable the CKFinder button in the toolbar.
 		toolbar: [ 'ckfinder', ... ]
+
 		ckfinder: {
 			// Upload the images to the server using the CKFinder's QuickUpload command.
-			uploadUrl: 'https://example.com/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images&responseType=json'
+			uploadUrl: 'https://example.com/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images&responseType=json',
+
+			// Define CKFinder's configuration (if necessary).
+			options: {
+				resourceType: 'Images'
+			}
 		}
 	} )
 	.then( ... )
 	.catch( ... );
 ```
 
-### Configuring the opener
+See the **[demo of the full integration](#full-integration)**.
+
+#### Configuring the opener
 
 You can change the way the CKFinder file manager opens using the {@link module:ckfinder/ckfinder~CKFinderConfig#openerMethod `config.ckfinder.openerMethod`} option.
 
@@ -131,6 +187,12 @@ The {@link module:ckfinder/ckfinder~CKFinder} plugin registers:
 	editor.execute( 'ckfinder' );
 	```
 
+Additionally, in the "image upload only" integration, you can use the following button and command registered by the {@link module:image/imageupload~ImageUpload} plugin:
+
+* the `'imageUpload'` UI button component,
+* the `'imageUpload'` command implemented by the {@link module:image/imageupload/imageuploadcommand~ImageUploadCommand}.
+
 ## Contribute
 
 The source code of the feature is available on GitHub in https://github.com/ckeditor/ckeditor5-ckfinder.
+

+ 10 - 2
packages/ckeditor5-ckfinder/src/ckfinder.js

@@ -14,12 +14,20 @@ import CKFinderEditing from './ckfinderediting';
 import CKFinderUploadAdapter from '@ckeditor/ckeditor5-adapter-ckfinder/src/uploadadapter';
 
 /**
- * The CKFinder feature.
+ * The CKFinder feature, a bridge between the CKEditor 5 WYSIWYG editor and the
+ * [CKFinder](https://ckeditor.com/ckfinder) file manager and uploader.
  *
  * This is a "glue" plugin which enables:
  *
  * * {@link module:ckfinder/ckfinderediting~CKFinderEditing},
- * * {@link module:ckfinder/ckfinderui~CKFinderUI}.
+ * * {@link module:ckfinder/ckfinderui~CKFinderUI},
+ * * {@link module:adapter-ckfinder/uploadadapter~CKFinderUploadAdapter}.
+ *
+ * See the {@glink features/ckfinder "CKFinder integration" guide} to learn how to configure
+ * and use this feature.
+ *
+ * Check out the {@glink features/image-upload comprehensive "Image upload" guide} to learn about
+ * other ways to upload images into CKEditor 5.
  *
  * @extends module:core/plugin~Plugin
  */