@instructure/canvas-rce 5.10.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.
- package/CHANGELOG.md +6 -0
- package/es/enhance-user-content/enhance_user_content.js +9 -1
- package/es/rce/RCEWrapper.js +0 -59
- package/es/rce/plugins/instructure_rce_external_tools/lti13-content-items/models/ResourceLinkContentItem.js +1 -1
- package/es/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/es/rce/transformContent.js +8 -0
- package/es/sidebar/actions/upload.js +3 -1
- package/lib/enhance-user-content/enhance_user_content.js +9 -1
- package/lib/rce/RCEWrapper.js +0 -59
- package/lib/rce/plugins/instructure_rce_external_tools/lti13-content-items/models/ResourceLinkContentItem.js +1 -1
- package/lib/rce/plugins/shared/fileTypeUtils.js +14 -6
- package/lib/rce/transformContent.js +8 -0
- package/lib/sidebar/actions/upload.js +3 -1
- package/package.json +1 -1
- package/canvas/README.md +0 -84
- package/canvas/locales/en.json +0 -934
- package/canvas/package.json +0 -189
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## 5.10.1 - 2023-12-01
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- Allow more fields from Canvas media object creation
|
|
12
|
+
- Ensure postMessage works with RCE LTI launches
|
|
13
|
+
|
|
8
14
|
## 5.10.0 - 2023-09-26
|
|
9
15
|
|
|
10
16
|
### Fixed
|
|
@@ -216,8 +216,16 @@ export function enhanceUserContent() {
|
|
|
216
216
|
iframeElem.setAttribute('src', addParentFrameContextToUrl(src, containingCanvasLtiToolId));
|
|
217
217
|
}
|
|
218
218
|
});
|
|
219
|
-
}
|
|
219
|
+
} // tell LTI tools that they are launching from within the active RCE
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
unenhanced_elem.querySelectorAll('iframe[src]').forEach(iframeElem => {
|
|
223
|
+
const src = iframeElem.getAttribute('src');
|
|
220
224
|
|
|
225
|
+
if (src.startsWith(canvasOrigin)) {
|
|
226
|
+
iframeElem.setAttribute('src', src.replace('display=in_rce', 'display=borderless'));
|
|
227
|
+
}
|
|
228
|
+
});
|
|
221
229
|
unenhanced_elem.querySelectorAll('a:not(.not_external, .external)').forEach(childLink => {
|
|
222
230
|
if (!isExternalLink(childLink, canvasOrigin)) return;
|
|
223
231
|
if (childLink.tagName === 'IMG' || childLink.querySelectorAll('img').length > 0) return;
|
package/es/rce/RCEWrapper.js
CHANGED
|
@@ -2714,67 +2714,9 @@ class RCEWrapper extends React.Component {
|
|
|
2714
2714
|
|
|
2715
2715
|
this.checkAccessibility();
|
|
2716
2716
|
this.fixToolbarKeyboardNavigation();
|
|
2717
|
-
this.forwardPostMessages();
|
|
2718
2717
|
(_this$props$onInitted = (_this$props = this.props).onInitted) === null || _this$props$onInitted === void 0 ? void 0 : _this$props$onInitted.call(_this$props, editor);
|
|
2719
2718
|
};
|
|
2720
2719
|
|
|
2721
|
-
this.forwardPostMessages = () => {
|
|
2722
|
-
const windowReferences = [];
|
|
2723
|
-
const rceWindow = this.editor.getWin(); // explicitly assign name for reference by parent window
|
|
2724
|
-
|
|
2725
|
-
rceWindow.name = `${RCEWrapper.editorFrameName}_${this.id}`;
|
|
2726
|
-
rceWindow.addEventListener('message', this.forwardPostMessagesHandler(rceWindow, windowReferences));
|
|
2727
|
-
};
|
|
2728
|
-
|
|
2729
|
-
this.forwardPostMessagesHandler = (rceWindow, windowReferences) => e => {
|
|
2730
|
-
let message;
|
|
2731
|
-
|
|
2732
|
-
try {
|
|
2733
|
-
message = typeof e.data === 'string' ? JSON.parse(e.data) : e.data;
|
|
2734
|
-
} catch (err) {
|
|
2735
|
-
// unparseable message may not be meant for our handlers
|
|
2736
|
-
return false;
|
|
2737
|
-
} // NOTE: the code to encode/decode `sourceToolInfo` is duplicated in
|
|
2738
|
-
// the ui/features/post_message_forwarding/index.ts, and
|
|
2739
|
-
// cannot be DRY'd because RCE is in a package
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
if (e.origin === rceWindow.origin) {
|
|
2743
|
-
const {
|
|
2744
|
-
sourceToolInfo,
|
|
2745
|
-
...messageWithoutSourceToolInfo
|
|
2746
|
-
} = message;
|
|
2747
|
-
const targetOrigin = sourceToolInfo === null || sourceToolInfo === void 0 ? void 0 : sourceToolInfo.origin;
|
|
2748
|
-
const targetWindow = windowReferences[sourceToolInfo === null || sourceToolInfo === void 0 ? void 0 : sourceToolInfo.windowId];
|
|
2749
|
-
|
|
2750
|
-
if (!targetOrigin || !targetWindow) {
|
|
2751
|
-
return false;
|
|
2752
|
-
}
|
|
2753
|
-
|
|
2754
|
-
targetWindow === null || targetWindow === void 0 ? void 0 : targetWindow.postMessage(messageWithoutSourceToolInfo, targetOrigin);
|
|
2755
|
-
} else {
|
|
2756
|
-
// message is from tool, forward to Canvas window
|
|
2757
|
-
// We can't forward the whole `e.source` window in the postMessage,
|
|
2758
|
-
// so we keep a list (`windowReferences`) of all windows we've received
|
|
2759
|
-
// messages from, and include the index into that list as `windowId`
|
|
2760
|
-
let windowId = windowReferences.indexOf(e.source);
|
|
2761
|
-
|
|
2762
|
-
if (windowId === -1) {
|
|
2763
|
-
windowReferences.push(e.source);
|
|
2764
|
-
windowId = windowReferences.length - 1;
|
|
2765
|
-
}
|
|
2766
|
-
|
|
2767
|
-
const newMessage = { ...message,
|
|
2768
|
-
sourceToolInfo: {
|
|
2769
|
-
origin: e.origin,
|
|
2770
|
-
windowId
|
|
2771
|
-
},
|
|
2772
|
-
frameName: rceWindow.name
|
|
2773
|
-
};
|
|
2774
|
-
rceWindow.parent.postMessage(newMessage, rceWindow.origin);
|
|
2775
|
-
}
|
|
2776
|
-
};
|
|
2777
|
-
|
|
2778
2720
|
this.fixToolbarKeyboardNavigation = () => {
|
|
2779
2721
|
var _this$_elementRef$cur2;
|
|
2780
2722
|
|
|
@@ -4257,7 +4199,6 @@ RCEWrapper.defaultProps = {
|
|
|
4257
4199
|
canvasOrigin: ''
|
|
4258
4200
|
};
|
|
4259
4201
|
RCEWrapper.skinCssInjected = false;
|
|
4260
|
-
RCEWrapper.editorFrameName = 'active_rce_frame';
|
|
4261
4202
|
|
|
4262
4203
|
function mergeMenuItems(standard, custom) {
|
|
4263
4204
|
var _custom$trim;
|
|
@@ -35,7 +35,7 @@ export default class ResourceLinkContentItem extends BaseLinkContentItem {
|
|
|
35
35
|
|
|
36
36
|
buildUrl() {
|
|
37
37
|
return addQueryParamsToUrl(this.context.ltiEndpoint, {
|
|
38
|
-
display: '
|
|
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
|
-
|
|
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) {
|
|
@@ -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');
|
|
@@ -216,8 +216,16 @@ export function enhanceUserContent() {
|
|
|
216
216
|
iframeElem.setAttribute('src', addParentFrameContextToUrl(src, containingCanvasLtiToolId));
|
|
217
217
|
}
|
|
218
218
|
});
|
|
219
|
-
}
|
|
219
|
+
} // tell LTI tools that they are launching from within the active RCE
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
unenhanced_elem.querySelectorAll('iframe[src]').forEach(iframeElem => {
|
|
223
|
+
const src = iframeElem.getAttribute('src');
|
|
220
224
|
|
|
225
|
+
if (src.startsWith(canvasOrigin)) {
|
|
226
|
+
iframeElem.setAttribute('src', src.replace('display=in_rce', 'display=borderless'));
|
|
227
|
+
}
|
|
228
|
+
});
|
|
221
229
|
unenhanced_elem.querySelectorAll('a:not(.not_external, .external)').forEach(childLink => {
|
|
222
230
|
if (!isExternalLink(childLink, canvasOrigin)) return;
|
|
223
231
|
if (childLink.tagName === 'IMG' || childLink.querySelectorAll('img').length > 0) return;
|
package/lib/rce/RCEWrapper.js
CHANGED
|
@@ -2714,67 +2714,9 @@ class RCEWrapper extends React.Component {
|
|
|
2714
2714
|
|
|
2715
2715
|
this.checkAccessibility();
|
|
2716
2716
|
this.fixToolbarKeyboardNavigation();
|
|
2717
|
-
this.forwardPostMessages();
|
|
2718
2717
|
(_this$props$onInitted = (_this$props = this.props).onInitted) === null || _this$props$onInitted === void 0 ? void 0 : _this$props$onInitted.call(_this$props, editor);
|
|
2719
2718
|
};
|
|
2720
2719
|
|
|
2721
|
-
this.forwardPostMessages = () => {
|
|
2722
|
-
const windowReferences = [];
|
|
2723
|
-
const rceWindow = this.editor.getWin(); // explicitly assign name for reference by parent window
|
|
2724
|
-
|
|
2725
|
-
rceWindow.name = `${RCEWrapper.editorFrameName}_${this.id}`;
|
|
2726
|
-
rceWindow.addEventListener('message', this.forwardPostMessagesHandler(rceWindow, windowReferences));
|
|
2727
|
-
};
|
|
2728
|
-
|
|
2729
|
-
this.forwardPostMessagesHandler = (rceWindow, windowReferences) => e => {
|
|
2730
|
-
let message;
|
|
2731
|
-
|
|
2732
|
-
try {
|
|
2733
|
-
message = typeof e.data === 'string' ? JSON.parse(e.data) : e.data;
|
|
2734
|
-
} catch (err) {
|
|
2735
|
-
// unparseable message may not be meant for our handlers
|
|
2736
|
-
return false;
|
|
2737
|
-
} // NOTE: the code to encode/decode `sourceToolInfo` is duplicated in
|
|
2738
|
-
// the ui/features/post_message_forwarding/index.ts, and
|
|
2739
|
-
// cannot be DRY'd because RCE is in a package
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
if (e.origin === rceWindow.origin) {
|
|
2743
|
-
const {
|
|
2744
|
-
sourceToolInfo,
|
|
2745
|
-
...messageWithoutSourceToolInfo
|
|
2746
|
-
} = message;
|
|
2747
|
-
const targetOrigin = sourceToolInfo === null || sourceToolInfo === void 0 ? void 0 : sourceToolInfo.origin;
|
|
2748
|
-
const targetWindow = windowReferences[sourceToolInfo === null || sourceToolInfo === void 0 ? void 0 : sourceToolInfo.windowId];
|
|
2749
|
-
|
|
2750
|
-
if (!targetOrigin || !targetWindow) {
|
|
2751
|
-
return false;
|
|
2752
|
-
}
|
|
2753
|
-
|
|
2754
|
-
targetWindow === null || targetWindow === void 0 ? void 0 : targetWindow.postMessage(messageWithoutSourceToolInfo, targetOrigin);
|
|
2755
|
-
} else {
|
|
2756
|
-
// message is from tool, forward to Canvas window
|
|
2757
|
-
// We can't forward the whole `e.source` window in the postMessage,
|
|
2758
|
-
// so we keep a list (`windowReferences`) of all windows we've received
|
|
2759
|
-
// messages from, and include the index into that list as `windowId`
|
|
2760
|
-
let windowId = windowReferences.indexOf(e.source);
|
|
2761
|
-
|
|
2762
|
-
if (windowId === -1) {
|
|
2763
|
-
windowReferences.push(e.source);
|
|
2764
|
-
windowId = windowReferences.length - 1;
|
|
2765
|
-
}
|
|
2766
|
-
|
|
2767
|
-
const newMessage = { ...message,
|
|
2768
|
-
sourceToolInfo: {
|
|
2769
|
-
origin: e.origin,
|
|
2770
|
-
windowId
|
|
2771
|
-
},
|
|
2772
|
-
frameName: rceWindow.name
|
|
2773
|
-
};
|
|
2774
|
-
rceWindow.parent.postMessage(newMessage, rceWindow.origin);
|
|
2775
|
-
}
|
|
2776
|
-
};
|
|
2777
|
-
|
|
2778
2720
|
this.fixToolbarKeyboardNavigation = () => {
|
|
2779
2721
|
var _this$_elementRef$cur2;
|
|
2780
2722
|
|
|
@@ -4257,7 +4199,6 @@ RCEWrapper.defaultProps = {
|
|
|
4257
4199
|
canvasOrigin: ''
|
|
4258
4200
|
};
|
|
4259
4201
|
RCEWrapper.skinCssInjected = false;
|
|
4260
|
-
RCEWrapper.editorFrameName = 'active_rce_frame';
|
|
4261
4202
|
|
|
4262
4203
|
function mergeMenuItems(standard, custom) {
|
|
4263
4204
|
var _custom$trim;
|
|
@@ -35,7 +35,7 @@ export default class ResourceLinkContentItem extends BaseLinkContentItem {
|
|
|
35
35
|
|
|
36
36
|
buildUrl() {
|
|
37
37
|
return addQueryParamsToUrl(this.context.ltiEndpoint, {
|
|
38
|
-
display: '
|
|
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
|
-
|
|
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) {
|
|
@@ -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');
|
package/package.json
CHANGED
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)
|