javascript - HTML node at caret position in contenteditable <div> -


I am working on the original Rich Text Editor (RTE) for a private site on which we are working. The site requires the use of RTTE to add a blog post.

Everything is working fine, but I would like to toggle the active status of the buttons in the toolbar when they have specific style applied. It works fine for things like bold, italic etc. Because we can use the document.queryCommandValue ("bold") , and so on.

We have the problem that & lt; Blockquote / & gt; and & lt; A / & gt; There is no way to detect things like tags

We use & lt; Blockquote & gt; Add the elements as follows:

  // Insert a blockquote: this._blockquote = function () {// Receive the selected text: var theText = this._getSelectedText () ; // What are we taking? If (theText! = '') {Var quote = $ ('& lt; block / & gt;'). Html (theText) .html (); This._cmd ('inserthtml', 'blockpost & gt;' + quote + '& lt; / blockquote & gt;'); } Else {this._cmd ('inserthtml', '
gt; & lt; / blockquote & gt;'); }}

My question is, how do we get a contenteditable ? For example, type my cursor to & lt; Blockquote & gt; "Blockquote" (or something similar) should be returned by putting it inside the node.

jQuery is an option

So, the following example has been given:

  & lt; Blockquote & gt; Some | & Lt; P & gt; Text & lt; / P & gt; & Lt; / Blockquote & gt; ^ Cursor / Carat Status  

I'm looking to return blockquote (because is in some text blockquote).

In this way you can see what type of element you are currently viewing. Function works with Chrome. With recursive function we can return the entire array.

  function returnNodeType () {var node = null; Node = window.getSelection () getRangeAt (0) .commonAncestorContainer. Node = ((node.Nodtip === 1) node: nodepiernet); Var nodarere = []; Returnarray = returnParentTag (node, node); Return refund; } Function returns parent tag (emil, node array) {node arrow pen (elem.tagName); If (elem.id! = "Editor") {var next = returnParentTag (elem.parentNode, nodeArray); If the next (next) return; } And return to node array; }  

A jsfiddle link can be found here:


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -