-
Notifications
You must be signed in to change notification settings - Fork 43
/
index.html
90 lines (81 loc) · 2.63 KB
/
index.html
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hyper Editor</title>
<link rel="stylesheet" href="/dist/hyper_editor.css" />
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet" />
</head>
<body>
<div id="hyperEditor"></div>
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
<script src="/dist/hyper_editor.js"></script>
<script>
function preview(value, callback) {
callback('global preview function')
}
document.addEventListener('DOMContentLoaded', function(){
hyperEditor = new HyperEditor('#hyperEditor', {
imageSearchApi: 'http://localhost:8000/hyper-editor/api/images/',
// preview: preview,
blocks: {
contentbox: {
styles: [
{id: 'default', name: 'Default'},
{id: 'a', name: 'A'},
{id: 'b', name: 'B'},
{id: 'c', name: 'C'}
]
},
text: {
styles: [
{id: 'default', name: 'Default'},
{id: 'c', name: 'C'}
]
}
}
})
hyperEditor.registerBlock('imageChooser2', {
title: 'Image 2',
description: 'A simple image block.',
default_values: {
settings: {}
},
config: {
preview: function (self, callback) { callback('imageChooser2')},
styles: [{id: 'default', name: 'Default'}]
},
settings_schema: {
fields: [
{
type: 'chooser',
label: 'Image Chooser',
model: 'image',
chooserButtonText: 'Choose Image',
getItems: function(query, page, perPage, callback) {
var str = 'q='+query + '&page'+page + '&perPage'+perPage
fetch('http://localhost:8000/hyper-editor/api/images/?'+str)
.then(function(response) { return response.json() })
.then(function(data) {
callback({
total: data.total,
currentPage: data.current_page,
result: data.result,
})
})
},
displayItem: function(item) {
return item.title
},
displaySelectedItem: function (item) {
return item.title
}
}
]
}
})
hyperEditor.initialize()
})
</script>
</body>
</html>