jquery Programming Glossary: range.insertnode
Rangy (JS/jQuery) split node http://stackoverflow.com/questions/11111704/rangy-js-jquery-split-node the paragraph range.collapseAfter p Insert the content range.insertNode contentAfterRangeStart Move the caret to the insertion point..
Web Page Source Annotation Tool http://stackoverflow.com/questions/14244498/web-page-source-annotation-tool range.createContextualFragment html Add the custom node range.insertNode node div #univ .click function Get Selected text var selection.. range.createContextualFragment html Add the custom node range.insertNode node Output1 Now You can replace any part of text Output 2..
How can I position an element next to user text selection? http://stackoverflow.com/questions/1589721/how-can-i-position-an-element-next-to-user-text-selection document.createTextNode markerTextChar range.insertNode markerEl if markerEl Lazily create element to be placed next..
Get the offset position of the caret in a textarea in pixels http://stackoverflow.com/questions/16212871/get-the-offset-position-of-the-caret-in-a-textarea-in-pixels var position span id 'nextword' nextword span 0 range.insertNode position var nextwordtop #nextword .position .top Insert `#caret`.. div 0 .childNodes 0 index var caret span id 'caret' span 0 range.insertNode caret var carettop #caret .position .top If preceding character.. .childNodes 0 index var prevchar span id 'prevchar' span 0 range.insertNode prevchar var prevchartop #prevchar .position .top Set textarea..
Contenteditable text editor and cursor position http://stackoverflow.com/questions/2937975/contenteditable-text-editor-and-cursor-position .getRangeAt 0 node range.createContextualFragment html range.insertNode node else if document.selection document.selection.createRange..
getSelection() not working in IE http://stackoverflow.com/questions/5421892/getselection-not-working-in-ie span.style.color red span.appendChild selectionContents range.insertNode span Coded up here http jsfiddle.net WdrC2 Thanks in advance.....
Dealing with line Breaks on contentEditable DIV http://stackoverflow.com/questions/6023307/dealing-with-line-breaks-on-contenteditable-div 0 br document.createElement br range.deleteContents range.insertNode br range.setStartAfter br range.setEndAfter br range.collapse.. being shown correctly range.deleteContents required or not range.insertNode br range.collapse false range.insertNode textNode range.selectNodeContents.. required or not range.insertNode br range.collapse false range.insertNode textNode range.selectNodeContents textNode selection.removeAllRanges..
Avoid createElement function if it's inside a <LI> element (contentEditable) http://stackoverflow.com/questions/6024594/avoid-createelement-function-if-its-inside-a-li-element-contenteditable 0 br document.createElement br range.deleteContents range.insertNode br range.setStartAfter br range.setEndAfter br range.collapse..
Insert html at caret in a contenteditable div http://stackoverflow.com/questions/6690752/insert-html-at-caret-in-a-contenteditable-div while node el.firstChild lastNode frag.appendChild node range.insertNode frag Preserve the selection if lastNode range range.cloneRange.. frag.appendChild node var firstNode frag.firstChild range.insertNode frag Preserve the selection if lastNode range range.cloneRange..
Rangy (JS/jQuery) split node http://stackoverflow.com/questions/11111704/rangy-js-jquery-split-node range.extractContents Collapse the range immediately after the paragraph range.collapseAfter p Insert the content range.insertNode contentAfterRangeStart Move the caret to the insertion point range.collapseAfter p sel.setSingleRange range share improve..
Web Page Source Annotation Tool http://stackoverflow.com/questions/14244498/web-page-source-annotation-tool 0 remove selection range.deleteContents Create a node node range.createContextualFragment html Add the custom node range.insertNode node div #univ .click function Get Selected text var selection document.getSelection Add your tags and prepare replacing.. 0 remove selection range.deleteContents Create a node node range.createContextualFragment html Add the custom node range.insertNode node Output1 Now You can replace any part of text Output 2 Replace any web page Saving file to chosen Location It is possible..
How can I position an element next to user text selection? http://stackoverflow.com/questions/1589721/how-can-i-position-an-element-next-to-user-text-selection document.createElement span markerEl.id markerId markerEl.appendChild document.createTextNode markerTextChar range.insertNode markerEl if markerEl Lazily create element to be placed next to the selection if selectionEl selectionEl document.createElement..
Get the offset position of the caret in a textarea in pixels http://stackoverflow.com/questions/16212871/get-the-offset-position-of-the-caret-in-a-textarea-in-pixels div 0 .childNodes 0 end var nextword range.toHtml range.deleteContents var position span id 'nextword' nextword span 0 range.insertNode position var nextwordtop #nextword .position .top Insert `#caret` at the position of the caret range.setStart div 0 .childNodes.. Insert `#caret` at the position of the caret range.setStart div 0 .childNodes 0 index var caret span id 'caret' span 0 range.insertNode caret var carettop #caret .position .top If preceding character is a space wrap it in a span if previouscharacter ' ' range.setStart.. div 0 .childNodes 0 index 1 range.setEnd div 0 .childNodes 0 index var prevchar span id 'prevchar' span 0 range.insertNode prevchar var prevchartop #prevchar .position .top Set textarea selection back to selection start this .focus this .setSelection..
Contenteditable text editor and cursor position http://stackoverflow.com/questions/2937975/contenteditable-text-editor-and-cursor-position if sel.getRangeAt sel.rangeCount range window.getSelection .getRangeAt 0 node range.createContextualFragment html range.insertNode node else if document.selection document.selection.createRange document.selection.createRange .pasteHTML html I've adapted..
getSelection() not working in IE http://stackoverflow.com/questions/5421892/getselection-not-working-in-ie range.extractContents var span document.createElement span span.style.color red span.appendChild selectionContents range.insertNode span Coded up here http jsfiddle.net WdrC2 Thanks in advance... javascript jquery internet explorer share improve this..
Dealing with line Breaks on contentEditable DIV http://stackoverflow.com/questions/6023307/dealing-with-line-breaks-on-contenteditable-div var selection window.getSelection range selection.getRangeAt 0 br document.createElement br range.deleteContents range.insertNode br range.setStartAfter br range.setEndAfter br range.collapse false selection.removeAllRanges selection.addRange range return.. u00a0 Passing directly will not end up being shown correctly range.deleteContents required or not range.insertNode br range.collapse false range.insertNode textNode range.selectNodeContents textNode selection.removeAllRanges selection.addRange.. will not end up being shown correctly range.deleteContents required or not range.insertNode br range.collapse false range.insertNode textNode range.selectNodeContents textNode selection.removeAllRanges selection.addRange range return false share improve..
Avoid createElement function if it's inside a <LI> element (contentEditable) http://stackoverflow.com/questions/6024594/avoid-createelement-function-if-its-inside-a-li-element-contenteditable var selection window.getSelection range selection.getRangeAt 0 br document.createElement br range.deleteContents range.insertNode br range.setStartAfter br range.setEndAfter br range.collapse false selection.removeAllRanges selection.addRange range return..
Insert html at caret in a contenteditable div http://stackoverflow.com/questions/6690752/insert-html-at-caret-in-a-contenteditable-div html var frag document.createDocumentFragment node lastNode while node el.firstChild lastNode frag.appendChild node range.insertNode frag Preserve the selection if lastNode range range.cloneRange range.setStartAfter lastNode range.collapse true sel.removeAllRanges.. node lastNode while node el.firstChild lastNode frag.appendChild node var firstNode frag.firstChild range.insertNode frag Preserve the selection if lastNode range range.cloneRange range.setStartAfter lastNode if selectPastedContent ..
|