-
Notifications
You must be signed in to change notification settings - Fork 15
/
demo.html
104 lines (95 loc) · 2.68 KB
/
demo.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Simditor</title>
<meta name="viewport" content="width=device-width">
<link media="all" rel="stylesheet" type="text/css" href="vendor/bower/simditor/styles/simditor.css" />
<link rel="stylesheet" type="text/css" href="styles/simditor-mention.css" />
<style>
.avatar {
float: left;
display: block;
width: 30px;
height: 20px;
margin-right: 4px;
}
</style>
<script type="text/javascript" src="vendor/bower/jquery/dist/jquery.min.js"></script>
</head>
<body>
<div class="wrapper">
<section id="page-demo">
<textarea id="txt-content" data-autosave="editor-content" autofocus></textarea>
</section>
<script type="text/javascript" src="vendor/bower/simple-module/lib/module.js"></script>
<script type="text/javascript" src="vendor/bower/simple-hotkeys/lib/hotkeys.js"></script>
<script type="text/javascript" src="vendor/bower/simditor/lib/simditor.js"></script>
<script type="text/javascript" src="lib/simditor-mention.js"></script>
<script type="text/javascript">
$(function() {
var editor = new Simditor({
textarea: $('#txt-content'),
placeholder: '这里输入文字...',
pasteImage: true,
toolbar: ['title', 'bold', 'italic', 'underline', 'strikethrough', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link', 'hr', '|', 'indent', 'outdent'],
mention:{
items:[
{
id: 1,
name: '春雨😊✈️',
pinyin: 'chunyu',
abbr: 'cy',
url: 'http://www.example.com'
},
{
id: 2,
name: '夏荷😢',
pinyin: 'xiahe',
abbr: 'xh'
},
{
id: 3,
name: '秋叶',
pinyin: 'qiuye',
abbr: 'qy'
},
{
id: 4,
name: '冬雪',
pinyin: 'dongxue',
abbr: 'dx'
},
{
id: 5,
name: 'Snow❄️',
pinyin: 'snow',
abbr: 'Snow'
},
{
id: 6,
name: 'Simditor Mention',
pinyin: 'simditormention',
abbr: 'simditormention'
}
],
itemRenderer:function($itemEl, data) {
var $span = $('span', $itemEl);
// $('<img>').attr('src', 'https://simditor.tower.im/assets/images/logo.png').addClass('avatar').insertBefore($span);
return $itemEl;
},
linkRenderer:function($linkEl, data) {
$linkEl.attr('href', 'www.example.com/' + data.id);
}
},
});
$(editor).on('mention', function(e, el, data) {
var color = (data.id % 2 === 0 ? 'blue' : 'red');
$(el).css('color', color);
});
});
</script>
</div>
</body>
</html>