Skip to content
This repository was archived by the owner on Feb 20, 2025. It is now read-only.

Commit 2c5d7e6

Browse files
committed
修改插件
1 parent e485265 commit 2c5d7e6

File tree

14 files changed

+523
-1526
lines changed

14 files changed

+523
-1526
lines changed

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,27 @@ module.exports = {
443443
* [markdown-it docs](https://github.com/markdown-it/markdown-it/tree/master/docs)
444444
* [posthtml docs](https://github.com/posthtml/posthtml/tree/master/docs)
445445

446+
### webslides plugin
447+
WebSlides 插件需要写到一个 js 文件中,然后作为数组放到`window.WSPlugins_`中,然后通过在md 页面的配置(yaml)添加 js 的方法引入。
448+
449+
450+
```md
451+
js:
452+
- webslide_plugins.js
453+
```
454+
455+
```js
456+
// webslide_plugins.js内容
457+
window.WSPlugins_ = [{
458+
id: 'webslide_plugin_name',
459+
// 下面是对应的插件类
460+
apply: class Plugin{}
461+
}]
462+
```
463+
464+
465+
参考[WebSlides文档](https://github.com/webslides/WebSlides/wiki/Plugin-development)
466+
446467
### Template:自制模板
447468

448469
参考[nodeppt-template-default](https://github.com/ksky521/nodeppt-template-default)。

packages/nodeppt-js/assets/scss/index.scss

+48
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ i.fa {
2424
}
2525
}
2626

27+
.animated.delay-300 {
28+
animation-delay: .3s;
29+
}
30+
31+
.animated.delay-400 {
32+
animation-delay: .4s;
33+
}
34+
2735
.animated.delay-500 {
2836
animation-delay: .5s;
2937
}
@@ -43,3 +51,43 @@ i.fa {
4351
.animated.delay-900 {
4452
animation-delay: .9s;
4553
}
54+
55+
.animated.delay-1100 {
56+
animation-delay: 1.1s;
57+
}
58+
59+
.animated.delay-1200 {
60+
animation-delay: 1.2s;
61+
}
62+
63+
.animated.delay-1300 {
64+
animation-delay: 1.3s;
65+
}
66+
67+
.animated.delay-1400 {
68+
animation-delay: 1.4s;
69+
}
70+
71+
.animated.delay-1500 {
72+
animation-delay: 1.5s;
73+
}
74+
75+
.animated.delay-1600 {
76+
animation-delay: 1.6s;
77+
}
78+
79+
.animated.delay-1700 {
80+
animation-delay: 1.7s;
81+
}
82+
83+
.animated.delay-1800 {
84+
animation-delay: 1.8s;
85+
}
86+
87+
.animated.delay-2400 {
88+
animation-delay: 2.4s;
89+
}
90+
91+
.animated.delay-2500 {
92+
animation-delay: 2.5s;
93+
}
+15-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
const yaml = require('js-yaml');
22
function getSettings(str) {
3-
return yaml.load(str);
3+
const settings = yaml.load(str);
4+
const pluginSettings = {};
5+
if (settings.plugins && Array.isArray(settings.plugins)) {
6+
settings.plugins = settings.plugins.map(p => {
7+
if (typeof p === 'string') {
8+
return p;
9+
} else if (typeof p === 'object') {
10+
const key = Object.keys(p)[0];
11+
pluginSettings[key] = p[key];
12+
return key;
13+
}
14+
});
15+
}
16+
settings.pluginsOptions = pluginSettings;
17+
return settings;
418
}
519

620
module.exports = getSettings;

packages/nodeppt-parser/template/index.ejs

+15-9
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@
4141

4242
<script>
4343
document.addEventListener('DOMContentLoaded', () => {
44-
const ws = new WebSlide()
45-
44+
const ws = new WebSlides({
45+
loop: false
46+
})
47+
window.wsInstance = ws;
4648
<% if (hasOwnProperty('plugins') && plugins && plugins.indexOf && ~plugins.indexOf('echarts')) { %>
4749
const initEchart = (e)=>{
4850
@@ -54,13 +56,17 @@ document.addEventListener('DOMContentLoaded', () => {
5456
const echartsChart = []
5557
const echartsOption = []
5658
for (let j = 0; j < len; j++) {
57-
const et = (echartsChart[j] = echarts.init(echartsNode[j]))
58-
try {
59-
echartsOption[j] = JSON.parse(echartsData[j].innerHTML.trim())
60-
et.setOption(echartsOption[j])
61-
} catch (e) {
62-
console.log(e)
63-
}
59+
<% if(hasOwnProperty('pluginsOptions') && pluginsOptions && pluginsOptions.echarts && pluginsOptions.echarts.theme) { %>
60+
const et = (echartsChart[j] = echarts.init(echartsNode[j], '<%= pluginsOptions.echarts.theme %>'))
61+
<% } else { %>
62+
const et = (echartsChart[j] = echarts.init(echartsNode[j]))
63+
<% } %>
64+
try {
65+
echartsOption[j] = JSON.parse(echartsData[j].innerHTML.trim())
66+
et.setOption(echartsOption[j])
67+
} catch (e) {
68+
console.log(e)
69+
}
6470
}
6571
}
6672
}

packages/nodeppt-serve/config/base.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = (api, options) => {
3535
.add('./main.js')
3636
.end()
3737
.output.path(api.resolve(options.outputDir))
38-
.filename('[name].js')
38+
.filename(`[name]${options.filenameHashing ? '.[hash:8]' : ''}.js`)
3939
.publicPath(options.baseUrl);
4040

4141
webpackConfig.resolve

packages/nodeppt-serve/template/main.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
* 页面的 main.js
33
*/
44
import Slide from 'nodeppt-js';
5+
if (typeof window === 'object' && Array.isArray(window.WSPlugins_)) {
6+
WSPlugins_.forEach(({id, apply}) => {
7+
Slide.registerPlugin(id, apply);
8+
});
9+
}
510

6-
window.WebSlide = Slide;
7-
8-
11+
window.WebSlides = Slide;

site/animation.md

+17-11
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,41 @@ css:
77

88
<slide class="bg-gradient-v" image="https://source.unsplash.com/nxfuA21kNHY/1440x1440 .dark" :class="size-60">
99

10-
Animation{.text-subtitle}
11-
# nodeppt {.text-landing}
10+
Animation{.text-subtitle.animated.fadeInDown.delay-800}
11+
# nodeppt {.text-landing.animated.fadeInRight}
1212

13-
This is probably the best **web presentation tool** so far! {.text-intro}
13+
This is probably the best **web presentation tool** so far! {.text-intro.animated.fadeInUp.delay-800}
1414

15-
[:fa-github: Github](https://github.com/ksky521/nodeppt){.button.ghost}
15+
[:fa-github: Github](https://github.com/ksky521/nodeppt){.button.ghost.animated.flipInX.delay-1500}
1616

17+
<slide :class="aligncenter fadeInUp animated">
1718

18-
<slide :class="aligncenter fadeInUp">
19-
## The little things mean the most
19+
## 使用 `.animated` 给元素添加动效
2020

21-
.fadeInUp
21+
`.animated.fadeInUp` <br/>`.animated` 添加的动效是自动播放的
2222

23-
24-
<slide :class="aligncenter zoomIn size-40">
23+
<slide :class="aligncenter animated zoomIn size-40">
2524

2625
![](https://webslides.tv/static/images/android.png)
2726

2827
<slide :class="aligncenter">
2928

30-
## h2.fadeIn.slow {.fadeIn.slow}
29+
## `h2.animated.fadeIn.slow` {.fadeIn.animated.slow}
30+
31+
<slide :class="aligncenter">
32+
33+
## `.animated.fadeIn.delay-800` {.fadeIn.animated.delay-800}
3134

3235
<slide class="aligncenter">
3336

3437
animate with {.text-subtitle}
35-
## `.tobuild`
38+
## `.tobuild` {.tada.animated.delay-500}
39+
3640

3741
需要添加动效的元素添加 `.tobuild` + 动效class {.tobuild.fadeInRight}
3842

43+
`.tobuild` 动效是手动触发的 {.tobuild.fadeInLeft}
44+
3945
<slide :class="size-50">
4046

4147
### `.build` 子元素全部会被添加`.tobuild`

site/background.md

+27-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
title: nodeppt 背景效果演示
22
speaker: 三水清
33
url: https://github.com/ksky521/nodeppt
4+
js:
5+
- background.js
46
css:
57
- https://fonts.googleapis.com/css?family=Roboto:100,100i,300,300i,400,400i,700,700i%7CMaitree:200,300,400,600,700&subset=latin-ext
68

79
<slide class="bg-black-blue aligncenter" image="https://source.unsplash.com/6njoEbtarec/ .dark">
810

9-
Background 演示{.text-subtitle}
11+
Background{.text-subtitle.animated.fadeInDown.delay-800}
1012
# nodeppt {.text-landing.text-shadow}
1113

1214
这可能是迄今为止最好的网页版演示库 {.text-intro}
@@ -20,6 +22,26 @@ Background 演示{.text-subtitle}
2022

2123
&lt;slide class="bg-apple"&gt;
2224

25+
<slide :class="size-40">
26+
27+
## 点击切换背景class
28+
29+
* [`.bg-primary`](){onclick="changeBackgroundColor('bg-primary')"}
30+
* [`.bg-secondary`](){onclick="changeBackgroundColor('bg-secondary')"}
31+
* [`.bg-light`](){onclick="changeBackgroundColor('bg-light')"}
32+
* [`.bg-black`](){onclick="changeBackgroundColor('bg-black')"}
33+
* [`.bg-black-blue`](){onclick="changeBackgroundColor('bg-black-blue')"}
34+
* [`.bg-red`](){onclick="changeBackgroundColor('bg-red')"}
35+
* [`.bg-blue`](){onclick="changeBackgroundColor('bg-blue')"}
36+
* [`.bg-green`](){onclick="changeBackgroundColor('bg-green')"}
37+
* [`.bg-purple`](){onclick="changeBackgroundColor('bg-purple')"}
38+
* [`.bg-trans-light`](){onclick="changeBackgroundColor('bg-trans-light')"}
39+
* [`.bg-trans-dark`](){onclick="changeBackgroundColor('bg-trans-dark')"}
40+
* [`.bg-apple`](){onclick="changeBackgroundColor('bg-apple')"}
41+
* [`.bg-gradient-h`](){onclick="changeBackgroundColor('bg-gradient-h')"}
42+
* [`.bg-gradient-r`](){onclick="changeBackgroundColor('bg-gradient-r')"}
43+
* [`.bg-gradient-v`](){onclick="changeBackgroundColor('bg-gradient-v')"}
44+
{.text-cols}
2345

2446
<slide>
2547
## Corporate Backgrounds
@@ -200,10 +222,11 @@ We'll fix it or if we can't, we'll replace it.
200222

201223
## .background.anim
202224

225+
203226
<slide class="aligncenter">
204227

205-
## U work so hard, **but** 干不过 write PPTs
228+
## U work so hard, **but** 干不过 write PPTs {.animated.tada}
206229

207-
快使用 [nodeppt](https://github.com/ksky521/nodeppt) 轻松搞定高大上PPT<br/> nodeppt 助力你的人生逆袭之路! {.text-into}
230+
快使用 [nodeppt](https://github.com/ksky521/nodeppt) 轻松搞定高大上PPT<br/> nodeppt 助力你的人生逆袭之路! {.text-into.animated.delay-800.fadeIn}
208231

209-
[:fa-cloud-download: Github](https://github.com/ksky521/nodeppt){.button}
232+
[:fa-cloud-download: Github](https://github.com/ksky521/nodeppt){.button.animated.delay-1s.fadeInUp}

0 commit comments

Comments
 (0)