Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

114
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda