Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Fix the plugins & configuration of documentation snippets.
Browse files Browse the repository at this point in the history
  • Loading branch information
jodator committed Jul 22, 2019
1 parent 63834d8 commit a0a8e6e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 30 deletions.
2 changes: 2 additions & 0 deletions docs/_snippets/framework/build-extending-content-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

import ClassicEditor from '@ckeditor/ckeditor5-build-classic/src/ckeditor';
import Code from '@ckeditor/ckeditor5-basic-styles/src/code';
import Font from '@ckeditor/ckeditor5-font/src/font';

ClassicEditor.builtinPlugins.push( Code );
ClassicEditor.builtinPlugins.push( Font );

window.ClassicEditor = ClassicEditor;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
/* globals ClassicEditor, console, window, document */

import { CS_CONFIG } from '@ckeditor/ckeditor5-cloud-services/tests/_utils/cloud-services-config';
import Font from '@ckeditor/ckeditor5-font/src/font';

function HandleFontSizeValue( editor ) {
// Add special catch-all converter for font-size feature.
Expand Down Expand Up @@ -51,7 +50,7 @@ function HandleFontSizeValue( editor ) {
ClassicEditor
.create( document.querySelector( '#snippet-arbitrary-attribute-values' ), {
cloudServices: CS_CONFIG,
extraPlugins: [ Font, HandleFontSizeValue ],
extraPlugins: [ HandleFontSizeValue ],
toolbar: {
items: [ 'heading', '|', 'bold', 'italic', '|', 'fontSize' ],
viewportTopOffset: window.getViewportTopOffsetConfig()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,20 @@
/* globals ClassicEditor, console, window, document */

import { CS_CONFIG } from '@ckeditor/ckeditor5-cloud-services/tests/_utils/cloud-services-config';
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';

/**
* Plugin that converts custom attributes for elements that are wrapped in <figure> in the view.
*/
class CustomFigureAttributes extends Plugin {
init() {
const editor = this.editor;
function CustomFigureAttributes( editor ) {
// Define on which elements the css classes should be preserved:
setupCustomClassConversion( 'img', 'image', editor );
setupCustomClassConversion( 'table', 'table', editor );

// Define on wchich elements the css classes should be preserved:
setupCustomClassConversion( 'img', 'image', editor );
setupCustomClassConversion( 'table', 'table', editor );
editor.conversion.for( 'upcast' ).add( upcastCustomClasses( 'figure' ), { priority: 'low' } );

editor.conversion.for( 'upcast' ).add( upcastCustomClasses( 'figure' ), { priority: 'low' } );

// Define custom attributes that should be preserved.
setupCustomAttributeConversion( 'img', 'image', 'id', editor );
setupCustomAttributeConversion( 'table', 'table', 'id', editor );
}
// Define custom attributes that should be preserved.
setupCustomAttributeConversion( 'img', 'image', 'id', editor );
setupCustomAttributeConversion( 'table', 'table', 'id', editor );
}

/**
Expand Down
24 changes: 9 additions & 15 deletions docs/framework/guides/deep-dive/extending-content.md
Original file line number Diff line number Diff line change
Expand Up @@ -722,15 +722,13 @@ function HandleFontSizeValue( editor ) {
Activate the plugin in the editor:

```js
import Font from '@ckeditor/ckeditor5-font/src/font';

ClassicEditor
.create( ..., {
items: [ 'heading', '|', 'bold', 'italic', '|', 'fontSize' ],
fontsize: {
options: [ 10, 12, 14, 'default', 18, 20, 22 ]
},
extraPlugins: [ Font, HandleFontSizeValue ],
extraPlugins: [ HandleFontSizeValue ],
} )
.then( editor => {
// ...
Expand All @@ -756,20 +754,16 @@ The sample below is extensible - to add own attributes to preserve just add anot
/**
* Plugin that converts custom attributes for elements that are wrapped in <figure> in the view.
*/
class CustomFigureAttributes extends Plugin {
init() {
const editor = this.editor;

// Define on wchich elements the css classes should be preserved:
setupCustomClassConversion( 'img', 'image', editor );
setupCustomClassConversion( 'table', 'table', editor );
function CustomFigureAttributes( editor ) {
// Define on which elements the css classes should be preserved:
setupCustomClassConversion( 'img', 'image', editor );
setupCustomClassConversion( 'table', 'table', editor );

editor.conversion.for( 'upcast' ).add( upcastCustomClasses( 'figure' ), { priority: 'low' } );
editor.conversion.for( 'upcast' ).add( upcastCustomClasses( 'figure' ), { priority: 'low' } );

// Define custom attributes that should be preserved.
setupCustomAttributeConversion( 'img', 'image', 'id', editor );
setupCustomAttributeConversion( 'table', 'table', 'id', editor );
}
// Define custom attributes that should be preserved.
setupCustomAttributeConversion( 'img', 'image', 'id', editor );
setupCustomAttributeConversion( 'table', 'table', 'id', editor );
}

/**
Expand Down

0 comments on commit a0a8e6e

Please sign in to comment.