├── docs
├── .nojekyll
├── style.css
├── index.html
└── README.md
├── config
├── prod.env.js
├── dev.env.js
└── index.js
├── src
├── assets
│ ├── dev.scss
│ ├── logo.png
│ └── demoBlock.scss
├── util
│ ├── guid.js
│ ├── createStyle.js
│ └── strip-tags.js
├── main.jsx
├── components
│ ├── index.jsx
│ └── demo-block.jsx
└── plugin
│ └── index.js
├── .editorconfig
├── .postcssrc.js
├── .gitignore
├── .babelrc
├── index.html
├── README.md
├── LICENSE
├── package.json
└── dist
└── docsify-demo-box-react.min.js
/docs/.nojekyll:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/style.css:
--------------------------------------------------------------------------------
1 | .demo-block {
2 | margin-bottom: 20px;
3 | }
4 |
--------------------------------------------------------------------------------
/config/prod.env.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | NODE_ENV: '"production"'
3 | }
4 |
--------------------------------------------------------------------------------
/src/assets/dev.scss:
--------------------------------------------------------------------------------
1 | body {
2 | overflow-y: scroll !important;
3 | // padding-top: 1000px;
4 | }
5 |
--------------------------------------------------------------------------------
/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/njleonzhang/docsify-demo-box-react/HEAD/src/assets/logo.png
--------------------------------------------------------------------------------
/config/dev.env.js:
--------------------------------------------------------------------------------
1 | var merge = require('webpack-merge')
2 | var prodEnv = require('./prod.env')
3 |
4 | module.exports = merge(prodEnv, {
5 | NODE_ENV: '"development"'
6 | })
7 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
--------------------------------------------------------------------------------
/src/util/guid.js:
--------------------------------------------------------------------------------
1 | export default function() {
2 | function s4() {
3 | return Math.floor((1 + Math.random()) * 0x10000)
4 | .toString(16)
5 | .substring(1);
6 | }
7 | return 'demoBlock' + s4();
8 | }
9 |
--------------------------------------------------------------------------------
/.postcssrc.js:
--------------------------------------------------------------------------------
1 | // https://github.com/michael-ciniawsky/postcss-load-config
2 |
3 | module.exports = {
4 | "plugins": {
5 | // to edit target browsers: use "browserlist" field in package.json
6 | "autoprefixer": {}
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | npm-debug.log*
4 | yarn-debug.log*
5 | yarn-error.log*
6 |
7 | # Editor directories and files
8 | .idea
9 | *.suo
10 | *.ntvs*
11 | *.njsproj
12 | *.sln
13 |
14 | docs/docsify-demo-box-react.js
15 |
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | ["es2015", { "modules": false }],
4 | "stage-2",
5 | "react"
6 | ],
7 | "plugins": [
8 | "react-hot-loader/babel",
9 | "transform-async-to-generator",
10 | "transform-decorators-legacy"
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/src/util/createStyle.js:
--------------------------------------------------------------------------------
1 | export default function(css) {
2 | let style = document.createElement('style')
3 |
4 | style.type = 'text/css'
5 | if (style.styleSheet) {
6 | style.styleSheet.cssText = css
7 | } else {
8 | style.appendChild(document.createTextNode(css))
9 | }
10 | document.head.appendChild(style)
11 | }
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | element-demo-box
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/util/strip-tags.js:
--------------------------------------------------------------------------------
1 | exports.strip = function(str, tags) {
2 | var dummyNode = document.createElement("DIV")
3 | dummyNode.innerHTML = str
4 |
5 | tags = tags ? [].concat(tags) : []
6 |
7 | tags.forEach(tag => {
8 | let targetNode = dummyNode.querySelector(tag)
9 | if (targetNode) {
10 | dummyNode.removeChild(targetNode)
11 | }
12 | })
13 |
14 | return dummyNode.innerHTML.trim()
15 | };
16 |
17 | exports.fetch = function(str, tag) {
18 | var dummyNode = document.createElement("DIV")
19 | dummyNode.innerHTML = str
20 |
21 | return dummyNode.querySelector(tag)
22 | ? dummyNode.querySelector(tag).innerHTML.trim()
23 | : ""
24 | };
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # docsify-demo-box-react
2 |
3 | > write React jsx demo in [docsify](https://docsify.js.org/#/) with instant preview and `jsfiddle` integration
4 |
5 |
6 | Your sample code can be rendered on the page instantly, so the people who read your document can see the preview immediately.
7 | If he/she expands the demo box, the source code and description are shown there.
8 | Click the button `Try in Jsfiddle`, `jsfiddle.net` will be open with the code of this sample.
9 |
10 | [Doc](https://njleonzhang.github.io/docsify-demo-box-react/)
11 |
12 | This plugin is for React. For Vue, please use [docsify-demo-box-vue](https://njleonzhang.github.io/docsify-demo-box-vue)
13 |
14 | ## Showcase
15 |
16 | These projects are using `docsify-demo-box-react`. Pull requests welcome :blush:
17 |
18 | | Project | Description |
19 | |---|---|
20 | | [soui-react](https://github.com/sodalife/soui-react/) | Soda UI Components for React |
21 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Leon Zhang
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/main.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import ReactDOM from 'react-dom'
3 | import {generateComponent} from './components'
4 | import './assets/dev.scss'
5 |
6 | let jsResources = '' +
7 | '\n'
8 |
9 | let cssResources = '@import url("//unpkg.com/element-ui/lib/theme-default/index.css");'
10 | let bootCode = ''
11 |
12 | let code = `
13 | hello word
14 |
29 | `
30 |
31 | var Component = generateComponent(code, 'jsx', jsResources, cssResources, bootCode)
32 |
33 | ReactDOM.render(
34 | ,
35 | document.getElementById('apphook')
36 | )
37 |
--------------------------------------------------------------------------------
/config/index.js:
--------------------------------------------------------------------------------
1 | // see http://vuejs-templates.github.io/webpack for documentation.
2 | var path = require('path')
3 |
4 | module.exports = {
5 | build: {
6 | env: require('./prod.env'),
7 | index: path.resolve(__dirname, '../dist/index.html'),
8 | assetsRoot: path.resolve(__dirname, '../dist'),
9 | assetsSubDirectory: 'static',
10 | assetsPublicPath: '/',
11 | productionSourceMap: true,
12 | // Gzip off by default as many popular static hosts such as
13 | // Surge or Netlify already gzip all static assets for you.
14 | // Before setting to `true`, make sure to:
15 | // npm install --save-dev compression-webpack-plugin
16 | productionGzip: false,
17 | productionGzipExtensions: ['js', 'css'],
18 | // Run the build command with an extra argument to
19 | // View the bundle analyzer report after build finishes:
20 | // `npm run build --report`
21 | // Set to `true` or `false` to always turn it on or off
22 | bundleAnalyzerReport: process.env.npm_config_report
23 | },
24 | dev: {
25 | env: require('./dev.env'),
26 | port: 8080,
27 | autoOpenBrowser: true,
28 | assetsSubDirectory: 'static',
29 | assetsPublicPath: '/',
30 | proxyTable: {},
31 | // CSS Sourcemaps off by default because relative paths are "buggy"
32 | // with this option, according to the CSS-Loader README
33 | // (https://github.com/webpack/css-loader#sourcemaps)
34 | // In our experience, they generally work as expected,
35 | // just be aware of this issue when enabling this option.
36 | cssSourceMap: false
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/components/index.jsx:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react'
2 | import striptags from '../util/strip-tags'
3 | import DemoBlock from './demo-block'
4 | import marked from 'marked'
5 |
6 | export let generateComponent = function(code, lang, jsResources, cssResources, bootCode, scrollParentSelector) {
7 | let html = striptags.fetch(code, 'template')
8 | let style = striptags.fetch(code, 'style')
9 | let script = striptags.fetch(code, 'script')
10 | let descOrg = striptags.fetch(code, 'desc')
11 | let desc = marked && marked(descOrg) || descOrg
12 | let noBootCode = code.indexOf('/*no-boot-code*/') > -1
13 | if (noBootCode) {
14 | bootCode = ""
15 | }
16 |
17 | let allJsResources = jsResources
18 |
19 | let extraJsMatchStrList = code.match(/\/\*\s*jsResource\s*(.*\S)\s*\*\//)
20 | if (!!extraJsMatchStrList) {
21 | let jsList = extraJsMatchStrList[1].split(' ')
22 | for(let js of jsList) {
23 | allJsResources += `\n`
24 | }
25 | }
26 |
27 | let scripts = script.split('export default')
28 | let scriptStrOrg = `(function() {${scripts[0]} ; return (${scripts[1]})})()`
29 | let scriptStr = Babel && Babel.transform(scriptStrOrg, { presets: ['es2015', 'react', 'stage-2'] }).code || scriptStrOrg
30 | let MyCodeComponent = eval(scriptStr)
31 |
32 | let jsfiddle = {
33 | html,
34 | style,
35 | script
36 | }
37 |
38 | function DemoBlockWrapper(props) {
39 | return (
40 |
51 |
52 |
53 | )
54 | }
55 |
56 | return DemoBlockWrapper
57 | }
58 |
--------------------------------------------------------------------------------
/src/plugin/index.js:
--------------------------------------------------------------------------------
1 | import {generateComponent} from '../components/'
2 | import ReactDOM from 'react-dom'
3 |
4 | export let create = function(jsResources, cssResources, bootCode) {
5 | return function(hook, vm) {
6 | let id = 0
7 |
8 | class Components {
9 | constructor() {
10 | this.componentCache = {}
11 | }
12 |
13 | cache(Component, id) {
14 | let href = window.location.href
15 | let componentObj = {
16 | id,
17 | Component
18 | }
19 |
20 | if (this.componentCache[href]) {
21 | this.componentCache[href].push(componentObj)
22 | } else {
23 | this.componentCache[href] = [componentObj]
24 | }
25 | }
26 |
27 | renderFromCache() {
28 | let href = window.location.href
29 | let componentObjs = this.componentCache[href]
30 | if (componentObjs) {
31 | componentObjs.forEach(componentObj => {
32 | ReactDOM.render(componentObj.Component(), document.getElementById(componentObj.id + ''))
33 | })
34 | }
35 | }
36 | }
37 |
38 | let components = new Components()
39 |
40 | function renderComponent(Component, id) {
41 | components.cache(Component, id)
42 |
43 | setTimeout(function () {
44 | ReactDOM.render(Component(), document.getElementById(id + ''))
45 | })
46 | }
47 |
48 | // for debug
49 | window.__components = components
50 |
51 | window.$docsify.markdown = {
52 | renderer: {
53 | code: function(code, lang) {
54 | if (/^\/\*\s*react\s*\*\//.test(code)) {
55 | id++
56 | let Component = generateComponent(code, lang, jsResources, cssResources, bootCode)
57 | renderComponent(Component, id)
58 | return ''
59 | } else {
60 | lang = lang || ''
61 | let hl = Prism.highlight(code, Prism.languages[lang] || Prism.languages.markup)
62 | return '' + hl + '
'
63 | }
64 | }
65 | }
66 | }
67 |
68 | hook.mounted(function() {
69 | // Called after initial completion. Only trigger once, no arguments.
70 | vm.router.onchange(_ => {
71 | components.renderFromCache()
72 | })
73 | })
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/assets/demoBlock.scss:
--------------------------------------------------------------------------------
1 | .demo-block {
2 | border: solid 1px #eaeefb;
3 | border-radius: 4px;
4 | transition: .2s;
5 |
6 | &.hover {
7 | box-shadow: 0 0 8px 0 rgba(232, 237, 250, .6), 0 2px 4px 0 rgba(232, 237, 250, .5);
8 | }
9 |
10 | code {
11 | font-family: Menlo, Monaco, Consolas, Courier, monospace;
12 | }
13 |
14 | .demo-button {
15 | float: right;
16 | }
17 |
18 | .source {
19 | padding: 24px;
20 | }
21 |
22 | .meta {
23 | background-color: #f9fafc;
24 | border-top: solid 1px #eaeefb;
25 | clear: both;
26 | overflow: hidden;
27 | height: 0;
28 | transition: height .2s;
29 | }
30 |
31 | .description {
32 | padding: 18px 24px;
33 | width: 40%;
34 | box-sizing: border-box;
35 | border-left: solid 1px #eaeefb;
36 | float: right;
37 | font-size: 14px;
38 | line-height: 1.8;
39 | color: #5e6d82;
40 | word-break: break-word;
41 |
42 | p {
43 | margin: 0 0 12px;
44 | line-height: 1.8;
45 | }
46 |
47 | code {
48 | color: #5e6d82;
49 | background-color: #e6effb;
50 | margin: 0 4px;
51 | display: inline-block;
52 | padding: 1px 5px;
53 | font-size: 12px;
54 | border-radius: 3px;
55 | height: 18px;
56 | line-height: 18px;
57 | }
58 |
59 | button {
60 | height: 36px;
61 | line-height: 36px;
62 | text-align: center;
63 | background: #20a0ff;
64 | border: none;
65 | outline: none;
66 | border-radius: 5px;
67 | color: white;
68 | display: block;
69 | font-size: 14px;
70 | padding-left: 10px;
71 | padding-right: 10px;
72 |
73 | &:hover {
74 | background: #4db3ff;
75 | }
76 | }
77 | }
78 |
79 | .highlight {
80 | width: 60%;
81 | border-right: solid 1px #eaeefb;
82 |
83 | pre {
84 | margin: 0;
85 | }
86 |
87 | code.hljs {
88 | margin: 0;
89 | border: none;
90 | max-height: none;
91 | border-radius: 0;
92 |
93 | &::before {
94 | content: none;
95 | }
96 | }
97 | .lang-css {
98 | padding-bottom: 0;
99 | }
100 | }
101 |
102 | .demo-block-control {
103 | border-top: solid 1px #eaeefb;
104 | height: 36px;
105 | box-sizing: border-box;
106 | background-color: #fff;
107 | border-bottom-left-radius: 4px;
108 | border-bottom-right-radius: 4px;
109 | text-align: center;
110 | margin-top: -1px;
111 | color: #d3dce6;
112 | cursor: pointer;
113 | transition: .2s;
114 | position: relative;
115 |
116 | &.is-fixed {
117 | position: fixed;
118 | bottom: 0;
119 | width: 868px;
120 | }
121 |
122 | i {
123 | font-size: 12px;
124 | line-height: 36px;
125 | transition: .3s;
126 | &.hovering {
127 | transform: translateX(-40px);
128 | }
129 | }
130 |
131 | span {
132 | position: absolute;
133 | transform: translateX(-30px);
134 | font-size: 14px;
135 | line-height: 36px;
136 | transition: .3s;
137 | display: inline-block;
138 | color: #58B7FF;
139 |
140 | &:hover {
141 | color: #1D8CE0;
142 | }
143 | }
144 |
145 | & .text-slide-enter,
146 | & .text-slide-leave-active {
147 | opacity: 0;
148 | transform: translateX(10px);
149 | }
150 | }
151 | }
152 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "docsify-demo-box-react",
3 | "version": "1.1.0",
4 | "description": "write React jsx demo in docsify with instant preview and jsfiddle integration",
5 | "author": "njleonzhang ",
6 | "scripts": {
7 | "dev": "node build/dev-server.js",
8 | "start": "node build/dev-server.js",
9 | "build": "node build/build.js",
10 | "plugin": "node build/build.js plugin; cp dist/docsify-demo-box-react.js docs/",
11 | "release": "build/release.sh"
12 | },
13 | "dependencies": {
14 | "classnames": "^2.2.5",
15 | "marked": "^0.3.6",
16 | "mobx": "^3.2.2",
17 | "prismjs": "^1.6.0",
18 | "prop-types": "^15.5.10",
19 | "react": "^15.6.1",
20 | "react-dom": "^15.6.1"
21 | },
22 | "devDependencies": {
23 | "autoprefixer": "^7.1.2",
24 | "babel-core": "^6.25.0",
25 | "babel-eslint": "^7.1.1",
26 | "babel-loader": "^7.1.1",
27 | "babel-plugin-istanbul": "^4.1.1",
28 | "babel-plugin-transform-async-to-generator": "^6.24.1",
29 | "babel-plugin-transform-decorators-legacy": "^1.3.4",
30 | "babel-plugin-transform-runtime": "^6.22.0",
31 | "babel-polyfill": "^6.23.0",
32 | "babel-preset-env": "^1.3.2",
33 | "babel-preset-es2015": "^6.24.1",
34 | "babel-preset-react": "^6.24.1",
35 | "babel-preset-stage-2": "^6.24.1",
36 | "babel-register": "^6.22.0",
37 | "chai": "^3.5.0",
38 | "chalk": "^2.0.1",
39 | "chromedriver": "^2.27.2",
40 | "compression-webpack-plugin": "^1.0.0",
41 | "connect-history-api-fallback": "^1.3.0",
42 | "copy-webpack-plugin": "^4.0.1",
43 | "cross-env": "^5.0.1",
44 | "cross-spawn": "^5.0.1",
45 | "css-loader": "^0.28.0",
46 | "eslint": "^4.3.0",
47 | "eslint-config-airbnb": "^15.1.0",
48 | "eslint-friendly-formatter": "^3.0.0",
49 | "eslint-loader": "^1.7.1",
50 | "eslint-plugin-html": "^3.1.1",
51 | "eslint-plugin-import": "^2.7.0",
52 | "eslint-plugin-jsx-a11y": "^5.1.1",
53 | "eslint-plugin-promise": "^3.4.0",
54 | "eslint-plugin-react": "^7.2.0",
55 | "eslint-plugin-standard": "^3.0.1",
56 | "eventsource-polyfill": "^0.9.6",
57 | "express": "^4.14.1",
58 | "extract-text-webpack-plugin": "^3.0.0",
59 | "file-loader": "^0.11.1",
60 | "friendly-errors-webpack-plugin": "^1.1.3",
61 | "html-webpack-inline-plugin": "^0.0.2",
62 | "html-webpack-plugin": "^2.28.0",
63 | "http-proxy-middleware": "^0.17.3",
64 | "husky": "^0.14.3",
65 | "inject-loader": "^3.0.0",
66 | "ip": "^1.1.5",
67 | "karma": "^1.4.1",
68 | "karma-coverage": "^1.1.1",
69 | "karma-mocha": "^1.3.0",
70 | "karma-phantomjs-launcher": "^1.0.2",
71 | "karma-phantomjs-shim": "^1.4.0",
72 | "karma-sinon-chai": "^1.3.1",
73 | "karma-sourcemap-loader": "^0.3.7",
74 | "karma-spec-reporter": "0.0.31",
75 | "karma-webpack": "^2.0.2",
76 | "lolex": "^2.1.2",
77 | "mocha": "^3.2.0",
78 | "nightwatch": "^0.9.12",
79 | "node-sass": "^4.5.3",
80 | "opn": "^5.1.0",
81 | "optimize-css-assets-webpack-plugin": "^3.0.0",
82 | "ora": "^1.2.0",
83 | "phantomjs-prebuilt": "^2.1.14",
84 | "postcss-loader": "^2.0.6",
85 | "postcss-pxtorem": "^4.0.1",
86 | "promise.prototype.finally": "^3.0.0",
87 | "react-hot-loader": "next",
88 | "rimraf": "^2.6.0",
89 | "sass-loader": "^6.0.6",
90 | "selenium-server": "^3.0.1",
91 | "semver": "^5.3.0",
92 | "shelljs": "^0.7.6",
93 | "sinon": "^2.1.0",
94 | "sinon-chai": "^2.8.0",
95 | "style-loader": "^0.18.2",
96 | "unminified-webpack-plugin": "^1.2.0",
97 | "url-loader": "^0.5.8",
98 | "webpack": "^3.5.1",
99 | "webpack-bundle-analyzer": "^2.2.1",
100 | "webpack-dev-middleware": "^1.10.0",
101 | "webpack-hot-middleware": "^2.18.2",
102 | "webpack-merge": "^4.1.0"
103 | },
104 | "engines": {
105 | "node": ">= 4.0.0",
106 | "npm": ">= 3.0.0"
107 | },
108 | "browserslist": [
109 | "> 1%",
110 | "last 2 versions",
111 | "not ie <= 8"
112 | ]
113 | }
114 |
--------------------------------------------------------------------------------
/src/components/demo-block.jsx:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react'
2 | import classNames from 'classnames'
3 | import '../assets/demoBlock.scss'
4 | import striptags from '../util/strip-tags'
5 | import createStyle from '../util/createStyle'
6 | import PropTypes from 'prop-types'
7 | import Prism from 'prismjs'
8 | import 'prismjs/components/prism-jsx.js'
9 |
10 | export default class DemoBlock extends Component {
11 | static defaultProps = {
12 | jsfiddle: {},
13 | desc: '',
14 | code: '',
15 | lang: '',
16 | jsResources: '',
17 | cssResources: '',
18 | bootCode: '',
19 | scrollParentSelector: '.section'
20 | }
21 |
22 | static propsTypes = {
23 | jsfiddle: PropTypes.object,
24 | desc: PropTypes.string,
25 | code: PropTypes.string,
26 | lang: PropTypes.string,
27 | jsResources: PropTypes.string,
28 | cssResources: PropTypes.string,
29 | bootCode: PropTypes.string,
30 | scrollParentSelector: PropTypes.string
31 | }
32 |
33 | constructor(props) {
34 | super(props)
35 |
36 | this.state = {
37 | hovering: false,
38 | controlText: 'Expand',
39 | codeAreaHeight: 0,
40 | fixedControl: false,
41 | demoControlStyle: {}
42 | }
43 |
44 | this.isExpanded = false
45 |
46 | const { style } = props.jsfiddle;
47 | createStyle(style);
48 |
49 | const hljx = Prism.highlight(
50 | striptags.fetch(
51 | this.props.code,
52 | 'script'
53 | ).replace(/\/\*.*\*\/\s*/g, ''),
54 | Prism.languages[this.props.lang] || Prism.languages.markup)
55 |
56 | const hlcss = Prism.highlight(
57 | style,
58 | Prism.languages.css || Prism.languages.markup)
59 |
60 | this.state.codePrismed = hlcss ? `
61 | ${hlcss}
62 |
` : '';
63 |
64 | this.state.codePrismed +=
65 | `
66 | ${hljx}
67 |
`;
68 | }
69 |
70 | componentDidMount() {
71 | if (this.codeArea.getElementsByClassName('description').length > 0) {
72 | this.codeAreaHeight =
73 | Math.max(this.codeArea.getElementsByClassName('description')[0].clientHeight,
74 | this.codeArea.getElementsByClassName('highlight')[0].clientHeight)
75 | } else {
76 | this.codeAreaHeight = this.codeArea.getElementsByClassName('highlight')[0].clientHeight
77 | }
78 | }
79 |
80 | onMouseEnter = _ => {
81 | this.setState({
82 | hovering: true
83 | })
84 | }
85 |
86 | onMouseLeave = _ => {
87 | this.setState({
88 | hovering: false
89 | })
90 | }
91 |
92 | toggleDetail = _ => {
93 | this.isExpanded = !this.isExpanded
94 |
95 | if (this.isExpanded) {
96 | this.setState({
97 | codeAreaHeight: `${this.codeAreaHeight}px`,
98 | controlText: 'Hide'
99 | })
100 |
101 | setTimeout(() => {
102 | this.scrollParent = document.querySelector(this.props.scrollParentSelector) || window;
103 | this.scrollParent && this.scrollParent.addEventListener('scroll', this.scrollHandler);
104 | this.scrollHandler();
105 | }, 200)
106 | } else {
107 | this.setState({
108 | codeAreaHeight: 0,
109 | controlText: 'Expand',
110 | fixedControl: false
111 | })
112 |
113 | this.removeScrollHandler()
114 | const { top, bottom, left, right } = this.codeArea.getBoundingClientRect()
115 |
116 | this.setState({
117 | demoControlStyle: {
118 | left: '0',
119 | width: 'auto'
120 | }
121 | })
122 | }
123 | }
124 |
125 | scrollHandler = () => {
126 | const { top, bottom, left, right } = this.codeArea.getBoundingClientRect()
127 | this.setState({
128 | fixedControl: bottom > document.documentElement.clientHeight && top + 36
129 | <= document.documentElement.clientHeight
130 | })
131 |
132 | this.setState({
133 | demoControlStyle: {
134 | left: this.state.fixedControl ? `${ left }px` : '0',
135 | width: this.state.fixedControl ? `${ right - left }px` : 'auto'
136 | }
137 | })
138 | }
139 |
140 | removeScrollHandler = () => {
141 | this.scrollParent && this.scrollParent.removeEventListener('scroll', this.scrollHandler)
142 | }
143 |
144 | goJsfiddle = _ => {
145 | const { script, html, style } = this.props.jsfiddle;
146 | let ComponentName = script.match(/export default class (.*) extends/)[1]
147 |
148 | let jsTpl = this.props.bootCode + '\n' + (script || '').replace(/export default/, '').trim()
149 | let htmlTpl = `${this.props.jsResources || ''}\n\n${html.trim()}\n
`
150 | let cssTpl = `${this.props.cssResources || ''}\n${(style || '').trim()}\n`;
151 |
152 | if (jsTpl) {
153 | jsTpl = `${jsTpl}\nReactDOM.render(<${ComponentName} \/>, document.getElementById("app"))`
154 | }
155 |
156 | const data = {
157 | js: jsTpl,
158 | css: cssTpl,
159 | html: htmlTpl,
160 | panel_js: 3,
161 | panel_css: 1
162 | };
163 | const form = document.getElementById('fiddle-form') || document.createElement('form')
164 | form.innerHTML = ''
165 | const node = document.createElement('textarea')
166 |
167 | form.method = 'post'
168 | form.action = 'https://jsfiddle.net/api/post/library/pure/'
169 | form.target = '_blank'
170 |
171 | for (let name in data) {
172 | node.name = name
173 | node.value = data[name].toString()
174 | form.appendChild(node.cloneNode())
175 | }
176 | form.setAttribute('id', 'fiddle-form')
177 | form.style.display = 'none'
178 | document.body.appendChild(form)
179 |
180 | form.submit()
181 | }
182 |
183 | render() {
184 | let hoverClass = classNames({
185 | 'demo-block': true,
186 | 'hover': this.state.hovering
187 | })
188 |
189 | let demoControlClass = classNames({
190 | 'demo-block-control': true,
191 | 'is-fixed': this.state.fixedControl
192 | })
193 |
194 | return (
195 |
199 |
200 | { this.props.children }
201 |
202 |
this.codeArea = codeArea} style={{height: this.state.codeAreaHeight}}>
203 |
204 |
205 |
206 |
207 |
208 |
209 |
this.control = control}
212 | onClick={this.toggleDetail}>
213 |
214 |
215 | { this.state.controlText }
216 |
217 |
218 |
219 | )
220 | }
221 |
222 | componentWillUnmount() {
223 | this.removeScrollHandler()
224 | }
225 | }
226 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | # [docsify-demo-box-react](https://github.com/njleonzhang/docsify-demo-box-react/)
2 |
3 | > A plugin for [docsify](https://docsify.js.org/#/) to write React jsx demo with instant preview and jsfiddle integration
4 |
5 | This plugin is for React. For Vue, please use [docsify-demo-box-vue](https://njleonzhang.github.io/docsify-demo-box-vue)
6 |
7 | ## Usage
8 |
9 | 1. import react and this plugin to docsify `index.html`
10 | ```html
11 |
12 |
13 |
14 | ```
15 |
16 | 2. Use this plugin as docsify plugin
17 | ```js
18 | var jsResources = '\n' +
19 | ''
20 | var cssResources = '@import url("//cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css");'
21 | var bootCode = 'var globalVariable = "leon"'
22 | var globalVariable = "leon"
23 |
24 | window.$docsify = {
25 | name: 'docsify-demo-box-react',
26 | repo: 'https://github.com/njleonzhang/docsify-demo-box-react',
27 | plugins: [
28 | DemoBoxReact.create(jsResources, cssResources, bootCode)
29 | ]
30 | }
31 | ```
32 |
33 | parameter of `create`:
34 | * jsResources: javascript script will be added in `jsfiddle` html filed
35 | * cssResources: css link will be added in `jsfiddle` css filed
36 | * bootCode: javascript code you want to add before sample code in `jsfiddle` javascript filed, which is usually used to boot your library.
37 |
38 |
39 | ## sample
40 |
41 | This doc is a sample, check the source [md](https://njleonzhang.github.io/docsify-demo-box-react/)
42 |
43 | write the following code with tag `/*react*/`:
44 |
45 | ```jsx
46 |
47 | Hello `world`
48 | * a
49 | * b
50 |
51 |
56 |
170 | ```
171 |
172 | ### special js link
173 | In this sample, default js resource is defined as `react` and `react-dom` in `index.html`
174 |
175 | ```
176 | // for preview
177 |
178 |
179 |
180 | // for jsfiddle
181 | var jsResources = '\n' +
182 | ''
183 | ```
184 |
185 |
186 | If you want to add special js resource for some samples, you need add `script` link in `index.html` for preview.
187 | At same time, use `jsResource` comment to add script for `jsfiffle`
188 |
189 | ```
190 | /*jsResource jslink1 jslink2 ...*/
191 | ```
192 |
193 | ```jsx
194 | /*react*/
195 | /*jsResource https://unpkg.com/vue */
196 |
197 | Hello world
198 |
199 |
222 | ```
223 |
224 | Try in `jsfiddle`, you will find the following script is added to `jsfiddle` html area.
225 | ```
226 |
227 | ```
228 |
--------------------------------------------------------------------------------
/dist/docsify-demo-box-react.min.js:
--------------------------------------------------------------------------------
1 | !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React")):"function"==typeof define&&define.amd?define(["React"],t):"object"==typeof exports?exports.DemoBoxReact=t(require("React")):e.DemoBoxReact=t(e.React)}("undefined"!=typeof self?self:this,function(__WEBPACK_EXTERNAL_MODULE_45__){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=80)}([function(e,t,n){"use strict";function r(e,t,n,r,i,a,s,l){if(o(t),!e){var u;if(void 0===t)u=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,i,a,s,l],p=0;u=new Error(t.replace(/%s/g,function(){return c[p++]})),u.name="Invariant Violation"}throw u.framesToPop=1,u}}var o=function(e){};e.exports=r},function(e,t,n){"use strict";function r(e){for(var t=arguments.length-1,n="Minified React error #"+e+"; visit http://facebook.github.io/react/docs/error-decoder.html?invariant="+e,r=0;r1){for(var h=Array(f),g=0;g1){for(var v=Array(m),y=0;y]/,l=n(36),u=l(function(e,t){if(e.namespaceURI!==i.svg||"innerHTML"in e)e.innerHTML=t;else{r=r||document.createElement("div"),r.innerHTML="";for(var n=r.firstChild;n.firstChild;)e.appendChild(n.firstChild)}});if(o.canUseDOM){var c=document.createElement("div");c.innerHTML=" ",""===c.innerHTML&&(u=function(e,t){if(e.parentNode&&e.parentNode.replaceChild(e,e),a.test(t)||"<"===t[0]&&s.test(t)){e.innerHTML=String.fromCharCode(65279)+t;var n=e.firstChild;1===n.data.length?e.removeChild(n):n.deleteData(0,1)}else e.innerHTML=t}),c=null}e.exports=u},function(e,t,n){"use strict";function r(e){var t=""+e,n=i.exec(t);if(!n)return t;var r,o="",a=0,s=0;for(a=n.index;a]/;e.exports=o},function(e,t,n){"use strict";function r(e){return Object.prototype.hasOwnProperty.call(e,g)||(e[g]=f++,p[e[g]]={}),p[e[g]]}var o,i=n(3),a=n(28),s=n(125),l=n(57),u=n(126),c=n(32),p={},d=!1,f=0,h={topAbort:"abort",topAnimationEnd:u("animationend")||"animationend",topAnimationIteration:u("animationiteration")||"animationiteration",topAnimationStart:u("animationstart")||"animationstart",topBlur:"blur",topCanPlay:"canplay",topCanPlayThrough:"canplaythrough",topChange:"change",topClick:"click",topCompositionEnd:"compositionend",topCompositionStart:"compositionstart",topCompositionUpdate:"compositionupdate",topContextMenu:"contextmenu",topCopy:"copy",topCut:"cut",topDoubleClick:"dblclick",topDrag:"drag",topDragEnd:"dragend",topDragEnter:"dragenter",topDragExit:"dragexit",topDragLeave:"dragleave",topDragOver:"dragover",topDragStart:"dragstart",topDrop:"drop",topDurationChange:"durationchange",topEmptied:"emptied",topEncrypted:"encrypted",topEnded:"ended",topError:"error",topFocus:"focus",topInput:"input",topKeyDown:"keydown",topKeyPress:"keypress",topKeyUp:"keyup",topLoadedData:"loadeddata",topLoadedMetadata:"loadedmetadata",topLoadStart:"loadstart",topMouseDown:"mousedown",topMouseMove:"mousemove",topMouseOut:"mouseout",topMouseOver:"mouseover",topMouseUp:"mouseup",topPaste:"paste",topPause:"pause",topPlay:"play",topPlaying:"playing",topProgress:"progress",topRateChange:"ratechange",topScroll:"scroll",topSeeked:"seeked",topSeeking:"seeking",topSelectionChange:"selectionchange",topStalled:"stalled",topSuspend:"suspend",topTextInput:"textInput",topTimeUpdate:"timeupdate",topTouchCancel:"touchcancel",topTouchEnd:"touchend",topTouchMove:"touchmove",topTouchStart:"touchstart",topTransitionEnd:u("transitionend")||"transitionend",topVolumeChange:"volumechange",topWaiting:"waiting",topWheel:"wheel"},g="_reactListenersID"+String(Math.random()).slice(2),m=i({},s,{ReactEventListener:null,injection:{injectReactEventListener:function(e){e.setHandleTopLevel(m.handleTopLevel),m.ReactEventListener=e}},setEnabled:function(e){m.ReactEventListener&&m.ReactEventListener.setEnabled(e)},isEnabled:function(){return!(!m.ReactEventListener||!m.ReactEventListener.isEnabled())},listenTo:function(e,t){for(var n=t,o=r(n),i=a.registrationNameDependencies[e],s=0;s-1||a("96",e),!u.plugins[n]){t.extractEvents||a("97",e),u.plugins[n]=t;var r=t.eventTypes;for(var i in r)o(r[i],t,i)||a("98",i,e)}}}function o(e,t,n){u.eventNameDispatchConfigs.hasOwnProperty(n)&&a("99",n),u.eventNameDispatchConfigs[n]=e;var r=e.phasedRegistrationNames;if(r){for(var o in r)if(r.hasOwnProperty(o)){var s=r[o];i(s,t,n)}return!0}return!!e.registrationName&&(i(e.registrationName,t,n),!0)}function i(e,t,n){u.registrationNameModules[e]&&a("100",e),u.registrationNameModules[e]=t,u.registrationNameDependencies[e]=t.eventTypes[n].dependencies}var a=n(1),s=(n(0),null),l={},u={plugins:[],eventNameDispatchConfigs:{},registrationNameModules:{},registrationNameDependencies:{},possibleRegistrationNames:null,injectEventPluginOrder:function(e){s&&a("101"),s=Array.prototype.slice.call(e),r()},injectEventPluginsByName:function(e){var t=!1;for(var n in e)if(e.hasOwnProperty(n)){var o=e[n];l.hasOwnProperty(n)&&l[n]===o||(l[n]&&a("102",n),l[n]=o,t=!0)}t&&r()},getPluginModuleForEvent:function(e){var t=e.dispatchConfig;if(t.registrationName)return u.registrationNameModules[t.registrationName]||null;if(void 0!==t.phasedRegistrationNames){var n=t.phasedRegistrationNames;for(var r in n)if(n.hasOwnProperty(r)){var o=u.registrationNameModules[n[r]];if(o)return o}}return null},_resetEventPlugins:function(){s=null;for(var e in l)l.hasOwnProperty(e)&&delete l[e];u.plugins.length=0;var t=u.eventNameDispatchConfigs;for(var n in t)t.hasOwnProperty(n)&&delete t[n];var r=u.registrationNameModules;for(var o in r)r.hasOwnProperty(o)&&delete r[o]}};e.exports=u},function(e,t,n){"use strict";function r(e){return"topMouseUp"===e||"topTouchEnd"===e||"topTouchCancel"===e}function o(e){return"topMouseMove"===e||"topTouchMove"===e}function i(e){return"topMouseDown"===e||"topTouchStart"===e}function a(e,t,n,r){var o=e.type||"unknown-event";e.currentTarget=v.getNodeFromInstance(r),t?g.invokeGuardedCallbackWithCatch(o,n,e):g.invokeGuardedCallback(o,n,e),e.currentTarget=null}function s(e,t){var n=e._dispatchListeners,r=e._dispatchInstances;if(Array.isArray(n))for(var o=0;o0&&r.length<20?n+" (keys: "+r.join(", ")+")":n}function i(e,t){var n=s.get(e);if(!n){return null}return n}var a=n(1),s=(n(10),n(21)),l=(n(7),n(8)),u=(n(0),n(2),{isMounted:function(e){var t=s.get(e);return!!t&&!!t._renderedComponent},enqueueCallback:function(e,t,n){u.validateCallback(t,n);var o=i(e);if(!o)return null;o._pendingCallbacks?o._pendingCallbacks.push(t):o._pendingCallbacks=[t],r(o)},enqueueCallbackInternal:function(e,t){e._pendingCallbacks?e._pendingCallbacks.push(t):e._pendingCallbacks=[t],r(e)},enqueueForceUpdate:function(e){var t=i(e,"forceUpdate");t&&(t._pendingForceUpdate=!0,r(t))},enqueueReplaceState:function(e,t,n){var o=i(e,"replaceState");o&&(o._pendingStateQueue=[t],o._pendingReplaceState=!0,void 0!==n&&null!==n&&(u.validateCallback(n,"replaceState"),o._pendingCallbacks?o._pendingCallbacks.push(n):o._pendingCallbacks=[n]),r(o))},enqueueSetState:function(e,t){var n=i(e,"setState");if(n){(n._pendingStateQueue||(n._pendingStateQueue=[])).push(t),r(n)}},enqueueElementInternal:function(e,t,n){e._pendingElement=t,e._context=n,r(e)},validateCallback:function(e,t){e&&"function"!=typeof e&&a("122",t,o(e))}});e.exports=u},function(e,t,n){"use strict";var r=(n(3),n(6)),o=(n(2),r);e.exports=o},function(e,t,n){"use strict";function r(e){var t,n=e.keyCode;return"charCode"in e?0===(t=e.charCode)&&13===n&&(t=13):t=n,t>=32||13===t?t:0}e.exports=r},function(e,t){e.exports=__WEBPACK_EXTERNAL_MODULE_45__},function(e,t){t.strip=function(e,t){var n=document.createElement("DIV");return n.innerHTML=e,t=t?[].concat(t):[],t.forEach(function(e){var t=n.querySelector(e);t&&n.removeChild(t)}),n.innerHTML.trim()},t.fetch=function(e,t){var n=document.createElement("DIV");return n.innerHTML=e,n.querySelector(t)?n.querySelector(t).innerHTML.trim():""}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";var r={hasCachedChildNodes:1};e.exports=r},function(e,t,n){"use strict";function r(e,t){return null==t&&o("30"),null==e?t:Array.isArray(e)?Array.isArray(t)?(e.push.apply(e,t),e):(e.push(t),e):Array.isArray(t)?[e].concat(t):[e,t]}var o=n(1);n(0);e.exports=r},function(e,t,n){"use strict";function r(e,t,n){Array.isArray(e)?e.forEach(t,n):e&&t.call(n,e)}e.exports=r},function(e,t,n){"use strict";function r(){return!i&&o.canUseDOM&&(i="textContent"in document.documentElement?"textContent":"innerText"),i}var o=n(5),i=null;e.exports=r},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=n(1),i=n(11),a=(n(0),function(){function e(t){r(this,e),this._callbacks=null,this._contexts=null,this._arg=t}return e.prototype.enqueue=function(e,t){this._callbacks=this._callbacks||[],this._callbacks.push(e),this._contexts=this._contexts||[],this._contexts.push(t)},e.prototype.notifyAll=function(){var e=this._callbacks,t=this._contexts,n=this._arg;if(e&&t){e.length!==t.length&&o("24"),this._callbacks=null,this._contexts=null;for(var r=0;r1)for(var n=1;n.":"function"==typeof t?" Instead of passing a class like Foo, pass React.createElement(Foo) or .":null!=t&&void 0!==t.props?" This may be caused by unintentionally loading two independent copies of React.":"");var a,s=m.createElement(U,{child:t});if(e){var l=x.get(e);a=l._processChildContext(l._context)}else a=P;var c=d(n);if(c){var p=c._currentElement,h=p.props.child;if(M(h,t)){var g=c._renderedComponent.getPublicInstance(),v=r&&function(){r.call(g)};return j._updateRootComponent(c,s,a,n,v),g}j.unmountComponentAtNode(n)}var y=o(n),b=y&&!!i(y),_=u(n),C=b&&!c&&!_,A=j._renderNewRootComponent(s,n,C,a)._renderedComponent.getPublicInstance();return r&&r.call(A),A},render:function(e,t,n){return j._renderSubtreeIntoContainer(null,e,t,n)},unmountComponentAtNode:function(e){c(e)||f("40");var t=d(e);if(!t){u(e),1===e.nodeType&&e.hasAttribute(I);return!1}return delete B[t._instance.rootID],w.batchedUpdates(l,t,e,!1),!0},_mountImageIntoNode:function(e,t,n,i,a){if(c(t)||f("41"),i){var s=o(t);if(A.canReuseMarkup(e,s))return void y.precacheNode(n,s);var l=s.getAttribute(A.CHECKSUM_ATTR_NAME);s.removeAttribute(A.CHECKSUM_ATTR_NAME);var u=s.outerHTML;s.setAttribute(A.CHECKSUM_ATTR_NAME,l);var p=e,d=r(p,u),g=" (client) "+p.substring(d-20,d+20)+"\n (server) "+u.substring(d-20,d+20);t.nodeType===R&&f("42",g)}if(t.nodeType===R&&f("43"),a.useCreateElement){for(;t.lastChild;)t.removeChild(t.lastChild);h.insertTreeBefore(t,e,null)}else S(t,e),y.precacheNode(n,t.firstChild)}};e.exports=j},function(e,t,n){"use strict";function r(e){for(var t;(t=e._renderedNodeType)===o.COMPOSITE;)e=e._renderedComponent;return t===o.HOST?e._renderedComponent:t===o.EMPTY?null:void 0}var o=n(70);e.exports=r},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),n.d(t,"create",function(){return l});var o=n(81),i=n(95),a=n.n(i),s=function(){function e(e,t){for(var n=0;n'}return''+Prism.highlight(r,Prism.languages[i]||Prism.languages.markup)+"
"}}},i.mounted(function(){l.router.onchange(function(e){d.renderFromCache()})})}}},function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.d(__webpack_exports__,"a",function(){return generateComponent});var __WEBPACK_IMPORTED_MODULE_0_react__=__webpack_require__(45),__WEBPACK_IMPORTED_MODULE_0_react___default=__webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__),__WEBPACK_IMPORTED_MODULE_1__util_strip_tags__=__webpack_require__(46),__WEBPACK_IMPORTED_MODULE_1__util_strip_tags___default=__webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__util_strip_tags__),__WEBPACK_IMPORTED_MODULE_2__demo_block__=__webpack_require__(82),__WEBPACK_IMPORTED_MODULE_3_marked__=__webpack_require__(94),__WEBPACK_IMPORTED_MODULE_3_marked___default=__webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_marked__),generateComponent=function generateComponent(code,lang,jsResources,cssResources,bootCode,scrollParentSelector){function DemoBlockWrapper(e){return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_2__demo_block__.a,{className:"demo-box",jsfiddle:jsfiddle,code:code,desc:desc,lang:lang,jsResources:allJsResources,cssResources:cssResources,bootCode:bootCode,noBootCode:noBootCode,scrollParentSelector:scrollParentSelector},__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(MyCodeComponent,null))}var html=__WEBPACK_IMPORTED_MODULE_1__util_strip_tags___default.a.fetch(code,"template"),style=__WEBPACK_IMPORTED_MODULE_1__util_strip_tags___default.a.fetch(code,"style"),script=__WEBPACK_IMPORTED_MODULE_1__util_strip_tags___default.a.fetch(code,"script"),descOrg=__WEBPACK_IMPORTED_MODULE_1__util_strip_tags___default.a.fetch(code,"desc"),desc=__WEBPACK_IMPORTED_MODULE_3_marked___default.a&&__WEBPACK_IMPORTED_MODULE_3_marked___default()(descOrg)||descOrg,noBootCode=code.indexOf("/*no-boot-code*/")>-1;noBootCode&&(bootCode="");var allJsResources=jsResources,extraJsMatchStrList=code.match(/\/\*\s*jsResource\s*(.*\S)\s*\*\//);if(extraJsMatchStrList){var jsList=extraJsMatchStrList[1].split(" "),_iteratorNormalCompletion=!0,_didIteratorError=!1,_iteratorError=void 0;try{for(var _iterator=jsList[Symbol.iterator](),_step;!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=!0){var js=_step.value;allJsResources+='\n