@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.
- package/CHANGELOG.md +5 -0
- package/es/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/es/sidebar/actions/upload.js +3 -1
- package/lib/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/sidebar/actions/upload.js +3 -1
- package/lib/translated/ar/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/ar/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/ar/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/ca/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/ca/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/ca/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/cy/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/cy/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/cy/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/da/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/da/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/da/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/da-x-k12/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/da-x-k12/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/da-x-k12/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/de/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/de/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/de/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/el/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/el/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/el/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/en/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/en/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/en/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/en-AU-x-unimelb/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/en-AU-x-unimelb/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/en-AU-x-unimelb/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/en-GB-x-ukhe/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/en-GB-x-ukhe/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/en-GB-x-ukhe/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/en_AU/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/en_AU/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/en_AU/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/en_CA/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/en_CA/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/en_CA/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/en_CY/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/en_CY/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/en_CY/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/en_GB/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/en_GB/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/en_GB/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/es/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/es/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/es/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/es_ES/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/es_ES/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/es_ES/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/es_GT/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/es_GT/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/es_GT/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/fa_IR/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/fa_IR/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/fa_IR/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/fi/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/fi/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/fi/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/fr/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/fr/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/fr/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/fr_CA/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/fr_CA/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/fr_CA/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/he/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/he/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/he/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/ht/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/ht/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/ht/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/hu/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/hu/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/hu/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/hy/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/hy/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/hy/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/is/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/is/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/is/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/it/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/it/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/it/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/ja/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/ja/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/ja/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/ko/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/ko/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/ko/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/mi/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/mi/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/mi/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/ms/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/ms/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/ms/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/nb/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/nb/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/nb/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/nb-x-k12/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/nb-x-k12/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/nb-x-k12/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/nl/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/nl/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/nl/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/nn/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/nn/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/nn/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/pl/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/pl/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/pl/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/pt/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/pt/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/pt/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/pt_BR/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/pt_BR/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/pt_BR/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/ru/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/ru/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/ru/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/se/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/se/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/se/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/sl/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/sl/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/sl/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/sv/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/sv/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/sv/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/sv-x-k12/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/sv-x-k12/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/sv-x-k12/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/sv_SE/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/sv_SE/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/sv_SE/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/tg/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/tg/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/tg/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/th/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/th/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/th/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/th_TH/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/th_TH/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/th_TH/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/tr/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/tr/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/tr/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/uk_UA/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/uk_UA/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/uk_UA/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/vi/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/vi/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/vi/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/vi_VN/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/vi_VN/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/vi_VN/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/zh/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/zh/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/zh/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/zh-Hans/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/zh-Hans/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/zh-Hans/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/zh-Hant/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/zh-Hant/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/zh-Hant/modules/sidebar/actions/upload.js +3 -1
- package/lib/translated/zh_HK/modules/rce/plugins/shared/__tests__/fileTypeUtils.test.js +13 -2
- package/lib/translated/zh_HK/modules/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/translated/zh_HK/modules/sidebar/actions/upload.js +3 -1
- package/package.json +3 -2
- package/scripts/publishToNpm.sh +77 -0
- package/canvas/README.md +0 -84
- package/canvas/locales/en.json +0 -934
- 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
|
-
|
|
98
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
98
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
98
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
98
|
-
|
|
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
|
-
|
|
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.
|
|
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)
|