Chris@1517: /* ***** BEGIN LICENSE BLOCK ***** Chris@1517: * This file is part of DotClear. Chris@1517: * Copyright (c) 2005 Nicolas Martin & Olivier Meunier and contributors. All Chris@1517: * rights reserved. Chris@1517: * Chris@1517: * DotClear is free software; you can redistribute it and/or modify Chris@1517: * it under the terms of the GNU General Public License as published by Chris@1517: * the Free Software Foundation; either version 2 of the License, or Chris@1517: * (at your option) any later version. Chris@1517: * Chris@1517: * DotClear is distributed in the hope that it will be useful, Chris@1517: * but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@1517: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@1517: * GNU General Public License for more details. Chris@1517: * Chris@1517: * You should have received a copy of the GNU General Public License Chris@1517: * along with DotClear; if not, write to the Free Software Chris@1517: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Chris@1517: * Chris@1517: * ***** END LICENSE BLOCK ***** Chris@1517: */ Chris@1517: Chris@1517: /* Modified by JP LANG for markdown formatting */ Chris@1517: Chris@1517: // strong Chris@1517: jsToolBar.prototype.elements.strong = { Chris@1517: type: 'button', Chris@1517: title: 'Strong', Chris@1517: fn: { Chris@1517: wiki: function() { this.singleTag('**') } Chris@1517: } Chris@1517: } Chris@1517: Chris@1517: // em Chris@1517: jsToolBar.prototype.elements.em = { Chris@1517: type: 'button', Chris@1517: title: 'Italic', Chris@1517: fn: { Chris@1517: wiki: function() { this.singleTag("*") } Chris@1517: } Chris@1517: } Chris@1517: Chris@1517: // del Chris@1517: jsToolBar.prototype.elements.del = { Chris@1517: type: 'button', Chris@1517: title: 'Deleted', Chris@1517: fn: { Chris@1517: wiki: function() { this.singleTag('~~') } Chris@1517: } Chris@1517: } Chris@1517: Chris@1517: // code Chris@1517: jsToolBar.prototype.elements.code = { Chris@1517: type: 'button', Chris@1517: title: 'Code', Chris@1517: fn: { Chris@1517: wiki: function() { this.singleTag('`') } Chris@1517: } Chris@1517: } Chris@1517: Chris@1517: // spacer Chris@1517: jsToolBar.prototype.elements.space1 = {type: 'space'} Chris@1517: Chris@1517: // headings Chris@1517: jsToolBar.prototype.elements.h1 = { Chris@1517: type: 'button', Chris@1517: title: 'Heading 1', Chris@1517: fn: { Chris@1517: wiki: function() { Chris@1517: this.encloseLineSelection('# ', '',function(str) { Chris@1517: str = str.replace(/^#+\s+/, '') Chris@1517: return str; Chris@1517: }); Chris@1517: } Chris@1517: } Chris@1517: } Chris@1517: jsToolBar.prototype.elements.h2 = { Chris@1517: type: 'button', Chris@1517: title: 'Heading 2', Chris@1517: fn: { Chris@1517: wiki: function() { Chris@1517: this.encloseLineSelection('## ', '',function(str) { Chris@1517: str = str.replace(/^#+\s+/, '') Chris@1517: return str; Chris@1517: }); Chris@1517: } Chris@1517: } Chris@1517: } Chris@1517: jsToolBar.prototype.elements.h3 = { Chris@1517: type: 'button', Chris@1517: title: 'Heading 3', Chris@1517: fn: { Chris@1517: wiki: function() { Chris@1517: this.encloseLineSelection('### ', '',function(str) { Chris@1517: str = str.replace(/^#+\s+/, '') Chris@1517: return str; Chris@1517: }); Chris@1517: } Chris@1517: } Chris@1517: } Chris@1517: Chris@1517: // spacer Chris@1517: jsToolBar.prototype.elements.space2 = {type: 'space'} Chris@1517: Chris@1517: // ul Chris@1517: jsToolBar.prototype.elements.ul = { Chris@1517: type: 'button', Chris@1517: title: 'Unordered list', Chris@1517: fn: { Chris@1517: wiki: function() { Chris@1517: this.encloseLineSelection('','',function(str) { Chris@1517: str = str.replace(/\r/g,''); Chris@1517: return str.replace(/(\n|^)[#-]?\s*/g,"$1* "); Chris@1517: }); Chris@1517: } Chris@1517: } Chris@1517: } Chris@1517: Chris@1517: // ol Chris@1517: jsToolBar.prototype.elements.ol = { Chris@1517: type: 'button', Chris@1517: title: 'Ordered list', Chris@1517: fn: { Chris@1517: wiki: function() { Chris@1517: this.encloseLineSelection('','',function(str) { Chris@1517: str = str.replace(/\r/g,''); Chris@1517: return str.replace(/(\n|^)[*-]?\s*/g,"$11. "); Chris@1517: }); Chris@1517: } Chris@1517: } Chris@1517: } Chris@1517: Chris@1517: // spacer Chris@1517: jsToolBar.prototype.elements.space3 = {type: 'space'} Chris@1517: Chris@1517: // bq Chris@1517: jsToolBar.prototype.elements.bq = { Chris@1517: type: 'button', Chris@1517: title: 'Quote', Chris@1517: fn: { Chris@1517: wiki: function() { Chris@1517: this.encloseLineSelection('','',function(str) { Chris@1517: str = str.replace(/\r/g,''); Chris@1517: return str.replace(/(\n|^) *([^\n]*)/g,"$1> $2"); Chris@1517: }); Chris@1517: } Chris@1517: } Chris@1517: } Chris@1517: Chris@1517: // unbq Chris@1517: jsToolBar.prototype.elements.unbq = { Chris@1517: type: 'button', Chris@1517: title: 'Unquote', Chris@1517: fn: { Chris@1517: wiki: function() { Chris@1517: this.encloseLineSelection('','',function(str) { Chris@1517: str = str.replace(/\r/g,''); Chris@1517: return str.replace(/(\n|^) *[>]? *([^\n]*)/g,"$1$2"); Chris@1517: }); Chris@1517: } Chris@1517: } Chris@1517: } Chris@1517: Chris@1517: // pre Chris@1517: jsToolBar.prototype.elements.pre = { Chris@1517: type: 'button', Chris@1517: title: 'Preformatted text', Chris@1517: fn: { Chris@1517: wiki: function() { this.encloseLineSelection('~~~\n', '\n~~~') } Chris@1517: } Chris@1517: } Chris@1517: Chris@1517: // spacer Chris@1517: jsToolBar.prototype.elements.space4 = {type: 'space'} Chris@1517: Chris@1517: // wiki page Chris@1517: jsToolBar.prototype.elements.link = { Chris@1517: type: 'button', Chris@1517: title: 'Wiki link', Chris@1517: fn: { Chris@1517: wiki: function() { this.encloseSelection("[[", "]]") } Chris@1517: } Chris@1517: } Chris@1517: // image Chris@1517: jsToolBar.prototype.elements.img = { Chris@1517: type: 'button', Chris@1517: title: 'Image', Chris@1517: fn: { Chris@1517: wiki: function() { this.encloseSelection("![](", ")") } Chris@1517: } Chris@1517: } Chris@1517: Chris@1517: // spacer Chris@1517: jsToolBar.prototype.elements.space5 = {type: 'space'}