From 2ed5c13a4ebdee46851268978628f464adc9f50c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Carlos=20Ra=C3=B1a?= Date: Tue, 2 Sep 2008 21:54:37 +0200 Subject: [PATCH] [svn r16226] to add a wiki button into fckeditor --- .../editor/plugins/wikilink/fck_wikilink.html | 108 ++++++++++ .../editor/plugins/wikilink/fckplugin.js | 187 ++++++++++++++++++ .../editor/plugins/wikilink/lang/en.js | 32 +++ .../editor/plugins/wikilink/lang/es.js | 31 +++ .../editor/plugins/wikilink/wikilink.gif | Bin 0 -> 1021 bytes 5 files changed, 358 insertions(+) create mode 100644 main/inc/lib/fckeditor/editor/plugins/wikilink/fck_wikilink.html create mode 100644 main/inc/lib/fckeditor/editor/plugins/wikilink/fckplugin.js create mode 100644 main/inc/lib/fckeditor/editor/plugins/wikilink/lang/en.js create mode 100644 main/inc/lib/fckeditor/editor/plugins/wikilink/lang/es.js create mode 100644 main/inc/lib/fckeditor/editor/plugins/wikilink/wikilink.gif diff --git a/main/inc/lib/fckeditor/editor/plugins/wikilink/fck_wikilink.html b/main/inc/lib/fckeditor/editor/plugins/wikilink/fck_wikilink.html new file mode 100644 index 0000000000..2cbca60fce --- /dev/null +++ b/main/inc/lib/fckeditor/editor/plugins/wikilink/fck_wikilink.html @@ -0,0 +1,108 @@ + + + + + Wikilink Properties + + + + + + + + + + +
+ + + + +
+ Wikilink Name
+ + TIP: You can also create a wiki link placing between double brackets [[]] a word +
+
+ + diff --git a/main/inc/lib/fckeditor/editor/plugins/wikilink/fckplugin.js b/main/inc/lib/fckeditor/editor/plugins/wikilink/fckplugin.js new file mode 100644 index 0000000000..bcf5c90b2b --- /dev/null +++ b/main/inc/lib/fckeditor/editor/plugins/wikilink/fckplugin.js @@ -0,0 +1,187 @@ +/* + * FCKeditor - The text editor for Internet - http://www.fckeditor.net + * Copyright (C) 2003-2008 Frederico Caldeira Knabben + * + * == BEGIN LICENSE == + * + * Licensed under the terms of any of the following licenses at your + * choice: + * + * - GNU General Public License Version 2 or later (the "GPL") + * http://www.gnu.org/licenses/gpl.html + * + * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") + * http://www.gnu.org/licenses/lgpl.html + * + * - Mozilla Public License Version 1.1 or later (the "MPL") + * http://www.mozilla.org/MPL/MPL-1.1.html + * + * == END LICENSE == + * Author: Juan Carlos Raña Trabado + * Plugin to insert "Wikilinks" in the editor, based in "Placeholders" + */ + +// Register the related command. +FCKCommands.RegisterCommand( 'Wikilink', new FCKDialogCommand( 'Wikilink', FCKLang.WikilinkDlgTitle, FCKPlugins.Items['wikilink'].Path + 'fck_wikilink.html', 340, 200 ) ) ; + +// Create the "Plaholder" toolbar button. +var oPlaceholderItem = new FCKToolbarButton( 'Wikilink', FCKLang.WikilinkBtn ) ; +oPlaceholderItem.IconPath = FCKPlugins.Items['wikilink'].Path + 'wikilink.gif' ; + +FCKToolbarItems.RegisterItem( 'Wikilink', oPlaceholderItem ) ; + + +// The object used for all Placeholder operations. +var FCKPlaceholders = new Object() ; + +// Add a new placeholder at the actual selection. +FCKPlaceholders.Add = function( name ) +{ + var oSpan = FCK.InsertElement( 'span' ) ; + this.SetupSpan( oSpan, name ) ; +} + +FCKPlaceholders.SetupSpan = function( span, name ) +{ + span.innerHTML = '[[ ' + name + ' ]]' ; + + span.style.backgroundColor = '#ffff00' ; + span.style.color = '#000000' ; + + if ( FCKBrowserInfo.IsGecko ) + span.style.cursor = 'default' ; + + span._fckplaceholder = name ; + span.contentEditable = false ; + + // To avoid it to be resized. + span.onresizestart = function() + { + FCK.EditorWindow.event.returnValue = false ; + return false ; + } +} + +// On Gecko we must do this trick so the user select all the SPAN when clicking on it. +FCKPlaceholders._SetupClickListener = function() +{ + FCKPlaceholders._ClickListener = function( e ) + { + if ( e.target.tagName == 'SPAN' && e.target._fckplaceholder ) + FCKSelection.SelectNode( e.target ) ; + } + + FCK.EditorDocument.addEventListener( 'click', FCKPlaceholders._ClickListener, true ) ; +} + +// Open the Placeholder dialog on double click. +FCKPlaceholders.OnDoubleClick = function( span ) +{ + if ( span.tagName == 'SPAN' && span._fckplaceholder ) + FCKCommands.GetCommand( 'Wikilink' ).Execute() ; +} + +FCK.RegisterDoubleClickHandler( FCKPlaceholders.OnDoubleClick, 'SPAN' ) ; + +// Check if a Placholder name is already in use. +FCKPlaceholders.Exist = function( name ) +{ + var aSpans = FCK.EditorDocument.getElementsByTagName( 'SPAN' ) ; + + for ( var i = 0 ; i < aSpans.length ; i++ ) + { + if ( aSpans[i]._fckplaceholder == name ) + return true ; + } + + return false ; +} + +if ( FCKBrowserInfo.IsIE ) +{ + FCKPlaceholders.Redraw = function() + { + if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) + return ; + + var aPlaholders = FCK.EditorDocument.body.innerText.match( /\[\[[^\[\]]+\]\]/g ) ; + if ( !aPlaholders ) + return ; + + var oRange = FCK.EditorDocument.body.createTextRange() ; + + for ( var i = 0 ; i < aPlaholders.length ; i++ ) + { + if ( oRange.findText( aPlaholders[i] ) ) + { + var sName = aPlaholders[i].match( /\[\[\s*([^\]]*?)\s*\]\]/ )[1] ; + oRange.pasteHTML( '' + aPlaholders[i] + '' ) ; + } + } + } +} +else +{ + FCKPlaceholders.Redraw = function() + { + if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) + return ; + + var oInteractor = FCK.EditorDocument.createTreeWalker( FCK.EditorDocument.body, NodeFilter.SHOW_TEXT, FCKPlaceholders._AcceptNode, true ) ; + + var aNodes = new Array() ; + + while ( ( oNode = oInteractor.nextNode() ) ) + { + aNodes[ aNodes.length ] = oNode ; + } + + for ( var n = 0 ; n < aNodes.length ; n++ ) + { + var aPieces = aNodes[n].nodeValue.split( /(\[\[[^\[\]]+\]\])/g ) ; + + for ( var i = 0 ; i < aPieces.length ; i++ ) + { + if ( aPieces[i].length > 0 ) + { + if ( aPieces[i].indexOf( '[[' ) == 0 ) + { + var sName = aPieces[i].match( /\[\[\s*([^\]]*?)\s*\]\]/ )[1] ; + + var oSpan = FCK.EditorDocument.createElement( 'span' ) ; + FCKPlaceholders.SetupSpan( oSpan, sName ) ; + + aNodes[n].parentNode.insertBefore( oSpan, aNodes[n] ) ; + } + else + aNodes[n].parentNode.insertBefore( FCK.EditorDocument.createTextNode( aPieces[i] ) , aNodes[n] ) ; + } + } + + aNodes[n].parentNode.removeChild( aNodes[n] ) ; + } + + FCKPlaceholders._SetupClickListener() ; + } + + FCKPlaceholders._AcceptNode = function( node ) + { + if ( /\[\[[^\[\]]+\]\]/.test( node.nodeValue ) ) + return NodeFilter.FILTER_ACCEPT ; + else + return NodeFilter.FILTER_SKIP ; + } +} + +FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKPlaceholders.Redraw ) ; + +// We must process the SPAN tags to replace then with the real resulting value of the placeholder. +FCKXHtml.TagProcessors['span'] = function( node, htmlNode ) +{ + if ( htmlNode._fckplaceholder ) + node = FCKXHtml.XML.createTextNode( '[[' + htmlNode._fckplaceholder + ']]' ) ; + else + FCKXHtml._AppendChildNodes( node, htmlNode, false ) ; + + return node ; +} diff --git a/main/inc/lib/fckeditor/editor/plugins/wikilink/lang/en.js b/main/inc/lib/fckeditor/editor/plugins/wikilink/lang/en.js new file mode 100644 index 0000000000..a5dd492244 --- /dev/null +++ b/main/inc/lib/fckeditor/editor/plugins/wikilink/lang/en.js @@ -0,0 +1,32 @@ +/* + * FCKeditor - The text editor for Internet - http://www.fckeditor.net + * Copyright (C) 2003-2008 Frederico Caldeira Knabben + * + * == BEGIN LICENSE == + * + * Licensed under the terms of any of the following licenses at your + * choice: + * + * - GNU General Public License Version 2 or later (the "GPL") + * http://www.gnu.org/licenses/gpl.html + * + * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") + * http://www.gnu.org/licenses/lgpl.html + * + * - Mozilla Public License Version 1.1 or later (the "MPL") + * http://www.mozilla.org/MPL/MPL-1.1.html + * + * == END LICENSE == + * + * Wiki link English language file. + */ + + +FCKLang.WikilinkBtn = 'Insert/Edit Wiki link' ; +FCKLang.WikilinkDlgTitle = 'Wiki link' ; +FCKLang.WikilinkDlgName = 'Wiki link name' ; +FCKLang.WikilinkErrNoName = 'Please type the wiki link name' ; +FCKLang.PlaceholderErrNameInUse = ' '; +FCKLang.WikilinkHelp = 'TIP: Also, you can create a wiki link without using this button. To create a new page or create a link to an existing one using wiki links, edit a page and add [[page title]] or [[name of link|title of page]] to its content.'; + + diff --git a/main/inc/lib/fckeditor/editor/plugins/wikilink/lang/es.js b/main/inc/lib/fckeditor/editor/plugins/wikilink/lang/es.js new file mode 100644 index 0000000000..4b431986df --- /dev/null +++ b/main/inc/lib/fckeditor/editor/plugins/wikilink/lang/es.js @@ -0,0 +1,31 @@ +/* + * FCKeditor - The text editor for Internet - http://www.fckeditor.net + * Copyright (C) 2003-2008 Frederico Caldeira Knabben + * + * == BEGIN LICENSE == + * + * Licensed under the terms of any of the following licenses at your + * choice: + * + * - GNU General Public License Version 2 or later (the "GPL") + * http://www.gnu.org/licenses/gpl.html + * + * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") + * http://www.gnu.org/licenses/lgpl.html + * + * - Mozilla Public License Version 1.1 or later (the "MPL") + * http://www.mozilla.org/MPL/MPL-1.1.html + * + * == END LICENSE == + * + * Author: Juan Carlos Raña Trabado + * Wikilink Spanish language file. + */ + + +FCKLang.WikilinkBtn = 'Insertar/Editar Enlace wiki' ; +FCKLang.WikilinkDlgTitle = 'Enlace wiki' ; +FCKLang.WikilinkDlgName = 'Nombre del enlace wiki' ; +FCKLang.WikilinkErrNoName = 'Introduzca el nombre del enlace wiki que desea insertar' ; +FCKLang.PlaceholderErrNameInUse = ' '; +FCKLang.WikilinkHelp = 'SUGERENCIA: también puede crear enlaces wiki sin usar este botón. Para crear una nueva página o para crear un enlace a una existente empleando enlaces wiki, edite una página y añada a su contenido [[título de la página]] o [[texto del enlace | título de la página]] .'; \ No newline at end of file diff --git a/main/inc/lib/fckeditor/editor/plugins/wikilink/wikilink.gif b/main/inc/lib/fckeditor/editor/plugins/wikilink/wikilink.gif new file mode 100644 index 0000000000000000000000000000000000000000..d10e9242ccb67bd21b7f614a8d078a3f42c04ca1 GIT binary patch literal 1021 zcmZ?wbhEHb6krfw_|Cxa|NsBr|Nj2}_xtbPfB*md27*67|Ns2?^Z)wq5r(ADXgr=g!kx<5z84c6qz{p4Dfk?pZQ*>#hFHk2bB|zIN@}{Tou2thqgH z?fvPipY^Z5uwuoEN$YmcU2$~QlA9B@tM;y)GIJ;l9O8d zZcdmmp})U>eOqaFcX!EL^{%e2+zDN!6T(|tTbo*@H#axe*EQNqN@#0vuBoYs>Cxqz z%@kLfRawf#FkMiz&m=Q5Gbb}HBRwNE!!0Q(DKOpKE5)TVj3FW-!XSEATxeW)aHM6N zVL(tofPZ+bTcKg7w!53BzeBjDN2-&fn~sNuor99CgM_ZLqPL}ps5b+TO_q+azLBAk zsJgI-tfZ8rw74Jx12-s^8AbuN5K#Qd!pP3Bh(QM=3Ca@;9Jd%;JDC_9794D5XPw~j zdC?K(7Ix;0gvTp5xK*tcxMCRGCvfqFbX=)OVpM97H%#-{IU)4~ho*tTq6ZHTb&0cv zPfPG{!}VI^TApen5BRU>ofpo-^YVJ0?h6)qw5^U49m8zj0|IvNj3Cm*T^3Q3>1)PHiu ziI<5JIOT+AOR(+==@eGsZ!VIUQ*h$MOsBa{rcR%qo}JIkuDBvIIIUm6IQvC`=7K;4 K#|}nD25SH~D}Chv literal 0 HcmV?d00001