comparison public/javascripts/jstoolbar/markdown.js @ 1517:dffacf8a6908 redmine-2.5

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