Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Scald drag and drop feature is great, but, depending on operating conditions, some users may feel more comfortable with a more classic gesture, double click for instance, to insert an atom from scald library.
Comments
Comment #1
gifad CreditAttribution: gifad commentedThe attached patch allows user to double click the image of an atom in the library widget, to insert it at the last insertion point defined in the active ckeditor instance.
Comment #2
gifad CreditAttribution: gifad commentedGo a step farther, and finally insert an “Insert” button...
PS: This patch was generously sponsored by the Image Assist D6 Veterans Association ;-)
Comment #3
jcisio CreditAttribution: jcisio commentedPatch looks good. A small add-on: will we be able to make it work without CKEditor (a plain textarea)?
Comment #4
gifad CreditAttribution: gifad commentedA small add-on ?
I could not find the equivalent of “ckeditorInstance” for plain textareas, so I had to make it myself...
Then, I realized “insertHtml” is a ckeditor function, so I had to make it myself again (well, with google's help...)
So I'm not sure that “Patch looks good.”
But it works ;-)
Comment #5
jcisio CreditAttribution: jcisio commentedWell, coding standards are not respected in copied snippet. Also, I think you can use Drupal.getSelection (it is used nowhere in core and is removed in D8, but it is still there in D7) to make your code shorter. Besides, we try to not introduce global variables/functions, put them in Drupal.dnd for example. Then we are good. This is a useful feature, because currently dnd does not work well with touch screens (the touch events).
Comment #6
gifad CreditAttribution: gifad commentedI don't know how to use Drupal.getSelection to make my code shorter, but fixed the other issues.
BTW, if you “try to not introduce global...”, you could add this to the patch :
Comment #7
jcisio CreditAttribution: jcisio commentedNew patch:
- Refactoring and move functions into Drupal.dnd (so that it could be overriden if necessary).
- Use editor.insertElement instead of editor.insertHtml (thanks to StackOverflow) so that we can remove the
<p> </p>
hack. I don't modify current code BTW.- Change the "insert" link name/class to avoid collision.
I only tested with Chrome/Linux so I think it would be tested more. Bugs that need to be fixed:
- Can not insert into a textfield.
- Do not use HTML markup, use SAS instead when insert into textarea/textfield.
Minor bug, but nice to eliminate:
- When the cursor is in the legend area, it creates "atom inside atom".
Comment #8
gifad CreditAttribution: gifad commentedI won't review your patch tonight, but i'll comment two of your comments:
I did not mentioned it, as the legend is reasonably editable only in wywiwyg mode, not in the awful "Edit atom properties".
BTW, I'm working on a “addRef” link, to insert atom in a Atom Reference Field (the one with “Drop a ressource here”) : One of the problems is the space left in the library widget : use icon buttons ? CTools buttons ?
Comment #9
jcisio CreditAttribution: jcisio commentedFor text input, we don't have to duplicate. I believe something like
$('textarea, input[type="text"]')
would work. Needs test BTW, because type="text" is the default, so we have to take care of the case where there is no "type", too.About the "bug" (or feature...), I don't care to fix it right now. It is left outside the "bugs that need to be fixed" group. Maybe it is an expected feature. But yesterday when I tested, I clicked "insert" once, one atom was inserted and the caret was placed in the legend. I clicked "insert" again for another atom, then it was placed in the legend. The expected behavior is to place it next to the other atom.
Comment #10
jcisio CreditAttribution: jcisio commentedComment #11
gifad CreditAttribution: gifad commentedLegend “unattended” processing works far better with the alternate legend layout suggested a couple of weeks ago in Edit atom legend in wysiwyg mode:
This makes easier for ckeditor to set caret position in the DOM (a single div is possible);
Also, everything with atoms work better if CKEditor “Enter mode” is set to "div" (instead of "p" or "br") but this needs educated contributors...
Comment #12
A-snowboard CreditAttribution: A-snowboard commentedI subscribe to this post because I am very interested.
In a few days I have time to test your patch.
Comment #13
gifad CreditAttribution: gifad commentedFixed.
BTW, I use $('textarea, .form-type-textfield input') to select textareas and textfields.
Comment #14
jcisio CreditAttribution: jcisio commented#13: scald-use-double-click-in-addition-to-dnd-2073413-13.patch queued for re-testing.
Comment #16
jcisio CreditAttribution: jcisio commentedReroll 13.
Comment #17
jcisio CreditAttribution: jcisio commentedComment #18
slybud CreditAttribution: slybud commentedOk I've thoroughly tested this patch against this configuration
Everything works fine and as described for the following use cases :
The only use case not working is when a content type mixes plain text and ckeditor field instances (in thaa case tou can not retain focus in simple textareas, media always get inserted into ckeditor fields)=> don't think this is a use case to consider, so I would be in favor of passing this patch to RTBC IMHO !
Comment #19
jcisio CreditAttribution: jcisio commentedNice to see that it works almost everywhere. Now just need to fix the last reported bug. I think in the "mixed case", we should keep trace of the type of the last focus element.
Comment #20
DeFr CreditAttribution: DeFr commentedHere's a re-roll that should handle mix-mode.
Comment #21
slybud CreditAttribution: slybud commentedOk great news guyz :
Great job everyone and moving this to RTBC !
Comment #22
jcisio CreditAttribution: jcisio commentedThanks all! Committed fd91aef and pushed. It solves multiple problems at one: IE8 compatibility, insert an atom inside another atom.