javascript - Locking elements in contenteditable="true" div -
i have contenteditable div that's used user input, when button clicked shows options replace words. first strips away html , creates span elements word can replaced. mark of these words different , face problems.
- when clicking directly before or after span , typing text text have same markup span. it's hard add words on line has span. thinking of solving padding spans
looks kind of strange. - user can click in span , change it, rather have user click on span , choose replace or ignore option before changing it. in other words needs locked. thinking of doing capturig keyup , if comes span e.preventdefault() on it's bit of pain program it.
so questions are:
is there easy way of locking span element in contenteditable doesn't involve capturing key , preventdefault (have not tried yet , not sure if it'll work)?
when clicking or moving cursor directly next span , typing text it'll part of span, there way not have part of span? padding span
might work looks strange when span first word on line. illustrate i've posted example html file below:
<!doctype html> <html> <head> <meta content="text/html; charset=utf-8" http-equiv="content-type"> <title>example</title> </head> <body> <div contenteditable="true"></div> <script type="text/javascript"> document.getelementsbytagname("div")[0] .innerhtml="<span style='color:green'>hello</span>" </script> </body> </html>
mark span inside editable container contenteditable="false". it'll solve both problems @ same time.
Comments
Post a Comment