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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
/**
* This file is part of DotClear.
* Copyright (c) 2005 Nicolas Martin & Olivier Meunier and contributors. All rights reserved.
* This code is released under the GNU General Public License.
*
* Modified by JP LANG for markdown formatting
*/
// strong
jsToolBar.prototype.elements.strong = {
type: 'button',
title: 'Strong',
shortcut: 'b',
fn: {
wiki: function() { this.singleTag('**') }
}
}
// em
jsToolBar.prototype.elements.em = {
type: 'button',
title: 'Italic',
shortcut: 'i',
fn: {
wiki: function() { this.singleTag("*") }
}
}
// ins
jsToolBar.prototype.elements.ins = {
type: 'button',
title: 'Underline',
shortcut: 'u',
fn: {
wiki: function() { this.singleTag('_') }
}
}
// del
jsToolBar.prototype.elements.del = {
type: 'button',
title: 'Deleted',
fn: {
wiki: function() { this.singleTag('~~') }
}
}
// code
jsToolBar.prototype.elements.code = {
type: 'button',
title: 'Code',
fn: {
wiki: function() { this.singleTag('`') }
}
}
// spacer
jsToolBar.prototype.elements.space1 = {type: 'space'}
// headings
jsToolBar.prototype.elements.h1 = {
type: 'button',
title: 'Heading 1',
fn: {
wiki: function() {
this.encloseLineSelection('# ', '',function(str) {
str = str.replace(/^#+\s+/, '')
return str;
});
}
}
}
jsToolBar.prototype.elements.h2 = {
type: 'button',
title: 'Heading 2',
fn: {
wiki: function() {
this.encloseLineSelection('## ', '',function(str) {
str = str.replace(/^#+\s+/, '')
return str;
});
}
}
}
jsToolBar.prototype.elements.h3 = {
type: 'button',
title: 'Heading 3',
fn: {
wiki: function() {
this.encloseLineSelection('### ', '',function(str) {
str = str.replace(/^#+\s+/, '')
return str;
});
}
}
}
// spacer
jsToolBar.prototype.elements.space2 = {type: 'space'}
// ul
jsToolBar.prototype.elements.ul = {
type: 'button',
title: 'Unordered list',
fn: {
wiki: function() {
this.encloseLineSelection('','',function(str) {
str = str.replace(/\r/g,'');
return str.replace(/(\n|^)[#-]?\s*/g,"$1* ");
});
}
}
}
// ol
jsToolBar.prototype.elements.ol = {
type: 'button',
title: 'Ordered list',
fn: {
wiki: function() {
this.encloseLineSelection('','',function(str) {
str = str.replace(/\r/g,'');
return str.replace(/(\n|^)[*-]?\s*/g,"$11. ");
});
}
}
}
// spacer
jsToolBar.prototype.elements.space3 = {type: 'space'}
// bq
jsToolBar.prototype.elements.bq = {
type: 'button',
title: 'Quote',
fn: {
wiki: function() {
this.encloseLineSelection('','',function(str) {
str = str.replace(/\r/g,'');
return str.replace(/(\n|^)( *)([^\n]*)/g,"$1> $2$3");
});
}
}
}
// unbq
jsToolBar.prototype.elements.unbq = {
type: 'button',
title: 'Unquote',
fn: {
wiki: function() {
this.encloseLineSelection('','',function(str) {
str = str.replace(/\r/g,'');
return str.replace(/(\n|^) *(> ?)?( *)([^\n]*)/g,"$1$3$4");
});
}
}
}
// table
jsToolBar.prototype.elements.table = {
type: 'button',
title: 'Table',
fn: {
wiki: function() {
var This = this;
this.tableMenu(function(cols, rowCount){
This.encloseLineSelection(
'|'+cols.join(' |')+' |\n' + // header
Array(cols.length+1).join('|--')+'|\n' + // second line
Array(rowCount+1).join(Array(cols.length+1).join('| ')+'|\n') // cells
);
});
}
}
}
// pre
jsToolBar.prototype.elements.pre = {
type: 'button',
title: 'Preformatted text',
fn: {
wiki: function() { this.encloseLineSelection('```\n', '\n```') }
}
}
// Code highlighting
jsToolBar.prototype.elements.precode = {
type: 'button',
title: 'Highlighted code',
fn: {
wiki: function() {
var This = this;
this.precodeMenu(function(lang){
This.encloseLineSelection('``` ' + lang + '\n', '\n```\n');
});
}
}
}
// spacer
jsToolBar.prototype.elements.space4 = {type: 'space'}
// wiki page
jsToolBar.prototype.elements.link = {
type: 'button',
title: 'Wiki link',
fn: {
wiki: function() { this.encloseSelection("[[", "]]") }
}
}
// image
jsToolBar.prototype.elements.img = {
type: 'button',
title: 'Image',
fn: {
wiki: function() { this.encloseSelection("![](", ")") }
}
}
// spacer
jsToolBar.prototype.elements.space5 = {type: 'space'}
// help
jsToolBar.prototype.elements.help = {
type: 'button',
title: 'Help',
fn: {
wiki: function() { window.open(this.help_link, '', 'resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes') }
}
}
|