This commit is contained in:
Markos Gogoulos
2026-02-01 14:40:41 +02:00
parent c6726d1b13
commit 7c0ea60d0e
34 changed files with 0 additions and 2238 deletions

View File

@@ -1,36 +0,0 @@
step 1
# nvm use 22
step 2
cd lms-plugins/mediacms-moodle
step 3
npm init -y
step 4
npm install --save-dev @babel/core @babel/cli @babel/preset-env @babel/plugin-transform-modules-amd
step 5
catn > .babelrc
{
"presets": [
["@babel/preset-env", {
"modules": "amd",
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 10"]
}
}]
],
"plugins": [
"@babel/plugin-transform-modules-amd"
]
}
step 6
npx babel tiny/mediacms/amd/src --out-dir tiny/mediacms/amd/build
step 7
cd tiny/mediacms/amd/build
for f in *.js; do cp "$f" "${f%.js}.min.js"; done

View File

@@ -1,61 +0,0 @@
define(["exports", "editor_tiny/loader", "./common", "./iframeembed", "core/str", "editor_tiny/utils"], function (_exports, _loader, _common, _iframeembed, _str, _utils) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.getSetup = void 0;
_iframeembed = _interopRequireDefault(_iframeembed);
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
var getSetup = _exports.getSetup = /*#__PURE__*/function () {
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
var _yield$Promise$all, _yield$Promise$all2, tinyMCE, buttonTitle, menuTitle, buttonImage;
return _regenerator().w(function (_context) {
while (1) switch (_context.n) {
case 0:
_context.n = 1;
return Promise.all([(0, _loader.getTinyMCE)(), (0, _str.getString)('insertmedia', _common.component), (0, _str.getString)('mediacms', _common.component), (0, _utils.getButtonImage)('icon', _common.component)]);
case 1:
_yield$Promise$all = _context.v;
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 4);
tinyMCE = _yield$Promise$all2[0];
buttonTitle = _yield$Promise$all2[1];
menuTitle = _yield$Promise$all2[2];
buttonImage = _yield$Promise$all2[3];
return _context.a(2, function (editor) {
var iframeEmbed = new _iframeembed.default(editor);
var action = function action() {
return iframeEmbed.displayDialogue();
};
// Register icon from pix folder (icon.svg)
editor.ui.registry.addIcon(_common.buttonName, buttonImage.html);
editor.ui.registry.addButton(_common.buttonName, {
icon: _common.buttonName,
tooltip: buttonTitle,
onAction: action
});
editor.ui.registry.addMenuItem(_common.buttonName, {
icon: _common.buttonName,
text: menuTitle,
onAction: action
});
});
}
}, _callee);
}));
return function getSetup() {
return _ref.apply(this, arguments);
};
}();
});

View File

@@ -1,61 +0,0 @@
define(["exports", "editor_tiny/loader", "./common", "./iframeembed", "core/str", "editor_tiny/utils"], function (_exports, _loader, _common, _iframeembed, _str, _utils) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.getSetup = void 0;
_iframeembed = _interopRequireDefault(_iframeembed);
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
var getSetup = _exports.getSetup = /*#__PURE__*/function () {
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
var _yield$Promise$all, _yield$Promise$all2, tinyMCE, buttonTitle, menuTitle, buttonImage;
return _regenerator().w(function (_context) {
while (1) switch (_context.n) {
case 0:
_context.n = 1;
return Promise.all([(0, _loader.getTinyMCE)(), (0, _str.getString)('insertmedia', _common.component), (0, _str.getString)('mediacms', _common.component), (0, _utils.getButtonImage)('icon', _common.component)]);
case 1:
_yield$Promise$all = _context.v;
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 4);
tinyMCE = _yield$Promise$all2[0];
buttonTitle = _yield$Promise$all2[1];
menuTitle = _yield$Promise$all2[2];
buttonImage = _yield$Promise$all2[3];
return _context.a(2, function (editor) {
var iframeEmbed = new _iframeembed.default(editor);
var action = function action() {
return iframeEmbed.displayDialogue();
};
// Register icon from pix folder (icon.svg)
editor.ui.registry.addIcon(_common.buttonName, buttonImage.html);
editor.ui.registry.addButton(_common.buttonName, {
icon: _common.buttonName,
tooltip: buttonTitle,
onAction: action
});
editor.ui.registry.addMenuItem(_common.buttonName, {
icon: _common.buttonName,
text: menuTitle,
onAction: action
});
});
}
}, _callee);
}));
return function getSetup() {
return _ref.apply(this, arguments);
};
}();
});

View File

@@ -1,11 +0,0 @@
define(["exports"], function (_exports) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.pluginName = _exports.component = _exports.buttonName = void 0;
var component = _exports.component = 'tiny_mediacms';
var pluginName = _exports.pluginName = 'mediacms';
var buttonName = _exports.buttonName = 'tiny_mediacms_video';
});

View File

@@ -1,11 +0,0 @@
define(["exports"], function (_exports) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.pluginName = _exports.component = _exports.buttonName = void 0;
var component = _exports.component = 'tiny_mediacms';
var pluginName = _exports.pluginName = 'mediacms';
var buttonName = _exports.buttonName = 'tiny_mediacms_video';
});

View File

@@ -1,15 +0,0 @@
define(["exports"], function (_exports) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.configure = void 0;
var configure = _exports.configure = function configure(instanceConfig) {
return {
mediacmsurl: instanceConfig.mediacmsurl,
launchUrl: instanceConfig.launchUrl,
lti: instanceConfig.lti
};
};
});

View File

@@ -1,15 +0,0 @@
define(["exports"], function (_exports) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.configure = void 0;
var configure = _exports.configure = function configure(instanceConfig) {
return {
mediacmsurl: instanceConfig.mediacmsurl,
launchUrl: instanceConfig.launchUrl,
lti: instanceConfig.lti
};
};
});

View File

@@ -1,512 +0,0 @@
define(["exports", "core/templates", "core/str", "core/modal_events", "./common", "./iframemodal", "./selectors", "./options"], function (_exports, _templates, _str, ModalEvents, _common, _iframemodal, _selectors, _options) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
_templates = _interopRequireDefault(_templates);
ModalEvents = _interopRequireWildcard(ModalEvents);
_iframemodal = _interopRequireDefault(_iframemodal);
_selectors = _interopRequireDefault(_selectors);
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var IframeEmbed = _exports.default = /*#__PURE__*/function () {
function IframeEmbed(editor) {
_classCallCheck(this, IframeEmbed);
this.editor = editor;
this.currentModal = null;
this.isUpdating = false;
this.selectedIframe = null;
this.debounceTimer = null;
this.iframeLibraryLoaded = false;
this.selectedLibraryVideo = null;
}
return _createClass(IframeEmbed, [{
key: "parseInput",
value: function parseInput(input) {
if (!input || !input.trim()) {
return null;
}
input = input.trim();
// Check for iframe
var iframeMatch = input.match(/<iframe[^>]*src=["']([^"']+)["'][^>]*>/i);
if (iframeMatch) {
return this.parseEmbedUrl(iframeMatch[1]);
}
// Check URL
if (input.startsWith('http://') || input.startsWith('https://')) {
return this.parseVideoUrl(input);
}
return null;
}
}, {
key: "parseVideoUrl",
value: function parseVideoUrl(url) {
try {
var urlObj = new URL(url);
var baseUrl = "".concat(urlObj.protocol, "//").concat(urlObj.host);
// /view?m=ID
if (urlObj.pathname.indexOf('/view') !== -1 && urlObj.searchParams.has('m')) {
return {
baseUrl: baseUrl,
videoId: urlObj.searchParams.get('m'),
isEmbed: false
};
}
// /embed?m=ID
if (urlObj.pathname.indexOf('/embed') !== -1 && urlObj.searchParams.has('m')) {
return {
baseUrl: baseUrl,
videoId: urlObj.searchParams.get('m'),
isEmbed: true,
// Parse options
showTitle: urlObj.searchParams.get('showTitle') === '1',
linkTitle: urlObj.searchParams.get('linkTitle') === '1',
showRelated: urlObj.searchParams.get('showRelated') === '1',
showUserAvatar: urlObj.searchParams.get('showUserAvatar') === '1'
};
}
// Check if it's already a launch.php URL
if (urlObj.pathname.indexOf('/filter/mediacms/launch.php') !== -1 && urlObj.searchParams.has('token')) {
return {
baseUrl: baseUrl,
videoId: urlObj.searchParams.get('token'),
isEmbed: true,
isLaunchUrl: true
};
}
return {
baseUrl: baseUrl,
rawUrl: url,
isGeneric: true
};
} catch (e) {
return null;
}
}
}, {
key: "parseEmbedUrl",
value: function parseEmbedUrl(url) {
return this.parseVideoUrl(url);
}
}, {
key: "buildEmbedUrl",
value: function buildEmbedUrl(parsed, options) {
if (parsed.isGeneric) {
return parsed.rawUrl;
}
var launchUrl = (0, _options.getLaunchUrl)(this.editor);
if (launchUrl && parsed.videoId) {
var _url = new URL(launchUrl);
_url.searchParams.set('token', parsed.videoId);
return _url.toString();
}
// Fallback to direct embed if launchUrl missing
var url = new URL("".concat(parsed.baseUrl, "/embed"));
url.searchParams.set('m', parsed.videoId);
return url.toString();
}
}, {
key: "getTemplateContext",
value: function () {
var _getTemplateContext = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(data) {
var width, height, aspectRatio;
return _regenerator().w(function (_context) {
while (1) switch (_context.n) {
case 0:
data = data || {};
width = data.width || 560;
height = data.height || 315;
aspectRatio = data.aspectRatio || '16:9';
return _context.a(2, {
elementid: this.editor.getElement().id,
isupdating: this.isUpdating,
url: data.url || '',
showTitle: data.showTitle !== false,
linkTitle: data.linkTitle !== false,
showRelated: data.showRelated !== false,
showUserAvatar: data.showUserAvatar !== false,
responsive: data.responsive !== false,
startAtEnabled: data.startAtEnabled || false,
startAt: data.startAt || '0:00',
width: width,
height: height,
is16_9: aspectRatio === '16:9',
is4_3: aspectRatio === '4:3',
is1_1: aspectRatio === '1:1',
isCustom: aspectRatio === 'custom'
});
}
}, _callee, this);
}));
function getTemplateContext(_x) {
return _getTemplateContext.apply(this, arguments);
}
return getTemplateContext;
}()
}, {
key: "displayDialogue",
value: function () {
var _displayDialogue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
var data, title, templateContext;
return _regenerator().w(function (_context2) {
while (1) switch (_context2.n) {
case 0:
this.selectedIframe = this.getSelectedIframe();
data = this.getCurrentIframeData();
this.isUpdating = data !== null;
this.iframeLibraryLoaded = false;
_context2.n = 1;
return (0, _str.getString)('iframemodaltitle', _common.component);
case 1:
title = _context2.v;
_context2.n = 2;
return this.getTemplateContext(data || {});
case 2:
templateContext = _context2.v;
_context2.n = 3;
return _iframemodal.default.create({
title: title,
templateContext: templateContext
});
case 3:
this.currentModal = _context2.v;
_context2.n = 4;
return this.registerEventListeners(this.currentModal);
case 4:
return _context2.a(2);
}
}, _callee2, this);
}));
function displayDialogue() {
return _displayDialogue.apply(this, arguments);
}
return displayDialogue;
}()
}, {
key: "getSelectedIframe",
value: function getSelectedIframe() {
var node = this.editor.selection.getNode();
if (node.nodeName.toLowerCase() === 'iframe') return node;
return node.querySelector('iframe') || null;
}
}, {
key: "getCurrentIframeData",
value: function getCurrentIframeData() {
if (!this.selectedIframe) return null;
var src = this.selectedIframe.getAttribute('src');
var parsed = this.parseInput(src);
// Defaults
var showTitle = true;
if (parsed && typeof parsed.showTitle !== 'undefined') {
showTitle = parsed.showTitle;
}
return {
url: src,
width: this.selectedIframe.getAttribute('width') || 560,
height: this.selectedIframe.getAttribute('height') || 315,
showTitle: showTitle
};
}
}, {
key: "getFormValues",
value: function getFormValues(root) {
var form = root.querySelector(_selectors.default.IFRAME.elements.form);
// Helper to safely get value or checked state
var getVal = function getVal(sel) {
var el = form.querySelector(sel);
return el ? el.value : '';
};
var getCheck = function getCheck(sel) {
var el = form.querySelector(sel);
return el ? el.checked : false;
};
return {
url: getVal(_selectors.default.IFRAME.elements.url).trim(),
showTitle: getCheck(_selectors.default.IFRAME.elements.showTitle),
linkTitle: getCheck(_selectors.default.IFRAME.elements.linkTitle),
showRelated: getCheck(_selectors.default.IFRAME.elements.showRelated),
showUserAvatar: getCheck(_selectors.default.IFRAME.elements.showUserAvatar),
responsive: getCheck(_selectors.default.IFRAME.elements.responsive),
aspectRatio: getVal(_selectors.default.IFRAME.elements.aspectRatio),
width: parseInt(getVal(_selectors.default.IFRAME.elements.width)) || 560,
height: parseInt(getVal(_selectors.default.IFRAME.elements.height)) || 315
};
}
}, {
key: "generateIframeHtml",
value: function () {
var _generateIframeHtml = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(values) {
var parsed, embedUrl, aspectRatioCalcs, context, template;
return _regenerator().w(function (_context3) {
while (1) switch (_context3.n) {
case 0:
parsed = this.parseInput(values.url);
if (parsed) {
_context3.n = 1;
break;
}
return _context3.a(2, '');
case 1:
embedUrl = this.buildEmbedUrl(parsed, values);
aspectRatioCalcs = {
'16:9': '16 / 9',
'4:3': '4 / 3',
'1:1': '1 / 1',
'custom': "".concat(values.width, " / ").concat(values.height)
};
context = {
src: embedUrl,
width: values.width,
height: values.height,
responsive: values.responsive,
aspectRatioValue: aspectRatioCalcs[values.aspectRatio] || '16 / 9'
};
_context3.n = 2;
return _templates.default.renderForPromise("".concat(_common.component, "/iframe_embed_output"), context);
case 2:
template = _context3.v;
return _context3.a(2, template.html);
}
}, _callee3, this);
}));
function generateIframeHtml(_x2) {
return _generateIframeHtml.apply(this, arguments);
}
return generateIframeHtml;
}()
}, {
key: "updatePreview",
value: function () {
var _updatePreview = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(root) {
var values, previewContainer, parsed, embedUrl;
return _regenerator().w(function (_context4) {
while (1) switch (_context4.n) {
case 0:
values = this.getFormValues(root);
previewContainer = root.querySelector(_selectors.default.IFRAME.elements.preview);
if (values.url) {
_context4.n = 1;
break;
}
previewContainer.innerHTML = '<span>Enter URL</span>';
return _context4.a(2);
case 1:
parsed = this.parseInput(values.url);
if (parsed) {
_context4.n = 2;
break;
}
previewContainer.innerHTML = '<span class="text-danger">Invalid URL</span>';
return _context4.a(2);
case 2:
embedUrl = this.buildEmbedUrl(parsed, values); // Simple preview
previewContainer.innerHTML = "<iframe src=\"".concat(embedUrl, "\" width=\"100%\" height=\"200\" frameborder=\"0\"></iframe>");
case 3:
return _context4.a(2);
}
}, _callee4, this);
}));
function updatePreview(_x3) {
return _updatePreview.apply(this, arguments);
}
return updatePreview;
}()
}, {
key: "registerEventListeners",
value: function () {
var _registerEventListeners = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(modal) {
var _this = this;
var root, form, urlInput, tabUrl, tabLib;
return _regenerator().w(function (_context5) {
while (1) switch (_context5.n) {
case 0:
root = modal.getRoot()[0];
form = root.querySelector(_selectors.default.IFRAME.elements.form); // Input changes update preview
form.addEventListener('change', function () {
return _this.updatePreview(root);
});
urlInput = form.querySelector(_selectors.default.IFRAME.elements.url);
if (urlInput) {
urlInput.addEventListener('input', function () {
return _this.updatePreview(root);
});
}
// Tab switching
tabUrl = form.querySelector(_selectors.default.IFRAME.elements.tabUrlBtn);
tabLib = form.querySelector(_selectors.default.IFRAME.elements.tabIframeLibraryBtn);
if (tabLib) {
tabLib.addEventListener('click', function (e) {
e.preventDefault();
_this.switchToTab(root, 'library');
_this.loadIframeLibrary(root);
});
}
if (tabUrl) {
tabUrl.addEventListener('click', function (e) {
e.preventDefault();
_this.switchToTab(root, 'url');
});
}
modal.getRoot().on(ModalEvents.save, function () {
return _this.handleDialogueSubmission(modal);
});
// Listen for messages
window.addEventListener('message', function (e) {
return _this.handleIframeLibraryMessage(root, e);
});
case 1:
return _context5.a(2);
}
}, _callee5);
}));
function registerEventListeners(_x4) {
return _registerEventListeners.apply(this, arguments);
}
return registerEventListeners;
}()
}, {
key: "switchToTab",
value: function switchToTab(root, tab) {
var form = root.querySelector(_selectors.default.IFRAME.elements.form);
var urlPane = form.querySelector(_selectors.default.IFRAME.elements.paneUrl);
var libPane = form.querySelector(_selectors.default.IFRAME.elements.paneIframeLibrary);
var urlBtn = form.querySelector(_selectors.default.IFRAME.elements.tabUrlBtn);
var libBtn = form.querySelector(_selectors.default.IFRAME.elements.tabIframeLibraryBtn);
if (tab === 'url') {
if (urlPane) {
urlPane.classList.add('show', 'active');
}
if (libPane) {
libPane.classList.remove('show', 'active');
}
if (urlBtn) {
urlBtn.classList.add('active');
}
if (libBtn) {
libBtn.classList.remove('active');
}
} else {
if (urlPane) {
urlPane.classList.remove('show', 'active');
}
if (libPane) {
libPane.classList.add('show', 'active');
}
if (urlBtn) {
urlBtn.classList.remove('active');
}
if (libBtn) {
libBtn.classList.add('active');
}
}
}
}, {
key: "loadIframeLibrary",
value: function loadIframeLibrary(root) {
var ltiConfig = (0, _options.getLti)(this.editor);
if (ltiConfig && ltiConfig.contentItemUrl) {
var iframe = root.querySelector(_selectors.default.IFRAME.elements.iframeLibraryFrame);
var loading = root.querySelector(_selectors.default.IFRAME.elements.iframeLibraryLoading);
var placeholder = root.querySelector(_selectors.default.IFRAME.elements.iframeLibraryPlaceholder);
if (placeholder) placeholder.classList.add('d-none');
if (iframe && !iframe.src) {
if (loading) loading.classList.remove('d-none');
iframe.classList.add('d-none');
iframe.onload = function () {
if (loading) loading.classList.add('d-none');
iframe.classList.remove('d-none');
};
iframe.src = ltiConfig.contentItemUrl;
}
}
}
}, {
key: "handleIframeLibraryMessage",
value: function handleIframeLibraryMessage(root, event) {
var data = event.data;
if (!data) return;
var embedUrl = null;
var videoId = null;
// LTI Deep Linking Response
if (data.type === 'ltiDeepLinkingResponse' || data.messageType === 'LtiDeepLinkingResponse') {
var items = data.content_items || data.contentItems || [];
if (items.length) {
embedUrl = items[0].url || items[0].embed_url;
if (embedUrl) {
var parsed = this.parseInput(embedUrl);
if (parsed) videoId = parsed.videoId;
}
}
}
// MediaCMS custom message
if (data.action === 'selectMedia' || data.type === 'videoSelected') {
embedUrl = data.embedUrl || data.url;
videoId = data.mediaId || data.videoId || data.id;
}
if (videoId) {
var mediaCMSUrl = (0, _options.getMediaCMSUrl)(this.editor);
if (mediaCMSUrl) {
var viewUrl = "".concat(mediaCMSUrl, "/view?m=").concat(videoId);
var urlInput = root.querySelector(_selectors.default.IFRAME.elements.url);
if (urlInput) {
urlInput.value = viewUrl;
this.updatePreview(root);
this.switchToTab(root, 'url');
}
}
}
}
}, {
key: "handleDialogueSubmission",
value: function () {
var _handleDialogueSubmission = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(modal) {
var root, values, html;
return _regenerator().w(function (_context6) {
while (1) switch (_context6.n) {
case 0:
root = modal.getRoot()[0];
values = this.getFormValues(root);
_context6.n = 1;
return this.generateIframeHtml(values);
case 1:
html = _context6.v;
if (html) {
this.editor.insertContent(html);
}
modal.hide();
case 2:
return _context6.a(2);
}
}, _callee6, this);
}));
function handleDialogueSubmission(_x5) {
return _handleDialogueSubmission.apply(this, arguments);
}
return handleDialogueSubmission;
}()
}]);
}();
});

View File

@@ -1,512 +0,0 @@
define(["exports", "core/templates", "core/str", "core/modal_events", "./common", "./iframemodal", "./selectors", "./options"], function (_exports, _templates, _str, ModalEvents, _common, _iframemodal, _selectors, _options) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
_templates = _interopRequireDefault(_templates);
ModalEvents = _interopRequireWildcard(ModalEvents);
_iframemodal = _interopRequireDefault(_iframemodal);
_selectors = _interopRequireDefault(_selectors);
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var IframeEmbed = _exports.default = /*#__PURE__*/function () {
function IframeEmbed(editor) {
_classCallCheck(this, IframeEmbed);
this.editor = editor;
this.currentModal = null;
this.isUpdating = false;
this.selectedIframe = null;
this.debounceTimer = null;
this.iframeLibraryLoaded = false;
this.selectedLibraryVideo = null;
}
return _createClass(IframeEmbed, [{
key: "parseInput",
value: function parseInput(input) {
if (!input || !input.trim()) {
return null;
}
input = input.trim();
// Check for iframe
var iframeMatch = input.match(/<iframe[^>]*src=["']([^"']+)["'][^>]*>/i);
if (iframeMatch) {
return this.parseEmbedUrl(iframeMatch[1]);
}
// Check URL
if (input.startsWith('http://') || input.startsWith('https://')) {
return this.parseVideoUrl(input);
}
return null;
}
}, {
key: "parseVideoUrl",
value: function parseVideoUrl(url) {
try {
var urlObj = new URL(url);
var baseUrl = "".concat(urlObj.protocol, "//").concat(urlObj.host);
// /view?m=ID
if (urlObj.pathname.indexOf('/view') !== -1 && urlObj.searchParams.has('m')) {
return {
baseUrl: baseUrl,
videoId: urlObj.searchParams.get('m'),
isEmbed: false
};
}
// /embed?m=ID
if (urlObj.pathname.indexOf('/embed') !== -1 && urlObj.searchParams.has('m')) {
return {
baseUrl: baseUrl,
videoId: urlObj.searchParams.get('m'),
isEmbed: true,
// Parse options
showTitle: urlObj.searchParams.get('showTitle') === '1',
linkTitle: urlObj.searchParams.get('linkTitle') === '1',
showRelated: urlObj.searchParams.get('showRelated') === '1',
showUserAvatar: urlObj.searchParams.get('showUserAvatar') === '1'
};
}
// Check if it's already a launch.php URL
if (urlObj.pathname.indexOf('/filter/mediacms/launch.php') !== -1 && urlObj.searchParams.has('token')) {
return {
baseUrl: baseUrl,
videoId: urlObj.searchParams.get('token'),
isEmbed: true,
isLaunchUrl: true
};
}
return {
baseUrl: baseUrl,
rawUrl: url,
isGeneric: true
};
} catch (e) {
return null;
}
}
}, {
key: "parseEmbedUrl",
value: function parseEmbedUrl(url) {
return this.parseVideoUrl(url);
}
}, {
key: "buildEmbedUrl",
value: function buildEmbedUrl(parsed, options) {
if (parsed.isGeneric) {
return parsed.rawUrl;
}
var launchUrl = (0, _options.getLaunchUrl)(this.editor);
if (launchUrl && parsed.videoId) {
var _url = new URL(launchUrl);
_url.searchParams.set('token', parsed.videoId);
return _url.toString();
}
// Fallback to direct embed if launchUrl missing
var url = new URL("".concat(parsed.baseUrl, "/embed"));
url.searchParams.set('m', parsed.videoId);
return url.toString();
}
}, {
key: "getTemplateContext",
value: function () {
var _getTemplateContext = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(data) {
var width, height, aspectRatio;
return _regenerator().w(function (_context) {
while (1) switch (_context.n) {
case 0:
data = data || {};
width = data.width || 560;
height = data.height || 315;
aspectRatio = data.aspectRatio || '16:9';
return _context.a(2, {
elementid: this.editor.getElement().id,
isupdating: this.isUpdating,
url: data.url || '',
showTitle: data.showTitle !== false,
linkTitle: data.linkTitle !== false,
showRelated: data.showRelated !== false,
showUserAvatar: data.showUserAvatar !== false,
responsive: data.responsive !== false,
startAtEnabled: data.startAtEnabled || false,
startAt: data.startAt || '0:00',
width: width,
height: height,
is16_9: aspectRatio === '16:9',
is4_3: aspectRatio === '4:3',
is1_1: aspectRatio === '1:1',
isCustom: aspectRatio === 'custom'
});
}
}, _callee, this);
}));
function getTemplateContext(_x) {
return _getTemplateContext.apply(this, arguments);
}
return getTemplateContext;
}()
}, {
key: "displayDialogue",
value: function () {
var _displayDialogue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
var data, title, templateContext;
return _regenerator().w(function (_context2) {
while (1) switch (_context2.n) {
case 0:
this.selectedIframe = this.getSelectedIframe();
data = this.getCurrentIframeData();
this.isUpdating = data !== null;
this.iframeLibraryLoaded = false;
_context2.n = 1;
return (0, _str.getString)('iframemodaltitle', _common.component);
case 1:
title = _context2.v;
_context2.n = 2;
return this.getTemplateContext(data || {});
case 2:
templateContext = _context2.v;
_context2.n = 3;
return _iframemodal.default.create({
title: title,
templateContext: templateContext
});
case 3:
this.currentModal = _context2.v;
_context2.n = 4;
return this.registerEventListeners(this.currentModal);
case 4:
return _context2.a(2);
}
}, _callee2, this);
}));
function displayDialogue() {
return _displayDialogue.apply(this, arguments);
}
return displayDialogue;
}()
}, {
key: "getSelectedIframe",
value: function getSelectedIframe() {
var node = this.editor.selection.getNode();
if (node.nodeName.toLowerCase() === 'iframe') return node;
return node.querySelector('iframe') || null;
}
}, {
key: "getCurrentIframeData",
value: function getCurrentIframeData() {
if (!this.selectedIframe) return null;
var src = this.selectedIframe.getAttribute('src');
var parsed = this.parseInput(src);
// Defaults
var showTitle = true;
if (parsed && typeof parsed.showTitle !== 'undefined') {
showTitle = parsed.showTitle;
}
return {
url: src,
width: this.selectedIframe.getAttribute('width') || 560,
height: this.selectedIframe.getAttribute('height') || 315,
showTitle: showTitle
};
}
}, {
key: "getFormValues",
value: function getFormValues(root) {
var form = root.querySelector(_selectors.default.IFRAME.elements.form);
// Helper to safely get value or checked state
var getVal = function getVal(sel) {
var el = form.querySelector(sel);
return el ? el.value : '';
};
var getCheck = function getCheck(sel) {
var el = form.querySelector(sel);
return el ? el.checked : false;
};
return {
url: getVal(_selectors.default.IFRAME.elements.url).trim(),
showTitle: getCheck(_selectors.default.IFRAME.elements.showTitle),
linkTitle: getCheck(_selectors.default.IFRAME.elements.linkTitle),
showRelated: getCheck(_selectors.default.IFRAME.elements.showRelated),
showUserAvatar: getCheck(_selectors.default.IFRAME.elements.showUserAvatar),
responsive: getCheck(_selectors.default.IFRAME.elements.responsive),
aspectRatio: getVal(_selectors.default.IFRAME.elements.aspectRatio),
width: parseInt(getVal(_selectors.default.IFRAME.elements.width)) || 560,
height: parseInt(getVal(_selectors.default.IFRAME.elements.height)) || 315
};
}
}, {
key: "generateIframeHtml",
value: function () {
var _generateIframeHtml = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(values) {
var parsed, embedUrl, aspectRatioCalcs, context, template;
return _regenerator().w(function (_context3) {
while (1) switch (_context3.n) {
case 0:
parsed = this.parseInput(values.url);
if (parsed) {
_context3.n = 1;
break;
}
return _context3.a(2, '');
case 1:
embedUrl = this.buildEmbedUrl(parsed, values);
aspectRatioCalcs = {
'16:9': '16 / 9',
'4:3': '4 / 3',
'1:1': '1 / 1',
'custom': "".concat(values.width, " / ").concat(values.height)
};
context = {
src: embedUrl,
width: values.width,
height: values.height,
responsive: values.responsive,
aspectRatioValue: aspectRatioCalcs[values.aspectRatio] || '16 / 9'
};
_context3.n = 2;
return _templates.default.renderForPromise("".concat(_common.component, "/iframe_embed_output"), context);
case 2:
template = _context3.v;
return _context3.a(2, template.html);
}
}, _callee3, this);
}));
function generateIframeHtml(_x2) {
return _generateIframeHtml.apply(this, arguments);
}
return generateIframeHtml;
}()
}, {
key: "updatePreview",
value: function () {
var _updatePreview = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(root) {
var values, previewContainer, parsed, embedUrl;
return _regenerator().w(function (_context4) {
while (1) switch (_context4.n) {
case 0:
values = this.getFormValues(root);
previewContainer = root.querySelector(_selectors.default.IFRAME.elements.preview);
if (values.url) {
_context4.n = 1;
break;
}
previewContainer.innerHTML = '<span>Enter URL</span>';
return _context4.a(2);
case 1:
parsed = this.parseInput(values.url);
if (parsed) {
_context4.n = 2;
break;
}
previewContainer.innerHTML = '<span class="text-danger">Invalid URL</span>';
return _context4.a(2);
case 2:
embedUrl = this.buildEmbedUrl(parsed, values); // Simple preview
previewContainer.innerHTML = "<iframe src=\"".concat(embedUrl, "\" width=\"100%\" height=\"200\" frameborder=\"0\"></iframe>");
case 3:
return _context4.a(2);
}
}, _callee4, this);
}));
function updatePreview(_x3) {
return _updatePreview.apply(this, arguments);
}
return updatePreview;
}()
}, {
key: "registerEventListeners",
value: function () {
var _registerEventListeners = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(modal) {
var _this = this;
var root, form, urlInput, tabUrl, tabLib;
return _regenerator().w(function (_context5) {
while (1) switch (_context5.n) {
case 0:
root = modal.getRoot()[0];
form = root.querySelector(_selectors.default.IFRAME.elements.form); // Input changes update preview
form.addEventListener('change', function () {
return _this.updatePreview(root);
});
urlInput = form.querySelector(_selectors.default.IFRAME.elements.url);
if (urlInput) {
urlInput.addEventListener('input', function () {
return _this.updatePreview(root);
});
}
// Tab switching
tabUrl = form.querySelector(_selectors.default.IFRAME.elements.tabUrlBtn);
tabLib = form.querySelector(_selectors.default.IFRAME.elements.tabIframeLibraryBtn);
if (tabLib) {
tabLib.addEventListener('click', function (e) {
e.preventDefault();
_this.switchToTab(root, 'library');
_this.loadIframeLibrary(root);
});
}
if (tabUrl) {
tabUrl.addEventListener('click', function (e) {
e.preventDefault();
_this.switchToTab(root, 'url');
});
}
modal.getRoot().on(ModalEvents.save, function () {
return _this.handleDialogueSubmission(modal);
});
// Listen for messages
window.addEventListener('message', function (e) {
return _this.handleIframeLibraryMessage(root, e);
});
case 1:
return _context5.a(2);
}
}, _callee5);
}));
function registerEventListeners(_x4) {
return _registerEventListeners.apply(this, arguments);
}
return registerEventListeners;
}()
}, {
key: "switchToTab",
value: function switchToTab(root, tab) {
var form = root.querySelector(_selectors.default.IFRAME.elements.form);
var urlPane = form.querySelector(_selectors.default.IFRAME.elements.paneUrl);
var libPane = form.querySelector(_selectors.default.IFRAME.elements.paneIframeLibrary);
var urlBtn = form.querySelector(_selectors.default.IFRAME.elements.tabUrlBtn);
var libBtn = form.querySelector(_selectors.default.IFRAME.elements.tabIframeLibraryBtn);
if (tab === 'url') {
if (urlPane) {
urlPane.classList.add('show', 'active');
}
if (libPane) {
libPane.classList.remove('show', 'active');
}
if (urlBtn) {
urlBtn.classList.add('active');
}
if (libBtn) {
libBtn.classList.remove('active');
}
} else {
if (urlPane) {
urlPane.classList.remove('show', 'active');
}
if (libPane) {
libPane.classList.add('show', 'active');
}
if (urlBtn) {
urlBtn.classList.remove('active');
}
if (libBtn) {
libBtn.classList.add('active');
}
}
}
}, {
key: "loadIframeLibrary",
value: function loadIframeLibrary(root) {
var ltiConfig = (0, _options.getLti)(this.editor);
if (ltiConfig && ltiConfig.contentItemUrl) {
var iframe = root.querySelector(_selectors.default.IFRAME.elements.iframeLibraryFrame);
var loading = root.querySelector(_selectors.default.IFRAME.elements.iframeLibraryLoading);
var placeholder = root.querySelector(_selectors.default.IFRAME.elements.iframeLibraryPlaceholder);
if (placeholder) placeholder.classList.add('d-none');
if (iframe && !iframe.src) {
if (loading) loading.classList.remove('d-none');
iframe.classList.add('d-none');
iframe.onload = function () {
if (loading) loading.classList.add('d-none');
iframe.classList.remove('d-none');
};
iframe.src = ltiConfig.contentItemUrl;
}
}
}
}, {
key: "handleIframeLibraryMessage",
value: function handleIframeLibraryMessage(root, event) {
var data = event.data;
if (!data) return;
var embedUrl = null;
var videoId = null;
// LTI Deep Linking Response
if (data.type === 'ltiDeepLinkingResponse' || data.messageType === 'LtiDeepLinkingResponse') {
var items = data.content_items || data.contentItems || [];
if (items.length) {
embedUrl = items[0].url || items[0].embed_url;
if (embedUrl) {
var parsed = this.parseInput(embedUrl);
if (parsed) videoId = parsed.videoId;
}
}
}
// MediaCMS custom message
if (data.action === 'selectMedia' || data.type === 'videoSelected') {
embedUrl = data.embedUrl || data.url;
videoId = data.mediaId || data.videoId || data.id;
}
if (videoId) {
var mediaCMSUrl = (0, _options.getMediaCMSUrl)(this.editor);
if (mediaCMSUrl) {
var viewUrl = "".concat(mediaCMSUrl, "/view?m=").concat(videoId);
var urlInput = root.querySelector(_selectors.default.IFRAME.elements.url);
if (urlInput) {
urlInput.value = viewUrl;
this.updatePreview(root);
this.switchToTab(root, 'url');
}
}
}
}
}, {
key: "handleDialogueSubmission",
value: function () {
var _handleDialogueSubmission = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(modal) {
var root, values, html;
return _regenerator().w(function (_context6) {
while (1) switch (_context6.n) {
case 0:
root = modal.getRoot()[0];
values = this.getFormValues(root);
_context6.n = 1;
return this.generateIframeHtml(values);
case 1:
html = _context6.v;
if (html) {
this.editor.insertContent(html);
}
modal.hide();
case 2:
return _context6.a(2);
}
}, _callee6, this);
}));
function handleDialogueSubmission(_x5) {
return _handleDialogueSubmission.apply(this, arguments);
}
return handleDialogueSubmission;
}()
}]);
}();
});

View File

@@ -1,35 +0,0 @@
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
define(["exports", "core/modal", "core/modal_registry", "./common"], function (_exports, _modal, _modal_registry, _common) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
_modal = _interopRequireDefault(_modal);
_modal_registry = _interopRequireDefault(_modal_registry);
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
var IframeModal = _exports.default = /*#__PURE__*/function (_Modal) {
function IframeModal() {
_classCallCheck(this, IframeModal);
return _callSuper(this, IframeModal, arguments);
}
_inherits(IframeModal, _Modal);
return _createClass(IframeModal);
}(_modal.default); // Define static properties outside the class body for compatibility
IframeModal.TYPE = "".concat(_common.component, "/iframe_embed_modal");
IframeModal.TEMPLATE = "".concat(_common.component, "/iframe_embed_modal");
_modal_registry.default.register(IframeModal.TYPE, IframeModal, IframeModal.TEMPLATE);
});

View File

@@ -1,35 +0,0 @@
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
define(["exports", "core/modal", "core/modal_registry", "./common"], function (_exports, _modal, _modal_registry, _common) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
_modal = _interopRequireDefault(_modal);
_modal_registry = _interopRequireDefault(_modal_registry);
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
var IframeModal = _exports.default = /*#__PURE__*/function (_Modal) {
function IframeModal() {
_classCallCheck(this, IframeModal);
return _callSuper(this, IframeModal, arguments);
}
_inherits(IframeModal, _Modal);
return _createClass(IframeModal);
}(_modal.default); // Define static properties outside the class body for compatibility
IframeModal.TYPE = "".concat(_common.component, "/iframe_embed_modal");
IframeModal.TEMPLATE = "".concat(_common.component, "/iframe_embed_modal");
_modal_registry.default.register(IframeModal.TYPE, IframeModal, IframeModal.TEMPLATE);
});

View File

@@ -1,32 +0,0 @@
define(["exports", "./common"], function (_exports, _common) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.register = _exports.getMediaCMSUrl = _exports.getLti = _exports.getLaunchUrl = void 0;
var register = _exports.register = function register(editor) {
var registerOption = editor.options.register;
registerOption("".concat(_common.component, ":mediacmsurl"), {
processor: 'string',
default: ''
});
registerOption("".concat(_common.component, ":launchUrl"), {
processor: 'string',
default: ''
});
registerOption("".concat(_common.component, ":lti"), {
processor: 'object',
default: {}
});
};
var getMediaCMSUrl = _exports.getMediaCMSUrl = function getMediaCMSUrl(editor) {
return editor.options.get("".concat(_common.component, ":mediacmsurl"));
};
var getLaunchUrl = _exports.getLaunchUrl = function getLaunchUrl(editor) {
return editor.options.get("".concat(_common.component, ":launchUrl"));
};
var getLti = _exports.getLti = function getLti(editor) {
return editor.options.get("".concat(_common.component, ":lti"));
};
});

View File

@@ -1,32 +0,0 @@
define(["exports", "./common"], function (_exports, _common) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.register = _exports.getMediaCMSUrl = _exports.getLti = _exports.getLaunchUrl = void 0;
var register = _exports.register = function register(editor) {
var registerOption = editor.options.register;
registerOption("".concat(_common.component, ":mediacmsurl"), {
processor: 'string',
default: ''
});
registerOption("".concat(_common.component, ":launchUrl"), {
processor: 'string',
default: ''
});
registerOption("".concat(_common.component, ":lti"), {
processor: 'object',
default: {}
});
};
var getMediaCMSUrl = _exports.getMediaCMSUrl = function getMediaCMSUrl(editor) {
return editor.options.get("".concat(_common.component, ":mediacmsurl"));
};
var getLaunchUrl = _exports.getLaunchUrl = function getLaunchUrl(editor) {
return editor.options.get("".concat(_common.component, ":launchUrl"));
};
var getLti = _exports.getLti = function getLti(editor) {
return editor.options.get("".concat(_common.component, ":lti"));
};
});

View File

@@ -1,52 +0,0 @@
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
define(["exports", "editor_tiny/loader", "editor_tiny/utils", "./common", "./commands", "./options", "./configuration"], function (_exports, _loader, _utils, _common, Commands, Options, Configuration) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
Commands = _interopRequireWildcard(Commands);
Options = _interopRequireWildcard(Options);
Configuration = _interopRequireWildcard(Configuration);
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
var _default = _exports.default = new Promise(/*#__PURE__*/function () {
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(resolve) {
var _yield$Promise$all, _yield$Promise$all2, tinyMCE, setupCommands, pluginMetadata;
return _regenerator().w(function (_context) {
while (1) switch (_context.n) {
case 0:
_context.n = 1;
return Promise.all([(0, _loader.getTinyMCE)(), Commands.getSetup(), (0, _utils.getPluginMetadata)(_common.component, _common.pluginName)]);
case 1:
_yield$Promise$all = _context.v;
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
tinyMCE = _yield$Promise$all2[0];
setupCommands = _yield$Promise$all2[1];
pluginMetadata = _yield$Promise$all2[2];
tinyMCE.PluginManager.add("".concat(_common.component, "/plugin"), function (editor) {
Options.register(editor);
setupCommands(editor);
return pluginMetadata;
});
resolve(["".concat(_common.component, "/plugin"), Configuration]);
case 2:
return _context.a(2);
}
}, _callee);
}));
return function (_x) {
return _ref.apply(this, arguments);
};
}());
});

View File

@@ -1,52 +0,0 @@
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
define(["exports", "editor_tiny/loader", "editor_tiny/utils", "./common", "./commands", "./options", "./configuration"], function (_exports, _loader, _utils, _common, Commands, Options, Configuration) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
Commands = _interopRequireWildcard(Commands);
Options = _interopRequireWildcard(Options);
Configuration = _interopRequireWildcard(Configuration);
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
var _default = _exports.default = new Promise(/*#__PURE__*/function () {
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(resolve) {
var _yield$Promise$all, _yield$Promise$all2, tinyMCE, setupCommands, pluginMetadata;
return _regenerator().w(function (_context) {
while (1) switch (_context.n) {
case 0:
_context.n = 1;
return Promise.all([(0, _loader.getTinyMCE)(), Commands.getSetup(), (0, _utils.getPluginMetadata)(_common.component, _common.pluginName)]);
case 1:
_yield$Promise$all = _context.v;
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
tinyMCE = _yield$Promise$all2[0];
setupCommands = _yield$Promise$all2[1];
pluginMetadata = _yield$Promise$all2[2];
tinyMCE.PluginManager.add("".concat(_common.component, "/plugin"), function (editor) {
Options.register(editor);
setupCommands(editor);
return pluginMetadata;
});
resolve(["".concat(_common.component, "/plugin"), Configuration]);
case 2:
return _context.a(2);
}
}, _callee);
}));
return function (_x) {
return _ref.apply(this, arguments);
};
}());
});

View File

@@ -1,26 +0,0 @@
define(["exports"], function (_exports) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
var _default = _exports.default = {
IFRAME: {
elements: {
form: '.tiny-mediacms-iframe-form',
url: 'input[name="mediacms_url"]',
width: 'input[name="mediacms_width"]',
height: 'input[name="mediacms_height"]',
preview: '.tiny-mediacms-preview',
tabUrlBtn: '#tiny-mediacms-tab-url',
tabIframeLibraryBtn: '#tiny-mediacms-tab-library',
paneUrl: '#tiny-mediacms-pane-url',
paneIframeLibrary: '#tiny-mediacms-pane-library',
iframeLibraryFrame: '.tiny-mediacms-library-frame',
iframeLibraryLoading: '.tiny-mediacms-library-loading',
iframeLibraryPlaceholder: '.tiny-mediacms-library-placeholder'
}
}
};
});

View File

@@ -1,26 +0,0 @@
define(["exports"], function (_exports) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
var _default = _exports.default = {
IFRAME: {
elements: {
form: '.tiny-mediacms-iframe-form',
url: 'input[name="mediacms_url"]',
width: 'input[name="mediacms_width"]',
height: 'input[name="mediacms_height"]',
preview: '.tiny-mediacms-preview',
tabUrlBtn: '#tiny-mediacms-tab-url',
tabIframeLibraryBtn: '#tiny-mediacms-tab-library',
paneUrl: '#tiny-mediacms-pane-url',
paneIframeLibrary: '#tiny-mediacms-pane-library',
iframeLibraryFrame: '.tiny-mediacms-library-frame',
iframeLibraryLoading: '.tiny-mediacms-library-loading',
iframeLibraryPlaceholder: '.tiny-mediacms-library-placeholder'
}
}
};
});

View File

@@ -1,35 +0,0 @@
import { getTinyMCE } from 'editor_tiny/loader';
import { component, buttonName } from './common';
import IframeEmbed from './iframeembed';
import { getString } from 'core/str';
import { getButtonImage } from 'editor_tiny/utils';
export const getSetup = async () => {
const [tinyMCE, buttonTitle, menuTitle, buttonImage] = await Promise.all([
getTinyMCE(),
getString('insertmedia', component),
getString('mediacms', component),
getButtonImage('icon', component)
]);
return (editor) => {
const iframeEmbed = new IframeEmbed(editor);
const action = () => iframeEmbed.displayDialogue();
// Register icon from pix folder (icon.svg)
editor.ui.registry.addIcon(buttonName, buttonImage.html);
editor.ui.registry.addButton(buttonName, {
icon: buttonName,
tooltip: buttonTitle,
onAction: action,
});
editor.ui.registry.addMenuItem(buttonName, {
icon: buttonName,
text: menuTitle,
onAction: action,
});
};
};

View File

@@ -1,4 +0,0 @@
export const component = 'tiny_mediacms';
export const pluginName = 'mediacms';
export const buttonName = 'tiny_mediacms_video';

View File

@@ -1,8 +0,0 @@
export const configure = (instanceConfig) => {
return {
mediacmsurl: instanceConfig.mediacmsurl,
launchUrl: instanceConfig.launchUrl,
lti: instanceConfig.lti
};
};

View File

@@ -1,380 +0,0 @@
import Templates from 'core/templates';
import { getString } from 'core/str';
import * as ModalEvents from 'core/modal_events';
import { component } from './common';
import IframeModal from './iframemodal';
import Selectors from './selectors';
import { getLti, getLaunchUrl, getMediaCMSUrl } from './options';
export default class IframeEmbed {
constructor(editor) {
this.editor = editor;
this.currentModal = null;
this.isUpdating = false;
this.selectedIframe = null;
this.debounceTimer = null;
this.iframeLibraryLoaded = false;
this.selectedLibraryVideo = null;
}
parseInput(input) {
if (!input || !input.trim()) {
return null;
}
input = input.trim();
// Check for iframe
const iframeMatch = input.match(/<iframe[^>]*src=["']([^"']+)["'][^>]*>/i);
if (iframeMatch) {
return this.parseEmbedUrl(iframeMatch[1]);
}
// Check URL
if (input.startsWith('http://') || input.startsWith('https://')) {
return this.parseVideoUrl(input);
}
return null;
}
parseVideoUrl(url) {
try {
const urlObj = new URL(url);
const baseUrl = `${urlObj.protocol}//${urlObj.host}`;
// /view?m=ID
if (urlObj.pathname.indexOf('/view') !== -1 && urlObj.searchParams.has('m')) {
return {
baseUrl: baseUrl,
videoId: urlObj.searchParams.get('m'),
isEmbed: false
};
}
// /embed?m=ID
if (urlObj.pathname.indexOf('/embed') !== -1 && urlObj.searchParams.has('m')) {
return {
baseUrl: baseUrl,
videoId: urlObj.searchParams.get('m'),
isEmbed: true,
// Parse options
showTitle: urlObj.searchParams.get('showTitle') === '1',
linkTitle: urlObj.searchParams.get('linkTitle') === '1',
showRelated: urlObj.searchParams.get('showRelated') === '1',
showUserAvatar: urlObj.searchParams.get('showUserAvatar') === '1',
};
}
// Check if it's already a launch.php URL
if (urlObj.pathname.indexOf('/filter/mediacms/launch.php') !== -1 && urlObj.searchParams.has('token')) {
return {
baseUrl: baseUrl,
videoId: urlObj.searchParams.get('token'),
isEmbed: true,
isLaunchUrl: true
};
}
return {
baseUrl: baseUrl,
rawUrl: url,
isGeneric: true
};
} catch (e) {
return null;
}
}
parseEmbedUrl(url) {
return this.parseVideoUrl(url);
}
buildEmbedUrl(parsed, options) {
if (parsed.isGeneric) {
return parsed.rawUrl;
}
const launchUrl = getLaunchUrl(this.editor);
if (launchUrl && parsed.videoId) {
const url = new URL(launchUrl);
url.searchParams.set('token', parsed.videoId);
return url.toString();
}
// Fallback to direct embed if launchUrl missing
const url = new URL(`${parsed.baseUrl}/embed`);
url.searchParams.set('m', parsed.videoId);
return url.toString();
}
async getTemplateContext(data) {
data = data || {};
const width = data.width || 560;
const height = data.height || 315;
const aspectRatio = data.aspectRatio || '16:9';
return {
elementid: this.editor.getElement().id,
isupdating: this.isUpdating,
url: data.url || '',
showTitle: data.showTitle !== false,
linkTitle: data.linkTitle !== false,
showRelated: data.showRelated !== false,
showUserAvatar: data.showUserAvatar !== false,
responsive: data.responsive !== false,
startAtEnabled: data.startAtEnabled || false,
startAt: data.startAt || '0:00',
width: width,
height: height,
is16_9: aspectRatio === '16:9',
is4_3: aspectRatio === '4:3',
is1_1: aspectRatio === '1:1',
isCustom: aspectRatio === 'custom',
};
}
async displayDialogue() {
this.selectedIframe = this.getSelectedIframe();
const data = this.getCurrentIframeData();
this.isUpdating = data !== null;
this.iframeLibraryLoaded = false;
const title = await getString('iframemodaltitle', component);
const templateContext = await this.getTemplateContext(data || {});
this.currentModal = await IframeModal.create({
title: title,
templateContext: templateContext,
});
await this.registerEventListeners(this.currentModal);
}
getSelectedIframe() {
const node = this.editor.selection.getNode();
if (node.nodeName.toLowerCase() === 'iframe') return node;
return node.querySelector('iframe') || null;
}
getCurrentIframeData() {
if (!this.selectedIframe) return null;
const src = this.selectedIframe.getAttribute('src');
const parsed = this.parseInput(src);
// Defaults
let showTitle = true;
if (parsed && typeof parsed.showTitle !== 'undefined') {
showTitle = parsed.showTitle;
}
return {
url: src,
width: this.selectedIframe.getAttribute('width') || 560,
height: this.selectedIframe.getAttribute('height') || 315,
showTitle: showTitle,
};
}
getFormValues(root) {
const form = root.querySelector(Selectors.IFRAME.elements.form);
// Helper to safely get value or checked state
const getVal = (sel) => {
const el = form.querySelector(sel);
return el ? el.value : '';
};
const getCheck = (sel) => {
const el = form.querySelector(sel);
return el ? el.checked : false;
};
return {
url: getVal(Selectors.IFRAME.elements.url).trim(),
showTitle: getCheck(Selectors.IFRAME.elements.showTitle),
linkTitle: getCheck(Selectors.IFRAME.elements.linkTitle),
showRelated: getCheck(Selectors.IFRAME.elements.showRelated),
showUserAvatar: getCheck(Selectors.IFRAME.elements.showUserAvatar),
responsive: getCheck(Selectors.IFRAME.elements.responsive),
aspectRatio: getVal(Selectors.IFRAME.elements.aspectRatio),
width: parseInt(getVal(Selectors.IFRAME.elements.width)) || 560,
height: parseInt(getVal(Selectors.IFRAME.elements.height)) || 315,
};
}
async generateIframeHtml(values) {
const parsed = this.parseInput(values.url);
if (!parsed) return '';
const embedUrl = this.buildEmbedUrl(parsed, values);
const aspectRatioCalcs = {
'16:9': '16 / 9',
'4:3': '4 / 3',
'1:1': '1 / 1',
'custom': `${values.width} / ${values.height}`
};
const context = {
src: embedUrl,
width: values.width,
height: values.height,
responsive: values.responsive,
aspectRatioValue: aspectRatioCalcs[values.aspectRatio] || '16 / 9',
};
const template = await Templates.renderForPromise(
`${component}/iframe_embed_output`,
context
);
return template.html;
}
async updatePreview(root) {
const values = this.getFormValues(root);
const previewContainer = root.querySelector(Selectors.IFRAME.elements.preview);
if (!values.url) {
previewContainer.innerHTML = '<span>Enter URL</span>';
return;
}
const parsed = this.parseInput(values.url);
if (!parsed) {
previewContainer.innerHTML = '<span class="text-danger">Invalid URL</span>';
return;
}
const embedUrl = this.buildEmbedUrl(parsed, values);
// Simple preview
previewContainer.innerHTML = `<iframe src="${embedUrl}" width="100%" height="200" frameborder="0"></iframe>`;
}
async registerEventListeners(modal) {
const root = modal.getRoot()[0];
const form = root.querySelector(Selectors.IFRAME.elements.form);
// Input changes update preview
form.addEventListener('change', () => this.updatePreview(root));
const urlInput = form.querySelector(Selectors.IFRAME.elements.url);
if (urlInput) {
urlInput.addEventListener('input', () => this.updatePreview(root));
}
// Tab switching
const tabUrl = form.querySelector(Selectors.IFRAME.elements.tabUrlBtn);
const tabLib = form.querySelector(Selectors.IFRAME.elements.tabIframeLibraryBtn);
if (tabLib) {
tabLib.addEventListener('click', (e) => {
e.preventDefault();
this.switchToTab(root, 'library');
this.loadIframeLibrary(root);
});
}
if (tabUrl) {
tabUrl.addEventListener('click', (e) => {
e.preventDefault();
this.switchToTab(root, 'url');
});
}
modal.getRoot().on(ModalEvents.save, () => this.handleDialogueSubmission(modal));
// Listen for messages
window.addEventListener('message', (e) => this.handleIframeLibraryMessage(root, e));
}
switchToTab(root, tab) {
const form = root.querySelector(Selectors.IFRAME.elements.form);
const urlPane = form.querySelector(Selectors.IFRAME.elements.paneUrl);
const libPane = form.querySelector(Selectors.IFRAME.elements.paneIframeLibrary);
const urlBtn = form.querySelector(Selectors.IFRAME.elements.tabUrlBtn);
const libBtn = form.querySelector(Selectors.IFRAME.elements.tabIframeLibraryBtn);
if (tab === 'url') {
if(urlPane) { urlPane.classList.add('show', 'active'); }
if(libPane) { libPane.classList.remove('show', 'active'); }
if(urlBtn) { urlBtn.classList.add('active'); }
if(libBtn) { libBtn.classList.remove('active'); }
} else {
if(urlPane) { urlPane.classList.remove('show', 'active'); }
if(libPane) { libPane.classList.add('show', 'active'); }
if(urlBtn) { urlBtn.classList.remove('active'); }
if(libBtn) { libBtn.classList.add('active'); }
}
}
loadIframeLibrary(root) {
const ltiConfig = getLti(this.editor);
if (ltiConfig && ltiConfig.contentItemUrl) {
const iframe = root.querySelector(Selectors.IFRAME.elements.iframeLibraryFrame);
const loading = root.querySelector(Selectors.IFRAME.elements.iframeLibraryLoading);
const placeholder = root.querySelector(Selectors.IFRAME.elements.iframeLibraryPlaceholder);
if (placeholder) placeholder.classList.add('d-none');
if (iframe && !iframe.src) {
if (loading) loading.classList.remove('d-none');
iframe.classList.add('d-none');
iframe.onload = () => {
if (loading) loading.classList.add('d-none');
iframe.classList.remove('d-none');
};
iframe.src = ltiConfig.contentItemUrl;
}
}
}
handleIframeLibraryMessage(root, event) {
const data = event.data;
if (!data) return;
let embedUrl = null;
let videoId = null;
// LTI Deep Linking Response
if (data.type === 'ltiDeepLinkingResponse' || data.messageType === 'LtiDeepLinkingResponse') {
const items = data.content_items || data.contentItems || [];
if (items.length) {
embedUrl = items[0].url || items[0].embed_url;
if (embedUrl) {
const parsed = this.parseInput(embedUrl);
if (parsed) videoId = parsed.videoId;
}
}
}
// MediaCMS custom message
if (data.action === 'selectMedia' || data.type === 'videoSelected') {
embedUrl = data.embedUrl || data.url;
videoId = data.mediaId || data.videoId || data.id;
}
if (videoId) {
const mediaCMSUrl = getMediaCMSUrl(this.editor);
if (mediaCMSUrl) {
const viewUrl = `${mediaCMSUrl}/view?m=${videoId}`;
const urlInput = root.querySelector(Selectors.IFRAME.elements.url);
if (urlInput) {
urlInput.value = viewUrl;
this.updatePreview(root);
this.switchToTab(root, 'url');
}
}
}
}
async handleDialogueSubmission(modal) {
const root = modal.getRoot()[0];
const values = this.getFormValues(root);
const html = await this.generateIframeHtml(values);
if (html) {
this.editor.insertContent(html);
}
modal.hide();
}
}

View File

@@ -1,14 +0,0 @@
import Modal from 'core/modal';
import ModalRegistry from 'core/modal_registry';
import { component } from './common';
export default class IframeModal extends Modal {
// Standard class methods if needed
}
// Define static properties outside the class body for compatibility
IframeModal.TYPE = `${component}/iframe_embed_modal`;
IframeModal.TEMPLATE = `${component}/iframe_embed_modal`;
ModalRegistry.register(IframeModal.TYPE, IframeModal, IframeModal.TEMPLATE);

View File

@@ -1,25 +0,0 @@
import { component } from './common';
export const register = (editor) => {
const registerOption = editor.options.register;
registerOption(`${component}:mediacmsurl`, {
processor: 'string',
default: ''
});
registerOption(`${component}:launchUrl`, {
processor: 'string',
default: ''
});
registerOption(`${component}:lti`, {
processor: 'object',
default: {}
});
};
export const getMediaCMSUrl = (editor) => editor.options.get(`${component}:mediacmsurl`);
export const getLaunchUrl = (editor) => editor.options.get(`${component}:launchUrl`);
export const getLti = (editor) => editor.options.get(`${component}:lti`);

View File

@@ -1,23 +0,0 @@
import { getTinyMCE } from 'editor_tiny/loader';
import { getPluginMetadata } from 'editor_tiny/utils';
import { component, pluginName } from './common';
import * as Commands from './commands';
import * as Options from './options';
import * as Configuration from './configuration';
export default new Promise(async (resolve) => {
const [tinyMCE, setupCommands, pluginMetadata] = await Promise.all([
getTinyMCE(),
Commands.getSetup(),
getPluginMetadata(component, pluginName),
]);
tinyMCE.PluginManager.add(`${component}/plugin`, (editor) => {
Options.register(editor);
setupCommands(editor);
return pluginMetadata;
});
resolve([`${component}/plugin`, Configuration]);
});

View File

@@ -1,19 +0,0 @@
export default {
IFRAME: {
elements: {
form: '.tiny-mediacms-iframe-form',
url: 'input[name="mediacms_url"]',
width: 'input[name="mediacms_width"]',
height: 'input[name="mediacms_height"]',
preview: '.tiny-mediacms-preview',
tabUrlBtn: '#tiny-mediacms-tab-url',
tabIframeLibraryBtn: '#tiny-mediacms-tab-library',
paneUrl: '#tiny-mediacms-pane-url',
paneIframeLibrary: '#tiny-mediacms-pane-library',
iframeLibraryFrame: '.tiny-mediacms-library-frame',
iframeLibraryLoading: '.tiny-mediacms-library-loading',
iframeLibraryPlaceholder: '.tiny-mediacms-library-placeholder'
}
}
};

View File

@@ -1,70 +0,0 @@
<?php
namespace tiny_mediacms;
use context;
use moodle_url;
use editor_tiny\plugin;
use editor_tiny\plugin_with_buttons;
use editor_tiny\plugin_with_menuitems;
defined('MOODLE_INTERNAL') || die();
class plugininfo extends plugin implements plugin_with_buttons, plugin_with_menuitems {
/**
* Whether the plugin is enabled
*/
public static function is_enabled(context $context, array $options, array $fpoptions, ?\editor_tiny\editor $editor = null): bool {
return isloggedin() && !isguestuser();
}
/**
* Get available buttons
*/
public static function get_available_buttons(): array {
return [
'tiny_mediacms/tiny_mediacms_video',
];
}
/**
* Get available menu items
*/
public static function get_available_menuitems(): array {
return [
'tiny_mediacms/tiny_mediacms_video',
];
}
/**
* Get the plugin configuration for the editor.
*/
protected static function get_plugin_configuration_for_context(context $context, array $options = []): array {
global $CFG;
// Read settings from the FILTER plugin
$mediacmsurl = get_config('filter_mediacms', 'mediacmsurl');
$ltitoolid = get_config('filter_mediacms', 'ltitoolid');
// Construct launch URL for the filter
$launchurl = new moodle_url('/filter/mediacms/launch.php');
// Content Item URL for LTI Deep Linking (if using the picker)
// Usually: /mod/lti/contentitem.php?id=LTI_TYPE_ID
$contentitemurl = '';
if ($ltitoolid) {
$contentitemurl = new moodle_url('/mod/lti/contentitem.php');
}
return [
'mediacmsurl' => $mediacmsurl,
'launchUrl' => $launchurl->out(false),
'lti' => [
'toolId' => (int) $ltitoolid,
'courseId' => $context->get_course_context(false)->instanceid ?? 0,
'contentItemUrl' => $contentitemurl ? $contentitemurl->out(false) : '',
]
];
}
}

View File

@@ -1,10 +0,0 @@
<?php
namespace tiny_mediacms\privacy;
defined('MOODLE_INTERNAL') || die();
class provider implements \core_privacy\local\metadata\null_provider {
public static function get_reason(): string {
return 'privacy:metadata';
}
}

View File

@@ -1,13 +0,0 @@
<?php
defined('MOODLE_INTERNAL') || die();
$string['pluginname'] = 'MediaCMS';
$string['mediacms:view'] = 'View MediaCMS';
$string['mediacms'] = 'MediaCMS';
$string['insertmedia'] = 'Insert MediaCMS Video';
$string['iframemodaltitle'] = 'Insert MediaCMS Video';
$string['urltab'] = 'URL';
$string['iframelibrarytab'] = 'Video Library';
$string['enterurl'] = 'Enter Video URL';
$string['invalidurl'] = 'Invalid MediaCMS URL';
$string['removeiframeconfirm'] = 'Are you sure you want to remove this video?';

View File

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
<path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/>
</svg>

Before

Width:  |  Height:  |  Size: 238 B

View File

@@ -1,4 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">
<circle cx="50" cy="50" r="48" fill="#2EAF5A"/>
<polygon points="38,28 38,72 75,50" fill="#FFFFFF"/>
</svg>

Before

Width:  |  Height:  |  Size: 200 B

View File

@@ -1,40 +0,0 @@
{{!
@template tiny_mediacms/iframe_embed_modal
}}
{{< core/modal }}
{{$body}}
<form class="tiny_iframecms_form" id="{{elementid}}_tiny_iframecms_form">
<ul class="nav nav-tabs mb-3" role="tablist">
<li class="nav-item">
<button class="nav-link active" id="{{elementid}}_tab_url" data-bs-toggle="tab" data-bs-target="#{{elementid}}_pane_url" type="button" role="tab">{{#str}} urltab, tiny_mediacms {{/str}}</button>
</li>
<li class="nav-item">
<button class="nav-link" id="{{elementid}}_tab_iframe_library" data-bs-toggle="tab" data-bs-target="#{{elementid}}_pane_iframe_library" type="button" role="tab">{{#str}} iframelibrarytab, tiny_mediacms {{/str}}</button>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade show active" id="{{elementid}}_pane_url" role="tabpanel">
<div class="mb-3">
<label class="form-label">{{#str}} enterurl, tiny_mediacms {{/str}}</label>
<input type="text" class="form-control tiny_iframecms_url" name="mediacms_url" value="{{url}}">
</div>
{{> tiny_mediacms/iframe_embed_options }}
<div class="tiny_mediacms_preview border p-2 text-center bg-light" style="min-height:200px">
Preview
</div>
</div>
<div class="tab-pane fade" id="{{elementid}}_pane_iframe_library" role="tabpanel">
<div class="tiny_mediacms_library_container text-center" style="min-height:400px">
<div class="tiny_mediacms_library_loading d-none">Loading...</div>
<iframe class="tiny_mediacms_library_frame d-none" style="width:100%;height:400px;border:0;"></iframe>
<div class="tiny_mediacms_library_placeholder p-5">Library will load here</div>
</div>
</div>
</div>
</form>
{{/body}}
{{$footer}}
<button type="button" class="btn btn-primary" data-action="save">{{#str}} insertmedia, tiny_mediacms {{/str}}</button>
<button type="button" class="btn btn-secondary" data-action="cancel">{{#str}} cancel, moodle {{/str}}</button>
{{/footer}}
{{/ core/modal }}

View File

@@ -1,47 +0,0 @@
{{!
@template tiny_mediacms/iframe_embed_options
}}
<div class="mb-3">
<label class="form-label font-weight-bold">{{#str}} embedoptions, tiny_mediacms {{/str}}</label>
<div class="row">
<div class="col-6">
<div class="form-check mb-2">
<input type="checkbox" class="form-check-input tiny_iframecms_showtitle" id="{{elementid}}_showtitle" {{#showTitle}}checked{{/showTitle}}>
<label class="form-check-label" for="{{elementid}}_showtitle">{{#str}} showtitle, tiny_mediacms {{/str}}</label>
</div>
<div class="form-check mb-2">
<input type="checkbox" class="form-check-input tiny_iframecms_linktitle" id="{{elementid}}_linktitle" {{#linkTitle}}checked{{/linkTitle}}>
<label class="form-check-label" for="{{elementid}}_linktitle">{{#str}} linktitle, tiny_mediacms {{/str}}</label>
</div>
</div>
<div class="col-6">
<div class="form-check mb-2">
<input type="checkbox" class="form-check-input tiny_iframecms_responsive" id="{{elementid}}_responsive" {{#responsive}}checked{{/responsive}}>
<label class="form-check-label" for="{{elementid}}_responsive">{{#str}} responsive, tiny_mediacms {{/str}}</label>
</div>
<div class="form-check mb-2">
<label class="form-check-label">{{#str}} aspectratio, tiny_mediacms {{/str}}</label>
<select class="form-control form-control-sm tiny_iframecms_aspectratio" id="{{elementid}}_aspectratio">
<option value="16:9" {{#is16_9}}selected{{/is16_9}}>16:9</option>
<option value="4:3" {{#is4_3}}selected{{/is4_3}}>4:3</option>
<option value="1:1" {{#is1_1}}selected{{/is1_1}}>1:1</option>
<option value="custom" {{#isCustom}}selected{{/isCustom}}>Custom</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-6">
<div class="input-group input-group-sm">
<span class="input-group-text">{{#str}} width, tiny_mediacms {{/str}}</span>
<input type="number" class="form-control tiny_iframecms_width" id="{{elementid}}_width" value="{{width}}">
</div>
</div>
<div class="col-6">
<div class="input-group input-group-sm">
<span class="input-group-text">{{#str}} height, tiny_mediacms {{/str}}</span>
<input type="number" class="form-control tiny_iframecms_height" id="{{elementid}}_height" value="{{height}}">
</div>
</div>
</div>
</div>

View File

@@ -1,9 +0,0 @@
{{!
@template tiny_mediacms/iframe_embed_output
}}
{{#responsive}}
<iframe src="{{src}}" style="width:100%;aspect-ratio:{{aspectRatioValue}};display:block;border:0;" allowFullScreen></iframe>
{{/responsive}}
{{^responsive}}
<iframe width="{{width}}" height="{{height}}" src="{{src}}" frameBorder="0" allowFullScreen></iframe>
{{/responsive}}

View File

@@ -1,9 +0,0 @@
<?php
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2026020101; // Bumped version
$plugin->requires = 2024100700;
$plugin->component = 'tiny_mediacms';
$plugin->maturity = MATURITY_STABLE;
$plugin->release = 'v1.0.1';
$plugin->dependencies = ['filter_mediacms' => 2026020100];