From f816f19d601d2011e66cc2a8e0a7723c8a923d31 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 11 Oct 2018 14:25:33 +0200 Subject: [PATCH] Fixes some issues for rte --- src/Umbraco.Web.UI.Client/bower.json | 12 +-- .../propertyeditors/rte/rte.controller.js | 82 +++++++++---------- 2 files changed, 48 insertions(+), 46 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/bower.json b/src/Umbraco.Web.UI.Client/bower.json index 61b54f6c1c..084cb1816a 100644 --- a/src/Umbraco.Web.UI.Client/bower.json +++ b/src/Umbraco.Web.UI.Client/bower.json @@ -78,11 +78,13 @@ "bower_components/angular-local-storage/dist/angular-local-storage.min.js", "bower_components/angular-local-storage/dist/angular-local-storage.min.js.map" ], - "tinymce": [ - "bower_components/tinymce/tinymce.min.js", - "bower_components/tinymce/skins/*", - "bower_components/tinymce/themes/*" - ], + "tinymce": { + "mapping": [ + { "bower_components/tinymce/skins/**": "skins" }, + { "bower_components/tinymce/themes/**": "themes" }, + { "bower_components/tinymce/tinymce.min.js": "tinymce.min.js" } + ] + }, "angular-i18n": "bower_components/angular-i18n/angular-locale_*.js", "typeahead.js": "bower_components/typeahead.js/dist/typeahead.bundle.min.js", "rgrove-lazyload": "bower_components/rgrove-lazyload/lazyload.js", diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/rte/rte.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/rte/rte.controller.js index 4232e30e07..52aa19b659 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/rte/rte.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/rte/rte.controller.js @@ -1,6 +1,6 @@ angular.module("umbraco") .controller("Umbraco.PropertyEditors.RTEController", - function ($rootScope, $scope, $q, $locale, dialogService, $log, imageHelper, assetsService, $timeout, tinyMceService, angularHelper, stylesheetResource, macroService, editorState) { + function ($scope, $q, assetsService, $timeout, tinyMceService, angularHelper, editorService, macroService, editorState) { //TODO: A lot of the code below should be shared between the grid rte and the normal rte @@ -15,49 +15,49 @@ angular.module("umbraco") function syncContent(editor) { - //stop watching before we update the value - stopWatch(); + //stop watching before we update the value + stopWatch(); angularHelper.safeApply($scope, function () { $scope.model.value = editor.getContent(); }); - //re-watch the value - startWatch(editor); - } - - var unwatch = null; - - /** - * Starts a watch on the model value so that we can update TinyMCE if the model changes behind the scenes or from the server - * @param {any} editor - */ - function startWatch(editor) { - unwatch = $scope.$watch("model.value", function (newVal, oldVal) { - if (newVal !== oldVal) { - //update the display val again if it has changed from the server; - //uses an empty string in the editor when the value is null - editor.setContent(newVal || "", { format: 'raw' }); - - //we need to manually fire this event since it is only ever fired based on loading from the DOM, this - // is required for our plugins listening to this event to execute - editor.fire('LoadContent', null); - } - }); - } - - /** Stops the watch on model.value which is done anytime we are manually updating the model.value */ - function stopWatch() { - if (unwatch) { - unwatch(); + //re-watch the value + startWatch(editor); } - } - + var unwatch = null; + + /** + * Starts a watch on the model value so that we can update TinyMCE if the model changes behind the scenes or from the server + * @param {any} editor + */ + function startWatch(editor) { + unwatch = $scope.$watch("model.value", function (newVal, oldVal) { + if (newVal !== oldVal) { + //update the display val again if it has changed from the server; + //uses an empty string in the editor when the value is null + editor.setContent(newVal || "", { format: 'raw' }); + + //we need to manually fire this event since it is only ever fired based on loading from the DOM, this + // is required for our plugins listening to this event to execute + editor.fire('LoadContent', null); + } + }); + } + + /** Stops the watch on model.value which is done anytime we are manually updating the model.value */ + function stopWatch() { + if (unwatch) { + unwatch(); + } + } + + var editorConfig = $scope.model.config.editor; if (!editorConfig || angular.isString(editorConfig)) { editorConfig = tinyMceService.defaultPrevalues(); } - + var promises = []; if (!editorConfig.maxImageSize && editorConfig.maxImageSize != 0) { editorConfig.maxImageSize = tinyMceService.defaultPrevalues().maxImageSize; @@ -132,7 +132,7 @@ angular.module("umbraco") tinyMceService.insertLinkInEditor(editor, model.target, anchorElement); editorService.close(); }, - close: function() { + close: function () { editorService.close(); } }; @@ -152,7 +152,7 @@ angular.module("umbraco") tinyMceService.insertMediaInEditor(editor, model.selectedImages[0]); editorService.close(); }, - close: function() { + close: function () { editorService.close(); } }; @@ -162,11 +162,11 @@ angular.module("umbraco") //Create the embedded plugin tinyMceService.createInsertEmbeddedMedia(editor, $scope, function () { var embed = { - submit: function(model) { + submit: function (model) { tinyMceService.insertEmbeddedMediaInEditor(editor, model.embed.preview); editorService.close(); }, - close: function() { + close: function () { editorService.close(); } }; @@ -183,7 +183,7 @@ angular.module("umbraco") tinyMceService.insertMacroInEditor(editor, macroObject, $scope); editorService.close(); }, - close: function() { + close: function () { editorService.close(); } }; @@ -208,7 +208,7 @@ angular.module("umbraco") } loadTinyMce(); - + //listen for formSubmitting event (the result is callback used to remove the event subscription) var unsubscribe = $scope.$on("formSubmitting", function () { //TODO: Here we should parse out the macro rendered content so we can save on a lot of bytes in data xfer @@ -227,7 +227,7 @@ angular.module("umbraco") tinyMceEditor.destroy() } }); - + }); });