diff --git a/index.ejs b/index.ejs index df82a39..50e6b91 100644 --- a/index.ejs +++ b/index.ejs @@ -69,6 +69,8 @@ headwayScript.src = 'https://cdn.headwayapp.co/widget.js' headwayScript.async = true document.body.appendChild(headwayScript) + var element = document.querySelector(HW_config.selector) + element && (element.style.display = 'inline-block') } diff --git a/package.json b/package.json index 9fba9e7..4734d38 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,6 @@ "poi-preset-bundle-report": "^2.0.1", "poi-preset-offline": "^9.0.3", "raw-loader": "^0.5.1", - "repo-latest-commit": "^1.0.0", "stylus": "^0.54.5", "stylus-loader": "^3.0.1", "surge": "^0.19.0", @@ -83,7 +82,7 @@ "codemirror": "^5.28.0", "codemirror-emmet": "^1.0.0", "debounce": "^1.0.2", - "element-ui": "^2.0.11", + "element-ui": "^2.9.2", "is-electron": "^2.1.0", "loadjs": "^3.5.1", "marked3": "^0.5.1", diff --git a/poi.config.js b/poi.config.js index ac9bc7e..4fae182 100644 --- a/poi.config.js +++ b/poi.config.js @@ -1,6 +1,7 @@ +const { execSync } = require('child_process') const nodeModules = require('webpack-node-modules') -const repoLatestCommit = require('repo-latest-commit') const pkg = require('./package') +const LATEST_COMMIT = execSync('git rev-parse HEAD', { encoding: 'utf8' }).slice(0, 7) const cdns = { BABEL_CDN: 'https://cdn.jsdelivr.net/npm/@babel/standalone@7.0.0-beta.32/babel.min.js', @@ -29,10 +30,13 @@ module.exports = { }, hash: false, homepage: '/', - env: Object.assign({ - VERSION: `v${pkg.version}-${repoLatestCommit().commit.slice(0, 7)}`, - LATEST_COMMIT: repoLatestCommit().commit.slice(0, 7) - }, cdns), + env: Object.assign( + { + VERSION: `v${pkg.version}-LATEST_COMMIT}`, + LATEST_COMMIT + }, + cdns + ), presets: [ require('poi-preset-bundle-report')(), require('poi-preset-babel-minify')(), @@ -62,14 +66,17 @@ module.exports = { ], babel: { babelrc: false, - presets: [ - require.resolve('babel-preset-poi') - ], - plugins: [[require.resolve('babel-plugin-component'), [ - { - libraryName: 'element-ui', - styleLibraryName: 'theme-chalk' - } - ]]] + presets: [require.resolve('babel-preset-poi')], + plugins: [ + [ + require.resolve('babel-plugin-component'), + [ + { + libraryName: 'element-ui', + styleLibraryName: 'theme-chalk' + } + ] + ] + ] } } diff --git a/src/components/App.vue b/src/components/App.vue index 8c6d523..504ea57 100644 --- a/src/components/App.vue +++ b/src/components/App.vue @@ -1,13 +1,13 @@ @@ -15,71 +15,290 @@ - diff --git a/src/components/ConsolePan.vue b/src/components/ConsolePan.vue index d9df33b..b4bb593 100644 --- a/src/components/ConsolePan.vue +++ b/src/components/ConsolePan.vue @@ -3,20 +3,11 @@ class="console-pan" :class="{'active-pan': isActivePan}" @click="setActivePan('console')" - :style="style"> + :style="style" + >
- - Console - - - Clear - + Console + Clear
-
+ v-for="(log, index) in logs" + >
- + diff --git a/src/components/HomeHeader.vue b/src/components/HomeHeader.vue index 05246ef..2730cb5 100644 --- a/src/components/HomeHeader.vue +++ b/src/components/HomeHeader.vue @@ -1,407 +1,60 @@ diff --git a/src/components/OutputPan.vue b/src/components/OutputPan.vue index 1b6cf75..023c54e 100644 --- a/src/components/OutputPan.vue +++ b/src/components/OutputPan.vue @@ -3,11 +3,9 @@ class="output-pan" :class="{ 'active-pan': isActivePan }" @click="setActivePan('output')" - :style="style"> - -
- Output -
+ :style="style" + > +
Output
@@ -25,7 +23,6 @@ import Event from '@/utils/event' import panPosition from '@/utils/pan-position' import getScripts from '@/utils/get-scripts' import proxyConsole from '!raw-loader!babel-loader?presets[]=babili&-babelrc!buble-loader!@/utils/proxy-console' -import SvgIcon from './SvgIcon.vue' const sandboxAttributes = [ 'allow-modals', @@ -90,10 +87,7 @@ export default { 'githubToken', 'iframeStatus' ]), - ...mapGetters([ - 'isLoggedIn', - 'canUpdateGist' - ]), + ...mapGetters(['isLoggedIn', 'canUpdateGist']), isActivePan() { return this.activePan === 'output' } @@ -165,19 +159,18 @@ export default { try { await Promise.all([ - transform.js(this.js) + transform + .js(this.js) .then(code => getScripts(code, scripts)) .then(code => { js = code }), - transform.html(this.html) - .then(code => { - html = code - }), - transform.css(this.css) - .then(code => { - css = code - }) + transform.html(this.html).then(code => { + html = code + }), + transform.css(this.css).then(code => { + css = code + }) ]) js = js.replace(/<\/script>/, '<\\/script>') @@ -217,7 +210,8 @@ export default { await this.transform(false) const headStyle = createElement('style')(css) - const codePanRuntime = createElement('script')(` + const codePanRuntime = + createElement('script')(` window.process = window.process || { env: { NODE_ENV: 'development' } } `) + scripts @@ -232,9 +226,7 @@ export default { createElement('script')(proxyConsole) const head = headStyle + codePanRuntime - const body = - html + - createElement('script')(js) + const body = html + createElement('script')(js) this.iframe.setHTML({ head, @@ -268,9 +260,7 @@ export default { } const shouldUpdateGist = this.canUpdateGist && !saveNew const url = `https://api.github.com/gists${ - shouldUpdateGist ? - `/${this.$route.params.gist}` : - '' + shouldUpdateGist ? `/${this.$route.params.gist}` : '' }` const method = shouldUpdateGist ? 'PATCH' : 'POST' const { data } = await axios(url, { @@ -309,22 +299,23 @@ export default { } } } - }, - components: { - SvgIcon } } diff --git a/src/components/PanResizer.vue b/src/components/PanResizer.vue index 30653f9..027f182 100644 --- a/src/components/PanResizer.vue +++ b/src/components/PanResizer.vue @@ -1,105 +1,112 @@ diff --git a/src/components/header/AddBoilerplate.vue b/src/components/header/AddBoilerplate.vue new file mode 100644 index 0000000..ea4f720 --- /dev/null +++ b/src/components/header/AddBoilerplate.vue @@ -0,0 +1,41 @@ + + + diff --git a/src/components/header/AddLibrary.vue b/src/components/header/AddLibrary.vue new file mode 100644 index 0000000..9ae2261 --- /dev/null +++ b/src/components/header/AddLibrary.vue @@ -0,0 +1,49 @@ + + + diff --git a/src/components/header/AutorunButton.vue b/src/components/header/AutorunButton.vue new file mode 100644 index 0000000..d1734a3 --- /dev/null +++ b/src/components/header/AutorunButton.vue @@ -0,0 +1,28 @@ + + + diff --git a/src/components/header/PanToggles.vue b/src/components/header/PanToggles.vue new file mode 100644 index 0000000..6d4d3a7 --- /dev/null +++ b/src/components/header/PanToggles.vue @@ -0,0 +1,62 @@ + + + + + \ No newline at end of file diff --git a/src/components/header/RunButton.vue b/src/components/header/RunButton.vue new file mode 100644 index 0000000..b54f3ea --- /dev/null +++ b/src/components/header/RunButton.vue @@ -0,0 +1,49 @@ + + + diff --git a/src/components/header/SaveGist.vue b/src/components/header/SaveGist.vue new file mode 100644 index 0000000..598bfa1 --- /dev/null +++ b/src/components/header/SaveGist.vue @@ -0,0 +1,103 @@ + + + diff --git a/src/components/header/UploadOptions.vue b/src/components/header/UploadOptions.vue new file mode 100644 index 0000000..3ca231a --- /dev/null +++ b/src/components/header/UploadOptions.vue @@ -0,0 +1,206 @@ + + + + + + diff --git a/src/store/index.js b/src/store/index.js index 07c7241..cd8e01e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -53,7 +53,7 @@ const getFileNameByLang = { const boilerplates = { empty: async () => ({ ...emptyPans(), - showPans: ['html', 'js', 'output'] + showPans: ['js', 'output'] }) } function importAll(r) { @@ -68,7 +68,7 @@ const store = new Vuex.Store({ state: { ...emptyPans(), logs: [], - visiblePans: ['html', 'js', 'output'], + visiblePans: ['js', 'output'], activePan: 'js', autoRun: false, githubToken: localStorage.getItem('codepan:gh-token') || '', diff --git a/src/utils/pan-position.js b/src/utils/pan-position.js index 50ab425..1926c8a 100644 --- a/src/utils/pan-position.js +++ b/src/utils/pan-position.js @@ -10,40 +10,40 @@ export default (pans, pan) => { if (pan === 'html') { return { - left: 0, - right: suffix(rightOffset(0)) + top: 0, + bottom: suffix(rightOffset(0)) } } if (pan === 'css') { const leftCount = pansCount(['html']) return { - left: suffix(leftCount), - right: suffix(rightOffset(leftCount)) + top: suffix(leftCount), + bottom: suffix(rightOffset(leftCount)) } } if (pan === 'js') { const leftCount = pansCount(['html', 'css']) return { - left: suffix(leftCount), - right: suffix(rightOffset(leftCount)) + top: suffix(leftCount), + bottom: suffix(rightOffset(leftCount)) } } if (pan === 'console') { const leftCount = pansCount(['html', 'css', 'js']) return { - left: suffix(leftCount), - right: suffix(rightOffset(leftCount)) + top: suffix(leftCount), + bottom: suffix(rightOffset(leftCount)) } } if (pan === 'output') { const leftCount = pansCount(['html', 'css', 'js', 'console']) return { - left: suffix(leftCount), - right: 0 + top: suffix(leftCount), + bottom: 0 } } } diff --git a/src/views/EditorPage.vue b/src/views/EditorPage.vue index d65102a..c38bc7f 100644 --- a/src/views/EditorPage.vue +++ b/src/views/EditorPage.vue @@ -1,37 +1,39 @@