OO-PG0006
Plug-In: Append File Links to Note
This plug-in will append links to the chosen files to the note of the selected row.
Return to: OmniOutliner Plug-In Collection
Append File Links to Note
/*{"type": "action","targets": ["omnioutliner"],"author": "Otto Automator","identifier": "com.omni-automation.oo.append-file-links","version": "1.0","description": "Will append links to the chosen files to the note of the selected row.","label": "Append File Links to Note","shortLabel": "Add File Links","paletteLabel": "Add File Links","image": "doc.fill"}*/(() => {const action = new PlugIn.Action(async function(selection, sender){try {outline = selection.outlinenode = selection.nodes.pop()item = node.objectvar note = item.valueForColumn(outline.noteColumn)if (note === null) {note = new Text("", outline.noteColumn.style);}picker = new FilePicker()picker.multiple = trueurls = await picker.show()var delimiterObj = new Text(" ⢠", note.style)var newLineObj = new Text("\n", note.style)if(note.string.length > 0){note.append(newLineObj)}urls.forEach((url, index) => {linkName = url.lastPathComponentlink = new Text(linkName, note.style)style = link.styleForRange(link.range)style.set(Style.Attribute.Link, url)note.append(link)if(index !== (urls.length - 1)){note.append(delimiterObj)}})item.setValueForColumn(note, outline.noteColumn);}catch(err){console.error(err.name, err.message)}});action.validate = function(selection, sender){// selection options: columns, document, editor, items, nodes, outline, stylesif (!selection.editor) {return false}return (selection.nodes.length === 1)};return action;})();