diff --git a/package.json b/package.json
index 0b15f2e3..4b87de3a 100644
--- a/package.json
+++ b/package.json
@@ -32,6 +32,7 @@
"globby": "^10.0.1",
"gray-matter": "^4.0.2",
"html-loader": "^1.3.2",
+ "lz-string": "^1.4.4",
"marked": "^0.3.12",
"mini-css-extract-plugin": "^1.3.3",
"node-static": "^0.7.11",
diff --git a/src/asset/icon/codePen.svg b/src/asset/icon/codePen.svg
new file mode 100644
index 00000000..4ba7f4de
--- /dev/null
+++ b/src/asset/icon/codePen.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/asset/icon/codeSandbox.svg b/src/asset/icon/codeSandbox.svg
new file mode 100644
index 00000000..2dcb7315
--- /dev/null
+++ b/src/asset/icon/codeSandbox.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/asset/icon/jsFiddle.svg b/src/asset/icon/jsFiddle.svg
new file mode 100644
index 00000000..8bdcae93
--- /dev/null
+++ b/src/asset/icon/jsFiddle.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/editor/Editor.vue b/src/editor/Editor.vue
index bf9507c9..d38ae15d 100644
--- a/src/editor/Editor.vue
+++ b/src/editor/Editor.vue
@@ -1,7 +1,7 @@
-
+
@@ -53,7 +53,41 @@
+
+
+
+
+
+
+
+
+
+
{
+ const [ key, value ] = el.split('=');
+ params[key] = value;
+ })
+ this.title = params.c;
if (store.isMobile) {
this.leftContainerSize = 0;
@@ -152,6 +204,55 @@ export default {
},
methods: {
+ compress(string) {
+ return LZString.compressToBase64(string)
+ .replace(/\+/g, '-') // Convert '+' to '-'
+ .replace(/\//g, '_') // Convert '/' to '_'
+ .replace(/=+$/, ''); // Remove ending '='
+ },
+ tabsBeforeLeave(activeName, oldActiveName) {
+ //阻止more-editor标签的返回
+ if(activeName == 'more-editor'){
+ return false;
+ }
+ },
+
+ getCodeSandboxConfig() {
+ codeSandboxPackage.name = this.title;
+ let config={
+ files: {
+ 'package.json': {
+ content: codeSandboxPackage
+ },
+ 'index.html':{
+ content: getCodeSandboxHTML()
+ },
+ 'sandbox.config.json':{
+ content: staticConfig
+ }
+ }
+ }
+ this.codeSandboxConfig = config;
+ },
+ getCodePenConfig() {
+ this.codePenConfig={
+ title: this.title,
+ html: HTML,
+ js: getJSCode(),
+ editors: "001",
+ js_external: codePenJSExternal
+ }
+ },
+
+ getJSFiddleConfig(){
+ this.jsFiddleConfig = {
+ html:HTML,
+ js: getJSCode(),
+ resources: fiddleJSExternal
+ }
+ },
+
+
onSplitterDragStart() {
this.mousedown = true;
},
@@ -450,5 +551,42 @@ $handler-width: 5px;
background: $clr-bg;
}
+.tabs-en{
+ #tab-more-editor{
+ text-align: right;
+ width: calc(100% - 180px);
+ cursor: default;
+ }
+ .el-tabs__nav {
+ width: calc(100% - 180px);
+ }
+
+}
+.tabs-zh{
+ #tab-more-editor{
+ text-align: right;
+ width: calc(100% - 130px);
+ cursor: default;
+ }
+ .el-tabs__nav {
+ width: calc(100% - 130px);
+ }
+}
+.editor-form{
+ width: 20px;
+ display: inline-block;
+ margin: 0 3px;
+
+ .editor-button{
+ background: none;
+ outline: none;
+ border: none;
+ }
+}
+
+
+
+
+
\ No newline at end of file
diff --git a/src/editor/onlineEditor.js b/src/editor/onlineEditor.js
new file mode 100644
index 00000000..979b2da2
--- /dev/null
+++ b/src/editor/onlineEditor.js
@@ -0,0 +1,92 @@
+
+import {store} from '../common/store';
+import {URL_PARAMS, SCRIPT_URLS} from '../common/config';
+
+const getRootPath = () => {
+ const hasRootPath = store.sourceCode.indexOf('ROOT_PATH') >= 0;
+ return hasRootPath ? `var ROOT_PATH = 'https://cdn.jsdelivr.net/gh/apache/echarts-website@asf-site/examples'`: '';
+}
+
+export const getCodeSandboxHTML = ()=>{
+
+ const rootPathCode = getRootPath()
+ return (`
+
+
+
+
+
+
+
+
+
+
+
+
+
+ `)
+}
+
+export const codeSandboxPackage = {
+ "name": "static",
+ "version": "1.0.0",
+ "description": "This is a static template with no bundling",
+ "main": "index.html",
+ "scripts": {
+ "start": "serve",
+ "build": "echo This is a static template, there is no bundler or bundling involved!"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/codesandbox-app/static-template.git"
+ },
+ "keywords": ["static", "template", "codesandbox"],
+ "author": "Ives van Hoorne",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/codesandbox-app/static-template/issues"
+ },
+ "homepage": "https://github.com/codesandbox-app/static-template#readme",
+ "devDependencies": {
+ "serve": "^11.2.0"
+ }
+}
+
+
+
+export const staticConfig = `{
+ "template": "static"
+}`
+
+export const getJSCode = () => {
+
+ const rootPathCode = getRootPath()
+ return (`
+ var chartDom = document.getElementById('main');
+ var myChart = echarts.init(chartDom);
+ var option;
+
+ ${rootPathCode}
+ ${store.sourceCode}
+
+ option && myChart.setOption(option);` )
+}
+
+const js_external = ['https://cdn.staticfile.org/jquery/2.2.4/jquery.min.js', SCRIPT_URLS.echartsMinJS, `${SCRIPT_URLS.echartsDir}/dist/extension/dataTool.min.js`, SCRIPT_URLS.echartsGLMinJS, SCRIPT_URLS.echartsStatMinJS]
+export const codePenJSExternal = js_external.join(';')
+
+export const fiddleJSExternal =js_external.join(',')
+
+
+export const HTML = ``
\ No newline at end of file