How to add a link to a document Alfresco in TinyMCE Editor

Pubblicato da lentux-informatica il

  •  
  •  
  •  
  •  
  •  

In this post shows how to insert a link to documents Alfresco in Tinymce editor with javascript.

Index.jsp

tinymce.init({
mode : "textareas",
theme : "advanced",
....
file_browser_callback : 'myFileBrowser',
....
})
function myFileBrowser (field_name, url, type, win) {
var cmsURL = window.location;
tinyMCE.activeEditor.windowManager.open({
 file : cmsURL.protocol+"//"+cmsURL.host+"/contenteditor-app/dashboard.do?action=internalLinks",
 title : 'Inserimento Link Alfresco',
 width : 600,
 height : 300,
 resizable : "yes",
 inline : "yes",
 close_previous : "no"
}, {
 window : win,
 input : field_name
});
return false;
}

Controller.java

@RequestMapping(params = "action=internalLinks")
      public ModelAndView showInternalLinks() {
       return new ModelAndView("file");
}

file.jsp (This is the page that I see when I click the button addLink in TinyMce).

<script type="text/javascript"
src="<%=request.getContextPath()%>/TinyMce/tiny_mce/tiny_mce_popup.js">
</script>

<script language=”javascript” type=”text/javascript”>
var FileBrowserDialogue = {
init : function() {
// Here goes your code for setting your custom things onLoad.
},
mySubmit : function() {
var URL = document.my_form.documentId.value;
var win = tinyMCEPopup.getWindowArg(“window”);
// insert information now
win.document.getElementById(tinyMCEPopup.getWindowArg(“input”)).value = URL;
// close popup window
tinyMCEPopup.close();
}
}

tinyMCEPopup.onInit.add(FileBrowserDialogue.init, FileBrowserDialogue);

$(document).ready( function() {
$(‘#linknavigator’).fileTree( {
root : ‘null’,
script : ‘dashboard.do?action=navigateLinks’
}, function(documentViewUrl, childrensId) {
$(‘#documentId’).val(documentViewUrl);
});
});
</script>




<div id=”linknavigator”>Naviga</div>

<div>
<form name=”my_form”><input id=”documentId” name=”documentId”
type=”hidden” value=”” /> <input type=”button” value=”Aggiungi”
onClick=
FileBrowserDialogue.mySubmit();;
></form>
</div>

gallery thumbnail
For more information or if you need the complete guide contact.


  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •