| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- /**
- * @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 window, document */
- import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
- import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
- import Table from '@ckeditor/ckeditor5-table/src/table';
- import RestrictedEditingException from '../../src/restrictededitingexception';
- import RestrictedEditing from '../../src/restrictedediting';
- const restrictedModeButton = document.getElementById( 'mode-restricted' );
- const standardModeButton = document.getElementById( 'mode-standard' );
- const currentModeDisplay = document.getElementById( 'current-mode' );
- enableSwitchToStandardMode();
- enableSwitchToRestrictedMode();
- function enableSwitchToRestrictedMode() {
- restrictedModeButton.removeAttribute( 'disabled' );
- restrictedModeButton.addEventListener( 'click', startRestrictedMode );
- }
- function enableSwitchToStandardMode() {
- standardModeButton.removeAttribute( 'disabled' );
- standardModeButton.addEventListener( 'click', startStandardMode );
- }
- async function startStandardMode() {
- standardModeButton.removeEventListener( 'click', startStandardMode );
- standardModeButton.setAttribute( 'disabled', 'disabled' );
- await reloadEditor( {
- plugins: [ ArticlePluginSet, Table, RestrictedEditingException ],
- toolbar: [
- 'heading', '|', 'bold', 'italic', 'link', '|',
- 'bulletedList', 'numberedList', 'blockQuote', 'insertTable', '|',
- 'restrictedEditingException', '|', 'undo', 'redo'
- ],
- image: {
- toolbar: [ 'imageStyle:full', 'imageStyle:side', '|', 'imageTextAlternative' ]
- },
- table: {
- contentToolbar: [
- 'tableColumn',
- 'tableRow',
- 'mergeTableCells'
- ]
- }
- } );
- currentModeDisplay.innerHTML = 'Current Mode: <span class="mode mode-standard">STANDARD</span>';
- enableSwitchToRestrictedMode();
- }
- async function startRestrictedMode() {
- restrictedModeButton.removeEventListener( 'click', startRestrictedMode );
- restrictedModeButton.setAttribute( 'disabled', 'disabled' );
- await reloadEditor( {
- plugins: [ ArticlePluginSet, Table, RestrictedEditing ],
- toolbar: [ 'bold', 'italic', 'link', '|', 'restrictedEditing', '|', 'undo', 'redo' ]
- } );
- currentModeDisplay.innerHTML = 'Current Mode: <span class="mode mode-restricted">RESTRICTED</span>';
- enableSwitchToStandardMode();
- }
- async function reloadEditor( config ) {
- if ( window.editor ) {
- await window.editor.destroy();
- }
- window.editor = await ClassicEditor.create( document.querySelector( '#editor' ), config );
- }
|