@oat-sa/tao-core-ui 3.22.0 → 3.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/figure/FigureStateActive.js +64 -32
  2. package/dist/image/ImgStateActive/initHelper.js +64 -32
  3. package/dist/image/ImgStateActive.js +64 -32
  4. package/dist/mediaplayer/players/html5.js +44 -18
  5. package/dist/mediaplayer/utils/crossOrigin.js +64 -0
  6. package/dist/mediaplayer.js +7 -1
  7. package/dist/previewer.js +1 -1
  8. package/dist/resourcemgr/assetSearch.js +793 -0
  9. package/dist/resourcemgr/assetSearchContract.js +477 -0
  10. package/dist/resourcemgr/css/resourcemgr.css +1137 -97
  11. package/dist/resourcemgr/css/resourcemgr.css.map +1 -1
  12. package/dist/resourcemgr/fileBrowser.js +456 -79
  13. package/dist/resourcemgr/filePreview.js +40 -4
  14. package/dist/resourcemgr/fileSelector.js +362 -92
  15. package/dist/resourcemgr.js +309 -57
  16. package/dist/searchModal/advancedSearch.js +233 -31
  17. package/package.json +15 -6
  18. package/src/image/ImgStateActive/initHelper.js +69 -31
  19. package/src/mediaplayer/players/html5.js +17 -7
  20. package/src/mediaplayer/readme.md +17 -0
  21. package/src/mediaplayer/tpl/audio.tpl +1 -1
  22. package/src/mediaplayer/tpl/video.tpl +1 -1
  23. package/src/mediaplayer/utils/crossOrigin.js +63 -0
  24. package/src/mediaplayer.js +10 -0
  25. package/src/previewer.js +1 -1
  26. package/src/resourcemgr/assetSearch.js +847 -0
  27. package/src/resourcemgr/assetSearchContract.js +489 -0
  28. package/src/resourcemgr/css/resourcemgr.css +1137 -97
  29. package/src/resourcemgr/css/resourcemgr.css.map +1 -1
  30. package/src/resourcemgr/fileBrowser.js +470 -91
  31. package/src/resourcemgr/filePreview.js +46 -4
  32. package/src/resourcemgr/fileSelector.js +338 -46
  33. package/src/resourcemgr/scss/resourcemgr.scss +1351 -88
  34. package/src/resourcemgr/tpl/advanced-search.tpl +10 -0
  35. package/src/resourcemgr/tpl/fileSelect.tpl +25 -28
  36. package/src/resourcemgr/tpl/folder.tpl +4 -1
  37. package/src/resourcemgr/tpl/layout.tpl +113 -54
  38. package/src/resourcemgr/tpl/rootFolder.tpl +3 -1
  39. package/src/resourcemgr.js +289 -47
  40. package/src/searchModal/advancedSearch.js +242 -31
@@ -24,6 +24,7 @@ require(['ui/mediaplayer'], function(mediaplayer) {
24
24
  - *Number* **volume** - Sets the sound volume (default: 80)
25
25
  - *Number* **width** - Sets the width of the player (default: depends on media type)
26
26
  - *Number* **height** - Sets the height of the player (default: depends on media type)
27
+ - *String* **crossOriginMode** - CORS mode for cross-domain HTML5 sources: `anonymous` (default, bare `crossorigin`) or `use-credentials` (`crossorigin="use-credentials"`)
27
28
  - *Function* **onrender** - Event listener called when the player is rendering
28
29
  - *Function* **onready** - Event listener called when the player is fully ready
29
30
  - *Function* **onplay** - Event listener called when the playback is starting
@@ -33,6 +34,22 @@ require(['ui/mediaplayer'], function(mediaplayer) {
33
34
  - *Function* **onlimitreached** - Event listener called when the play limit has been reached
34
35
  - *Function* **ondestroy** - Event listener called when the player is destroying
35
36
 
37
+ ### Module configuration
38
+
39
+ Set a default `crossOriginMode` for all player instances via RequireJS:
40
+
41
+ ```javascript
42
+ require.config({
43
+ config: {
44
+ 'ui/mediaplayer': {
45
+ crossOriginMode: 'use-credentials'
46
+ }
47
+ }
48
+ });
49
+ ```
50
+
51
+ Per-instance `crossOriginMode` overrides the module default.
52
+
36
53
  ### Events
37
54
 
38
55
  Some events are triggered both on the component using `eventifier` and on the DOM through the component wrapper.
@@ -1,4 +1,4 @@
1
- <audio class="media audio" preload="{{preload}}" controls {{#if cors}}crossorigin{{/if}}>
1
+ <audio class="media audio" preload="{{preload}}" controls{{#if crossOriginUseCredentials}} crossorigin="use-credentials"{{else}}{{#if crossOrigin}} crossorigin{{/if}}{{/if}}>
2
2
  {{__ 'Your browser doesn’t support the audio player.'}}
3
3
  {{#if link}}
4
4
  <a href="{{link}}">{{__ 'Please download the track and listen offline.'}}</a>
@@ -1,4 +1,4 @@
1
- <video class="media video" preload="{{preload}}" poster="{{poster}}" controls {{#if cors}}crossorigin{{/if}}>
1
+ <video class="media video" preload="{{preload}}" poster="{{poster}}" controls{{#if crossOriginUseCredentials}} crossorigin="use-credentials"{{else}}{{#if crossOrigin}} crossorigin{{/if}}{{/if}}>
2
2
  {{__ 'Your browser doesn’t support the video player.'}}
3
3
  {{#if link}}
4
4
  <a href="{{link}}">{{__ 'Please download the video and view offline.'}}</a>
@@ -0,0 +1,63 @@
1
+ /**
2
+ * This program is free software; you can redistribute it and/or
3
+ * modify it under the terms of the GNU General Public License
4
+ * as published by the Free Software Foundation; under version 2
5
+ * of the License (non-upgradable).
6
+ *
7
+ * This program is distributed in the hope that it will be useful,
8
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ * GNU General Public License for more details.
11
+ *
12
+ * You should have received a copy of the GNU General Public License
13
+ * along with this program; if not, write to the Free Software
14
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
+ *
16
+ * Copyright (c) 2026 (original work) Open Assessment Technologies SA ;
17
+ */
18
+
19
+ /** @typedef {'anonymous' | 'use-credentials'} CrossOriginMode */
20
+
21
+ const VALID_CROSS_ORIGIN_MODES = new Set(['anonymous', 'use-credentials']);
22
+
23
+ /**
24
+ * Normalises cross-origin mode from instance or RequireJS module config.
25
+ * @param {CrossOriginMode | string | undefined | null} instanceMode
26
+ * @param {CrossOriginMode | string | undefined | null} [moduleMode]
27
+ * @returns {CrossOriginMode}
28
+ */
29
+ function resolveCrossOriginMode(instanceMode, moduleMode) {
30
+ let mode = instanceMode;
31
+
32
+ if (typeof mode === 'undefined' || mode === null) {
33
+ mode = moduleMode;
34
+ }
35
+ if (typeof mode === 'undefined' || mode === null) {
36
+ mode = 'anonymous';
37
+ }
38
+
39
+ return VALID_CROSS_ORIGIN_MODES.has(mode) ? /** @type {CrossOriginMode} */ (mode) : 'anonymous';
40
+ }
41
+
42
+ /**
43
+ * Resolves the crossorigin attribute for HTML5 media when sources are cross-domain.
44
+ * @param {Array<{ src?: string }>} sources
45
+ * @param {CrossOriginMode} crossOriginMode
46
+ * @param {{ sameDomain: (url: string) => boolean }} page
47
+ * @returns {CrossOriginMode | null} null when attribute should be omitted
48
+ */
49
+ function resolveCrossOriginAttribute(sources, crossOriginMode, page) {
50
+ const isCrossDomain = sources.some(source => source && source.src && !page.sameDomain(source.src));
51
+
52
+ if (!isCrossDomain) {
53
+ return null;
54
+ }
55
+
56
+ return resolveCrossOriginMode(crossOriginMode);
57
+ }
58
+
59
+ export default {
60
+ VALID_CROSS_ORIGIN_MODES,
61
+ resolveCrossOriginMode,
62
+ resolveCrossOriginAttribute
63
+ };
@@ -27,9 +27,13 @@ import store from 'core/store';
27
27
  import support from 'ui/mediaplayer/support';
28
28
  import players from 'ui/mediaplayer/players';
29
29
  import playerTpl from 'ui/mediaplayer/tpl/player';
30
+ import crossOriginUtil from 'ui/mediaplayer/utils/crossOrigin';
31
+ import module from 'module';
30
32
  import 'ui/mediaplayer/css/player.css';
31
33
  import 'nouislider';
32
34
 
35
+ const moduleConfig = module.config ? module.config() : {};
36
+
33
37
  /**
34
38
  * CSS namespace
35
39
  * @type {String}
@@ -212,6 +216,7 @@ const isResponsiveSize = sizeProps => {
212
216
  * @param {Number} [config.height] - Sets the height of the player (default: depends on media type)
213
217
  * @param {Boolean} [config.preview] - Enables the media preview (load media metadata)
214
218
  * @param {Boolean} [config.debug] - Enables the debug mode
219
+ * @param {'anonymous'|'use-credentials'} [config.crossOriginMode] - CORS credentials mode for cross-domain HTML5 sources (default: module config, then anonymous)
215
220
  * @param {number} [config.config.stalledDetectionDelay] - The delay before considering a media is stalled
216
221
  * @event render - Event triggered when the player is rendering
217
222
  * @event error - Event triggered when the player throws an unrecoverable error
@@ -239,6 +244,10 @@ function mediaplayerFactory(config) {
239
244
  // load the config set, discard null values in order to allow defaults to be set
240
245
  this.config = _.omitBy(mediaPlayerConfig || {}, value => typeof value === 'undefined' || value === null);
241
246
  _.defaults(this.config, defaults.options);
247
+ this.config.crossOriginMode = crossOriginUtil.resolveCrossOriginMode(
248
+ this.config.crossOriginMode,
249
+ moduleConfig.crossOriginMode
250
+ );
242
251
  if (!this.config.mimeType && 'string' === typeof this.config.type && this.config.type.indexOf('/') > 0) {
243
252
  this.config.mimeType = this.config.type;
244
253
  }
@@ -882,6 +891,7 @@ function mediaplayerFactory(config) {
882
891
  sources: this.getSources(),
883
892
  preview: this.config.preview,
884
893
  debug: this.config.debug,
894
+ crossOriginMode: this.config.crossOriginMode,
885
895
  stalledDetectionDelay: this.config.stalledDetectionDelay
886
896
  };
887
897
  this.player = playerFactory(this.$player, playerConfig)
package/src/previewer.js CHANGED
@@ -227,7 +227,7 @@ const previewer = {
227
227
  // stop video, free the socket and remove player interface on video deletion
228
228
  // stop video and free the socket on all other cases when video is selected or temporary hidden or modal window is closed
229
229
  $controls = $(
230
- '.actions a:nth-child(1), .actions a:nth-child(3), .icon-close, .upload-switcher, .select-action, .files li>span',
230
+ '.actions a:nth-child(1), .actions a:nth-child(3), .icon-close, .upload-switcher, .select-action, .files-list tr, .files .desc',
231
231
  '#mediaManager'
232
232
  );
233
233
  $controls.off('mousedown.mediaelement').on('mousedown.mediaelement', function(event) {