Skip to content

Commit f7a1042

Browse files
committed
WIP cleanup ⛑
1 parent 2e940a4 commit f7a1042

File tree

8 files changed

+12261
-117
lines changed

8 files changed

+12261
-117
lines changed

assets/demo/demo.js

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1-
/* global Mobiledoc */
2-
'use strict';
1+
import { Editor } from './mobiledoc.js';
32

4-
$(() => {
5-
bootstrapEditor();
6-
bootstrapSimpleDemo();
7-
bootstrapToolbarEditor();
8-
bootstrapCardEditor();
9-
});
3+
function bootstrapSimpleDemo() {
4+
let el = $('#editor-basic')[0];
5+
let editor = new Editor({
6+
placeholder: 'Welcome to Mobiledoc'
7+
});
8+
editor.render(el);
9+
}
1010

11-
let bootstrapEditor = () => {
11+
function activateButtons(parentSelector, editor) {
12+
$(`${parentSelector} button`).click(function () {
13+
let button = $(this);
14+
let action = button.data('action');
15+
let args = button.data('args').split(',');
16+
17+
editor[action](...args);
18+
});
19+
}
20+
21+
function bootstrapEditor() {
1222
let el = $('#editor')[0];
13-
let editor = new Mobiledoc.Editor({
23+
let editor = new Editor({
1424
placeholder: 'Type here',
1525
autofocus: true
1626
});
@@ -23,35 +33,17 @@ let bootstrapEditor = () => {
2333
};
2434
editor.postDidChange(displayMobiledoc);
2535
displayMobiledoc();
26-
};
27-
28-
let bootstrapSimpleDemo = () => {
29-
let el = $('#editor-basic')[0];
30-
let editor = new Mobiledoc.Editor({
31-
placeholder: 'Welcome to Mobiledoc',
32-
});
33-
editor.render(el);
34-
};
35-
36-
let activateButtons = (parentSelector, editor) => {
37-
$(`${parentSelector} button`).click(function() {
38-
let button = $(this);
39-
let action = button.data('action');
40-
let args = button.data('args').split(',');
41-
42-
editor[action](...args);
43-
});
44-
};
36+
}
4537

4638
let bootstrapToolbarEditor = () => {
4739
let el = $('#editor-toolbar')[0];
48-
let editor = new Mobiledoc.Editor({
40+
let editor = new Editor({
4941
placeholder: 'Editor with toolbar'
5042
});
5143
editor.render(el);
5244

5345
activateButtons('#editor-toolbar-wrapper', editor);
54-
}
46+
};
5547

5648
let bootstrapCardEditor = () => {
5749
let card = {
@@ -73,11 +65,18 @@ let bootstrapCardEditor = () => {
7365
}
7466
};
7567
let el = $('#editor-card')[0];
76-
let editor = new Mobiledoc.Editor({
68+
let editor = new Editor({
7769
placeholder: 'Editor with card',
7870
cards: [card],
7971
atoms: [atom]
8072
});
8173
editor.render(el);
8274
activateButtons('#editor-card-wrapper', editor);
8375
};
76+
77+
$(() => {
78+
bootstrapEditor();
79+
bootstrapSimpleDemo();
80+
bootstrapToolbarEditor();
81+
bootstrapCardEditor();
82+
});

assets/demo/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
</head>
77
<body>
88
<script src="../tests/jquery/jquery.js"></script>
9-
<script src="../global/mobiledoc-kit.js"></script>
109
<script src="./vendor/mobiledoc-pretty-json-renderer.js"></script>
11-
<script src="./demo.js"></script>
10+
<script type="module" src="./demo.js"></script>
1211
<link rel="stylesheet" href="../css/mobiledoc-kit.css">
1312
<link rel="stylesheet" href="./demo.css">
1413
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/styles/default.min.css">

0 commit comments

Comments
 (0)