This is a migrated thread and some comments may be shown as answers.

MOSSLinkManager

11 Answers 186 Views
WebParts for SharePoint
This is a migrated thread and some comments may be shown as answers.
Patrick Maeschli
Top achievements
Rank 1
Patrick Maeschli asked on 08 Sep 2011, 01:53 PM
Hi 

We used the telerik radeditor in SP2007. Now we migrated to SP2010 and also upgraded the radeditor to the current version.
Unfortunately the behaviour of the MOSSLinkmanager seems to have changed.

it seems that i can't add any target (_new) to the hyperlink and the title of the link can't be altered.

Also we tried to use the LinkManager, there the functionality increased drasticly but we are limited to the current site, and we can't navigate through the hierarchy.

any ideas how we can add this missing functionality so that our client will be happy again?

TIA
best regards 
patrick

11 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 08 Sep 2011, 02:22 PM
Hello Patrick,

I was able to achieve the requested functionality by copying the code of the MOSSLinkManager command from MOSSEditorTools.js to the MOSSImageManager / SPImageManager command in the SPEditorTools.js file. I also copied the Telerik_SP_SetDirectionOnElement function from the MOSSEditorTools.js to SPEditorTools.js.

Here are the updated functions:

Copy Code
Telerik.Web.UI.Editor.CommandList["MOSSLinkManager"] =
Telerik.Web.UI.Editor.CommandList["SPLinkManager"] = function (commandName, editor, args) {
var params = editor._dialogParameters;
var docEditor = editor.get_document();
var configObj = new AssetPickerConfig("");
configObj.ClientID = editor.get_id();
configObj.DefaultAssetLocation = "";
configObj.DefaultAssetImageLocation = "";
configObj.CurrentWebBaseUrl = params["CurrentWebBaseUrl"];
configObj.AllowExternalUrls = params["AllowExternalUrls"];
var bInserting = false;
var elemToReplace = null;
var linkAsset = new LinkAsset("");
var innerLinkHTML = null;
linkAsset.ManageLinkDisplayText = false;
var frameElementId = (editor.get_contentAreaMode() == Telerik.Web.UI.EditorContentAreaMode.Div) ? editor.get_contentArea().id : editor.get_contentWindow().frameElement.id;
var elemLink = FormJSRTE_GetNearestContainingParentElementOfTypes(frameElementId, editor.getSelectedElement(), new Array("A"));
if (!elemLink) {
bInserting = true;
elemLink = docEditor.createElement("A");
if (elemLink == null) return;
var editorSelection = editor.getSelection();
if (editorSelection.isControl()) {
elemToReplace = editor.getSelectedElement();
}
else {
innerLinkHTML = editorSelection.getHtml();
}
}
else {
innerLinkHTML = elemLink.innerHTML;
}
configObj.ReturnCallback = function (newAssetUrl, newAssetText, currentConfig, dialogReturnedData) {
if (dialogReturnedData) {
var linkText = "";
if ($telerik.isIE)
linkText = elemLink.innerText;
else
linkText = elemLink.textContent;
if (innerLinkHTML && innerLinkHTML != "") {
elemLink.innerHTML = innerLinkHTML;
}
else if (linkText == "") {
if (linkAsset.AssetText && linkAsset.AssetText != "") {
linkText = linkAsset.AssetText;
}
else {
linkText = linkAsset.AssetUrl;
}
elemLink.innerHTML += linkText;
}
if (elemToReplace != null) {
var parentEl = elemToReplace.parentNode;
elemLink.innerHTML = "";
parentEl.insertBefore(elemLink, elemToReplace);
elemLink.appendChild(elemToReplace);
linkAsset.FixupIconsAndEmptyAnchors(elemLink);
return;
}
else if (bInserting) {
var selection = docEditor.selection;
if (selection != null) {
var textRange = selection.createRange();
if (textRange != null) {
var text = textRange.text;
if (text && text != "" && !text.match(/^\s+$/)) {
textRange.execCommand("Unlink");
elemLink.innerHTML = textRange.htmlText;
linkAsset.FixupIconsAndEmptyAnchors(elemLink);
}
var tempDiv = docEditor.createElement("DIV");
tempDiv.appendChild(elemLink);
textRange.pasteHTML(tempDiv.innerHTML);
}
}
else {
//if we cannot get the selection, use the editor paste function instead
var tempDiv = docEditor.createElement("DIV");
var pNodes = elemLink.getElementsByTagName("P");
for (var i = 0, l = pNodes.length; i < l; i++) {
Telerik.Web.UI.Editor.Utils.removeNode(pNodes[i]);
}
tempDiv.appendChild(elemLink);
editor.pasteHtml(tempDiv.innerHTML, commandName);
tempDiv = null;
}
}
else {
linkAsset.FixupIconsAndEmptyAnchors(elemLink);
}
}
}
linkAsset.LaunchModalDialogOnElement(configObj, elemLink, true, !bInserting);
};
//this code belongs in form.js, however it is copied here as well since in some pages form.js is not loaded by default.
function FormJSRTE_GetNearestContainingParentElementOfTypes(strBaseElementID, elem, aTagNames) {
var aTagNames_length = aTagNames.length;
if (elem == null) return null;
for (var i = 0; i < aTagNames_length; i++) {
if (elem.tagName == aTagNames[i]) {
return elem;
}
}
var elemParent = elem.parentNode;
while (elemParent != null) {
if (elemParent.id == strBaseElementID) {
return null;
}
for (var i = 0; i < aTagNames_length; i++) {
if (elemParent.tagName == aTagNames[i]) {
return elemParent;
}
}
elemParent = elemParent.parentNode;
}
return null;
}

Here is a video demonstrating my test: http://screencast.com/t/w8Pcxfi89

Another option is to use the LinkManager of RadEditor (which offers open in new window) instead of the built-in SharePoint link manager. All you need to do is to open the ToolsFile.xml / ListToolsFile.xml files and replace the

<tool name="SPLinkManager" text="Insert Link" />

with

<tool name="LinkManager" text="Insert Link" />



Kind regards,
Rumen
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Harro
Top achievements
Rank 2
answered on 13 Jan 2012, 09:13 AM
Hello Rumen,

When I apply this code can a existing link also be edited?
What I mean is: Will the current settings of the link be shown in the dialog?

Regards,
Harro
0
Rumen
Telerik team
answered on 17 Jan 2012, 03:49 PM
Hi Harro,

Yes, you can edit an existing link and its attributes will be populated in the dialog as shown in the following video: http://screencast.com/t/ct0PDEuH3.

Best regards,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Harro
Top achievements
Rank 2
answered on 20 Jan 2012, 09:21 AM
Hello Rumen,

Thanks. That is exactly what I need. :)

Why is this solution not part of the default implementation?
It seems the default implementation has less functionality for inserting/editing links than the default RTE provided by SharePoint.

Regards,
Harro
0
Rumen
Telerik team
answered on 23 Jan 2012, 01:27 PM
Hi Harro,

The SPLinkManager tool of RadEditor for SharePoint 2010 opens the same link manager dialog which is loaded by the "Link" button of the default RTE provided by SharePoint 2010. You can see this in the following video: http://screencast.com/t/q0TVP1vZY21.

If you want to launch the Link manager of the default RTE of MOSS, you can use the solution provided in my earlier answers.

All the best,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Harro
Top achievements
Rank 2
answered on 23 Jan 2012, 01:43 PM
Hi Rumen,

That's correct.
But the default RTE of SharePoint 2010 is offering two options: "From SharePoint" and "From adress".
The first one is available in the RTE from Telerik, but the second one is missing.
In MOSS this was combined in the dialog that is used in your solution.

My point is: The default RTE is offering two options and the one from Telerik is offering only one.
Also the default RTE offers a toolbar for editing the link (when placing the cursor on the link) which is not present in the Telerik editor.

The reason for me to buy the Telerik Editor for SharePoint is to extend and improve the functionality of the RTE, but the options for working with links is by default less.
0
Rumen
Telerik team
answered on 25 Jan 2012, 05:47 PM
Hi,

RadEditor offers a dialog which is quite similar to the "From address" feature of the built-in Rich Text Editor of SharePoint. You can test the InsertLink dialog in the following demo: Dialogs.

All the best,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Harro Schmidt
Top achievements
Rank 1
answered on 27 Jan 2012, 04:04 PM
Hi Rumen,

Let me summarize things.

These are the options:
- By default the RadEditor for SharePoint 2010 opens the SharePoint browse dialog when clicking the 'Insert Link' button. (This dialog can't be used for normal links and does not support link properties)
- The RadEditor for SharePoint also support using the default Telerik LinkManager. (This dialog does not have the capability to browse the SharePoint site)
- You can change this behaviour by using the solution from the post (but if you upgrade the RadEditor this is lost and its a screen from MOSS, not SharePoint 2010)

What I'm trying to tell is that if you offer an editor which replaces the default SharePoint RTE, it must by default have at least the same functionality. That means that if you choose the 'Insert Link' button you must have a choice of choosing the link type. (Or add an extra button)
And if you select a link you must be able to edit it's properties.

Maybe I have to file a feature request for that?

Regards,
Harro
0
Rumen
Telerik team
answered on 27 Jan 2012, 08:08 PM
Hello,

Let me explain what RadEditor for SharePoint does offer for inserting and editing links in its content area:
  • SPLinkManager - which is based on the built-in link manager of SharePoint 2010
  • LinkManager - this is a built-in link manager of RadEditor
  • InsertLink - this is a lite version of the LinkManager with an option to open the LinkManager via a button.

The three tools could insert new links and edit already existing links (the first one can edit only the url by design) and you can add all of them too the toolbar by adding the following links to the C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\wpresources\RadEditorSharePoint\6.2.1.0__1f131a624888eeed\Resources\ToolsFile.xml | ListToolsFile.xml files:


<tool name="SPLinkManager" text="Insert Link" />
<tool name="LinkManager" text="Insert Link" />
<tool name="InsertLink" text="Insert Link Light" />

RadEditor for SharePoint offers yet another tool which you can use to edit existing links and it is the NodeInspector module:

<modules>
    <module name="RadEditorNodeInspector" />
</modules>


For your convenience I recorded a video how the above tools work: http://screencast.com/t/LT3M2Djplh.

If you would like you can also enable the built-in link manager of the default Rich Text editor of SharePoint 2007 (MOSS) by following the instructions provided in my post in this thread on 08-Sep-2011.

As for your last question: And if you select a link you must be able to edit it's properties. - Yes, I already answered above you can edit the existing links in all of the above tools.

If needed and if you wish you can see how to edit and customize these dialogs in the following article: ExternalDialogsPath property.

All the best,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Harro
Top achievements
Rank 2
answered on 30 Jan 2012, 09:00 AM
Hi Rumen,

Thanks, these are the functions I need.
The NodeInspector tool looks very useful.

Still I have one remark: Why are these functions and module not added to the default configuration of the RadEditor for SharePoint.
The problem is not that I don't know what the editor exactly can do, but that I can't say to a client of ours: "Here is the WSP, install it and you're ready." In the current situation you always have to modify the configuration to equal the default RTE of SharePoint.

Regards,
Harro
0
Rumen
Telerik team
answered on 30 Jan 2012, 03:33 PM
Hello,

If more people request this we will definitely add the full or light version of the Link Manager to the toolbar. As to the Node Inspector Module, the built-in editor of SharePoint 2010 does not offer such a tool and for this reason our is hidden by default so that there is enough space for the content area.

Greetings,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
WebParts for SharePoint
Asked by
Patrick Maeschli
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Harro
Top achievements
Rank 2
Harro Schmidt
Top achievements
Rank 1
Share this question
or