-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(extension): embed extension, youku/bilibili
- Loading branch information
Showing
24 changed files
with
639 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,7 @@ import { | |
OFormatClear, | ||
OPrint, | ||
OImage, | ||
OEmbed, | ||
RecommendedExtensions | ||
} from 'src/extentions' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<template> | ||
<section class="o-embed-menu"> | ||
<section v-for="(group, i) of services" :key="`group-${i}`"> | ||
<div class="group">{{$o.lang.embed[group.value]}}</div> | ||
|
||
<section class="row col-12 q-col-gutter-sm services"> | ||
<div class="row col-3" v-for="(service, j) of group.children" :key="`service-${i}-${j}`"> | ||
<q-item class="col-12" clickable v-close-popup @click="select(service)"> | ||
<q-item-section avatar> | ||
<img :src="`statics/service/${service.svgIcon}.svg`" v-if="service.svgIcon" /> | ||
<q-icon :name="service.icon || 'apps'" :color="service.color" v-else /> | ||
</q-item-section> | ||
<q-item-section> | ||
{{$o.lang.embed[service.value]}} | ||
</q-item-section> | ||
</q-item> | ||
</div> | ||
</section> | ||
</section> | ||
</section> | ||
</template> | ||
|
||
<script> | ||
import { | ||
VideoServices, | ||
MapServices, | ||
DesignServices, | ||
DevelopServices, | ||
DataServices | ||
} from 'src/data/embed' | ||
export default { | ||
name: 'o-embed-menu', | ||
data () { | ||
return { | ||
} | ||
}, | ||
methods: { | ||
select (service) { | ||
this.$emit('select', service) | ||
} | ||
}, | ||
computed: { | ||
services () { | ||
return [ | ||
{ | ||
label: 'Video', | ||
value: 'video', | ||
children: VideoServices | ||
}, | ||
{ | ||
label: 'Map', | ||
value: 'map', | ||
children: MapServices | ||
}, | ||
{ | ||
label: 'Design', | ||
value: 'design', | ||
children: DesignServices | ||
}, | ||
{ | ||
label: 'Develop', | ||
value: 'develop', | ||
children: DevelopServices | ||
}, | ||
{ | ||
label: '数据', | ||
value: 'data', | ||
children: DataServices | ||
} | ||
] | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="stylus"> | ||
.o-embed-menu { | ||
padding 0 1rem 1rem 1rem | ||
.group { | ||
padding-top 1rem | ||
} | ||
.services { | ||
// | ||
.q-item { | ||
min-height 40px | ||
min-width 80px | ||
border-radius 4px | ||
background rgba(0, 0, 0, 0.03) | ||
} | ||
.q-item__section--avatar { | ||
min-width unset | ||
img { | ||
width 24px | ||
height 24px | ||
} | ||
} | ||
.q-item__section--side { | ||
padding-right 0 | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
<template> | ||
<section class="o-embed iframe" :class="src ? '' : 'no-data'"> | ||
<div class="row col-12 o-toolbar" v-if="view.editable"> | ||
<q-input v-model="originalLink" placeholder="service" debounce="300" class="col text-red link" standout clearable @paste.stop.native> | ||
<template v-slot:prepend> | ||
<img :src="`statics/service/${service.svgIcon}.svg`" v-if="service.svgIcon" /> | ||
<q-icon :name="service.icon || 'apps'" :color="service.color" v-else /> | ||
</template> | ||
</q-input> | ||
<div class="row col-auto q-px-sm"> | ||
<q-btn label="示例" class="q-mx-sm" /> | ||
<q-btn label="确定" color="blue" @click="onConfirm" /> | ||
</div> | ||
</div> | ||
<iframe class="iframe" | ||
:src="src" | ||
:style="{height: `${height}px`}" | ||
frameborder="0" | ||
allowfullscreen="true" | ||
v-if="src"></iframe> | ||
</section> | ||
</template> | ||
|
||
<script> | ||
import { getEmbedService, getServiceSrc } from 'src/data/embed' | ||
export default { | ||
name: 'o-embed', | ||
data () { | ||
return { | ||
originalLink: '' | ||
} | ||
}, | ||
props: ['node', 'updateAttrs', 'view'], | ||
components: { | ||
}, | ||
methods: { | ||
onConfirm () { | ||
let result = getServiceSrc(this.service.value, this.originalLink) | ||
if (!result.validLink || !result.validId) { | ||
console.warn('invalid link') | ||
this.$q.notify({ | ||
color: 'red', | ||
icon: 'warning', | ||
message: 'Invalid link', | ||
timeout: 800 | ||
}) | ||
return | ||
} | ||
this.link = this.originalLink | ||
this.src = result.src | ||
} | ||
}, | ||
computed: { | ||
service () { | ||
return getEmbedService(this.node.attrs.service) | ||
}, | ||
link: { | ||
get () { | ||
return this.node.attrs.link | ||
}, | ||
set (link) { | ||
this.updateAttrs({ | ||
link | ||
}) | ||
} | ||
}, | ||
src: { | ||
get () { | ||
return this.node.attrs.src | ||
}, | ||
set (src) { | ||
this.updateAttrs({ | ||
src | ||
}) | ||
} | ||
}, | ||
height: { | ||
get () { | ||
return this.node.attrs.height || 500 | ||
}, | ||
set (height) { | ||
this.updateAttrs({ | ||
height | ||
}) | ||
} | ||
} | ||
}, | ||
mounted () { | ||
this.originalLink = this.link | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="stylus"> | ||
.o-embed { | ||
position relative | ||
min-height 40px | ||
.o-toolbar { | ||
position absolute | ||
top -44px | ||
width 100% | ||
height 40px | ||
margin 4px 0 | ||
background #efefef | ||
border-radius 5px | ||
visibility hidden | ||
.link { | ||
img { | ||
width 24px | ||
height 24px | ||
} | ||
} | ||
.q-input { | ||
padding 0 4px | ||
} | ||
.q-field__control, .q-field__marginal { | ||
height 32px | ||
} | ||
.q-field__suffix { | ||
line-height unset | ||
} | ||
} | ||
.iframe { | ||
width 100% | ||
height 500px | ||
border solid 1px rgba(0,0,0,0.05) | ||
border-radius 5px | ||
} | ||
} | ||
.o-embed.no-data { | ||
.o-toolbar { | ||
top 0 | ||
visibility visible | ||
} | ||
} | ||
.o-embed:hover { | ||
.o-toolbar { | ||
visibility visible | ||
} | ||
} | ||
</style> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.