contenteditable - JavaScript - Split Parent of Selection -
using javascript (and potentially rangy) trying create utility function allow me "split" element based on selection , selector pass in. instance, let's had following:
<div class="designer" contenteditable="true"> <div class="content"> <p> here <span style="color: pink;">some cool</span> stuff. <p> </div> </div>
now let's user had cursor between "some" , "cool". want able call function this:
$splitparent('p'):
which yield following:
<div class="designer" contenteditable="true"> <div class="content"> <p> here <span style="color: pink;">some</span> <p> <p> <span style="color: pink;"> cool</span> stuff. <p> </div> </div>
and calling this:
$splitparent('.content');
would yield this:
<div class="designer" contenteditable="true"> <div class="content"> <p> here <span style="color: pink;">some</span> <p> </div> <div class="content"> <p> <span style="color: pink;"> cool</span> stuff. <p> </div> </div>
i haven't been able think of straight-forward way of accomplishing this. ideas?
Comments
Post a Comment