From 3b83390f957326e221faf60bde87311a12963b69 Mon Sep 17 00:00:00 2001 From: Serkan Algur Date: Wed, 3 Sep 2014 09:35:42 +0300 Subject: [PATCH 1/8] Turkish translation Turkish translation file added and missed code, ordred list, save, quote texts added to translation --- locale/bootstrap-markdown.tr.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 locale/bootstrap-markdown.tr.js diff --git a/locale/bootstrap-markdown.tr.js b/locale/bootstrap-markdown.tr.js new file mode 100644 index 0000000..21ffe10 --- /dev/null +++ b/locale/bootstrap-markdown.tr.js @@ -0,0 +1,31 @@ +/** + * Turkish translation for bootstrap-markdown + * Serkan Algur + */ +(function ($) { + $.fn.markdown.messages.tr = { + 'Bold': "Kalın", + 'Italic': "İtalik", + 'Heading': "Başlık", + 'URL/Link': "Link ekle", + 'Image': "Resim ekle", + 'List': "Liste Oluşturun", + 'Preview': "Önizleme", + 'strong text': "kalın yazı", + 'emphasized text': "italik yazı", + 'heading text': "Başlık Yazısı", + 'enter link description here': "Link açıklamasını buraya girin", + 'Insert Hyperlink': "İnternet adresi girin", + 'enter image description here': "resim açıklamasını buraya ekleyin", + 'Insert Image Hyperlink': "Resim linkini ekleyin", + 'enter image title here': "resim başlığını buraya ekleyin", + 'list text here': "liste yazısı", + 'Save' : "Kaydet", + 'Ordered List' : "Numaralı Liste", + 'Unordered List' : "Madde imli liste", + 'Quote' : "Alıntı", + 'quote here' : "alıntıyı buraya ekleyin", + 'Code' : "Kod", + 'code text here' : "kodu buraya ekleyin" + }; +}(jQuery)); From a3f06a95e2ea45f22c7240ad930fc29045c31f50 Mon Sep 17 00:00:00 2001 From: Oleg Vivtash Date: Wed, 10 Sep 2014 03:43:27 +0300 Subject: [PATCH 2/8] More accurate toolbar button construction --- js/bootstrap-markdown.js | 53 +++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/js/bootstrap-markdown.js b/js/bootstrap-markdown.js index 456cbae..b22cf6c 100644 --- a/js/bootstrap-markdown.js +++ b/js/bootstrap-markdown.js @@ -83,7 +83,7 @@ for (z=0;z'); + $button.text(' ' + this.__localize(btnText)).addClass('btn-default btn-sm').addClass(btnClass); + if(btnClass.match(/btn\-(primary|success|info|warning|danger|link)/)){ + $button.removeClass('btn-default'); + } + $button.attr({ + 'type': 'button', + 'title': this.__localize(button.title) + hotkeyCaption, + 'tabindex': tabIndex, + 'data-provider': ns, + 'data-handler': buttonHandler, + 'data-hotkey': hotkey + }); + if (button.toggle == true){ + $button.attr('data-toggle', 'button'); } + $icon = $(''); + $icon.addClass(buttonIcon); + $icon.prependTo($button); - // Attach the button object - btnGroupContainer.append('') + btnGroupContainer.append($button); // Register handler and callback - handler.push(buttonHandler) - callback.push(button.callback) + handler.push(buttonHandler); + callback.push(button.callback); } // Attach the button group into container dom - container.append(btnGroupContainer) + container.append(btnGroupContainer); } } - return container + return container; } , __setListener: function() { // Set size and resizable Properties From 8cb259e6b9d35203edacf7d8f4b954d29a1e368d Mon Sep 17 00:00:00 2001 From: Oleg Vivtash Date: Wed, 10 Sep 2014 16:20:38 +0300 Subject: [PATCH 3/8] Few variable name updates inside `__buildButtons` --- js/bootstrap-markdown.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/js/bootstrap-markdown.js b/js/bootstrap-markdown.js index b22cf6c..c3ea8d4 100644 --- a/js/bootstrap-markdown.js +++ b/js/bootstrap-markdown.js @@ -83,7 +83,7 @@ for (z=0;z'); - $button.text(' ' + this.__localize(btnText)).addClass('btn-default btn-sm').addClass(btnClass); + // Construct the button object + buttonContainer = $(''); + buttonContainer.text(' ' + this.__localize(btnText)).addClass('btn-default btn-sm').addClass(btnClass); if(btnClass.match(/btn\-(primary|success|info|warning|danger|link)/)){ - $button.removeClass('btn-default'); + buttonContainer.removeClass('btn-default'); } - $button.attr({ + buttonContainer.attr({ 'type': 'button', 'title': this.__localize(button.title) + hotkeyCaption, 'tabindex': tabIndex, @@ -107,13 +107,14 @@ 'data-hotkey': hotkey }); if (button.toggle == true){ - $button.attr('data-toggle', 'button'); + buttonContainer.attr('data-toggle', 'button'); } - $icon = $(''); - $icon.addClass(buttonIcon); - $icon.prependTo($button); + buttonIconContainer = $(''); + buttonIconContainer.addClass(buttonIcon); + buttonIconContainer.prependTo(buttonContainer); - btnGroupContainer.append($button); + // Attach the button object + btnGroupContainer.append(buttonContainer); // Register handler and callback handler.push(buttonHandler); From 66b9772a248685f63a1ba8ef5bd7b20f58371240 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Wed, 10 Sep 2014 22:02:31 +0700 Subject: [PATCH 4/8] * Allow nested bold and italic * Alleviate XSS input Ref #98 --- js/bootstrap-markdown.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/js/bootstrap-markdown.js b/js/bootstrap-markdown.js index c3ea8d4..8fb86dc 100644 --- a/js/bootstrap-markdown.js +++ b/js/bootstrap-markdown.js @@ -944,13 +944,13 @@ } // transform selection and set the cursor into chunked text - if (content.substr(selected.start-1,1) == '*' - && content.substr(selected.end,1) == '*' ) { + if (content.substr(selected.start-1,1) == '_' + && content.substr(selected.end,1) == '_' ) { e.setSelection(selected.start-1,selected.end+1) e.replaceSelection(chunk) cursor = selected.start-1 } else { - e.replaceSelection('*'+chunk+'*') + e.replaceSelection('_'+chunk+'_') cursor = selected.start+1 } @@ -1012,9 +1012,11 @@ link = prompt(e.__localize('Insert Hyperlink'),'http://') - if (link != null && link != '' && link != 'http://') { + if (link != null && link != '' && link != 'http://' && link.substr(0,4) == 'http') { + var sanitizedLink = $('
'+link+'
').text() + // transform selection and set the cursor into chunked text - e.replaceSelection('['+chunk+']('+link+')') + e.replaceSelection('['+chunk+']('+sanitizedLink+')') cursor = selected.start+1 // Set the cursor @@ -1039,9 +1041,11 @@ link = prompt(e.__localize('Insert Image Hyperlink'),'http://') - if (link != null) { + if (link != null && link != '' && link != 'http://' && link.substr(0,4) == 'http') { + var sanitizedLink = $('
'+link+'
').text() + // transform selection and set the cursor into chunked text - e.replaceSelection('!['+chunk+']('+link+' "'+e.__localize('enter image title here')+'")') + e.replaceSelection('!['+chunk+']('+sanitizedLink+' "'+e.__localize('enter image title here')+'")') cursor = selected.start+2 // Set the next tab From 3859d29e7d462a359733e3cc240c6faf23004e44 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Wed, 10 Sep 2014 22:41:13 +0700 Subject: [PATCH 5/8] Ignore node module dir --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b13058c..4bb18cd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ bower_components .DS_Store +node_modules/* From ab441492aa1b31bef25b7549e513227a45e54692 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Wed, 10 Sep 2014 22:41:32 +0700 Subject: [PATCH 6/8] Clean up theme related --- css/bootstrap-markdown.min.css | 3 +-- js/bootstrap-markdown.js | 11 ----------- less/bootstrap-markdown.less | 32 -------------------------------- 3 files changed, 1 insertion(+), 45 deletions(-) diff --git a/css/bootstrap-markdown.min.css b/css/bootstrap-markdown.min.css index 8f91feb..388b2f5 100644 --- a/css/bootstrap-markdown.min.css +++ b/css/bootstrap-markdown.min.css @@ -1,2 +1 @@ -/* CSS crunched with Crunch - http://crunchapp.net/ */ -.md-editor{display:block;border:1px solid #ddd}.md-editor>.md-header,.md-editor .md-footer{display:block;padding:6px 4px;background:#f5f5f5}.md-editor>.md-header{margin:0}.md-editor>.md-preview{background:#fff;border-top:1px dashed #ddd;border-bottom:1px dashed #ddd;min-height:10px;overflow:auto}.md-editor>textarea{font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:14px;outline:0;outline:thin dotted \9;margin:0;display:block;padding:0;width:100%;border:0;border-top:1px dashed #ddd;border-bottom:1px dashed #ddd;border-radius:0;box-shadow:none;background:#eee}.md-editor>textarea:focus{box-shadow:none;background:#fff}.md-editor.active{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6)}.md-editor .md-controls{float:right;padding:3px}.md-editor .md-controls .md-control{right:5px;color:#bebebe;padding:3px 3px 3px 10px}.md-editor .md-controls .md-control:hover{color:#333}.md-editor.md-fullscreen-mode{width:100%;height:100%;position:fixed;top:0;left:0;z-index:99999;padding:60px 30px 15px;background:#fff !important;border:0 !important}.md-editor.md-fullscreen-mode.theme-dark{background:#1d1f21 !important}.md-editor.md-fullscreen-mode.theme-dark .md-fullscreen-controls a{color:#a4b1b1}.md-editor.md-fullscreen-mode.theme-dark .md-fullscreen-controls a:hover{color:#dbe0e0;text-shadow:0 0 10px #000}.md-editor.md-fullscreen-mode.theme-dark .md-preview,.md-editor.md-fullscreen-mode.theme-dark .md-input,.md-editor.md-fullscreen-mode.theme-dark .md-input:hover,.md-editor.md-fullscreen-mode.theme-dark .md-input:active,.md-editor.md-fullscreen-mode.theme-dark .md-input:focus{color:#dbe0e0;background:#1d1f21 !important}.md-editor.md-fullscreen-mode.theme-dark .btn:hover,.md-editor.md-fullscreen-mode.theme-dark .btn:focus,.md-editor.md-fullscreen-mode.theme-dark .btn.active,.md-editor.md-fullscreen-mode.theme-dark .btn:active{color:#dbe0e0;text-shadow:0 0 10px #000}.md-editor.md-fullscreen-mode .md-footer{display:none}.md-editor.md-fullscreen-mode .md-input,.md-editor.md-fullscreen-mode .md-preview{margin:0 auto !important;height:100% !important;font-size:20px !important;padding:20px !important;color:#999;line-height:1.6em !important;resize:none !important;box-shadow:none !important;background:#fff !important;border:0 !important}.md-editor.md-fullscreen-mode .md-preview{color:#333;overflow:auto}.md-editor.md-fullscreen-mode .md-input:hover,.md-editor.md-fullscreen-mode .md-input:focus{color:#333;background:#fff !important}.md-editor.md-fullscreen-mode .md-header{background:none;text-align:center;position:fixed;width:100%;top:20px}.md-editor.md-fullscreen-mode .btn-group{float:none}.md-editor.md-fullscreen-mode .btn{border:0;background:none;color:#b3b3b3}.md-editor.md-fullscreen-mode .btn:hover,.md-editor.md-fullscreen-mode .btn:focus,.md-editor.md-fullscreen-mode .btn.active,.md-editor.md-fullscreen-mode .btn:active{box-shadow:none;color:#333}.md-editor.md-fullscreen-mode .md-fullscreen-controls{position:absolute;top:20px;right:20px;text-align:right;z-index:1002;display:block}.md-editor.md-fullscreen-mode .md-fullscreen-controls a{color:#b3b3b3;clear:right;margin:10px;width:30px;height:30px;text-align:center}.md-editor.md-fullscreen-mode .md-fullscreen-controls a:hover{color:#333;text-decoration:none}.md-editor.md-fullscreen-mode .md-editor{height:100% !important;position:relative}.md-editor .md-fullscreen-controls{display:none}.md-nooverflow{overflow:hidden;position:fixed;width:100%} \ No newline at end of file +.md-editor{display:block;border:1px solid #ddd}.md-editor .md-footer,.md-editor>.md-header{display:block;padding:6px 4px;background:#f5f5f5}.md-editor>.md-header{margin:0}.md-editor>.md-preview{background:#fff;border-top:1px dashed #ddd;border-bottom:1px dashed #ddd;min-height:10px;overflow:auto}.md-editor>textarea{font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:14px;outline:0;margin:0;display:block;padding:0;width:100%;border:0;border-top:1px dashed #ddd;border-bottom:1px dashed #ddd;border-radius:0;box-shadow:none;background:#eee}.md-editor>textarea:focus{box-shadow:none;background:#fff}.md-editor.active{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}.md-editor .md-controls{float:right;padding:3px}.md-editor .md-controls .md-control{right:5px;color:#bebebe;padding:3px 3px 3px 10px}.md-editor .md-controls .md-control:hover{color:#333}.md-editor.md-fullscreen-mode{width:100%;height:100%;position:fixed;top:0;left:0;z-index:99999;padding:60px 30px 15px;background:#fff!important;border:0!important}.md-editor.md-fullscreen-mode .md-footer{display:none}.md-editor.md-fullscreen-mode .md-input,.md-editor.md-fullscreen-mode .md-preview{margin:0 auto!important;height:100%!important;font-size:20px!important;padding:20px!important;color:#999;line-height:1.6em!important;resize:none!important;box-shadow:none!important;background:#fff!important;border:0!important}.md-editor.md-fullscreen-mode .md-preview{color:#333;overflow:auto}.md-editor.md-fullscreen-mode .md-input:focus,.md-editor.md-fullscreen-mode .md-input:hover{color:#333;background:#fff!important}.md-editor.md-fullscreen-mode .md-header{background:0 0;text-align:center;position:fixed;width:100%;top:20px}.md-editor.md-fullscreen-mode .btn-group{float:none}.md-editor.md-fullscreen-mode .btn{border:0;background:0 0;color:#b3b3b3}.md-editor.md-fullscreen-mode .btn.active,.md-editor.md-fullscreen-mode .btn:active,.md-editor.md-fullscreen-mode .btn:focus,.md-editor.md-fullscreen-mode .btn:hover{box-shadow:none;color:#333}.md-editor.md-fullscreen-mode .md-fullscreen-controls{position:absolute;top:20px;right:20px;text-align:right;z-index:1002;display:block}.md-editor.md-fullscreen-mode .md-fullscreen-controls a{color:#b3b3b3;clear:right;margin:10px;width:30px;height:30px;text-align:center}.md-editor.md-fullscreen-mode .md-fullscreen-controls a:hover{color:#333;text-decoration:none}.md-editor.md-fullscreen-mode .md-editor{height:100%!important;position:relative}.md-editor .md-fullscreen-controls{display:none}.md-nooverflow{overflow:hidden;position:fixed;width:100%} \ No newline at end of file diff --git a/js/bootstrap-markdown.js b/js/bootstrap-markdown.js index 8fb86dc..c6285a2 100644 --- a/js/bootstrap-markdown.js +++ b/js/bootstrap-markdown.js @@ -405,7 +405,6 @@ if (options.fullscreen.enable && options.fullscreen !== false) { this.$editor.append('\
\ - \ \
') @@ -413,11 +412,6 @@ e.preventDefault() instance.setFullscreen(false) }) - - this.$editor.on('click', '.switch-theme', function(e) { - e.preventDefault() - instance.$editor.toggleClass('theme-dark') - }) } // hide hidden buttons from options @@ -1271,11 +1265,6 @@ fa: 'fa fa-compress', glyph: 'glyphicon glyphicon-fullscreen', 'fa-3': 'icon-resize-small' - }, - switchTheme: { - fa: 'fa fa-adjust', - glyph: 'glyphicon glyphicon-adjust', - 'fa-3': 'icon-adjust' } } }, diff --git a/less/bootstrap-markdown.less b/less/bootstrap-markdown.less index 09493ca..6c376b2 100644 --- a/less/bootstrap-markdown.less +++ b/less/bootstrap-markdown.less @@ -83,38 +83,6 @@ background: #fff !important; border: 0 !important; - &.theme-dark { - background: #1d1f21 !important; - - .md-fullscreen-controls a { - color: #a4b1b1; - &:hover { - color: #dbe0e0; - text-shadow: 0 0 10px #000; - } - } - - .md-preview, - .md-input, - .md-input:hover, - .md-input:active, - .md-input:focus { - color: #dbe0e0; - background: #1d1f21 !important; - - } - - .btn { - &:hover, - &:focus, - &.active, - &:active { - color: #dbe0e0; - text-shadow: 0 0 10px #000; - } - } - } - .md-footer { display: none; } From e081bb45dc24d0d2e4086f4a400a162af4928c3d Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Wed, 10 Sep 2014 22:44:40 +0700 Subject: [PATCH 7/8] Bump version --- bower.json | 2 +- js/bootstrap-markdown.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bower.json b/bower.json index e7a4d4a..005b298 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "bootstrap-markdown", - "version": "2.6.0", + "version": "2.7.0", "main": ["./js/bootstrap-markdown.js", "./css/bootstrap-markdown.min.css"], "dependencies": { "bootstrap": "~3.1.1" diff --git a/js/bootstrap-markdown.js b/js/bootstrap-markdown.js index c6285a2..d9a7b76 100644 --- a/js/bootstrap-markdown.js +++ b/js/bootstrap-markdown.js @@ -1,5 +1,5 @@ /* =================================================== - * bootstrap-markdown.js v2.6.0 + * bootstrap-markdown.js v2.7.0 * http://github.com/toopay/bootstrap-markdown * =================================================== * Copyright 2013-2014 Taufan Aditya diff --git a/package.json b/package.json index 212c346..6be50d4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bootstrap-markdown", "filename": "js/bootstrap-markdown.js", - "version": "2.6.0", + "version": "2.7.0", "description": "A bootstrap plugin for markdown editing", "homepage": "https://github.com/toopay/bootstrap-markdown", "keywords": [ From 9e865ead59d6ea66631b77a4529cd80dc327f2a5 Mon Sep 17 00:00:00 2001 From: Jovanni Lo Date: Tue, 16 Sep 2014 16:55:54 +0800 Subject: [PATCH 8/8] parseContent Fix Fixed a bug from parseContent method when used inside onPreview hook. Added an optional argument val for some reason :) --- js/bootstrap-markdown.js | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/js/bootstrap-markdown.js b/js/bootstrap-markdown.js index d9a7b76..4d0251d 100644 --- a/js/bootstrap-markdown.js +++ b/js/bootstrap-markdown.js @@ -426,23 +426,17 @@ return this } - , parseContent: function() { - var content, - callbackContent = this.$options.onPreview(this) // Try to get the content from callback - - if (typeof callbackContent == 'string') { - // Set the content based by callback content - content = callbackContent + , parseContent: function(val) { + var content + + // parse with supported markdown parser + var val = val || this.$textarea.val(); + if(typeof markdown == 'object') { + content = markdown.toHTML(val); + }else if(typeof marked == 'function') { + content = marked(val); } else { - // Set the content - var val = this.$textarea.val(); - if(typeof markdown == 'object') { - content = markdown.toHTML(val); - }else if(typeof marked == 'function') { - content = marked(val); - } else { - content = val; - } + content = val; } return content; @@ -453,14 +447,17 @@ container = this.$textarea, afterContainer = container.next(), replacementContainer = $('
',{'class':'md-preview','data-provider':'markdown-preview'}), - content + content, + callbackContent // Give flag that tell the editor enter preview mode this.$isPreview = true // Disable all buttons this.disableButtons('all').enableButtons('cmdPreview') - content = this.parseContent() + callbackContent = options.onPreview(this) // Try to get the content from callback + // Set the content based from the callback content if string otherwise parse value from textarea + content = typeof callbackContent == 'string' ? callbackContent : this.parseContent(); // Build preview element replacementContainer.html(content)