Skip to content

Instantly share code, notes, and snippets.

@fumikito
Created January 27, 2016 02:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fumikito/ef3f62b3a289f737e203 to your computer and use it in GitHub Desktop.
Save fumikito/ef3f62b3a289f737e203 to your computer and use it in GitHub Desktop.
Interactive Pages input
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