| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- /**
- * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
- /* globals ClassicEditor, window, document */
- const restrictedModeButton = document.getElementById( 'mode-restricted' );
- const standardModeButton = document.getElementById( 'mode-standard' );
- restrictedModeButton.addEventListener( 'change', handleModeChange );
- standardModeButton.addEventListener( 'change', handleModeChange );
- startMode( document.querySelector( 'input[name="editor-restriction-mode"]:checked' ).value );
- async function handleModeChange( evt ) {
- await startMode( evt.target.value );
- }
- async function startMode( selectedMode ) {
- if ( selectedMode === 'standard' ) {
- await startStandardEditingMode();
- } else {
- await startRestrictedEditingMode();
- }
- }
- async function startStandardEditingMode() {
- await reloadEditor( {
- removePlugins: [ 'RestrictedEditingMode' ],
- toolbar: [
- 'heading', '|', 'bold', 'italic', 'link', '|',
- 'bulletedList', 'numberedList', 'blockQuote', 'insertTable', '|',
- 'restrictedEditingException', '|', 'undo', 'redo'
- ],
- image: {
- toolbar: [ 'imageStyle:full', 'imageStyle:side', '|', 'imageTextAlternative' ]
- },
- table: {
- contentToolbar: [
- 'tableColumn',
- 'tableRow',
- 'mergeTableCells'
- ]
- }
- } );
- }
- async function startRestrictedEditingMode() {
- await reloadEditor( {
- removePlugins: [ 'StandardEditingMode' ],
- toolbar: [ 'bold', 'italic', 'link', '|', 'restrictedEditing', '|', 'undo', 'redo' ]
- } );
- }
- async function reloadEditor( config ) {
- if ( window.editor ) {
- await window.editor.destroy();
- }
- window.editor = await ClassicEditor.create( document.querySelector( '#restricted-editing-editor' ), config );
- }
|