implement extension point for share menu

pull/1/head
ansuz 7 years ago committed by Caleb James DeLisle
parent 5346afe51f
commit ca3697ae3a

@ -859,9 +859,14 @@ define([
if (typeof config !== "object" || !Array.isArray(config.options)) { return; } 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"); } 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 allowedTags = ['a', 'p', 'hr'];
var isValidOption = function (o) { var isValidOption = function (o) {
if (typeof o !== "object") { return false; } if (typeof o !== "object") { return false; }
if (isElement(o)) { return true; }
if (!o.tag || allowedTags.indexOf(o.tag) === -1) { return false; } if (!o.tag || allowedTags.indexOf(o.tag) === -1) { return false; }
return true; return true;
}; };
@ -893,6 +898,7 @@ define([
config.options.forEach(function (o) { config.options.forEach(function (o) {
if (!isValidOption(o)) { return; } if (!isValidOption(o)) { return; }
if (isElement(o)) { return $innerblock.append($(o)); }
$('<' + o.tag + '>', o.attributes || {}).html(o.content || '').appendTo($innerblock); $('<' + o.tag + '>', o.attributes || {}).html(o.content || '').appendTo($innerblock);
}); });

@ -8,7 +8,8 @@ define([
'/common/common-feedback.js', '/common/common-feedback.js',
'/customize/messages.js', '/customize/messages.js',
'/common/clipboard.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 Common;
var Bar = { var Bar = {
@ -496,6 +497,9 @@ define([
content: '<span class="fa fa-eye"></span> ' + Messages.getEmbedCode content: '<span class="fa fa-eye"></span> ' + Messages.getEmbedCode
}); });
} }
if (typeof(Config.customizeShareOptions) === 'function') {
Config.customizeShareOptions(hashes, options);
}
var dropdownConfigShare = { var dropdownConfigShare = {
text: $('<div>').append($shareIcon).html(), text: $('<div>').append($shareIcon).html(),
options: options, options: options,

Loading…
Cancel
Save