Skip to content

Commit 0bda33b

Browse files
authored
Merge pull request #13 from artf/update
Update
2 parents 1b6cde4 + 36bc20b commit 0bda33b

13 files changed

+4203
-5377
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.DS_Store
22
private/
33
node_modules/
4+
dist/
45
.eslintrc
56
*.log
67
_index.html

README.md

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,61 +13,89 @@ Simple countdown component for GrapesJS Editor
1313

1414
## Summary
1515

16-
* Plugin name: `gjs-component-countdown`
16+
* Plugin name: `grapesjs-component-countdown`
1717
* Components: `countdown`
1818
* Blocks: `countdown`
1919

2020

21-
22-
23-
2421
## Options
2522

26-
* `blocks` Which blocks to add, default: `['countdown']` (all)
27-
* `defaultStyle` Add default style to blocks, default: true
28-
* `startTime` Default start time, eg. '2018-01-25 00:00', default: ''
29-
* `endText` Text to show when the countdown is ended, default: 'EXPIRED'
30-
* `dateInputType` Date input type, eg, 'date', 'datetime-local', default: 'date'
31-
* `countdownClsPfx` Countdown class prefix, default: 'countdown'
32-
* `labelCountdown` Countdown label, default 'Countdown'
33-
* `labelCountdownCategory` Countdown category label, default 'Extra'
34-
* `labelDays` Days label text used in component, default 'days'
35-
* `labelHours` Hours label text used in component, default 'hours'
36-
* `labelMinutes` Minutes label text used in component, default 'minutes'
37-
* `labelSeconds` Seconds label text used in component, default 'seconds'
23+
| Option | Description | Default |
24+
|-|-|-
25+
| `id` | The ID used to create the block and component. | `countdown` |
26+
| `label` | The label used for the block and the component. | `Countdown` |
27+
| `block` | Object to extend the default block, eg. `{ label: 'Countdown', category: 'Extra', ... }`. Pass a falsy value to avoid adding the block. | `{}` |
28+
| `props` | Object to extend the default component properties., eg. `{ name: 'Countdown', droppable: false, ... }`. | `{}` |
29+
| `style` | Custom CSS styles for the component. This will replace the default one. | `''` |
30+
| `styleAdditional` | Additional CSS styles for the component. These will be appended to the default one. | `''` |
31+
| `startTime` | Default start time, eg. `2030-01-25 00:00`. | `''` |
32+
| `endText` | Text to show when the countdown is ended. | `'EXPIRED'` |
33+
| `dateInputType` | Date input type, eg. `date`, `datetime-local` | `'date'` |
34+
| `labelDays` | Days label text used in component. | `'days'` |
35+
| `labelHours` | Hours label text used in component. | `'hours'` |
36+
| `labelMinutes` | Minutes label text used in component. | `'minutes'` |
37+
| `labelSeconds` | Seconds label text used in component. | `'seconds'` |
38+
| `classPrefix` | Countdown component class prefix. | `'countdown'` |
3839

3940

4041

4142

4243

4344
## Download
4445

45-
* `npm i grapesjs-component-countdown` or `yarn add grapesjs-component-countdown`
46+
* CDN
47+
* `https://unpkg.com/grapesjs-component-countdown`
48+
* NPM
49+
* `npm i grapesjs-component-countdown`
50+
* GIT
51+
* `git clone https://github.com/artf/grapesjs-component-countdown.git`
52+
4653

4754

4855

4956

5057

5158
## Usage
5259

60+
Directly in the browser
5361
```html
54-
<link href="path/to/grapes.min.css" rel="stylesheet"/>
55-
<script src="path/to/grapes.min.js"></script>
62+
<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet"/>
63+
<script src="https://unpkg.com/grapesjs"></script>
5664
<script src="path/to/grapesjs-component-countdown.min.js"></script>
5765

5866
<div id="gjs"></div>
5967

6068
<script type="text/javascript">
6169
var editor = grapesjs.init({
6270
container : '#gjs',
63-
plugins: ['gjs-component-countdown'],
71+
// ...
72+
plugins: ['grapesjs-component-countdown'],
6473
pluginsOpts: {
65-
'gjs-component-countdown': {/* ...options */}
74+
'grapesjs-component-countdown': { /* options */ }
6675
}
6776
});
6877
</script>
6978
```
7079

80+
Modern javascript
81+
```js
82+
import grapesjs from 'grapesjs';
83+
import pluginCountdown from 'grapesjs-component-countdown';
84+
85+
const editor = grapesjs.init({
86+
container : '#gjs',
87+
// ...
88+
plugins: [pluginCountdown],
89+
pluginsOpts: {
90+
[pluginCountdown]: { /* options */ }
91+
}
92+
// or
93+
plugins: [
94+
editor => pluginCountdown(editor, { /* options */ }),
95+
],
96+
});
97+
```
98+
7199

72100

73101

dist/grapesjs-component-countdown.min.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

index.html

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<title>GrapesJS Countdown Plugin</title>
66
<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet">
77
<script src="https://unpkg.com/grapesjs"></script>
8-
<script src="dist/grapesjs-component-countdown.min.js"></script>
98
<style>
109
body, html {
1110
height: 100%;
@@ -16,17 +15,18 @@
1615
<body>
1716
<div id="gjs" style="height:0px; overflow:hidden"></div>
1817
<script type="text/javascript">
19-
var editor = grapesjs.init({
20-
height: '100%',
21-
noticeOnUnload: 0,
22-
storageManager:{autoload: 0},
23-
container : '#gjs',
24-
fromElement: true,
25-
26-
plugins: ['gjs-component-countdown'],
27-
pluginsOpts: {
28-
'gjs-component-countdown': {}
29-
}
18+
setTimeout(() => {
19+
window.editor = grapesjs.init({
20+
height: '100%',
21+
noticeOnUnload: false,
22+
storageManager: false,
23+
container : '#gjs',
24+
fromElement: true,
25+
plugins: ['grapesjs-component-countdown'],
26+
pluginsOpts: {
27+
'grapesjs-component-countdown': {}
28+
}
29+
});
3030
});
3131
</script>
3232
</body>

0 commit comments

Comments
 (0)