Skip to content

Commit 83e9980

Browse files
committed
Merge branch 't/13337b' into major
2 parents ab16bc5 + b8deb7d commit 83e9980

20 files changed

+157
-16
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ New Features:
77

88
* [#13304](http://dev.ckeditor.com/ticket/13304): Added support for passing DOM elements to [`config.sharedSpaces`](http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-sharedSpaces). Thanks to [Undergrounder](https://github.com/Undergrounder)!
99
* [#13215](http://dev.ckeditor.com/ticket/13215): Added ability to cancel fetching a resource by the Embed plugins.
10+
* [#13337](http://dev.ckeditor.com/ticket/13337): Added the [`repository.onWidget()`](http://docs.ckeditor.com/#!/api/CKEDITOR.plugins.widget.repository-method-onWidget) method – a convenient way to listen to [widget](http://docs.ckeditor.com/#!/api/CKEDITOR.plugins.widget) events through the [repository](http://docs.ckeditor.com/#!/api/CKEDITOR.plugins.widget.repository).
1011

1112
Fixed Issues:
1213

plugins/widget/plugin.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,46 @@
540540
return newInstances;
541541
},
542542

543+
/**
544+
* Allows to listen to events on specific types of widgets, even if they are not created yet.
545+
*
546+
* Please note that this method inherits parameters from the {@link CKEDITOR.event#method-on} method with one
547+
* extra parameter at the beginning which is a widget name.
548+
*
549+
* editor.widgets.onWidget( 'image', 'action', function( evt ) {
550+
* // Event `action` occurs on `image` widget.
551+
* } );
552+
*
553+
* @since 4.5
554+
* @param {String} widgetName
555+
* @param {String} eventName
556+
* @param {Function} listenerFunction
557+
* @param {Object} [scopeObj]
558+
* @param {Object} [listenerData]
559+
* @param {Number} [priority=10]
560+
*/
561+
onWidget: function( widgetName ) {
562+
var args = Array.prototype.slice.call( arguments );
563+
564+
args.shift();
565+
566+
for ( var i in this.instances ) {
567+
var instance = this.instances[ i ];
568+
569+
if ( instance.name == widgetName ) {
570+
instance.on.apply( instance, args );
571+
}
572+
}
573+
574+
this.on( 'instanceCreated', function( evt ) {
575+
var widget = evt.data;
576+
577+
if ( widget.name == widgetName ) {
578+
widget.on.apply( widget, args );
579+
}
580+
} );
581+
},
582+
543583
/**
544584
* Parses element classes string and returns an object
545585
* whose keys contain class names. Skips all `cke_*` classes.

tests/plugins/widget/acf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* bender-tags: editor,unit,widgetcore */
1+
/* bender-tags: widgetcore */
22
/* bender-ckeditor-plugins: widget,toolbar,clipboard */
33
/* bender-include: _helpers/tools.js */
44
/* global widgetTestsTools */

tests/plugins/widget/activefilter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* bender-tags: editor,unit,widgetcore */
1+
/* bender-tags: widgetcore */
22
/* bender-ckeditor-plugins: widget,undo,basicstyles,clipboard,dialog,link,toolbar,stylescombo,font,colorbutton,language,indentblock */
33
/* bender-include: _helpers/tools.js */
44
/* global widgetTestsTools */

tests/plugins/widget/checkdirty.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* bender-tags: editor,unit,widgetcore */
1+
/* bender-tags: widgetcore */
22
/* bender-ckeditor-plugins: widget */
33
/* bender-include: _helpers/tools.js */
44
/* global widgetTestsTools */

tests/plugins/widget/contextmenu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* bender-tags: editor,unit,widgetcore */
1+
/* bender-tags: widgetcore */
22
/* bender-ckeditor-plugins: widget,contextmenu */
33
/* bender-include: _helpers/tools.js */
44
/* global widgetTestsTools */

tests/plugins/widget/customstylehandler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* bender-tags: editor,unit,widgetcore */
1+
/* bender-tags: widgetcore */
22
/* bender-ckeditor-plugins: widget */
33
/* bender-include: _helpers/tools.js */
44
/* global widgetTestsTools */

tests/plugins/widget/definition.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* bender-tags: editor,unit,widgetcore */
1+
/* bender-tags: widgetcore */
22
/* bender-ckeditor-plugins: widget,undo */
33
/* bender-include: _helpers/tools.js */
44
/* global widgetTestsTools */

tests/plugins/widget/dnd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* bender-tags: editor,unit,widgetcore */
1+
/* bender-tags: widgetcore */
22
/* bender-ckeditor-plugins: widget,undo,clipboard */
33
/* bender-include: _helpers/tools.js */
44
/* global widgetTestsTools, lineutilsTestsTools */

tests/plugins/widget/editing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* bender-tags: editor,unit,widgetcore */
1+
/* bender-tags: widgetcore */
22
/* bender-ckeditor-plugins: widget,dialog */
33
/* bender-include: _helpers/tools.js */
44
/* global widgetTestsTools */

0 commit comments

Comments
 (0)