markdown editor i18n

This commit is contained in:
lealife
2015-10-14 18:38:08 +08:00
parent cf8171c9cd
commit ad295d97c8
7 changed files with 177 additions and 129 deletions

View File

@ -611,7 +611,7 @@ function log(o) {
<!-- 帮助 --> <!-- 帮助 -->
<ul class="nav left-buttons"> <ul class="nav left-buttons">
<li class="wmd-button-group6 btn-group"> <li class="wmd-button-group6 btn-group">
<li class="wmd-button btn btn-success" id="wmd-help-button" title="Markdown syntax" style="left: 0px; display: none;"><span style="display: none; background-position: 0px 0px;"></span><i class="fa fa-question-circle"></i></li> <li class="wmd-button btn btn-success" id="wmd-help-button" title="{{msg . "Markdown syntax"}}" style="left: 0px; display: none;"><span style="display: none; background-position: 0px 0px;"></span><i class="fa fa-question-circle"></i></li>
</li> </li>
</ul> </ul>
@ -691,32 +691,6 @@ function log(o) {
</div> </div>
<!-- mdEditor --> <!-- mdEditor -->
<!-- v2 -->
<div class="modal fade modal-insert-link">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">&times;</button>
<h4 class="modal-title">Hyperlink</h4>
</div>
<div class="modal-body">
<p>Please provide the link URL and an optional title:</p>
<div class="input-group">
<span class="input-group-addon"><i class="icon-globe"></i></span><input
id="input-insert-link" type="text" class="col-sm-5 form-control"
placeholder='http://example.com/ "optional title"' />
</div>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-default" data-dismiss="modal">Cancel</a>
<a href="#" class="btn btn-primary action-insert-link"
data-dismiss="modal">OK</a>
</div>
</div>
</div>
</div>
<!-- 插入图片 --> <!-- 插入图片 -->
<div class="modal fade modal-insert-image"> <div class="modal fade modal-insert-image">
<div class="modal-dialog" style="width: 840px;max-width:100%;"> <div class="modal-dialog" style="width: 840px;max-width:100%;">
@ -724,15 +698,15 @@ function log(o) {
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" <button type="button" class="close" data-dismiss="modal"
aria-hidden="true">&times;</button> aria-hidden="true">&times;</button>
<h4 class="modal-title">Image</h4> <h4 class="modal-title">{{msg . "Image"}}</h4>
</div> </div>
<div class="modal-body" style="padding-top: 0; padding-bottom: 0"> <div class="modal-body" style="padding-top: 0; padding-bottom: 0">
<iframe name="mdImageManager" style="width: 100%; height: 350px" scrolling="no" id="leauiIfrForMD" src="" frameborder="0"></iframe> <iframe name="mdImageManager" style="width: 100%; height: 350px" scrolling="no" id="leauiIfrForMD" src="" frameborder="0"></iframe>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<a href="#" class="btn btn-default" <a href="#" class="btn btn-default"
data-dismiss="modal">Cancel</a> <a href="#" data-dismiss="modal">{{msg . "Cancel"}}</a> <a href="#"
class="btn btn-primary action-insert-image" data-dismiss="modal">Insert Image</a> class="btn btn-primary action-insert-image" data-dismiss="modal">{{msg . "Insert Image"}}</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -9,7 +9,7 @@ SP=$(cd "$(dirname "$0")"; pwd)
tmp="/Users/life/Desktop/leanote_release" tmp="/Users/life/Desktop/leanote_release"
# version # version
V="v1.0.1" V="v1.1"
##================================= ##=================================
# 1. 先build 成 3个平台, 2种bit = 6种 # 1. 先build 成 3个平台, 2种bit = 6种

View File

@ -395,6 +395,64 @@ sharePwd=查看密码
cancelShare=取消分享 cancelShare=取消分享
getShareLinkAndPwd=生成该笔记的分享链接和密码 getShareLinkAndPwd=生成该笔记的分享链接和密码
# markdown editor
Hyperlink=超链接
Please provide the link URL and an optional title=请填写链接和一个可选的标题
optional title=可选标题
Ok=确认
Cancel=取消
Strong=粗体
strong text=粗体
Emphasis=斜体
emphasized text=斜体
Blockquote=引用
Code Sample=代码
enter code here=代码
Image=图片
Heading=标题
Numbered List=有序列表
Bulleted List=无序列表
List item=项目
Horizontal Rule=水平线
Markdown syntax=Markdown 语法
Undo=撤销
Redo=重做
enter image description here=图片标题
enter link description here=链接标题
Insert Image=插入
# album image
Images=图片
Upload=上传
Image URL=图片地址
Albums=相册
Default=默认
File title search=通过标题搜索
Go to upload images=去上传图片
Rename=重命名
Add=添加
Add Album=添加相册
Add Image=添加图片
Can't load this url=不能载入该图片
No Images=无图片
Click to upload images Or Drop images to here=点击上传图片或将图片拖至此
Cannot delete default album=不能删除默认相册
Cannot rename default album=不能重命名默认相册
This album has images, please delete it's images at first.=相册内有图片, 不能删除
Rename Album=重命名
Add Success!=添加成功!
Rename Success!=重命名成功!
Delete Success!=删除成功
Are you sure to delete this image ?=确定删除该图片?
click to remove this image=删除图片
error=错误
Error=错误
Prev=上一页
Next=下一页
# 必须要加这个, 奇怪 # 必须要加这个, 奇怪
[CN] [CN]

190
public/dist/main.js vendored
View File

@ -36974,42 +36974,41 @@ define('editor',[
}; };
var defaultsStrings = { var defaultsStrings = {
bold: "Strong <strong> Ctrl/Cmd+B", bold: getMsg("Strong") + ' <strong> Ctrl/Cmd+B',
boldexample: "strong text", boldexample: getMsg("strong text"),
italic: "Emphasis <em> Ctrl/Cmd+I", italic: getMsg("Emphasis") + ' <em> Ctrl/Cmd+I',
italicexample: "emphasized text", italicexample: getMsg("emphasized text"),
link: "Hyperlink <a> Ctrl/Cmd+L", link: getMsg("Hyperlink") + ' <a> Ctrl/Cmd+L',
linkdescription: "enter link description here", linkdescription: getMsg("enter link description here"),
linkdialog: "<p><b>Insert Hyperlink</b></p><p>http://example.com/ \"optional title\"</p>", linkdialog: "<p><b>Insert Hyperlink</b></p><p>http://example.com/ \"optional title\"</p>",
quote: "Blockquote <blockquote> Ctrl/Cmd+Q", quote: getMsg("Blockquote") + ' <blockquote> Ctrl/Cmd+Q',
quoteexample: "Blockquote", quoteexample: getMsg("Blockquote"),
code: "Code Sample <pre><code> Ctrl/Cmd+K", code: getMsg("Code Sample") + ' <pre><code> Ctrl/Cmd+K',
codeexample: "enter code here", codeexample: getMsg("enter code here"),
image: "Image <img> Ctrl/Cmd+G", image: getMsg("Image") + '<img> Ctrl/Cmd+G',
imagedescription: "enter image description here", imagedescription: getMsg("enter image description here"),
imagedialog: "<p><b>Insert Image</b></p><p>http://example.com/images/diagram.jpg \"optional title\"<br><br>Need <a href='http://www.google.com/search?q=free+image+hosting' target='_blank'>free image hosting?</a></p>", imagedialog: "<p><b>Insert Image</b></p><p>http://example.com/images/diagram.jpg \"optional title\"<br><br>Need <a href='http://www.google.com/search?q=free+image+hosting' target='_blank'>free image hosting?</a></p>",
olist: "Numbered List <ol> Ctrl/Cmd+O", olist: getMsg("Numbered List") +' <ol> Ctrl/Cmd+O',
ulist: "Bulleted List <ul> Ctrl/Cmd+U", ulist: getMsg("Bulleted List") +' <ul> Ctrl/Cmd+U',
litem: "List item", litem: getMsg("List item"),
heading: "Heading <h1>/<h2> Ctrl/Cmd+H", heading: getMsg("Heading") + ' <h1>/<h2> Ctrl/Cmd+H',
headingexample: "Heading", headingexample: getMsg("Heading"),
hr: "Horizontal Rule <hr> Ctrl/Cmd+R", hr: getMsg("Horizontal Rule") + ' <hr> Ctrl/Cmd+R',
undo: "Undo - Ctrl/Cmd+Z", undo: getMsg("Undo") + ' - Ctrl/Cmd+Z',
redo: "Redo - Ctrl/Cmd+Y", redo: getMsg("Redo") + ' - Ctrl/Cmd+Y',
help: "Markdown Editing Help" help: "Markdown Editing Help"
}; };
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// YOUR CHANGES GO HERE // YOUR CHANGES GO HERE
// //
@ -38312,7 +38311,8 @@ define('editor',[
// life 新添加函数 // life 新添加函数
// life // life
function insertLinkLife(link, text) { // isImage 2015/3/1
function insertLinkLife(link, text, isImage) {
inputBox.focus(); inputBox.focus();
if (undoManager) { if (undoManager) {
undoManager.setCommandMode(); undoManager.setCommandMode();
@ -38336,7 +38336,7 @@ define('editor',[
previewManager.refresh(); previewManager.refresh();
}; };
var a = commandProto.insertLink(chunks, fixupInputArea, link, text); var a = commandProto.insertLink(chunks, fixupInputArea, link, text, isImage);
if(!a) fixupInputArea(); if(!a) fixupInputArea();
} }
@ -38734,9 +38734,8 @@ define('editor',[
}); });
} }
// life 添加 // life 添加
commandProto.insertLink = function (chunk, postProcessing, link, text) { commandProto.insertLink = function (chunk, postProcessing, link, text, isImage) {
isImage = false;
chunk.trimWhitespace(); chunk.trimWhitespace();
chunk.findTags(/\s*!?\[/, /\][ ]?(?:\n[ ]*)?(\[.*?\])?/); chunk.findTags(/\s*!?\[/, /\][ ]?(?:\n[ ]*)?(\[.*?\])?/);
var background; var background;
@ -38746,7 +38745,6 @@ define('editor',[
chunk.startTag = chunk.startTag.replace(/!?\[/, ""); chunk.startTag = chunk.startTag.replace(/!?\[/, "");
chunk.endTag = ""; chunk.endTag = "";
this.addLinkDef(chunk, null); this.addLinkDef(chunk, null);
} }
else { else {
@ -38814,8 +38812,7 @@ define('editor',[
var that = this; var that = this;
// The function to be executed when you enter a link and press OK or Cancel. // The function to be executed when you enter a link and press OK or Cancel.
// Marks up the link and adds the ref. // Marks up the link and adds the ref.
var linkEnteredCallback = function (link) { var linkEnteredCallback = function (link, text) {
background.parentNode.removeChild(background); background.parentNode.removeChild(background);
if (link !== null) { if (link !== null) {
@ -38845,16 +38842,21 @@ define('editor',[
var num = that.addLinkDef(chunk, linkDef); var num = that.addLinkDef(chunk, linkDef);
*/ */
chunk.startTag = isImage ? "![" : "["; chunk.startTag = isImage ? "![" : "[";
//chunk.endTag = "][" + num + "]"; // chunk.endTag = "][" + num + "]";
chunk.endTag = "](" + properlyEncoded(link) + ")"; chunk.endTag = "](" + properlyEncoded(link) + ")";
if (!chunk.selection) { if (!chunk.selection) {
if (isImage) { var str = '';
chunk.selection = that.getString("imagedescription"); if (text) {
str = text;
} else if (isImage) {
str = that.getString("imagedescription");
} }
else { else {
chunk.selection = that.getString("linkdescription"); str = that.getString("linkdescription");
} }
chunk.selection = str;
} }
} }
postProcessing(); postProcessing();
@ -39064,6 +39066,7 @@ define('editor',[
} }
}; };
// 这里, 应该用 ``` ```
commandProto.doCode = function (chunk, postProcessing) { commandProto.doCode = function (chunk, postProcessing) {
var hasTextBefore = /\S[ ]*$/.test(chunk.before); var hasTextBefore = /\S[ ]*$/.test(chunk.before);
@ -39232,8 +39235,9 @@ define('editor',[
}; };
// 要改成 ## ### ####
// life 2015/7/12
commandProto.doHeading = function (chunk, postProcessing) { commandProto.doHeading = function (chunk, postProcessing) {
// Remove leading/trailing whitespace and reduce internal spaces to single spaces. // Remove leading/trailing whitespace and reduce internal spaces to single spaces.
chunk.selection = chunk.selection.replace(/\s+/g, " "); chunk.selection = chunk.selection.replace(/\s+/g, " ");
chunk.selection = chunk.selection.replace(/(^\s+|\s+$)/g, ""); chunk.selection = chunk.selection.replace(/(^\s+|\s+$)/g, "");
@ -39241,63 +39245,58 @@ define('editor',[
// If we clicked the button with no selected text, we just // If we clicked the button with no selected text, we just
// make a level 2 hash header around some default text. // make a level 2 hash header around some default text.
if (!chunk.selection) { if (!chunk.selection) {
chunk.startTag = "## "; // 需要skip的时候 life
if(chunk.before && (chunk.before[chunk.before.length - 1] != "\n")) {
chunk.skipLines(1, 1);
}
chunk.startTag = "# ";
chunk.selection = this.getString("headingexample"); chunk.selection = this.getString("headingexample");
chunk.endTag = " ##"; chunk.endTag = ""; // ##
return; return;
} }
var headerLevel = 0; // The existing header level of the selected text.
// Remove any existing hash heading markdown and save the header level.
chunk.findTags(/#+[ ]*/, /[ ]*#+/); chunk.findTags(/#+[ ]*/, /[ ]*#+/);
if (/#+/.test(chunk.startTag)) { // console.log(chunk);
headerLevel = re.lastMatch.length;
}
chunk.startTag = chunk.endTag = "";
// Try to get the current header level by looking for - and = in the line if(chunk.before && (chunk.before[chunk.before.length - 1] != "\n")) {
// below the selection. chunk.skipLines(1, 1);
chunk.findTags(null, /\s?(-+|=+)/);
if (/=+/.test(chunk.endTag)) {
headerLevel = 1;
}
if (/-+/.test(chunk.endTag)) {
headerLevel = 2;
} }
// Skip to the next line so we can create the header markdown. var beforeHLevel = 0;
chunk.startTag = chunk.endTag = ""; var startTag = chunk.startTag;
chunk.skipLines(1, 1); if (/^#+[ ]*$/.test(startTag)) {
startTag = startTag.replace(/ /g, '');
beforeHLevel = startTag.length;
}
// We make a level 2 header if there is no current header. // [0, 4]
// If there is a header level, we substract one from the header level. var headerLevelToCreate = 0;
// If it's already a level 1 header, it's removed. if(beforeHLevel >= 0 && beforeHLevel <= 3) {
var headerLevelToCreate = headerLevel == 0 ? 2 : headerLevel - 1; headerLevelToCreate = beforeHLevel + 1;
}
if(beforeHLevel >= 4) {
headerLevelToCreate = 0;
chunk.startTag = '';
}
if (headerLevelToCreate > 0) { if (headerLevelToCreate > 0) {
var header = "";
while (headerLevelToCreate--) {
header += "#";
}
header += " ";
// The button only creates level 1 and 2 underline headers. chunk.startTag = header;
// Why not have it iterate over hash header levels? Wouldn't that be easier and cleaner?
var headerChar = headerLevelToCreate >= 2 ? "-" : "=";
var len = chunk.selection.length;
if (len > SETTINGS.lineLength) {
len = SETTINGS.lineLength;
}
chunk.endTag = "\n";
while (len--) {
chunk.endTag += headerChar;
}
} }
return;
}; };
commandProto.doHorizontalRule = function (chunk, postProcessing) { commandProto.doHorizontalRule = function (chunk, postProcessing) {
chunk.startTag = "----------\n"; chunk.startTag = "----------\n";
chunk.selection = ""; chunk.selection = "";
chunk.skipLines(2, 1, true); chunk.skipLines(1, 1, true);
} }
})(); })();
define("pagedown", function(){}); define("pagedown", function(){});
@ -39336,12 +39335,21 @@ define('core',[
} }
} }
// Load settings in settings dialog
// var $themeInputElt;
// Create the PageDown editor // Create the PageDown editor
var pagedownEditor; var pagedownEditor;
var fileDesc; var fileDesc;
var insertLinkO = $('<div class="modal fade modal-insert-link"><div class="modal-dialog"><div class="modal-content">'
+ '<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>'
+ '<h4 class="modal-title">' + getMsg('Hyperlink') + '</h4></div>'
+ '<div class="modal-body"><p>' + getMsg('Please provide the link URL and an optional title') + ':</p>'
+ '<div class="input-group"><span class="input-group-addon"><i class="fa fa-link"></i></span><input id="input-insert-link" type="text" class="col-sm-5 form-control" placeholder="http://example.com ' + getMsg('optional title') + '"></div></div><div class="modal-footer"><a href="#" class="btn btn-default" data-dismiss="modal">' + getMsg('Cancel') + '</a> <a href="#" class="btn btn-primary action-insert-link" data-dismiss="modal">' + getMsg('OK') + '</a></div></div></div></div>');
var actionInsertLinkO = insertLinkO.find('.action-insert-link');
// Load settings in settings dialog
// var $themeInputElt;
core.initEditorFirst = function() { core.initEditorFirst = function() {
// Create the converter and the editor // Create the converter and the editor
var converter = new Markdown.Converter(); var converter = new Markdown.Converter();
@ -39370,7 +39378,7 @@ define('core',[
pagedownEditor.hooks.set("insertLinkDialog", function(callback) { pagedownEditor.hooks.set("insertLinkDialog", function(callback) {
core.insertLinkCallback = callback; core.insertLinkCallback = callback;
utils.resetModalInputs(); utils.resetModalInputs();
$(".modal-insert-link").modal(); insertLinkO.modal();
return true; return true;
}); });
// Custom insert image dialog // Custom insert image dialog
@ -39382,7 +39390,7 @@ define('core',[
utils.resetModalInputs(); utils.resetModalInputs();
var ifr = $("#leauiIfrForMD"); var ifr = $("#leauiIfrForMD");
if(!ifr.attr('src')) { if(!ifr.attr('src')) {
ifr.attr('src', '/tinymce/plugins/leaui_image/index.html?md=1'); ifr.attr('src', '/album/index?md=1');
} }
$(".modal-insert-image").modal(); $(".modal-insert-image").modal();
@ -39489,17 +39497,33 @@ define('core',[
}); });
// Click events on "insert link" and "insert image" dialog buttons // Click events on "insert link" and "insert image" dialog buttons
$(".action-insert-link").click(function(e) { actionInsertLinkO.click(function(e) {
var value = utils.getInputTextValue($("#input-insert-link"), e); var value = utils.getInputTextValue($("#input-insert-link"), e);
if(value !== undefined) { if(value !== undefined) {
core.insertLinkCallback(value); var arr = value.split(' ');
var text = '';
var link = arr[0];
if (arr.length > 1) {
arr.shift();
text = $.trim(arr.join(' '));
}
core.insertLinkCallback(link, text);
core.insertLinkCallback = undefined; core.insertLinkCallback = undefined;
} }
}); });
// 插入图片 // 插入图片
$(".action-insert-image").click(function() { $(".action-insert-image").click(function() {
// 得到图片链接或图片 // 得到图片链接或图片
var value = document.mdImageManager.mdGetImgSrc(); /*
https://github.com/leanote/leanote/issues/171
同遇到了网页编辑markdown时不能添加图片的问题
可以上传图片但是按下插入图片按钮之后编辑器中没有加入![...](...)
我的控制台有这样的错误 TypeError: document.mdImageManager is undefined
*/
// mdImageManager是iframe的name, mdGetImgSrc是iframe内的全局方法
// var value = document.mdImageManager.mdGetImgSrc();
var value = document.getElementById('leauiIfrForMD').contentWindow.mdGetImgSrc();
// var value = utils.getInputTextValue($("#input-insert-image"), e); // var value = utils.getInputTextValue($("#input-insert-image"), e);
if(value) { if(value) {
core.insertLinkCallback(value); core.insertLinkCallback(value);
@ -39508,7 +39532,7 @@ define('core',[
}); });
// Hide events on "insert link" and "insert image" dialogs // Hide events on "insert link" and "insert image" dialogs
$(".modal-insert-link, .modal-insert-image").on('hidden.bs.modal', function() { insertLinkO.on('hidden.bs.modal', function() {
if(core.insertLinkCallback !== undefined) { if(core.insertLinkCallback !== undefined) {
core.insertLinkCallback(null); core.insertLinkCallback(null);
core.insertLinkCallback = undefined; core.insertLinkCallback = undefined;
@ -39522,7 +39546,7 @@ define('core',[
// 弹框显示markdown语法 // 弹框显示markdown语法
$('#wmd-help-button').click(function() { $('#wmd-help-button').click(function() {
window.open("http://leanote.com/blog/view/531b263bdfeb2c0ea9000002"); window.open("http://leanote.com/blog/post/531b263bdfeb2c0ea9000002");
}); });
// Load images // Load images
@ -40608,6 +40632,10 @@ if(window.baseDir.indexOf('-min') !== -1) {
} }
*/ */
window.getMsg || (getMsg = function(msg) {
return msg;
});
// RequireJS entry point. By requiring synchronizer, publisher, sharing and // RequireJS entry point. By requiring synchronizer, publisher, sharing and
// media-importer, we are actually loading all the modules // media-importer, we are actually loading all the modules
require([ require([

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -640,11 +640,8 @@ a.list-group-item:focus {
-webkit-transition: background-color ease-in-out .15s, color ease-in-out .15s, border-color ease-in-out .15s; -webkit-transition: background-color ease-in-out .15s, color ease-in-out .15s, border-color ease-in-out .15s;
transition: background-color ease-in-out .15s, color ease-in-out .15s, border-color ease-in-out .15s; transition: background-color ease-in-out .15s, color ease-in-out .15s, border-color ease-in-out .15s;
} }
.btn-default:hover,
.alertify-button-cancel:hover, .alertify-button-cancel:hover,
.btn-default:focus,
.alertify-button-cancel:focus, .alertify-button-cancel:focus,
.btn-default:active,
.alertify-button-cancel:active, .alertify-button-cancel:active,
.open .btn-default.dropdown-toggle, .open .btn-default.dropdown-toggle,
.open .alertify-button-cancel.dropdown-toggle { .open .alertify-button-cancel.dropdown-toggle {
@ -652,29 +649,20 @@ a.list-group-item:focus {
border-color: rgba(128, 128, 128, 0.1); border-color: rgba(128, 128, 128, 0.1);
background-color: rgba(128, 128, 128, 0.04) !important; background-color: rgba(128, 128, 128, 0.04) !important;
} }
.btn-primary:hover,
.alertify-button-ok:hover, .alertify-button-ok:hover,
.btn-primary:focus,
.alertify-button-ok:focus, .alertify-button-ok:focus,
.btn-primary:active, .btn-primary:active,
.alertify-button-ok:active,
.open .btn-primary.dropdown-toggle, .open .btn-primary.dropdown-toggle,
.open .alertify-button-ok.dropdown-toggle { .open .alertify-button-ok.dropdown-toggle {
color: #343434; color: #343434;
border-color: rgba(128, 128, 128, 0.1); border-color: rgba(128, 128, 128, 0.1);
background-color: #e3e3e3 !important; background-color: #e3e3e3 !important;
} }
.btn-success:hover,
.btn-success:focus,
.btn-success:active,
.open .btn-success.dropdown-toggle { .open .btn-success.dropdown-toggle {
color: #343434 !important; color: #343434 !important;
border-color: rgba(128, 128, 128, 0.1); border-color: rgba(128, 128, 128, 0.1);
background-color: rgba(128, 128, 128, 0.05) !important; background-color: rgba(128, 128, 128, 0.05) !important;
} }
.btn-info:hover,
.btn-info:focus,
.btn-info:active,
.btn-info.info-tooltip, .btn-info.info-tooltip,
.info-tooltip .btn-info, .info-tooltip .btn-info,
.open .btn-info.dropdown-toggle { .open .btn-info.dropdown-toggle {