From 01217c9f4a83cbf700bca803cf1479c06981dac1 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Fri, 25 Sep 2015 17:41:15 +0800 Subject: Added extraTags support for list, and can toggle todo list in the view mode --- public/js/index.js | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'public/js/index.js') diff --git a/public/js/index.js b/public/js/index.js index c414b0b5..28503413 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -102,7 +102,7 @@ var supportExternals = [ search: 'gist' } ]; -var supportBlockquoteTags = [ +var supportExtraTags = [ { text: '[name tag]', search: '[]', @@ -2031,13 +2031,35 @@ $(editor.getInputField()) return !isInCode; } }, - { //blockquote personal info & general info + { //extra tags for blockquote match: /(?:^|\n|\s)(\>.*)(\[\])(\w*)$/, search: function (term, callback) { var list = []; - $.map(supportBlockquoteTags, function (blockquotetag) { - if (blockquotetag.search.indexOf(term) === 0) - list.push(blockquotetag.command()); + $.map(supportExtraTags, function (extratag) { + if (extratag.search.indexOf(term) === 0) + list.push(extratag.command()); + }); + $.map(supportReferrals, function (referral) { + if (referral.search.indexOf(term) === 0) + list.push(referral.text); + }) + callback(list); + checkCursorMenu(); + }, + replace: function (value) { + return '$1' + value; + }, + context: function (text) { + return !isInCode; + } + }, + { //extra tags for list + match: /(^[>\s]*[\-\+\*]\s(?:\[[x ]\]|.*))(\[\])(\w*)$/, + search: function (term, callback) { + var list = []; + $.map(supportExtraTags, function (extratag) { + if (extratag.search.indexOf(term) === 0) + list.push(extratag.command()); }); $.map(supportReferrals, function (referral) { if (referral.search.indexOf(term) === 0) -- cgit v1.2.3