diff --git a/sites/all/modules/contrib/fields/linkit/README.md b/sites/all/modules/contrib/fields/linkit/README.md index 7f610ba71..687ce4b3f 100644 --- a/sites/all/modules/contrib/fields/linkit/README.md +++ b/sites/all/modules/contrib/fields/linkit/README.md @@ -1,33 +1,54 @@ Linkit =========== -Linkit provides an **enriched linking experience for internal and external -linking** with editors by using an autocomplete field. Linkit has by default -support for nodes, users, taxonomy terms, files, comments and -**basic support for all types of entities** that defines a canonical link -template. +Linkit provides an **enriched linking experience for internal and +external linking** with editors by using an autocomplete field. Linkit +has by default support for nodes, users, taxonomy terms, files, +comments and **basic support for all types of entities** that defines a +canonical link template. Installation ------------ * Normal module installation procedure. See - https://www.drupal.org/documentation/install/modules-themes/modules-8 +https://www.drupal.org/documentation/install/modules-themes/modules-8 + +* **Enable Linkit** +To enable Linkit, go to `/admin/config/content/formats` and edit the +desired text format you want to enable Linkit for. Linkit will alter +the default link plugin, so make sure that it is enabled. When the +default link plugin is enabled, you will have to select a Linkit +profile to use in the "Drupal link" tab under the toolbar configuration. + +* **Enable Linkit filter** +Linkit will insert URLs in a format like "entity:node/1". The Linkit +filter will then transform that URL into a "real" URL when rendering +the text. **Note: The Linkit filter must run before "Limit allowed HTML +tags and correct faulty HTML"**. + +* If the **Limit allowed HTML tags and correct faulty HTML** filter is +enabled, add *data-entity-type* and *data-entity-uuid* to the `` tag +in the *Allowed HTML* tags (i.e. ``). + +* (optional) **Use automatic titles with the Linkit filter** +If automatic titles is enabled in the Linkit filter settings, and +**Limit allowed HTML tags and correct faulty HTML** is enabled, add +*title* to the `` tag in the *Allowed HTML* tags (i.e. +``). Configuration ------------ -After the installation, you have to create a Linkit profile. The profile will -contain information about which plugins to use. -Profiles can be created at `/admin/config/content/linkit` +A default Linkit profile will have been installed as a step in the +module installation process. The profile will contain information about +which plugins to use. -When you have created a profile, you need to enable the Linkit plugin on the -text format you want to use. Formats are found at -`admin/config/content/formats`. +You can create additional profiles at `/admin/config/content/linkit`. Plugins examples ------------ -There are plugin implementation examples in the linkit_test module bundled with -Linkit core. +There are plugin implementation examples in the linkit_test module +bundled with Linkit core. diff --git a/sites/all/modules/contrib/fields/linkit/config/optional/linkit.linkit_profile.default.yml b/sites/all/modules/contrib/fields/linkit/config/optional/linkit.linkit_profile.default.yml new file mode 100644 index 000000000..7aa4092fa --- /dev/null +++ b/sites/all/modules/contrib/fields/linkit/config/optional/linkit.linkit_profile.default.yml @@ -0,0 +1,19 @@ +langcode: en +status: true +dependencies: + module: + - node +id: default +label: Default +description: 'A default Linkit profile' +matchers: + 556010a3-e317-48b3-b4ed-854c10f4b950: + uuid: 556010a3-e317-48b3-b4ed-854c10f4b950 + id: 'entity:node' + weight: 0 + settings: + metadata: 'by [node:author] | [node:created:medium]' + bundles: { } + group_by_bundle: false + include_unpublished: false + substitution_type: canonical diff --git a/sites/all/modules/contrib/fields/linkit/config/schema/linkit.schema.yml b/sites/all/modules/contrib/fields/linkit/config/schema/linkit.schema.yml index 1e63f0262..882a2f1cb 100644 --- a/sites/all/modules/contrib/fields/linkit/config/schema/linkit.schema.yml +++ b/sites/all/modules/contrib/fields/linkit/config/schema/linkit.schema.yml @@ -10,43 +10,11 @@ linkit.linkit_profile.*: type: string description: type: string - attributes: - type: sequence - sequence: - type: linkit.attribute matchers: type: sequence sequence: type: linkit.matcher -linkit.attribute: - type: mapping - mapping: - id: - type: string - settings: - type: linkit.attribute.[%parent.id] - weight: - type: integer - -linkit.attribute.*: - type: mapping - label: 'Attribute settings' - -# Plugin \Drupal\linkit\Plugin\Linkit\Attribute\Target -linkit.attribute.target: - type: linkit.attribute - mapping: - widget_type: - type: string - -# Plugin \Drupal\linkit\Plugin\Linkit\Attribute\Title -linkit.attribute.title: - type: linkit.attribute - mapping: - automatic_title: - type: boolean - linkit.matcher: type: mapping mapping: @@ -66,7 +34,7 @@ linkit.matcher.*: linkit.matcher.entity: type: mapping mapping: - result_description: + metadata: type: string bundles: type: sequence @@ -75,6 +43,8 @@ linkit.matcher.entity: nullable: true group_by_bundle: type: boolean + substitution_type: + type: string linkit.matcher.entity:*: type: linkit.matcher.entity @@ -83,6 +53,11 @@ linkit.matcher.entity:*: linkit.matcher.entity:file: type: linkit.matcher.entity mapping: + file_extensions: + type: string + file_status: + type: integer + default: 1 images: type: mapping mapping: @@ -113,19 +88,25 @@ linkit.matcher.entity:user: include_blocked: type: boolean -# Third party settings on behalf of the imce module. -linkit.linkit_profile.*.third_party.imce: - type: mapping +# Plugin \Drupal\linkit\Plugin\Filter\LinkitFilter +filter_settings.linkit: + type: filter + label: 'Linkit' mapping: - use: + title: type: boolean - scheme: - type: string + label: 'Automatically set the "title" attribute' -ckeditor.plugin.linkit: +# Plugin \Drupal\ckeditor\Plugin\CKEditorPlugin\DrupalLink +# Linkit alters the plugin to save Linkit specific information used by the +# altered plugin. +ckeditor.plugin.drupallink: type: mapping - label: 'Profile dropdown' + label: 'Drupal link' mapping: + linkit_enabled: + type: boolean + label: 'Use Linkit' linkit_profile: type: string - label: 'List of profiles' + label: 'Linkit profile' diff --git a/sites/all/modules/contrib/fields/linkit/css/linkit.admin.theme.css b/sites/all/modules/contrib/fields/linkit/css/linkit.admin.theme.css index c4afd11b9..7a668a78e 100644 --- a/sites/all/modules/contrib/fields/linkit/css/linkit.admin.theme.css +++ b/sites/all/modules/contrib/fields/linkit/css/linkit.admin.theme.css @@ -9,7 +9,6 @@ line-height: 1.2em; } -.linkit-matcher-add-form tbody td:first-child, -.linkit-attribute-add-form tbody td:first-child { +.linkit-matcher-add-form tbody td:first-child { width: 1%; } diff --git a/sites/all/modules/contrib/fields/linkit/css/linkit.autocomplete.css b/sites/all/modules/contrib/fields/linkit/css/linkit.autocomplete.css index 806e98a2e..4159a495f 100644 --- a/sites/all/modules/contrib/fields/linkit/css/linkit.autocomplete.css +++ b/sites/all/modules/contrib/fields/linkit/css/linkit.autocomplete.css @@ -3,48 +3,55 @@ * Stylesheet for the Linkit module. */ .js input.form-linkit-autocomplete { - background-image: url(/core/misc/throbber-inactive.png); + background-image: url(../images/throbber-inactive.png); background-position: 100% center; /* LTR */ background-repeat: no-repeat; } + .js[dir="rtl"] input.form-linkit-autocomplete { - background-position: 0% center; + background-position: 0 center; } + .js input.form-linkit-autocomplete.ui-autocomplete-loading { - background-image: url(/core/misc/throbber-active.gif); + background-image: url(../images/throbber-active.gif); background-position: 100% center; /* LTR */ } + .js[dir="rtl"] input.form-linkit-autocomplete.ui-autocomplete-loading { - background-position: 0% center; + background-position: 0 center; } /* Override the default jQuery UI theme */ .linkit-ui-autocomplete { - max-height: 330px; + max-height: calc((100vh - 80px)/2); overflow: auto; } -.linkit-ui-autocomplete.ui-widget { + +.linkit-ui-autocomplete.ui-widget { font-size: .9em; } -.linkit-ui-autocomplete.ui-menu .ui-menu-item { - list-style: none; +.linkit-ui-autocomplete.ui-menu .linkit-result-line-wrapper { + margin: 0; padding: 5px 7px; } -.linkit-ui-autocomplete .ui-menu-item.ui-state-focus { - margin: 0; +.linkit-ui-autocomplete.ui-menu .linkit-result-line-wrapper.ui-state-focus, +.linkit-ui-autocomplete.ui-menu .linkit-result-line-wrapper.ui-state-active { border: 0; border-bottom: 1px solid #bfbfbf; background: #0075ba; color: #fff; } -.linkit-result:not(:last-of-type) { +.linkit-result-line:not(:last-of-type) { border-bottom: 1px solid #bfbfbf; } -.linkit-result--group { +.ui-menu .linkit-result-line--group.ui-menu-divider { + margin: 0; + height: auto; + line-height: inherit; padding: 3px; background-color: #e7e7e7; border-bottom: 1px solid #bfbfbf; @@ -54,16 +61,17 @@ color: #555; } -.linkit-result--title { +.linkit-result-line--title { + display: block; font-weight: 600; } -.linkit-result--description { +.linkit-result-line--description { display: block; font-size: 0.9em; line-height: 1.3; } -.linkit-result--description img { +.linkit-result-line--description img { display: block; } diff --git a/sites/all/modules/contrib/fields/linkit/images/throbber-active.gif b/sites/all/modules/contrib/fields/linkit/images/throbber-active.gif new file mode 100644 index 000000000..abf5c5d5b Binary files /dev/null and b/sites/all/modules/contrib/fields/linkit/images/throbber-active.gif differ diff --git a/sites/all/modules/contrib/fields/linkit/images/throbber-inactive.png b/sites/all/modules/contrib/fields/linkit/images/throbber-inactive.png new file mode 100644 index 000000000..befbb9f0a Binary files /dev/null and b/sites/all/modules/contrib/fields/linkit/images/throbber-inactive.png differ diff --git a/sites/all/modules/contrib/fields/linkit/js/attribute/title.js b/sites/all/modules/contrib/fields/linkit/js/attribute/title.js deleted file mode 100644 index a2bb7a134..000000000 --- a/sites/all/modules/contrib/fields/linkit/js/attribute/title.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @file - * Title attribute functions. - */ - -(function ($, Drupal, document) { - - 'use strict'; - - var fieldName = '[name="attributes[title]"]'; - - /** - * Automatically populate the title attribute. - */ - $(document).bind('linkit.autocomplete.select', function (triggerEvent, event, ui) { - if (ui.item.hasOwnProperty('title')) { - $('form.linkit-editor-dialog-form').find(fieldName).val(ui.item.title); - } - }); - -})(jQuery, Drupal, document); diff --git a/sites/all/modules/contrib/fields/linkit/js/autocomplete.js b/sites/all/modules/contrib/fields/linkit/js/autocomplete.js index 34e6e11a8..558278ddf 100644 --- a/sites/all/modules/contrib/fields/linkit/js/autocomplete.js +++ b/sites/all/modules/contrib/fields/linkit/js/autocomplete.js @@ -3,7 +3,7 @@ * Linkit Autocomplete based on jQuery UI. */ -(function ($, Drupal, _, document) { +(function ($, Drupal, _) { 'use strict'; @@ -13,7 +13,9 @@ * JQuery UI autocomplete source callback. * * @param {object} request + * The request object. * @param {function} response + * The function to call with the response. */ function sourceData(request, response) { var elementId = this.element.attr('id'); @@ -22,21 +24,15 @@ autocomplete.cache[elementId] = {}; } - /** - * @param {object} suggestions - */ - function showSuggestions(suggestions) { - response(suggestions.matches); - } - /** * Transforms the data object into an array and update autocomplete results. * * @param {object} data + * The data sent back from the server. */ function sourceCallbackHandler(data) { - autocomplete.cache[elementId][term] = data; - showSuggestions(data); + autocomplete.cache[elementId][term] = data.suggestions; + response(data.suggestions); } // Get the desired term and construct the autocomplete URL for it. @@ -44,27 +40,48 @@ // Check if the term is already cached. if (autocomplete.cache[elementId].hasOwnProperty(term)) { - showSuggestions(autocomplete.cache[elementId][term]); + response(autocomplete.cache[elementId][term]); } else { - var options = $.extend({success: sourceCallbackHandler, data: {q: term}}, autocomplete.ajax); + var options = $.extend({ + success: sourceCallbackHandler, + data: {q: term} + }, autocomplete.ajax); $.ajax(this.element.attr('data-autocomplete-path'), options); } } /** - * Handles an autocomplete select event. - * - * @param {jQuery.Event} event - * @param {object} ui - * - * @return {boolean} - */ + * Handles an autocomplete select event. + * + * @param {jQuery.Event} event + * The event triggered. + * @param {object} ui + * The jQuery UI settings object. + * + * @return {boolean} + * False to prevent further handlers. + */ function selectHandler(event, ui) { - if (ui.item.hasOwnProperty('path')) { - event.target.value = ui.item.path; + var $form = $(event.target).closest('form'); + if (!ui.item.path) { + throw 'Missing path param.' + JSON.stringify(ui.item); } - $(document).trigger('linkit.autocomplete.select', [event, ui]); + + $('input[name="href_dirty_check"]', $form).val(ui.item.path); + + if (ui.item.entity_type_id || ui.item.entity_uuid || ui.item.substitution_id) { + if (!ui.item.entity_type_id || !ui.item.entity_uuid || !ui.item.substitution_id) { + throw 'Missing path param.' + JSON.stringify(ui.item); + } + + $('input[name="attributes[data-entity-type]"]', $form).val(ui.item.entity_type_id); + $('input[name="attributes[data-entity-uuid]"]', $form).val(ui.item.entity_uuid); + $('input[name="attributes[data-entity-substitution]"]', $form).val(ui.item.substitution_id); + } + + event.target.value = ui.item.path; + return false; } @@ -74,18 +91,20 @@ * @param {object} ul * The