How to use the @ckeditor/ckeditor5-engine/src/conversion/buildmodelconverter function in @ckeditor/ckeditor5-engine

To help you get started, we’ve selected a few @ckeditor/ckeditor5-engine 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 Tangerine-Community / Tangerine / client-v3 / ckeditor / plugins / ckeditor5-acasi / src / acasi.js View on Github external
return widget;
      } );

    // buildModelConverter().for( editing.modelToView )
    //   .fromElement( 'paper-radio-button' )
    //   .toElement( (element) => {
    //     console.log("modelToView paper-radio-button element")
    //     // const imageContainer = new ViewContainerElement( 'radio', { class: 'paper-radio-button' }, toImageWidget(new ViewEmptyElement( 'img' )) );
    //     // const imageContainer = new ViewContainerElement( 'radio', { class: 'paper-radio-button' }, toImageWidget(new ViewElement( 'img' , {'src': 'assets/images/never.png'}) ) );
    //     const imageContainer = new ViewContainerElement( 'radio', { class: 'paper-radio-button' } );
    //     const widget = toWidget( imageContainer );
    //     widget.setAttribute( 'contenteditable', true );
    //     return widget;
    //   } );

    buildModelConverter().for( editing.modelToView )
      .fromElement( 'figure' )
      .toElement( (element) => {
        console.log("modelToView figure element")
        const klass = element.item.getAttribute('class')
        const container = new ViewContainerElement( 'figure', { class: klass } );
        // let container = new ViewContainerElement( 'figure', {'class': klass}, toImageWidget(new ViewEmptyElement( 'img' )) );
        // const widget = toWidget( container );
        // widget.setAttribute( 'contenteditable', true );
        return container;
      } );

    buildViewConverter().for(data.viewToModel).from({
      name: 'form',
      attribute: { id: /./ }
    })
      .toElement( (viewImage) => {
github ckeditor / ckeditor5-image / tests / widget / widget.js View on Github external
.then( newEditor => {
				editor = newEditor;
				doc = editor.document;
				viewDocument = editor.editing.view;

				doc.schema.registerItem( 'widget', '$block' );
				doc.schema.objects.add( 'widget' );
				doc.schema.registerItem( 'paragraph', '$block' );
				doc.schema.registerItem( 'inline', '$inline' );
				doc.schema.objects.add( 'inline' );
				doc.schema.registerItem( 'nested' );
				doc.schema.allow( { name: '$inline', inside: 'nested' } );
				doc.schema.allow( { name: 'nested', inside: 'widget' } );

				buildModelConverter().for( editor.editing.modelToView )
					.fromElement( 'paragraph' )
					.toElement( 'p' );

				buildModelConverter().for( editor.editing.modelToView )
					.fromElement( 'widget' )
					.toElement( () => {
						const b = new AttributeContainer( 'b' );
						const div = new ViewContainer( 'div', null, b );

						return toWidget( div );
					} );

				buildModelConverter().for( editor.editing.modelToView )
					.fromElement( 'inline' )
					.toElement( 'figure' );
github ckeditor / ckeditor5-image / tests / widget / widgetengine.js View on Github external
.then( newEditor => {
				editor = newEditor;
				document = editor.document;
				viewDocument = editor.editing.view;
				document.schema.registerItem( 'widget', '$block' );
				document.schema.registerItem( 'editable' );
				document.schema.allow( { name: '$inline', inside: 'editable' } );
				document.schema.allow( { name: 'editable', inside: 'widget' } );
				document.schema.allow( { name: 'editable', inside: '$root' } );

				buildModelConverter().for( editor.editing.modelToView )
					.fromElement( 'widget' )
					.toElement( () => {
						const element = toWidget( new ViewContainer( 'div' ), { label: 'element label' } );

						return element;
					} );

				buildModelConverter().for( editor.editing.modelToView )
					.fromElement( 'editable' )
					.toElement( () => new ViewEditable( 'figcaption', { contenteditable: true } ) );
			} );
	} );