rangy

Caret disappears in Firefox when saving its position with Rangy

我与影子孤独终老i 提交于 2019-12-01 20:11:13
问题 This happens only in Firefox. Important: I am saving the caret's position with rangy.saveSelection(): when click the content editable div on keyup when adding an external html element (as a node) to the content editable div I need the position saved constantly through multiple means to be able to insert html elements on click (I have some tags). When I click in the contentEditable div and the div is empty (first focus, let's say), I cannot see the caret unless I start typing. If the caret is

'Range.detach' is now a no-op, as per DOM

泄露秘密 提交于 2019-12-01 18:58:37
I have been noticing this warning and error message in my console after updating Chrome to 36.0.1985.125. Warning: 'Range.detach' is now a no-op, as per DOM (http://dom.spec.whatwg.org/#dom-range-detach). Error: Discontiguous selection is not supported. Can be seen: http://rangy.googlecode.com/svn/trunk/demos/cssclassapplier.html Other javascript/jquery plugins (wysihtml5, rangy) have also been affected, any solutions? I'm still trying to decide what to do about this. See this Rangy issue (migration to GitHub not quite complete, sorry). I think it's unhelpful behaviour on the part of Chrome

How do I create a range object when I know just the character offsets?

守給你的承諾、 提交于 2019-11-29 00:52:18
问题 So I have a div that contains a block of text, previously the user has selected some text in this block and I created a range object from this selection. I stored the offset of the selected text's starting and ending points but I am having problems re-creating the range (so i can manipulate it). "quotables" is the div that holds all the text. I dont know what I am doing wrong. var theRange = rangy.createRange(); var node = $('.quotables').html(); theRange.setStart(node, 14); theRange.setEnd

Rangy (JS/jQuery) split node

孤街浪徒 提交于 2019-11-28 09:26:23
How would I split a node/element at a position (selection). Example I have this markup: <p>This is <a href="">a te|st</a>, you like?</p> (this pipe represents the position/selection) I want to convert it to: <p>This is <a href="">a te</a></p>|<p><a href="">st</a>, you like?</p> Maintaining the selection. Any ideas? I and using the Rangy library, and also jQuery, but can use raw JS if applicable. You could do this by creating a range that extends from the caret to the point immediately after the paragraph and using its extractContents() method. Live demo: http://jsfiddle.net/timdown/rr9qs/2/

Rangy (JS/jQuery) split node

主宰稳场 提交于 2019-11-27 02:54:59
问题 How would I split a node/element at a position (selection). Example I have this markup: <p>This is <a href="">a te|st</a>, you like?</p> (this pipe represents the position/selection) I want to convert it to: <p>This is <a href="">a te</a></p>|<p><a href="">st</a>, you like?</p> Maintaining the selection. Any ideas? I and using the Rangy library, and also jQuery, but can use raw JS if applicable. 回答1: You could do this by creating a range that extends from the caret to the point immediately

replace innerHTML in contenteditable div

陌路散爱 提交于 2019-11-26 16:21:29
i need to implement highlight for numbers( in future im add more complex rules ) in the contenteditable div. The problem is When im insert new content with javascript replace, DOM changes and contenteditable div lost focus. What i need is keep focus on div with caret on the current position, so users can just type without any issues and my function simple highlighting numbers. Googling around i decide that Rangy library is the best solution. I have following code: function formatText() { var savedSel = rangy.saveSelection(); el = document.getElementById('pad'); el.innerHTML = el.innerHTML

replace innerHTML in contenteditable div

与世无争的帅哥 提交于 2019-11-26 04:45:59
问题 i need to implement highlight for numbers( in future im add more complex rules ) in the contenteditable div. The problem is When im insert new content with javascript replace, DOM changes and contenteditable div lost focus. What i need is keep focus on div with caret on the current position, so users can just type without any issues and my function simple highlighting numbers. Googling around i decide that Rangy library is the best solution. I have following code: function formatText() { var