@ckeditor/ckeditor5-widget
Advanced tools
Comparing version 18.0.0 to 19.0.0
Changelog | ||
========= | ||
## [19.0.0](https://github.com/ckeditor/ckeditor5-widget/compare/v18.0.0...v19.0.0) (2020-04-29) | ||
### MINOR BREAKING CHANGES | ||
* Make sure the latest version of the [`Essentials`](https://ckeditor.com/docs/ckeditor5/latest/api/essentials.html) plugin or the [`SelectAll`](https://ckeditor.com/docs/ckeditor5/latest/api/module_select-all_selectall-SelectAll.html) plugin is installed in your integration. Either is required for proper keystroke handling in editor widgets. | ||
### Bug fixes | ||
* Image resize now cleans up temporary view `width` style changes. Closes [ckeditor/ckeditor5#6060](https://github.com/ckeditor/ckeditor5/issues/6060). ([92226f9](https://github.com/ckeditor/ckeditor5-widget/commit/92226f9)) | ||
### Other changes | ||
* Moved the <kbd>Ctrl</kbd>+<kbd>A</kbd> keystroke handling in widgets to the [`SelectAll`](https://ckeditor.com/docs/ckeditor5/latest/api/module_select-all_selectall-SelectAll.html) plugin (see [ckeditor/ckeditor5#6536](https://github.com/ckeditor/ckeditor5/issues/6536)). ([57eb263](https://github.com/ckeditor/ckeditor5-widget/commit/57eb263)) | ||
* Updated translations. ([79d1a21](https://github.com/ckeditor/ckeditor5-widget/commit/79d1a21)) | ||
## [18.0.0](https://github.com/ckeditor/ckeditor5-widget/compare/v17.0.0...v18.0.0) (2020-03-19) | ||
@@ -5,0 +21,0 @@ |
{ | ||
"name": "@ckeditor/ckeditor5-widget", | ||
"version": "18.0.0", | ||
"version": "19.0.0", | ||
"description": "Widget API for CKEditor 5.", | ||
@@ -12,21 +12,21 @@ "keywords": [ | ||
"dependencies": { | ||
"@ckeditor/ckeditor5-core": "^18.0.0", | ||
"@ckeditor/ckeditor5-engine": "^18.0.0", | ||
"@ckeditor/ckeditor5-ui": "^18.0.0", | ||
"@ckeditor/ckeditor5-utils": "^18.0.0", | ||
"@ckeditor/ckeditor5-core": "^19.0.0", | ||
"@ckeditor/ckeditor5-engine": "^19.0.0", | ||
"@ckeditor/ckeditor5-ui": "^19.0.0", | ||
"@ckeditor/ckeditor5-utils": "^19.0.0", | ||
"lodash-es": "^4.17.10" | ||
}, | ||
"devDependencies": { | ||
"@ckeditor/ckeditor5-basic-styles": "^18.0.0", | ||
"@ckeditor/ckeditor5-block-quote": "^18.0.0", | ||
"@ckeditor/ckeditor5-clipboard": "^18.0.0", | ||
"@ckeditor/ckeditor5-editor-balloon": "^18.0.0", | ||
"@ckeditor/ckeditor5-editor-classic": "^18.0.0", | ||
"@ckeditor/ckeditor5-enter": "^18.0.0", | ||
"@ckeditor/ckeditor5-essentials": "^18.0.0", | ||
"@ckeditor/ckeditor5-heading": "^18.0.0", | ||
"@ckeditor/ckeditor5-paragraph": "^18.0.0", | ||
"@ckeditor/ckeditor5-table": "^18.0.0", | ||
"@ckeditor/ckeditor5-typing": "^18.0.0", | ||
"@ckeditor/ckeditor5-undo": "^18.0.0", | ||
"@ckeditor/ckeditor5-basic-styles": "^19.0.0", | ||
"@ckeditor/ckeditor5-block-quote": "^19.0.0", | ||
"@ckeditor/ckeditor5-clipboard": "^19.0.0", | ||
"@ckeditor/ckeditor5-editor-balloon": "^19.0.0", | ||
"@ckeditor/ckeditor5-editor-classic": "^19.0.0", | ||
"@ckeditor/ckeditor5-enter": "^19.0.0", | ||
"@ckeditor/ckeditor5-essentials": "^19.0.0", | ||
"@ckeditor/ckeditor5-heading": "^19.0.0", | ||
"@ckeditor/ckeditor5-paragraph": "^19.0.0", | ||
"@ckeditor/ckeditor5-table": "^19.0.0", | ||
"@ckeditor/ckeditor5-typing": "^19.0.0", | ||
"@ckeditor/ckeditor5-undo": "^19.0.0", | ||
"eslint": "^5.5.0", | ||
@@ -33,0 +33,0 @@ "eslint-config-ckeditor5": "^2.0.0", |
@@ -12,3 +12,2 @@ /** | ||
import IconView from '@ckeditor/ckeditor5-ui/src/icon/iconview'; | ||
import env from '@ckeditor/ckeditor5-utils/src/env'; | ||
@@ -94,7 +93,3 @@ import dragHandleIcon from '../theme/icons/drag-handle.svg'; | ||
export function toWidget( element, writer, options = {} ) { | ||
// The selection on Edge behaves better when the whole editor contents is in a single contenteditable element. | ||
// https://github.com/ckeditor/ckeditor5/issues/1079 | ||
if ( !env.isEdge ) { | ||
writer.setAttribute( 'contenteditable', 'false', element ); | ||
} | ||
writer.setAttribute( 'contenteditable', 'false', element ); | ||
@@ -225,13 +220,9 @@ writer.addClass( WIDGET_CLASS_NAME, element ); | ||
// The selection on Edge behaves better when the whole editor contents is in a single contentedible element. | ||
// https://github.com/ckeditor/ckeditor5/issues/1079 | ||
if ( !env.isEdge ) { | ||
// Set initial contenteditable value. | ||
writer.setAttribute( 'contenteditable', editable.isReadOnly ? 'false' : 'true', editable ); | ||
// Set initial contenteditable value. | ||
writer.setAttribute( 'contenteditable', editable.isReadOnly ? 'false' : 'true', editable ); | ||
// Bind the contenteditable property to element#isReadOnly. | ||
editable.on( 'change:isReadOnly', ( evt, property, is ) => { | ||
writer.setAttribute( 'contenteditable', is ? 'false' : 'true', editable ); | ||
} ); | ||
} | ||
// Bind the contenteditable property to element#isReadOnly. | ||
editable.on( 'change:isReadOnly', ( evt, property, is ) => { | ||
writer.setAttribute( 'contenteditable', is ? 'false' : 'true', editable ); | ||
} ); | ||
@@ -238,0 +229,0 @@ editable.on( 'change:isFocused', ( evt, property, is ) => { |
@@ -13,3 +13,3 @@ /** | ||
import { getLabel, isWidget, WIDGET_SELECTED_CLASS_NAME } from './utils'; | ||
import { getCode, keyCodes, parseKeystroke } from '@ckeditor/ckeditor5-utils/src/keyboard'; | ||
import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard'; | ||
import env from '@ckeditor/ckeditor5-utils/src/env'; | ||
@@ -19,4 +19,2 @@ | ||
const selectAllKeystrokeCode = parseKeystroke( 'Ctrl+A' ); | ||
/** | ||
@@ -177,4 +175,2 @@ * The widget plugin. It enables base support for widgets. | ||
wasHandled = this._handleArrowKeys( isForward ); | ||
} else if ( isSelectAllKeyCode( domEventData ) ) { | ||
wasHandled = this._selectAllNestedEditableContent() || this._selectAllContent(); | ||
} else if ( keyCode === keyCodes.enter ) { | ||
@@ -313,56 +309,2 @@ wasHandled = this._handleEnterKey( domEventData.shiftKey ); | ||
/** | ||
* Extends the {@link module:engine/model/selection~Selection document's selection} to span the entire | ||
* content of the nested editable if already anchored in one. | ||
* | ||
* See: {@link module:engine/model/schema~Schema#getLimitElement}. | ||
* | ||
* @private | ||
*/ | ||
_selectAllNestedEditableContent() { | ||
const model = this.editor.model; | ||
const documentSelection = model.document.selection; | ||
const limitElement = model.schema.getLimitElement( documentSelection ); | ||
if ( documentSelection.getFirstRange().root == limitElement ) { | ||
return false; | ||
} | ||
model.change( writer => { | ||
writer.setSelection( writer.createRangeIn( limitElement ) ); | ||
} ); | ||
return true; | ||
} | ||
/** | ||
* Handles <kbd>CTRL + A</kbd> when widget is selected. | ||
* | ||
* @private | ||
* @returns {Boolean} Returns true if widget was selected and selecting all was handled by this method. | ||
*/ | ||
_selectAllContent() { | ||
const model = this.editor.model; | ||
const editing = this.editor.editing; | ||
const view = editing.view; | ||
const viewDocument = view.document; | ||
const viewSelection = viewDocument.selection; | ||
const selectedElement = viewSelection.getSelectedElement(); | ||
// Only widget is selected. | ||
// https://github.com/ckeditor/ckeditor5-widget/issues/23 | ||
if ( selectedElement && isWidget( selectedElement ) ) { | ||
const widgetParent = editing.mapper.toModelElement( selectedElement.parent ); | ||
model.change( writer => { | ||
writer.setSelection( writer.createRangeIn( widgetParent ) ); | ||
} ); | ||
return true; | ||
} | ||
return false; | ||
} | ||
/** | ||
* Sets {@link module:engine/model/selection~Selection document's selection} over given element. | ||
@@ -432,10 +374,2 @@ * | ||
// Returns 'true' if provided (DOM) key event data corresponds with the Ctrl+A keystroke. | ||
// | ||
// @param {module:engine/view/observer/keyobserver~KeyEventData} domEventData | ||
// @returns {Boolean} | ||
function isSelectAllKeyCode( domEventData ) { | ||
return getCode( domEventData ) == selectAllKeystrokeCode; | ||
} | ||
// Returns `true` when element is a nested editable or is placed inside one. | ||
@@ -442,0 +376,0 @@ // |
@@ -36,2 +36,5 @@ /** | ||
/** | ||
* @inheritDoc | ||
*/ | ||
init() { | ||
@@ -107,2 +110,5 @@ /** | ||
/** | ||
* @inheritDoc | ||
*/ | ||
destroy() { | ||
@@ -232,2 +238,4 @@ this._observer.stopListening(); | ||
/** | ||
* A view of an element to be resized. Typically it's the main widget's view instance. | ||
* | ||
* @member {module:engine/view/containerelement~ContainerElement} module:widget/widgetresize~ResizerOptions#viewElement | ||
@@ -234,0 +242,0 @@ */ |
@@ -74,2 +74,9 @@ /** | ||
/** | ||
* The width of the resized {@link module:widget/widgetresize~ResizerOptions#viewElement viewElement} before the resizing started. | ||
* | ||
* @private | ||
* @member {Number|String|undefined} #_initialViewWidth | ||
*/ | ||
/** | ||
* @observable | ||
@@ -143,2 +150,4 @@ */ | ||
this._initialViewWidth = this._options.viewElement.getStyle( 'width' ); | ||
this.state.begin( domResizeHandle, this._getHandleHost(), this._getResizeHost() ); | ||
@@ -193,5 +202,7 @@ } | ||
this._options.onCommit( newValue ); | ||
this._cleanup(); | ||
// Both cleanup and onCommit callback are very likely to make view changes. Ensure that it is made in a single step. | ||
this._options.editor.editing.view.change( () => { | ||
this._cleanup(); | ||
this._options.onCommit( newValue ); | ||
} ); | ||
} | ||
@@ -275,2 +286,8 @@ | ||
this._sizeUI.isVisible = false; | ||
const editingView = this._options.editor.editing.view; | ||
editingView.change( writer => { | ||
writer.setStyle( 'width', this._initialViewWidth, this._options.viewElement ); | ||
} ); | ||
} | ||
@@ -277,0 +294,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
125906
46
2051
+ Added@ckeditor/ckeditor5-core@19.0.1(transitive)
+ Added@ckeditor/ckeditor5-engine@19.0.1(transitive)
+ Added@ckeditor/ckeditor5-ui@19.0.1(transitive)
+ Added@ckeditor/ckeditor5-utils@19.0.2(transitive)
- Removed@ckeditor/ckeditor5-core@18.0.0(transitive)
- Removed@ckeditor/ckeditor5-engine@18.0.0(transitive)
- Removed@ckeditor/ckeditor5-ui@18.0.0(transitive)
- Removed@ckeditor/ckeditor5-utils@18.0.0(transitive)