Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

115
Vistas
Select the parent tags in CKeditor javascript

I am dealing with a CKeditor plugin issue, that I developed. I want to simple add custom html to wrap around an exiting list. However when I try to do this the selected text does not include the parent tag when the user select the list. I hope this makes sense, here is my JS file. I want to select the ul tags as well, it is currently only selecting the li tags.

/**
 * @file
 * Checkbox plugin definition. </div>'
 */
CKEDITOR.plugins.add("checkbox", {
  init: function (editor) {
    "use strict";

    editor.addCommand("checkbox_template", {
      exec: function (editor) {
        var selectedHtml = "";
        var selection = editor.getSelection();


        if (selection) {
          selectedHtml = getSelectionHtml(selection);
        }

        editor.insertHtml("<div class=\"checkbox-list\">" + selectedHtml + "</div>");

     },
  });

    editor.ui.addButton("Checkbox", {
      label: "Checkbox (WYSIWYG)",
      toolbar: "insert",
      command: "checkbox_template",
      icon: this.path + "image/checkbox.jpeg",
    });
  },
});
/**
 Get HTML of a selection.
 */

function getSelectionHtml(selection) {
   var ranges = selection.getRanges();
   for (var i = 0; i < ranges.length; i++) {
    var content = ranges[i].extractContents();
    html = content.getHtml();
  }
  return html;
}

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda