From ca3697ae3aed79c73de1afca94d4bf8dc229cd3d Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 10 Jan 2018 11:49:16 +0100 Subject: [PATCH] implement extension point for share menu --- www/common/common-ui-elements.js | 6 ++++++ www/common/toolbar3.js | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 90e554d31..75c4fe31a 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -859,9 +859,14 @@ define([ if (typeof config !== "object" || !Array.isArray(config.options)) { return; } if (config.feedback && !config.common) { return void console.error("feedback in a dropdown requires sframe-common"); } + var isElement = function (o) { + return /HTML/.test(Object.prototype.toString.call(o)) && + typeof(o.tagName) === 'string'; + }; var allowedTags = ['a', 'p', 'hr']; var isValidOption = function (o) { if (typeof o !== "object") { return false; } + if (isElement(o)) { return true; } if (!o.tag || allowedTags.indexOf(o.tag) === -1) { return false; } return true; }; @@ -893,6 +898,7 @@ define([ config.options.forEach(function (o) { if (!isValidOption(o)) { return; } + if (isElement(o)) { return $innerblock.append($(o)); } $('<' + o.tag + '>', o.attributes || {}).html(o.content || '').appendTo($innerblock); }); diff --git a/www/common/toolbar3.js b/www/common/toolbar3.js index 2d4dccd63..6a0016fcf 100644 --- a/www/common/toolbar3.js +++ b/www/common/toolbar3.js @@ -8,7 +8,8 @@ define([ '/common/common-feedback.js', '/customize/messages.js', '/common/clipboard.js', -], function ($, Config, ApiConfig, UIElements, UI, Hash, Feedback, Messages, Clipboard) { + '/common/hyperscript.js', +], function ($, Config, ApiConfig, UIElements, UI, Hash, Feedback, Messages, Clipboard, h) { var Common; var Bar = { @@ -496,6 +497,9 @@ define([ content: ' ' + Messages.getEmbedCode }); } + if (typeof(Config.customizeShareOptions) === 'function') { + Config.customizeShareOptions(hashes, options); + } var dropdownConfigShare = { text: $('
').append($shareIcon).html(), options: options,