From db6eba758f395da76439ee9add0f85f2648f0b49 Mon Sep 17 00:00:00 2001 From: Kamil Piechaczek Date: Mon, 11 Apr 2022 11:44:03 +0200 Subject: [PATCH 1/6] Aligned to API to using new version of the CKEditor 5. --- src/ckeditorinspector.js | 17 ++++++++++ src/editorquickactions.js | 13 +++++++- tests/inspector/ckeditorinspector.js | 49 +++++++++++++++++++++++++--- 3 files changed, 74 insertions(+), 5 deletions(-) diff --git a/src/ckeditorinspector.js b/src/ckeditorinspector.js index d34e4e5..d727cea 100644 --- a/src/ckeditorinspector.js +++ b/src/ckeditorinspector.js @@ -77,6 +77,23 @@ export default class CKEditorInspector { * with generated editor names. */ static attach( ...args ) { + const { CKEDITOR_VERSION } = window; + + if ( CKEDITOR_VERSION ) { + const [ major ] = CKEDITOR_VERSION.split( '.' ).map( Number ); + + if ( major < 34 ) { + Logger.warn( + '[CKEditorInspector] The inspector requires using CKEditor 5 in version 34 or higher. ' + + 'If you cannot update CKEditor 5, consider downgrading the major version of the inspector to version 3.' + ); + } + } else { + Logger.warn( + '[CKEditorInspector] Could not determine a version of CKEditor 5. Some of the functionalities may not work as expected.' + ); + } + const { editors, options } = normalizeArguments( args ); for ( const editorName in editors ) { diff --git a/src/editorquickactions.js b/src/editorquickactions.js index b05569e..612bab0 100644 --- a/src/editorquickactions.js +++ b/src/editorquickactions.js @@ -21,6 +21,8 @@ import CheckmarkIcon from './assets/img/checkmark.svg'; import './editorquickactions.css'; +const INSPECTOR_READ_ONLY_LOCK_ID = 'Lock from Inspector (@ckeditor/ckeditor5-inspector)'; + class EditorQuickActions extends Component { constructor( props ) { super( props ); @@ -32,6 +34,7 @@ class EditorQuickActions extends Component { this._keyDownHandler = this._handleKeyDown.bind( this ); this._keyUpHandler = this._handleKeyUp.bind( this ); + this._readOnlyHandler = this._handleReadOnly.bind( this ); this._editorDataJustCopiedTimeout = null; } @@ -50,7 +53,7 @@ class EditorQuickActions extends Component { icon={} isOn={this.props.isReadOnly} isEnabled={!!this.props.editor} - onClick={() => { this.props.editor.isReadOnly = !this.props.editor.isReadOnly; }} + onClick={this._readOnlyHandler} />