CLICK HERE TO BUY IT TODAY! OR GET IT FREE VIA TRIALPAY  

PHP Demo Application - Source Code

/Framework/Model/Vendor/CkEditor/_source/plugins/pastetext/plugin.js



/*
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
 * @file Paste as plain text plugin
 */
(function()
{
	    // The pastetext command definition.
	    var pasteTextCmd =
	    {
		        exec : function( editor )
		        {
			            var clipboardText CKEDITOR.tools.tryThese(
			                function()
			                {
				                    var clipboardText window.clipboardData.getData'Text' );
				                    if ( !clipboardText )
				                        throw 0;
				                    return clipboardText;
				                }
			                // Any other approach that's working...
			                );
			            if ( !clipboardText )   // Clipboard access privilege is not granted.
			            {
				                editor.openDialog'pastetext' );
				                return false;
				            }
			            else
			                editor.fire'paste', { 'text' clipboardText
				} );
			            return true;
			        }
		    };
	    function doInsertTextdoctext )
	    {
		        // Native text insertion.
		        if ( CKEDITOR.env.ie )
		        {
			            var selection doc.selection;
			            if ( selection.type == 'Control' )
			                selection.clear();
			            selection.createRange().pasteHTMLtext );
			        }
		        else
		            doc.execCommand'inserthtml'falsetext );
		    }
	    // Register the plugin.
	    CKEDITOR.plugins.add'pastetext',
	    {
		        init : function( editor )
		        {
			            var commandName 'pastetext',
			                command editor.addCommandcommandNamepasteTextCmd );
			            editor.ui.addButton'PasteText',
			                {
				                    label editor.lang.pasteText.button,
				                    command commandName
				                });
			            CKEDITOR.dialog.addcommandNameCKEDITOR.getUrlthis.path 'dialogs/pastetext.js' ) );
			            if ( editor.config.forcePasteAsPlainText )
			            {
				                // Intercept the default pasting process.
				                editor.on'beforeCommandExec', function ( evt )
				                {
					                    if ( evt.data.name == 'paste' )
					                    {
						                        editor.execCommand'pastetext' );
						                        evt.cancel();
						                    }
					                }, nullnull);
				            }
			        },
		        requires : [ 'clipboard' ]
		    });
	    function doEntereditormodetimesforceMode )
	    {
		        while ( times-- )
		        {
			            CKEDITOR.plugins.enterkeymode == CKEDITOR.ENTER_BR 'enterBr' 'enterBlock' ]
			                    ( editormodenullforceMode );
			        }
		    }
	    CKEDITOR.editor.prototype.insertText = function( text )
	    {
		        this.focus();
		        this.fire'saveSnapshot' );
		        var mode this.getSelection().getStartElement().hasAscendant'pre'true ) ? CKEDITOR.ENTER_BR this.config.enterMode,
		            isEnterBrMode mode == CKEDITOR.ENTER_BR,
		            doc this.document.$,
		            self this,
		            line;
		        text CKEDITOR.tools.htmlEncodetext.replace( /\r\n|\r/g'\n' ) );
		        var startIndex 0;
		        text.replace( /\n+/g, function( matchlastIndex )
		         {
			            line text.substringstartIndexlastIndex );
			            startIndex lastIndex match.length;
			            line.length && doInsertTextdocline );
			            var lineBreakNums match.length,
			                // Duo consequence line-break as a enter block.
			                enterBlockTimes isEnterBrMode Math.floorlineBreakNums ),
			                // Per link-break as a enter br.
			                enterBrTimes isEnterBrMode lineBreakNums lineBreakNums 2;
			            // Line-breaks are converted to editor enter key strokes.
			            doEnterselfmodeenterBlockTimes );
			            doEnterselfCKEDITOR.ENTER_BRenterBrTimesisEnterBrMode false true );
			});
		        // Insert the last text line of text.
		        line text.substringstartIndextext.length );
		        line.length && doInsertTextdocline );
		        this.fire'saveSnapshot' );
		    };
	})();
/**
 * Whether to force all pasting operations to insert on plain text into the
 * editor, loosing any formatting information possibly available in the source
 * text.
 * @name CKEDITOR.config.forcePasteAsPlainText
 * @type Boolean
 * @default false
 * @example
 * config.forcePasteAsPlainText = true;
 */





PHP Demo Source Code Index