
Security News
The Code You Didn't Write Is Still Yours to Defend
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.
storybook-addon-html-document
Advanced tools
A Storybook addon that extracts and displays compiled syntax-highlighted HTML, and can load html documents.
A Storybook addon that extracts and displays compiled syntax-highlighted HTML, and can load html documents. It uses highlight.js for syntax highlighting.
Expand @whitespace-se/storybook-addon-html
npm i --save-dev storybook-addon-html-document
Create a file called main.js inside the .storybook directory and add the
following content:
// .storybook/main.js
module.exports = {
addons: [
'storybook-addon-html-document'
],
}
Add withHTMLDOC as a global decorator inside .storybook/preview.js:
// .storybook/preview.js
// if you use @storybook/html.
//import { addDecorator } from '@storybook/html';
//import { withHTMLDOC } from 'storybook-addon-html-document/html';
import { addDecorator } from '@storybook/react';
import { withHTMLDOC } from 'storybook-addon-html-document/react';
addDecorator(withHTMLDOC);
The HTML is formatted with Prettier. You can override the Prettier config
(except parser and plugins) by providing an object following the
Prettier API override format:
// .storybook/preview.js
// if you use @storybook/html.
//import { addDecorator } from '@storybook/html';
//import { withHTMLDOC } from 'storybook-addon-html-document/html';
import { addDecorator } from '@storybook/react';
import { withHTML } from 'storybook-addon-html-document/react';
addDecorator(
withHTML({
prettier: {
tabWidth: 4,
useTabs: false,
htmlWhitespaceSensitivity: 'strict',
},
}),
);
//Suggest moving to move stories native html resources outside the project.
baseConfig.module.rules.push({
test: /\.(html)$/,
include:[path.join(appPath,'/.storybook/resource')],
exclude: path.join(appPath,'/public/index.html'),
use: [{
loader:'html-loader',
options:{
minimize:false
}
}]
})
//Setup file-loader Ensure that html native resources are properly loaded
baseConfig.module.rules.push({
include:function(url){
//排除loader注入文件
if(!/node\_modules\/.*?\-loader/.test(url)){
return true
}else{
// console.log(url)
}
},
issuer:function(url){
if(/\.storybook\/resource.+\.html/.test(url)){
// console.log(url)
return true
}
},
loader:'file-loader',
options: {
name: 'static/media/[name].[hash:8].[ext]'
}
})
When importing the decorator, use the correct path for your framework, e.g. storybook-addon-html-document/react for React or storybook-addon-html-document/html for HTML.
Right now, the addon can be used with these frameworks:
FAQs
A Storybook addon that extracts and displays compiled syntax-highlighted HTML, and can load html documents.
The npm package storybook-addon-html-document receives a total of 115 weekly downloads. As such, storybook-addon-html-document popularity was classified as not popular.
We found that storybook-addon-html-document demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.