@instructure/canvas-rce 5.10.0 → 5.10.2

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.
@@ -24,7 +24,7 @@ import { Button, IconButton, CondensedButton } from '@instructure/ui-buttons';
24
24
  import { Flex } from '@instructure/ui-flex';
25
25
  import { View } from '@instructure/ui-view';
26
26
  import { Badge } from '@instructure/ui-badge';
27
- import { InstUISettingsProvider } from '@instructure/emotion';
27
+ import { ApplyTheme } from '@instructure/ui-themeable';
28
28
  import { Text } from '@instructure/ui-text';
29
29
  import { SVGIcon } from '@instructure/ui-svg-images';
30
30
  import { IconA11yLine, IconKeyboardShortcutsLine, IconMiniArrowEndLine, IconFullScreenLine, IconExitFullScreenLine } from '@instructure/ui-icons';
@@ -190,12 +190,10 @@ export default function StatusBar(props) {
190
190
  return button;
191
191
  }
192
192
 
193
- return /*#__PURE__*/React.createElement(InstUISettingsProvider, {
193
+ return /*#__PURE__*/React.createElement(ApplyTheme, {
194
194
  theme: {
195
- componentOverrides: {
196
- Badge: {
197
- colorPrimary: props.a11yBadgeColor
198
- }
195
+ [Badge.theme]: {
196
+ colorPrimary: props.a11yBadgeColor
199
197
  }
200
198
  }
201
199
  }, /*#__PURE__*/React.createElement(Badge, {
@@ -35,7 +35,7 @@ export default class ResourceLinkContentItem extends BaseLinkContentItem {
35
35
 
36
36
  buildUrl() {
37
37
  return addQueryParamsToUrl(this.context.ltiEndpoint, {
38
- display: 'borderless',
38
+ display: 'in_rce',
39
39
  resource_link_lookup_uuid: this.lookup_uuid,
40
40
  [PARENT_FRAME_CONTEXT_PARAM]: this.context.containingCanvasLtiToolId
41
41
  });
@@ -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) {
@@ -36,7 +36,7 @@ import { TextInput } from '@instructure/ui-text-input';
36
36
  import { TextArea } from '@instructure/ui-text-area';
37
37
  import { SimpleSelect } from '@instructure/ui-simple-select';
38
38
  import { IconQuestionLine } from '@instructure/ui-icons';
39
- import { InstUISettingsProvider } from '@instructure/emotion';
39
+ import { ApplyTheme } from '@instructure/ui-themeable';
40
40
  import { Alert } from '@instructure/ui-alerts';
41
41
  import ColorField from './color-field';
42
42
  import PlaceholderSVG from './placeholder-svg';
@@ -428,12 +428,10 @@ export default class Checker extends React.Component {
428
428
  onClick: () => this.setState({
429
429
  showWhyPopover: false
430
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, {
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(ApplyTheme, {
432
432
  theme: {
433
- componentOverrides: {
434
- Link: {
435
- textDecoration: 'underline'
436
- }
433
+ [Link.theme]: {
434
+ textDecoration: 'underline'
437
435
  }
438
436
  }
439
437
  }, /*#__PURE__*/React.createElement(Link, {
@@ -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');
@@ -0,0 +1,127 @@
1
+ /*
2
+ * Copyright (C) 2019 - 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 { darken, lighten, alpha } from '@instructure/ui-color-utils'; // pull canvas theme values we need for the rce skin
19
+
20
+ export default function generator(_ref) {
21
+ let {
22
+ borders,
23
+ colors,
24
+ forms,
25
+ shadows,
26
+ spacing,
27
+ typography
28
+ } = _ref;
29
+ const vars = {
30
+ canvasBackgroundColor: colors.white,
31
+ canvasTextColor: colors.textDarkest,
32
+ canvasErrorColor: colors.textDanger,
33
+ canvasWarningColor: colors.textWarning,
34
+ canvasInfoColor: colors.textInfo,
35
+ canvasSuccessColor: colors.textSuccess,
36
+ canvasBorderColor: colors.borderMedium,
37
+ toolbarButtonHoverBackground: darken(colors.backgroundLightest, 5),
38
+ // copied from INSTUI "light" Button
39
+ canvasBrandColor: colors.brand,
40
+ activeMenuItemBackground: colors.backgroundBrand,
41
+ activeMenuItemLabelColor: colors.textLightest,
42
+ tableSelectorHighlightColor: alpha(lighten(colors.brand, 10), 50),
43
+ canvasLinkColor: colors.link,
44
+ canvasLinkDecoration: 'none',
45
+ // the instui default button
46
+ canvasButtonBackground: colors.backgroundLightest,
47
+ canvasButtonBorderColor: 'transparent',
48
+ canvasButtonColor: colors.textDarkest,
49
+ canvasButtonHoverBackground: colors.backgroundLightest,
50
+ canvasButtonHoverColor: colors.brand,
51
+ canvasButtonActiveBackground: colors.backgroundLightest,
52
+ canvasButtonFontWeight: typography.fontWeightNormal,
53
+ canvasButtonFontSize: typography.fontSizeMedium,
54
+ canvasButtonLineHeight: forms.inputHeightMedium,
55
+ canvasButtonPadding: `0 ${spacing.small}`,
56
+ // the instui primary button
57
+ canvasPrimaryButtonBackground: colors.backgroundBrand,
58
+ canvasPrimaryButtonColor: colors.textLightest,
59
+ canvasPrimaryButtonBorderColor: 'transparent',
60
+ canvasPrimaryButtonHoverBackground: darken(colors.backgroundBrand, 10),
61
+ canvasPrimaryButtonHoverColor: colors.textLightest,
62
+ // the instui secondary button
63
+ canvasSecondaryButtonBackground: colors.backgroundLight,
64
+ canvasSecondaryButtonColor: colors.textDarkest,
65
+ canvasSecondaryButtonBorderColor: darken(colors.backgroundLight, 10),
66
+ canvasSecondaryButtonHoverBackground: darken(colors.backgroundLight, 10),
67
+ canvasSecondaryButtonHoverColor: colors.textDarkest,
68
+ canvasFocusBorderColor: borders.brand,
69
+ canvasFocusBorderWidth: borders.widthSmall,
70
+ // canvas really uses widthMedium
71
+ canvasFocusBoxShadow: `0 0 0 2px ${colors.brand}`,
72
+ canvasEnabledColor: borders.brand,
73
+ canvasEnabledBoxShadow: `inset 0 0 0.1875rem 0.0625rem ${darken(colors.borderLightest, 25)}`,
74
+ canvasFontFamily: typography.fontFamily,
75
+ canvasFontSize: '1rem',
76
+ canvasFontSizeSmall: typography.fontSizeSmall,
77
+ // modal dialogs
78
+ canvasModalShadow: shadows.depth3,
79
+ canvasModalHeadingPadding: spacing.medium,
80
+ canvasModalHeadingFontSize: typography.fontSizeXLarge,
81
+ canvasModalHeadingFontWeight: typography.fontWeightNormal,
82
+ canvasModalBodyPadding: spacing.medium,
83
+ canvasModalFooterPadding: spacing.small,
84
+ canvasModalFooterBackground: colors.backgroundLight,
85
+ canvasFormElementMargin: `0 0 ${spacing.medium} 0`,
86
+ canvasFormElementLabelColor: colors.textDarkest,
87
+ canvasFormElementLabelMargin: `0 0 ${spacing.small} 0`,
88
+ canvasFormElementLabelFontSize: typography.fontSizeMedium,
89
+ canvasFormElementLabelFontWeight: typography.fontWeightBold,
90
+ // a11y button badge
91
+ canvasBadgeBackgroundColor: colors.textInfo
92
+ };
93
+ vars.tinySplitButtonChevronHoverBackground = darken(vars.toolbarButtonHoverBackground, 10);
94
+ return vars;
95
+ }
96
+
97
+ generator.canvas = function (variables) {
98
+ return {
99
+ canvasLinkColor: variables['ic-link-color'],
100
+ canvasLinkDecoration: variables['ic-link-decoration'],
101
+ canvasTextColor: variables['ic-brand-font-color-dark'],
102
+ canvasBrandColor: variables['ic-brand-primary'],
103
+ canvasFocusBorderColor: variables['ic-brand-primary'],
104
+ canvasFocusBoxShadow: `0 0 0 2px ${variables['ic-brand-primary']}`,
105
+ canvasEnabledColor: variables['ic-brand-primary'],
106
+ canvasPrimaryButtonBackground: variables['ic-brand-primary'],
107
+ canvasPrimaryButtonColor: variables['ic-brand-button--primary-text'],
108
+ canvasPrimaryButtonHoverBackground: darken(variables['ic-brand-button--primary-bgd'], 10),
109
+ activeMenuItemBackground: variables['ic-brand-button--primary-bgd'],
110
+ activeMenuItemLabelColor: variables['ic-brand-button--primary-text'],
111
+ tableSelectorHighlightColor: alpha(lighten(variables['ic-brand-primary'], 10), 50)
112
+ };
113
+ };
114
+
115
+ generator['canvas-a11y'] = generator['canvas-high-contrast'] = function (_ref2) {
116
+ let {
117
+ colors
118
+ } = _ref2;
119
+ return {
120
+ canvasButtonBackground: colors.backgroundLight,
121
+ canvasSecondaryButtonBorderColor: colors.borderMedium,
122
+ canvasLinkDecoration: 'underline',
123
+ canvasFocusBorderColor: colors.borderBrand,
124
+ canvasFocusBoxShadow: `0 0 0 2px ${colors.brand}`,
125
+ canvasBrandColor: colors.brand
126
+ };
127
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/canvas-rce",
3
- "version": "5.10.0",
3
+ "version": "5.10.2",
4
4
  "description": "A component wrapping Canvas's usage of Tinymce",
5
5
  "main": "es/index.js",
6
6
  "scripts": {
@@ -76,9 +76,8 @@
76
76
  "@instructure/canvas-media": "*",
77
77
  "@instructure/canvas-theme": "7",
78
78
  "@instructure/debounce": "^7",
79
- "@instructure/emotion": "^8.38.1",
80
79
  "@instructure/k5uploader": "*",
81
- "@instructure/media-capture": "^9.0.0",
80
+ "@instructure/media-capture": "~8.4.1-rc.16",
82
81
  "@instructure/ui-a11y-content": "^7",
83
82
  "@instructure/ui-a11y-utils": "^7",
84
83
  "@instructure/ui-alerts": "^7",
@@ -99,7 +98,7 @@
99
98
  "@instructure/ui-img": "^7",
100
99
  "@instructure/ui-link": "^7",
101
100
  "@instructure/ui-list": "^7",
102
- "@instructure/ui-media-player": "^9.0.0",
101
+ "@instructure/ui-media-player": "7",
103
102
  "@instructure/ui-menu": "^7",
104
103
  "@instructure/ui-modal": "^7",
105
104
  "@instructure/ui-motion": "^7",
@@ -158,18 +157,18 @@
158
157
  "redux-batch-middleware": "^0.2.0",
159
158
  "redux-thunk": "^2",
160
159
  "scroll-into-view": "https://github.com/bkirkby/scroll-into-view.git#588b0ced98eeecf84e6fb2074aa076e80b7cffab",
161
- "text-field-edit": "^3.2.0",
162
160
  "tinymce": "^5",
161
+ "text-field-edit": "^3.2.0",
163
162
  "uri-js": "^4.2.2",
164
163
  "wcag-element-contrast": "^1.0.1"
165
164
  },
166
165
  "devDependencies": {
167
166
  "@babel/cli": "^7",
168
167
  "@babel/core": "^7",
169
- "@babel/plugin-proposal-optional-chaining": "^7.20.7",
170
- "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3",
171
168
  "@babel/preset-typescript": "^7",
172
169
  "@babel/register": "7",
170
+ "@babel/plugin-proposal-optional-chaining": "^7.20.7",
171
+ "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3",
173
172
  "@instructure/babel-plugin-themeable-styles": "7.19.0-canvas",
174
173
  "@instructure/browserslist-config-canvas-lms": ">=2",
175
174
  "@instructure/translations": ">=1",
@@ -198,7 +197,6 @@
198
197
  "jest": "^28",
199
198
  "jest-canvas-mock": "^2",
200
199
  "jest-junit": "^7",
201
- "jest-mock-proxy": "3.1.2",
202
200
  "mathjax": "^3.2.0",
203
201
  "mocha": "^6",
204
202
  "mocha-junit-reporter": "^1.18.0",
@@ -210,7 +208,6 @@
210
208
  "shelljs": "^0.8.3",
211
209
  "sinon": "^7",
212
210
  "skin-deep": "^1",
213
- "source-map-support": "0.5.21",
214
211
  "testcafe": "1.14.2",
215
212
  "testcafe-browser-provider-selenium": "^1.2.0",
216
213
  "testcafe-react-selectors": "^3.3.0",
@@ -220,7 +217,9 @@
220
217
  "webpack": "^5",
221
218
  "webpack-merge": "^5",
222
219
  "webpack-nano": "^1",
223
- "webpack-plugin-serve": "^1"
220
+ "webpack-plugin-serve": "^1",
221
+ "source-map-support": "0.5.21",
222
+ "jest-mock-proxy": "3.1.2"
224
223
  },
225
224
  "resolutions": {
226
225
  "format-message-estree-util": "./packages/format-message-estree-util"
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)