Action

New Note in Bear

Posted by @mattbirchler, Last update over 6 years ago

Add a note to Bear with a title (required), tags, pin to the top, and of course all the content you would like.

First line of your draft will be the Bear note title.
Write “pin” on a subsequent line to pin it to the top.
Use a dash to indicate tags (can be comma separated)
All content should be placed below 3 dashes (—)

Steps

  • script

    var arr = draft.content.split("\n");
    
    var baseURL = "bear://x-callback-url/create";
    var addLink = CallbackURL.create();
    addLink.baseURL = baseURL;
    
    for (i = 0; i < arr.length; i++) {
    	
    	// Title
    	if (i == 0) {
    		addLink.addParameter("title", arr[i]);
    	}
    	
    	// Tags
    	else if (arr[i].slice(0,2) == "- ") {
    		addLink.addParameter("tags", arr[i].slice(2,100));
    	}
    	
    	// Pin it
    	else if (arr[i] == "pin" || arr[i] == "Pin") {
    		addLink.addParameter("pin","yes");
    	}
    	
    	// Content
    	else if (arr[i].slice(0,3) == "---") {
    		var the_content = "";
    		var count = i + 1;
    		for (counter = count; counter < arr.length; counter++) {
    			the_content += arr[counter] + "\n";
    		}
    		addLink.addParameter("text",the_content);
    	}
    };
    
    
    // open and wait for result
    var success = addLink.open();

Options

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