From 0dc21eeeeecadc8e6d54d20cc0ca092a01de67ac Mon Sep 17 00:00:00 2001 From: Kapil Garg Date: Wed, 12 Aug 2020 15:33:51 +0530 Subject: [PATCH] circular dependency --- package.json | 6 ++++-- src/angular-froala.js | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bb534fd..ed5d957 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "Angular.js bindings for Froala WYSIWYG HTML rich text editor", "main": "src/angular-froala.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "start": "http-server -o" }, "repository": { "type": "git", @@ -49,6 +50,7 @@ }, "dependencies": { "coffee-script": "^1.12.7", - "froala-editor": "3.2.1" + "froala-editor": "3.2.1", + "http-server": "^0.12.3" } } diff --git a/src/angular-froala.js b/src/angular-froala.js index a54320a..cc93aba 100644 --- a/src/angular-froala.js +++ b/src/angular-froala.js @@ -98,11 +98,20 @@ }; }; + ctrl.clone = function(item) { + let eventData = item.events; + let newItem = JSON.parse(JSON.stringify(item)) + newItem.events = eventData; + return newItem + } + ctrl.createEditor = function(froalaInitOptions) { if (!ctrl.editorInitialized) { froalaInitOptions = (froalaInitOptions || {}); ctrl.options = angular.extend({}, defaultConfig, froalaConfig, scope.froalaOptions, froalaInitOptions); + ctrl.options = ctrl.clone(ctrl.options) + ctrl.registerEventsWithCallbacks('initializationDelayed', function() { ngModel.$render() });