Restore focus to the event trap if reset by an operation

With the event trap now being inside the cursor, any repositioning of
the cursor causes the document.activeElement and window selection to
change. This causes the document to stop being editable after actions
such as bolding current text.

Now, the focus state of the event trap is checked prior to each
operation, and will be reset back to the event trap if disrupted by an
operation. Note, checks are in place to prevent stealing focus if the
document is not active when an operation is executed.

Fixes issue #298
Merge pull request #301 from peitschie/focus-fix

Restore focus to the event trap if reset by an operation
Capture cursor registration for undo event even when not in edit mode

Any cursor add or removal commands should be tracked for the purposes
of restoring the document state. If a cursor operation is missed, the
document will not re-add the cursor after an undo operation.
Don’t reset the undo manager state when entering or exiting edit mode

This allows consumers to enter and exit edit mode multiple times without
the undo stack being reset. Once the initial undo state has been captured
after the document is loaded, there is no major problems with preserving
the undo state (other than the undo manager’s shameful performance).
Clarify names & usage of the undo manager
Merge pull request #297 from peitschie/unbreak-undo

Undo fixes and a (tiny) behaviour adjustment
Support expecting unit tests to fail
Integrate failing operation tests into normal run
Merge pull request #302 from kossebau/addExpectFailToUnitTests

Add expected fails to unit tests
Exclude any text content inside a cursor node the document text body

A cursor cannot contain valid document text, and should never be returned
in text node or text elements collections.
Merge pull request #303 from peitschie/ignore-cursor-content

Exclude any text content inside a cursor node the document text body
Uses the previous selection style for the newly inserted character when replacing text
Merge pull request #296 from kevinlli/styleFix

Uses the previous selection style for the newly inserted character when replacing text
Respect blinkOnRangeSelect when regaining caret focus

If blinkOnRangeSelect is false and the current cursor range is not
collapsed, the caret should NOT start blinking under any circumstances.
Merge pull request #305 from peitschie/blink-caret-issue

Respect blinkOnRangeSelect when regaining caret focus
Only make the event trap editable if the document is in edit mode

Various browser menus (cut, delete) should only enable if the document
is currently in edit mode.
Merge pull request #304 from peitschie/readonly-eventtrap

Only make the event trap editable if the document is in edit mode
Fix parameter annotation for getAppliedStylesForElement of Formatting.js
Preserve the direct cursor style when spliting at the end of paragraph.

At the moment, spliting at the end of the following paragraph
<p style-name="standard">hello <span style-name="bold">world|</span></p>
will create a new paragraph like below
<p style-name="standard">|<span style-name="bold"></span></p>

The cursor is moved out of the span due to empty span is not considered as
a valid cursor position in the current design. this causes newly entered
text are not formatted corretly.

The workaround: first merge the paragrpah style and direct cursor style (if any) into a new automatic style; and then apply it to the newly created paragrpah.