You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to create an Action for Drafts (getdrafts.com) which transforms the currently selected text (selection_only) into small caps.
Initial Response
Absolutely! I can help you create a Drafts action that transforms selected text into small caps. Here's how we can approach this:
Understanding the request
You want an action for the Drafts application.
The action should convert any selected text to small caps.
If no text is selected, it should presumably do nothing.
Overview of the solution
We'll use the Drafts scripting API to:
Get the currently selected text.
If there is no selection, exit.
Convert the selected text to small caps.
Replace the selection in the editor with the converted text.
The code
// Get the currently selected text.letselection=editor.getSelectedText();// If there is no selection, exit.if(!selection){context.cancel();}// Convert the selection to small caps.letsmallCapsText=selection.toLowerCase();// Replace the selection with the small caps text.editor.setSelectedText(smallCapsText);
Implementation instructions
Open the Drafts application on your device.
Create a new action.
In the action editor, select "Javascript" as the action step type.
Copy and paste the code above into the code editor.
Save the action with a descriptive name, like "Small Caps".
Select some text in a draft and run the action. The selected text should now be in small caps.
Additional notes
This action will only work on the selected text. If you want to convert the entire draft to small caps, you'll need to modify the code to get the entire draft content instead of just the selection.
You can customize the action further by adding options to control the case of the converted text, such as uppercase or title case.
Remember to test the action thoroughly to make sure it works as expected.
I hope this helps! Let me know if you have any other questions or need further assistance.
Correction Prompt:
No, small caps like this: sᴍᴀʟʟ ᴄᴀᴘs
Corrected Response
Ah, I understand! You'd like to use the Unicode small caps characters like sᴍᴀʟʟ ᴄᴀᴘs.
Here's the updated code:
// Get the currently selected text. letselection=editor.getSelectedText();// If there is no selection, exit. if(!selection){context.cancel();}// Convert the selection to small caps. letsmallCapsText=selection.toLowerCase().replace(/[a-z]/g,function(char){switch(char){case'a': return'ᴀ';case'b': return'ʙ';case'c': return'ᴄ';case'd': return'ᴅ';case'e': return'ᴇ';case'f': return'ꜰ';case'g': return'ɢ';case'h': return'ʜ';case'i': return'ɪ';case'j': return'ᴊ';case'k': return'ᴋ';case'l': return'ʟ';case'm': return'ᴍ';case'n': return'ɴ';case'o': return'ᴏ';case'p': return'ᴘ';case'q': return'ǫ';case'r': return'ʀ';case's': return'ꜱ';case't': return'ᴛ';case'u': return'ᴜ';case'v': return'ᴠ';case'w': return'ᴡ';case'x': return'x';case'y': return'ʏ';case'z': return'ᴢ';default: returnchar;}});// Replace the selection with the small caps text. editor.setSelectedText(smallCapsText);
This script now iterates through each character in the selected text and replaces it with its corresponding Unicode small caps equivalent.
The implementation instructions remain the same. Just replace the previous code with this updated version in your Drafts action.
Updated
11032024-012821
40BC6A91-D4D1-4630-9AFB-D6DAE113BF7C
Social
<iframe src="https://mastodon.social/@DavidBlue/113417837332892729/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="400" allowfullscreen="allowfullscreen"></iframe><script src="https://static-cdn.mastodon.social/embed.js" async="async"></script>Thanks to Google Gemini, I created an Action for @drafts that converts currently-selected text to ꜱᴍᴀʟʟ ᴄᴀᴘꜱ. https://directory.getdrafts.com/a/2VW
Meta
Description
Convert the current text selection to ꜱᴍᴀʟʟ ᴄᴀᴘꜱ case.
Directory Description
Convert the current text selection to ꜱᴍᴀʟʟ ᴄᴀᴘꜱ case.
Babylon
Prompt:
Initial Response
Absolutely! I can help you create a Drafts action that transforms selected text into small caps. Here's how we can approach this:
Understanding the request
Overview of the solution
We'll use the Drafts scripting API to:
The code
Implementation instructions
Additional notes
I hope this helps! Let me know if you have any other questions or need further assistance.
Correction Prompt:
Corrected Response
Ah, I understand! You'd like to use the Unicode small caps characters like sᴍᴀʟʟ ᴄᴀᴘs.
Here's the updated code:
This script now iterates through each character in the selected text and replaces it with its corresponding Unicode small caps equivalent.
The implementation instructions remain the same. Just replace the previous code with this updated version in your Drafts action.
Sources
The text was updated successfully, but these errors were encountered: