My markup for contenteditable element is as below:
for firefox, https://developer.mozilla.org/zh-CN/docs/XPCOM_Interface_Reference/NsIEditor, offers OBSERVER on editors. Assumingly 'privileges' are needed as XPCOM-based. Other sol. on firefox beside mouse & kbd-tracking:
on 'focus' and 'blur' - events of all/concerning nodes/elements(text?) compare the node-content between state at focus-event and the node-content at the blur-event (= leave, also if window-close or sop'n similar), and set YOUR, or '_moz_dirty' , dirty-attribute(s. depending on whom/what browser it should serve, make also MANY different dirty-attrib's as purposes are requiring).
Assuming that the content of your iframe is served from the same domain you could use:
$('.rich_text').contents()
.find('body')
.bind('selectstart', function(){});
As you can see from here, the selectstart event is correctly fired when the element is selected.
There is no cross-browser way of detecting changes to the selection. IE and recent WebKit browsers (Chrome and Safari, for example) support a selectionchange
event on the document. Firefox and Opera have no such event and all you can do is detect selection changes made via keyboard and mouse events, which is unsatisfactory (there is no way of detecting "Select All" from context or edit menus, for example).
Update 2017: There is now a cross-browser way. Recent WebKit/Blink browsers (Chrome, Safari, Opera) support selectionchange, and Firefox supports it since version 43.