]> git.ardis.lu - event-hashes/commitdiff
Improve rich text paste into Word
authorArdis Lu <ardisglu@gmail.com>
Thu, 21 Mar 2024 06:03:51 +0000 (23:03 -0700)
committerArdis Lu <ardisglu@gmail.com>
Thu, 21 Mar 2024 06:03:51 +0000 (23:03 -0700)
The vendor prefixes limit scope and enable access to native Word features like theme fonts.

index.html

index 801594c16b00775e5ebd88f44d7a9b3c73e25536..75a7bcf12798624bc9ac752767d3bbd82e190a7d 100644 (file)
       else {
         const data = [new ClipboardItem({
           'text/plain': new Blob([table.innerText], { type: 'text/plain' }),
-          'text/html': new Blob([`<style>table{white-space:nowrap}</style>${table.outerHTML}`], { type: 'text/html' })
+          'text/html': new Blob([`<style>table{white-space:nowrap;border-collapse:collapse;mso-ascii-theme-font:minor-latin;}th,td{mso-border-alt:solid windowtext .5pt;}thead{background:#E8E8E8;}</style>${table.outerHTML}`], { type: 'text/html' })
         })];
         navigator.clipboard.write(data);
       }
This page took 0.043345 seconds and 4 git commands to generate.