-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
index.ts
66 lines (59 loc) · 1.7 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import {ambientSound} from './ambient-sound';
import {backLink} from './back-link';
import {cyclingLink} from './cycling-link';
import {dropdownMenu} from './dropdown-menu';
import {embedFlickrImage} from './embed-flickr-image';
import {embedImage} from './embed-image';
import {embedPassage} from './embed-passage';
import {embedUnsplashImage} from './embed-unsplash-image';
import {embedYouTubeVideo} from './embed-youtube-video';
import {link} from './link';
import {restartLink} from './restart-link';
import {revealLink} from './reveal-link';
import {soundEffect} from './sound-effect';
import {textInput} from './text-input';
import {Insert} from './types';
export * from './types';
const builtins: Insert[] = [
ambientSound,
backLink,
cyclingLink as Insert<Record<string, unknown>>,
dropdownMenu as Insert<Record<string, unknown>>,
embedFlickrImage,
embedImage,
embedPassage,
embedUnsplashImage as Insert<Record<string, unknown>>,
embedYouTubeVideo,
link,
restartLink,
revealLink,
soundEffect,
textInput
];
let inserts: Insert[] = [...builtins];
/**
* Returns an array of active inserts. Please treat the value returned as
* read-only. Use `add` or `remove` to make changes instead.
*/
export function all() {
return inserts;
}
/**
* Adds an insert.
*/
export function add(insert: Insert) {
inserts = [...inserts, insert];
}
/**
* Removes an insert. The insert passed must be the exact object passed to the
* `add()` function. If the passed insert hasn't been added, this does nothing.
*/
export function remove(insert: Insert) {
inserts = inserts.filter(i => i !== insert);
}
/**
* Resets inserts to the original set built into Chapbook.
*/
export function reset() {
inserts = [...builtins];
}