Closed
Bug 66213
Opened 25 years ago
Closed 25 years ago
editor change for smiley feature
Categories
(Core :: DOM: Editor, enhancement)
Core
DOM: Editor
Tracking
()
VERIFIED
FIXED
People
(Reporter: anatoliya, Assigned: anatoliya)
Details
Attachments
(6 files)
|
7.30 KB,
patch
|
Details | Diff | Splinter Review | |
|
7.30 KB,
patch
|
Details | Diff | Splinter Review | |
|
8.09 KB,
patch
|
Details | Diff | Splinter Review | |
|
9.15 KB,
patch
|
Details | Diff | Splinter Review | |
|
8.95 KB,
patch
|
Details | Diff | Splinter Review | |
|
10.29 KB,
patch
|
Details | Diff | Splinter Review |
new menu to represent and insert smileys
| Assignee | ||
Comment 1•25 years ago
|
||
Comment 2•25 years ago
|
||
This looks fine to me except I'm not sure I agree with the spaces inserted (in
editorOverlay.xul). Seems to me that we should either insert spaces before and
after or we shouldn't insert any spaces.
AIM 3.5.966 on Macintosh doesn't insert any spaces.
| Assignee | ||
Comment 4•25 years ago
|
||
Comment 5•25 years ago
|
||
Comments on the patch:
1. The smiley commands are not using the editor command handling mechanism. They
won't be enabled and disabled correctly (e.g. during document loading).
2. Need better names for the smileys. :( is "Smile6" for example. It should be
"Short frown" or something.
3. Why do the smileys insert a space before them? They should be smart about
this, depending on whether there is already a space before the insertion point.
A more worrysome aspect of this patch is that it introduces a dependency between
the editor and mailnews XUL files, since the EditorToolbars.css file contains
paths into the messenger jar. I think we should try to avoid this.
Comment 6•25 years ago
|
||
The patch doesn't apply for me: I get "**** malformed patch at line 96: Index:
mozilla/themes/classic/editor/EditorToolbars.css".
akk, if you are going from a windows patch to Linux, it almost never works. is
that the issue?
sfraser: could you explain how to correct the editor command handling mechanism
issue? anatoliy is new, and could use the help.
sfraser: we were told by UE to get this into the editor toolbar. maybe smilies
aren't used by all apps, but seems to me that with irc, chat, messenger, and im
already applications that use smilies and use composer, it doesn't seem
unreasonable that it be made available. I think even Word has support for
smilies in one way or another, surely if 3 our of 4 of the NS 6 apps have a need
for it, you guys should take a serious look at providing it as opposed to having
each of us roll it ourselves...
if that's the case, let's move the smilies into toolkit or comm. or you could
create a jar just for them...
Comment 9•25 years ago
|
||
Re: editor command handling mechanism. You should write your smiley insert as a
command, and register that command with the composer command handler. See
ComposerCommands.js for examples, and read <http://www.mozilla.org/editor/
editor_commands.html> to understand how this works. Your comamnd's
isCommandEnabled() method should figure out when the command should be enabled
(probably 'return (window.editorShell && window.editorShell.documentEditable);').
Its doCommand() method calls editorShell.insertText() with the appropriate smiley
string. To get the appropriate string, you can either use something like the
stateful command mechanism that stashes the smiley string on the command node,
and has the command retrieve it from there, or can implement a separate command
for each type of smiley. In future, commands will be able to take parameters, so
this will become easier.
As for where to put this stuff:
We certainly don't want to add a dependency between editor and messenger jar
files. Neither do we want this feature exposed in the composer UI. I suggest that
you add the GIFs to the communicator jar. It's also odd that you've added CSS to
EditorToolbars.css, but the buttons that are styled are not in editor XUL. It
would be perferable to find a better home for that CSS.
| Assignee | ||
Comment 10•25 years ago
|
||
| Assignee | ||
Comment 11•25 years ago
|
||
update includes:
- editor command handling mechanism,
- new location for CSS and images,
- "smart processing" for insertion
Comment 12•25 years ago
|
||
Simon, could you please review Anatoliya's patch? Thanks.
Status: NEW → ASSIGNED
Comment 13•25 years ago
|
||
Patch looks much better. My only qualms are with the call to
editorShell.GetContentsAs("text/plain", 8);
which is done to find out if there is a space at the end of the text.
editorShell.GetContentsAs() is a very expensive call for long document, and
calling it could produce noticable delay when the user chooses this command.
Also, you're trying to find if there is a space before hte insertion point, but
your code only looks for a space at the end of the entire document. What if the
insertion point isn't at the end?
ccing: akkana and jfrancis for ideas here. Talking with Joe, it seems hard to get
the char before the insertion point (what if you're just after a table?). There
is some code that could be refactored to ask "is previous char a space".
| Assignee | ||
Comment 14•25 years ago
|
||
| Assignee | ||
Comment 15•25 years ago
|
||
I added several features providing "smart" behavour for smiley insertion for any
document position (not just for end of document).
As a "side effect", editorShell.GetContentsAs call was eliminated,
also, there is no need to look for space, before the insertion point now.
Comment 16•25 years ago
|
||
Phew, big patch ;)
OK, we're getting closer. I do have some comments on the selection code tho.
In a number of cases you bail with an alert. I think showing an alert here is way
to "in your face" for the user; just fail silently. Or, if you really want to do
things right, test for these situations in the 'isCommandEnabled', and return
false if you're in a state where smiley insertion is not permitted. This code
should not be too expensive to call from isCommandEnabled.
Why disallow inserting smileys when the selection is not collapsed? It seems
reasonable to allow the user to select text, and replace it with a smiley.
You also check !selection.isCollapsed before checking if you have a selection.
The stuff to get the next/previous char is cool, but the last part that crawls up
the content tree seems a little excessive, and it's not clear what it's trying to
do. Does it just ensure that it will add a right space if you'are at the very end
of the doc? I'd be inclined to just remove that code.
Minor nit: there is some inconsistent spacing in the file.
| Assignee | ||
Comment 17•25 years ago
|
||
| Assignee | ||
Comment 18•25 years ago
|
||
New update includes:
- alerts are deleted;
- error handling was moved to isCommandEnabled
- remove code for last char finding 9I agree it is expensive)
- adjusted spacing
I left "collapsed condition"
(without that the procedure can become too complex)
Comment 19•25 years ago
|
||
That looks good. Just one more small thing! Your command's enabled state depends
on whether the selection is collapsed on not, yet your command won't be udpated
every time the selection changes. Only commands under a commandset whose events
include "style" get updated in this way. But I don't think you want to add your
command there, because we want to try to avoid the overhead of updating the
command every time the selection moves, and, since you have no button for this,
it doesn't matter. You just need to ensure that the command gets updated before
the user sees the menu.
So your <menupopup> needs an 'oncreate' handler that updates the state of
the command. That oncreate handler should call goUpdateCommand("cmd_smiley");
With this in place, you shoudl check that the menu items are appropriately
disabled when the selection is non-collapsed.
I still question why you are only allowing smiley insertion when the selection is
collapsed? Can you respond to that?
| Assignee | ||
Comment 20•25 years ago
|
||
| Assignee | ||
Comment 21•25 years ago
|
||
update:
- insertion of smiley images (not codes) to composer area
(works for any selection);
- smiley menu disable, when smiley images are disabled from prefs
Comment 22•25 years ago
|
||
OK, um, so if you insert images now, where (if anywhere) do they get converted to
strings when the message is sent? If they don't, can you be sure that the image
URLs are valid on the receiving end? And what if I insert a smiley into a mail
destined for a 4.x user?
| Assignee | ||
Comment 23•25 years ago
|
||
Sure, I am doing conversion images to text, but AFTER user pushes Send button.
(the user cannot edit message after that, of course). No images are sent to
remotely.
The same can be done for mail.
Comment 24•25 years ago
|
||
cc'ing to inform scott from mail team
Comment 25•25 years ago
|
||
But who says that the composer content will be sent by mail? The code is in
composer, so you can't guarantee that it won't be invoked by a user writing a web
page or generating content that is output by some other system that you don't
know about. I believe that I brought up this problem during the original
discussion of this (IMHO somewhat ill conceived) feature.
Comment 26•25 years ago
|
||
So, thinking a little more, I think the solution to this is to use CSS to somehow
style a span such that the content contains the smiley text, but the user sees
the image. I'm not quite sure how to best do this: ccing cmanske for input.
| Assignee | ||
Comment 27•25 years ago
|
||
Simon,
1. My decision is working fine for my applications.
2. As to mail:
a) Currently there is no Smiley menu at mail composer menu and on composer,
my code can be invoked JUST from Smiley menu;
b) if email will be sent, the same approach (text convertsion) can be used;
c) if it is NOT for remote user (like email), let's say for web page
composer, currently there is a feature "insert image". Everybody can
insert ANY image. Smiley feature works exactly like that, except, just
smiley images can be inserted. That is no reason to insert text instead of
image here (with span, for instance)
| Assignee | ||
Comment 28•25 years ago
|
||
One more thing:
I need to convert <span> element the same way like image element, before I send
it remotely, so I get no advantage from that
Comment 29•25 years ago
|
||
OK, so let's go with attachment 24243 [details] [diff] [review] (02/02/01) for now. sr=sfraser on that
patch.
Comment 30•25 years ago
|
||
IMO, this is a bad idea for Mozilla Mailnews. More later (hopefully).
| Assignee | ||
Comment 31•25 years ago
|
||
fixed
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Comment 32•25 years ago
|
||
Anatoliya, please verify this bug and mark VERIFIED-FIXED...thanks!
You need to log in
before you can comment on or make changes to this bug.
Description
•