An Omni Automation action for OmniOutliner. Tap the “Install PlugIn” button to add to the OmniGraffle Automation menu on your device.
/*{
"type": "action",
"targets": ["omnioutliner"],
"author": "Otto Automator",
"description": "This action will create a new document in the Drafts app using the text from the outline.",
"label": "Drafts • New Draft with Outline Text",
"shortLabel": "Drafts Doc"
}*/
var _ = function(){
var action = new PlugIn.Action(function(selection, sender){
// action code
// selection options: columns, document, editor, items, nodes, outline, styles
var alert = new Alert("Item Spacing", "Use a single or double space between top-level items?")
alert.addOption("Single")
alert.addOption("Double")
alert.show(function(result){
if (result == 0){itemSpacer = ""} else {itemSpacer = "\n"}
var topics = new Array()
var indent = "\t"
rootItem.descendants.forEach(function(item,index){
level = item.level
if (level === 1){
if (index === 0){
itemString = item.topic
} else {
itemString = itemSpacer + item.topic
}
} else {
itemString = indent.repeat(level-1) + item.topic
}
topics.push(itemString)
})
outlineText = topics.join("\n")
encodedStr = encodeURIComponent(outlineText)
urlStr = "drafts5://x-callback-url/create?text=" + encodedStr
url = URL.fromString(urlStr)
url.call(function(result){console.log(result)})
})
});
action.validate = function(selection, sender){
// validation code
// selection options: columns, document, editor, items, nodes, outline, styles
if(rootItem.descendants.length > 0){return true} else {return false}
};
return action;
}();
_;
Outline Text to New Drafts Document
Copy Script Install Plug-In
01 /*{
02 "type" : "action" ,
03 "targets" : ["omnioutliner" ],
04 "author" : "Otto Automator" ,
05 "description" : "This action will create a new document in the Drafts app using the text from the outline." ,
06 "label" : "Drafts • New Draft with Outline Text" ,
07 "shortLabel" : "Drafts Doc"
08 }*/
09 var _ = function (){
10 var action = new PlugIn .Action (function (selection, sender){
11
12
13
14 var alert = new Alert ("Item Spacing" , "Use a single or double space between top-level items? ")
15 alert .addOption ("Single" )
16 alert .addOption ("Double" )
17 alert .show (function (result ){
18 if (result == 0){itemSpacer = "" } else {itemSpacer = "\n"}
19 var topics = new Array ()
20 var indent = "\t"
21 rootItem .descendants .forEach (function (item , index ){
22 level = item .level
23 if (level === 1){
24 if (index === 0){
25 itemString = item .topic
26 } else {
27 itemString = itemSpacer + item .topic
28 }
29 } else {
30 itemString = indent .repeat (level -1) + item .topic
31 }
32 topics .push (itemString )
33 })
34 outlineText = topics .join ("\n" )
35 encodedStr = encodeURIComponent (outlineText )
36 urlStr = "drafts5://x-callback-url/create?text=" + encodedStr
37 url = URL .fromString (urlStr )
38 url .call (function (result ){console .log (result )})
39 })
40 });
41
42 action .validate = function (selection, sender){
43
44
45 return (rootItem .descendants .length > 0)
46 };
47
48 return action ;
49 }();
50 _ ;
01-08 The action metadata. Edit the author and label tags to suit your purposes.
42-46 The action validation routine determines the document conditions under which the action becomes available in the Automation menu. In this case, if the outline contains one or more rows.
10-40 The code executed when the action is triggered.
14-17 Create and display an alert with options for the user to indicate whether a single or double space is to be used between top-level items.
18-31 Create an array containing the topic column text from the outline rows. IMPORTANT: this script is designed to be used with single-column outlines.
34 Convert the array of row content into a single text string using the basic JavaScript join () method..
35 Use the standard JavaScript encodeURIComponent () method to percent encode the outline string. Carriage returns and certain punctuation will be convert to percent codes for use in a URL.
36 Using the Drafts URL API , append the encoded outline string to the end a URL command for creating a new document and setting its contents.
37 Convert the URL string into an instance of the URL object class.
38 Use the call () method to execute the URL object.
The following video shows the Omni Automation action in use:
Your browser does not support the video tag.
PLAY
PAUSE
BACK
REWIND
TOPICS
Home
OmniGraffle
OmniOutliner
OmniPlan
OmniFocus
Drafts App
JavaScript Action Templates
New Draft with Graphic Text
New Draft with Outline Text
Export Outline to New Draft
Draft to Selected Graphic
Process Graphic Text
Append ¶’s to Outline
Prepend ¶’s to Outline
New Outline from Draft
The Business Letter
UNDER CONSTRUCTION
This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.
DISCLAIMER
Mention of third-party websites and products is for informational purposes only and constitutes neither an endorsement nor a recommendation. OMNI-AUTOMATION.COM assumes no responsibility with regard to the selection, performance or use of information or products found at third-party websites. OMNI-AUTOMATION.COM provides this only as a convenience to our users. OMNI-AUTOMATION.COM has not tested the information found on these sites and makes no representations regarding its accuracy or reliability. There are risks inherent in the use of any information or products found on the Internet, and OMNI-AUTOMATION.COM assumes no responsibility in this regard. Please understand that a third-party site is independent from OMNI-AUTOMATION.COM and that OMNI-AUTOMATION.COM has no control over the content on that website. Please contact the vendor for additional information.