Opened 12 years ago

Closed 6 years ago

#2431 closed defect (wontfix)

Editor: Image selection box is not updated properly when changing alignment.

Reported by: bill.blume@… Owned by: nonken
Priority: low Milestone: future
Component: Dojox Version: 0.4.1
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by bill)

There is a bug in Firefox's rich text editor where it does not properly update the selection box of a selected image if you change the alignment of that image, For example, if one selects a left-aligned image and then centers it, the image is moved to the center but its selection box remains to the left. This occurs for both firefox 1.5 and firefox 2.0 and for both Dojo 0.3.1 and 0.4.1.

Here is the fix I am currently using to workaround this defect. This patch is represented as a subclass of the Editor2 class.

dojo.provide("my.widget.MyEditor");
dojo.require("dojo.widget.Editor2");

dojo.widget.defineWidget(
  "my.widget.MyEditor",
  dojo.widget.Editor2,
  {
    postExecCommand: function (command, argument)
    {
      if (dojo.render.html.mozilla &&
          (command == "justifyleft" ||
           command == "justifycenter" ||
           command == "justifyright"))
      {
        // There is a bug in gecko browsers where the drawn selection
        // box does not get updated when one centers or left aligns an
        // image.  So reset the selection by saving it, setting a dummy
        // selection, then restoring the original range.
        var selection = this.window.getSelection();

        if (selection.rangeCount == 1)
        {
          var range = selection.getRangeAt(0).cloneRange();

          if (range.startContainer && range.endContainer &&
              range.startContainer == range.endContainer &&
              range.startContainer.nodeType == 1) {
            var imgNode = null;

            if (range.startContainer.tagName == "IMG")
            {
              imgNode = range.startContainer;
            }
            else if (range.endOffset - range.startOffset == 1 &&
                     range.startContainer.childNodes[range.startOffset].tagName == "IMG")
            {
              imgNode = range.startContainer.childNodes[range.startOffset];
            }

            if (imgNode != null)
            {
              selection.removeAllRanges();
              selection.selectAllChildren(imgNode);
            }
          }
        }
      }
    }
  },
  "html",
  function() {
    dojo.event.connect("after", this, "execCommand", this, "postExecCommand");
  }
)

Change History (11)

comment:1 Changed 12 years ago by bill

Milestone: 1.1

Hmm, currently images in the editor in Dijit aren't even supported at all but it would be nice to put that back in.

comment:2 Changed 12 years ago by bill

Component: EditorDojox
Milestone: 1.1
Owner: changed from liucougar to Tom Trenka
Summary: Image selection box is not updated properly when changing alignment.Editor: Image selection box is not updated properly when changing alignment.

comment:3 Changed 12 years ago by bill

Owner: changed from Tom Trenka to liucougar

comment:4 Changed 11 years ago by dylan

Milestone: 1.2

comment:5 Changed 11 years ago by bill

Milestone: 1.21.3

move 1.2 bugs to 1.3

comment:6 Changed 10 years ago by bill

Description: modified (diff)
Milestone: 1.3future
Owner: changed from liucougar to nonken

We don't even have that fancy image property manipulation box, although nonken long ago was working on one.

comment:7 Changed 10 years ago by nonken

Milestone: future1.4

comment:8 Changed 10 years ago by bill

Milestone: 1.41.5

comment:9 Changed 9 years ago by bill

Milestone: 1.51.6

1.5 is released, moving remaining tickets to 1.6

comment:10 Changed 8 years ago by bill

Milestone: 1.6future

(sadly) punting seemingly abandoned ticket and meta tickets to future

comment:11 Changed 6 years ago by bill

Resolution: wontfix
Status: newclosed

Probably no longer valid, please open a new ticket if there's an issue w/the editor in Dojo 1.8, on modern versions of firefox.

Note: See TracTickets for help on using tickets.