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

240
Vistas
use navigator clipboard to store image/png from canvas blob

I tried to store canvas blob into navigator clipboard

graphicDiv.addEventListener(
      'click',
      (event) => {
        const canvas = <HTMLCanvasElement> document.getElementById('canvas');
        canvas.toBlob((blob) => {
          if (blob) {
            let data = [new ClipboardItem({ [blob.type]: blob })];

            navigator.clipboard.write(data).then(
              function () {},
              function (err) {}
            );
          }
        });
      },
      false
    );

it seems something is wrong since TS gives me errors as follow

Argument of type '{ [x: string]: Blob; }' is not assignable to parameter of type 'Record<string, ClipboardItemData>'.
  'string' index signatures are incompatible.
    Type 'Blob' is missing the following properties from type 'Promise<ClipboardItemDataType>
error TS2339: Property 'write' does not exist on type 'Clipboard'.

102            let data = [new ClipboardItem({ [blob.type]: blob })];
                                      ~~~~~

is there any one familier with how to store canvas chartjs chart into the clipboard?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

https://www.w3.org/TR/clipboard-apis/#typedefdef-clipboarditemdata 6.4.2. Writing to the clipboard

These data types must be placed on the clipboard with a corresponding native type description if added to a DataTransfer object during copy and cut events.

 text/plain

 text/uri-list

 text/csv

 text/html

 image/svg+xml

 application/xml, text/xml

 application/json
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