Skip to content

Commit

Permalink
✨ show & export for PPT
Browse files Browse the repository at this point in the history
  • Loading branch information
nicejade committed Aug 14, 2019
1 parent 27b0218 commit 571195a
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/assets/styles/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ a {
html,
body {
font-size: 14px;
background-color: #ffffff !important;
}
// export page css
.export-page {
Expand Down
3 changes: 2 additions & 1 deletion src/config/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export const appTitle = 'Arya - 在线 Markdown 编辑器'
export const exportTextMap = {
'/export/png': '导出 PNG',
'/export/jpeg': '导出 JPEG',
'/export/pdf': '导出 PDF'
'/export/pdf': '导出 PDF',
'/export/ppt': '导出 PPT'
}

export const toolbarConf = [
Expand Down
99 changes: 99 additions & 0 deletions src/pages/ExportPPT.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<!-- @format -->

<template>
<div class="export-ppt">
<div class="reveal">
<div class="slides">
<section data-markdown data-separator="---" data-separator-vertical="--">
<section data-template>
{{ savedMdContent }}
</section>
</section>
</div>
</div>
</div>
</template>

<script>
import Vditor from 'vditor'
import Reveal from 'reveal.js/js/reveal'
import 'reveal.js/css/reset.css'
import 'reveal.js/css/reveal.css'
import 'reveal.js/css/theme/beige.css'

export default {
name: 'export-ppt',

data() {
return {
savedMdContent: ''
}
},

created() {},

components: {},

mounted() {
this.savedMdContent = localStorage.getItem('vditorvditor')
this.initReveal()
},

methods: {
initReveal() {
window.Reveal = Reveal
const revealSourcePath = `https://cdn.bootcss.com/reveal.js/3.8.0/`
Reveal.initialize({
controls: true,
progress: true,
center: true,
hash: true,
transition: 'slide',
dependencies: [
{
src: `${revealSourcePath}/plugin/markdown/marked.js`,
condition: function() {
return !!document.querySelector('[data-markdown]')
}
},
{
src: `${revealSourcePath}/plugin/markdown/markdown.js`,
condition: function() {
return !!document.querySelector('[data-markdown]')
}
},
{ src: `${revealSourcePath}/plugin/highlight/highlight.js`, async: true },
{ src: `${revealSourcePath}/plugin/search/search.js`, async: true },
{ src: `${revealSourcePath}/plugin/zoom-js/zoom.js`, async: true },
{ src: `${revealSourcePath}/plugin/notes/notes.js`, async: true }
]
})
},
exportAndDownloadPPT(element, filename) {},
/* ---------------------Callback Event--------------------- */
onBackToMainPage() {
this.$router.push('/')
},
onExportBtnClick() {
this.isLoading = true
const element = document.getElementsByClassName('vditor-preview')[0]
const filename = this.$utils.getExportFileName()
this.exportAndDownloadPPT(element, filename)
}
}
}
</script>

<style lang="scss">
.export-ppt {
width: 100%;
.reveal {
font-size: 2em;
background-color: #ffffff;
height: calc(100vh - 60px);
h1 {
font-size: 2em !important;
}
}
}
</style>
4 changes: 4 additions & 0 deletions src/pages/partials/HeaderNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
<icon class="dropdown-icon" name="download" />
<span class="dropdown-text">{{ exportTextMap['/export/pdf'] }}</span>
</el-dropdown-item>
<el-dropdown-item command="/export/ppt">
<icon class="dropdown-icon" name="download" />
<span class="dropdown-text">{{ exportTextMap['/export/ppt'] }}</span>
</el-dropdown-item>
<el-dropdown-item command="export-html" disabled divided>
<icon class="dropdown-icon" name="download" />
<span class="dropdown-text">导出 HTML</span>
Expand Down
7 changes: 7 additions & 0 deletions src/router/routes/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ export default [
title: `导出 PDF | ${window.$appTitle}`
},
component: resolve => require(['@pages/ExportPdf'], resolve)
},
{
path: 'ppt',
meta: {
title: `导出 PPT | ${window.$appTitle}`
},
component: resolve => require(['@pages/ExportPPT'], resolve)
}
]
}
Expand Down

0 comments on commit 571195a

Please sign in to comment.