i used have code this:
this.insertnodeatcaret = function(node) { var sel, range, html; function containeriseditable(selection) { return $(selection.anchornode).parent().hasclass("editable"); } if (window.getselection) { sel = window.getselection(); // if caret otherwise inserts // anywhere! if (containeriseditable(sel) && sel.getrangeat && sel.rangecount) { var previousposition = sel.getrangeat(0).startoffset; sel.getrangeat(0).insertnode(node); } } else if (document.selection && document.selection.createrange) { range = document.selection.createrange(); html = (node.nodetype == 3) ? node.data : node.outerhtml; range.pastehtml(html); } };
but in typescript 1.5 selection removed document (https://github.com/microsoft/typescript/wiki/breaking-changes), don't know how working .. tried window.getselection() without results
any appreciated :)
thanks, michael
but in typescript 1.5 selection removed document
that specific internet explorer , not available in general browsers. removed. can use unsafely (by treating document
any
) quite easily. here code sample refactored compile without error:
const insertnodeatcaret = function (node) { const doc = document any; var sel, range, html; function containeriseditable(selection) { return $(selection.anchornode).parent().hasclass("editable"); } if (window.getselection) { sel = window.getselection(); // if caret otherwise inserts // anywhere! if (containeriseditable(sel) && sel.getrangeat && sel.rangecount) { var previousposition = sel.getrangeat(0).startoffset; sel.getrangeat(0).insertnode(node); } } else if (doc.selection && doc.selection.createrange) { range = doc.selection.createrange(); html = (node.nodetype == 3) ? node.data : node.outerhtml; range.pastehtml(html); } };
of course assumes know doing, more compiler knows.
update
how can see compatibility of among browsers , available
you can see compatability chart of window.getselection here : https://developer.mozilla.org/en-us/docs/web/api/window/getselection
document.selection
ie only/specific , has been removed : https://msdn.microsoft.com/en-us/library/ms535869(v=vs.85).aspx
Comments
Post a Comment