Chris@1517
|
1 /* ***** BEGIN LICENSE BLOCK *****
|
Chris@1517
|
2 * This file is part of DotClear.
|
Chris@1517
|
3 * Copyright (c) 2005 Nicolas Martin & Olivier Meunier and contributors. All
|
Chris@1517
|
4 * rights reserved.
|
Chris@1517
|
5 *
|
Chris@1517
|
6 * DotClear is free software; you can redistribute it and/or modify
|
Chris@1517
|
7 * it under the terms of the GNU General Public License as published by
|
Chris@1517
|
8 * the Free Software Foundation; either version 2 of the License, or
|
Chris@1517
|
9 * (at your option) any later version.
|
Chris@1517
|
10 *
|
Chris@1517
|
11 * DotClear is distributed in the hope that it will be useful,
|
Chris@1517
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Chris@1517
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Chris@1517
|
14 * GNU General Public License for more details.
|
Chris@1517
|
15 *
|
Chris@1517
|
16 * You should have received a copy of the GNU General Public License
|
Chris@1517
|
17 * along with DotClear; if not, write to the Free Software
|
Chris@1517
|
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Chris@1517
|
19 *
|
Chris@1517
|
20 * ***** END LICENSE BLOCK *****
|
Chris@1517
|
21 */
|
Chris@1517
|
22
|
Chris@1517
|
23 /* Modified by JP LANG for markdown formatting */
|
Chris@1517
|
24
|
Chris@1517
|
25 // strong
|
Chris@1517
|
26 jsToolBar.prototype.elements.strong = {
|
Chris@1517
|
27 type: 'button',
|
Chris@1517
|
28 title: 'Strong',
|
Chris@1517
|
29 fn: {
|
Chris@1517
|
30 wiki: function() { this.singleTag('**') }
|
Chris@1517
|
31 }
|
Chris@1517
|
32 }
|
Chris@1517
|
33
|
Chris@1517
|
34 // em
|
Chris@1517
|
35 jsToolBar.prototype.elements.em = {
|
Chris@1517
|
36 type: 'button',
|
Chris@1517
|
37 title: 'Italic',
|
Chris@1517
|
38 fn: {
|
Chris@1517
|
39 wiki: function() { this.singleTag("*") }
|
Chris@1517
|
40 }
|
Chris@1517
|
41 }
|
Chris@1517
|
42
|
Chris@1517
|
43 // del
|
Chris@1517
|
44 jsToolBar.prototype.elements.del = {
|
Chris@1517
|
45 type: 'button',
|
Chris@1517
|
46 title: 'Deleted',
|
Chris@1517
|
47 fn: {
|
Chris@1517
|
48 wiki: function() { this.singleTag('~~') }
|
Chris@1517
|
49 }
|
Chris@1517
|
50 }
|
Chris@1517
|
51
|
Chris@1517
|
52 // code
|
Chris@1517
|
53 jsToolBar.prototype.elements.code = {
|
Chris@1517
|
54 type: 'button',
|
Chris@1517
|
55 title: 'Code',
|
Chris@1517
|
56 fn: {
|
Chris@1517
|
57 wiki: function() { this.singleTag('`') }
|
Chris@1517
|
58 }
|
Chris@1517
|
59 }
|
Chris@1517
|
60
|
Chris@1517
|
61 // spacer
|
Chris@1517
|
62 jsToolBar.prototype.elements.space1 = {type: 'space'}
|
Chris@1517
|
63
|
Chris@1517
|
64 // headings
|
Chris@1517
|
65 jsToolBar.prototype.elements.h1 = {
|
Chris@1517
|
66 type: 'button',
|
Chris@1517
|
67 title: 'Heading 1',
|
Chris@1517
|
68 fn: {
|
Chris@1517
|
69 wiki: function() {
|
Chris@1517
|
70 this.encloseLineSelection('# ', '',function(str) {
|
Chris@1517
|
71 str = str.replace(/^#+\s+/, '')
|
Chris@1517
|
72 return str;
|
Chris@1517
|
73 });
|
Chris@1517
|
74 }
|
Chris@1517
|
75 }
|
Chris@1517
|
76 }
|
Chris@1517
|
77 jsToolBar.prototype.elements.h2 = {
|
Chris@1517
|
78 type: 'button',
|
Chris@1517
|
79 title: 'Heading 2',
|
Chris@1517
|
80 fn: {
|
Chris@1517
|
81 wiki: function() {
|
Chris@1517
|
82 this.encloseLineSelection('## ', '',function(str) {
|
Chris@1517
|
83 str = str.replace(/^#+\s+/, '')
|
Chris@1517
|
84 return str;
|
Chris@1517
|
85 });
|
Chris@1517
|
86 }
|
Chris@1517
|
87 }
|
Chris@1517
|
88 }
|
Chris@1517
|
89 jsToolBar.prototype.elements.h3 = {
|
Chris@1517
|
90 type: 'button',
|
Chris@1517
|
91 title: 'Heading 3',
|
Chris@1517
|
92 fn: {
|
Chris@1517
|
93 wiki: function() {
|
Chris@1517
|
94 this.encloseLineSelection('### ', '',function(str) {
|
Chris@1517
|
95 str = str.replace(/^#+\s+/, '')
|
Chris@1517
|
96 return str;
|
Chris@1517
|
97 });
|
Chris@1517
|
98 }
|
Chris@1517
|
99 }
|
Chris@1517
|
100 }
|
Chris@1517
|
101
|
Chris@1517
|
102 // spacer
|
Chris@1517
|
103 jsToolBar.prototype.elements.space2 = {type: 'space'}
|
Chris@1517
|
104
|
Chris@1517
|
105 // ul
|
Chris@1517
|
106 jsToolBar.prototype.elements.ul = {
|
Chris@1517
|
107 type: 'button',
|
Chris@1517
|
108 title: 'Unordered list',
|
Chris@1517
|
109 fn: {
|
Chris@1517
|
110 wiki: function() {
|
Chris@1517
|
111 this.encloseLineSelection('','',function(str) {
|
Chris@1517
|
112 str = str.replace(/\r/g,'');
|
Chris@1517
|
113 return str.replace(/(\n|^)[#-]?\s*/g,"$1* ");
|
Chris@1517
|
114 });
|
Chris@1517
|
115 }
|
Chris@1517
|
116 }
|
Chris@1517
|
117 }
|
Chris@1517
|
118
|
Chris@1517
|
119 // ol
|
Chris@1517
|
120 jsToolBar.prototype.elements.ol = {
|
Chris@1517
|
121 type: 'button',
|
Chris@1517
|
122 title: 'Ordered list',
|
Chris@1517
|
123 fn: {
|
Chris@1517
|
124 wiki: function() {
|
Chris@1517
|
125 this.encloseLineSelection('','',function(str) {
|
Chris@1517
|
126 str = str.replace(/\r/g,'');
|
Chris@1517
|
127 return str.replace(/(\n|^)[*-]?\s*/g,"$11. ");
|
Chris@1517
|
128 });
|
Chris@1517
|
129 }
|
Chris@1517
|
130 }
|
Chris@1517
|
131 }
|
Chris@1517
|
132
|
Chris@1517
|
133 // spacer
|
Chris@1517
|
134 jsToolBar.prototype.elements.space3 = {type: 'space'}
|
Chris@1517
|
135
|
Chris@1517
|
136 // bq
|
Chris@1517
|
137 jsToolBar.prototype.elements.bq = {
|
Chris@1517
|
138 type: 'button',
|
Chris@1517
|
139 title: 'Quote',
|
Chris@1517
|
140 fn: {
|
Chris@1517
|
141 wiki: function() {
|
Chris@1517
|
142 this.encloseLineSelection('','',function(str) {
|
Chris@1517
|
143 str = str.replace(/\r/g,'');
|
Chris@1517
|
144 return str.replace(/(\n|^) *([^\n]*)/g,"$1> $2");
|
Chris@1517
|
145 });
|
Chris@1517
|
146 }
|
Chris@1517
|
147 }
|
Chris@1517
|
148 }
|
Chris@1517
|
149
|
Chris@1517
|
150 // unbq
|
Chris@1517
|
151 jsToolBar.prototype.elements.unbq = {
|
Chris@1517
|
152 type: 'button',
|
Chris@1517
|
153 title: 'Unquote',
|
Chris@1517
|
154 fn: {
|
Chris@1517
|
155 wiki: function() {
|
Chris@1517
|
156 this.encloseLineSelection('','',function(str) {
|
Chris@1517
|
157 str = str.replace(/\r/g,'');
|
Chris@1517
|
158 return str.replace(/(\n|^) *[>]? *([^\n]*)/g,"$1$2");
|
Chris@1517
|
159 });
|
Chris@1517
|
160 }
|
Chris@1517
|
161 }
|
Chris@1517
|
162 }
|
Chris@1517
|
163
|
Chris@1517
|
164 // pre
|
Chris@1517
|
165 jsToolBar.prototype.elements.pre = {
|
Chris@1517
|
166 type: 'button',
|
Chris@1517
|
167 title: 'Preformatted text',
|
Chris@1517
|
168 fn: {
|
Chris@1517
|
169 wiki: function() { this.encloseLineSelection('~~~\n', '\n~~~') }
|
Chris@1517
|
170 }
|
Chris@1517
|
171 }
|
Chris@1517
|
172
|
Chris@1517
|
173 // spacer
|
Chris@1517
|
174 jsToolBar.prototype.elements.space4 = {type: 'space'}
|
Chris@1517
|
175
|
Chris@1517
|
176 // wiki page
|
Chris@1517
|
177 jsToolBar.prototype.elements.link = {
|
Chris@1517
|
178 type: 'button',
|
Chris@1517
|
179 title: 'Wiki link',
|
Chris@1517
|
180 fn: {
|
Chris@1517
|
181 wiki: function() { this.encloseSelection("[[", "]]") }
|
Chris@1517
|
182 }
|
Chris@1517
|
183 }
|
Chris@1517
|
184 // image
|
Chris@1517
|
185 jsToolBar.prototype.elements.img = {
|
Chris@1517
|
186 type: 'button',
|
Chris@1517
|
187 title: 'Image',
|
Chris@1517
|
188 fn: {
|
Chris@1517
|
189 wiki: function() { this.encloseSelection("") }
|
Chris@1517
|
190 }
|
Chris@1517
|
191 }
|
Chris@1517
|
192
|
Chris@1517
|
193 // spacer
|
Chris@1517
|
194 jsToolBar.prototype.elements.space5 = {type: 'space'}
|