javascript - How do I return a manipulated array as text to TextEdit? -


i'm new jxa , i'm trying learn how basic things in textedit. know how paragraphs of document array:

app = application('textedit')
docpars = app.documents[0].paragraphs()

and then, say, sort it. can't figure out how send textedit array (i.e. multiple paragraphs in te document).

tia

here example you

var textedit = application("textedit"); var newdocument = textedit.document(); textedit.documents.push(newdocument);  for(var = 0; < 10; i++){     newdocument.paragraphs.push(textedit.paragraph({ color:"red", size:20 }, "test line " + + "\n")) } 

// update example array

var textedit = application("textedit"); var newdocument = textedit.document(); textedit.documents.push(newdocument);  var array = ["test first line", "i love stackoverflow", "i love jxa", "i love apple"]  for(var = 0; < array.length; i++){     newdocument.paragraphs.push(textedit.paragraph({ color:"red", size:20 }, array[i] + "\n")) } 

Comments