Moving a ToDo item to the top


I am having problems getting this function to work:

     name: 'moveTop',
     description: 'Move the current Todo node to the top of the list.',
     performCommand: function(editor) {

     var cnode = editor.selectedRange().startNode,
            pnode = cnode.previousBranch();

        // Go to the top of the current todo list.
       while (pnode.type() != 'heading') {
          pnode = pnode.previousBranch();

        // Append to top of the list.
        fcnode = pnode.firstChild();

I also can not get commands to run in the Debugger. You can not bring up the command pallet in the debugger, so how are you to debug commands?

All of my todo list are in level one headers. I want to move items to the top, bottom, next list and previous list. I have all of these working, except for this one!



In the debugger console command line, you can give the name string of the command (eg ‘moveTop’) to the window.performAction method.

Try, for example, selecting a line in the SDK editor, and entering:


(window. is the default namespace/context, so it should be optional, in practice)

i.e. just:


(commands will often have no return value, so the console will tend to respond with undefined after the command is performed)

I knew there must be a way. It needs to be in the documents! Thanks.

Okay. I fixed it. I did not realize firstChild wasn’t a function. Easy to see in the debugger. Thanks for the help.