3636 controlText
3737 }}</span >
3838 </transition >
39- <transition name =" text-slide" >
39+ <!-- < transition name="text-slide">
4040 <div
4141 v-show="hovering || isExpanded"
4242 size="small"
4343 type="text"
44- class =" slide-content codePenBtn"
45- @click.stop =" goCodepen"
44+ class="slide-content online-edit-btn"
4645 >
4746 {{ demoLangInfo.runInline }}
4847 </div>
48+ </transition> -->
49+ <transition name =" text-slide" >
50+ <div
51+ v-show =" hovering || isExpanded"
52+ size =" small"
53+ type =" text"
54+ class =" slide-content online-edit-btn"
55+ >
56+ <CodeSandBoxOnline
57+ :btn-name =" demoLangInfo['openInCodeSandBox'] || ''"
58+ :version =" onlineExample.version"
59+ :example-tpl =" onlineExample.html"
60+ :example-script =" onlineExample.script"
61+ :example-style =" onlineExample.style"
62+ />
63+ </div >
4964 </transition >
5065 </div >
5166 </div >
@@ -58,12 +73,15 @@ import { version } from "../../../package.json";
5873
5974import locale from " ./locale" ;
6075import I18nMixins from " ./mixins/i18n-mixins" ;
76+ import CodeSandBoxOnline from " @/comp/online-edit/code-sand-box/index.jsx" ;
6177
6278export default {
79+ components: { CodeSandBoxOnline },
6380 mixins: [I18nMixins],
6481 data () {
6582 return {
66- codepen: {
83+ onlineExample: {
84+ version: " " ,
6785 script: " " ,
6886 html: " " ,
6987 style: " "
@@ -136,53 +154,6 @@ export default {
136154 },
137155
138156 methods: {
139- goCodepen () {
140- const { script , html , style } = this .codepen ;
141- const resourcesTpl =
142- " <scr" +
143- ' ipt src="//unpkg.com/vue/dist/vue.js"></scr' +
144- " ipt>" +
145- " \n <scr" +
146- ` ipt src="//unpkg.com/vue-easytable@${ version} /libs/umd/index.js"></scr` +
147- " ipt>" ;
148- let jsTpl = (script || " " )
149- .replace (/ export default/ , " var Main =" )
150- .trim ();
151- let htmlTpl = ` ${ resourcesTpl} \n <div id="app">\n ${ html .trim ()} \n </div>` ;
152- let cssTpl = ` @import url("//unpkg.com/vue-easytable@${ version} /libs/theme-default/index.css");\n ${ (
153- style || " "
154- ).trim ()} \n ` ;
155- jsTpl = jsTpl
156- ? jsTpl +
157- " \n var Ctor = Vue.extend(Main)\n new Ctor().$mount('#app')"
158- : " new Vue().$mount('#app')" ;
159- const data = {
160- js: jsTpl,
161- css: cssTpl,
162- html: htmlTpl
163- };
164- const form =
165- document .getElementById (" fiddle-form" ) ||
166- document .createElement (" form" );
167- while (form .firstChild ) {
168- form .removeChild (form .firstChild );
169- }
170- form .method = " POST" ;
171- form .action = " https://codepen.io/pen/define/" ;
172- form .target = " _blank" ;
173- form .style .display = " none" ;
174-
175- const input = document .createElement (" input" );
176- input .setAttribute (" name" , " data" );
177- input .setAttribute (" type" , " hidden" );
178- input .setAttribute (" value" , JSON .stringify (data));
179-
180- form .appendChild (input);
181- document .body .appendChild (form);
182-
183- form .submit ();
184- },
185-
186157 scrollHandler () {
187158 const {
188159 top ,
@@ -205,6 +176,7 @@ export default {
205176 },
206177
207178 created () {
179+ this .onlineExample .version = version;
208180 const highlight = this .$slots .highlight ;
209181 if (highlight && highlight[0 ]) {
210182 let code = " " ;
@@ -216,9 +188,9 @@ export default {
216188 }
217189 }
218190 if (code) {
219- this .codepen .html = stripTemplate (code);
220- this .codepen .script = stripScript (code);
221- this .codepen .style = stripStyle (code);
191+ this .onlineExample .html = stripTemplate (code);
192+ this .onlineExample .script = stripScript (code);
193+ this .onlineExample .style = stripStyle (code);
222194 }
223195 }
224196 },
@@ -395,7 +367,7 @@ export default {
395367 transform : translateX (10px );
396368 }
397369
398- .codePenBtn {
370+ .online-edit-btn {
399371 line-height : 44px ;
400372 position : absolute ;
401373 top : 0 ;
0 commit comments