Editorial Workflows

Graph

unlisted workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Insert graph to current document.

Shared by: BunuelCuboSoto

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Selected Text ?
Entire Line(s)
OFF
Empty Selection Output
  • No Output
  • All Text
  • Closest Word
Folded Text
  • Include
  • Replace with:
If… ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Stop ?
Stop
  • This Workflow
  • Repeat Block
Show HUD Alert
ON
Message
No selected text
…End If
Open x-callback URL ?
URL
mathx://x-callback-url/graphic?function=Input&showslegend=0&destination=pasteboard
x-success
editorial://workflow-callback
Output
  • First Parameter of x-success URL
  • Raw x-success URL
Run Python Script ?
Source Code
#coding: utf-8
import photos
import workflow
import console
import editor
import os
import io
import clipboard

img = clipboard.get_image()
if not img:
	workflow.stop()

doc_path = editor.get_path()
doc_dir, fn = os.path.split(doc_path)
default_name = 'Image'
i = 1
while True:
	if not os.path.exists(os.path.join(doc_dir, default_name + '.jpg')):
		break
	default_name = 'Image_' + str(i)
	i += 1

root, rel_doc_path = editor.to_relative_path(editor.get_path())
filename = console.input_alert('File Name', 'The image will be saved in the folder of the current document.', default_name + '.jpg', 'Save')
if not filename:
	workflow.stop()
img_data = io.BytesIO()
img.save(img_data, 'jpeg')
rel_doc_dir, fn = os.path.split(rel_doc_path)
dest_path = os.path.join(rel_doc_dir, filename)
editor.set_file_contents(dest_path, img_data.getvalue(), root)
workflow.set_output(filename)
Replace Selected Text ?
Replacement Text
![Image](Input)