mirror of
https://github.com/UnickSoft/graphonline.git
synced 2026-04-16 21:30:08 +00:00
first commit
This commit is contained in:
124
lib/ckeditor4/plugins/sharedspace/plugin.js
Executable file
124
lib/ckeditor4/plugins/sharedspace/plugin.js
Executable file
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* @license Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
|
||||
* For licensing, see LICENSE.md or http://ckeditor.com/license
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
var containerTpl = CKEDITOR.addTemplate( 'sharedcontainer', '<div' +
|
||||
' id="cke_{name}"' +
|
||||
' class="cke {id} cke_reset_all cke_chrome cke_editor_{name} cke_shared cke_detached cke_{langDir} ' + CKEDITOR.env.cssClass + '"' +
|
||||
' dir="{langDir}"' +
|
||||
' title="' + ( CKEDITOR.env.gecko ? ' ' : '' ) + '"' +
|
||||
' lang="{langCode}"' +
|
||||
' role="presentation"' +
|
||||
'>' +
|
||||
'<div class="cke_inner">' +
|
||||
'<div id="{spaceId}" class="cke_{space}" role="presentation">{content}</div>' +
|
||||
'</div>' +
|
||||
'</div>' );
|
||||
|
||||
CKEDITOR.plugins.add( 'sharedspace', {
|
||||
afterInit: function( editor ) {
|
||||
var spaces = editor.config.sharedSpaces;
|
||||
|
||||
if ( spaces ) {
|
||||
for ( var spaceName in spaces ) {
|
||||
create( editor, spaceName, spaces[ spaceName ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function create( editor, spaceName, targetId ) {
|
||||
var target = CKEDITOR.document.getById( targetId ),
|
||||
innerHtml, space;
|
||||
|
||||
if ( target ) {
|
||||
// Have other plugins filling the space.
|
||||
innerHtml = editor.fire( 'uiSpace', { space: spaceName, html: '' } ).html;
|
||||
|
||||
if ( innerHtml ) {
|
||||
// Block the uiSpace handling by others (e.g. themed-ui).
|
||||
editor.on( 'uiSpace', function( ev ) {
|
||||
if ( ev.data.space == spaceName )
|
||||
ev.cancel();
|
||||
}, null, null, 1 ); // Hi-priority
|
||||
|
||||
// Inject the space into the target.
|
||||
space = target.append( CKEDITOR.dom.element.createFromHtml( containerTpl.output({
|
||||
id: editor.id,
|
||||
name: editor.name,
|
||||
langDir: editor.lang.dir,
|
||||
langCode: editor.langCode,
|
||||
space: spaceName,
|
||||
spaceId: editor.ui.spaceId( spaceName ),
|
||||
content: innerHtml
|
||||
})));
|
||||
|
||||
// Only the first container starts visible. Others get hidden.
|
||||
if ( target.getCustomData( 'cke_hasshared' ) )
|
||||
space.hide();
|
||||
else
|
||||
target.setCustomData( 'cke_hasshared', 1 );
|
||||
|
||||
// There's no need for the space to be selectable.
|
||||
space.unselectable();
|
||||
|
||||
// Prevent clicking on non-buttons area of the space from blurring editor.
|
||||
space.on( 'mousedown', function( evt ) {
|
||||
evt = evt.data;
|
||||
if ( !evt.getTarget().hasAscendant( 'a', 1 ) )
|
||||
evt.preventDefault();
|
||||
});
|
||||
|
||||
// Register this UI space to the focus manager.
|
||||
editor.focusManager.add( space, 1 );
|
||||
|
||||
// When the editor gets focus, show the space container, hiding others.
|
||||
editor.on( 'focus', function() {
|
||||
for ( var i = 0, sibling, children = target.getChildren(); ( sibling = children.getItem( i ) ); i++ ) {
|
||||
if ( sibling.type == CKEDITOR.NODE_ELEMENT &&
|
||||
!sibling.equals( space ) &&
|
||||
sibling.hasClass( 'cke_shared' ) ) {
|
||||
sibling.hide();
|
||||
}
|
||||
}
|
||||
|
||||
space.show();
|
||||
});
|
||||
|
||||
editor.on( 'destroy', function() {
|
||||
space.remove();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
/**
|
||||
* Makes it possible to place some of the editor UI blocks, like the toolbar
|
||||
* and the elements path, into any element in the page.
|
||||
*
|
||||
* The elements used to hold the UI blocks can be shared among several editor
|
||||
* instances. In that case, only the blocks of the active editor instance will
|
||||
* display.
|
||||
*
|
||||
* // Place the toolbar inside the element with ID "someElementId" and the
|
||||
* // elements path into the element with ID "anotherId".
|
||||
* config.sharedSpaces = {
|
||||
* top: 'someElementId',
|
||||
* bottom: 'anotherId'
|
||||
* };
|
||||
*
|
||||
* // Place the toolbar inside the element with ID "someElementId". The
|
||||
* // elements path will remain attached to the editor UI.
|
||||
* config.sharedSpaces = {
|
||||
* top: 'someElementId'
|
||||
* };
|
||||
*
|
||||
* @cfg {Object} [sharedSpaces]
|
||||
* @member CKEDITOR.config
|
||||
*/
|
||||
119
lib/ckeditor4/plugins/sharedspace/samples/sharedspace.html
Executable file
119
lib/ckeditor4/plugins/sharedspace/samples/sharedspace.html
Executable file
@@ -0,0 +1,119 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
|
||||
For licensing, see LICENSE.md or http://ckeditor.com/license
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>Shared-Space Plugin — CKEditor Sample</title>
|
||||
<meta charset="utf-8">
|
||||
<script src="../../../ckeditor.js"></script>
|
||||
<link rel="stylesheet" href="../../../samples/sample.css">
|
||||
<meta name="ckeditor-sample-name" content="Shared-Space plugin">
|
||||
<meta name="ckeditor-sample-group" content="Plugins">
|
||||
<meta name="ckeditor-sample-description" content="Having the toolbar and the bottom bar spaces shared by different editor instances.">
|
||||
</head>
|
||||
<body>
|
||||
<h1 class="samples">
|
||||
<a href="../../../samples/index.html">CKEditor Samples</a> » Sharing Toolbar and Bottom-bar Spaces
|
||||
</h1>
|
||||
<div class="description">
|
||||
<p>
|
||||
This sample shows several editor instances that share the very same spaces for both the toolbar and the bottom bar.
|
||||
</p>
|
||||
</div>
|
||||
<div id="top">
|
||||
<!-- This div will handle all toolbars -->
|
||||
</div>
|
||||
|
||||
<div style="height: 300px; overflow: auto; border: 1px solid #afafaf; padding: 20px; margin: 20px;">
|
||||
|
||||
<div id="framed1" style="width: 49%; float: left; margin-bottom: 20px;"></div>
|
||||
<div id="framed2" style="width: 49%; float: right; margin-bottom: 20px;"></div>
|
||||
|
||||
<hr style="clear: both; margin: 20px 0;">
|
||||
|
||||
<div contenteditable="true" id="inline1" style="width: 49%; float: left;">
|
||||
<h3>
|
||||
Integer condimentum sit amet
|
||||
</h3>
|
||||
<p>
|
||||
<strong>Aenean nonummy a, mattis varius. Cras aliquet.</strong>
|
||||
Praesent <a href="http://ckeditor.com/">magna non mattis ac, rhoncus nunc</a>, rhoncus eget, cursus pulvinar mollis.</p>
|
||||
<p>Proin id nibh. Sed eu libero posuere sed, lectus. Phasellus dui gravida gravida feugiat mattis ac, felis.</p>
|
||||
<p>Integer condimentum sit amet, tempor elit odio, a dolor non ante at sapien. Sed ac lectus. Nulla ligula quis eleifend mi, id leo velit pede cursus arcu id nulla ac lectus. Phasellus vestibulum. Nunc viverra enim quis diam.</p>
|
||||
</div>
|
||||
<div contenteditable="true" id="inline2" style="width: 49%; float: right;">
|
||||
<h3>
|
||||
Praesent wisi accumsan sit amet nibh
|
||||
</h3>
|
||||
<p>Donec ullamcorper, risus tortor, pretium porttitor. Morbi quam quis lectus non leo.</p>
|
||||
<p style="margin-left: 40px; ">Integer faucibus scelerisque. Proin faucibus at, aliquet vulputate, odio at eros. Fusce <a href="http://ckeditor.com/">gravida, erat vitae augue</a>. Fusce urna fringilla gravida.</p>
|
||||
<p>In hac habitasse platea dictumst. Praesent wisi accumsan sit amet nibh. Maecenas orci luctus a, lacinia quam sem, posuere commodo, odio condimentum tempor, pede semper risus. Suspendisse pede. In hac habitasse platea dictumst. Nam sed laoreet sit amet erat. Integer.</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="bottom">
|
||||
<!-- This div will handle all toolbars -->
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
// Turn off automatic editor creation first.
|
||||
CKEDITOR.disableAutoInline = true;
|
||||
|
||||
CKEDITOR.inline( 'inline1', {
|
||||
extraPlugins: 'sharedspace',
|
||||
removePlugins: 'floatingspace,resize',
|
||||
sharedSpaces: {
|
||||
top: 'top',
|
||||
bottom: 'bottom'
|
||||
}
|
||||
});
|
||||
|
||||
CKEDITOR.inline( 'inline2', {
|
||||
extraPlugins: 'sharedspace',
|
||||
removePlugins: 'floatingspace,resize',
|
||||
sharedSpaces: {
|
||||
top: 'top',
|
||||
bottom: 'bottom'
|
||||
}
|
||||
});
|
||||
|
||||
CKEDITOR.appendTo( 'framed1', {
|
||||
extraPlugins: 'sharedspace',
|
||||
removePlugins: 'maximize,resize',
|
||||
sharedSpaces: {
|
||||
top: 'top',
|
||||
bottom: 'bottom'
|
||||
}
|
||||
},
|
||||
document.getElementById( 'inline1' ).innerHTML
|
||||
);
|
||||
|
||||
CKEDITOR.appendTo( 'framed2', {
|
||||
extraPlugins: 'sharedspace',
|
||||
removePlugins: 'maximize,resize',
|
||||
sharedSpaces: {
|
||||
top: 'top',
|
||||
bottom: 'bottom'
|
||||
}
|
||||
},
|
||||
document.getElementById( 'inline2' ).innerHTML
|
||||
);
|
||||
|
||||
</script>
|
||||
|
||||
<div id="footer">
|
||||
<hr>
|
||||
<p>
|
||||
CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
|
||||
</p>
|
||||
<p id="copy">
|
||||
Copyright © 2003-2012, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
|
||||
Knabben. All rights reserved.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user