@instructure/canvas-rce 5.6.17 → 5.6.18

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 (175) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/es/rce/plugins/shared/fileTypeUtils.js +14 -6
  3. package/es/sidebar/actions/upload.js +3 -1
  4. package/lib/rce/plugins/shared/fileTypeUtils.js +14 -6
  5. package/lib/sidebar/actions/upload.js +3 -1
  6. package/lib/translated/ar/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  7. package/lib/translated/ar/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  8. package/lib/translated/ar/modules/sidebar/actions/upload.js +3 -1
  9. package/lib/translated/ca/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  10. package/lib/translated/ca/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  11. package/lib/translated/ca/modules/sidebar/actions/upload.js +3 -1
  12. package/lib/translated/cy/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  13. package/lib/translated/cy/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  14. package/lib/translated/cy/modules/sidebar/actions/upload.js +3 -1
  15. package/lib/translated/da/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  16. package/lib/translated/da/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  17. package/lib/translated/da/modules/sidebar/actions/upload.js +3 -1
  18. package/lib/translated/da-x-k12/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  19. package/lib/translated/da-x-k12/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  20. package/lib/translated/da-x-k12/modules/sidebar/actions/upload.js +3 -1
  21. package/lib/translated/de/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  22. package/lib/translated/de/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  23. package/lib/translated/de/modules/sidebar/actions/upload.js +3 -1
  24. package/lib/translated/el/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  25. package/lib/translated/el/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  26. package/lib/translated/el/modules/sidebar/actions/upload.js +3 -1
  27. package/lib/translated/en/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  28. package/lib/translated/en/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  29. package/lib/translated/en/modules/sidebar/actions/upload.js +3 -1
  30. package/lib/translated/en-AU-x-unimelb/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  31. package/lib/translated/en-AU-x-unimelb/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  32. package/lib/translated/en-AU-x-unimelb/modules/sidebar/actions/upload.js +3 -1
  33. package/lib/translated/en-GB-x-ukhe/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  34. package/lib/translated/en-GB-x-ukhe/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  35. package/lib/translated/en-GB-x-ukhe/modules/sidebar/actions/upload.js +3 -1
  36. package/lib/translated/en_AU/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  37. package/lib/translated/en_AU/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  38. package/lib/translated/en_AU/modules/sidebar/actions/upload.js +3 -1
  39. package/lib/translated/en_CA/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  40. package/lib/translated/en_CA/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  41. package/lib/translated/en_CA/modules/sidebar/actions/upload.js +3 -1
  42. package/lib/translated/en_CY/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  43. package/lib/translated/en_CY/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  44. package/lib/translated/en_CY/modules/sidebar/actions/upload.js +3 -1
  45. package/lib/translated/en_GB/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  46. package/lib/translated/en_GB/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  47. package/lib/translated/en_GB/modules/sidebar/actions/upload.js +3 -1
  48. package/lib/translated/es/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  49. package/lib/translated/es/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  50. package/lib/translated/es/modules/sidebar/actions/upload.js +3 -1
  51. package/lib/translated/es_ES/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  52. package/lib/translated/es_ES/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  53. package/lib/translated/es_ES/modules/sidebar/actions/upload.js +3 -1
  54. package/lib/translated/es_GT/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  55. package/lib/translated/es_GT/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  56. package/lib/translated/es_GT/modules/sidebar/actions/upload.js +3 -1
  57. package/lib/translated/fa_IR/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  58. package/lib/translated/fa_IR/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  59. package/lib/translated/fa_IR/modules/sidebar/actions/upload.js +3 -1
  60. package/lib/translated/fi/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  61. package/lib/translated/fi/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  62. package/lib/translated/fi/modules/sidebar/actions/upload.js +3 -1
  63. package/lib/translated/fr/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  64. package/lib/translated/fr/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  65. package/lib/translated/fr/modules/sidebar/actions/upload.js +3 -1
  66. package/lib/translated/fr_CA/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  67. package/lib/translated/fr_CA/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  68. package/lib/translated/fr_CA/modules/sidebar/actions/upload.js +3 -1
  69. package/lib/translated/he/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  70. package/lib/translated/he/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  71. package/lib/translated/he/modules/sidebar/actions/upload.js +3 -1
  72. package/lib/translated/ht/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  73. package/lib/translated/ht/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  74. package/lib/translated/ht/modules/sidebar/actions/upload.js +3 -1
  75. package/lib/translated/hu/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  76. package/lib/translated/hu/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  77. package/lib/translated/hu/modules/sidebar/actions/upload.js +3 -1
  78. package/lib/translated/hy/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  79. package/lib/translated/hy/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  80. package/lib/translated/hy/modules/sidebar/actions/upload.js +3 -1
  81. package/lib/translated/is/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  82. package/lib/translated/is/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  83. package/lib/translated/is/modules/sidebar/actions/upload.js +3 -1
  84. package/lib/translated/it/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  85. package/lib/translated/it/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  86. package/lib/translated/it/modules/sidebar/actions/upload.js +3 -1
  87. package/lib/translated/ja/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  88. package/lib/translated/ja/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  89. package/lib/translated/ja/modules/sidebar/actions/upload.js +3 -1
  90. package/lib/translated/ko/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  91. package/lib/translated/ko/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  92. package/lib/translated/ko/modules/sidebar/actions/upload.js +3 -1
  93. package/lib/translated/mi/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  94. package/lib/translated/mi/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  95. package/lib/translated/mi/modules/sidebar/actions/upload.js +3 -1
  96. package/lib/translated/ms/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  97. package/lib/translated/ms/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  98. package/lib/translated/ms/modules/sidebar/actions/upload.js +3 -1
  99. package/lib/translated/nb/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  100. package/lib/translated/nb/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  101. package/lib/translated/nb/modules/sidebar/actions/upload.js +3 -1
  102. package/lib/translated/nb-x-k12/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  103. package/lib/translated/nb-x-k12/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  104. package/lib/translated/nb-x-k12/modules/sidebar/actions/upload.js +3 -1
  105. package/lib/translated/nl/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  106. package/lib/translated/nl/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  107. package/lib/translated/nl/modules/sidebar/actions/upload.js +3 -1
  108. package/lib/translated/nn/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  109. package/lib/translated/nn/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  110. package/lib/translated/nn/modules/sidebar/actions/upload.js +3 -1
  111. package/lib/translated/pl/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  112. package/lib/translated/pl/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  113. package/lib/translated/pl/modules/sidebar/actions/upload.js +3 -1
  114. package/lib/translated/pt/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  115. package/lib/translated/pt/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  116. package/lib/translated/pt/modules/sidebar/actions/upload.js +3 -1
  117. package/lib/translated/pt_BR/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  118. package/lib/translated/pt_BR/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  119. package/lib/translated/pt_BR/modules/sidebar/actions/upload.js +3 -1
  120. package/lib/translated/ru/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  121. package/lib/translated/ru/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  122. package/lib/translated/ru/modules/sidebar/actions/upload.js +3 -1
  123. package/lib/translated/se/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  124. package/lib/translated/se/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  125. package/lib/translated/se/modules/sidebar/actions/upload.js +3 -1
  126. package/lib/translated/sl/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  127. package/lib/translated/sl/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  128. package/lib/translated/sl/modules/sidebar/actions/upload.js +3 -1
  129. package/lib/translated/sv/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  130. package/lib/translated/sv/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  131. package/lib/translated/sv/modules/sidebar/actions/upload.js +3 -1
  132. package/lib/translated/sv-x-k12/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  133. package/lib/translated/sv-x-k12/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  134. package/lib/translated/sv-x-k12/modules/sidebar/actions/upload.js +3 -1
  135. package/lib/translated/sv_SE/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  136. package/lib/translated/sv_SE/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  137. package/lib/translated/sv_SE/modules/sidebar/actions/upload.js +3 -1
  138. package/lib/translated/tg/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  139. package/lib/translated/tg/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  140. package/lib/translated/tg/modules/sidebar/actions/upload.js +3 -1
  141. package/lib/translated/th/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  142. package/lib/translated/th/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  143. package/lib/translated/th/modules/sidebar/actions/upload.js +3 -1
  144. package/lib/translated/th_TH/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  145. package/lib/translated/th_TH/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  146. package/lib/translated/th_TH/modules/sidebar/actions/upload.js +3 -1
  147. package/lib/translated/tr/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  148. package/lib/translated/tr/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  149. package/lib/translated/tr/modules/sidebar/actions/upload.js +3 -1
  150. package/lib/translated/uk_UA/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  151. package/lib/translated/uk_UA/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  152. package/lib/translated/uk_UA/modules/sidebar/actions/upload.js +3 -1
  153. package/lib/translated/vi/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  154. package/lib/translated/vi/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  155. package/lib/translated/vi/modules/sidebar/actions/upload.js +3 -1
  156. package/lib/translated/vi_VN/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  157. package/lib/translated/vi_VN/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  158. package/lib/translated/vi_VN/modules/sidebar/actions/upload.js +3 -1
  159. package/lib/translated/zh/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  160. package/lib/translated/zh/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  161. package/lib/translated/zh/modules/sidebar/actions/upload.js +3 -1
  162. package/lib/translated/zh-Hans/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  163. package/lib/translated/zh-Hans/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  164. package/lib/translated/zh-Hans/modules/sidebar/actions/upload.js +3 -1
  165. package/lib/translated/zh-Hant/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  166. package/lib/translated/zh-Hant/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  167. package/lib/translated/zh-Hant/modules/sidebar/actions/upload.js +3 -1
  168. package/lib/translated/zh_HK/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
  169. package/lib/translated/zh_HK/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
  170. package/lib/translated/zh_HK/modules/sidebar/actions/upload.js +3 -1
  171. package/package.json +3 -2
  172. package/scripts/publishToNpm.sh +77 -0
  173. package/canvas/README.md +0 -84
  174. package/canvas/locales/en.json +0 -934
  175. package/canvas/package.json +0 -189
@@ -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) {
@@ -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');
@@ -138,11 +138,22 @@ describe('fileTypeUtils', () => {
138
138
  it('uses attachment route if id is present', () => {
139
139
  const file = {
140
140
  id: '123',
141
- type: 'video/mov'
141
+ type: 'video/mov',
142
+ uuid: 'abc'
142
143
  };
143
144
  const url = mediaPlayerURLFromFile(file);
144
145
  expect(url).toBe('/media_attachments_iframe/123?type=video&embedded=true');
145
146
  });
147
+ it('uses adds the uuid if the context is User', () => {
148
+ const file = {
149
+ id: '123',
150
+ type: 'video/mov',
151
+ contextType: 'User',
152
+ uuid: 'abc'
153
+ };
154
+ const url = mediaPlayerURLFromFile(file);
155
+ expect(url).toBe('/media_attachments_iframe/123?type=video&embedded=true&verifier=abc');
156
+ });
146
157
  it('uses the file verifier if present', () => {
147
158
  const file = {
148
159
  id: '123',
@@ -150,7 +161,7 @@ describe('fileTypeUtils', () => {
150
161
  url: 'host?verifier=something'
151
162
  };
152
163
  const url = mediaPlayerURLFromFile(file);
153
- expect(url).toBe('/media_attachments_iframe/123?type=video&verifier=something&embedded=true');
164
+ expect(url).toBe('/media_attachments_iframe/123?type=video&embedded=true&verifier=something');
154
165
  });
155
166
  it('uses media_object route if no attachmentId exists', () => {
156
167
  const file = {
@@ -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) {
@@ -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');
@@ -138,11 +138,22 @@ describe('fileTypeUtils', () => {
138
138
  it('uses attachment route if id is present', () => {
139
139
  const file = {
140
140
  id: '123',
141
- type: 'video/mov'
141
+ type: 'video/mov',
142
+ uuid: 'abc'
142
143
  };
143
144
  const url = mediaPlayerURLFromFile(file);
144
145
  expect(url).toBe('/media_attachments_iframe/123?type=video&embedded=true');
145
146
  });
147
+ it('uses adds the uuid if the context is User', () => {
148
+ const file = {
149
+ id: '123',
150
+ type: 'video/mov',
151
+ contextType: 'User',
152
+ uuid: 'abc'
153
+ };
154
+ const url = mediaPlayerURLFromFile(file);
155
+ expect(url).toBe('/media_attachments_iframe/123?type=video&embedded=true&verifier=abc');
156
+ });
146
157
  it('uses the file verifier if present', () => {
147
158
  const file = {
148
159
  id: '123',
@@ -150,7 +161,7 @@ describe('fileTypeUtils', () => {
150
161
  url: 'host?verifier=something'
151
162
  };
152
163
  const url = mediaPlayerURLFromFile(file);
153
- expect(url).toBe('/media_attachments_iframe/123?type=video&verifier=something&embedded=true');
164
+ expect(url).toBe('/media_attachments_iframe/123?type=video&embedded=true&verifier=something');
154
165
  });
155
166
  it('uses media_object route if no attachmentId exists', () => {
156
167
  const file = {
@@ -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) {
@@ -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');
@@ -138,11 +138,22 @@ describe('fileTypeUtils', () => {
138
138
  it('uses attachment route if id is present', () => {
139
139
  const file = {
140
140
  id: '123',
141
- type: 'video/mov'
141
+ type: 'video/mov',
142
+ uuid: 'abc'
142
143
  };
143
144
  const url = mediaPlayerURLFromFile(file);
144
145
  expect(url).toBe('/media_attachments_iframe/123?type=video&embedded=true');
145
146
  });
147
+ it('uses adds the uuid if the context is User', () => {
148
+ const file = {
149
+ id: '123',
150
+ type: 'video/mov',
151
+ contextType: 'User',
152
+ uuid: 'abc'
153
+ };
154
+ const url = mediaPlayerURLFromFile(file);
155
+ expect(url).toBe('/media_attachments_iframe/123?type=video&embedded=true&verifier=abc');
156
+ });
146
157
  it('uses the file verifier if present', () => {
147
158
  const file = {
148
159
  id: '123',
@@ -150,7 +161,7 @@ describe('fileTypeUtils', () => {
150
161
  url: 'host?verifier=something'
151
162
  };
152
163
  const url = mediaPlayerURLFromFile(file);
153
- expect(url).toBe('/media_attachments_iframe/123?type=video&verifier=something&embedded=true');
164
+ expect(url).toBe('/media_attachments_iframe/123?type=video&embedded=true&verifier=something');
154
165
  });
155
166
  it('uses media_object route if no attachmentId exists', () => {
156
167
  const file = {
@@ -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) {
@@ -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');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/canvas-rce",
3
- "version": "5.6.17",
3
+ "version": "5.6.18",
4
4
  "description": "A component wrapping Canvas's usage of Tinymce",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -47,7 +47,8 @@
47
47
  "fmt:fix": "prettier --write '**/*.js*' '**/*.ts*'",
48
48
  "clean": "rm -rf lib && yarn clean:es && rm -rf coverage && yarn demo:clean",
49
49
  "clean:es": "rm -rf es",
50
- "generate-svgs": "yarn build:cjs && scripts/generateSvgs.js && prettier --write src/rce/plugins/instructure_equation/MathIcon/svgs.js"
50
+ "generate-svgs": "yarn build:cjs && scripts/generateSvgs.js && prettier --write src/rce/plugins/instructure_equation/MathIcon/svgs.js",
51
+ "publishToNpm": "scripts/publishToNpm.sh"
51
52
  },
52
53
  "keywords": [
53
54
  "canvas",
@@ -0,0 +1,77 @@
1
+ #!/bin/bash
2
+
3
+ # This script will remind you to update the change log and
4
+ # to bump the version number of the package
5
+
6
+ # It will then check that you're logged into AWS (which
7
+ # is required to send the Slack notification)
8
+
9
+ # After those valiations are complete, it will prompt you
10
+ # to log into npm and it will then publish the package
11
+
12
+ # If the publish succeeds, it will send a Slack notification
13
+
14
+ # You can disable various steps of the script for dry runs
15
+ # by setting the following when running the script:
16
+ # SKIP_NPM_LOGIN=1
17
+ # SKIP_NPM_PUBLISH=1
18
+ # SKIP_ALERT=1
19
+
20
+ function prompt {
21
+ read -p "$1 (Y/N): " confirm &&
22
+ if [[ ! "$confirm" =~ ^[Yy]+([eE][sS])?$ ]]; then
23
+ echo -e "\n⚠️ $2 ⚠️\n"
24
+ exit 1
25
+ fi
26
+ }
27
+
28
+ prompt "Did you update CHANGELOG.md?" "Update CHANGELOG.md before publishing to NPM."
29
+
30
+ prompt "Did you bump the version number in package.json?" "Bump the version number in package.json before publishing to NPM."
31
+
32
+ if [ -z "$SKIP_ALERT" ]; then
33
+ # runs the get-user command and throws away output
34
+ # checks for nonzero exit code to determine if the
35
+ # user is logged in or not
36
+ aws iam get-user > /dev/null 2>&1
37
+ if [[ ! $? -eq 0 ]]; then
38
+ echo -e "\n⚠️ Please log into AWS and try again. ⚠️\n"
39
+ exit 1
40
+ fi
41
+ else
42
+ echo "Would have checked if you were logged into AWS"
43
+ fi
44
+
45
+ if [ -z "$SKIP_NPM_LOGIN" ]; then
46
+ echo -e "\nLogging into NPM...\n"
47
+ npm login
48
+ else
49
+ echo "Would have logged into NPM"
50
+ fi
51
+
52
+ if [ -z "$SKIP_NPM_PUBLISH" ]; then
53
+ echo -e "\nPublishing to NPM...\n"
54
+ npm publish
55
+ else
56
+ echo "Would have published to NPM"
57
+ fi
58
+
59
+ if [[ ! $? -eq 0 ]]; then
60
+ echo -e "\n🚨 Publish failed. Please try again. 🚨\n"
61
+ exit 1
62
+ fi
63
+
64
+ PACKAGE_VERSION=$(cat package.json | grep "version" | awk '{print $2}' | sed 's/[",]//g')
65
+ CHANGELOG_LINK="<https://gerrit.instructure.com/plugins/gitiles/canvas-lms/+/refs/heads/master/packages/canvas-rce/CHANGELOG.md | here>"
66
+ SLACK_MESSAGE="canvas-rce version $PACKAGE_VERSION has been published to NPM \n\nSee the full list of changes $CHANGELOG_LINK."
67
+
68
+ if [ -z "$SKIP_ALERT" ]; then
69
+ (
70
+ aws --region us-east-1 sqs send-message \
71
+ --queue-url https://sqs.us-east-1.amazonaws.com/636161780776/slack-lambda \
72
+ --message-body "{\"channel\":\"#ask-learning-foundations\",\"username\":\"RCE Publish\",\"text\":\"$SLACK_MESSAGE\"}"
73
+ ) || echo "Failed to send Slack message."
74
+ else
75
+ echo "Would have sent a Slack message:"
76
+ echo -e $SLACK_MESSAGE
77
+ fi
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)