mduvall/grande.js — pull request #21 by y-lohse (2013-09-05 07:34:14+00:00)
Title: Hr support

This patch allows inserting hr (#19) by pressing enter when the previous paragraph is empty. In that case the previous paragraph is replaced by the hr. I loosely tested it in the latests chrome, firefox & IE and it works fine. The native deletion of a hr however varies from browser to browser, as mentioned in #20.

Aside from that the patch refactors some not-so-minor things:

- the hr stuff was vastly different from text parsing, so I created a new `triggerNodeAnalysis` function. I think it will become usefull when we address #20 as well
- `triggerTextParse` had some repetition with `triggerNodeAnalysis` so I moved the common code inside an anonymous function called upon `keyup`. This function does the common checkings and then calls the 2 others.
- I renamed and slightly changed the behavior of `hasParentWithTag`. It now returns the first parent element that matches the given type instead of just true. It still works as a test function as previously but is also used in 3 places to grab a parent node.