Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#955 closed task (fixed)

Editor2 remaining work w/toolbar

Reported by: bill Owned by: alex
Priority: high Milestone:
Component: Widgets Version: 0.3
Keywords: Editor2 Cc:
Blocked By: Blocking:

Description

Reminder to finish up remaining work on Editor2 w.r.t. sharing toolbar between multiple editors. (Alex, correct me if I'm wrong.)

Change History (5)

comment:1 Changed 13 years ago by Dusan

Keywords: Editor2 added
Milestone: 0.40.3release
Priority: normalhigh

Not sure if my problem belongs to this ticket but if you put 2 Editor2 on one page then toolbar on first one will not work

comment:2 Changed 13 years ago by bill

Milestone: 0.3release0.4
Priority: highnormal
Version: 0.20.3

comment:3 Changed 13 years ago by bdarnton@…

Problem: With multiple Editor2 components in existence, clicking toolbar buttons only has any effect for the most recently created widget.

Not sure of this is useful to you, but this is the fix I came up with...

This is due to the way toolbar events are connected to their rich text areas.

When there are three Editor2 components in existence, this sequence occurs:

DEBUG: setBlur: [Widget Editor2, Editor2_0]
DEBUG: setBlur: [Widget Editor2, Editor2_1]
DEBUG: setBlur: [Widget Editor2, Editor2_2]
DEBUG: setFocus: [Widget Editor2, Editor2_0]

DEBUG: setBlur: [Widget Editor2, Editor2_0]
DEBUG: setBlur: [Widget Editor2, Editor2_1]
DEBUG: setBlur: [Widget Editor2, Editor2_2]
DEBUG: setFocus: [Widget Editor2, Editor2_1]

DEBUG: setBlur: [Widget Editor2, Editor2_0]
DEBUG: setBlur: [Widget Editor2, Editor2_1]
DEBUG: setBlur: [Widget Editor2, Editor2_2]
DEBUG: setFocus: [Widget Editor2, Editor2_2]

meaning that only Editor2_2 is capable of responding to toolbar events.

This occurs because when the editor is running in an Iframe the "edit node" that each Editor2 widget listens to for focus events is not unique to the widget, it is the HTML Body element. When multiple Editor2 widgets are created they each register a publisher which listens for the 'onfocus' event on the document body and then broadcasts the 'Editor2.clobberFocus' topic. Each Editor2 widget is subscribed to that topic and so all of these widgets run their 'setBlur' method. The first Editor2 widget then runs its 'setFocus' method. The problem appears because each widget in turn causes all of the Editor2 widgets to run their 'setBlur' methods, disconnecting their toolbars from their rich text areas, and then runs its own 'setFocus' method to reconnect the toolbar events to its rich text area. Unless the widget is the last one created, its toolbar remains disconnected. The solution is to ensure that the 'Editor2.clobberFocus' topic is only published once.

Line 73 of Editor2.js registers the publisher:

dojo.event.topic.registerPublisher("Editor2.clobberFocus", this.editNode, "onfocus");

Replace this with a test to make sure that it only happens once.

var registerPublisher = true;
if(this.iframe || this.object) {
  if(dojo.event.topic.topics["Editor2.clobberFocus"]) {
    registerPublisher = false;
  }
}
if(registerPublisher) {
  dojo.event.topic.registerPublisher("Editor2.clobberFocus", this.editNode, "onfocus");
}

Bernard Darnton www.salamissoftware.com

comment:4 Changed 13 years ago by liucougar

Resolution: fixed
Status: newclosed

this should have been fixed in svn trunk

(a similar patch was already committed)

comment:5 Changed 12 years ago by (none)

Milestone: 0.4

Milestone 0.4 deleted

Note: See TracTickets for help on using tickets.