If you try to drop an atom into a summary field of a text and summary field, then it will fail with a javascript error.

A solution from @gifad:
Text and summary solved by this patch to mee.module :

function mee_field_widget_form_alter(&$element, &$form_state, $context) {
...
   // Activate DnD Library for this element if enabled.
   if (!empty($enables['dnd'])) {
-    // Force an #id so that we can reference to it later
-    $element['#id'] = drupal_html_id('edit-' . $context['field']['field_name']);
-    $element += array(
-      '#dnd-enabled' => TRUE,
-      '#dnd-settings' => array(
-        'drop_selector' => '#' . $element['#id'] . ' .drop',
-      ),
-    );
+    $fieldname = $element['#field_name'];
+    $language = $element['#language'];
+    $settings = $form_state['field'][$fieldname][$language]['instance']['settings'];
+    $context_default = isset($settings['context_default']) ? 
+       $settings['context_default'] : 
+       variable_get('dnd_context_default', 'sdl_editor_representation');
+  //uncomment when dnd_process_textarea removed from dnd.module
+  //$element['#attached']['library'][] = array('dnd', 'library');
+  //$element['#attributes']['data-dnd-context'][] = $context_default;
+    if (isset($element['summary']))
+      $element['summary']['#attributes']['data-dnd-context'][] = $context_default;
  }

and then remove dnd_element_info_alter() and dnd_process_textarea()

CommentFileSizeAuthor
#2 2407023-scald-summary-broken-2.patch3.32 KBgifad

Comments

gifad’s picture

thanks nagy.balint;
another addition is needed to complete summary handling, as pointed out by yched in #60, about tracking resources;
also in mee.module :

 function _mee_process_item_value(&$item, $entity_type, $entity, $field, $delta) {
   if (mee_store_format() == 'embed_div') {
     $sids = array();
     $copyrights = array();
     // Collect the emebed data.
     foreach (_mee_extract_widget_embed_info(filter_dom_load($item['value'])) as $info) {
       $sids[] = $info['sid'];
       $copyrights[$info['sid']] = $info['caption'];
     }
+    if (!empty($item['summary'])) {
+      foreach (_mee_extract_widget_embed_info(filter_dom_load($item['summary'])) as $info) {
+        $sids[] = $info['sid'];
+        $copyrights[$info['sid']] = $info['caption'];
+      }
+    }
     $sids = array_unique($sids);
   }
gifad’s picture

Status: Active » Needs review
StatusFileSize
new3.32 KB

Here is a real patch, including dnd.module cleanup...

nagy.balint’s picture

I checked, it works fine for me under firefox, chrome and ckeditor 4.4.6.

Can you tell me where this was used before?

-    // Force an #id so that we can reference to it later
-    $element['#id'] = drupal_html_id('edit-' . $context['field']['field_name']);
-    $element += array(
-      '#dnd-enabled' => TRUE,
-      '#dnd-settings' => array(
-        'drop_selector' => '#' . $element['#id'] . ' .drop',
-      ),
-    );
gifad’s picture

@nagy.balint

Can you tell me where this was used before?

The #id and #dnd-enabled was for dnd.module : process_textarea() to identify element
I suppose it was there because dnd does not depend on mee, so it could not test 'dnd-enabled' itself ?
But if mee.module is not enabled, 'dnd-enabled' checkbox does not even exist...

the drop_selector was qualified as "dead code" by yched recently (#60)...
I could not find any reference in scald package, and no other scald related module I know of...

nagy.balint’s picture

Okey, thanks for the explanation.

nagy.balint’s picture

@yched : can you review this patch as well? Then we could put this on RTBC.

  • nagy.balint committed 2a00863 on 7.x-1.x authored by gifad
    Issue #2407023 by gifad: CKEditor: dragging into a summary field of a...
nagy.balint’s picture

Status: Needs review » Fixed

Since it was already reviewed by gifad, and me. And there was no negative comment since, i think its safe to commit.
Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.