Questions tagged [rangy]

Rangy is a cross-browser JavaScript range and selection library.

Rangy is a cross-browser JavaScript range and selection library. It provides a simple standards-based API for performing common DOM Range and Selection tasks in all major browsers, abstracting away the wildly different implementations of this functionality between Internet Explorer up to and including version 8 and DOM-compliant browsers.

The project website is http://code.google.com/p/rangy/.

222 questions
18
votes
5 answers

Contenteditable DIV - how can I determine if the cursor is at the start or end of the content

I have a contenteditable div which contains typical wysiwyg editor html (bold, anchors, lists). I need to determine if the current cursor is, onKeyDown, at the start and at the end of the div. The reason for this is, based on the cursor position,…
Edward M Smith
  • 10,557
  • 2
  • 44
  • 50
14
votes
4 answers

Insert Table into content editable div

I have a fiddle showing what my code is doing. Using javascript/jquery I am trying to insert a table into a content editable div at the current caret position. I am using Tim Down's Rangy library to accomplish this. I am doing this with the…
Blake Plumb
  • 5,667
  • 2
  • 28
  • 49
11
votes
1 answer

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

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…
Adim
  • 761
  • 2
  • 8
  • 22
10
votes
2 answers

replace innerHTML in contenteditable div

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…
Petya petrov
  • 1,755
  • 5
  • 20
  • 34
9
votes
2 answers

How to get the HTML before, inside, and after a selection (not in textarea)?

Here is what I am trying to accomplish: When a user uses a mouse, keyboard, or touch to select text inside "myDiv" I want to acquire three discreet chunks of HTML: the HTML before the selection (to the "left" of it), the HTML inside the selection,…
Alan Bellows
  • 1,683
  • 1
  • 14
  • 21
9
votes
3 answers

Could not complete the operation due to error 800a025e

What does this error mean in IE10/11: Error: Could not complete the operation due to error 800a025e. And how would I debug it? It says its this…
8
votes
2 answers

contenteditable div: IE8 not happy with backspace remove of HTML element

I am making use of a contenteditable div in combination with the rangy Javascript library to insert HTML at the cursor position. End of the day the contents of the div commonly looks like:
"Hello "
7
votes
1 answer

User-select: none behaves differently in Safari

What I am trying to achieve I am building input-like content editable div. You are supposed to click some tags outside the div to add them inside the div while also being able to type around said tags. The problem and how to reproduce it I am using…
Darkkz
  • 324
  • 4
  • 17
7
votes
0 answers

Rangy.js - Saving a comment to highlighted text

I'm currently implementing the very cool range and selection library Rangy.js. I want to implement a function that can highlight some text and then add and save a comment to the highlight. In the demos it is shown how to add a note to the selection…
7
votes
1 answer

Getting the parent node for selected text with rangy library

I'm using the rangy library and can select text in a content editable as follows: var sel = rangy.getSelection(); alert(sel); I can't figure out how to get the selected text parent node/element. For example, if I'm selecting text that is…
Frank
  • 704
  • 1
  • 9
  • 21
6
votes
1 answer

Rangy (JS/jQuery) split node

How would I split a node/element at a position (selection). Example I have this markup:

This is a te|st, you like?

(this pipe represents the position/selection) I want to convert it to:

This is a te

|

Petah
  • 42,792
  • 26
  • 149
  • 203
5
votes
3 answers

jQuery doesn't support .has in IE8? what is a work around?

code: http://jsfiddle.net/4hV6c/4/ just make any selection, and you'll get a script error in ie8 I'm trying to do this: $(end_node.parentNode).has(start_node) which in modern browsers (chrome, ff, opera, etc) returns [] if start_node is not in…
NullVoxPopuli
  • 51,415
  • 69
  • 184
  • 335
5
votes
0 answers

Converting rich-text to plain-text when pasting in contenteditable div

Im trying to create a contenteditable div with the behaviour of chrome's 'plaintext-only'. So, users can only input plain-text and when copying rich-text it is pasted as plain-text. In my script @-mentions are converted to buttons and added using…
Gilbert
  • 179
  • 2
  • 10
1
2 3
14 15