0

I use rangy highlight selection text (it wrap selection text by a span tag). But when i select text and image, it generate a span tag but span can't wrap img tag. it append before img tag.

My code

cssApplier = rangy.createCssClassApplier("highlight", {
                        ignoreWhiteSpace: true,
                        elementTagName: "span",
                        elementProperties: {
                            id: randomId,
                            onclick: function () {
                                SelectComment(this);
                                return false;
                            }
                        }
                    })
                    cssApplier.applyToRange(sel.getRangeAt(0));

i change elementTagName to div but no change.

<span id="1356599579267" class="highlight current">
    </span>
<img type="photo" title="" templatetype="default" style="width:200px " src="http://sohanews2.vcmedia.vn/k:2012/1350782211-hongque_thoitrang_eva--3--f7897/my-nhan-showbiz-va-lo-hong-ve-tam-nhan-thuc.jpg" rel="http://sohanews2.vcmedia.vn/2012/1350782211-hongque_thoitrang_eva--3--f7897.jpg" photoid="24109" id="img_24109" alt="">

So, how to wrap img or object tag or input tag. by highlight element by rangy?

swiftBoy
  • 35,607
  • 26
  • 136
  • 135
Anh Tú
  • 636
  • 7
  • 21

1 Answers1

1

The CSS class applier module only works on text nodes, which is by design. However, I can see the value, so I intend to do something about it. There are two open issues in the Rangy bug tracker on this:

Tim Down
  • 318,141
  • 75
  • 454
  • 536