Example actions and other extensions for Drafts, the quick-capture notes app.
let inputNumber = editor.getSelectedText();
// Remove non-numeric characters
const strippedInput = inputNumber.replace(/[^\d]/g, '');
// Check if the input is empty
if (strippedInput === '') {
console.log('Input must contain numerical characters');
context.cancel();
}
else {
// Remove leading '1' if present
let formattedNumber = strippedInput;
if (formattedNumber.startsWith('1')) {
formattedNumber = formattedNumber.slice(1);
}
// Format the number
const regex = /^(\d{3})(\d{3})(\d+)$/;
formattedNumber = formattedNumber.replace(regex, '$1.$2.$3');
editor.setSelectedText(formattedNumber);
}
I was a late iPhone adopter. I held on tight to my BlackBerry for way too long. It wasn’t until the iPhone 4S that I made my way over to the iPhone. And then a new opportunity really opened u…
twitter-workspace-for-drafts/README.md at main · chrisgrieser/twitter-workspace-for-drafts
Various capabilities for composing tweets in the Drafts app. - twitter-workspace-for-drafts/README.md at main · chrisgrieser/twitter-workspace-for-drafts