Action

Word-count of selection

Posted by campjacob, Last update over 4 years ago

Javascript action to count the number of words currently selected in editor. I use it to count if a quote has 50 or more words to know if I need to use special blockquote formatting based on APA standards.

Steps

  • script

    (() => {
    
    	const main = () =>
    		alert(
    			words(editor.getSelectedText())
    			.length
    			.toString() + ' words in selection'
    		);
    	
    	// words :: String -> [String]
    	const words = s => s.split(/\s+/);
    
    	// MAIN ---
    	main();
    	
    })()

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.