@instructure/canvas-rce 5.10.0 → 5.11.1

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 (55) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/Dockerfile +1 -1
  3. package/es/common/mimeClass.js +70 -67
  4. package/es/enhance-user-content/doc_previews.js +1 -1
  5. package/es/enhance-user-content/enhance_user_content.js +9 -1
  6. package/es/getThemeVars.js +3 -4
  7. package/es/rce/RCE.js +1 -3
  8. package/es/rce/RCEWrapper.js +3 -67
  9. package/es/rce/RceHtmlEditor.js +28 -8
  10. package/es/rce/plugins/instructure_links/components/Link.js +3 -9
  11. package/es/rce/plugins/instructure_links/components/LinkSet.js +4 -8
  12. package/es/rce/plugins/instructure_links/components/NoResults.js +5 -10
  13. package/es/rce/plugins/instructure_links/plugin.js +1 -7
  14. package/es/rce/plugins/instructure_rce_external_tools/components/ExternalToolDialog/ExternalToolDialog.js +1 -2
  15. package/es/rce/plugins/instructure_rce_external_tools/components/ExternalToolDialog/ExternalToolDialogTray.js +6 -12
  16. package/es/rce/plugins/instructure_rce_external_tools/components/ExternalToolSelectionDialog/ExternalToolSelectionDialog.js +2 -2
  17. package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/models/ResourceLinkContentItem.js +1 -1
  18. package/es/rce/plugins/instructure_record/VideoOptionsTray/TrayController.js +7 -2
  19. package/es/rce/plugins/instructure_record/VideoOptionsTray/index.js +3 -9
  20. package/es/rce/plugins/instructure_wordcount/components/WordCountModal.js +8 -16
  21. package/es/rce/plugins/shared/CanvasContentTray.js +7 -1
  22. package/es/rce/plugins/shared/fileTypeUtils.js +14 -6
  23. package/es/rce/plugins/tinymce-a11y-checker/components/{color-field.js → ColorField.js} +9 -7
  24. package/es/rce/plugins/tinymce-a11y-checker/components/checker.js +27 -24
  25. package/es/rce/root.js +1 -3
  26. package/es/rce/transformContent.js +8 -0
  27. package/es/sidebar/actions/upload.js +3 -1
  28. package/jest/jest-setup.js +2 -0
  29. package/lib/common/mimeClass.js +70 -67
  30. package/lib/enhance-user-content/doc_previews.js +1 -1
  31. package/lib/enhance-user-content/enhance_user_content.js +9 -1
  32. package/lib/getThemeVars.js +3 -4
  33. package/lib/rce/RCE.js +1 -3
  34. package/lib/rce/RCEWrapper.js +3 -67
  35. package/lib/rce/RceHtmlEditor.js +28 -8
  36. package/lib/rce/plugins/instructure_links/components/Link.js +3 -9
  37. package/lib/rce/plugins/instructure_links/components/LinkSet.js +4 -8
  38. package/lib/rce/plugins/instructure_links/components/NoResults.js +5 -10
  39. package/lib/rce/plugins/instructure_links/plugin.js +1 -7
  40. package/lib/rce/plugins/instructure_rce_external_tools/components/ExternalToolDialog/ExternalToolDialog.js +1 -2
  41. package/lib/rce/plugins/instructure_rce_external_tools/components/ExternalToolDialog/ExternalToolDialogTray.js +6 -12
  42. package/lib/rce/plugins/instructure_rce_external_tools/components/ExternalToolSelectionDialog/ExternalToolSelectionDialog.js +2 -2
  43. package/lib/rce/plugins/instructure_rce_external_tools/lti13-content-items/models/ResourceLinkContentItem.js +1 -1
  44. package/lib/rce/plugins/instructure_record/VideoOptionsTray/TrayController.js +7 -2
  45. package/lib/rce/plugins/instructure_record/VideoOptionsTray/index.js +3 -9
  46. package/lib/rce/plugins/instructure_wordcount/components/WordCountModal.js +8 -16
  47. package/lib/rce/plugins/shared/CanvasContentTray.js +7 -1
  48. package/lib/rce/plugins/shared/fileTypeUtils.js +14 -6
  49. package/lib/rce/plugins/tinymce-a11y-checker/components/{color-field.js → ColorField.js} +9 -7
  50. package/lib/rce/plugins/tinymce-a11y-checker/components/checker.js +27 -24
  51. package/lib/rce/root.js +1 -3
  52. package/lib/rce/transformContent.js +8 -0
  53. package/lib/sidebar/actions/upload.js +3 -1
  54. package/locales/en.json +1438 -89
  55. package/package.json +52 -51
@@ -1,3 +1,5 @@
1
+ import _pt from "prop-types";
2
+
1
3
  /*
2
4
  * Copyright (C) 2018 - present Instructure, Inc.
3
5
  *
@@ -15,8 +17,8 @@
15
17
  * You should have received a copy of the GNU Affero General Public License along
16
18
  * with this program. If not, see <http://www.gnu.org/licenses/>.
17
19
  */
18
- import React from 'react';
19
- import PropTypes from 'prop-types';
20
+ import React from 'react'; // @ts-expect-error
21
+
20
22
  import contrast from 'wcag-element-contrast';
21
23
  import { TextInput } from '@instructure/ui-text-input';
22
24
  import { View } from '@instructure/ui-view';
@@ -62,7 +64,7 @@ export default class ColorField extends React.Component {
62
64
  as: "div"
63
65
  }, /*#__PURE__*/React.createElement(TextInput, {
64
66
  "data-testid": "color-field-text-input",
65
- label: this.props.label,
67
+ renderLabel: this.props.label,
66
68
  value: this.state.textValue,
67
69
  onChange: e => this.setState({
68
70
  textValue: e.target.value
@@ -77,8 +79,8 @@ export default class ColorField extends React.Component {
77
79
 
78
80
  }
79
81
  ColorField.propTypes = {
80
- label: PropTypes.string.isRequired,
81
- name: PropTypes.string.isRequired,
82
- value: PropTypes.string.isRequired,
83
- onChange: PropTypes.func.isRequired
82
+ label: _pt.string.isRequired,
83
+ name: _pt.string.isRequired,
84
+ value: _pt.string.isRequired,
85
+ onChange: _pt.func.isRequired
84
86
  };
@@ -20,8 +20,7 @@
20
20
  // our own imported describe function confuses eslint
21
21
  import React from 'react';
22
22
  import { LiveAnnouncer, LiveMessage } from 'react-aria-live';
23
- import { ScreenReaderContent } from '@instructure/ui-a11y-content';
24
- import { Button, CloseButton } from '@instructure/ui-buttons';
23
+ import { Button, CloseButton, IconButton } from '@instructure/ui-buttons';
25
24
  import { Flex } from '@instructure/ui-flex';
26
25
  import { Tray } from '@instructure/ui-tray';
27
26
  import { Popover } from '@instructure/ui-popover';
@@ -38,7 +37,7 @@ import { SimpleSelect } from '@instructure/ui-simple-select';
38
37
  import { IconQuestionLine } from '@instructure/ui-icons';
39
38
  import { InstUISettingsProvider } from '@instructure/emotion';
40
39
  import { Alert } from '@instructure/ui-alerts';
41
- import ColorField from './color-field';
40
+ import ColorField from './ColorField';
42
41
  import PlaceholderSVG from './placeholder-svg';
43
42
  import describe from '../utils/describe';
44
43
  import * as dom from '../utils/dom';
@@ -363,7 +362,7 @@ export default class Checker extends React.Component {
363
362
  placement: "end",
364
363
  contentRef: e => this.trayElement = e,
365
364
  size: "regular",
366
- theme: {
365
+ themeOverride: {
367
366
  regularWidth: '22em'
368
367
  }
369
368
  }, /*#__PURE__*/React.createElement(Flex, {
@@ -380,10 +379,11 @@ export default class Checker extends React.Component {
380
379
  }, /*#__PURE__*/React.createElement(Heading, {
381
380
  as: "h2"
382
381
  }, formatMessage('Accessibility Checker'))), /*#__PURE__*/React.createElement(Flex.Item, null, /*#__PURE__*/React.createElement(CloseButton, {
382
+ screenReaderLabel: formatMessage('Close Accessibility Checker'),
383
383
  placement: "end",
384
384
  onClick: () => this.handleClose(),
385
- buttonRef: ref => this._closeButtonRef = ref
386
- }, formatMessage('Close Accessibility Checker'))))), /*#__PURE__*/React.createElement(Flex.Item, {
385
+ elementRef: ref => this._closeButtonRef = ref
386
+ })))), /*#__PURE__*/React.createElement(Flex.Item, {
387
387
  as: "div",
388
388
  padding: "0 large large"
389
389
  }, this.state.errors.length > 0 && /*#__PURE__*/React.createElement(View, {
@@ -408,30 +408,33 @@ export default class Checker extends React.Component {
408
408
  width: "auto"
409
409
  }, /*#__PURE__*/React.createElement(Popover, {
410
410
  on: "click",
411
- show: this.state.showWhyPopover,
411
+ isShowingContent: this.state.showWhyPopover,
412
412
  shouldContainFocus: true,
413
- shouldReturnFocus: true
414
- }, /*#__PURE__*/React.createElement(Popover.Trigger, null, /*#__PURE__*/React.createElement(Button, {
415
- variant: "icon",
416
- icon: IconQuestionLine,
417
- onClick: () => this.setState({
418
- showWhyPopover: true
419
- })
420
- }, /*#__PURE__*/React.createElement(ScreenReaderContent, null, formatMessage('Why')))), /*#__PURE__*/React.createElement(Popover.Content, null, /*#__PURE__*/React.createElement(View, {
413
+ shouldReturnFocus: true,
414
+ renderTrigger: () => /*#__PURE__*/React.createElement(IconButton, {
415
+ screenReaderLabel: formatMessage('Why'),
416
+ renderIcon: IconQuestionLine,
417
+ onClick: () => this.setState({
418
+ showWhyPopover: true
419
+ }),
420
+ withBackground: false,
421
+ withBorder: false
422
+ }, /*#__PURE__*/React.createElement(IconQuestionLine, null))
423
+ }, /*#__PURE__*/React.createElement(View, {
421
424
  padding: "medium",
422
425
  display: "block",
423
426
  width: "16rem"
424
427
  }, /*#__PURE__*/React.createElement(CloseButton, {
425
428
  placement: "end",
426
429
  offset: "x-small",
427
- variant: "icon",
428
430
  onClick: () => this.setState({
429
431
  showWhyPopover: false
430
- })
431
- }, formatMessage('Close')), /*#__PURE__*/React.createElement(Text, null, /*#__PURE__*/React.createElement("p", null, rule.why()), /*#__PURE__*/React.createElement("p", null, rule.link && rule.link.length && /*#__PURE__*/React.createElement(InstUISettingsProvider, {
432
- theme: {
432
+ }),
433
+ screenReaderLabel: formatMessage('Close')
434
+ }), /*#__PURE__*/React.createElement(Text, null, /*#__PURE__*/React.createElement("p", null, rule.why()), /*#__PURE__*/React.createElement("p", null, rule.link && rule.link.length && /*#__PURE__*/React.createElement(InstUISettingsProvider, {
435
+ themeOverride: {
433
436
  componentOverrides: {
434
- Link: {
437
+ [Link.componentId]: {
435
438
  textDecoration: 'underline'
436
439
  }
437
440
  }
@@ -439,7 +442,7 @@ export default class Checker extends React.Component {
439
442
  }, /*#__PURE__*/React.createElement(Link, {
440
443
  href: rule.link,
441
444
  target: "_blank"
442
- }, rule.linkText()))))))))))), /*#__PURE__*/React.createElement("form", {
445
+ }, rule.linkText())))))))))), /*#__PURE__*/React.createElement("form", {
443
446
  onSubmit: event => {
444
447
  event.preventDefault();
445
448
  this.fixIssue();
@@ -469,13 +472,13 @@ export default class Checker extends React.Component {
469
472
  width: "auto"
470
473
  }, /*#__PURE__*/React.createElement(Button, {
471
474
  type: "submit",
472
- variant: "primary",
475
+ color: "primary",
473
476
  disabled: !this.state.formStateValid
474
477
  }, formatMessage('Apply')))))))), this.state.errors.length === 0 && !this.state.checking && /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(Text, null, /*#__PURE__*/React.createElement("p", null, formatMessage('No accessibility issues were detected.'))), /*#__PURE__*/React.createElement(PlaceholderSVG, null)), this.state.checking && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(LiveMessage, {
475
478
  message: formatMessage('Checking for accessibility issues'),
476
479
  "aria-live": "polite"
477
480
  }), /*#__PURE__*/React.createElement(Spinner, {
478
- title: formatMessage('Checking for accessibility issues'),
481
+ renderTitle: formatMessage('Checking for accessibility issues'),
479
482
  margin: "medium auto"
480
483
  }))))));
481
484
  }
@@ -539,7 +542,7 @@ export default class Checker extends React.Component {
539
542
 
540
543
  default:
541
544
  return /*#__PURE__*/React.createElement(TextInput, {
542
- label: f.label,
545
+ renderLabel: f.label,
543
546
  name: f.dataKey,
544
547
  value: this.state.formState[f.dataKey] || '',
545
548
  onChange: this.updateFormState,
package/lib/rce/root.js CHANGED
@@ -1,5 +1,3 @@
1
- var _process, _process$env;
2
-
3
1
  /*
4
2
  * Copyright (C) 2018 - present Instructure, Inc.
5
3
  *
@@ -23,7 +21,7 @@ import RCEWrapper from './RCEWrapper';
23
21
  import normalizeProps from './normalizeProps';
24
22
  import formatMessage from '../format-message';
25
23
 
26
- if (!((_process = process) !== null && _process !== void 0 && (_process$env = _process.env) !== null && _process$env !== void 0 && _process$env.BUILD_LOCALE)) {
24
+ if (!process || !process.env || !undefined) {
27
25
  formatMessage.setup({
28
26
  locale: 'en',
29
27
  generateId: require('format-message-generate-id/underscored_crc32'),
@@ -60,6 +60,14 @@ export function transformRceContentForEditing(inputHtml, options) {
60
60
  for (const attributeName of attributeNamesToRemove) {
61
61
  element.removeAttribute(attributeName);
62
62
  }
63
+ }); // fixup LTI iframe launches to use the `in_rce` display type
64
+
65
+ container.querySelectorAll('iframe[src]').forEach(element => {
66
+ const src = element.getAttribute('src');
67
+
68
+ if (src !== null && src !== void 0 && src.includes('display=borderless')) {
69
+ element.setAttribute('src', src.replace('display=borderless', 'display=in_rce'));
70
+ }
63
71
  });
64
72
  return container.innerHTML;
65
73
  }
@@ -272,7 +272,9 @@ export function mediaUploadComplete(error, uploadData) {
272
272
  media_id: mediaObject.media_object.media_id,
273
273
  type: uploadedFile.type,
274
274
  title: uploadedFile.title || uploadedFile.name,
275
- id: mediaObject.media_object.attachment_id
275
+ id: mediaObject.media_object.attachment_id,
276
+ uuid: mediaObject.media_object.uuid,
277
+ contextType: mediaObject.media_object.context_type
276
278
  };
277
279
  dispatch(removePlaceholdersFor(uploadedFile.name));
278
280
  embedUploadResult(embedData, 'media');