How to use the @ckeditor/ckeditor5-widget/src/utils.toWidgetEditable function in @ckeditor/ckeditor5-widget

To help you get started, we’ve selected a few @ckeditor/ckeditor5-widget examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ckeditor / ckeditor5-table / src / converters / downcast.js View on Github external
function renameViewTableCell( tableCell, desiredCellElementName, conversionApi, asWidget ) {
	const viewWriter = conversionApi.writer;
	const viewCell = conversionApi.mapper.toViewElement( tableCell );

	// View cell might be not yet converted - skip it as it will be properly created by cell converter later on.
	if ( !viewCell ) {
		return;
	}

	let renamedCell;

	if ( asWidget ) {
		const editable = viewWriter.createEditableElement( desiredCellElementName, viewCell.getAttributes() );
		renamedCell = toWidgetEditable( editable, viewWriter );

		viewWriter.insert( viewWriter.createPositionAfter( viewCell ), renamedCell );
		viewWriter.move( viewWriter.createRangeIn( viewCell ), viewWriter.createPositionAt( renamedCell, 0 ) );
		viewWriter.remove( viewWriter.createRangeOn( viewCell ) );
	} else {
		renamedCell = viewWriter.rename( desiredCellElementName, viewCell );
	}

	conversionApi.mapper.unbindViewElement( viewCell );
	conversionApi.mapper.bindElements( tableCell, renamedCell );
}
github ckeditor / ckeditor5-engine / tests / manual / selection.js View on Github external
view: ( modelItem, viewWriter ) => {
				return toWidgetEditable( viewWriter.createEditableElement( 'td' ), viewWriter );
			}
		} );
github ckeditor / ckeditor5-core / tests / _neos / block.js View on Github external
viewWriter
				);

				viewWriter.setCustomProperty( 'objectBlock', true, templateViewElement );

				const viewSlots = findViewSlots( viewWriter.createRangeIn( templateViewElement ) );
				const modelSlots = findObjectBlockModelSlots( modelElement );

				if ( Object.keys( viewSlots ).sort().join( ',' ) != Object.keys( modelSlots ).sort().join( ',' ) ) {
					throw new Error( 'Different set of slots in the template and in the model.' );
				}

				for ( const slotName of Object.keys( viewSlots ) ) {
					editor.editing.mapper.bindElements( modelSlots[ slotName ], viewSlots[ slotName ] );

					toWidgetEditable( viewSlots[ slotName ], viewWriter );
				}

				return toWidget( templateViewElement, viewWriter );
			}
		} );
github ckeditor / ckeditor5-image / src / imagecaption / utils.js View on Github external
return writer => {
		const editable = writer.createEditableElement( 'figcaption' );
		writer.setCustomProperty( 'imageCaption', true, editable );

		enablePlaceholder( {
			view,
			element: editable,
			text: placeholderText
		} );

		return toWidgetEditable( editable, writer );
	};
}
github ckeditor / ckeditor5-table / src / converters / downcast.js View on Github external
function createViewTableCellElement( tableWalkerValue, tableAttributes, insertPosition, conversionApi, options ) {
	const asWidget = options && options.asWidget;
	const cellElementName = getCellElementName( tableWalkerValue, tableAttributes );

	const cellElement = asWidget ?
		toWidgetEditable( conversionApi.writer.createEditableElement( cellElementName ), conversionApi.writer ) :
		conversionApi.writer.createContainerElement( cellElementName );

	const tableCell = tableWalkerValue.cell;

	const firstChild = tableCell.getChild( 0 );
	const isSingleParagraph = tableCell.childCount === 1 && firstChild.name === 'paragraph';

	conversionApi.writer.insert( insertPosition, cellElement );

	if ( isSingleParagraph && !hasAnyAttribute( firstChild ) ) {
		const innerParagraph = tableCell.getChild( 0 );
		const paragraphInsertPosition = conversionApi.writer.createPositionAt( cellElement, 'end' );

		conversionApi.consumable.consume( innerParagraph, 'insert' );

		if ( options.asWidget ) {