src/cm/media/js/markitup/sets.js
changeset 0 40c8f766c9b8
equal deleted inserted replaced
-1:000000000000 0:40c8f766c9b8
       
     1 // -------------------------------------------------------------------
       
     2 // markItUp!
       
     3 // -------------------------------------------------------------------
       
     4 // Copyright (C) 2008 Jay Salvat
       
     5 // http://markitup.jaysalvat.com/
       
     6 // -------------------------------------------------------------------
       
     7 // MarkDown tags example
       
     8 // http://en.wikipedia.org/wiki/Markdown
       
     9 // http://daringfireball.net/projects/markdown/
       
    10 // -------------------------------------------------------------------
       
    11 // Feel free to add more tags
       
    12 // -------------------------------------------------------------------
       
    13 myMarkdownSettings = {
       
    14     nameSpace:       "markdown", // Useful to prevent multi-instances CSS conflict
       
    15     previewAutoRefresh:		false,
       
    16     onShiftEnter:		{keepDefault:false, openWith:'\n\n'},
       
    17 	markupSet: [
       
    18 		{name:gettext('First Level Heading'), key:'1', placeHolder:gettext('Your title here...'), closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '=') } },
       
    19 		{name:gettext('Second Level Heading'), key:'2', placeHolder:gettext('Your title here...'), closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '-') } },
       
    20 		{name:gettext('Heading 3'), key:'3', openWith:'### ', placeHolder:gettext('Your title here...') },
       
    21 		{name:gettext('Heading 4'), key:'4', openWith:'#### ', placeHolder:gettext('Your title here...') },
       
    22 		{name:gettext('Heading 5'), key:'5', openWith:'##### ', placeHolder:gettext('Your title here...') },
       
    23 		{name:gettext('Heading 6'), key:'6', openWith:'###### ', placeHolder:gettext('Your title here...') },
       
    24 		{separator:'---------------' },		
       
    25 		{name:gettext('Bold'), key:'B', openWith:'**', closeWith:'**'},
       
    26 		{name:gettext('Italic'), key:'I', openWith:'_', closeWith:'_'},
       
    27 		{separator:'---------------' },
       
    28 		{name:gettext('Bulleted List'), openWith:'- ' },
       
    29 		{name:gettext('Numeric List'), openWith:function(markItUp) {
       
    30 			return markItUp.line+'. ';
       
    31 		}},
       
    32 		{separator:'---------------' },
       
    33 		{name:gettext('Picture'), key:'P', replaceWith:'![[![Alternative text]!]]([![Url:!:http://]!] "[![Title]!]")'},
       
    34 		{name:gettext('Link'), key:'L', openWith:'[', closeWith:']([![Url:!:http://]!] "[![Title]!]")', placeHolder:'Your text to link here...' },
       
    35 		{separator:'---------------'},	
       
    36 		{name:gettext('Quotes'), openWith:'> '},
       
    37 		{name:gettext('Code Block / Code'), openWith:'(!(\t|!|`)!)', closeWith:'(!(`)!)'},
       
    38 		{separator:'---------------'},
       
    39 		{name:gettext('Preview'), call:'preview', className:"preview"}
       
    40 	]
       
    41 }
       
    42 
       
    43 // mIu nameSpace to avoid conflict.
       
    44 miu = {
       
    45 	markdownTitle: function(markItUp, char) {
       
    46 		heading = '';
       
    47 		n = $.trim(markItUp.selection||markItUp.placeHolder).length;
       
    48 		for(i = 0; i < n; i++) {
       
    49 			heading += char;
       
    50 		}
       
    51 		return '\n'+heading;
       
    52 	}
       
    53 }
       
    54 
       
    55 //----------------------------------------------------------------------------
       
    56 //Html tags
       
    57 //http://en.wikipedia.org/wiki/html
       
    58 //----------------------------------------------------------------------------
       
    59 myHTMLSettings = {
       
    60 	nameSpace:       "html", // Useful to prevent multi-instances CSS conflict
       
    61  	previewAutoRefresh:		false,
       
    62 	onShiftEnter:	{keepDefault:false, replaceWith:'<br />\n'},
       
    63 	onCtrlEnter:	{keepDefault:false, openWith:'\n<p>', closeWith:'</p>\n'},
       
    64 	onTab:			{keepDefault:false, openWith:'	 '},
       
    65 	markupSet: [
       
    66 		{name:gettext('First Level Heading'), key:'1', openWith:'<h1(!( class="[![Class]!]")!)>', closeWith:'</h1>', placeHolder:gettext('Your title here...') },
       
    67 		{name:gettext('Second Level Heading'), key:'2', openWith:'<h2(!( class="[![Class]!]")!)>', closeWith:'</h2>', placeHolder:gettext('Your title here...') },
       
    68 		{name:gettext('Heading 3'), key:'3', openWith:'<h3(!( class="[![Class]!]")!)>', closeWith:'</h3>', placeHolder:gettext('Your title here...') },
       
    69 		{name:gettext('Heading 4'), key:'4', openWith:'<h4(!( class="[![Class]!]")!)>', closeWith:'</h4>', placeHolder:gettext('Your title here...') },
       
    70 		{name:gettext('Heading 5'), key:'5', openWith:'<h5(!( class="[![Class]!]")!)>', closeWith:'</h5>', placeHolder:gettext('Your title here...') },
       
    71 		{name:gettext('Heading 6'), key:'6', openWith:'<h6(!( class="[![Class]!]")!)>', closeWith:'</h6>', placeHolder:gettext('Your title here...') },
       
    72 		{name:gettext('Paragraph'), openWith:'<p(!( class="[![Class]!]")!)>', closeWith:'</p>' },
       
    73 		{separator:'---------------' },
       
    74 		{name:gettext('Bold'), key:'B', openWith:'(!(<strong>|!|<b>)!)', closeWith:'(!(</strong>|!|</b>)!)' },
       
    75 		{name:gettext('Italic'), key:'I', openWith:'(!(<em>|!|<i>)!)', closeWith:'(!(</em>|!|</i>)!)' },
       
    76 		{name:gettext('Stroke through'), key:'S', openWith:'<del>', closeWith:'</del>' },
       
    77 		{separator:'---------------' },
       
    78 		{name:gettext('Bulleted List'), openWith:'<ul>\n', closeWith:'</ul>\n' },
       
    79 		{name:gettext('Numeric List'), openWith:'<ol>\n', closeWith:'</ol>\n' },
       
    80 		{name:gettext('List element'), openWith:'<li>', closeWith:'</li>' },
       
    81 		{separator:'---------------' },
       
    82 		{name:gettext('Picture'), key:'P', replaceWith:'<img src="[![Source:!:http://]!]" alt="[![Alternative text]!]" />' },
       
    83 		{name:gettext('Link'), key:'L', openWith:'<a href="[![Link:!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:gettext('Your text to link...') },
       
    84 		{separator:'---------------' },
       
    85 		{name:gettext('Clean'), className:'clean', replaceWith:function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } },
       
    86 		{name:gettext('Preview'), className:'preview', call:'preview' }
       
    87 	]
       
    88 }