Action
Lorem Ipsum Generator
Posted by agiletortoise,
Last update
16 days ago
UPDATES
16 days ago
Add prompt options
Generate Lorem Ipsum placeholder text using the Loripsum.net API. Defaults to generating 3 short paragraphs of plain text Lorem Ipsum. Other API options are available, see their docs for details.
Steps
-
script
// Generate and insert Lorem Ipsum placeholder text // Uses Loripsum API: https://loripsum.net // START: configure default options // for more options, see docs at: https://loripsum.net let noParagraphs = 3 let paraLength = "short"; // "short", "medium", "long", "verylong" // END: options function generate(noParagraphs, paraLength) { // make API request and insert text. let url = `https://loripsum.net/api/${noParagraphs}/${paraLength}/plaintext` let http = new HTTP(); let response = http.request({ "url": url }); if (response.statusCode == 200) { return response.responseText } else { console.log("Error requesting lorem text"); context.fail(); } } let p = new Prompt() p.title = "Generate Lorem Ipsum" p.message = "Create placeholder text and insert in the current draft." p.addTextField("noParagraphs", "Paragraphs", noParagraphs.toString(), { "keyboard": "numberPad" }) p.addSegmentedControl("length", "Paragraph Length", ["short","medium","long"], paraLength) p.addButton("Generate") if(p.show()) { let ix = parseInt(p.fieldValues["noParagraphs"]) if (ix) { noParagraphs = ix } paraLength = p.fieldValues["length"] let result = generate(noParagraphs, paraLength) let [st, len] = editor.getSelectedRange() editor.setSelectedText(result) editor.setSelectedRange(st, result.length) }
Options
-
After Success Default Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.