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

Update redactor.js #95

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 49 additions & 6 deletions redactor/redactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,15 @@ var RLANG = {
autosaveCallback: false, // function
interval: 60, // seconds

imageId: 0,

imageGetJson: false, // url (ex. /folder/images.json ) or false

imageUpload: false, // url
imageUploadCallback: false, // function
imageUploadErrorCallback: false, // function

imageDeleteCallback: false, // function

fileUpload: false, // url
fileUploadCallback: false, // function
fileUploadErrorCallback: false, // function
Expand Down Expand Up @@ -284,7 +287,7 @@ var RLANG = {
'<div class="redactor_tab" id="redactor_tab1">' +
'<label>URL</label><input type="text" id="redactor_link_url" class="redactor_input" />' +
'<label>' + RLANG.text + '</label><input type="text" class="redactor_input redactor_link_text" id="redactor_link_url_text" />' +
'<label><input type="checkbox" id="redactor_link_blank"> ' + RLANG.link_new_tab + '</label>' +
'<label><input type="checkbox" id="redactor_link_blank" checked="checked"> ' + RLANG.link_new_tab + '</label>' +
'</div>' +
'<div class="redactor_tab" id="redactor_tab2" style="display: none;">' +
'<label>Email</label><input type="text" id="redactor_link_mailto" class="redactor_input" />' +
Expand Down Expand Up @@ -834,6 +837,35 @@ var RLANG = {
// if empty
if (key === 8 || key === 46)
{
function compareHtml(beforeHtml, afterHtml)
{
var diff='"tag":"';
var j=0;
var openQuate = false;
for(var i=0;i<beforeHtml.length;i++)
{
if(beforeHtml[i]!=afterHtml[j])
{
if(beforeHtml[i]==' ' && !openQuate)
diff += '","';
else if(beforeHtml[i]=='=')
diff += '":"'
else if(beforeHtml[i]=='>')
break;
else if (beforeHtml[i]=='"')
openQuate = !openQuate;
else
diff += beforeHtml[i];

}
else
j++;
}
return '{'+diff+'"}';
}
var delJSON = JSON.parse(compareHtml(this.beforeHtml, this.$editor.html()));
if(delJSON.tag == 'img')
this.opts.imageDeleteCallback(delJSON);
this.observeImages();
return this.formatEmpty(e);
}
Expand Down Expand Up @@ -926,6 +958,12 @@ var RLANG = {
}
}

// backspace and delete
if (key === 8 || key === 46)
{
this.beforeHtml = this.$editor.html();
}

// clear undo buffer
if (!ctrl && key !== 90)
{
Expand Down Expand Up @@ -1615,8 +1653,7 @@ var RLANG = {
html = html.replace(/<br>/i, '');
}

var thtml = html.replace(/<(?:.|\n)*?>/gm, '');

var thtml = html.replace('/<p>*</p>/gm>','');
if (html === '' || thtml === '')
{
e.preventDefault();
Expand Down Expand Up @@ -3103,6 +3140,10 @@ var RLANG = {
},
imageDelete: function(el)
{
var json = [];
json['id'] = $(el).attr('id');
json['src'] = $(el).attr('src');
this.opts.imageDeleteCallback(json);
$(el).remove();
this.modalClose();
this.syncCode();
Expand Down Expand Up @@ -3325,7 +3366,9 @@ var RLANG = {
var html = '';
if (link !== true)
{
html = '<p><img src="' + json.filelink + '" /></p>';
++this.opts.imageId;
html = '<p><img id=redImage'+(this.opts.imageId)+' class=redImage src="' + json.filelink + '" /></p>';
json.id='redImage'+this.opts.imageId;
}
else
{
Expand Down Expand Up @@ -4207,4 +4250,4 @@ var RLANG = {
* updated: Imperavi Inc.
*
*/
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(5($){$.1.4.7={t:5(0,v){$(2).0("8",c);$(2).0("r",0);$(2).l(\'g\',$.1.4.7.b)},u:5(0){$(2).w(\'g\',$.1.4.7.b)},b:5(1){9 0=$(2).0("r");9 3=$.1.4.7.f(0).h();6(3!=\'\'){$(2).0("8",x);1.j="7";1.3=3;$.1.i.m(2,k)}},f:5(0){9 3=\'\';6(q.e){3=q.e()}o 6(d.e){3=d.e()}o 6(d.p){3=d.p.B().3}A 3}};$.1.4.a={t:5(0,v){$(2).0("n",0);$(2).0("8",c);$(2).l(\'g\',$.1.4.a.b);$(2).l(\'D\',$.1.4.a.s)},u:5(0){$(2).w(\'g\',$.1.4.a.b)},b:5(1){6($(2).0("8")){9 0=$(2).0("n");9 3=$.1.4.7.f(0).h();6(3==\'\'){$(2).0("8",c);1.j="a";$.1.i.m(2,k)}}},s:5(1){6($(2).0("8")){9 0=$(2).0("n");9 3=$.1.4.7.f(0).h();6((1.y=z)&&(3==\'\')){$(2).0("8",c);1.j="a";$.1.i.m(2,k)}}}}})(C);',40,40,'data|event|this|text|special|function|if|textselect|textselected|var|textunselect|handler|false|rdocument|getSelection|getSelectedText|mouseup|toString|handle|type|arguments|bind|apply|rttt|else|selection|rwindow|ttt|handlerKey|setup|teardown|namespaces|unbind|true|keyCode|27|return|createRange|jQuery|keyup'.split('|'),0,{}))
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(5($){$.1.4.7={t:5(0,v){$(2).0("8",c);$(2).0("r",0);$(2).l(\'g\',$.1.4.7.b)},u:5(0){$(2).w(\'g\',$.1.4.7.b)},b:5(1){9 0=$(2).0("r");9 3=$.1.4.7.f(0).h();6(3!=\'\'){$(2).0("8",x);1.j="7";1.3=3;$.1.i.m(2,k)}},f:5(0){9 3=\'\';6(q.e){3=q.e()}o 6(d.e){3=d.e()}o 6(d.p){3=d.p.B().3}A 3}};$.1.4.a={t:5(0,v){$(2).0("n",0);$(2).0("8",c);$(2).l(\'g\',$.1.4.a.b);$(2).l(\'D\',$.1.4.a.s)},u:5(0){$(2).w(\'g\',$.1.4.a.b)},b:5(1){6($(2).0("8")){9 0=$(2).0("n");9 3=$.1.4.7.f(0).h();6(3==\'\'){$(2).0("8",c);1.j="a";$.1.i.m(2,k)}}},s:5(1){6($(2).0("8")){9 0=$(2).0("n");9 3=$.1.4.7.f(0).h();6((1.y=z)&&(3==\'\')){$(2).0("8",c);1.j="a";$.1.i.m(2,k)}}}}})(C);',40,40,'data|event|this|text|special|function|if|textselect|textselected|var|textunselect|handler|false|rdocument|getSelection|getSelectedText|mouseup|toString|handle|type|arguments|bind|apply|rttt|else|selection|rwindow|ttt|handlerKey|setup|teardown|namespaces|unbind|true|keyCode|27|return|createRange|jQuery|keyup'.split('|'),0,{}))