File: testwidgets.js

package info (click to toggle)
ckeditor 4.19.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 290,372 kB
  • sloc: javascript: 242,409; sh: 202; makefile: 64; python: 37; php: 15; xml: 5
file content (29 lines) | stat: -rw-r--r-- 978 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
CKEDITOR.plugins.add( 'inlineWidget', {
	requires: 'widget',
	init: function( editor ) {
		editor.widgets.add( 'test1', {
			button: 'Create Inline Widget',
			template: '<strong class="inline-widget" style="background-color:#C0392B;padding:5px;">Very strong text.</strong>',
			requiredContent: 'strong(inline-widget)',
			allowedContent: 'strong(!inline-widget){*}',
			upcast: function( element ) {
				return element.name === 'strong' && element.hasClass( 'inline-widget' );
			}
		} );
	}
} );

CKEDITOR.plugins.add( 'blockWidget', {
	requires: 'widget',
	init: function( editor ) {
		editor.widgets.add( 'test2', {
			button: 'Create Block Widget',
			template: '<div class="block-widget" style="background-color:#F4D03F;padding:5px;">Some text in div.</div>',
			requiredContent: 'div(block-widget)',
			allowedContent: 'div(!block-widget){*}',
			upcast: function( element ) {
				return element.name === 'div' && element.hasClass( 'block-widget' );
			}
		} );
	}
} );