This is the developer page and program documentation for wikEd, a full-featured in-browser text editor that adds enhanced text processing functions to Wikipedia and other MediaWiki edit pages. Please use this talk page for discussing wikEd development issues.
How it works
wikEd replaces the classic textarea input field with an iframe in designmode. That is essentially a separate html page that can be edited. The browser's rich-text editing interface is used to manipulate the text upon clicking a wikEd button, see . After pushing the Save page button the content is copied back to the hidden textarea and then submitted.
Program structure
(Somewhat outdated)
Basic initialization
Built-in user interface texts
Edit-frame css rules
Main window css rules
Button image URLs
Button definitions
Toolbar definition
User customizable variables
Global variables including DOM elements
Check for updates (Ajax)
Schedules the setup routine to run after the page has been loaded
element.addEventListener('click', function(event, variable) { ... }, true); // uses the last value of variable
If possible, please use the wikEd wrapper: WikEdAddEventListener(element, 'click', WikEdGlobalFunction, true)
Custom attributes of DOM elements:
element.setAttribute('custom') = 123;
var attribString = element.getAttribute('custom'); // it is always a string!
It is NOT possible to access functions, objects, or variables from other scripts running on the page! However, it is possible to access variable values using the function wikEd.GetGlobals().
Debugging setup
For performance reasons it is highly recommended to test the scripts on a local copy of a Wikipedia edit page. (Outdated)
Copy the whole wikEd program code from the page wikEd.js to D:\wikEd\wiked.js
Copy the whole diff program code from the page diff.js to D:\wikEd\diff.js
Save a Wikipedia edit page of your choice to D:\wikEd\test.html
Open the page in your text editor and change all addresses of scripts, css files, and images their respective local copies. All other relative links starting with "/ have to be preceded with "http://en.wikipedia.org".
Download the user interface images here, rename the extension to ".zip", and extract them
Set the following configuration variables in the header JavaScript of the edit page:
varwikEdAutoUpdate=false;varwikEdUseLocalImages=true;varwikEdImagePathLocal='file:///D:/wikEd/images/';// the directory were you keep all wikEd button imagesvarwikEdSkipBrowserTest=true;// this enables wikEd under IE and OperavarwikEdShowSourceButton=true;varwikEdDiffScriptSrc='file:///D:/wikEd/diff.js';// the local diff program used for 'Show current changes below'varwikEdInstaViewSrc='file:///D:/wikEd/instaview.js';// InstaView AJAX preview
For finally testing the code on Wikipedia, every developer should create a code page in his own user space ending with .js (e.g. User:YourUsername/wikEd_dev.js). These pages can only be edited by the owner for security reasons.
Making wikEd cross-browser compatible
There is the new library IERange that provides DOM ranges for MS IE. This seems to work in general and has been added to wikEd. However, MSIE has no support for execCommand('inserthtml', code); and the workaround frameDocument.selection.createRange().pasteHTML(code); breaks the undo history!