Skip to content

Instantly share code, notes, and snippets.

@pgrunewald
Created May 23, 2018 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pgrunewald/f0d00a1899b533d5cc467aa5195b57e5 to your computer and use it in GitHub Desktop.
Save pgrunewald/f0d00a1899b533d5cc467aa5195b57e5 to your computer and use it in GitHub Desktop.
CKEditor widget demo
.simplebox {
padding: 8px;
margin: 10px;
background: #eee;
border-radius: 8px;
border: 1px solid #ddd;
box-shadow: 0 1px 1px #fff inset, 0 -1px 0px #ccc inset;
}
CKEDITOR.plugins.add( 'simplebox', {
requires: 'widget',
icons: 'simplebox',
init: function( editor ) {
editor.widgets.add( 'simplebox', {
button: 'Create a simple box',
template:
'<div class="simplebox"></div>',
allowedContent:
'div(!simplebox)',
requiredContent: 'div(simplebox)',
upcast: function( element ) {
return element.name == 'div' && element.hasClass( 'simplebox' );
}
} );
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment