HUH, this can really shoot you in the knee:
* edit a node that has a textformat without linkit support (or without wysiwyg)
* switch to a textformat with wysiwyg linkit button
* select text and click linkit button

expected: linkit dialog
result: Alert box "Could not fild linkit profile"

Saving the node with the text format and re-editing worksaround the issue.

Comments

geek-merlin’s picture

What i missed for years: *Many thanks for this great module!!*
;-)

geek-merlin’s picture

Title: Linkit editor button alerts "Could not fild linkit profile" if loaded textformat did not have linkit support » Linkit editor button alerts "Could not fild linkit profile" after wysiwyg textformat switch

Some research shows the flaw lies here. I think to support textformat switching JS settings must have the whole array textformat => linkit-profile, not just the linkit profile for the original textformat.

/**
 * Add Linkit settings to pages where we have an editor element.
 */
function linkit_pre_render_editor_element($element) {
  static $processed = array();

  if (!isset($processed[$element['#id']])) {
    // Load the first profile that is assign to this text format.
    $profile = linkit_profile_load_by_format($element['#format']);

    // If we dont have any profile, lets just return the element.
    if (!$profile) {
      return $element;
    }

    // Set the field ID.
    $field_id = $element['#id'] . '-value';

    $field_js = array(
      'data' => array(
        'linkit' => array(
          'fields' => array(
            $field_id => array(
              'profile' => $profile->name,
            ),
          ),
        ),
      ),
      'type' => 'setting',
    );

anon’s picture

Priority: Major » Normal
Issue summary: View changes

Thanks for your appreciation.

This issue is confirmed.
Tho I don't have any ideas on how to solve it now.

The problem is that only the base element is sent to linkit_pre_render_editor_element().
and if that field doesn't have a profile assigned to itself, we just skip the rest.

When switching between text formats in the select list, it is only js stuff going on, and we can't add our settings then.

SebCorbin’s picture

StatusFileSize
new527 bytes

Here's a possible patch that solve a similar problem

jrabeemer’s picture

I can confirm this "bug". If you have "Filtered" and "Full HTML" enabled and toggle that filter on a new node @ /node/add/XXXXX, Linkit will fail. The enabled filter type where Linkit is configured must be set on the node, by default or by saving the node with that type, for it to work.

SebCorbin’s picture

Status: Active » Needs review
StatusFileSize
new770 bytes

Updated patch fixing notice when no $element['value']['#id'] is set

aasarava’s picture

#6 works to fix the problem with the linkit button not opening a popup at all (#2124127). Thanks! (Edit: Can't repeat this, so it was perhaps flushing cache or reinstalling the module that fixed that problem.)

I'm now trying to apply #6 to the latest dev and now it's not allowing the Linkit dialog to pop open at all. With the patch applied, I get the dreaded "Could not find the Linkit profile" alert for any input format.

anon’s picture

askibinski’s picture

FYI: I believe this issue also occurs on the core Drupal "body-summary" field.

anon’s picture

Status: Needs review » Needs work

The patch in #6 doesn't solves the problem.

toby wild’s picture

I can confirm Anon's comment.

Patch #6 doesn't solve the problem in linkit-7.x-3.0 or linkit-7.x-3.1

fabianvdbor’s picture

I have a patch that solves the problem in the by linkit-7.x-3.2.

askibinski’s picture

related:
#1912780: Enable linkit for Long text and summary fields
(same js error but different cause)

askibinski’s picture

edit: deleted double post (drupal.org was down)

anon’s picture

The patch in #12 doesn't solved the real problem. See #2319721: Wrong element id when it is not the default value

The last submitted patch, 6: 2115763-6-linkit_missing_profile_format.patch, failed testing.

mcrittenden’s picture

Title: Linkit editor button alerts "Could not fild linkit profile" after wysiwyg textformat switch » Linkit editor button errors out after switching WYSIWYG text format
mcrittenden’s picture

Status: Needs work » Needs review
StatusFileSize
new5.75 KB

Here's a patch which, for editor/format-based Linkit profiles (as opposed to field-based Linkit profiles), rethinks things to be based on format rather than on element, so that when the format for any given element is switched, it just looks up the Linkit profile for the new format and uses that.

Note that this has been tested more thoroughly on WYSIWYG/TinyMCE than it has on WYSIWYG/CKEditor or CKEditor module.

dsnopek’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +panopoly

The patch in #18 works in my testing! We're going to start using this in Panopoly soon.

The last submitted patch, 4: 2115763-4-linkit_missing_profile_format.patch, failed testing.

The last submitted patch, 12: 2115763-12-linkit_missing_profile_format.patch, failed testing.

hnln’s picture

#18 works for me 2. For me the linkit button was working in ckeditor for non fields (custom forms, ...), but got js errors when trying to use on body or long text fields with a linkit associated wysiwyg profile. Patch fixed that.

  • anon committed f03cde2 on 7.x-3.x authored by mcrittenden
    Issue #2115763 by SebCorbin, mcrittenden, fabianvdbor: Linkit editor...
anon’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for all the hard work on this one. I really appreciate it. This is now committed to the 7.x-dev. Thanks again.

Status: Fixed » Closed (fixed)

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