@instructure/canvas-rce 5.9.0 → 5.10.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 (41) hide show
  1. package/.mocharc.js +7 -0
  2. package/CHANGELOG.md +17 -0
  3. package/es/enhance-user-content/enhance_user_content.js +9 -1
  4. package/es/enhance-user-content/mathml.js +8 -5
  5. package/es/rce/RCEWrapper.js +0 -40
  6. package/es/rce/plugins/instructure_equation/EquationEditorModal/parseLatex.js +0 -2
  7. package/es/rce/plugins/instructure_rce_external_tools/components/ExternalToolDialog/ExternalToolDialogModal.js +4 -5
  8. package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/models/ResourceLinkContentItem.js +1 -1
  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/shared/fileTypeUtils.js +14 -6
  14. package/es/rce/plugins/tinymce-a11y-checker/rules/large-text-contrast.js +9 -0
  15. package/es/rce/plugins/tinymce-a11y-checker/rules/small-text-contrast.js +9 -0
  16. package/es/rce/transformContent.js +8 -0
  17. package/es/sidebar/actions/upload.js +3 -1
  18. package/es/translations/locales/de.js +4 -4
  19. package/jest/jest-setup.js +0 -1
  20. package/lib/enhance-user-content/enhance_user_content.js +9 -1
  21. package/lib/enhance-user-content/mathml.js +8 -5
  22. package/lib/rce/RCEWrapper.js +0 -40
  23. package/lib/rce/plugins/instructure_equation/EquationEditorModal/parseLatex.js +0 -2
  24. package/lib/rce/plugins/instructure_rce_external_tools/components/ExternalToolDialog/ExternalToolDialogModal.js +4 -5
  25. package/lib/rce/plugins/instructure_rce_external_tools/lti13-content-items/models/ResourceLinkContentItem.js +1 -1
  26. package/lib/rce/plugins/shared/CanvasContentTray.js +8 -8
  27. package/lib/rce/plugins/shared/ContentSelection.js +7 -3
  28. package/lib/rce/plugins/shared/ImageCropper/Preview.js +8 -7
  29. package/lib/rce/plugins/shared/LinkDisplay.js +2 -2
  30. package/lib/rce/plugins/shared/fileTypeUtils.js +14 -6
  31. package/lib/rce/plugins/tinymce-a11y-checker/rules/large-text-contrast.js +9 -0
  32. package/lib/rce/plugins/tinymce-a11y-checker/rules/small-text-contrast.js +9 -0
  33. package/lib/rce/transformContent.js +8 -0
  34. package/lib/sidebar/actions/upload.js +3 -1
  35. package/lib/translations/locales/de.js +4 -4
  36. package/package.json +4 -4
  37. package/canvas/README.md +0 -84
  38. package/canvas/locales/en.json +0 -934
  39. package/canvas/package.json +0 -189
  40. package/es/rce/getBrowser.js +0 -53
  41. 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"
@@ -15,7 +15,7 @@
15
15
  * You should have received a copy of the GNU Affero General Public License along
16
16
  * with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
- import { parse } from 'url';
18
+ import { format, parse } from 'url';
19
19
  import { absoluteToRelativeUrl } from '../../../common/fileUrl';
20
20
  import { IconAudioLine, IconDocumentLine, IconMsExcelLine, IconMsPptLine, IconMsWordLine, IconPdfLine, IconVideoLine } from '@instructure/ui-icons';
21
21
  import RCEGlobals from '../../RCEGlobals';
@@ -94,13 +94,21 @@ export function mediaPlayerURLFromFile(file, canvasOrigin) {
94
94
  const type = content_type.replace(/\/.*$/, '');
95
95
 
96
96
  if ((_RCEGlobals$getFeatur = RCEGlobals.getFeatures()) !== null && _RCEGlobals$getFeatur !== void 0 && _RCEGlobals$getFeatur.media_links_use_attachment_id && isAudioOrVideo(content_type) && file.id) {
97
- if (!file.url && !file.href) {
98
- return `/media_attachments_iframe/${file.id}?type=${type}&embedded=true`;
97
+ const url = parse(`/media_attachments_iframe/${file.id}`, true);
98
+ url.query.type = type;
99
+ url.query.embedded = true;
100
+
101
+ if (file.uuid && file.contextType == 'User') {
102
+ url.query.verifier = file.uuid;
103
+ } else if (file.url || file.href) {
104
+ const parsed_url = parse(file.url || file.href, true);
105
+
106
+ if (parsed_url.query.verifier) {
107
+ url.query.verifier = parsed_url.query.verifier;
108
+ }
99
109
  }
100
110
 
101
- const parsed_url = parse(file.url || file.href, true);
102
- const verifier = parsed_url.query.verifier ? `&verifier=${parsed_url.query.verifier}` : '';
103
- return `/media_attachments_iframe/${file.id}?type=${type}${verifier}&embedded=true`;
111
+ return format(url);
104
112
  }
105
113
 
106
114
  if (file.embedded_iframe_url) {
@@ -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 => {
@@ -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');
@@ -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)"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/canvas-rce",
3
- "version": "5.9.0",
3
+ "version": "5.10.1",
4
4
  "description": "A component wrapping Canvas's usage of Tinymce",
5
5
  "main": "es/index.js",
6
6
  "scripts": {
@@ -78,7 +78,7 @@
78
78
  "@instructure/debounce": "^7",
79
79
  "@instructure/emotion": "^8.38.1",
80
80
  "@instructure/k5uploader": "*",
81
- "@instructure/media-capture": "~8.4.1-rc.16",
81
+ "@instructure/media-capture": "^9.0.0",
82
82
  "@instructure/ui-a11y-content": "^7",
83
83
  "@instructure/ui-a11y-utils": "^7",
84
84
  "@instructure/ui-alerts": "^7",
@@ -99,7 +99,7 @@
99
99
  "@instructure/ui-img": "^7",
100
100
  "@instructure/ui-link": "^7",
101
101
  "@instructure/ui-list": "^7",
102
- "@instructure/ui-media-player": "7",
102
+ "@instructure/ui-media-player": "^9.0.0",
103
103
  "@instructure/ui-menu": "^7",
104
104
  "@instructure/ui-modal": "^7",
105
105
  "@instructure/ui-motion": "^7",
@@ -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",
package/canvas/README.md DELETED
@@ -1,84 +0,0 @@
1
- # Canvas Rich Content Editor
2
-
3
- The Canvas LMS Rich Content Editor extracted in it's own npm package for use
4
- across multiple services. In the canvas ecosystem, this npm module is used
5
- in pair with a running `canvas-rce-api` microservice.
6
-
7
- Some features require a running instance of the `canvas-rce-api`,
8
- but you do not need that instance in order to
9
- do development on `canvas-rce`. (see [docs/development.md](docs/development.md))
10
-
11
- The first customer of the `canvas-rce` is the `canvas-lms` LMS so documentation
12
- and references throughout documentation might reflect and assume the use of
13
- `canvas-lms`.
14
-
15
- ## Install and setup
16
-
17
- As a published npm module, you can add canvas-rce to your node project by doing
18
- the following:
19
-
20
- ```bash
21
- npm install canvas-rce --save
22
- ```
23
-
24
- For guidance on how `canvas-rce` is used within canvas, please reference
25
- the [canvas-lms use of canvas-rce](https://github.com/instructure/canvas-lms/tree/stable/ui/shared/rce)
26
- to get an idea on how to incorporate it into your project. Pay
27
- special attention to the `RichContentEditor.js` and `serviceRCELoader.js`.
28
-
29
- Outside of canvas, the `CanvasRce` React component is your entry point.
30
- _Work is ongoing to make the props to `CanvasRce` more rational.
31
- Please be patient._
32
-
33
- ## Tests
34
-
35
- While canvas consumes the es modules build of the rce,
36
- Jest tests are run against the commonjs build, so make sure you've built the
37
- commonjs assets before running tests:
38
-
39
- ```bash
40
- yarn build:canvas
41
- yarn test:jest
42
- ```
43
-
44
- There are still legacy mocha tests run with `yarn test:mocha`. `yarn test` runs them all.
45
-
46
- ### test debugging hints
47
-
48
- ```
49
- yarn test:jest:debug path/to/__test__/file.test.js
50
- ```
51
-
52
- will break and wait for you to attach a debugger (e.g. `chrome://inspect/#devices`).
53
-
54
- Similarly, for mocha tests
55
-
56
- ```
57
- yarn test:mocha:debug path/to/test/file.test.js
58
- ```
59
-
60
- Both those commands may include a `--watch` argument to keep the process alive
61
- while you iterate.
62
-
63
- ## Polyfills
64
-
65
- This project makes use of modern JavaScript APIs like Promise, Object.assign,
66
- Array.prototype.includes, etc. which are present in modern
67
- browsers but may not be present in old browsers like IE 11. In order to not
68
- send unnecessarily large and duplicated code bundles to the browser, consumers
69
- are expected to have already globally polyfilled those APIs.
70
- Canvas only supports modern browsers and the rce has not been tested
71
- in older browsers like IE. If you need suggestions for how to include
72
- polyfills in your
73
- own app, you can just put this in your html above the script that includes
74
- canvas-rce:
75
-
76
- ```
77
- <script src="https://cdn.polyfill.io/v2/polyfill.min.js?rum=0"></script>
78
- ```
79
-
80
- (See: https://polyfill.io/v2/docs/ for more info)
81
-
82
- ## Development
83
-
84
- See [DEVELOPMENT.md](./DEVELOPMENT.md)