summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordeciphered2017-08-18 02:52:49 (GMT)
committerolstjos2017-08-18 02:52:49 (GMT)
commit91311eb649057fea87cb9d23e449d42ff1983246 (patch)
treef0fdfe4f9299600f4d3914e3cc9df8da44735d8c
parenta10ef32fe7bb02f5ae6f0d6b297034b346413b2c (diff)
Issue #2355961 by Deciphered, joseph.olstad: Use selected editor text as media file link text
-rw-r--r--modules/media_wysiwyg/js/wysiwyg-media.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/modules/media_wysiwyg/js/wysiwyg-media.js b/modules/media_wysiwyg/js/wysiwyg-media.js
index 31cac5c..87ac8cc 100644
--- a/modules/media_wysiwyg/js/wysiwyg-media.js
+++ b/modules/media_wysiwyg/js/wysiwyg-media.js
@@ -14,6 +14,11 @@ Drupal.media = Drupal.media || {};
Drupal.wysiwyg.plugins.media = {
/**
+ * The selected text string.
+ */
+ selectedText: null,
+
+ /**
* Determine whether a DOM element belongs to this plugin.
*
* @param node
@@ -51,6 +56,9 @@ Drupal.wysiwyg.plugins.media = {
insert.onSelect([media_file]);
}
else {
+ // Store currently selected text.
+ this.selectedText = data.content;
+
// Insert new media.
insert.prompt(settings.global);
}
@@ -118,7 +126,8 @@ InsertMedia.prototype = {
fid: this.mediaFile.fid,
view_mode: formatted_media.type,
attributes: this.mediaFile.attributes,
- fields: formatted_media.options
+ fields: formatted_media.options,
+ link_text: Drupal.wysiwyg.plugins.media.selectedText
});
// Get the markup and register it for the macro / placeholder handling.
var markup = Drupal.media.filter.getWysiwygHTML(element);