Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
29eac078
Commit
29eac078
authored
Nov 02, 2016
by
qingwei.li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add jsfiddle in demo
parent
6f41d5c7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
14 deletions
+73
-14
build/cooking.demo.js
build/cooking.demo.js
+8
-2
build/strip-tags.js
build/strip-tags.js
+8
-1
examples/components/demo-block.vue
examples/components/demo-block.vue
+57
-11
No files found.
build/cooking.demo.js
View file @
29eac078
...
@@ -46,11 +46,17 @@ cooking.add('vueMarkdown', {
...
@@ -46,11 +46,17 @@ cooking.add('vueMarkdown', {
var
m
=
tokens
[
idx
].
info
.
trim
().
match
(
/^demo
\s
*
(
.*
)
$/
);
var
m
=
tokens
[
idx
].
info
.
trim
().
match
(
/^demo
\s
*
(
.*
)
$/
);
if
(
tokens
[
idx
].
nesting
===
1
)
{
if
(
tokens
[
idx
].
nesting
===
1
)
{
var
description
=
(
m
&&
m
.
length
>
1
)
?
m
[
1
]
:
''
;
var
description
=
(
m
&&
m
.
length
>
1
)
?
m
[
1
]
:
''
;
var
html
=
convert
(
striptags
(
tokens
[
idx
+
1
].
content
,
'
script
'
));
var
content
=
tokens
[
idx
+
1
].
content
;
var
html
=
convert
(
striptags
.
strip
(
content
,
'
script
'
));
var
script
=
striptags
.
fetch
(
content
,
'
script
'
);
var
jsfiddle
=
{
html
:
html
,
script
:
script
};
var
descriptionHTML
=
description
var
descriptionHTML
=
description
?
'
<div class="description">
'
+
md
.
render
(
description
)
+
'
</div>
'
?
'
<div class="description">
'
+
md
.
render
(
description
)
+
'
</div>
'
:
''
;
:
''
;
return
`<demo-block class="demo-box">
jsfiddle
=
md
.
utils
.
escapeHtml
(
JSON
.
stringify
(
jsfiddle
));
return
`<demo-block class="demo-box" :jsfiddle="
${
jsfiddle
}
">
<div class="source">
${
html
}
</div>
<div class="source">
${
html
}
</div>
<div class="meta">
<div class="meta">
${
descriptionHTML
}
${
descriptionHTML
}
...
...
build/strip-tags.js
View file @
29eac078
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
var
cheerio
=
require
(
'
cheerio
'
);
var
cheerio
=
require
(
'
cheerio
'
);
module
.
exports
=
function
(
str
,
tags
)
{
exports
.
strip
=
function
(
str
,
tags
)
{
var
$
=
cheerio
.
load
(
str
,
{
decodeEntities
:
false
});
var
$
=
cheerio
.
load
(
str
,
{
decodeEntities
:
false
});
if
(
!
tags
||
tags
.
length
===
0
)
{
if
(
!
tags
||
tags
.
length
===
0
)
{
...
@@ -25,3 +25,10 @@ module.exports = function(str, tags) {
...
@@ -25,3 +25,10 @@ module.exports = function(str, tags) {
return
$
.
html
();
return
$
.
html
();
};
};
exports
.
fetch
=
function
(
str
,
tag
)
{
var
$
=
cheerio
.
load
(
str
,
{
decodeEntities
:
false
});
if
(
!
tag
)
return
str
;
return
$
(
tag
).
html
();
};
examples/components/demo-block.vue
View file @
29eac078
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
:class=
"[blockClass,
{ 'hover': hovering }]"
:class=
"[blockClass,
{ 'hover': hovering }]"
@mouseenter="hovering = true"
@mouseenter="hovering = true"
@mouseleave="hovering = false">
@mouseleave="hovering = false">
<el-button
class=
"demo-button"
type=
"text"
@
click=
"goJsfiddle"
>
jsfiddle
</el-button>
<slot></slot>
<slot></slot>
<div
class=
"demo-block-control"
@
click=
"isExpanded = !isExpanded"
>
<div
class=
"demo-block-control"
@
click=
"isExpanded = !isExpanded"
>
<transition
name=
"arrow-slide"
>
<transition
name=
"arrow-slide"
>
...
@@ -21,19 +22,23 @@
...
@@ -21,19 +22,23 @@
border
:
solid
1px
#eaeefb
;
border
:
solid
1px
#eaeefb
;
border-radius
:
4px
;
border-radius
:
4px
;
transition
:
.2s
;
transition
:
.2s
;
&.hover
{
&.hover
{
box-shadow
:
0
0
8px
0
rgba
(
232
,
237
,
250
,
.6
),
0
2px
4px
0
rgba
(
232
,
237
,
250
,
.5
);
box-shadow
:
0
0
8px
0
rgba
(
232
,
237
,
250
,
.6
),
0
2px
4px
0
rgba
(
232
,
237
,
250
,
.5
);
}
}
code
{
code
{
font-family
:
Menlo
,
Monaco
,
Consolas
,
Courier
,
monospace
;
font-family
:
Menlo
,
Monaco
,
Consolas
,
Courier
,
monospace
;
}
}
.demo-button
{
float
:
right
;
}
.source
{
.source
{
padding
:
24px
;
padding
:
24px
;
}
}
.meta
{
.meta
{
background-color
:
#f9fafc
;
background-color
:
#f9fafc
;
border-top
:
solid
1px
#eaeefb
;
border-top
:
solid
1px
#eaeefb
;
...
@@ -57,7 +62,7 @@
...
@@ -57,7 +62,7 @@
p
{
p
{
margin
:
0
;
margin
:
0
;
}
}
code
{
code
{
color
:
#5e6d82
;
color
:
#5e6d82
;
background-color
:
#e6effb
;
background-color
:
#e6effb
;
...
@@ -69,7 +74,7 @@
...
@@ -69,7 +74,7 @@
border-radius
:
3px
;
border-radius
:
3px
;
}
}
}
}
.highlight
{
.highlight
{
width
:
60%
;
width
:
60%
;
border-right
:
solid
1px
#eaeefb
;
border-right
:
solid
1px
#eaeefb
;
...
@@ -77,19 +82,19 @@
...
@@ -77,19 +82,19 @@
pre
{
pre
{
margin
:
0
;
margin
:
0
;
}
}
code
.hljs
{
code
.hljs
{
margin
:
0
;
margin
:
0
;
border
:
none
;
border
:
none
;
max-height
:
none
;
max-height
:
none
;
border-radius
:
0
;
border-radius
:
0
;
&::before
{
&::before
{
content
:
none
;
content
:
none
;
}
}
}
}
}
}
.demo-block-control
{
.demo-block-control
{
border-top
:
solid
1px
#eaeefb
;
border-top
:
solid
1px
#eaeefb
;
height
:
36px
;
height
:
36px
;
...
@@ -121,12 +126,12 @@
...
@@ -121,12 +126,12 @@
transition
:
.3s
;
transition
:
.3s
;
display
:
inline-block
;
display
:
inline-block
;
}
}
&
:hover
{
&
:hover
{
color
:
#20a0ff
;
color
:
#20a0ff
;
background-color
:
#f9fafc
;
background-color
:
#f9fafc
;
}
}
&
.text-slide-enter
,
&
.text-slide-enter
,
&
.text-slide-leave-active
{
&
.text-slide-leave-active
{
opacity
:
0
;
opacity
:
0
;
...
@@ -145,6 +150,47 @@
...
@@ -145,6 +150,47 @@
};
};
},
},
props
:
{
jsfiddle
:
Object
,
default
()
{
return
{};
}
},
methods
:
{
goJsfiddle
()
{
const
{
script
,
html
}
=
this
.
jsfiddle
;
const
resourcesTpl
=
'
<scr
'
+
'
ipt src="//unpkg.com/vue/dist/vue.js"></scr
'
+
'
ipt>
'
+
'
\n
<scr
'
+
'
ipt src="//unpkg.com/element-ui@next/lib/index.js"></scr
'
+
'
ipt>
'
;
let
jsTpl
=
(
script
||
''
).
replace
(
/export default/
,
'
var Main =
'
).
trim
();
let
htmlTpl
=
`
${
resourcesTpl
}
\n<div id="app">\n
${
html
.
trim
()}
\n</div>`
;
let
cssTpl
=
'
@import url("//unpkg.com/element-ui@next/lib/theme-default/index.css");
'
;
jsTpl
=
jsTpl
?
jsTpl
+
'
\n
var Ctor = Vue.extend(Main)
\n
new Ctor().$mount(
\'
#app
\'
)
'
:
'
new Vue().$mount(
\'
#app
\'
)
'
;
const
data
=
{
js
:
jsTpl
,
css
:
cssTpl
,
html
:
htmlTpl
,
panel_js
:
3
};
const
form
=
document
.
createElement
(
'
form
'
);
const
node
=
document
.
createElement
(
'
textarea
'
);
form
.
method
=
'
post
'
;
form
.
action
=
'
http://jsfiddle.net/api/post/library/pure/
'
;
form
.
target
=
'
_blank
'
;
for
(
let
name
in
data
)
{
node
.
name
=
name
;
node
.
value
=
data
[
name
].
toString
();
form
.
appendChild
(
node
.
cloneNode
());
}
form
.
submit
();
}
},
computed
:
{
computed
:
{
blockClass
()
{
blockClass
()
{
return
`demo-
${
this
.
$router
.
currentRoute
.
path
.
split
(
'
/
'
).
pop
()
}
`
;
return
`demo-
${
this
.
$router
.
currentRoute
.
path
.
split
(
'
/
'
).
pop
()
}
`
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment