Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ckeditor/ckeditor5-widget

Package Overview
Dependencies
Maintainers
1
Versions
703
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ckeditor/ckeditor5-widget - npm Package Compare versions

Comparing version 1.0.0-alpha.1 to 1.0.0-alpha.2

12

CHANGELOG.md
Changelog
=========
## [1.0.0-alpha.2](https://github.com/ckeditor/ckeditor5-widget/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2017-11-14)
### Bug fixes
* The <kbd>Ctrl</kbd>+<kbd>A</kbd> keystroke will be now correctly handled when a widget is selected. Closes [#23](https://github.com/ckeditor/ckeditor5-widget/issues/23). ([3e8f91f](https://github.com/ckeditor/ckeditor5-widget/commit/3e8f91f))
* View element's `setAttribute()` method should be used with string values of the `contenteditable` attribute. Closes [#26](https://github.com/ckeditor/ckeditor5-widget/issues/26). ([d2a6cf5](https://github.com/ckeditor/ckeditor5-widget/commit/d2a6cf5))
### Other changes
* Widgets highlight remove handler will now use only descriptor id, instead of the full descriptor. ([1dfdc83](https://github.com/ckeditor/ckeditor5-widget/commit/1dfdc83))
## [1.0.0-alpha.1](https://github.com/ckeditor/ckeditor5-widget/compare/v0.2.0...v1.0.0-alpha.1) (2017-10-03)

@@ -5,0 +17,0 @@

29

package.json
{
"name": "@ckeditor/ckeditor5-widget",
"version": "1.0.0-alpha.1",
"version": "1.0.0-alpha.2",
"description": "Widget API for CKEditor 5.",

@@ -10,12 +10,12 @@ "keywords": [

"dependencies": {
"@ckeditor/ckeditor5-core": "^1.0.0-alpha.1",
"@ckeditor/ckeditor5-engine": "^1.0.0-alpha.1",
"@ckeditor/ckeditor5-utils": "^1.0.0-alpha.1",
"@ckeditor/ckeditor5-theme-lark": "^1.0.0-alpha.1"
"@ckeditor/ckeditor5-core": "^1.0.0-alpha.2",
"@ckeditor/ckeditor5-engine": "^1.0.0-alpha.2",
"@ckeditor/ckeditor5-utils": "^1.0.0-alpha.2",
"@ckeditor/ckeditor5-theme-lark": "^1.0.0-alpha.2"
},
"devDependencies": {
"@ckeditor/ckeditor5-dev-lint": "^3.1.4",
"eslint": "^4.8.0",
"eslint-config-ckeditor5": "^1.0.6",
"gulp": "^3.9.1",
"guppy-pre-commit": "^0.4.0"
"husky": "^0.14.3",
"lint-staged": "^4.2.3"
},

@@ -38,3 +38,16 @@ "engines": {

"theme"
],
"scripts": {
"lint": "eslint --quiet '**/*.js'",
"precommit": "lint-staged"
},
"lint-staged": {
"**/*.js": [
"eslint --quiet"
]
},
"eslintIgnore": [
"src/lib/**",
"packages/**"
]
}

@@ -57,9 +57,9 @@ /**

* @fires change:top
* @param {module:engine/conversion/model-to-view-converters~HighlightDescriptor} descriptor
* @param {String} id Id of the descriptor to remove.
*/
remove( descriptor ) {
remove( id ) {
const stack = this._stack;
const oldTop = stack[ 0 ];
this._removeDescriptor( descriptor );
this._removeDescriptor( id );
const newTop = stack[ 0 ];

@@ -112,7 +112,7 @@

* @private
* @param {module:engine/conversion/model-to-view-converters~HighlightDescriptor} descriptor
* @param {String} id Descriptor's id.
*/
_removeDescriptor( descriptor ) {
_removeDescriptor( id ) {
const stack = this._stack;
const index = stack.findIndex( item => item.id === descriptor.id );
const index = stack.findIndex( item => item.id === id );

@@ -119,0 +119,0 @@ // If descriptor with same id is on the list - remove it.

@@ -41,3 +41,3 @@ /**

* Converts given {@link module:engine/view/element~Element} to widget in following way:
* * sets `contenteditable` attribute to `true`,
* * sets `contenteditable` attribute to `"true"`,
* * adds custom `getFillerOffset` method returning `null`,

@@ -55,3 +55,3 @@ * * adds `ck-widget` CSS class,

export function toWidget( element, options = {} ) {
element.setAttribute( 'contenteditable', false );
element.setAttribute( 'contenteditable', 'false' );
element.getFillerOffset = getFillerOffset;

@@ -101,3 +101,3 @@ element.addClass( WIDGET_CLASS_NAME );

element.setCustomProperty( 'addHighlight', ( element, descriptor ) => stack.add( descriptor ) );
element.setCustomProperty( 'removeHighlight', ( element, descriptor ) => stack.remove( descriptor ) );
element.setCustomProperty( 'removeHighlight', ( element, id ) => stack.remove( id ) );
}

@@ -147,7 +147,7 @@

// Set initial contenteditable value.
editable.setAttribute( 'contenteditable', !editable.isReadOnly );
editable.setAttribute( 'contenteditable', editable.isReadOnly ? 'false' : 'true' );
// Bind contenteditable property to element#isReadOnly.
editable.on( 'change:isReadOnly', ( evt, property, is ) => {
editable.setAttribute( 'contenteditable', !is );
editable.setAttribute( 'contenteditable', is ? 'false' : 'true' );
} );

@@ -154,0 +154,0 @@

@@ -47,3 +47,9 @@ /**

let previouslySelected;
/**
* Holds previously selected widgets.
*
* @private
* @type {Set.<module:engine/view/element~Element>}
*/
this._previouslySelected = new Set();

@@ -53,19 +59,23 @@ // Model to view selection converter.

this.editor.editing.modelToView.on( 'selection', ( evt, data, consumable, conversionApi ) => {
// Remove selected class from previously selected widget.
if ( previouslySelected && previouslySelected.hasClass( WIDGET_SELECTED_CLASS_NAME ) ) {
previouslySelected.removeClass( WIDGET_SELECTED_CLASS_NAME );
}
// Remove selected class from previously selected widgets.
this._clearPreviouslySelectedWidgets();
const viewSelection = conversionApi.viewSelection;
// Check if widget was clicked or some sub-element.
const selectedElement = viewSelection.getSelectedElement();
if ( !selectedElement || !isWidget( selectedElement ) ) {
return;
for ( const range of viewSelection.getRanges() ) {
for ( const value of range ) {
const node = value.item;
if ( node.is( 'element' ) && isWidget( node ) ) {
node.addClass( WIDGET_SELECTED_CLASS_NAME );
this._previouslySelected.add( node );
// Check if widget is a single element selected.
if ( node == selectedElement ) {
viewSelection.setFake( true, { label: getLabel( selectedElement ) } );
}
}
}
}
viewSelection.setFake( true, { label: getLabel( selectedElement ) } );
selectedElement.addClass( WIDGET_SELECTED_CLASS_NAME );
previouslySelected = selectedElement;
}, { priority: 'low' } );

@@ -141,3 +151,3 @@

} else if ( isSelectAllKeyCode( domEventData ) ) {
wasHandled = this._selectAllNestedEditableContent();
wasHandled = this._selectAllNestedEditableContent() || this._selectAllContent();
}

@@ -263,2 +273,32 @@

/**
* 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 modelDocument = this.editor.document;
const modelSelection = modelDocument.selection;
const editing = this.editor.editing;
const viewDocument = editing.view;
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 );
modelDocument.enqueueChanges( () => {
modelSelection.setRanges( [ ModelRange.createIn( widgetParent ) ] );
} );
return true;
}
return false;
}
/**
* Sets {@link module:engine/model/selection~Selection document's selection} over given element.

@@ -300,2 +340,14 @@ *

}
/**
* Removes CSS class from previously selected widgets.
* @private
*/
_clearPreviouslySelectedWidgets() {
for ( const widget of this._previouslySelected ) {
widget.removeClass( WIDGET_SELECTED_CLASS_NAME );
}
this._previouslySelected.clear();
}
}

@@ -302,0 +354,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc