Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function testPanelAttach( spy ) {
sinon.assert.calledOnce( spy );
const options = spy.firstCall.args[ 0 ];
// Check if proper target element was used.
expect( options.target.tagName.toLowerCase() ).to.equal( 'figure' );
// Check if correct positions are used.
const [ north, south ] = options.positions;
expect( north ).to.equal( BalloonPanelView.defaultPositions.northArrowSouth );
expect( south ).to.equal( BalloonPanelView.defaultPositions.southArrowNorth );
}
} );
.then( editor => {
newEditor = editor;
balloon = newEditor.plugins.get( 'ContextualBalloon' );
balloonToolbar = newEditor.plugins.get( 'BalloonToolbar' );
const button = new View();
button.element = global.document.createElement( 'div' );
// There must be at least one toolbar items which is not disabled to show it.
// https://github.com/ckeditor/ckeditor5-ui/issues/269
balloonToolbar.toolbarView.items.add( button );
newEditor.editing.view.isFocused = true;
newEditor.editing.view.getDomRoot().focus();
} );
} );
.then( editor => {
newEditor = editor;
balloon = newEditor.plugins.get( 'ContextualBalloon' );
balloonToolbar = newEditor.plugins.get( 'BalloonToolbar' );
const button = new View();
button.element = global.document.createElement( 'div' );
// There must be at least one toolbar items which is not disabled to show it.
// https://github.com/ckeditor/ckeditor5-ui/issues/269
balloonToolbar.toolbarView.items.add( button );
newEditor.editing.view.isFocused = true;
newEditor.editing.view.getDomRoot().focus();
} );
} );
_createUrlInput() {
const t = this.locale.t;
const labeledInput = new LabeledInputView( this.locale, InputTextView );
const inputView = labeledInput.inputView;
this._urlInputViewInfoDefault = t( 'Paste the media URL in the input.' );
this._urlInputViewInfoTip = t( 'Tip: Paste the URL into the content to embed faster.' );
labeledInput.label = t( 'Media URL' );
labeledInput.infoText = this._urlInputViewInfoDefault;
inputView.placeholder = 'https://example.com';
inputView.on( 'input', () => {
// Display the tip text only when there's some value. Otherwise fall back to the default info text.
labeledInput.infoText = inputView.element.value ? this._urlInputViewInfoTip : this._urlInputViewInfoDefault;
} );
return labeledInput;
}
_createOnchangeInputView() {
const t = this.locale.t;
// const onchangeInput = new LabeledInputView( this.locale, InputTextView );
const onchangeInput = new LabeledInputView( this.locale, TextareaView );
onchangeInput.label = t( 'Onchange javascript' );
return onchangeInput;
}
}
componentFactory.add( 'alignment', locale => {
const dropdownView = createDropdown( locale );
// Add existing alignment buttons to dropdown's toolbar.
const buttons = options.map( option => componentFactory.create( `alignment:${ option }` ) );
addToolbarToDropdown( dropdownView, buttons );
// Configure dropdown properties an behavior.
dropdownView.buttonView.set( {
label: t( 'Text alignment' ),
tooltip: true
} );
dropdownView.toolbarView.isVertical = true;
dropdownView.toolbarView.ariaLabel = t( 'Text alignment toolbar' );
dropdownView.extendTemplate( {
attributes: {
editor.ui.componentFactory.add( 'insertTable', locale => {
const command = editor.commands.get( 'insertTable' );
const dropdownView = createDropdown( locale );
dropdownView.bind( 'isEnabled' ).to( command );
// Decorate dropdown's button.
dropdownView.buttonView.set( {
icon: tableIcon,
label: t( 'Insert table' ),
tooltip: true
} );
// Prepare custom view for dropdown's panel.
const insertTableView = new InsertTableView( locale );
dropdownView.panelView.children.add( insertTableView );
insertTableView.delegate( 'execute' ).to( dropdownView );
editor.ui.componentFactory.add( FONT_SIZE, locale => {
const dropdownView = createDropdown( locale );
addListToDropdown( dropdownView, _prepareListOptions( options, command ) );
// Create dropdown model.
dropdownView.buttonView.set( {
label: t( 'Font Size' ),
icon: fontSizeIcon,
tooltip: true
} );
dropdownView.extendTemplate( {
attributes: {
class: [
'ck-font-size-dropdown'
]
}
} );
componentFactory.add( 'highlight', locale => {
const command = editor.commands.get( 'highlight' );
const dropdownView = createDropdown( locale, SplitButtonView );
const splitButtonView = dropdownView.buttonView;
splitButtonView.set( {
tooltip: t( 'Highlight' ),
// Holds last executed highlighter.
lastExecuted: startingHighlighter.model,
// Holds current highlighter to execute (might be different then last used).
commandValue: startingHighlighter.model,
isToggleable: true
} );
// Dropdown button changes to selection (command.value):
// - If selection is in highlight it get active highlight appearance (icon, color) and is activated.
// - Otherwise it gets appearance (icon, color) of last executed highlight.
splitButtonView.bind( 'icon' ).to( command, 'value', value => getIconForType( getActiveOption( value, 'type' ) ) );
splitButtonView.bind( 'color' ).to( command, 'value', value => getActiveOption( value, 'color' ) );
_prepareDropdown( label, icon, options, locale ) {
const editor = this.editor;
const dropdownView = createDropdown( locale );
const commands = [];
// Prepare dropdown list items for list dropdown.
const itemDefinitions = new Collection();
for ( const option of options ) {
addListOption( option, editor, commands, itemDefinitions );
}
addListToDropdown( dropdownView, itemDefinitions );
// Decorate dropdown's button.
dropdownView.buttonView.set( {
label,
icon,
tooltip: true