tinymce 优化

This commit is contained in:
life
2015-09-24 10:44:53 +08:00
parent 9a9bdad038
commit d7e403b69e
14 changed files with 46610 additions and 22 deletions

View File

@@ -656,6 +656,7 @@ window.requireNode = window.require;
window.nodeRequire = window.require;
window.require = undefined;
</script>
<!-- 渲染view -->
<script src="public/tinymce/tinymce.js"></script>
<script src="public/libs/ace/ace.js"></script>
@@ -669,12 +670,6 @@ window.require = undefined;
<script src="public/js/app/share.js"></script>
<script src="public/js/object_id.js"></script>
<!-- plugin js start -->
<!-- default plugin -->
<!-- theme -->
<!-- <script src="public/plugins/theme/plugin.js"></script> -->
<!-- plugin js end -->
<!-- 使用require js -->
<script src="public/js/require.js"></script>

Binary file not shown.

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Binary file not shown.

View File

@@ -457,7 +457,7 @@ function initEditor() {
"table directionality textcolor" ], // nonbreaking
toolbar1 : "formatselect | forecolor backcolor | bold italic underline strikethrough | image | leanote_code leanote_inline_code | bullist numlist | alignleft aligncenter alignright alignjustify",
toolbar2 : "outdent indent blockquote | link unlink | table | hr removeformat | subscript superscript |searchreplace | pastetext pasteCopyImage | leanote_ace_pre | fontselect fontsizeselect",
toolbar2 : "outdent indent blockquote | link unlink | table | hr removeformat | subscript superscript |searchreplace | pastetext | leanote_ace_pre | fontselect fontsizeselect",
// 使用tab键: http://www.tinymce.com/wiki.php/Plugin3x:nonbreaking
// http://stackoverflow.com/questions/13543220/tiny-mce-how-to-allow-people-to-indent

View File

@@ -26,19 +26,46 @@
src: local('Open Sans Italic'), local('OpenSans-Italic'), url('../fonts/open-sans2/xjAJXh38I15wypJXxuGMBobN6UDyHWBl620a-IRfuBk.woff') format('woff');
}
/* leanote */
@font-face {
font-family: 'leanoteregular';
src: url('../fonts/leanote/leanote-regular-webfont.eot');
src: url('../fonts/leanote/leanote-regular-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/leanote/leanote-regular-webfont.woff') format('woff'),
url('../fonts/leanote/leanote-regular-webfont.ttf') format('truetype'),
url('../fonts/leanote/leanote-regular-webfont.svg#leanoteregular') format('svg');
font-family: 'leanote';
src:url('../fonts/leanote-font2/leanote.eot?-vcf23i');
src:url('../fonts/leanote-font2/leanote.eot?#iefix-vcf23i') format('embedded-opentype'),
url('../fonts/leanote-font2/leanote.ttf?-vcf23i') format('truetype'),
url('../fonts/leanote-font2/leanote.woff?-vcf23i') format('woff'),
url('../fonts/leanote-font2/leanote.svg?-vcf23i#leanote') format('svg');
font-weight: normal;
font-style: normal;
}
html,body {
// 字体
#logo,
#switcher span,
.mce-i-mind,
.mce-i-ace-pre,
.lea-icon
{
font-family: 'leanote' !important;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-markdown:before {
content: "\e604";
}
.mce-i-mind:before {
content: "\e602";
}
.mce-i-ace-pre:before {
content: "\e603";
}
#pageInner {
position: absolute;
left: 0;

View File

@@ -22,14 +22,37 @@
font-weight: 400;
src: local('Open Sans Italic'), local('OpenSans-Italic'), url('../fonts/open-sans2/xjAJXh38I15wypJXxuGMBobN6UDyHWBl620a-IRfuBk.woff') format('woff');
}
/* leanote */
@font-face {
font-family: 'leanoteregular';
src: url('../fonts/leanote/leanote-regular-webfont.eot');
src: url('../fonts/leanote/leanote-regular-webfont.eot?#iefix') format('embedded-opentype'), url('../fonts/leanote/leanote-regular-webfont.woff') format('woff'), url('../fonts/leanote/leanote-regular-webfont.ttf') format('truetype'), url('../fonts/leanote/leanote-regular-webfont.svg#leanoteregular') format('svg');
font-family: 'leanote';
src: url('../fonts/leanote-font2/leanote.eot?-vcf23i');
src: url('../fonts/leanote-font2/leanote.eot?#iefix-vcf23i') format('embedded-opentype'), url('../fonts/leanote-font2/leanote.ttf?-vcf23i') format('truetype'), url('../fonts/leanote-font2/leanote.woff?-vcf23i') format('woff'), url('../fonts/leanote-font2/leanote.svg?-vcf23i#leanote') format('svg');
font-weight: normal;
font-style: normal;
}
#logo,
#switcher span,
.mce-i-mind,
.mce-i-ace-pre,
.lea-icon {
font-family: 'leanote' !important;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-markdown:before {
content: "\e604";
}
.mce-i-mind:before {
content: "\e602";
}
.mce-i-ace-pre:before {
content: "\e603";
}
#pageInner {
position: absolute;
left: 0;

View File

@@ -69,6 +69,8 @@ tinymce.addI18n('en',{
"Encoding": "Encoding",
"Description": "Description",
"Author": "Author",
"codeLang": "Language",
"toggleCode": "`ctrl+shift+c` toggle code",
"Fullscreen": "Full-screen",
"Horizontal line": "Horizontal line",
"Horizontal space": "Horizontal space",

View File

@@ -37,6 +37,8 @@ tinymce.addI18n('zh',{
"Decrease indent": "\u51cf\u5c11\u7f29\u8fdb",
"Header 4": "\u6807\u98984",
"Convert Code": "转换成文本",
"codeLang": "代码语言",
"toggleCode": "ctrl+shift+c 切换代码",
"Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.": "\u5f53\u524d\u4e3a\u7eaf\u6587\u672c\u7c98\u8d34\u6a21\u5f0f\uff0c\u518d\u6b21\u70b9\u51fb\u53ef\u4ee5\u56de\u5230\u666e\u901a\u7c98\u8d34\u6a21\u5f0f\u3002",
"Underline": "\u4e0b\u5212\u7ebf",
"Cancel": "\u53d6\u6d88",
@@ -74,6 +76,9 @@ tinymce.addI18n('zh',{
"Horizontal line": "\u6c34\u5e73\u5206\u5272\u7ebf",
"Horizontal space": "\u6c34\u5e73\u8fb9\u8ddd",
"Insert\/edit image": "上传/插入图片",
"Insert\/edit mind map": "新建/编辑思维导图",
"Insert Mind Map": "插入思维导图",
"Mind Map": "思维导图",
"General": "\u666e\u901a",
"Advanced": "\u9ad8\u7ea7",
"Source": "\u5730\u5740",

View File

@@ -38,6 +38,16 @@ tinymce.PluginManager.add('leanote_code', function(editor, url) {
return html.replace(/\n/g, "<br />"); // .replace(/\<br *\/*\>/gi,"\n").replace(/<\/(p|li|div|ul|ol|hr)>/, "\n").replace(/(<([^>]+)>)/gi, "");
}
// 在toggle成pre或ace时
// 最后没有元素, 或者元素不是p, 则在最后插入之
function insertPIfNotExists() {
var children = $('#editorContent').children();
var lastChild = children && children.length > 0 ? children[children.length - 1] : null;
if (!lastChild || lastChild.tagName != 'P') {
$('#editorContent').append('<p><br data-mce-bogus="1"></p>');
}
}
// brush 刷子
function toggleCode(brush) {
ed = tinymce.activeEditor;
@@ -124,6 +134,7 @@ tinymce.PluginManager.add('leanote_code', function(editor, url) {
}
}
if(pre) {
insertPIfNotExists();
/*
var rng = ed.selection.getRng();
var $pre = $(pre);
@@ -181,12 +192,15 @@ tinymce.PluginManager.add('leanote_code', function(editor, url) {
text = html2BreakLine(node);
$(node).replaceWith("<pre id='" + id + "'" + brushClasses + ">" + text + "</pre>");
}
var aceEditor = LeaAce.initAce(id);
if(aceEditor) {
aceEditor.focus();
if(brush && brush != "convert") {
aceEditor.session.setMode("ace/mode/" + brush);
}
insertPIfNotExists();
}
}
// ed.selection.moveToBookmark(everBookmark);
@@ -291,8 +305,7 @@ tinymce.PluginManager.add('leanote_code', function(editor, url) {
if(LeaAce.canAce()) {
editor.addButton('leanote_ace_pre', {
icon: 'code',
image: url + '/img/ace-pre2.png',
icon: 'ace-pre',
tooltip: 'Toggle ace with raw html',
active: LeaAce.isAce === false,
onclick: function() {

View File

@@ -1 +1 @@
tinymce.PluginManager.requireLangPack("leanote_code"),tinymce.PluginManager.add("leanote_code",function(a,b){function c(a){return a?("object"==typeof a&&(a=$(a).html()),a.replace(/\<br *\/*\>/gi,"\n").replace(/<\/(p|li|div|ul|ol|hr)>/,"\n").replace(/(<([^>]+)>)/gi,"").replace(/\n\n/g,"\n")):a}function d(a){return a?("object"==typeof a&&(a=$(a).html()),a.replace(/\n/g,"<br />")):a}function e(a){g=tinymce.activeEditor;var b,e=g.selection.getNode(),f=g.selection.getContent(),h=LeaAce.isInAce(e),i=!1,j=!1;h&&(i=h[0],j=h[1]),$("#editorContent .toggle-raw").remove();var k='class="brush:'+a+'"';if(a&&"convert"!=a){if(i&&i.session.setMode("ace/mode/"+a),j||"PRE"!=e.nodeName||(j=$(e)),j){var l=LeaAce.getPreBrush(j);return void j.removeClass(l).addClass("brush:"+a)}}else if(a&&("BODY"==e.nodeName||"editorContent"==$(e).attr("id")))return;if(LeaAce.canAce()){var m=LeaAce.getAceId();if(LeaAce.disableAddHistory(),i){var n=i.getValue();n=n.replace(/</g,"&lt;"),n=n.replace(/>/g,"&gt;"),n=n.replace(/\n/g,"<br />"),j.replaceWith("<p>"+n+"</p>"),i.destroy()}else{if("PRE"==e.nodeName){var j=$(e),n=j.html();return n&&(n=n.replace(/\n/g,"<br />")),void j.replaceWith("<p>"+n+"</p>")}var b=f;if(!b&&("BODY"==e.nodeName||"editorContent"==$(e).attr("id")))return;b?(b=c(b),g.insertContent('<pre id="'+m+'" '+k+">"+b+"</pre>")):(b=c(e),$(e).replaceWith("<pre id='"+m+"'"+k+">"+b+"</pre>"));var i=LeaAce.initAce(m);i&&(i.focus(),a&&"convert"!=a&&i.session.setMode("ace/mode/"+a))}LeaAce.resetAddHistory()}else if("PRE"!=e.nodeName&&(e=$(e).closest("pre").get(0)),e&&"PRE"==e.nodeName){var j=$(e),n=j.html();n&&(n=n.replace(/\n/g,"<br />")),j.replaceWith("<p>"+n+"</p>")}else{try{b=$.trim($(f).text())}catch(o){}b||(b=$.trim(f));var p=null,m=LeaAce.getAceId();b?(b=d(b),p='<pre id="'+m+'" '+k+">"+b+"</pre>",g.insertContent(p)):e?(b=d(e),p='<pre id="'+m+'" '+k+">"+b+"</pre>",$(e).replaceWith(p)):(p='<pre id="'+m+'" '+k+">"+b+"</pre>",g.insertContent(p))}}function f(){return function(){var b=this;a.on("nodeChange",function(){var c=null;try{var d=a.selection.getNode();if("PRE"!=d.nodeName&&(d=$(d).closest("pre").get(0)),d){var e=LeaAce.isInAce(d),f=!1,g=!1;if(e||"PRE"==d.nodeName){e?(f=e[0],g=e[1]):g=$(d);var h=LeaAce.getPreBrush(g);c=$.trim(h.split(":")[1]),b.diableValue("convert",!1)}else b.diableValue("convert",!0)}}catch(i){log(i)}"convert"!=c&&b.value(c)})}}var g=a;a.addButton("leanote_code",function(){var a=["Convert Code:convert","CSS:css","HTML:html","Javascript:javascript","C/C++:c_cpp","C#:csharp","Java:java","Objective-c:objectivec","PHP:php","Python:python","Ruby:ruby","Shell:sh","Delphi:delphi","Golang:golang","Erlang:erlang","Groovy:groovy","Latex:latex","Xml:xml","ActionScript:actionScript"],b=[];for(var c in a){var d=a[c].split(":");b.push({text:d[0],value:d[1]})}return{type:"listbox",text:"codeLang",tooltip:"toggleCode",values:b,fixedWidth:!0,onselect:function(a){a.control.settings.value&&e(a.control.settings.value)},onPostRender:f(b)}}),a.addButton("leanote_inline_code",{icon:"code",tooltip:"Inline Code",stateSelector:"code",onclick:function(){a.execCommand("mceToggleFormat",!1,"code")}}),LeaAce.canAce()&&a.addButton("leanote_ace_pre",{icon:"code",image:b+"/img/ace-pre2.png",tooltip:"Toggle ace with raw html",active:LeaAce.isAce===!1,onclick:function(){LeaAce.isAce===!1?(this.active(!1),LeaAce.isAce=!0,LeaAce.initAceFromContent(a)):(this.active(!0),LeaAce.allToPre(a),LeaAce.isAce=!1)}}),g.addCommand("toggleCode",e),g.addShortcut("ctrl+shift+c","","toggleCode"),g.addShortcut("command+shift+c","","toggleCode"),LeaAce.canAce()&&a.on("keydown",function(a){var b=LeaAce.nowIsInAce();return b?(setTimeout(function(){b[0].focus()}),!0):void 0}),g.on("keydown",function(a){var b=a.which?a.which:a.keyCode;return 9==b?(a.shiftKey||g.insertContent("&nbsp;&nbsp;&nbsp;&nbsp;"),a.preventDefault(),a.stopPropagation(),!1):void 0})});
tinymce.PluginManager.requireLangPack("leanote_code"),tinymce.PluginManager.add("leanote_code",function(a,b){function c(a){return a?("object"==typeof a&&(a=$(a).html()),a.replace(/\<br *\/*\>/gi,"\n").replace(/<\/(p|li|div|ul|ol|hr)>/,"\n").replace(/(<([^>]+)>)/gi,"").replace(/\n\n/g,"\n")):a}function d(a){return a?("object"==typeof a&&(a=$(a).html()),a.replace(/\n/g,"<br />")):a}function e(){var a=$("#editorContent").children(),b=a&&a.length>0?a[a.length-1]:null;b&&"P"==b.tagName||$("#editorContent").append('<p><br data-mce-bogus="1"></p>')}function f(a){h=tinymce.activeEditor;var b,f=h.selection.getNode(),g=h.selection.getContent(),i=LeaAce.isInAce(f),j=!1,k=!1;i&&(j=i[0],k=i[1]),$("#editorContent .toggle-raw").remove();var l='class="brush:'+a+'"';if(a&&"convert"!=a){if(j&&j.session.setMode("ace/mode/"+a),k||"PRE"!=f.nodeName||(k=$(f)),k){var m=LeaAce.getPreBrush(k);return void k.removeClass(m).addClass("brush:"+a)}}else if(a&&("BODY"==f.nodeName||"editorContent"==$(f).attr("id")))return;if(LeaAce.canAce()){var n=LeaAce.getAceId();if(LeaAce.disableAddHistory(),j){var o=j.getValue();o=o.replace(/</g,"&lt;"),o=o.replace(/>/g,"&gt;"),o=o.replace(/\n/g,"<br />"),k.replaceWith("<p>"+o+"</p>"),j.destroy()}else{if("PRE"==f.nodeName){var k=$(f),o=k.html();return o&&(o=o.replace(/\n/g,"<br />")),void k.replaceWith("<p>"+o+"</p>")}var b=g;if(!b&&("BODY"==f.nodeName||"editorContent"==$(f).attr("id")))return;b?(b=c(b),h.insertContent('<pre id="'+n+'" '+l+">"+b+"</pre>")):(b=c(f),$(f).replaceWith("<pre id='"+n+"'"+l+">"+b+"</pre>"));var j=LeaAce.initAce(n);j&&(j.focus(),a&&"convert"!=a&&j.session.setMode("ace/mode/"+a),e())}LeaAce.resetAddHistory()}else if("PRE"!=f.nodeName&&(f=$(f).closest("pre").get(0)),f&&"PRE"==f.nodeName){var k=$(f),o=k.html();o&&(o=o.replace(/\n/g,"<br />")),k.replaceWith("<p>"+o+"</p>")}else{try{b=$.trim($(g).text())}catch(p){}b||(b=$.trim(g));var q=null,n=LeaAce.getAceId();b?(b=d(b),q='<pre id="'+n+'" '+l+">"+b+"</pre>",h.insertContent(q)):f?(b=d(f),q='<pre id="'+n+'" '+l+">"+b+"</pre>",$(f).replaceWith(q)):(q='<pre id="'+n+'" '+l+">"+b+"</pre>",h.insertContent(q)),q&&e()}}function g(){return function(){var b=this;a.on("nodeChange",function(){var c=null;try{var d=a.selection.getNode();if("PRE"!=d.nodeName&&(d=$(d).closest("pre").get(0)),d){var e=LeaAce.isInAce(d),f=!1,g=!1;if(e||"PRE"==d.nodeName){e?(f=e[0],g=e[1]):g=$(d);var h=LeaAce.getPreBrush(g);c=$.trim(h.split(":")[1]),b.diableValue("convert",!1)}else b.diableValue("convert",!0)}}catch(i){log(i)}"convert"!=c&&b.value(c)})}}var h=a;a.addButton("leanote_code",function(){var a=["Convert Code:convert","CSS:css","HTML:html","Javascript:javascript","C/C++:c_cpp","C#:csharp","Java:java","Objective-c:objectivec","PHP:php","Python:python","Ruby:ruby","Shell:sh","Delphi:delphi","Golang:golang","Erlang:erlang","Groovy:groovy","Latex:latex","Xml:xml","ActionScript:actionScript"],b=[];for(var c in a){var d=a[c].split(":");b.push({text:d[0],value:d[1]})}return{type:"listbox",text:"codeLang",tooltip:"toggleCode",values:b,fixedWidth:!0,onselect:function(a){a.control.settings.value&&f(a.control.settings.value)},onPostRender:g(b)}}),a.addButton("leanote_inline_code",{icon:"code",tooltip:"Inline Code",stateSelector:"code",onclick:function(){a.execCommand("mceToggleFormat",!1,"code")}}),LeaAce.canAce()&&a.addButton("leanote_ace_pre",{icon:"ace-pre",tooltip:"Toggle ace with raw html",active:LeaAce.isAce===!1,onclick:function(){LeaAce.isAce===!1?(this.active(!1),LeaAce.isAce=!0,LeaAce.initAceFromContent(a)):(this.active(!0),LeaAce.allToPre(a),LeaAce.isAce=!1)}}),h.addCommand("toggleCode",f),h.addShortcut("ctrl+shift+c","","toggleCode"),h.addShortcut("command+shift+c","","toggleCode"),LeaAce.canAce()&&a.on("keydown",function(a){var b=LeaAce.nowIsInAce();return b?(setTimeout(function(){b[0].focus()}),!0):void 0}),h.on("keydown",function(a){var b=a.which?a.which:a.keyCode;return 9==b?(a.shiftKey||h.insertContent("&nbsp;&nbsp;&nbsp;&nbsp;"),a.preventDefault(),a.stopPropagation(),!1):void 0})});

File diff suppressed because it is too large Load Diff

15
src/public/tinymce/tinymce.full.min.js vendored Normal file

File diff suppressed because one or more lines are too long