Open URLs in Selection/Draft

Posted by Chris Grieser, Last update 28 days ago

If text is selected, opens on URLs in the selection.

If no text is selection, opens all URLs in the whole draft.


  • script

    //checks ether there is an in selection at the moment
    if (editor.getSelectedText() == "") {
    	var textToCheck = draft.content; 
    } else {
    	var textToCheck = editor.getSelectedText();
    //identifies URL and opens all
    let matches = textToCheck.match(/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/ig); // URL-Regex from
    if (matches != null){
    	for (i = 0; i < matches.length; i++) {
    } else {
    	app.displayErrorMessage("No URL found");


  • After Success Nothing
    Notification Error
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.