API Move ssmedia plugin to asset-admin

This commit is contained in:
Damian Mooyman 2017-02-27 10:58:41 +13:00
parent 1d49c4afe9
commit b3fc11e594
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A
10 changed files with 16 additions and 189 deletions

View File

@ -1,7 +1,5 @@
webpackJsonp([2],[function(n,i){"use strict"
!function(){var n={getInfo:function i(){return{longname:"Insert link for SilverStripe CMS",author:"Sam Minnée",authorurl:"http://www.siverstripe.com/",infourl:"http://www.silverstripe.com/",version:"1.1"
}},init:function e(n){n.addButton("sslink",{icon:"link",title:"Insert Link",cmd:"sslink"}),n.addMenuItem("sslink",{icon:"link",text:"Insert Link",cmd:"sslink"}),n.addCommand("sslink",function(){window.jQuery("#"+n.id).entwine("ss").openLinkDialog()
}),n.on("BeforeExecCommand",function(i){var e=i.command,t=i.ui,o=i.value
"mceAdvLink"!==e&&"mceLink"!==e||(i.preventDefault(),n.execCommand("sslink",t,o))})}}
!function(){var n={init:function i(n){n.addButton("sslink",{icon:"link",title:"Insert Link",cmd:"sslink"}),n.addMenuItem("sslink",{icon:"link",text:"Insert Link",cmd:"sslink"}),n.addCommand("sslink",function(){
window.jQuery("#"+n.id).entwine("ss").openLinkDialog()}),n.on("BeforeExecCommand",function(i){var e=i.command,t=i.ui,s=i.value
"mceAdvLink"!==e&&"mceLink"!==e||(i.preventDefault(),n.execCommand("sslink",t,s))})}}
tinymce.PluginManager.add("sslink",function(i){return n.init(i)})}()}])

View File

@ -1,4 +1,4 @@
webpackJsonp([4],[function(e,n,t){"use strict"
webpackJsonp([3],[function(e,n,t){"use strict"
function i(e){return e&&e.__esModule?e:{"default":e}}var o=t(1),r=i(o)
r["default"].entwine("ss",function(e){e("form.uploadfield-form .TreeDropdownField").entwine({onmatch:function n(){this._super()
var e=this

View File

@ -1,4 +1,4 @@
webpackJsonp([5],[function(e,t,n){"use strict"
webpackJsonp([4],[function(e,t,n){"use strict"
n(2),n(3),n(6),n(16),n(18),n(24),n(26),n(28),n(29),n(31),n(34),n(104),n(112),n(116),n(126),n(127),n(128),n(129),n(130),n(131),n(133),n(136),n(138),n(140),n(143),n(146),n(148),n(150),n(152),n(154),n(156),
n(157),n(166),n(167),n(169),n(170),n(171),n(172),n(173),n(174),n(175),n(176),n(177),n(178),n(179),n(180),n(181),n(184),n(186),n(187),n(188),n(189),n(193),n(194),n(195),n(196),n(197),n(194),n(200),n(202),
n(204),n(205)},,function(e,t){"use strict"

View File

@ -1,4 +1,4 @@
webpackJsonp([6],[function(e,n,o){"use strict"
webpackJsonp([5],[function(e,n,o){"use strict"
function t(e){return e&&e.__esModule?e:{"default":e}}var l=o(1),a=t(l),c=function u(e){var n=e.cloneNode(!0),o=(0,a["default"])("<div></div>")
return o.append(n),o.html()}
a["default"].leaktools={logDuplicateElements:function d(){var e=(0,a["default"])("*"),n=!1

View File

@ -5,13 +5,13 @@ window.webpackJsonp=function o(a,s){for(var u,l,c=0,d=[];c<a.length;c++)l=a[c],i
for(u in s)t[u]=s[u]
for(n&&n(a,s);d.length;)d.shift().call(null,e)
if(s[0])return r[0]=0,e(0)}
var r={},i={7:0}
var r={},i={6:0}
return e.e=function a(t,n){if(0===i[t])return n.call(null,e)
if(void 0!==i[t])i[t].push(n)
else{i[t]=[n]
var r=document.getElementsByTagName("head")[0],o=document.createElement("script")
o.type="text/javascript",o.charset="utf-8",o.async=!0,o.src=e.p+""+t+".js/"+({0:"LeftAndMain.Ping",1:"MemberImportForm",2:"TinyMCE_sslink",3:"TinyMCE_ssmedia",4:"UploadField_select",5:"bundle",6:"leaktools"
}[t]||t)+".js",r.appendChild(o)}},e.m=t,e.c=r,e.p="",e(0)}([function(t,e,n){"use strict"
o.type="text/javascript",o.charset="utf-8",o.async=!0,o.src=e.p+""+t+".js/"+({0:"LeftAndMain.Ping",1:"MemberImportForm",2:"TinyMCE_sslink",3:"UploadField_select",4:"bundle",5:"leaktools"}[t]||t)+".js",
r.appendChild(o)}},e.m=t,e.c=r,e.p="",e(0)}([function(t,e,n){"use strict"
n(398),n(694),n(695),n(698),n(700),n(702),n(732),n(870),n(979),n(981),n(1114),n(1124),n(1139),n(1314),n(1316),n(1364),n(1370),n(1623),n(1631),n(1634),n(1635),n(1638),n(1641),n(1642),n(1744),n(1755),n(1758),
n(1772),n(1777),n(168),n(198),n(203),n(1778),n(1779),n(1780),n(1781),n(199),n(1782),n(1783),n(1784),n(1785),n(1786),n(1787),n(1788),n(1789)},function(t,e){t.exports=jQuery},,,,function(t,e){t.exports=React

View File

@ -2,23 +2,12 @@
(() => {
const sslink = {
/**
* Returns information about the plugin as a name/value array.
* The current keys are longname, author, authorurl, infourl and version.
*
* @returns Name/value array containing information about the plugin.
* @type Array
*/
getInfo() {
return {
longname: 'Insert link for SilverStripe CMS',
author: 'Sam Minnée',
authorurl: 'http://www.siverstripe.com/',
infourl: 'http://www.silverstripe.com/',
version: '1.1',
};
},
/**
* Initialise this plugin
*
* @param {Object} ed
*/
init(ed) {
ed.addButton('sslink', {
icon: 'link',

View File

@ -1,159 +0,0 @@
/* global tinymce */
/* eslint-disable no-cond-assign */
/* eslint-disable no-param-reassign */
/* eslint-disable func-names */
(() => {
const ssmedia = {
/**
* Returns information about the plugin as a name/value array.
* The current keys are longname, author, authorurl, infourl and version.
*
* @returns Name/value array containing information about the plugin.
* @type Array
*/
getInfo() {
return {
longname: 'Media Dialog for SilverStripe CMS',
author: 'Sam Minnée',
authorurl: 'http://www.siverstripe.com/',
infourl: 'http://www.silverstripe.com/',
version: '1.1',
};
},
init(ed) {
ed.addButton('ssmedia', {
icon: 'image',
title: 'Insert Media',
cmd: 'ssmedia',
});
ed.addMenuItem('ssmedia', {
icon: 'image',
text: 'Insert Media',
cmd: 'ssmedia',
});
ed.addCommand('ssmedia', () => {
// See HtmlEditorField.js
window.jQuery(`#${ed.id}`).entwine('ss').openMediaDialog();
});
// Replace the mceAdvImage and mceImage commands with the ssmedia command
ed.on('BeforeExecCommand', (e) => {
const cmd = e.command;
const ui = e.ui;
const val = e.value;
if (cmd === 'mceAdvImage' || cmd === 'mceImage') {
e.preventDefault();
ed.execCommand('ssmedia', ui, val);
}
});
ed.on('SaveContent', (o) => {
const content = window.jQuery(o.content);
const attrsFn = (attrs) => (
Object.keys(attrs)
.map((name) => (attrs[name] ? `${name}="${attrs[name]}"` : null))
.filter((el) => el !== null)
.join(' ')
);
// Transform [embed] shortcodes
content.find('.ss-htmleditorfield-file.embed').each(function () {
const el = window.jQuery(this);
const attrs = {
width: el.attr('width'),
class: el.attr('cssclass'),
thumbnail: el.data('thumbnail'),
};
const shortCode = `[embed ${attrsFn(attrs)}]${el.data('url')}[/embed]`;
el.replaceWith(shortCode);
});
// Transform [image] shortcodes
content.find('img').each(function () {
const el = window.jQuery(this);
const attrs = {
// Requires server-side preprocessing of HTML+shortcodes in HTMLValue
src: el.attr('src'),
id: el.data('id'),
width: el.attr('width'),
height: el.attr('height'),
class: el.attr('class'),
// don't save caption, since that's in the containing element
title: el.attr('title'),
alt: el.attr('alt'),
};
const shortCode = `[image ${attrsFn(attrs)}]`;
el.replaceWith(shortCode);
});
// Insert outerHTML in order to retain all nodes incl. <script>
// tags which would've been filtered out with jQuery.html().
// Note that <script> tags might be sanitized separately based on editor config.
o.content = '';
content.each(function () {
if (this.outerHTML !== undefined) {
o.content += this.outerHTML;
}
});
});
ed.on('BeforeSetContent', (o) => {
let matches = null;
let content = o.content;
const attrFromStrFn = (str) => (
str
// Split on all attributes, quoted or not
.match(/([^\s\/'"=,]+)\s*=\s*(('([^']+)')|("([^"]+)")|([^\s,\]]+))/g)
.reduce((coll, val) => {
const match
= val.match(/^([^\s\/'"=,]+)\s*=\s*(?:(?:'([^']+)')|(?:"([^"]+)")|(?:[^\s,\]]+))$/);
const key = match[1];
const value = match[2] || match[3] || match[4]; // single, double, or unquoted match
return Object.assign({}, coll, { [key]: value });
}, {})
);
// Transform [embed] tag
const shortTagEmbegRegex = /\[embed(.*?)](.+?)\[\/\s*embed\s*]/gi;
while (matches = shortTagEmbegRegex.exec(content)) {
const attrs = attrFromStrFn(matches[1]);
const el = window.jQuery('<img/>').attr({
src: attrs.thumbnail,
width: attrs.width,
height: attrs.height,
class: attrs.class,
'data-url': matches[2],
}).addClass('ss-htmleditorfield-file embed');
attrs.cssclass = attrs.class;
Object.keys(attrs).forEach((key) => el.attr(`data-${key}`, attrs[key]));
content = content.replace(matches[0], (window.jQuery('<div/>').append(el).html()));
}
// Transform [image] tag
const shortTagImageRegex = /\[image(.*?)]/gi;
while ((matches = shortTagImageRegex.exec(content))) {
const attrs = attrFromStrFn(matches[1]);
const el = window.jQuery('<img/>').attr({
src: attrs.src,
width: attrs.width,
height: attrs.height,
class: attrs.class,
alt: attrs.alt,
title: attrs.title,
'data-id': attrs.id,
});
content = content.replace(matches[0], (window.jQuery('<div/>').append(el).html()));
}
o.content = content;
});
},
};
// Adds the plugin class to the list of available TinyMCE plugins
tinymce.PluginManager.add('ssmedia', (editor) => ssmedia.init(editor));
})();

View File

@ -154,4 +154,4 @@ fieldset{
background:#ffe9e9;
border:1px solid #c80700;
border-radius:4px;
}
}

View File

@ -588,4 +588,4 @@ body #Footer p{
font-size:18px;
padding:0 2px 2px 0;
font-weight:700;
}
}

View File

@ -45,7 +45,6 @@ const config = [
leaktools: `${PATHS.ADMIN_JS_SRC}/legacy/leaktools.js`,
MemberImportForm: `${PATHS.ADMIN_JS_SRC}/legacy/MemberImportForm.js`,
UploadField_select: `${PATHS.ADMIN_JS_SRC}/legacy/UploadField_select.js`,
TinyMCE_ssmedia: `${PATHS.ADMIN_JS_SRC}/legacy/TinyMCE_ssmedia.js`,
TinyMCE_sslink: `${PATHS.ADMIN_JS_SRC}/legacy/TinyMCE_sslink.js`,
},
resolve: {