PDA

View Full Version : BB Code Enhancements - Editor BBcode Tags to embed EditArea code editor in posts


nerbert
05-31-2013, 10:00 PM
Editor Tags allow you to embed EditArea (http://www.cdolivet.com/editarea/editarea/docs/about.html) code editor in posts as an editable alternative to , [html] and [php] tags

This product is no longer supported. See https://vborg.vbsupport.ru/showthread.php?p=2457960#post2457960

New Version 1.1 (see below for installation)

Use tags to display, edit and store code in posts. You can edit code and save it in the database without editing the post, just click the Save button at the bottom of the editor.

The EditArea code editor displays formatted highlighted code and has the usual features of code editors. It's the editor used in cPanel. Features include search and replace, go to line, undo/redo, syntax and font size selection, highlight toggling, word-wrap toggling and full screen toggling.

https://vborg.vbsupport.ru/attachment.php?attachmentid=145278&d=1370454679

Features


Control panel in Settings > Options > BB Code Settings


Enable/Disable allows you to turn Editor Tags off without deleting the BB Code. When Editor Tags are disabled, code posted in Editor Tags will show in a pre element much like a Code Tag display.


By default, editing permission is the same as editing for the post. You can disable editing globally in the control panel.


Edited code can be saved without editing the post. A Save button saves the EditArea contents to the database with AJAX.


Default height of the editor can be set in the control panel.


[New] Resizable in all browsers.


[New] Works with or without Quick Edit enabled



Installation


Go to sourceforge (http://sourceforge.net/projects/editarea/) to download the EditArea product. Upload the unzipped editarea_0_8_2 folder to the clientscript folder.

Note: The easy way to upload large packages is to first create an "upload_zips" folder in your forum root, then upload the zipped file there. Then unzip the file and by default the new folder will be in the upload_zips folder. You can then move or copy it to clientscript.


Import the product file in Admin CP.


Upload the button image to the images/editor folder


Create the BB Code in the Custom BB Codes feature

Title: Editor Tags

BB Code Tag Name: editor

Replacement: [code]<div id="editor_" style="margin:16px 0px;">
<div id="mask_" style="z-index:2;position:relative;background:blue;opacity: 0.0;filter:Alpha(opacity=0);display:none;"></div>
<pre id="pre_" class="editortags">{param}</pre>
<textarea id="t_" readonly="" class="editortags">{param}</textarea>
<div id="saveDiv_" class="save">
<span id="progress_" style="visibility:hidden;"><img src="images/misc/progress.gif" style="margin:0px 0px -4px -16px;" alt=""></span>
<input id="save_" class="button" style="margin:2px;display:none" type="button" value="Save" onclick="vB_QuickEditor.preSave(this.parentNode.parentNode)" />
<div id="error_" style="display:none;"></div>
<img id="img_" style="float:right;margin:3px 1px -4px;" alt="" />
<input id="resize_" type="button" style="background:white;opacity:0.0;filter:Alpha(opacity= 0); border:none;height:22px;width:13px;float:right;mar gin:1px -13px -2px 0px;">
<input id="clear_" type="button" class="button" style="display:none;float:right;" value="Clear" onclick="vB_QuickEditor.clearError(this)" />
</div>
<iframe frameborder="0" style="display:none;" onload="if(typeof build != 'undefined') build(this)"></iframe>
</div>

Example: [editor] ..... CODE .....

Description: Puts the EditArea code editor in posts

Use {option} No

Button Image: images/editor/editor.png

Remove Tag If Empty No

Disable BB Code Within This BB Code Yes

Disable Smilies Within This BB Code Yes

Disable Word Wrapping Within This BB Code Yes

Disable Automatic Link Parsing Within This BB Code Yes


To install the new version 1.1, uninstall the old version, upload the new product file and change the Replacement code in the bbcode setting. Everything else stays the same.




Notes



Browser compatibility: This has been tested in Chrome, Firefox, Opera and some versions of IE. EditArea will not work well with Opera; the code displays properly but the tab key will not indent the code. There are some problems with IE8 throwing errors, this can be avoided by not placing more than one editor in a single post.


The product creates two new templates, bbcode_editor_script, which goes in the <head>, and editortags.css.


If you already have EditArea on your server from this product, EditArea Code Editor for Templates & Plugins in Admin CP (https://vborg.vbsupport.ru/showthread.php?t=288362&highlight=editarea), you can use it by changing the path in the <script> tag in bbcode_editor_script template.



Changes


June 2 2013 Eliminated the progess image to theleft of the Save button. It was causing problems in vB4.2.1. Fixed minor problem with display in IE.
Upload the new product file and overwrite the old one. Change the Replacement code above in the BBcode manager


June 5 2013 Released new version 1.1. I eliminated the alternative height setting in the admin CP as the editor is now resizable in all browsers.

nerbert
06-01-2013, 07:45 AM
Reserved

Muhammad Rahman
06-01-2013, 10:49 PM
I've tried ...
but, when the save code is missing ..

nerbert
06-02-2013, 12:48 AM
What browser are you using?

What version of vBulletin do you have?

When you clicked the button did you see a little progress image to the left? (dots go round and round)

Muhammad Rahman
06-02-2013, 03:28 AM
Firefox 21.,
vBulletin 4.2.1.,
No.,
:D

nerbert
06-02-2013, 04:13 AM
This correction applies to the original file. If you have uploaded the latest file and followed the instructions in the OP ignore this post.


I thought that might be the problem. They changed the location of the little progress image.

Open up the bbcode_editortags_script template and in the lower part modify as shown:


if(typeof vB_AJAX_QuickEditor != 'undefined') {
vB_AJAX_QuickEditor.prototype.preSave=function(pos tid,timeid){
this.postid = postid;
this.timeid = timeid;
this.progress = fetch_object('progress_' + this.postid)
this.progress.style.visibility = 'visible';
var postText = fetch_object('post_message_' + postid).innerHTML;
var matches = postText.match(/id="?editor_[\d]{13}"?/gi);
for(var i = 0; i < matches.length; i++) {
if(matches[i].indexOf(timeid) != -1) break;
}
var index = i;
tid = 't_' + timeid
vB_QuickEditor.saveCode(postid,tid,index);
}

vB_AJAX_QuickEditor.prototype.saveCode=function(po stid,tid,index){
this.tid = tid;
document.body.style.cursor='wait';
var C=YAHOO.util.Dom.get('postcount'+postid);
var D=editAreaLoader.getValue(tid);
this.savedCode = D;
editAreaLoader.setValue(tid, '');
this.ajax_req=YAHOO.util.Connect.asyncRequest('POS T',fetch_ajax_url('editpost.php?do=updatecode&postid='+postid),
{success:vB_QuickEditor.updateCode, failure:vB_QuickEditor.updateCode,scope:vB_QuickEd itor},
'do=updatecode&ajax=1' +
'&securitytoken=' + SECURITYTOKEN +
'&message=' + PHP.urlencode('I hate Internet Explorer') +
'&code=' + PHP.urlencode(D) +
'&postid=' + postid +
'&index=' + index +
'&posthash=' + vBulletin.attachinfo.posthash +
'&poststarttime=' + vBulletin.attachinfo.poststarttime +
'&relpath=' + PHP.urlencode(RELPATH) +
'&postcount=' + PHP.urlencode(C.name));
}

vB_AJAX_QuickEditor.prototype.updateCode=function( C){
if(C.responseXML){
vB_QuickEditor.progress.style.visibility = 'hidden';
document.body.style.cursor='auto';
if(fetch_tag_count(C.responseXML,'error')){
var D=fetch_tags(C.responseXML,'error');
var A='<ol>';
for(var B=0;B<D.length;B++){
A+='<li>'+D[B].firstChild.nodeValue+'</li>'
}
A+='</ol>';
var saveDiv = fetch_object('d_' + this.timeid)
saveDiv.getElementsByTagName('div')[0].innerHTML = A;
saveDiv.getElementsByTagName('input')[1].style.display = 'block';
}else{
editAreaLoader.setValue(vB_QuickEditor.tid, fetch_tags(C.responseXML, 'postbit')[0].firstChild.nodeValue);
}
}
return false
}
}



When you click the button the code should disappear and then the code read from the daabase will show. I takes just a second or so.

EDITED: I found a better fix

Muhammad Rahman
06-02-2013, 07:29 AM
I did not find the template bbcode_editortags_script
the existing bbcode_editor_script

nerbert
06-02-2013, 11:10 AM
I meant bbcode_editor_script.

Upload the new product file and over write the old one and change the code in the bbcode manager and it should work

Muhammad Rahman
06-03-2013, 02:38 AM
I have uploaded and reinstall ..
still does not work ...

This my forum (http://www.lam-alif.com)

nerbert
06-03-2013, 04:09 AM
If you made that template change you will have to go back to bbcode_editor_script and revert it. If it shows red it needs to be reverted, so it gets the new version from MASTER STYLE

nerbert
06-05-2013, 02:18 PM
@ Muhammad Rahman: I'm wondering if you have Quick Edit disabled?

Settings > Options > Message Posting and Editing Options > Quick Edit

__________________________________________________ ______________________________ ___________

I finished a new Version 1.1, which allows resizing in all browsers, so the special height setting in the admin CP is no longer needed. Also editing is possible regardless of whether Quick Edit is enabled. Fixed miscellaneous minor bugs.

Muhammad Rahman
06-30-2013, 04:10 PM
@ Muhammad Rahman: I'm wondering if you have Quick Edit disabled?

Settings > Options > Message Posting and Editing Options > Quick Edit

__________________________________________________ _________________________________________

I finished a new Version 1.1, which allows resizing in all browsers, so the special height setting in the admin CP is no longer needed. Also editing is possible regardless of whether Quick Edit is enabled. Fixed miscellaneous minor bugs.

still not working for my forum .. :o

john7911
11-02-2013, 03:10 PM
Thank you ;)
Is it possible to put AutoLISP (Autodesk AutoCAD)

john7911
11-02-2013, 03:35 PM
I have the same problem as Muhammad Rahman :(

nerbert
11-02-2013, 08:28 PM
I have the same problem as Muhammad Rahman :(
I don't use this any more because I have something better. It has a minor imperfection or two I've been trying to fix but since I have so many other things going on I think I'll just post it as is.

The new product uses the CodeMirror editor and is completely different from this so I'll start a new product thread. I have to test it some more and tidy it up so give me a few hours.

I'll post a link here when I post the new product.

nerbert
11-03-2013, 04:03 AM
Here's a whole new version that uses CodeMirror

https://vborg.vbsupport.ru/showthread.php?t=304118