Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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