fixed formatting buttons in edit project text editor

agj/ssh-add-key
aasis21 2018-02-18 20:04:42 +05:30
parent fb36498d01
commit 828ec8a10b
5 changed files with 272 additions and 147 deletions

View File

@ -1,9 +1,9 @@
// ----------------------------------------------------------------------------
// markItUp! Universal MarkUp Engine, JQuery plugin
// v 1.1.7
// v 1.1.x
// Dual licensed under the MIT and GPL licenses.
// ----------------------------------------------------------------------------
// Copyright (C) 2007-2010 Jay Salvat
// Copyright (C) 2007-2012 Jay Salvat
// http://markitup.jaysalvat.com/
// ----------------------------------------------------------------------------
// Permission is hereby granted, free of charge, to any person obtaining a copy
@ -12,10 +12,10 @@
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -26,16 +26,23 @@
// ----------------------------------------------------------------------------
(function($) {
$.fn.markItUp = function(settings, extraSettings) {
var options, ctrlKey, shiftKey, altKey;
ctrlKey = shiftKey = altKey = false;
var method, params, options, ctrlKey, shiftKey, altKey; ctrlKey = shiftKey = altKey = false;
if (typeof settings == 'string') {
method = settings;
params = extraSettings;
}
options = { id: '',
nameSpace: '',
root: '',
previewHandler: false,
previewInWindow: '', // 'width=800, height=600, resizable=yes, scrollbars=yes'
previewInElement: '',
previewAutoRefresh: true,
previewPosition: 'after',
previewTemplatePath: '~/templates/preview.html',
previewParser: false,
previewParserPath: '',
previewParserVar: 'data',
resizeHandle: true,
@ -59,6 +66,35 @@
});
}
// Quick patch to keep compatibility with jQuery 1.9
var uaMatch = function(ua) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
/(webkit)[ \/]([\w.]+)/.exec(ua) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
/(msie) ([\w.]+)/.exec(ua) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
[];
return {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
};
};
var matched = uaMatch( navigator.userAgent );
var browser = {};
if (matched.browser) {
browser[matched.browser] = true;
browser.version = matched.version;
}
if (browser.chrome) {
browser.webkit = true;
} else if (browser.webkit) {
browser.safari = true;
}
return this.each(function() {
var $$, textarea, levels, scrollPosition, caretPosition, caretOffset,
clicked, hash, header, footer, previewWindow, template, iFrame, abort;
@ -72,6 +108,20 @@
options.previewParserPath = localize(options.previewParserPath);
options.previewTemplatePath = localize(options.previewTemplatePath);
if (method) {
switch(method) {
case 'remove':
remove();
break;
case 'insert':
markup(params);
break;
default:
$.error('Method ' + method + ' does not exist on jQuery.markItUp');
}
return;
}
// apply the computed path to ~/
function localize(data, inText) {
if (inText) {
@ -105,29 +155,29 @@
footer = $('<div class="markItUpFooter"></div>').insertAfter($$);
// add the resize handle after textarea
if (options.resizeHandle === true && $.browser.safari !== true) {
if (options.resizeHandle === true && browser.safari !== true) {
resizeHandle = $('<div class="markItUpResizeHandle"></div>')
.insertAfter($$)
.bind("mousedown", function(e) {
.bind("mousedown.markItUp", function(e) {
var h = $$.height(), y = e.clientY, mouseMove, mouseUp;
mouseMove = function(e) {
$$.css("height", Math.max(20, e.clientY+h-y)+"px");
return false;
};
mouseUp = function(e) {
$("html").unbind("mousemove", mouseMove).unbind("mouseup", mouseUp);
$("html").unbind("mousemove.markItUp", mouseMove).unbind("mouseup.markItUp", mouseUp);
return false;
};
$("html").bind("mousemove", mouseMove).bind("mouseup", mouseUp);
$("html").bind("mousemove.markItUp", mouseMove).bind("mouseup.markItUp", mouseUp);
});
footer.append(resizeHandle);
}
// listen key events
$$.keydown(keyPressed).keyup(keyPressed);
$$.bind('keydown.markItUp', keyPressed).bind('keyup', keyPressed);
// bind an event to catch external calls
$$.bind("insertion", function(e, settings) {
$$.bind("insertion.markItUp", function(e, settings) {
if (settings.target !== false) {
get();
}
@ -137,9 +187,13 @@
});
// remember the last focus
$$.focus(function() {
$$.bind('focus.markItUp', function() {
$.markItUp.focused = this;
});
if (options.previewInElement) {
refreshPreview();
}
}
// recursively build header with dropMenus from markupset
@ -158,32 +212,33 @@
t += levels[j]+"-";
}
li = $('<li class="markItUpButton markItUpButton'+t+(i)+' '+(button.className||'')+'"><a href="" '+key+' title="'+title+'">'+(button.name||'')+'</a></li>')
.bind("contextmenu", function() { // prevent contextmenu on mac and allow ctrl+click
.bind("contextmenu.markItUp", function() { // prevent contextmenu on mac and allow ctrl+click
return false;
}).click(function() {
return false;
}).mousedown(function() {
}).bind('click.markItUp', function(e) {
e.preventDefault();
}).bind("focusin.markItUp", function(){
$$.focus();
}).bind('mouseup', function() {
if (button.call) {
eval(button.call)();
}
setTimeout(function() { markup(button) },1);
return false;
}).hover(function() {
}).bind('mouseenter.markItUp', function() {
$('> ul', this).show();
$(document).one('click', function() { // close dropmenu if click outside
$('ul ul', header).hide();
}
);
}, function() {
}).bind('mouseleave.markItUp', function() {
$('> ul', this).hide();
}
).appendTo(ul);
}).appendTo(ul);
if (button.dropMenu) {
levels.push(i);
$(li).addClass('markItUpDropMenu').append(dropMenus(button.dropMenu));
}
}
});
});
levels.pop();
return ul;
}
@ -231,22 +286,49 @@
// build block to insert
function build(string) {
openWith = prepare(clicked.openWith);
placeHolder = prepare(clicked.placeHolder);
replaceWith = prepare(clicked.replaceWith);
closeWith = prepare(clicked.closeWith);
var openWith = prepare(clicked.openWith);
var placeHolder = prepare(clicked.placeHolder);
var replaceWith = prepare(clicked.replaceWith);
var closeWith = prepare(clicked.closeWith);
var openBlockWith = prepare(clicked.openBlockWith);
var closeBlockWith = prepare(clicked.closeBlockWith);
var multiline = clicked.multiline;
if (replaceWith !== "") {
block = openWith + replaceWith + closeWith;
} else if (selection === '' && placeHolder !== '') {
block = openWith + placeHolder + closeWith;
} else {
block = openWith + (string||selection) + closeWith;
string = string || selection;
var lines = [string], blocks = [];
if (multiline === true) {
lines = string.split(/\r?\n/);
}
for (var l = 0; l < lines.length; l++) {
line = lines[l];
var trailingSpaces;
if (trailingSpaces = line.match(/ *$/)) {
blocks.push(openWith + line.replace(/ *$/g, '') + closeWith + trailingSpaces);
} else {
blocks.push(openWith + line + closeWith);
}
}
block = blocks.join("\n");
}
return { block:block,
openWith:openWith,
replaceWith:replaceWith,
block = openBlockWith + block + closeBlockWith;
return { block:block,
openBlockWith:openBlockWith,
openWith:openWith,
replaceWith:replaceWith,
placeHolder:placeHolder,
closeWith:closeWith
closeWith:closeWith,
closeBlockWith:closeBlockWith
};
}
@ -255,26 +337,25 @@
var len, j, n, i;
hash = clicked = button;
get();
$.extend(hash, { line:"",
$.extend(hash, { line:"",
root:options.root,
textarea:textarea,
selection:(selection||''),
textarea:textarea,
selection:(selection||''),
caretPosition:caretPosition,
ctrlKey:ctrlKey,
shiftKey:shiftKey,
ctrlKey:ctrlKey,
shiftKey:shiftKey,
altKey:altKey
}
);
// callbacks before insertion
prepare(options.beforeInsert);
prepare(clicked.beforeInsert);
if (ctrlKey === true && shiftKey === true) {
if ((ctrlKey === true && shiftKey === true) || button.multiline === true) {
prepare(clicked.beforeMultiInsert);
}
}
$.extend(hash, { line:1 });
if (ctrlKey === true && shiftKey === true) {
if ((ctrlKey === true && shiftKey === true)) {
lines = selection.split(/\r?\n/);
for (j = 0, n = lines.length, i = 0; i < n; i++) {
if ($.trim(lines[i]) !== '') {
@ -284,13 +365,15 @@
lines[i] = "";
}
}
string = { block:lines.join('\n')};
start = caretPosition;
len = string.block.length + (($.browser.opera) ? n : 0);
len = string.block.length + ((browser.opera) ? n-1 : 0);
} else if (ctrlKey === true) {
string = build(selection);
start = caretPosition + string.openWith.length;
len = string.block.length - string.openWith.length - string.closeWith.length;
len = len - (string.block.match(/ $/) ? 1 : 0);
len -= fixIeBug(string.block);
} else if (shiftKey === true) {
string = build(selection);
@ -305,9 +388,9 @@
}
if ((selection === '' && string.replaceWith === '')) {
caretOffset += fixOperaBug(string.block);
start = caretPosition + string.openWith.length;
len = string.block.length - string.openWith.length - string.closeWith.length;
start = caretPosition + string.openBlockWith.length + string.openWith.length;
len = string.block.length - string.openBlockWith.length - string.openWith.length - string.closeWith.length - string.closeBlockWith.length;
caretOffset = $$.val().substring(caretPosition, $$.val().length).length;
caretOffset -= fixOperaBug($$.val().substring(0, caretPosition));
@ -325,7 +408,7 @@
$.extend(hash, { line:'', selection:selection });
// callbacks after insertion
if (ctrlKey === true && shiftKey === true) {
if ((ctrlKey === true && shiftKey === true) || button.multiline === true) {
prepare(clicked.afterMultiInsert);
}
prepare(clicked.afterInsert);
@ -333,35 +416,35 @@
// refresh preview if opened
if (previewWindow && options.previewAutoRefresh) {
refreshPreview();
refreshPreview();
}
// reinit keyevent
shiftKey = altKey = ctrlKey = abort = false;
}
// Substract linefeed in Opera
function fixOperaBug(string) {
if ($.browser.opera) {
if (browser.opera) {
return string.length - string.replace(/\n*/g, '').length;
}
return 0;
}
// Substract linefeed in IE
function fixIeBug(string) {
if ($.browser.msie) {
if (browser.msie) {
return string.length - string.replace(/\r*/g, '').length;
}
return 0;
}
// add markup
function insert(block) {
function insert(block) {
if (document.selection) {
var newSelection = document.selection.createRange();
newSelection.text = block;
} else {
$$.val($$.val().substring(0, caretPosition) + block + $$.val().substring(caretPosition + selection.length, $$.val().length));
textarea.value = textarea.value.substring(0, caretPosition) + block + textarea.value.substring(caretPosition + selection.length, textarea.value.length);
}
}
@ -369,13 +452,13 @@
function set(start, len) {
if (textarea.createTextRange){
// quick fix to make it work on Opera 9.5
if ($.browser.opera && $.browser.version >= 9.5 && len == 0) {
if (browser.opera && browser.version >= 9.5 && len == 0) {
return false;
}
range = textarea.createTextRange();
range.collapse(true);
range.moveStart('character', start);
range.moveEnd('character', len);
range.moveStart('character', start);
range.moveEnd('character', len);
range.select();
} else if (textarea.setSelectionRange ){
textarea.setSelectionRange(start, start + len);
@ -391,11 +474,11 @@
scrollPosition = textarea.scrollTop;
if (document.selection) {
selection = document.selection.createRange().text;
if ($.browser.msie) { // ie
if (browser.msie) { // ie
var range = document.selection.createRange(), rangeCopy = range.duplicate();
rangeCopy.moveToElementText(textarea);
caretPosition = -1;
while(rangeCopy.inRange(range)) { // fix most of the ie bugs with linefeeds...
while(rangeCopy.inRange(range)) {
rangeCopy.moveStart('character');
caretPosition ++;
}
@ -404,27 +487,34 @@
}
} else { // gecko & webkit
caretPosition = textarea.selectionStart;
selection = $$.val().substring(caretPosition, textarea.selectionEnd);
}
selection = textarea.value.substring(caretPosition, textarea.selectionEnd);
}
return selection;
}
// open preview window
function preview() {
if (!previewWindow || previewWindow.closed) {
if (typeof options.previewHandler === 'function') {
previewWindow = true;
} else if (options.previewInElement) {
previewWindow = $(options.previewInElement);
} else if (!previewWindow || previewWindow.closed) {
if (options.previewInWindow) {
previewWindow = window.open('', 'preview', options.previewInWindow);
$(window).unload(function() {
previewWindow.close();
});
} else {
iFrame = $('<iframe class="markItUpPreviewFrame"></iframe>');
if (options.previewPosition == 'after') {
iFrame.insertAfter(footer);
} else {
iFrame.insertBefore(header);
}
}
previewWindow = iFrame[iFrame.length - 1].contentWindow || frame[iFrame.length - 1];
}
} else if (altKey === true) {
// Thx Stephen M. Redd for the IE8 fix
if (iFrame) {
iFrame.remove();
} else {
@ -433,7 +523,10 @@
previewWindow = iFrame = false;
}
if (!options.previewAutoRefresh) {
refreshPreview();
refreshPreview();
}
if (options.previewInWindow) {
previewWindow.focus();
}
}
@ -442,60 +535,68 @@
renderPreview();
}
function renderPreview() {
function renderPreview() {
var phtml;
if (options.previewParserPath !== '') {
$.ajax( {
if (options.previewHandler && typeof options.previewHandler === 'function') {
options.previewHandler( $$.val() );
} else if (options.previewParser && typeof options.previewParser === 'function') {
var data = options.previewParser( $$.val() );
writeInPreview(localize(data, 1) );
} else if (options.previewParserPath !== '') {
$.ajax({
type: 'POST',
dataType: 'text',
global: false,
url: options.previewParserPath,
data: options.previewParserVar+'='+encodeURIComponent($$.val()),
success: function(data) {
writeInPreview( localize(data, 1) );
writeInPreview( localize(data, 1) );
}
} );
});
} else {
if (!template) {
$.ajax( {
$.ajax({
url: options.previewTemplatePath,
dataType: 'text',
global: false,
success: function(data) {
writeInPreview( localize(data, 1).replace(/<!-- content -->/g, $$.val()) );
}
} );
});
}
}
return false;
}
function writeInPreview(data) {
if (previewWindow.document) {
if (options.previewInElement) {
$(options.previewInElement).html(data);
} else if (previewWindow && previewWindow.document) {
try {
sp = previewWindow.document.documentElement.scrollTop
} catch(e) {
sp = 0;
}
}
previewWindow.document.open();
previewWindow.document.write(data);
previewWindow.document.close();
previewWindow.document.documentElement.scrollTop = sp;
}
if (options.previewInWindow) {
previewWindow.focus();
}
}
// set keys pressed
function keyPressed(e) {
function keyPressed(e) {
shiftKey = e.shiftKey;
altKey = e.altKey;
ctrlKey = (!(e.altKey && e.ctrlKey)) ? e.ctrlKey : false;
ctrlKey = (!(e.altKey && e.ctrlKey)) ? (e.ctrlKey || e.metaKey) : false;
if (e.type === 'keydown') {
if (ctrlKey === true) {
li = $("a[accesskey="+String.fromCharCode(e.keyCode)+"]", header).parent('li');
li = $('a[accesskey="'+((e.keyCode == 13) ? '\\n' : String.fromCharCode(e.keyCode))+'"]', header).parent('li');
if (li.length !== 0) {
ctrlKey = false;
setTimeout(function() {
li.triggerHandler('mousedown');
li.triggerHandler('mouseup');
},1);
return false;
}
@ -515,8 +616,8 @@
}
}
if (e.keyCode === 9) { // Tab key
if (shiftKey == true || ctrlKey == true || altKey == true) { // Thx Dr Floob.
return false;
if (shiftKey == true || ctrlKey == true || altKey == true) {
return false;
}
if (caretOffset !== -1) {
get();
@ -532,14 +633,19 @@
}
}
function remove() {
$$.unbind(".markItUp").removeClass('markItUpEditor');
$$.parent('div').parent('div.markItUp').parent('div').replaceWith($$);
$$.data('markItUp', null);
}
init();
});
};
$.fn.markItUpRemove = function() {
return this.each(function() {
var $$ = $(this).unbind().removeClass('markItUpEditor');
$$.parent('div').parent('div.markItUp').parent('div').replaceWith($$);
$(this).markItUp('remove');
}
);
};

File diff suppressed because one or more lines are too long

View File

@ -1,40 +1,48 @@
.markItUp .btnHeading a {
/* -------------------------------------------------------------------
// ReST!
// ------------------------------------------------------------------*/
.ReST .markItUpButton1 a {
background-image:url(images/h1.png);
}
.markItUp .btnSubheading a {
.ReST .markItUpButton2 a {
background-image:url(images/h2.png);
}
.markItUp .btnSubsubheading a {
.ReST .markItUpButton3 a {
background-image:url(images/h3.png);
}
.markItUp .btnBold a {
background-image:url(images/bold.png);
.ReST .markItUpButton4 a {
background-image:url(images/bold.png);
}
.markItUp .btnItalic a {
.ReST .markItUpButton5 a {
background-image:url(images/italic.png);
}
.markItUp .btnBulletedList a {
.ReST .markItUpButton6 a {
background-image:url(images/list-bullet.png);
}
.markItUp .btnNumberedList a {
.ReST .markItUpButton7 a {
background-image:url(images/list-numeric.png);
}
.markItUp .btnInternalLink a {
.ReST .markItUpButton8 a {
background-image:url(images/book_link.png);
}
.markItUp .btnLink a {
.ReST .markItUpButton9 a {
background-image:url(images/link_go.png);
}
.markItUp .btnQuotes a {
.ReST .markItUpButton10 a {
background-image:url(images/picture.png);
}
.ReST .markItUpButton11 a {
background-image:url(images/quotes.png);
}
.markItUp .btnCode a {
.ReST .markItUpButton12 a {
background-image:url(images/code.png);
}
.markItUp .btnIndent a {
background-image:url(images/indent.png);
.ReST .markItUpButton13 a {
background-image:url(images/indent.png);
}

View File

@ -1,49 +1,68 @@
SphinxDocsSettings = {
nameSpace: 'restructuredtext',
onShiftEnter: {keepDefault:false, openWith:'\n\n'},
markupSet: [
{name:'Top-level Heading', className: 'btnHeading', key:"1", placeHolder:'Your heading here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '=') } },
{name:'Sub-heading', className: 'btnSubheading', key:"2", placeHolder:'Your sub-heading here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '-') } },
{name:'Sub-sub-heading', className: 'btnSubsubheading', key:"3", placeHolder:'Your sub-sub-heading here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '^') } },
{separator:'---------------' },
{name:'Bold', className: 'btnBold', key:"B", openWith:'**', closeWith:'**'},
{name:'Italic', className: 'btnItalic', key:"I", openWith:'*', closeWith:'*'},
{separator:'---------------' },
{name:'Bulleted List', className: 'btnBulletedList', openWith:'* ' },
{name:'Numeric List', className: 'btnNumberedList', openWith:function(markItUp) {
return markItUp.line+'. ';
}},
{separator:'---------------' },
//{name:'Picture', key:"P", replaceWith:'![[![Alternative text]!]]([![Url:!:http://]!] "[![Title]!]")'},
{name:'Internal Link', className: 'btnInternalLink', key:"L", openWith:':doc:`', closeWith:' <[![Heading:!:]!]>`', placeHolder:'Your text to link here...' },
{name:'External Link', className: 'btnLink', key:"E", openWith:'`', closeWith:' <[![Url:!:http://]!]>`_', placeHolder:'Your text to link here...' },
{separator:'---------------'},
{name:'Quotes', className: 'btnQuotes', placeHolder: 'block quote text here...', replaceWith:function(markItUp) {
// -------------------------------------------------------------------
// markItUp!
// -------------------------------------------------------------------
// Copyright (C) 2008 Jay Salvat
// http://markitup.jaysalvat.com/
// -------------------------------------------------------------------
// ReStructured Text
// http://docutils.sourceforge.net/
// http://docutils.sourceforge.net/rst.html
// -------------------------------------------------------------------
// Mark Renron <indexofire@gmail.com>
// http://www.indexofire.com
// -------------------------------------------------------------------
// Jannis Leidel <jannis@leidel.info>
// http://enn.io
// -------------------------------------------------------------------
mySettings = {
nameSpace: 'ReST',
onShiftEnter: {keepDefault:false, openWith:'\n\n'},
onTab: {keepDefault:false, replaceWith:' '},
markupSet: [
//{name:'Level 1 Heading', key:'1', placeHolder:'Your title Here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '#'); } },
//{name:'Level 2 Heading', key:'2', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '*'); } },
{name:'Level 1 Heading', key:'1', placeHolder:'Your heading here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '='); } },
{name:'Level 2 Heading', key:'2', placeHolder:'Your sub-heading here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '-'); } },
{name:'Level 3 Heading', key:'3', placeHolder:'Your sub-sub-heading here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '^'); } },
//{name:'Level 6 Heading', key:'6', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '"'); } },
{separator:'---------------' },
{name:'Bold', key:'B', openWith:'**', closeWith:'**', placeHolder:'Input Your Bold Text Here...'},
{name:'Italic', key:'I', openWith:'`', closeWith:'`', placeHolder:'Input Your Italic Text Here...'},
{separator:'---------------' },
{name:'Bulleted List', openWith:'* ' },
{name:'Numeric List', openWith:function(markItUp) { return markItUp.line+'. '; } },
{separator:'---------------' },
{name:'Internal Link', key:"L", openWith:':doc:`', closeWith:' <[![Heading:!:]!]>`', placeHolder:'Your text to link here...' },
{name:'External Link', key:"E", openWith:'`', closeWith:' <[![Url:!:http://]!]>`_', placeHolder:'Your text to link here...' },
{separator:'---------------' },
{name:'Picture', key:'P', openWith:'.. image:: ', placeHolder:'Link Your Images Here...'},
{name:'Quotes', placeHolder: 'block quote text here...', replaceWith:function(markItUp) {
return miu.indentText(markItUp);
}},
{name:'Code Block / Code', className: 'btnCode', placeHolder:'Code here...', replaceWith:function(markItUp) {
{name:'Code Block / Code', placeHolder:'Code here...', replaceWith:function(markItUp) {
directive = '\n.. code-block:: python\n\n';
indented = miu.indentText(markItUp);
return directive + indented;
}},
{separator:'---------------'},
{name:'Indent', className:"btnIndent", replaceWith:function(markItUp) {
{name:'Indent', replaceWith:function(markItUp) {
return miu.indentText(markItUp);
}}
]
}
]
};
// mIu nameSpace to avoid conflict.
miu = {
markdownTitle: function(markItUp, char) {
heading = '';
n = $.trim(markItUp.selection||markItUp.placeHolder).length;
for(i = 0; i < n; i++) {
heading += char;
}
return '\n'+heading+'\n';
},
indentText: function(markItUp) {
markdownTitle: function(markItUp, character) {
heading = '';
n = $.trim(markItUp.selection||markItUp.placeHolder).length;
for(i = 0; i < n; i++) {
heading += character;
}
return '\n'+heading + '\n';
},
indentText: function(markItUp) {
text_block = markItUp.selection || markItUp.placeHolder;
indented = '';
$.each(text_block.split('\n'), function(idx, text) {
@ -51,4 +70,4 @@ miu = {
});
return indented;
}
}
};

View File

@ -14,7 +14,7 @@
<script type="text/javascript" src="{{ MEDIA_URL }}lib/markitup/sets/sphinx/editor.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#id_description").markItUp(SphinxDocsSettings); // .markItUp(mySettings);
$("#id_description").markItUp(mySettings);
});
</script>
{% endblock %}