Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add i18n support and emotions #11

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
274 changes: 220 additions & 54 deletions Markdown.Editor.js

Large diffs are not rendered by default.

21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
PageDown-Bootstrap
==================
PageDown-bootstrap with i18n and emotion support
=======================

This is a fork of http://code.google.com/p/pagedown/ changed to use Twitter Bootstrap for styling the editor and modal popups.
> This is a fork of https://github.com/samwillis/pagedown-bootstrap to add i18n and emotions support

The demo is viewable here: http://samwillis.co.uk/pagedown-bootstrap/demo/browser/demo.html
**i18n support**

Currenly the hint and the hover tooltips are seperated from Markdown.Editor.js to i18n/Markdown.i18n.LANGUAGE.js, where translations are located. Only chinese translation is complete, but you can add pretty much any language as you like. Just make sure the format looks like the i18n/Markdown.i18n.zh-cn.js file(Your pull requests are always welcome!).

Usage:

reference the translation file in your template and pass a language preference to set the editor language when you are constructing your editor in your js code

**emotions**

You have to call Markdown.SupportEmotions(imgPath,emotions) before constructing your
editor if your want it to include emotions

The demo is viewable here: http://shellfly.org/pagedown-with-emotions/demo/browser/demo.html

New icons based on http://glyphicons.com/, http://dribbble.com/shots/365544-Mini-glyphs-12-px-Free-PSD and the origional icons.
18 changes: 15 additions & 3 deletions demo/browser/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="../../jquery.min.js"></script>
<script src="bootstrap/js/bootstrap-transition.js"></script>
<script src="bootstrap/js/bootstrap-modal.js"></script>
<script src="bootstrap/js/bootstrap-tooltip.js"></script>
<script type="text/javascript" src="../../Markdown.Converter.js"></script>
<script type="text/javascript" src="../../Markdown.Sanitizer.js"></script>
<script type="text/javascript" src="../../Markdown.Editor.js"></script>
<script type="text/javascript" src="../../i18n/Markdown.i18n.zh_cn.js"></script>

</head>
<body>
Expand Down Expand Up @@ -81,6 +82,7 @@ <h2>2. This is a custom editor</h2>
<textarea class="wmd-input" id="wmd-input-second">
This is the *second* editor.
------------------------------
It was created after Markdown.SupportEmotions ![](/img/icon_idea.gif)

It has a plugin hook registered that surrounds all words starting with the
letter A with asterisks before doing the Markdown conversion. Another one gives bare links
Expand All @@ -104,7 +106,17 @@ <h2>2. This is a custom editor</h2>
var converter1 = Markdown.getSanitizingConverter();
var editor1 = new Markdown.Editor(converter1);
editor1.run();


var imgPath = '/img/';
var emotions = [['cool', 'arrow', 'biggrin', 'confused', 'cry', 'eek','neutral'],
['evil', 'exclaim', 'idea', 'lol', 'mad', 'mrgreen','question'],
['razz', 'redface', 'rolleyes', 'sad','smile','surprised', 'twisted'],
['wink']]
for (var i=0;i<emotions.length; i++)
for (j=0;j<emotions[i].length; j++)
emotions[i][j] = 'icon_' + emotions[i][j] + '.gif'

Markdown.SupportEmotions(imgPath,emotions);
var converter2 = new Markdown.Converter();

converter2.hooks.chain("preConversion", function (text) {
Expand All @@ -117,7 +129,7 @@ <h2>2. This is a custom editor</h2>

var help = function () { alert("Do you need help?"); }

var editor2 = new Markdown.Editor(converter2, "-second", { handler: help });
var editor2 = new Markdown.Editor(converter2, "-second", { handler: help },'zh-CN');

editor2.run();
})();
Expand Down
41 changes: 41 additions & 0 deletions i18n/Markdown.i18n.zh_cn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
;(function($){
$.fn.markdown_editor.translations['zh-CN'] = {
tooltips: {
bold: '粗体 - Ctrl+B',
bold_insertion: '加粗文字内容',
italic: '斜体 - Ctrl+I',
italic_insertion: '斜体文字内容',
quote: '引用 - Ctrl+Q',
quote_insertion: '引用内容',
code: '代码示例 - Ctrl+K',
code_insertion: '在这里输入代码内容',
olist: '有序列表 - Ctrl+O',
olist_insertion: '列表项内容',
ulist: '无序列表 - Ctrl+U',
ulist_insertion: '列表项内容',
heading: '标题 - Ctrl+H',
heading_insertion: '标题内容',
image: '图片 - Ctrl+G',
link: '链接 - Ctrl+L',
hr: '水平分割线 - Ctrl+R',
undo: '撤销 - Ctrl+Z',
redo_pc: '重做 - Ctrl+Y',
redo_mac: '重做 - Ctrl+Shift+Z' ,
emotions: '表情 - Ctrl+E'
},
dialog_text: {
link_title: "插入链接",
link_example: "<p>http://example.com/ \"标题(选填)\"</p>",
link_description: "请在这里填写链接描述",
image_title: "插入图片",
image_example: "<p>http://example.com/images/diagram.jpg \"标题(选填)\"</p>",
image_description: "请在这里填写图片描述"
},
button_text: {
ok: "确定",
cancel: "取消"
},


}
}(jQuery));
Binary file added img/icon_arrow.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_biggrin.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_confused.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_cool.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_cry.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_eek.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_evil.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_exclaim.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_idea.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_lol.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_mad.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_mrgreen.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_neutral.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_question.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_razz.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_redface.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_rolleyes.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_sad.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_smile.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_surprised.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_twisted.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon_wink.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions jquery.min.js

Large diffs are not rendered by default.