porting 7.6-rc1 into 8
This commit is contained in:
@@ -172,8 +172,17 @@ tinymce.PluginManager.add('umbracolink', function(editor) {
|
||||
|
||||
//locallink detection, we do this here, to avoid poluting the dialogservice
|
||||
//so the dialog service can just expect to get a node-like structure
|
||||
if(currentTarget.url.indexOf("localLink:") > 0){
|
||||
currentTarget.id = currentTarget.url.substring(currentTarget.url.indexOf(":")+1,currentTarget.url.length-1);
|
||||
if (currentTarget.url.indexOf("localLink:") > 0) {
|
||||
var linkId = currentTarget.url.substring(currentTarget.url.indexOf(":") + 1, currentTarget.url.length - 1);
|
||||
//we need to check if this is an INT or a UDI
|
||||
var parsedIntId = parseInt(linkId, 10);
|
||||
if (isNaN(parsedIntId)) {
|
||||
//it's a UDI
|
||||
currentTarget.udi = linkId;
|
||||
}
|
||||
else {
|
||||
currentTarget.id = linkId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,27 +191,34 @@ 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 hasUdi = data.udi ? true : false;
|
||||
var id = hasUdi ? data.udi : (data.id ? data.id : null);
|
||||
|
||||
//Create a json obj used to create the attributes for the tag
|
||||
function createElemAttributes() {
|
||||
var a = {
|
||||
href: href,
|
||||
title: data.name,
|
||||
target: data.target ? data.target : null,
|
||||
rel: data.rel ? data.rel : null
|
||||
};
|
||||
if (hasUdi) {
|
||||
a["data-udi"] = data.udi;
|
||||
}
|
||||
else if (data.id) {
|
||||
a["data-id"] = data.id;
|
||||
}
|
||||
}
|
||||
|
||||
function insertLink() {
|
||||
if (anchorElm) {
|
||||
dom.setAttribs(anchorElm, {
|
||||
href: href,
|
||||
title: data.name,
|
||||
target: data.target ? data.target : null,
|
||||
rel: data.rel ? data.rel : null,
|
||||
'data-id': data.id ? data.id : null
|
||||
});
|
||||
dom.setAttribs(anchorElm, createElemAttributes());
|
||||
|
||||
selection.select(anchorElm);
|
||||
editor.execCommand('mceEndTyping');
|
||||
} else {
|
||||
editor.execCommand('mceInsertLink', false, {
|
||||
href: href,
|
||||
title: data.name,
|
||||
target: data.target ? data.target : null,
|
||||
rel: data.rel ? data.rel : null,
|
||||
'data-id': data.id ? data.id : null
|
||||
});
|
||||
editor.execCommand('mceInsertLink', false, createElemAttributes());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,9 +228,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)){
|
||||
href = "/{localLink:" + data.id + "}";
|
||||
insertLink();
|
||||
if (id && (angular.isUndefined(data.isMedia) || !data.isMedia)){
|
||||
|
||||
href = "/{localLink:" + id + "}";
|
||||
|
||||
insertLink();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user