From d44d3888801886444446aba9cdacf33f40f4bc1e Mon Sep 17 00:00:00 2001 From: brazorf Date: Mon, 30 Jan 2017 20:39:05 +0100 Subject: [PATCH] Feature: bind custom medium-editor event listeners. --- src/angular-medium-editor.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/angular-medium-editor.js b/src/angular-medium-editor.js index f7df3aa..6c4c3c9 100644 --- a/src/angular-medium-editor.js +++ b/src/angular-medium-editor.js @@ -16,7 +16,7 @@ angular.module('angular-medium-editor', []) return { require: 'ngModel', restrict: 'AE', - scope: { bindOptions: '=' }, + scope: { bindOptions: '=', eventsConfig: '=' }, link: function(scope, iElement, iAttrs, ngModel) { angular.element(iElement).addClass('angular-medium-editor'); @@ -45,6 +45,10 @@ angular.module('angular-medium-editor', []) ngModel.editor.subscribe('editableInput', function (event, editable) { ngModel.$setViewValue(editable.innerHTML.trim()); }); + + angular.forEach(scope.eventsConfig, function(callback, eventName){ + ngModel.editor.subscribe(eventName, callback); + }); scope.$watch('bindOptions', function(bindOptions) { ngModel.editor.init(iElement, bindOptions);