Projet

Général

Profil

Révision da542b7b

Ajouté par Assos Assos il y a plus de 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/media_ckeditor/js/plugins/media/library.js
13 13
     */
14 14
    invoke: function (data, settings, instanceId) {
15 15
      if (data.format == 'html') {
16
        // CKEDITOR module support doesn't set this setting
17
        if (typeof settings['global'] === 'undefined') {
18
          settings['global'] = {id: 'media_wysiwyg'};
19
        }
20
        // If the selection is (or contains) an element with the attribute of
21
        // "data-media-element", assume the user wants to edit that thing.
22
        var $alreadyInsertedMedia;
16 23
        if (jQuery(data.node).is('[data-media-element]')) {
24
          $alreadyInsertedMedia = jQuery(data.node);
25
        }
26
        else {
27
          $alreadyInsertedMedia = jQuery(data.node).find('[data-media-element]');
28
        }
29
        if ($alreadyInsertedMedia.length) {
17 30
          // Change the view mode for already-inserted media.
18
          var mediaFile = Drupal.media.filter.extract_file_info(jQuery(data.node));
31
          var mediaFile = Drupal.media.filter.extract_file_info($alreadyInsertedMedia);
19 32
          Drupal.media.popups.mediaStyleSelector(mediaFile, function (mediaFiles) {
20 33
            Drupal.settings.ckeditor.plugins['media'].insertMediaFile(mediaFile, mediaFiles, CKEDITOR.instances[instanceId]);
21 34
          }, settings['global']);
......
46 59
      var element = Drupal.media.filter.create_element(formattedMedia.html, {
47 60
        fid: mediaFile.fid,
48 61
        view_mode: formattedMedia.type,
49
        attributes: formattedMedia.options
62
        attributes: mediaFile.attributes,
63
        fields: formattedMedia.options
50 64
      });
51 65

  
66
      var hasWidgetSupport = typeof(CKEDITOR.plugins.registered.widget) != 'undefined';
67

  
52 68
      // Use own wrapper element to be able to properly deal with selections.
53 69
      // Check prepareDataForWysiwygMode() in plugin.js for details.
54 70
      var wysiwygHTML = Drupal.media.filter.getWysiwygHTML(element);
55 71

  
56
      // Insert element. Use CKEDITOR.dom.element.createFromHtml to ensure our
57
      // custom wrapper element is preserved.
58 72
      if (wysiwygHTML.indexOf("<!--MEDIA-WRAPPER-START-") !== -1) {
59 73
        ckeditorInstance.plugins.media.mediaLegacyWrappers = true;
60 74
        wysiwygHTML = wysiwygHTML.replace(/<!--MEDIA-WRAPPER-START-(\d+)-->(.*?)<!--MEDIA-WRAPPER-END-\d+-->/gi, '');
61
      } else {
62
        wysiwygHTML = '<mediawrapper data="">' + wysiwygHTML + '</mediawrapper>';
63 75
      }
64 76

  
77
      // Insert element. Use CKEDITOR.dom.element.createFromHtml to ensure our
78
      // custom wrapper element is preserved.
65 79
      var editorElement = CKEDITOR.dom.element.createFromHtml(wysiwygHTML);
66 80
      ckeditorInstance.insertElement(editorElement);
67 81

  
68 82
      // Initialize widget on our html if possible.
69
      if (parseFloat(CKEDITOR.version) >= 4.3 && typeof(CKEDITOR.plugins.registered.widget) != 'undefined') {
83
      if (parseFloat(CKEDITOR.version) >= 4.3 && hasWidgetSupport) {
70 84
        ckeditorInstance.widgets.initOn( editorElement, 'mediabox' );
85

  
86
        // Also support the image2 plugin.
87
        ckeditorInstance.widgets.initOn( editorElement, 'image' );
71 88
      }
72 89
    },
73 90

  

Formats disponibles : Unified diff