From 3f3db006e78badd0852efbc46c3e82ca71c36ed3 Mon Sep 17 00:00:00 2001 From: mikkelhm Date: Tue, 21 Mar 2017 14:43:54 +0100 Subject: [PATCH] When selecting a local link, also update the data-id to be the udi --- .../tinymce/plugins/umbracolink/plugin.min.js | 22 +++++++++---------- .../src/common/services/tinymce.service.js | 17 ++++++-------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/lib/tinymce/plugins/umbracolink/plugin.min.js b/src/Umbraco.Web.UI.Client/lib/tinymce/plugins/umbracolink/plugin.min.js index 37e22e3739..9d80e310de 100644 --- a/src/Umbraco.Web.UI.Client/lib/tinymce/plugins/umbracolink/plugin.min.js +++ b/src/Umbraco.Web.UI.Client/lib/tinymce/plugins/umbracolink/plugin.min.js @@ -191,7 +191,9 @@ tinymce.PluginManager.add('umbracolink', function(editor) { callback: function (data) { if (data) { var href = data.url; - + // We want to use the Udi. If it is set, we use it, else fallback to id, and finally to null + var id = data.udi ? data.udi : (data.id ? data.id : null); + function insertLink() { if (anchorElm) { dom.setAttribs(anchorElm, { @@ -199,7 +201,7 @@ tinymce.PluginManager.add('umbracolink', function(editor) { title: data.name, target: data.target ? data.target : null, rel: data.rel ? data.rel : null, - 'data-id': data.id ? data.id : null + 'data-id': id }); selection.select(anchorElm); @@ -210,7 +212,7 @@ tinymce.PluginManager.add('umbracolink', function(editor) { title: data.name, target: data.target ? data.target : null, rel: data.rel ? data.rel : null, - 'data-id': data.id ? data.id : null + 'data-id': id }); } } @@ -221,15 +223,11 @@ tinymce.PluginManager.add('umbracolink', function(editor) { } //if we have an id, it must be a locallink:id, aslong as the isMedia flag is not set - if(data.id && (angular.isUndefined(data.isMedia) || !data.isMedia)){ - if (data.udi) { - href = "/{localLink:" + data.udi + "}"; - } - else { - //This shouldn't happen! but just in case we'll leave this here - href = "/{localLink:" + data.id + "}"; - } - insertLink(); + if (id && (angular.isUndefined(data.isMedia) || !data.isMedia)){ + + href = "/{localLink:" + id + "}"; + + insertLink(); return; } diff --git a/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js b/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js index 8676ac5b34..d08b21b89c 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js @@ -725,6 +725,8 @@ function tinyMceService(dialogService, $log, imageHelper, $http, $timeout, macro insertLinkInEditor: function(editor, target, anchorElm) { var href = target.url; + // We want to use the Udi. If it is set, we use it, else fallback to id, and finally to null + var id = target.udi ? target.udi : (target.id ? target.id : null); function insertLink() { if (anchorElm) { @@ -733,7 +735,7 @@ function tinyMceService(dialogService, $log, imageHelper, $http, $timeout, macro title: target.name, target: target.target ? target.target : null, rel: target.rel ? target.rel : null, - 'data-id': target.id ? target.id : null + 'data-id': id }); editor.selection.select(anchorElm); @@ -744,7 +746,7 @@ function tinyMceService(dialogService, $log, imageHelper, $http, $timeout, macro title: target.name, target: target.target ? target.target : null, rel: target.rel ? target.rel : null, - 'data-id': target.id ? target.id : null + 'data-id': id }); } } @@ -755,14 +757,9 @@ function tinyMceService(dialogService, $log, imageHelper, $http, $timeout, macro } //if we have an id, it must be a locallink:id, aslong as the isMedia flag is not set - if(target.id && (angular.isUndefined(target.isMedia) || !target.isMedia)){ - if (target.udi) { - href = "/{localLink:" + target.udi + "}"; - } - else { - //This shouldn't happen! but just in case we'll leave this here - href = "/{localLink:" + target.id + "}"; - } + if(id && (angular.isUndefined(target.isMedia) || !target.isMedia)){ + + href = "/{localLink:" + id + "}"; insertLink(); return;