Opened 5 years ago

Closed 3 years ago

Last modified 3 years ago

#12508 closed Bug (wontfix)

divearea form

Reported by: datalink Owned by: Tomasz Jakut
Priority: Normal Milestone:
Component: General Version: 4.0 Beta
Keywords: Cc:

Description

I use the divarea plugin. Divarea removes <form>-tags from source in all browsers.

Place a form, with or without input fields, to divarea sample, open the sample and switch to source mode, form is removed.

Change History (13)

comment:1 Changed 5 years ago by Jakub Ś

Status: newconfirmed
Version: 4.0 Beta

Problem can be reproduced from CKEditor 4.0 beta in every browser.

comment:2 Changed 5 years ago by datalink

Workaround:

onLoad: function() {
	CKEDITOR.addCss( '.cke_editable [data-cke-form="ckeform"]' +
		'{' +
			'border: 1px dotted #FF0000;' +
			'padding: 2px;' +
			'margin: 0px 2px;' +
			'display: block;' +
		'}\n' );
},
beforeInit: function( editor ) {
	var dataProcessor = editor.dataProcessor,
		dataFilter = dataProcessor && dataProcessor.dataFilter;
	
	dataFilter.addRules({
		elements: {
			form: function( element ) {
				if(!element.attributes['data-cke-form']) {
					element.attributes['data-cke-form'] = 'ckeform';
				}
				
				element.name = 'cke:form';
				
				return element;
			}
		}
	});
},

works for me in inline mode and in iframe mode

comment:3 Changed 5 years ago by Jakub Ś

Yes adding that code to divarea plugin seems to do the trick.

One small issue is when you click on cke:form in elements path, the element path gets expanded. For example: You have form and input field inside it. In elements path you currently have body cke:form and you click on cke:form. In result elements path gets expanded to {{{body cke:form p input}}}.

comment:4 Changed 5 years ago by datalink

Another issue is, the context menu doesn't work for both (form and cke:form). So I insert cke:form to forms/dialogs/form.js

line 16: form = path.contains( 'cke:form', 1 );
line 30: element = editor.document.createElement( 'cke:form' );

comment:5 Changed 3 years ago by Jakub Ś

#13918 was marked as duplicate

comment:6 Changed 3 years ago by Marek Lewandowski

Milestone: CKEditor 4.5.6

comment:7 Changed 3 years ago by Tomasz Jakut

Owner: set to Tomasz Jakut
Status: confirmedassigned

comment:8 Changed 3 years ago by Tomasz Jakut

Status: assignedreview

The problem is not caused by divarea plugin alone, but the fact that such editor is placed inside form.

Replacing form with bogus element between switching editor's modes and then restoring it after data insertion seems to do the trick. Pushed branch:t/12508.

comment:9 Changed 3 years ago by Marek Lewandowski

Milestone: CKEditor 4.5.6CKEditor 4.5.7

comment:10 Changed 3 years ago by Marek Lewandowski

Milestone: CKEditor 4.5.7CKEditor 4.5.8

comment:11 Changed 3 years ago by Marek Lewandowski

Milestone: CKEditor 4.5.8CKEditor 4.5.9

comment:12 Changed 3 years ago by Marek Lewandowski

Resolution: wontfix
Status: reviewclosed

This is a very rare case, and we don't want to bloat core code with this case.

It's easily fixable with the code proposed by @t.jakut, like following:

editor.on( 'instanceReady', function() {
	var dataProcessor = editor.dataProcessor,
		dataFilter = dataProcessor && dataProcessor.dataFilter;

	if ( !editor.editable().isInline() || !editor.editable().getAscendant( 'form' ) ) {
		return;
	}

	if ( dataFilter ) {
		dataFilter.addRules( {
			elements: {
				form: function( element ) {
					element.name = 'cke-form';
				}
			}
		}, { applyToAll: true } );

		editor.on( 'afterSetData', function() {
			var elemsToUpdate = editor.editable().find( 'cke-form' );

			for ( var i = 0; i < elemsToUpdate.count(); ++i ) {
				var element = elemsToUpdate.getItem( i ),
					form = new CKEDITOR.dom.element( 'form' );

				element.copyAttributes( form );
				element.moveChildren( form );

				form.replace( element );
			}
		}, null, null, 999 );
	}

	// IE8 has problems with unknown elements without that line.
	if ( CKEDITOR.env.ie && CKEDITOR.env.version == 8 ) {
		editor.document.$.createElement( 'cke-form' );
	}
} );

So you can use it as a workaround to fix your case.

comment:13 Changed 3 years ago by Marek Lewandowski

Milestone: CKEditor 4.5.9
Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy