Rangy.js - createClassApplier with multiple classes

I am trying to create a class application that will wrap the selection in the following element:

<code class="mainClass selector1 selector2">Selected Content</code> 

I do the following:

 var Applier = rangy.createClassApplier("mainClass", { elementTagName: "code", elementProperties: { className: [ "selector1", "selector2" ] } }); Applier.toggleSelection(); 

This gives the following:

 <code class="mainClass selector1,selector2">Selected Content</code> 

What is the syntax for creating an application so that it does what I'm trying to do?

+5
source share
1 answer

It seems that this has not been implemented ( see here ). To fix this, change line 69 to range.classApplied to do this:

if (typeof el.classList == "object" && typeof className == "object")

0
source

Source: https://habr.com/ru/post/1257936/


All Articles