@instructure/canvas-rce 5.8.0 → 5.10.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 (43) hide show
  1. package/.mocharc.js +7 -0
  2. package/CHANGELOG.md +20 -0
  3. package/es/enhance-user-content/mathml.js +8 -5
  4. package/es/rce/RCEWrapper.js +65 -6
  5. package/es/rce/RCEWrapperProps.js +1 -0
  6. package/es/rce/__mocks__/_mockCryptoEs.js +124 -0
  7. package/es/rce/plugins/instructure_equation/EquationEditorModal/parseLatex.js +0 -2
  8. package/es/rce/plugins/instructure_rce_external_tools/components/ExternalToolDialog/ExternalToolDialogModal.js +4 -5
  9. package/es/rce/plugins/shared/CanvasContentTray.js +8 -8
  10. package/es/rce/plugins/shared/ContentSelection.js +7 -3
  11. package/es/rce/plugins/shared/ImageCropper/Preview.js +8 -7
  12. package/es/rce/plugins/shared/LinkDisplay.js +2 -2
  13. package/es/rce/plugins/tinymce-a11y-checker/rules/large-text-contrast.js +9 -0
  14. package/es/rce/plugins/tinymce-a11y-checker/rules/small-text-contrast.js +9 -0
  15. package/es/translations/locales/da-x-k12.js +39 -0
  16. package/es/translations/locales/de.js +4 -4
  17. package/es/translations/locales/fi.js +39 -0
  18. package/es/translations/locales/nb-x-k12.js +39 -0
  19. package/es/translations/locales/sv-x-k12.js +39 -0
  20. package/es/util/encrypted-storage.js +84 -0
  21. package/jest/jest-setup.js +5 -3
  22. package/jest.config.js +1 -0
  23. package/lib/enhance-user-content/mathml.js +8 -5
  24. package/lib/rce/RCEWrapper.js +65 -6
  25. package/lib/rce/RCEWrapperProps.js +1 -0
  26. package/lib/rce/__mocks__/_mockCryptoEs.js +124 -0
  27. package/lib/rce/plugins/instructure_equation/EquationEditorModal/parseLatex.js +0 -2
  28. package/lib/rce/plugins/instructure_rce_external_tools/components/ExternalToolDialog/ExternalToolDialogModal.js +4 -5
  29. package/lib/rce/plugins/shared/CanvasContentTray.js +8 -8
  30. package/lib/rce/plugins/shared/ContentSelection.js +7 -3
  31. package/lib/rce/plugins/shared/ImageCropper/Preview.js +8 -7
  32. package/lib/rce/plugins/shared/LinkDisplay.js +2 -2
  33. package/lib/rce/plugins/tinymce-a11y-checker/rules/large-text-contrast.js +9 -0
  34. package/lib/rce/plugins/tinymce-a11y-checker/rules/small-text-contrast.js +9 -0
  35. package/lib/translations/locales/da-x-k12.js +39 -0
  36. package/lib/translations/locales/de.js +4 -4
  37. package/lib/translations/locales/fi.js +39 -0
  38. package/lib/translations/locales/nb-x-k12.js +39 -0
  39. package/lib/translations/locales/sv-x-k12.js +39 -0
  40. package/lib/util/encrypted-storage.js +84 -0
  41. package/package.json +5 -5
  42. package/es/rce/getBrowser.js +0 -53
  43. package/lib/rce/getBrowser.js +0 -53
@@ -22,6 +22,7 @@ import { CloseButton, Button } from '@instructure/ui-buttons';
22
22
  import { Heading } from '@instructure/ui-heading';
23
23
  import { Spinner } from '@instructure/ui-spinner';
24
24
  import { Flex } from '@instructure/ui-flex';
25
+ import { View } from '@instructure/ui-view';
25
26
  import ErrorBoundary from './ErrorBoundary';
26
27
  import Bridge from '../../../bridge/Bridge';
27
28
  import formatMessage from '../../../format-message';
@@ -463,19 +464,18 @@ export default function CanvasContentTray(props) {
463
464
  }, /*#__PURE__*/React.createElement(Flex.Item, {
464
465
  padding: "medium",
465
466
  shadow: "above"
466
- }, /*#__PURE__*/React.createElement(Flex, {
467
+ }, /*#__PURE__*/React.createElement(View, {
468
+ as: "div",
467
469
  margin: "none none medium none"
468
- }, /*#__PURE__*/React.createElement(Flex.Item, {
469
- shouldgrow: true,
470
- shouldshrink: true
471
470
  }, /*#__PURE__*/React.createElement(Heading, {
472
471
  level: "h2"
473
- }, getHeader())), /*#__PURE__*/React.createElement(Flex.Item, null, /*#__PURE__*/React.createElement(CloseButton, {
472
+ }, getHeader()), /*#__PURE__*/React.createElement(CloseButton, {
474
473
  placement: "end",
474
+ offset: "medium",
475
475
  onClick: handleDismissTray,
476
476
  "data-testid": "CloseButton_ContentTray",
477
477
  screenReaderLabel: formatMessage('Close')
478
- }))), isEditTray && /*#__PURE__*/React.createElement(LinkDisplay, {
478
+ })), isEditTray && /*#__PURE__*/React.createElement(LinkDisplay, {
479
479
  linkText: linkText,
480
480
  placeholderText: (link === null || link === void 0 ? void 0 : link.title) || placeholderText,
481
481
  linkFileName: (link === null || link === void 0 ? void 0 : link.title) || '',
@@ -492,8 +492,8 @@ export default function CanvasContentTray(props) {
492
492
  isContentLoading: isLoading(storeProps),
493
493
  use_rce_icon_maker: props.use_rce_icon_maker
494
494
  }))), /*#__PURE__*/React.createElement(Flex.Item, {
495
- grow: true,
496
- shrink: true,
495
+ shouldGrow: true,
496
+ shouldShrink: true,
497
497
  margin: "xx-small xxx-small 0",
498
498
  elementRef: el => scrollingAreaRef.current = el
499
499
  }, /*#__PURE__*/React.createElement(Flex, {
@@ -32,7 +32,7 @@ export const DISPLAY_AS_EMBED = 'embed';
32
32
  export const DISPLAY_AS_EMBED_DISABLED = 'embed-disabled';
33
33
  export const DISPLAY_AS_DOWNLOAD_LINK = 'download-link';
34
34
  export function asImageEmbed($element) {
35
- const nodeName = $element.nodeName.toLowerCase();
35
+ const nodeName = $element === null || $element === void 0 ? void 0 : $element.nodeName.toLowerCase();
36
36
 
37
37
  if (nodeName !== 'img') {
38
38
  return null;
@@ -44,9 +44,11 @@ export function asImageEmbed($element) {
44
44
  };
45
45
  }
46
46
  export function asLink($element, editor) {
47
+ var _$link;
48
+
47
49
  let $link = $element;
48
50
 
49
- if ($link.tagName !== 'A') {
51
+ if (((_$link = $link) === null || _$link === void 0 ? void 0 : _$link.tagName) !== 'A') {
50
52
  // the user may have selected some text that is w/in a link
51
53
  // but didn't include the <a>. Let's see if that's true
52
54
  $link = editor.dom.getParent($link, 'a[href]');
@@ -213,7 +215,7 @@ function isMediaElement($element, mediaType) {
213
215
 
214
216
  // the video is hosted in an iframe, but tinymce
215
217
  // wraps it in a span with swizzled attribute names
216
- if (!($element !== null && $element !== void 0 && $element.getAttribute)) {
218
+ if (!($element !== null && $element !== void 0 && $element.getAttribute) || !$element) {
217
219
  return false;
218
220
  }
219
221
 
@@ -242,6 +244,8 @@ export function isAudioElement($element) {
242
244
  export function findMediaPlayerIframe(elem) {
243
245
  var _elem$firstElementChi;
244
246
 
247
+ if (!elem) return null;
248
+
245
249
  if (elem.tagName === 'IFRAME') {
246
250
  // we have the iframe
247
251
  return elem;
@@ -25,7 +25,6 @@ import { useMouseWheel } from './useMouseWheel';
25
25
  import { useKeyMouseTouchEvents } from './useKeyMouseEvents';
26
26
  import checkerboardStyle from '../CheckerboardStyling';
27
27
  import { View } from '@instructure/ui-view';
28
- import { getBrowser } from '../../../getBrowser';
29
28
  /**
30
29
  * Remove the node contents and append the svg element.
31
30
  */
@@ -86,17 +85,19 @@ export const Preview = _ref2 => {
86
85
  translateY: tempTranslateY,
87
86
  rotation,
88
87
  scaleRatio: tempScaleRatio
89
- }); // Clip is not supported in Safari until v16.
88
+ });
89
+
90
+ function isSafariVersion15OrLesser() {
91
+ const match = /Version\/(\d+).+Safari/.exec(navigator.userAgent);
92
+ return match ? parseInt(match[1], 10) < 16 : false;
93
+ } // Clip is not supported in Safari until v16.
90
94
  // It's needed here to prevent a strange screenreader
91
95
  // behavior that makes the cropper look bad. 'hidden'
92
96
  // suffices when clip is not available, although it's not perfect
93
97
  // TODO: remove when Safari versions >= 16 are more commonplace
94
98
 
95
- const {
96
- name,
97
- version
98
- } = getBrowser();
99
- const overflow = name === 'Safari' && parseFloat(version) < 16 ? 'hidden' : 'clip';
99
+
100
+ const overflow = isSafariVersion15OrLesser() ? 'hidden' : 'clip';
100
101
  return /*#__PURE__*/React.createElement("div", {
101
102
  style: {
102
103
  justifyContent: 'center',
@@ -81,8 +81,8 @@ export const LinkDisplay = _ref => {
81
81
  size: "x-small"
82
82
  }))), /*#__PURE__*/React.createElement(Flex.Item, {
83
83
  padding: "0 x-small 0 0",
84
- grow: true,
85
- shrink: true,
84
+ shouldGrow: true,
85
+ shouldShrink: true,
86
86
  textAlign: "start"
87
87
  }, /*#__PURE__*/React.createElement(View, {
88
88
  as: "div"
@@ -30,6 +30,15 @@ export default {
30
30
  return true;
31
31
  }
32
32
 
33
+ for (let e = elem; e; e = e.parentElement) {
34
+ const bgimage = window.getComputedStyle(e).getPropertyValue('background-image');
35
+
36
+ if (bgimage !== 'none' && bgimage !== '') {
37
+ // ignore background images and gradients
38
+ return true;
39
+ }
40
+ }
41
+
33
42
  return contrast(elem);
34
43
  },
35
44
  data: smallTextContrast.data,
@@ -32,6 +32,15 @@ export default {
32
32
  return true;
33
33
  }
34
34
 
35
+ for (let e = elem; e; e = e.parentElement) {
36
+ const bgimage = window.getComputedStyle(e).getPropertyValue('background-image');
37
+
38
+ if (bgimage !== 'none' && bgimage !== '') {
39
+ // ignore background images and gradients
40
+ return true;
41
+ }
42
+ }
43
+
35
44
  return contrast(elem);
36
45
  },
37
46
  data: elem => {
@@ -45,6 +45,9 @@ const locale = {
45
45
  "add_image_60b2de07": {
46
46
  "message": "Tilføj billede"
47
47
  },
48
+ "add_one_9e34a6f8": {
49
+ "message": "Tilføj en!"
50
+ },
48
51
  "additional_considerations_f3801683": {
49
52
  "message": "Yderligere overvejelser"
50
53
  },
@@ -1323,9 +1326,27 @@ const locale = {
1323
1326
  "no_accessibility_issues_were_detected_f8d3c875": {
1324
1327
  "message": "Der blev ikke fundet nogen tilgængelighedsproblemer."
1325
1328
  },
1329
+ "no_announcements_created_yet_c44a94f4": {
1330
+ "message": "Der er ikke oprettet beskeder endnu."
1331
+ },
1332
+ "no_announcements_found_20185afc": {
1333
+ "message": "Ingen beskeder fundet."
1334
+ },
1335
+ "no_assignments_created_yet_1b236d87": {
1336
+ "message": "Der er ikke oprettet opgaver endnu."
1337
+ },
1338
+ "no_assignments_found_79e46d7f": {
1339
+ "message": "Ingen opgaver fundet."
1340
+ },
1326
1341
  "no_changes_to_save_d29f6e91": {
1327
1342
  "message": "Ingen ændringer at gemme."
1328
1343
  },
1344
+ "no_discussions_created_yet_ff99abe3": {
1345
+ "message": "Der er ikke oprettet diskussioner endnu."
1346
+ },
1347
+ "no_discussions_found_9284063b": {
1348
+ "message": "Ingen diskussioner fundet."
1349
+ },
1329
1350
  "no_e16d9132": {
1330
1351
  "message": "Nej"
1331
1352
  },
@@ -1335,9 +1356,27 @@ const locale = {
1335
1356
  "no_headers_9bc7dc7f": {
1336
1357
  "message": "Ingen overskrifter"
1337
1358
  },
1359
+ "no_modules_created_yet_c71b6d4d": {
1360
+ "message": "Der er ikke oprettet forløb endnu."
1361
+ },
1362
+ "no_modules_found_2df43a40": {
1363
+ "message": "Ingen forløb fundet."
1364
+ },
1365
+ "no_pages_created_yet_c379fa6e": {
1366
+ "message": "Der er ikke oprettet sider endnu."
1367
+ },
1368
+ "no_pages_found_6799350": {
1369
+ "message": "Ingen sider fundet."
1370
+ },
1338
1371
  "no_preview_is_available_for_this_file_f940114a": {
1339
1372
  "message": "Der findes ikke forhåndsvisning for denne fil."
1340
1373
  },
1374
+ "no_quizzes_created_yet_1a2370b9": {
1375
+ "message": "Der er ikke oprettet nogen quizzer endnu."
1376
+ },
1377
+ "no_quizzes_found_c80c537a": {
1378
+ "message": "Der er ikke fundet nogen quizzer."
1379
+ },
1341
1380
  "no_results_940393cf": {
1342
1381
  "message": "Ingen resultater."
1343
1382
  },
@@ -373,7 +373,7 @@ const locale = {
373
373
  "message": "{ count, plural,\n one {# Objekt geladen}\n other {# Objekte geladen}\n}"
374
374
  },
375
375
  "course_documents_104d76e0": {
376
- "message": "Kursunterlagen"
376
+ "message": "Kursdokumente"
377
377
  },
378
378
  "course_files_62deb8f8": {
379
379
  "message": "Kursdateien"
@@ -2278,16 +2278,16 @@ const locale = {
2278
2278
  "message": "Wird von Screenreadern verwendet, um das Video zu beschreiben."
2279
2279
  },
2280
2280
  "user_documents_c206e61f": {
2281
- "message": "Benutzer*in Dokumente"
2281
+ "message": "Meine Dokumente"
2282
2282
  },
2283
2283
  "user_files_78e21703": {
2284
2284
  "message": "Benutzerdateien"
2285
2285
  },
2286
2286
  "user_images_b6490852": {
2287
- "message": "Benutzerbilder"
2287
+ "message": "Meine Bilder"
2288
2288
  },
2289
2289
  "user_media_14fbf656": {
2290
- "message": "Nutzer-Medien"
2290
+ "message": "Meine Medien"
2291
2291
  },
2292
2292
  "vector_notation_cf6086ab": {
2293
2293
  "message": "Vektor (Notation)"
@@ -45,6 +45,9 @@ const locale = {
45
45
  "add_image_60b2de07": {
46
46
  "message": "Lisää kuva"
47
47
  },
48
+ "add_one_9e34a6f8": {
49
+ "message": "Lisää yksi!"
50
+ },
48
51
  "additional_considerations_f3801683": {
49
52
  "message": "Muuta huomioon otettavaa"
50
53
  },
@@ -1323,9 +1326,27 @@ const locale = {
1323
1326
  "no_accessibility_issues_were_detected_f8d3c875": {
1324
1327
  "message": "Ei havaittu käytettävyysongelmia."
1325
1328
  },
1329
+ "no_announcements_created_yet_c44a94f4": {
1330
+ "message": "Ilmoituksia ei ole vielä luotu."
1331
+ },
1332
+ "no_announcements_found_20185afc": {
1333
+ "message": "Ilmoituksia ei löytynyt."
1334
+ },
1335
+ "no_assignments_created_yet_1b236d87": {
1336
+ "message": "Tehtäviä ei ole vielä luotu."
1337
+ },
1338
+ "no_assignments_found_79e46d7f": {
1339
+ "message": "Tehtäviä ei löytynyt."
1340
+ },
1326
1341
  "no_changes_to_save_d29f6e91": {
1327
1342
  "message": "Ei tallennettavia muutoksia."
1328
1343
  },
1344
+ "no_discussions_created_yet_ff99abe3": {
1345
+ "message": "Keskusteluja ei ole vielä luotu."
1346
+ },
1347
+ "no_discussions_found_9284063b": {
1348
+ "message": "Keskusteluja ei löytynyt."
1349
+ },
1329
1350
  "no_e16d9132": {
1330
1351
  "message": "Ei"
1331
1352
  },
@@ -1335,9 +1356,27 @@ const locale = {
1335
1356
  "no_headers_9bc7dc7f": {
1336
1357
  "message": "Ei otsikoita"
1337
1358
  },
1359
+ "no_modules_created_yet_c71b6d4d": {
1360
+ "message": "Moduuleja ei ole vielä luotu."
1361
+ },
1362
+ "no_modules_found_2df43a40": {
1363
+ "message": "Moduuleja ei löytynyt."
1364
+ },
1365
+ "no_pages_created_yet_c379fa6e": {
1366
+ "message": "Sivuja ei ole vielä luotu"
1367
+ },
1368
+ "no_pages_found_6799350": {
1369
+ "message": "Sivuja ei löytynyt."
1370
+ },
1338
1371
  "no_preview_is_available_for_this_file_f940114a": {
1339
1372
  "message": "Tälle tiedostolle ei ole saatavissa esikatselua."
1340
1373
  },
1374
+ "no_quizzes_created_yet_1a2370b9": {
1375
+ "message": "Testejä ei ole vielä luotu."
1376
+ },
1377
+ "no_quizzes_found_c80c537a": {
1378
+ "message": "Testejä ei löytynyt."
1379
+ },
1341
1380
  "no_results_940393cf": {
1342
1381
  "message": "Ei tuloksia."
1343
1382
  },
@@ -45,6 +45,9 @@ const locale = {
45
45
  "add_image_60b2de07": {
46
46
  "message": "Legg til bilde"
47
47
  },
48
+ "add_one_9e34a6f8": {
49
+ "message": "Legg til en!"
50
+ },
48
51
  "additional_considerations_f3801683": {
49
52
  "message": "Ekstra hensyn"
50
53
  },
@@ -1323,9 +1326,27 @@ const locale = {
1323
1326
  "no_accessibility_issues_were_detected_f8d3c875": {
1324
1327
  "message": "Ingen tiljengelighetsproblemer ble oppdaget."
1325
1328
  },
1329
+ "no_announcements_created_yet_c44a94f4": {
1330
+ "message": "Ingen beskjeder opprettet ennå."
1331
+ },
1332
+ "no_announcements_found_20185afc": {
1333
+ "message": "Ingen beskjeder funnet."
1334
+ },
1335
+ "no_assignments_created_yet_1b236d87": {
1336
+ "message": "Ingen oppgave opprettet ennå."
1337
+ },
1338
+ "no_assignments_found_79e46d7f": {
1339
+ "message": "Ingen oppgaver funnet."
1340
+ },
1326
1341
  "no_changes_to_save_d29f6e91": {
1327
1342
  "message": "Ingen endringer å lagre."
1328
1343
  },
1344
+ "no_discussions_created_yet_ff99abe3": {
1345
+ "message": "Ingen diskusjoner opprettet ennå."
1346
+ },
1347
+ "no_discussions_found_9284063b": {
1348
+ "message": "Ingen diskusjoner funnet."
1349
+ },
1329
1350
  "no_e16d9132": {
1330
1351
  "message": "Nei"
1331
1352
  },
@@ -1335,9 +1356,27 @@ const locale = {
1335
1356
  "no_headers_9bc7dc7f": {
1336
1357
  "message": "Ingen titler"
1337
1358
  },
1359
+ "no_modules_created_yet_c71b6d4d": {
1360
+ "message": "Ingen moduler opprettet ennå."
1361
+ },
1362
+ "no_modules_found_2df43a40": {
1363
+ "message": "Ingen moduler funnet."
1364
+ },
1365
+ "no_pages_created_yet_c379fa6e": {
1366
+ "message": "Ingen sider opprettet ennå."
1367
+ },
1368
+ "no_pages_found_6799350": {
1369
+ "message": "Ingen sider funnet."
1370
+ },
1338
1371
  "no_preview_is_available_for_this_file_f940114a": {
1339
1372
  "message": "Ingen forhåndsvisning er tilgjengelig for denne filen."
1340
1373
  },
1374
+ "no_quizzes_created_yet_1a2370b9": {
1375
+ "message": "Ingen quizer opprettet ennå."
1376
+ },
1377
+ "no_quizzes_found_c80c537a": {
1378
+ "message": "Ingen quizer funnet."
1379
+ },
1341
1380
  "no_results_940393cf": {
1342
1381
  "message": "Ingen resultater."
1343
1382
  },
@@ -45,6 +45,9 @@ const locale = {
45
45
  "add_image_60b2de07": {
46
46
  "message": "Lägg till bild"
47
47
  },
48
+ "add_one_9e34a6f8": {
49
+ "message": "Lägg till en!"
50
+ },
48
51
  "additional_considerations_f3801683": {
49
52
  "message": "Ytterliggare hänsynstaganden"
50
53
  },
@@ -1323,9 +1326,27 @@ const locale = {
1323
1326
  "no_accessibility_issues_were_detected_f8d3c875": {
1324
1327
  "message": "Inga tillgänglighetsproblem upptäcktes."
1325
1328
  },
1329
+ "no_announcements_created_yet_c44a94f4": {
1330
+ "message": "Inga meddelanden har skapats än."
1331
+ },
1332
+ "no_announcements_found_20185afc": {
1333
+ "message": "Inga meddelande hittades."
1334
+ },
1335
+ "no_assignments_created_yet_1b236d87": {
1336
+ "message": "Inga uppgifter har skapats än."
1337
+ },
1338
+ "no_assignments_found_79e46d7f": {
1339
+ "message": "Inga uppgifter hittades."
1340
+ },
1326
1341
  "no_changes_to_save_d29f6e91": {
1327
1342
  "message": "Inga ändringar att spara."
1328
1343
  },
1344
+ "no_discussions_created_yet_ff99abe3": {
1345
+ "message": "Inga diskussioner har skapats än."
1346
+ },
1347
+ "no_discussions_found_9284063b": {
1348
+ "message": "Inga diskussioner hittades."
1349
+ },
1329
1350
  "no_e16d9132": {
1330
1351
  "message": "Nej"
1331
1352
  },
@@ -1335,9 +1356,27 @@ const locale = {
1335
1356
  "no_headers_9bc7dc7f": {
1336
1357
  "message": "Inga rubriker"
1337
1358
  },
1359
+ "no_modules_created_yet_c71b6d4d": {
1360
+ "message": "Inga moduler har skapats än."
1361
+ },
1362
+ "no_modules_found_2df43a40": {
1363
+ "message": "Inga moduler hittades."
1364
+ },
1365
+ "no_pages_created_yet_c379fa6e": {
1366
+ "message": "Inga sidor har skapats än."
1367
+ },
1368
+ "no_pages_found_6799350": {
1369
+ "message": "Inga sidor hittades."
1370
+ },
1338
1371
  "no_preview_is_available_for_this_file_f940114a": {
1339
1372
  "message": "Förhandsvisning är inte tillgänglig för den här filen."
1340
1373
  },
1374
+ "no_quizzes_created_yet_1a2370b9": {
1375
+ "message": "Inga quiz har skapats än."
1376
+ },
1377
+ "no_quizzes_found_c80c537a": {
1378
+ "message": "Inga quiz hittades."
1379
+ },
1341
1380
  "no_results_940393cf": {
1342
1381
  "message": "Inga resultat."
1343
1382
  },
@@ -0,0 +1,84 @@
1
+ /*
2
+ * Copyright (C) 2023 - present Instructure, Inc.
3
+ *
4
+ * This file is part of Canvas.
5
+ *
6
+ * Canvas is free software: you can redistribute it and/or modify it under
7
+ * the terms of the GNU Affero General Public License as published by the Free
8
+ * Software Foundation, version 3 of the License.
9
+ *
10
+ * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
11
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
+ * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13
+ * details.
14
+ *
15
+ * You should have received a copy of the GNU Affero General Public License along
16
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ import CryptoES from 'crypto-es';
19
+ export default class EncryptedStorage {
20
+ constructor(passphrase) {
21
+ this.passphrase = void 0;
22
+
23
+ this.errorHandlerWrapper = callback => {
24
+ try {
25
+ return callback();
26
+ } catch (error) {
27
+ console.error('error', error);
28
+ return null;
29
+ }
30
+ };
31
+
32
+ this.passphrase = CryptoES.enc.Utf8.parse(passphrase);
33
+ }
34
+
35
+ setItem(key, content) {
36
+ return this.errorHandlerWrapper(() => {
37
+ // If passphrase is present, encrypt string and JSON stringify
38
+ let encrypted;
39
+
40
+ if (this.passphrase) {
41
+ encrypted = CryptoES.RC4.encrypt(content, this.passphrase, {
42
+ mode: CryptoES.mode.CFB,
43
+ padding: CryptoES.pad.AnsiX923
44
+ }).toString();
45
+ }
46
+
47
+ const data = JSON.stringify({
48
+ autosaveTimestamp: new Date().getTime(),
49
+ content: encrypted
50
+ });
51
+ return window.localStorage.setItem(key, data);
52
+ });
53
+ }
54
+
55
+ getItem(key) {
56
+ return this.errorHandlerWrapper(() => {
57
+ const data = window.localStorage.getItem(key);
58
+
59
+ if (!data) {
60
+ return data;
61
+ } // If passphrase is present, parse JSON and decrypt string
62
+
63
+
64
+ if (this.passphrase) {
65
+ const parsedData = JSON.parse(data);
66
+ parsedData.content = CryptoES.RC4.decrypt(parsedData.content, this.passphrase, {
67
+ mode: CryptoES.mode.CFB,
68
+ padding: CryptoES.pad.AnsiX923
69
+ });
70
+ parsedData.content = parsedData.content.toString(CryptoES.enc.Utf8);
71
+ return parsedData;
72
+ }
73
+ });
74
+ }
75
+
76
+ key(index) {
77
+ return this.errorHandlerWrapper(() => window.localStorage.key(index));
78
+ }
79
+
80
+ removeItem(key) {
81
+ return this.errorHandlerWrapper(() => window.localStorage.removeItem(key));
82
+ }
83
+
84
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/canvas-rce",
3
- "version": "5.8.0",
3
+ "version": "5.10.0",
4
4
  "description": "A component wrapping Canvas's usage of Tinymce",
5
5
  "main": "es/index.js",
6
6
  "scripts": {
@@ -77,9 +77,8 @@
77
77
  "@instructure/canvas-theme": "7",
78
78
  "@instructure/debounce": "^7",
79
79
  "@instructure/emotion": "^8.38.1",
80
- "@instructure/js-utils": "*",
81
80
  "@instructure/k5uploader": "*",
82
- "@instructure/media-capture": "~8.4.1-rc.16",
81
+ "@instructure/media-capture": "^9.0.0",
83
82
  "@instructure/ui-a11y-content": "^7",
84
83
  "@instructure/ui-a11y-utils": "^7",
85
84
  "@instructure/ui-alerts": "^7",
@@ -100,7 +99,7 @@
100
99
  "@instructure/ui-img": "^7",
101
100
  "@instructure/ui-link": "^7",
102
101
  "@instructure/ui-list": "^7",
103
- "@instructure/ui-media-player": "7",
102
+ "@instructure/ui-media-player": "^9.0.0",
104
103
  "@instructure/ui-menu": "^7",
105
104
  "@instructure/ui-modal": "^7",
106
105
  "@instructure/ui-motion": "^7",
@@ -133,6 +132,7 @@
133
132
  "aphrodite": "^2",
134
133
  "axios": "^0.21.1",
135
134
  "bloody-offset": "0.0.0",
135
+ "crypto-es": "^2.0.4",
136
136
  "classnames": "^2.2.5",
137
137
  "concurrently": "^4",
138
138
  "format-message": "^6",
@@ -215,7 +215,7 @@
215
215
  "testcafe-browser-provider-selenium": "^1.2.0",
216
216
  "testcafe-react-selectors": "^3.3.0",
217
217
  "ts-node": "^10.9.1",
218
- "typescript": "^5.0.2",
218
+ "typescript": "^5.2.2",
219
219
  "url-loader": "^4.1.1",
220
220
  "webpack": "^5",
221
221
  "webpack-merge": "^5",
@@ -1,53 +0,0 @@
1
- /*
2
- * Copyright (C) 2022 - present Instructure, Inc.
3
- *
4
- * This file is part of Canvas.
5
- *
6
- * Canvas is free software: you can redistribute it and/or modify it under
7
- * the terms of the GNU Affero General Public License as published by the Free
8
- * Software Foundation, version 3 of the License.
9
- *
10
- * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
11
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
- * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13
- * details.
14
- *
15
- * You should have received a copy of the GNU Affero General Public License along
16
- * with this program. If not, see <http://www.gnu.org/licenses/>.
17
- */
18
- // From packages/parse-browser-info/index.js
19
- export function getBrowser() {
20
- const ua = navigator.userAgent;
21
- let tem;
22
- let M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
23
-
24
- if (/trident/i.test(M[1])) {
25
- tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
26
- return {
27
- name: 'IE',
28
- version: tem[1] || ''
29
- };
30
- }
31
-
32
- if (M[1] === 'Chrome') {
33
- tem = ua.match(/\bOPR|Edge\/(\d+)/);
34
-
35
- if (tem != null) {
36
- return {
37
- name: 'Opera',
38
- version: tem[1]
39
- };
40
- }
41
- }
42
-
43
- M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
44
-
45
- if ((tem = ua.match(/version\/(\d+)/i)) != null) {
46
- M.splice(1, 1, tem[1]);
47
- }
48
-
49
- return {
50
- name: M[0],
51
- version: M[1]
52
- };
53
- }