Created
January 27, 2016 02:13
-
-
Save fumikito/ef3f62b3a289f737e203 to your computer and use it in GitHub Desktop.
Interactive Pages input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on run {input, parameters} | |
tell application "Pages" | |
activate | |
open input | |
tell front document | |
-- GET ALL TAGS | |
set theseTags to the tag of every placeholder text | |
-- FILTER FOR UNIQUE TAGS | |
set uniqueTags to {} | |
repeat with i from 1 to the count of theseTags | |
set thisTag to item i of theseTags | |
if thisTag is not in uniqueTags then | |
set the end of uniqueTags to thisTag | |
end if | |
end repeat | |
-- PROMPT USER FOR REPLACEMENT TEXT | |
repeat with i from 1 to the count of uniqueTags | |
set thisTag to item i of uniqueTags | |
display dialog "Enter the replacement text for this tag:" & ¬ | |
return & return & thisTag default answer "" buttons ¬ | |
{"Cancel", "Skip", "OK"} default button 3 | |
copy the result to {button returned:buttonPressed, text returned:replacementString} | |
if buttonPressed is "OK" then | |
set (every placeholder text whose tag is thisTag) to replacementString | |
end if | |
end repeat | |
end tell | |
end tell | |
return input | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment