Action

Format Number

Posted by agiletortoise, Last update about 1 month ago

Text selected text in the editor, convert it to a number, and replace with a formatted number string. (e.g. 1234567 becomes 1,234,567).

Demonstrates the use of Javascript number formatting.

Steps

  • script

    let sel = editor.getSelectedText();
    let n = parseFloat(sel);
    
    if (!n) {
    	console.log("Text selection must be number");
    	context.cancel();
    }
    else {
    	editor.setSelectedText(n.toLocaleString("en-US"));
    }

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.