bit-docs / bit-docs-tag-demo

@demo tag for bit-docs
https://www.npmjs.com/package/bit-docs-tag-demo
MIT License
1 stars 0 forks source link

Fix code copy button #22

Closed cherifGsoul closed 5 years ago

cherifGsoul commented 5 years ago

Fixes "Copy" button which copies empty string.

The issue is that a copy button for each demo gets registered in the bit-docs-prettify step when the demos code is empty

The logic behind the changes

  1. Update the template in the demo_tpl.js to have empty <pre> element
  2. Update the process function in the demo_frame.js by creating a <code> element, setting its innerHTML and append it to <pre>

Like this Copy button will be registered at the right time instead of during bit-docs-prettify step.

Fixes https://github.com/canjs/canjs/issues/5126