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

357
Vistas
How to open view-code modal that contains the source code in grapesjs?

I just started using grapesjs and I'm trying tobuild a simple web builder using grapesjs, I customized my editor's UI. I'm trying to add a view code button similar to the one in grapesjs Demo that shows the source code in a modal like this one grapesjs code modal

right now I added the export button to my panel

const editor = grapesjs.init({
  ...
  // panels config
  panels: {
    defaults: [
      {
        id: "basic-actions",
        el: "#actions",
        buttons: [
          {
            id: "visibility",
            active: true,
            label: "<i class='fa-solid fa-eye'></i>",
            command: "sw-visibility",
          },
          {
            id: "save",
            label: "<i class='fa fa-paper-plane btn-save'></i>",
            command: "save-project",
          },
          {
            id: "cmd-clear",
            label: "<i class='fa-solid fa-trash'></i>",
            command: "cmd-clear",
          },
          {
            id: "undo",
            label: "<i class='fa-solid fa-undo'></i>",
            command: "undo",
          },
          {
            id: "redo",
            label: "<i class='fa-solid fa-redo'></i>",
            command: "redo",
          },
          {
            id: "export",
            label: "<i class='fa-solid fa-download'></i>",
            command: "export",
          },
        ]
      },
    ]
  },
})

now I'm want to set the code to "export" command so I can show that modal here I'm stuck

editor.Commands.add('export', {
  run: (editor) => {
    // what to do ???
    console.log(editor.getHtml())
  }
})
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I found this in the official documentaion

{
    id: "export",
    label: "<i class='fa-solid fa-download'></i>",
    command: "export-template",
    context: "export-template",
},

and it solves my problem. and about downloading the files I used this plugin

about 4 years ago · Juan Pablo Isaza Denunciar
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