OK, so a few people are interested. If we limit the use of such feature, at first, only to math. This feature is doable. Remember that if we have a $x^2$ as text, select and press C-M, we can get x^2 in math mode. This can be used in this case.
1. in the view-source (edit-source later?) dialog, if the user clicks anywhere other than between $ $ or [ ], the focus is *not* accepted. 2. If between $ $, locate the inset in the lyx file (should not be too hard) and select. 3. For whatever inputted between $$, use the C-M facility and try to convert it to math and replace selected inset. (If convert fail, do nothing, or convert the inset to ERT. ) Sound reasonable? Bo.