Skip to content

Commit

Permalink
Grid-RTE got a unique ID, which fixes TineMCE code, which is dependen…
Browse files Browse the repository at this point in the history
…t on a unique ID. #4011
  • Loading branch information
nielslyngsoe committed Feb 13, 2019
1 parent 988be21 commit 60fa931
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ angular.module("umbraco.directives")
// TODO: A lot of the code below should be shared between the grid rte and the normal rte

var promises = [];

var d = new Date();
var n = d.getTime();
scope.textAreaHtmlId = scope.uniqueId + "_" + n + "_rte";

//queue file loading
if (typeof (tinymce) === "undefined") {
Expand All @@ -28,7 +32,7 @@ angular.module("umbraco.directives")
var tinyMceEditor = null;

promises.push(tinyMceService.getTinyMceEditorConfig({
htmlId: scope.uniqueId,
htmlId: scope.textAreaHtmlId,
stylesheets: scope.configuration ? scope.configuration.stylesheets : null,
toolbar: toolbar,
mode: scope.configuration.mode
Expand Down Expand Up @@ -132,17 +136,11 @@ angular.module("umbraco.directives")
}

});

//listen for formSubmitting event (the result is callback used to remove the event subscription)
var formSubmittingListener = scope.$on("formSubmitting", function () {
scope.value = tinyMceEditor ? tinyMceEditor.getContent() : null;
});


//when the element is disposed we need to unsubscribe!
// NOTE: this is very important otherwise if this is part of a modal, the listener still exists because the dom
// element might still be there even after the modal has been hidden.
scope.$on('$destroy', function () {
formSubmittingListener();
eventsService.unsubscribe(tabShownListener);
//ensure we unbind this in case the blur doesn't fire above
$('.umb-panel-body').off('scroll', pinToolbar);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="umb-rte">
<div id="{{uniqueId}}"></div>
<div id="{{textAreaHtmlId}}"></div>
</div>

0 comments on commit 60fa931

Please sign in to comment.