This commit is contained in:
Markos Gogoulos
2026-02-01 14:19:16 +02:00
parent 7c04cc30fb
commit c6726d1b13
28 changed files with 4147 additions and 68 deletions

View File

@@ -0,0 +1,13 @@
{
"presets": [
["@babel/preset-env", {
"modules": "amd",
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 10"]
}
}]
],
"plugins": [
"@babel/plugin-transform-modules-amd"
]
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,18 @@
{
"name": "mediacms-moodle",
"version": "1.0.0",
"description": "This package provides the integration between MediaCMS and Moodle (versions 4.x and 5.x). It consists of two components that work together to provide a seamless video experience:",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/cli": "^7.28.6",
"@babel/core": "^7.29.0",
"@babel/plugin-transform-modules-amd": "^7.27.1",
"@babel/preset-env": "^7.29.0"
}
}

View File

@@ -0,0 +1,36 @@
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

@@ -0,0 +1,61 @@
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

@@ -0,0 +1,61 @@
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

@@ -0,0 +1,11 @@
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

@@ -0,0 +1,11 @@
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

@@ -0,0 +1,15 @@
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

@@ -0,0 +1,15 @@
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

@@ -0,0 +1,512 @@
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

@@ -0,0 +1,512 @@
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

@@ -0,0 +1,35 @@
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

@@ -0,0 +1,35 @@
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

@@ -0,0 +1,32 @@
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

@@ -0,0 +1,32 @@
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

@@ -0,0 +1,52 @@
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

@@ -0,0 +1,52 @@
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

@@ -0,0 +1,26 @@
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

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

View File

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

View File

@@ -8,16 +8,15 @@ import Selectors from './selectors';
import { getLti, getLaunchUrl, getMediaCMSUrl } from './options'; import { getLti, getLaunchUrl, getMediaCMSUrl } from './options';
export default class IframeEmbed { export default class IframeEmbed {
editor = null;
currentModal = null;
isUpdating = false;
selectedIframe = null;
debounceTimer = null;
iframeLibraryLoaded = false;
selectedLibraryVideo = null;
constructor(editor) { constructor(editor) {
this.editor = editor; this.editor = editor;
this.currentModal = null;
this.isUpdating = false;
this.selectedIframe = null;
this.debounceTimer = null;
this.iframeLibraryLoaded = false;
this.selectedLibraryVideo = null;
} }
parseInput(input) { parseInput(input) {
@@ -44,11 +43,8 @@ export default class IframeEmbed {
const urlObj = new URL(url); const urlObj = new URL(url);
const baseUrl = `${urlObj.protocol}//${urlObj.host}`; const baseUrl = `${urlObj.protocol}//${urlObj.host}`;
// Check if it matches configured MediaCMS URL (if strictly required)
// For now we accept any valid MediaCMS-like structure
// /view?m=ID // /view?m=ID
if (urlObj.pathname.includes('/view') && urlObj.searchParams.has('m')) { if (urlObj.pathname.indexOf('/view') !== -1 && urlObj.searchParams.has('m')) {
return { return {
baseUrl: baseUrl, baseUrl: baseUrl,
videoId: urlObj.searchParams.get('m'), videoId: urlObj.searchParams.get('m'),
@@ -57,7 +53,7 @@ export default class IframeEmbed {
} }
// /embed?m=ID // /embed?m=ID
if (urlObj.pathname.includes('/embed') && urlObj.searchParams.has('m')) { if (urlObj.pathname.indexOf('/embed') !== -1 && urlObj.searchParams.has('m')) {
return { return {
baseUrl: baseUrl, baseUrl: baseUrl,
videoId: urlObj.searchParams.get('m'), videoId: urlObj.searchParams.get('m'),
@@ -71,7 +67,7 @@ export default class IframeEmbed {
} }
// Check if it's already a launch.php URL // Check if it's already a launch.php URL
if (urlObj.pathname.includes('/filter/mediacms/launch.php') && urlObj.searchParams.has('token')) { if (urlObj.pathname.indexOf('/filter/mediacms/launch.php') !== -1 && urlObj.searchParams.has('token')) {
return { return {
baseUrl: baseUrl, baseUrl: baseUrl,
videoId: urlObj.searchParams.get('token'), videoId: urlObj.searchParams.get('token'),
@@ -112,7 +108,12 @@ export default class IframeEmbed {
return url.toString(); return url.toString();
} }
async getTemplateContext(data = {}) { async getTemplateContext(data) {
data = data || {};
const width = data.width || 560;
const height = data.height || 315;
const aspectRatio = data.aspectRatio || '16:9';
return { return {
elementid: this.editor.getElement().id, elementid: this.editor.getElement().id,
isupdating: this.isUpdating, isupdating: this.isUpdating,
@@ -124,12 +125,12 @@ export default class IframeEmbed {
responsive: data.responsive !== false, responsive: data.responsive !== false,
startAtEnabled: data.startAtEnabled || false, startAtEnabled: data.startAtEnabled || false,
startAt: data.startAt || '0:00', startAt: data.startAt || '0:00',
width: data.width || 560, width: width,
height: data.height || 315, height: height,
is16_9: !data.aspectRatio || data.aspectRatio === '16:9', is16_9: aspectRatio === '16:9',
is4_3: data.aspectRatio === '4:3', is4_3: aspectRatio === '4:3',
is1_1: data.aspectRatio === '1:1', is1_1: aspectRatio === '1:1',
isCustom: data.aspectRatio === 'custom', isCustom: aspectRatio === 'custom',
}; };
} }
@@ -139,9 +140,12 @@ export default class IframeEmbed {
this.isUpdating = data !== null; this.isUpdating = data !== null;
this.iframeLibraryLoaded = false; this.iframeLibraryLoaded = false;
const title = await getString('iframemodaltitle', component);
const templateContext = await this.getTemplateContext(data || {});
this.currentModal = await IframeModal.create({ this.currentModal = await IframeModal.create({
title: await getString('iframemodaltitle', component), title: title,
templateContext: await this.getTemplateContext(data || {}), templateContext: templateContext,
}); });
await this.registerEventListeners(this.currentModal); await this.registerEventListeners(this.currentModal);
@@ -158,20 +162,31 @@ export default class IframeEmbed {
const src = this.selectedIframe.getAttribute('src'); const src = this.selectedIframe.getAttribute('src');
const parsed = this.parseInput(src); const parsed = this.parseInput(src);
// Defaults
let showTitle = true;
if (parsed && typeof parsed.showTitle !== 'undefined') {
showTitle = parsed.showTitle;
}
return { return {
url: src, url: src,
width: this.selectedIframe.getAttribute('width') || 560, width: this.selectedIframe.getAttribute('width') || 560,
height: this.selectedIframe.getAttribute('height') || 315, height: this.selectedIframe.getAttribute('height') || 315,
showTitle: parsed?.showTitle ?? true, showTitle: showTitle,
// ... other defaults
}; };
} }
getFormValues(root) { getFormValues(root) {
const form = root.querySelector(Selectors.IFRAME.elements.form); const form = root.querySelector(Selectors.IFRAME.elements.form);
// Helper to safely get value or checked state // Helper to safely get value or checked state
const getVal = (sel) => form.querySelector(sel)?.value; const getVal = (sel) => {
const getCheck = (sel) => form.querySelector(sel)?.checked; const el = form.querySelector(sel);
return el ? el.value : '';
};
const getCheck = (sel) => {
const el = form.querySelector(sel);
return el ? el.checked : false;
};
return { return {
url: getVal(Selectors.IFRAME.elements.url).trim(), url: getVal(Selectors.IFRAME.elements.url).trim(),
@@ -207,11 +222,11 @@ export default class IframeEmbed {
aspectRatioValue: aspectRatioCalcs[values.aspectRatio] || '16 / 9', aspectRatioValue: aspectRatioCalcs[values.aspectRatio] || '16 / 9',
}; };
const { html } = await Templates.renderForPromise( const template = await Templates.renderForPromise(
`${component}/iframe_embed_output`, `${component}/iframe_embed_output`,
context context
); );
return html; return template.html;
} }
async updatePreview(root) { async updatePreview(root) {
@@ -234,16 +249,16 @@ export default class IframeEmbed {
previewContainer.innerHTML = `<iframe src="${embedUrl}" width="100%" height="200" frameborder="0"></iframe>`; previewContainer.innerHTML = `<iframe src="${embedUrl}" width="100%" height="200" frameborder="0"></iframe>`;
} }
// ... Event listeners and Modal handling ...
// Simplified for brevity, assuming standard handlers
async registerEventListeners(modal) { async registerEventListeners(modal) {
const root = modal.getRoot()[0]; const root = modal.getRoot()[0];
const form = root.querySelector(Selectors.IFRAME.elements.form); const form = root.querySelector(Selectors.IFRAME.elements.form);
// Input changes update preview // Input changes update preview
form.addEventListener('change', () => this.updatePreview(root)); form.addEventListener('change', () => this.updatePreview(root));
form.querySelector(Selectors.IFRAME.elements.url).addEventListener('input', () => this.updatePreview(root)); const urlInput = form.querySelector(Selectors.IFRAME.elements.url);
if (urlInput) {
urlInput.addEventListener('input', () => this.updatePreview(root));
}
// Tab switching // Tab switching
const tabUrl = form.querySelector(Selectors.IFRAME.elements.tabUrlBtn); const tabUrl = form.querySelector(Selectors.IFRAME.elements.tabUrlBtn);
@@ -278,15 +293,15 @@ export default class IframeEmbed {
const libBtn = form.querySelector(Selectors.IFRAME.elements.tabIframeLibraryBtn); const libBtn = form.querySelector(Selectors.IFRAME.elements.tabIframeLibraryBtn);
if (tab === 'url') { if (tab === 'url') {
urlPane.classList.add('show', 'active'); if(urlPane) { urlPane.classList.add('show', 'active'); }
libPane.classList.remove('show', 'active'); if(libPane) { libPane.classList.remove('show', 'active'); }
urlBtn.classList.add('active'); if(urlBtn) { urlBtn.classList.add('active'); }
libBtn.classList.remove('active'); if(libBtn) { libBtn.classList.remove('active'); }
} else { } else {
urlPane.classList.remove('show', 'active'); if(urlPane) { urlPane.classList.remove('show', 'active'); }
libPane.classList.add('show', 'active'); if(libPane) { libPane.classList.add('show', 'active'); }
urlBtn.classList.remove('active'); if(urlBtn) { urlBtn.classList.remove('active'); }
libBtn.classList.add('active'); if(libBtn) { libBtn.classList.add('active'); }
} }
} }
@@ -295,13 +310,16 @@ export default class IframeEmbed {
if (ltiConfig && ltiConfig.contentItemUrl) { if (ltiConfig && ltiConfig.contentItemUrl) {
const iframe = root.querySelector(Selectors.IFRAME.elements.iframeLibraryFrame); const iframe = root.querySelector(Selectors.IFRAME.elements.iframeLibraryFrame);
const loading = root.querySelector(Selectors.IFRAME.elements.iframeLibraryLoading); 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 (iframe && !iframe.src) {
loading.classList.remove('d-none'); if (loading) loading.classList.remove('d-none');
iframe.classList.add('d-none'); iframe.classList.add('d-none');
iframe.onload = () => { iframe.onload = () => {
loading.classList.add('d-none'); if (loading) loading.classList.add('d-none');
iframe.classList.remove('d-none'); iframe.classList.remove('d-none');
}; };
@@ -322,9 +340,6 @@ export default class IframeEmbed {
const items = data.content_items || data.contentItems || []; const items = data.content_items || data.contentItems || [];
if (items.length) { if (items.length) {
embedUrl = items[0].url || items[0].embed_url; embedUrl = items[0].url || items[0].embed_url;
// Try to extract ID from URL if not provided
// But actually we just need the ID to build the launch URL
// If the response gives us a full embed URL, we can parse it
if (embedUrl) { if (embedUrl) {
const parsed = this.parseInput(embedUrl); const parsed = this.parseInput(embedUrl);
if (parsed) videoId = parsed.videoId; if (parsed) videoId = parsed.videoId;
@@ -339,21 +354,18 @@ export default class IframeEmbed {
} }
if (videoId) { if (videoId) {
// Populate URL field with the clean embed URL (launch URL) if possible,
// or just the direct URL which parseInput will handle
// Actually, best to set the raw MediaCMS URL and let parseInput -> buildEmbedUrl handle the conversion
// But if we have the ID, we can construct a view URL
const mediaCMSUrl = getMediaCMSUrl(this.editor); const mediaCMSUrl = getMediaCMSUrl(this.editor);
if (mediaCMSUrl) { if (mediaCMSUrl) {
const viewUrl = `${mediaCMSUrl}/view?m=${videoId}`; const viewUrl = `${mediaCMSUrl}/view?m=${videoId}`;
const urlInput = root.querySelector(Selectors.IFRAME.elements.url); const urlInput = root.querySelector(Selectors.IFRAME.elements.url);
if (urlInput) {
urlInput.value = viewUrl; urlInput.value = viewUrl;
this.updatePreview(root); this.updatePreview(root);
this.switchToTab(root, 'url'); this.switchToTab(root, 'url');
} }
} }
} }
}
async handleDialogueSubmission(modal) { async handleDialogueSubmission(modal) {
const root = modal.getRoot()[0]; const root = modal.getRoot()[0];

View File

@@ -4,8 +4,11 @@ import ModalRegistry from 'core/modal_registry';
import { component } from './common'; import { component } from './common';
export default class IframeModal extends Modal { export default class IframeModal extends Modal {
static TYPE = `${component}/iframe_embed_modal`; // Standard class methods if needed
static TEMPLATE = `${component}/iframe_embed_modal`;
} }
// 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); ModalRegistry.register(IframeModal.TYPE, IframeModal, IframeModal.TEMPLATE);

View File

@@ -24,7 +24,7 @@ class plugininfo extends plugin implements plugin_with_buttons, plugin_with_menu
*/ */
public static function get_available_buttons(): array { public static function get_available_buttons(): array {
return [ return [
'tiny_mediacms/tiny_mediacms', 'tiny_mediacms/tiny_mediacms_video',
]; ];
} }
@@ -33,7 +33,7 @@ class plugininfo extends plugin implements plugin_with_buttons, plugin_with_menu
*/ */
public static function get_available_menuitems(): array { public static function get_available_menuitems(): array {
return [ return [
'tiny_mediacms/tiny_mediacms', 'tiny_mediacms/tiny_mediacms_video',
]; ];
} }

View File

@@ -0,0 +1,4 @@
<?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>

After

Width:  |  Height:  |  Size: 238 B

View File

@@ -0,0 +1,4 @@
<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>

After

Width:  |  Height:  |  Size: 200 B

View File

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