mirror of
https://github.com/UnickSoft/graphonline.git
synced 2026-04-15 14:41:05 +00:00
first commit
This commit is contained in:
27
lib/ckeditor4/plugins/insertpre/README.md
Executable file
27
lib/ckeditor4/plugins/insertpre/README.md
Executable file
@@ -0,0 +1,27 @@
|
||||
CKEditor Insert <pre> Plugin
|
||||
===============================
|
||||
|
||||
This plugin makes it easier to insert a <pre> tag in CKEditor.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
1. Clone/copy this repository contents in a new "plugins/insertpre" folder in your CKEditor installation.
|
||||
2. Enable the "insertpre" plugin in the CKEditor configuration file (config.js):
|
||||
|
||||
config.extraPlugins = 'insertpre';
|
||||
|
||||
That's all. "InsertPre" button will appear on the editor toolbar and will be ready to use.
|
||||
|
||||
3. Optionally, you may specify which class should be added to the <pre> element:
|
||||
|
||||
CKEDITOR.config.insertpre_class = 'prettyprint';
|
||||
|
||||
As well as specify how the <pre> tag should be rendered inside CKEditor:
|
||||
|
||||
CKEDITOR.config.insertpre_style = 'background-color:#F8F8F8;border:1px solid #DDD;padding:10px;';
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Licensed under the terms of any of the following licenses at your choice: [GPL](http://www.gnu.org/licenses/gpl.html), [LGPL](http://www.gnu.org/licenses/lgpl.html) and [MPL](http://www.mozilla.org/MPL/MPL-1.1.html).
|
||||
BIN
lib/ckeditor4/plugins/insertpre/icons/insertpre-color.png
Executable file
BIN
lib/ckeditor4/plugins/insertpre/icons/insertpre-color.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 603 B |
BIN
lib/ckeditor4/plugins/insertpre/icons/insertpre.png
Executable file
BIN
lib/ckeditor4/plugins/insertpre/icons/insertpre.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 693 B |
6
lib/ckeditor4/plugins/insertpre/lang/en.js
Executable file
6
lib/ckeditor4/plugins/insertpre/lang/en.js
Executable file
@@ -0,0 +1,6 @@
|
||||
CKEDITOR.plugins.setLang( 'insertpre', 'en', {
|
||||
title : 'Insert code snippet',
|
||||
code : 'Code',
|
||||
edit : 'Edit code',
|
||||
notEmpty : 'The code field cannot be empty.'
|
||||
});
|
||||
6
lib/ckeditor4/plugins/insertpre/lang/pl.js
Executable file
6
lib/ckeditor4/plugins/insertpre/lang/pl.js
Executable file
@@ -0,0 +1,6 @@
|
||||
CKEDITOR.plugins.setLang( 'insertpre', 'pl', {
|
||||
title : 'Wstaw kod',
|
||||
code : 'Kod',
|
||||
edit : 'Edytuj',
|
||||
notEmpty: 'Pole z kodem nie może być puste.'
|
||||
});
|
||||
131
lib/ckeditor4/plugins/insertpre/plugin.js
Executable file
131
lib/ckeditor4/plugins/insertpre/plugin.js
Executable file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
|
||||
For licensing, see LICENSE.html or http://ckeditor.com/license
|
||||
*/
|
||||
|
||||
CKEDITOR.plugins.add( 'insertpre',
|
||||
{
|
||||
requires: 'dialog',
|
||||
lang : 'en,pl', // %REMOVE_LINE_CORE%
|
||||
icons: 'insertpre', // %REMOVE_LINE_CORE%
|
||||
onLoad : function()
|
||||
{
|
||||
if ( CKEDITOR.config.insertpre_class )
|
||||
{
|
||||
CKEDITOR.addCss(
|
||||
'pre.' + CKEDITOR.config.insertpre_class + ' {' +
|
||||
CKEDITOR.config.insertpre_style +
|
||||
'}'
|
||||
);
|
||||
}
|
||||
},
|
||||
init : function( editor )
|
||||
{
|
||||
// allowed and required content is the same for this plugin
|
||||
var required = CKEDITOR.config.insertpre_class ? ( 'pre( ' + CKEDITOR.config.insertpre_class + ' )' ) : 'pre';
|
||||
editor.addCommand( 'insertpre', new CKEDITOR.dialogCommand( 'insertpre', {
|
||||
allowedContent : required,
|
||||
requiredContent : required
|
||||
} ) );
|
||||
editor.ui.addButton && editor.ui.addButton( 'InsertPre',
|
||||
{
|
||||
label : editor.lang.insertpre.title,
|
||||
icon : this.path + 'icons/insertpre.png',
|
||||
command : 'insertpre',
|
||||
toolbar: 'insert,99'
|
||||
} );
|
||||
|
||||
if ( editor.contextMenu )
|
||||
{
|
||||
editor.addMenuGroup( 'code' );
|
||||
editor.addMenuItem( 'insertpre',
|
||||
{
|
||||
label : editor.lang.insertpre.edit,
|
||||
icon : this.path + 'icons/insertpre.png',
|
||||
command : 'insertpre',
|
||||
group : 'code'
|
||||
});
|
||||
editor.contextMenu.addListener( function( element )
|
||||
{
|
||||
if ( element )
|
||||
element = element.getAscendant( 'pre', true );
|
||||
if ( element && !element.isReadOnly() && element.hasClass( editor.config.insertpre_class ) )
|
||||
return { insertpre : CKEDITOR.TRISTATE_OFF };
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
CKEDITOR.dialog.add( 'insertpre', function( editor )
|
||||
{
|
||||
return {
|
||||
title : editor.lang.insertpre.title,
|
||||
minWidth : 540,
|
||||
minHeight : 380,
|
||||
contents : [
|
||||
{
|
||||
id : 'general',
|
||||
label : editor.lang.insertpre.code,
|
||||
elements : [
|
||||
{
|
||||
type : 'textarea',
|
||||
id : 'contents',
|
||||
label : editor.lang.insertpre.code,
|
||||
cols: 140,
|
||||
rows: 22,
|
||||
validate : CKEDITOR.dialog.validate.notEmpty( editor.lang.insertpre.notEmpty ),
|
||||
required : true,
|
||||
setup : function( element )
|
||||
{
|
||||
var html = element.getHtml();
|
||||
if ( html )
|
||||
{
|
||||
var div = document.createElement( 'div' );
|
||||
div.innerHTML = html;
|
||||
this.setValue( div.firstChild.nodeValue );
|
||||
}
|
||||
},
|
||||
commit : function( element )
|
||||
{
|
||||
element.setHtml( CKEDITOR.tools.htmlEncode( this.getValue() ) );
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
onShow : function()
|
||||
{
|
||||
var sel = editor.getSelection(),
|
||||
element = sel.getStartElement();
|
||||
if ( element )
|
||||
element = element.getAscendant( 'pre', true );
|
||||
|
||||
if ( !element || element.getName() != 'pre' || !element.hasClass( editor.config.insertpre_class ) )
|
||||
{
|
||||
element = editor.document.createElement( 'pre' );
|
||||
this.insertMode = true;
|
||||
}
|
||||
else
|
||||
this.insertMode = false;
|
||||
|
||||
this.pre = element;
|
||||
this.setupContent( this.pre );
|
||||
},
|
||||
onOk : function()
|
||||
{
|
||||
if ( editor.config.insertpre_class )
|
||||
this.pre.setAttribute( 'class', editor.config.insertpre_class );
|
||||
|
||||
if ( this.insertMode )
|
||||
editor.insertElement( this.pre );
|
||||
|
||||
this.commitContent( this.pre );
|
||||
}
|
||||
};
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
if (typeof(CKEDITOR.config.insertpre_style) == 'undefined')
|
||||
CKEDITOR.config.insertpre_style = 'background-color:#F8F8F8;border:1px solid #DDD;padding:10px;';
|
||||
if (typeof(CKEDITOR.config.insertpre_class) == 'undefined')
|
||||
CKEDITOR.config.insertpre_class = 'prettyprint';
|
||||
Reference in New Issue
Block a user