Opened 9 years ago

Closed 9 years ago

#13843 closed Bug (invalid)

Editor doesn't focus on custom widget on load

Reported by: Vangelis Owned by:
Priority: Normal Milestone:
Component: Core : Focus Version:
Keywords: Cc:

Description

Steps to reproduce

  1. Add a widget (with editable content) at the start of the editable content and save.
  2. Close the editor.
  3. Load the editor.

(I have attached the config that I'm using. The custom widget that I used is simplebox.)

Expected result

The editor should focus on the first editable element in the widget.

Actual result

The editor doesn't focus on the widget until the user clicks in it.

config.js

I added the following lines of code in the config file: CKEDITOR.on('instanceReady', function(e) {

e.editor.focus();

});

Change History (1)

comment:1 Changed 9 years ago by Jakub Ś

Resolution: invalid
Status: newclosed
Version: 4.5.4

You have used editor focus method and not widget focus method. The editor.focus focuses main content area in which widgets are kept.

Let's say that you have one widget in main content area.

<div class="simplebox" style="width: 200px;">
	<h2 class="simplebox-title">Title</h2>
	<div class="simplebox-content">
		<p>Content...</p>
	</div>
</div>

The easiest code would be:

CKEDITOR.instances.editor1.on( 'instanceReady', function( evt ) {	
	console.log(CKEDITOR.instances.editor1.widgets); //available widgets
	console.log(CKEDITOR.instances.editor1.widgets.instances[ 0 ]); //widget instance
	console.log(CKEDITOR.instances.editor1.widgets.instances[ 0 ].editables);//widget instance editabes

	CKEDITOR.instances.editor1.widgets.instances[ 0 ].focus();//focus entire widget
	CKEDITOR.instances.editor1.widgets.instances[ 0 ].editables.title.focus();//focus particular editable
});

You can use above example to get result you want (you can display objects in Firebug and find properties which allow you to identify the widget).

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy