Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I create tags using Rangy.js without a class attribute?
    primarykey
    data
    text
    <p>I've been playing with Rangy.js for selection ranges and so far really like it. I'm looking to wrap a selection range's text nodes within a certain tag and toggle this upon button click. I have it working great using the cssClassApplierModule with the exception of (and it makes sense due to the name) I HAVE to also give the dom element a class that it's applying to itself.</p> <p>So right now when I select a range and apply for instance a strong tag, my end result is:</p> <pre><code>Text text text &lt;strong class="test"&gt; selected text &lt;/strong&gt; text text text </code></pre> <p>And I'd like it to be:</p> <pre><code>Text text text &lt;strong&gt; selected text &lt;/strong&gt; text text text </code></pre> <p>The code I have so far is as follows:</p> <pre><code>function gEBI(id) { return document.getElementById(id); } var action; function toggleAction() { action.toggleSelection(); } rangy.init(); // Enable buttons var cssClassApplierModule = rangy.modules.CssClassApplier; // Next line is pure paranoia: it will only return false if the browser has no support for ranges, // selections or TextRanges. Even IE 5 would pass this test. if (rangy.supported &amp;&amp; cssClassApplierModule &amp;&amp; cssClassApplierModule.supported) { action = rangy.createCssClassApplier("test", { elementTagName: "strong", elementProperties: { } }); var toggleActionButton = gEBI(nsID); toggleActionButton.disabled = false; toggleActionButton.ontouchstart = toggleActionButton.onmousedown = function () { toggleAction(); return false; }; } </code></pre> <p>I tried "" and null instead of "text" as the css class being passed, and it will toggle, but no longer toggle off and is obviously not the correct solution.</p> <p>Any help appreciated.. Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload