toggle editor modes

Posted by @FlohGro, Last update about 1 month ago

Toggle the following modes of the Editor With a prompt:
“focus”,“link”,“focus & link”, “arrange”

Steps

  • script

    // toggle modes 
    let toggleFocusMode = () => {
    	if(editor.focusModeEnabled == true)
    	{
    	editor.focusModeEnabled = false;
    	}
    	else
    	{
    	editor.focusModeEnabled = true;
    	}
    }
    
    let toggleLinkMode = () => {
    	if(editor.linkModeEnabled == true)
    	{	
    	  (editor.linkModeEnabled = false);
    	}
    	else
    	{
    	  (editor.linkModeEnabled = true);
    	}
    }
    
    
    var modes2toggle = ["focus","link","focus & link", "arrange"];
    
    var p = Prompt.create();
    
    for(i in modes2toggle){
    	p.addButton(modes2toggle[i]);
    }
    
    p.title = "toggle modes";
    p.title = "select modes to toggle";
    
    var didSelect = p.show();
    if (didSelect == true) {
    	var sel = p.buttonPressed;
    	if (sel == "focus") {
    		toggleFocusMode();
    		let msg = editor.focusModeEnabled ? "enabled" : "disabled";
    		app.displaySuccessMessage(sel + " mode " + msg);
    	} else if (sel == "link") {
    		toggleLinkMode();
    		let msg = editor.linkModeEnabled ? "enabled" : "disabled";
    		app.displaySuccessMessage(sel + " mode " + msg);
    	} else if (sel == "focus & link") {
    		toggleFocusMode();
    		toggleLinkMode();		
    		let msg1 = editor.focusModeEnabled ? "enabled" : "disabled";
    		let msg2 = editor.linkModeEnabled ? "enabled" : "disabled";
    		app.displaySuccessMessage(sel + " mode " + msg1 + " & " + msg2);
    	} else if (sel == "arrange") {
    		editor.arrange(draft.content);
    	}
    } else {
    	app.displayInfoMessage("cancelled toggle modes");
    }

Options

  • After Success Nothing
    Notification None
    Log Level Error
Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.