Ah--very cool.
Was there a reason why you didn't update to the latest CVS of all of HTMLarea?
I'm filing my patches as a bug-tracker item for mailing-lists. The diff is against the oacs-5-1 tree. The bug-tracker item is
https://openacs.org/bugtracker/openacs/bug?bug_number=1644
Note I figured most of this out by looking at bug.tcl in the bug-tracker package.