forked from fex-team/kityminder-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
127 lines (117 loc) · 4.53 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>KityMinder Editor - Powered By FEX</title>
<link href="favicon.ico" type="image/x-icon" rel="shortcut icon">
<!-- bower:css -->
<link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="../bower_components/codemirror/lib/codemirror.css" />
<link rel="stylesheet" href="../bower_components/hotbox/hotbox.css" />
<link rel="stylesheet" href="../bower_components/kityminder-core/dist/kityminder.core.css" />
<link rel="stylesheet" href="../bower_components/color-picker/dist/color-picker.min.css" />
<!-- endbower -->
<link rel="stylesheet" href="kityminder.editor.min.css">
<style>
html, body {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
}
h1.editor-title {
background: #393F4F;
color: white;
margin: 0;
height: 40px;
font-size: 14px;
line-height: 40px;
font-family: 'Hiragino Sans GB', 'Arial', 'Microsoft Yahei';
font-weight: normal;
padding: 0 20px;
}
div.minder-editor-container {
position: absolute;
top: 40px;
bottom: 0;
left: 0;
right: 0;
}
.fixed-menu {
position: fixed;
bottom: 15px;
right: 20px;
z-index: 128;
}
.dummy-link, .dummy-file-input {
display: none;
}
</style>
</head>
<body ng-app="kityminderDemo" ng-controller="MainController">
<h1 class="editor-title">KityMinder Editor - Powered By FEX</h1>
<kityminder-editor on-init="initEditor(editor, minder)"></kityminder-editor>
<div class="fixed-menu btn-group-vertical">
<button type="button" class="btn btn-default" id="btn-import">导入</button>
<button type="button" class="btn btn-default" id="btn-export">导出</button>
</div>
<a class="dummy-link"></a>
<input type="file" class="dummy-file-input">
</body>
<!-- bower:js -->
<script src="../bower_components/jquery/dist/jquery.js"></script>
<script src="../bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="../bower_components/angular/angular.js"></script>
<script src="../bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="../bower_components/codemirror/lib/codemirror.js"></script>
<script src="../bower_components/codemirror/mode/xml/xml.js"></script>
<script src="../bower_components/codemirror/mode/javascript/javascript.js"></script>
<script src="../bower_components/codemirror/mode/css/css.js"></script>
<script src="../bower_components/codemirror/mode/htmlmixed/htmlmixed.js"></script>
<script src="../bower_components/codemirror/mode/markdown/markdown.js"></script>
<script src="../bower_components/codemirror/addon/mode/overlay.js"></script>
<script src="../bower_components/codemirror/mode/gfm/gfm.js"></script>
<script src="../bower_components/angular-ui-codemirror/ui-codemirror.js"></script>
<script src="../bower_components/marked/lib/marked.js"></script>
<script src="../bower_components/kity/dist/kity.min.js"></script>
<script src="../bower_components/hotbox/hotbox.js"></script>
<script src="../bower_components/json-diff/json-diff.js"></script>
<script src="../bower_components/kityminder-core/dist/kityminder.core.min.js"></script>
<script src="../bower_components/color-picker/dist/color-picker.min.js"></script>
<!-- endbower -->
<script src="kityminder.editor.min.js"></script>
<script>
angular.module('kityminderDemo', ['kityminderEditor'])
.config(function (configProvider) {
configProvider.set('imageUpload', '../server/imageUpload.php');
})
.controller('MainController', function($scope) {
$scope.initEditor = function(editor, minder) {
window.editor = editor;
window.minder = minder;
};
});
document.getElementById('btn-import').addEventListener('click', function() {
let inputFile = document.querySelector('.dummy-file-input');
inputFile.click();
});
document.getElementById('btn-export').addEventListener('click', function() {
let data = new Blob([JSON.stringify(window.minder.exportJson(), null, 2)],
{type : 'application/json'});
let a = document.querySelector('.dummy-link');
let url = URL.createObjectURL(data);
a.setAttribute('href', url);
a.setAttribute('download', 'naotu.json');
a.click();
URL.revokeObjectURL(url);
});
document.querySelector('.dummy-file-input').addEventListener('change', function(e) {
let file = e.target.files[0];
let fileReader = new FileReader();
fileReader.addEventListener('load', function() {
window.minder.importJson(JSON.parse(fileReader.result));
});
fileReader.readAsText(file, 'utf-8');
});
</script>
</html>