diff --git a/docs/_snippets/builds/saving-data/autosave.html b/docs/_snippets/builds/saving-data/autosave.html new file mode 100644 index 00000000000..4f578e73cb8 --- /dev/null +++ b/docs/_snippets/builds/saving-data/autosave.html @@ -0,0 +1,111 @@ +
Test me!
+Server data:
+ +
+
+
+
+
diff --git a/docs/_snippets/builds/saving-data/autosave.js b/docs/_snippets/builds/saving-data/autosave.js
new file mode 100644
index 00000000000..d189953b050
--- /dev/null
+++ b/docs/_snippets/builds/saving-data/autosave.js
@@ -0,0 +1,67 @@
+/**
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* globals ClassicEditor, console, window, document, setTimeout */
+
+import { CS_CONFIG } from '@ckeditor/ckeditor5-cloud-services/tests/_utils/cloud-services-config';
+
+let HTTP_SERVER_LAG = 500;
+
+document.querySelector( '#snippet-autosave-lag' ).addEventListener( 'change', evt => {
+ HTTP_SERVER_LAG = evt.target.value;
+} );
+
+ClassicEditor
+ .create( document.querySelector( '#snippet-autosave' ), {
+ cloudServices: CS_CONFIG,
+ toolbar: {
+ viewportTopOffset: 60
+ },
+ autosave: {
+ save( editor ) {
+ return saveData( editor.getData() );
+ }
+ }
+ } )
+ .then( editor => {
+ window.editor = editor;
+
+ displayStatus( editor );
+ } )
+ .catch( err => {
+ console.error( err.stack );
+ } );
+
+function saveData( data ) {
+ return new Promise( resolve => {
+ // Fake HTTP server's lag.
+ setTimeout( () => {
+ log( data );
+
+ resolve();
+ }, HTTP_SERVER_LAG );
+ } );
+}
+
+function displayStatus( editor ) {
+ const pendingActions = editor.plugins.get( 'PendingActions' );
+ const statusIndicator = document.querySelector( '.snippet-autosave-status' );
+ const console = document.querySelector( '#snippet-autosave-console' );
+
+ pendingActions.on( 'change:hasAny', ( evt, propertyName, newValue ) => {
+ if ( newValue ) {
+ statusIndicator.classList.add( 'busy' );
+ console.classList.remove( 'received' );
+ } else {
+ statusIndicator.classList.remove( 'busy' );
+ console.classList.add( 'received' );
+ }
+ } );
+}
+
+function log( msg ) {
+ const console = document.querySelector( '#snippet-autosave-console' );
+ console.textContent = msg;
+}
diff --git a/docs/_snippets/builds/saving-data/build-autosave-source.html b/docs/_snippets/builds/saving-data/build-autosave-source.html
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/docs/_snippets/builds/saving-data/build-autosave-source.js b/docs/_snippets/builds/saving-data/build-autosave-source.js
new file mode 100644
index 00000000000..ec7ee316dca
--- /dev/null
+++ b/docs/_snippets/builds/saving-data/build-autosave-source.js
@@ -0,0 +1,14 @@
+/**
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* globals window */
+
+import ClassicEditor from '@ckeditor/ckeditor5-build-classic/src/ckeditor';
+
+import Autosave from '@ckeditor/ckeditor5-autosave/src/autosave';
+
+ClassicEditor.builtinPlugins.push( Autosave );
+
+window.ClassicEditor = ClassicEditor;
diff --git a/docs/_snippets/builds/saving-data/manualsave.html b/docs/_snippets/builds/saving-data/manualsave.html
new file mode 100644
index 00000000000..c3cc0da57c2
--- /dev/null
+++ b/docs/_snippets/builds/saving-data/manualsave.html
@@ -0,0 +1,92 @@
+Test me!
+Server data:
+ +
+
+
+
+
diff --git a/docs/_snippets/builds/saving-data/manualsave.js b/docs/_snippets/builds/saving-data/manualsave.js
new file mode 100644
index 00000000000..b03b07e3fae
--- /dev/null
+++ b/docs/_snippets/builds/saving-data/manualsave.js
@@ -0,0 +1,106 @@
+/**
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* globals ClassicEditor, console, window, document, setTimeout */
+
+import { CS_CONFIG } from '@ckeditor/ckeditor5-cloud-services/tests/_utils/cloud-services-config';
+
+let HTTP_SERVER_LAG = 500;
+let isDirty = false;
+
+document.querySelector( '#snippet-manual-lag' ).addEventListener( 'change', evt => {
+ HTTP_SERVER_LAG = evt.target.value;
+} );
+
+ClassicEditor
+ .create( document.querySelector( '#snippet-manual' ), {
+ cloudServices: CS_CONFIG,
+ toolbar: {
+ viewportTopOffset: 60
+ }
+ } )
+ .then( editor => {
+ window.editor = editor;
+
+ handleStatusChanges( editor );
+ handleSaveButton( editor );
+ handleBeforeunload( editor );
+ } )
+ .catch( err => {
+ console.error( err.stack );
+ } );
+
+// Handle clicking the "Save" button.
+function handleSaveButton( editor ) {
+ const saveButton = document.querySelector( '#snippet-manual-save' );
+ const pendingActions = editor.plugins.get( 'PendingActions' );
+
+ saveButton.addEventListener( 'click', evt => {
+ const data = editor.getData();
+ const action = pendingActions.add( 'Saving in progress.' );
+
+ evt.preventDefault();
+
+ // Fake HTTP server's lag.
+ setTimeout( () => {
+ log( data );
+
+ pendingActions.remove( action );
+
+ // Reset isDirty only if data didn't change in the meantime.
+ if ( data == editor.getData() ) {
+ isDirty = false;
+ }
+
+ updateStatus( editor );
+ }, HTTP_SERVER_LAG );
+ } );
+}
+
+function handleStatusChanges( editor ) {
+ const pendingActions = editor.plugins.get( 'PendingActions' );
+
+ pendingActions.on( 'change:hasAny', () => updateStatus( editor ) );
+
+ editor.model.document.on( 'change:data', () => {
+ isDirty = true;
+
+ updateStatus( editor );
+ } );
+}
+
+function handleBeforeunload( editor ) {
+ window.addEventListener( 'beforeunload', evt => {
+ if ( editor.plugins.get( 'PendingActions' ).hasAny ) {
+ evt.preventDefault();
+ }
+ } );
+}
+
+function updateStatus( editor ) {
+ const saveButton = document.querySelector( '#snippet-manual-save' );
+
+ if ( isDirty ) {
+ saveButton.classList.add( 'active' );
+ } else {
+ saveButton.classList.remove( 'active' );
+ }
+
+ if ( editor.plugins.get( 'PendingActions' ).hasAny ) {
+ document.querySelector( '#snippet-manual-save-console' ).classList.remove( 'received' );
+ saveButton.value = 'Saving...';
+ saveButton.classList.add( 'saving' );
+ } else {
+ saveButton.value = 'Save';
+ saveButton.classList.remove( 'saving' );
+ }
+}
+
+function log( msg ) {
+ const console = document.querySelector( '#snippet-manual-save-console' );
+
+ console.classList.add( 'received' );
+ console.textContent = msg;
+}
diff --git a/docs/builds/guides/development/installing-plugins.md b/docs/builds/guides/development/installing-plugins.md
index d0162d356eb..d57241905ba 100644
--- a/docs/builds/guides/development/installing-plugins.md
+++ b/docs/builds/guides/development/installing-plugins.md
@@ -186,35 +186,34 @@ All this works because a typical `src/ckeditor.js` module that you can find in e
```js
import ClassicEditorBase from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
import EssentialsPlugin from '@ckeditor/ckeditor5-essentials/src/essentials';
-import UploadadapterPlugin from '@ckeditor/ckeditor5-adapter-ckfinder/src/uploadadapter';
+import UploadAdapterPlugin from '@ckeditor/ckeditor5-adapter-ckfinder/src/uploadadapter';
import AutoformatPlugin from '@ckeditor/ckeditor5-autoformat/src/autoformat';
import BoldPlugin from '@ckeditor/ckeditor5-basic-styles/src/bold';
import ItalicPlugin from '@ckeditor/ckeditor5-basic-styles/src/italic';
-import BlockquotePlugin from '@ckeditor/ckeditor5-block-quote/src/blockquote';
+import BlockQuotePlugin from '@ckeditor/ckeditor5-block-quote/src/blockquote';
// ...
export default class ClassicEditor extends ClassicEditorBase {}
-ClassicEditor.build = {
- plugins: [
- EssentialsPlugin,
- UploadadapterPlugin,
- AutoformatPlugin,
- BoldPlugin,
- ItalicPlugin,
- BlockquotePlugin,
- // ...
- ],
- config: {
- toolbar: {
- items: [
- 'heading',
- 'bold',
- // ...
- ]
- },
- // ...
- }
+ClassicEditor.builtInPlugins = [
+ EssentialsPlugin,
+ UploadAdapterPlugin,
+ AutoformatPlugin,
+ BoldPlugin,
+ ItalicPlugin,
+ BlockQuotePlugin,
+ // ...
+];
+
+ClassicEditor.defaultConfig = {
+ toolbar: {
+ items: [
+ 'heading',
+ 'bold',
+ // ...
+ ]
+ },
+ // ...
};
```
diff --git a/docs/builds/guides/integration/advanced-setup.md b/docs/builds/guides/integration/advanced-setup.md
index 13600c4fb21..2221d17a0e9 100644
--- a/docs/builds/guides/integration/advanced-setup.md
+++ b/docs/builds/guides/integration/advanced-setup.md
@@ -1,6 +1,6 @@
---
category: builds-integration
-order: 40
+order: 50
---
# Advanced setup
@@ -175,71 +175,69 @@ You can now import all the needed plugins and the creator directly into your cod
```js
import ClassicEditorBase from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
import EssentialsPlugin from '@ckeditor/ckeditor5-essentials/src/essentials';
-import UploadadapterPlugin from '@ckeditor/ckeditor5-adapter-ckfinder/src/uploadadapter';
+import UploadAdapterPlugin from '@ckeditor/ckeditor5-adapter-ckfinder/src/uploadadapter';
import AutoformatPlugin from '@ckeditor/ckeditor5-autoformat/src/autoformat';
import BoldPlugin from '@ckeditor/ckeditor5-basic-styles/src/bold';
import ItalicPlugin from '@ckeditor/ckeditor5-basic-styles/src/italic';
-import BlockquotePlugin from '@ckeditor/ckeditor5-block-quote/src/blockquote';
-import EasyimagePlugin from '@ckeditor/ckeditor5-easy-image/src/easyimage';
+import BlockQuotePlugin from '@ckeditor/ckeditor5-block-quote/src/blockquote';
+import EasyImagePlugin from '@ckeditor/ckeditor5-easy-image/src/easyimage';
import HeadingPlugin from '@ckeditor/ckeditor5-heading/src/heading';
import ImagePlugin from '@ckeditor/ckeditor5-image/src/image';
-import ImagecaptionPlugin from '@ckeditor/ckeditor5-image/src/imagecaption';
-import ImagestylePlugin from '@ckeditor/ckeditor5-image/src/imagestyle';
-import ImagetoolbarPlugin from '@ckeditor/ckeditor5-image/src/imagetoolbar';
-import ImageuploadPlugin from '@ckeditor/ckeditor5-image/src/imageupload';
+import ImageCaptionPlugin from '@ckeditor/ckeditor5-image/src/imagecaption';
+import ImageStylePlugin from '@ckeditor/ckeditor5-image/src/imagestyle';
+import ImageToolbarPlugin from '@ckeditor/ckeditor5-image/src/imagetoolbar';
+import ImageUploadPlugin from '@ckeditor/ckeditor5-image/src/imageupload';
import LinkPlugin from '@ckeditor/ckeditor5-link/src/link';
import ListPlugin from '@ckeditor/ckeditor5-list/src/list';
import ParagraphPlugin from '@ckeditor/ckeditor5-paragraph/src/paragraph';
export default class ClassicEditor extends ClassicEditorBase {}
-ClassicEditor.build = {
- plugins: [
- EssentialsPlugin,
- UploadadapterPlugin,
- AutoformatPlugin,
- BoldPlugin,
- ItalicPlugin,
- BlockquotePlugin,
- EasyimagePlugin,
- HeadingPlugin,
- ImagePlugin,
- ImagecaptionPlugin,
- ImagestylePlugin,
- ImagetoolbarPlugin,
- ImageuploadPlugin,
- LinkPlugin,
- ListPlugin,
- ParagraphPlugin
- ],
- config: {
- toolbar: {
- items: [
- 'heading',
- '|',
- 'bold',
- 'italic',
- 'link',
- 'bulletedList',
- 'numberedList',
- 'imageUpload',
- 'blockQuote',
- 'undo',
- 'redo'
- ]
- },
- image: {
- toolbar: [
- 'imageStyle:full',
- 'imageStyle:side',
- '|',
- 'imageTextAlternative'
- ]
- },
- language: 'en'
- }
+ClassicEditor.builtinPlugins = [
+ EssentialsPlugin,
+ UploadAdapterPlugin,
+ AutoformatPlugin,
+ BoldPlugin,
+ ItalicPlugin,
+ BlockQuotePlugin,
+ EasyImagePlugin,
+ HeadingPlugin,
+ ImagePlugin,
+ ImageCaptionPlugin,
+ ImageStylePlugin,
+ ImageToolbarPlugin,
+ ImageUploadPlugin,
+ LinkPlugin,
+ ListPlugin,
+ ParagraphPlugin
+];
+
+ClassicEditor.defaultConfig = {
+ toolbar: {
+ items: [
+ 'heading',
+ '|',
+ 'bold',
+ 'italic',
+ 'link',
+ 'bulletedList',
+ 'numberedList',
+ 'imageUpload',
+ 'blockQuote',
+ 'undo',
+ 'redo'
+ ]
+ },
+ image: {
+ toolbar: [
+ 'imageStyle:full',
+ 'imageStyle:side',
+ '|',
+ 'imageTextAlternative'
+ ]
+ },
+ language: 'en'
};
-
```
This module will export an editor creator class which has all the plugins and configuration that you need already built-in. To use such editor, simply import that class and call the static `.create()` method like in all {@link builds/guides/integration/basic-api#creating-an-editor examples}.
@@ -265,18 +263,18 @@ The second variant how to run the editor is to use the creator class directly, w
```js
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
import EssentialsPlugin from '@ckeditor/ckeditor5-essentials/src/essentials';
-import UploadadapterPlugin from '@ckeditor/ckeditor5-adapter-ckfinder/src/uploadadapter';
+import UploadAdapterPlugin from '@ckeditor/ckeditor5-adapter-ckfinder/src/uploadadapter';
import AutoformatPlugin from '@ckeditor/ckeditor5-autoformat/src/autoformat';
import BoldPlugin from '@ckeditor/ckeditor5-basic-styles/src/bold';
import ItalicPlugin from '@ckeditor/ckeditor5-basic-styles/src/italic';
-import BlockquotePlugin from '@ckeditor/ckeditor5-block-quote/src/blockquote';
-import EasyimagePlugin from '@ckeditor/ckeditor5-easy-image/src/easyimage';
+import BlockQuotePlugin from '@ckeditor/ckeditor5-block-quote/src/blockquote';
+import EasyImagePlugin from '@ckeditor/ckeditor5-easy-image/src/easyimage';
import HeadingPlugin from '@ckeditor/ckeditor5-heading/src/heading';
import ImagePlugin from '@ckeditor/ckeditor5-image/src/image';
-import ImagecaptionPlugin from '@ckeditor/ckeditor5-image/src/imagecaption';
-import ImagestylePlugin from '@ckeditor/ckeditor5-image/src/imagestyle';
-import ImagetoolbarPlugin from '@ckeditor/ckeditor5-image/src/imagetoolbar';
-import ImageuploadPlugin from '@ckeditor/ckeditor5-image/src/imageupload';
+import ImageCaptionPlugin from '@ckeditor/ckeditor5-image/src/imagecaption';
+import ImageStylePlugin from '@ckeditor/ckeditor5-image/src/imagestyle';
+import ImageToolbarPlugin from '@ckeditor/ckeditor5-image/src/imagetoolbar';
+import ImageUploadPlugin from '@ckeditor/ckeditor5-image/src/imageupload';
import LinkPlugin from '@ckeditor/ckeditor5-link/src/link';
import ListPlugin from '@ckeditor/ckeditor5-list/src/list';
import ParagraphPlugin from '@ckeditor/ckeditor5-paragraph/src/paragraph';
@@ -289,12 +287,12 @@ ClassicEditor
AutoformatPlugin,
BoldPlugin,
ItalicPlugin,
- BlockquotePlugin,
+ BlockQuotePlugin,
HeadingPlugin,
ImagePlugin,
- ImagecaptionPlugin,
- ImagestylePlugin,
- ImagetoolbarPlugin,
+ ImageCaptionPlugin,
+ ImageStylePlugin,
+ ImageToolbarPlugin,
LinkPlugin,
ListPlugin,
ParagraphPlugin
diff --git a/docs/builds/guides/integration/configuration.md b/docs/builds/guides/integration/configuration.md
index d0b264b9cfd..1d73af525a5 100644
--- a/docs/builds/guides/integration/configuration.md
+++ b/docs/builds/guides/integration/configuration.md
@@ -59,7 +59,7 @@ ClassicEditor
Each build has a number of plugins available. You can easily list all plugins available in your build:
```js
-ClassicEditor.build.plugins.map( plugin => plugin.pluginName );
+ClassicEditor.builtinPlugins.map( plugin => plugin.pluginName );
```
## Adding features
diff --git a/docs/builds/guides/integration/saving-data.md b/docs/builds/guides/integration/saving-data.md
new file mode 100644
index 00000000000..46a1ace25c5
--- /dev/null
+++ b/docs/builds/guides/integration/saving-data.md
@@ -0,0 +1,313 @@
+---
+category: builds-integration
+order: 40
+---
+
+{@snippet builds/saving-data/build-autosave-source}
+
+# Getting and saving data
+
+CKEditor 5 allows you to retrieve and save the data to your server (or to your system in general) in various ways. In this guide you can learn about the options and their pros and cons.
+
+## Automatic integration with HTML forms
+
+This is the most classical way of integrating the editor. It is typically used in simpler CMSes, forums, comment sections, etc.
+
+This approach is only available in the {@link builds/guides/overview#classic-editor Classic editor} and only if it was used to replace a `