Lookup in Pleco from any app?

吳思文

Member
In iOS settings/general/dictionary there's a bunch of dictionaries to select for lookup from any app. Wouldn't it be great if Pleco were there? Working in Chinese in other apps, many times I find myself wanting to jump straight to the Pleco dictionary entry instead of copying, launching Pleco, pasting and searching.
 
Version 4 of Pleco is supposed to allow you to use the Share Sheet to send selection to Pleco. In the mean time I’ve been using the new Shortcuts feature in iOS 12. I’ve created a shortcut called “Send to Pleco” which sends the selected text to Pleco from a Share Sheet.


1538328146745.png
 

Shun

状元
Hi Alex,

thanks for the tip. Am I doing something wrong if there's only "Shortcuts" available in the Share Sheet? I can choose "Shortcuts" and then tap on the "Look up in Pleco" script button, but I can't add "Look up in Pleco" directly to the Share Sheet. (I also looked under "More" in both rows.) Here is my script setting:


shortcut pleco.png safari share sheet.png

Regards,

Shun
 
Am I doing something wrong if there's only "Shortcuts" available in the Share Sheet? I can choose "Shortcuts" and then tap on the "Look up in Pleco" script button, but I can't add "Look up in Pleco" directly to the Share Sheet.
Sorry, I guess I didn't explain it clearly. Yes, there is only Shortcuts available. Then you can select "Look up in Pleco".
 

mikelove

皇帝
Staff member
Yep, no way to have a dedicated button without an App Extension, and supporting App Extensions has required us to totally overhaul our app.
 

pdwalker

状元
Version 4 of Pleco is supposed to allow you to use the Share Sheet to send selection to Pleco. In the mean time I’ve been using the new Shortcuts feature in iOS 12. I’ve created a shortcut called “Send to Pleco” which sends the selected text to Pleco from a Share Sheet.
[snip]

Hi Alex,

I have no idea how to find what you just did.

Would it be possible for you to walk me through the steps to find this so I can set it up on my own phone?
 
Would it be possible for you to walk me through the steps to find this so I can set it up on my own phone?

  1. You need download the Shortcuts app first from the App Store https://itunes.apple.com/us/app/shortcuts/id915249334?mt=8
  2. Open the Shortcuts app and select Create Shortcut:
    1538452184007.png
  3. Click on the Search field and select Content Types->Documents
    1538452453809.png
  4. Scroll down and select Files->Open In...
    1538452566796.png
  5. Turn of the Show Open in Menu slider and select Choose
    1538453555780.png
  6. Select Pleco as the App
  7. Press the controls selector
    1538453873854.png
  8. Turn on Show in Share Sheet and change the Accepted types to Rich Text, Text. Here you can also change the Name of the shortcut and it's Icon
    1538454147749.png
  9. Now press Done a few times and you should see something like this
    1538454382454.png
  10. You can now highlight text in an app and select Share... You will be presented with a Share Sheet and a list of applications. Select Shortcuts and then you will be presented with a list of Shortcuts to run. Select your Send Text To Pleco shortcut. If you don't see Shortcuts you can select More and add it to the list.
    1538454707476.png
 

pdwalker

状元
You need download the Shortcuts app first from the App Store

and that explains why I couldn't find anything on my phone.

Thank you for the detailed explanation. I can't wait to try it!
 

chunchieh

Member
I’ve created a shortcut that looks up selected text directly, instead of importing it into the document reader: https://routinehub.co/shortcut/11346/

Is this shortcut really something that needs frequent updating enough to warrant automatically installing changes to it? How can we know that you won’t replace your shortcut content with something malicious? Creating an HTML document also seems sketchy and overkill. Does Apple prevent scripts from running in HTML documents within a shortcut? I was able to create a shortcut that grabs selected text, copies to the clipboard and opens Pleco without 34 steps.

If anyone wants to do it themselves:

1) Create a new shortcut by opening the Shortcuts app and clicking the “+” button

2) Tap the settings icon

3) Choose “Show in Share Sheet” and tap “Done”

4) In the section that says, “Receive Any input from Share Sheet, Quick Actions”, tap “Any”, tap “Clear”, toggle on “Text”, tap “Done”.

5)Tap “Add action” and search for “copy”. Tap “Copy to clipboard”. You should see it automatically add an action that says, “Copy Shortcut Input to clipboard”.

6) Tap the search bar and search for “open app”. Tap it. When it adds the “Open App” item, tap “App” and choose Pleco.
AAC1DE63-74B7-43E3-82DF-38B8B9B35447.jpeg
9D33B77B-A8A0-49BF-A7D7-D04A1C07D1C2.jpeg
949A81A2-F6CF-4532-8956-447E3B7EE447.png
69E4851D-35A6-45C1-A060-F103805F1150.jpeg
225D3739-9E8F-41D1-A227-1D7CFB0A3008.jpeg
 

Shun

状元
Hi chunchieh,

many thanks. I replicated it, and I noticed there's just one thing one needs to make sure of. Pleco needs to be set to look up automatically the clipboard text after startup. No big deal, just one setting in Miscellaneous.

IMG_6055.PNG



Also, I enabled Rich Text as input:

IMG_6054.PNG


Cheers,

Shun
 
Last edited:

Calion

秀才
Is this shortcut really something that needs frequent updating enough to warrant automatically installing changes to it

It’s not about the frequency, it’s about whether it might ever need updating at all. Which it already has.

How can we know that you won’t replace your shortcut content with something malicious?

How do you know that any shortcut author won’t put malicious content into any update, ever? All this does is automatically allow you to download the new version. It doesn’t—and can’t—change anything in the existing shortcut.

Creating an HTML document also seems sketchy and overkill.

I tried hard not to have to include that, but it was the only way to make it open longer text blocks in the Pleco document reader, which was a requested feature. I swiped that code from another shortcut that had been posted on these forums. More info here: https://www.plecoforums.com/threads/is-there-a-way-to-look-up-selected-text-in-pleco.6899/

Does Apple prevent scripts from running in HTML documents within a shortcut?

You can’t execute Javascript in Shortcuts without an extension such as Scriptable.

Regardless, you can easily look and see that there are no scripts. It’s not like someone can go insert Javascript into a shortcut that happens to have HTML into it.

Besides, the shortcut doesn’t execute the HTML, it just changes it to rich text and opens it in Pleco.

I was able to create a shortcut that grabs selected text, copies to the clipboard and opens Pleco without 34 steps.

That…doesn’t seem to open the text in Pleco, just copy it and open Pleco, so you then have to paste it. Which I guess saves a couple of steps, but is hardly as handy as selecting text and having it just show up in Pleco.

I mean, do what you want, of course, but if you’re worried about it checking for updates, just delete the “If Current IP Address” subroutine.

Odd that people here seem to be suspicious about the update checker, when those on the Obsidian forums have not mentioned it at all for my other shortcut.
 
Last edited:

Calion

秀才
I’ve updated the internal readme to address concerns about the updater. Really, there’s no way it could hurt anything (any more than any shortcut update could).
 
Top