Code for New Paragraph

Adding a new paragraph or paragraph like item requires making the item, making the action that adds it and then putting both of these in their proper place.

Where it Happens

Clicking the [+] at the bottom of any page runs createFactory found in refresh.coffee

A drop into the page is processed by handleDragging in refresh.coffee.

The TextEditor in legacy.coffee calls nearby createTextElement when it splits paragraphs.

The server can tamper with the story on its own as it does in handing /submit.

The Submit Changes button handling in plugin changes.coffee adds the item returned by /submit to the current page.

Batch importers fabricate story and journal any way they see fit.

What Happens

Create a story item with desired type and id from util.randomBytes(8).

Create an itemElement and append it to the DOM. Run plugin.do to fill out this element.

Create an 'add' action for the journal. Include the 'after' id which you will find by DOM inspection. Record the action with pageHandler.put.

Double Check

Actions don't show up in the journal until after the update server turnaround.

Make sure the revised story can survive a page refresh.

Make sure revision.coffee can recreate a proper page from the journal actions you record.