/
inline-editor.js
56 lines (50 loc) · 1.35 KB
/
inline-editor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
/* globals console, window, document */
import InlineEditor from '@ckeditor/ckeditor5-build-inline/src/ckeditor';
import { CS_CONFIG } from '@ckeditor/ckeditor5-cloud-services/tests/_utils/cloud-services-config';
const inlineInjectElements = document.querySelectorAll( '#snippet-inline-editor [data-inline-inject]' );
Array.from( inlineInjectElements ).forEach( inlineElement => {
const config = {
toolbar: {
viewportTopOffset: window.getViewportTopOffsetConfig()
},
cloudServices: CS_CONFIG
};
if ( inlineElement.tagName.toLowerCase() == 'header' ) {
config.removePlugins = [
'Blockquote',
'Image',
'ImageCaption',
'ImageStyle',
'ImageToolbar',
'ImageUpload',
'List',
'EasyImage',
'CKFinder',
'CKFinderUploadAdapter'
];
config.toolbar.items = [ 'heading', '|', 'bold', 'italic', 'link' ];
} else {
config.image = {
toolbar: [
'imageStyle:inline',
'imageStyle:wrapText',
'imageStyle:breakText',
'|',
'toggleImageCaption',
'imageTextAlternative'
]
};
}
InlineEditor
.create( inlineElement, config )
.then( editor => {
window.editor = editor;
} )
.catch( err => {
console.error( err );
} );
} );