@instructure/canvas-rce 5.9.0 → 5.10.0
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/.mocharc.js +7 -0
- package/CHANGELOG.md +11 -0
- package/es/enhance-user-content/mathml.js +8 -5
- package/es/rce/RCEWrapper.js +32 -13
- package/es/rce/plugins/instructure_equation/EquationEditorModal/parseLatex.js +0 -2
- package/es/rce/plugins/instructure_rce_external_tools/components/ExternalToolDialog/ExternalToolDialogModal.js +4 -5
- package/es/rce/plugins/shared/CanvasContentTray.js +8 -8
- package/es/rce/plugins/shared/ContentSelection.js +7 -3
- package/es/rce/plugins/shared/ImageCropper/Preview.js +8 -7
- package/es/rce/plugins/shared/LinkDisplay.js +2 -2
- package/es/rce/plugins/tinymce-a11y-checker/rules/large-text-contrast.js +9 -0
- package/es/rce/plugins/tinymce-a11y-checker/rules/small-text-contrast.js +9 -0
- package/es/translations/locales/de.js +4 -4
- package/jest/jest-setup.js +0 -1
- package/lib/enhance-user-content/mathml.js +8 -5
- package/lib/rce/RCEWrapper.js +32 -13
- package/lib/rce/plugins/instructure_equation/EquationEditorModal/parseLatex.js +0 -2
- package/lib/rce/plugins/instructure_rce_external_tools/components/ExternalToolDialog/ExternalToolDialogModal.js +4 -5
- package/lib/rce/plugins/shared/CanvasContentTray.js +8 -8
- package/lib/rce/plugins/shared/ContentSelection.js +7 -3
- package/lib/rce/plugins/shared/ImageCropper/Preview.js +8 -7
- package/lib/rce/plugins/shared/LinkDisplay.js +2 -2
- package/lib/rce/plugins/tinymce-a11y-checker/rules/large-text-contrast.js +9 -0
- package/lib/rce/plugins/tinymce-a11y-checker/rules/small-text-contrast.js +9 -0
- package/lib/translations/locales/de.js +4 -4
- package/package.json +4 -4
- package/es/rce/getBrowser.js +0 -53
- package/lib/rce/getBrowser.js +0 -53
package/.mocharc.js
CHANGED
|
@@ -15,6 +15,13 @@
|
|
|
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
|
+
|
|
19
|
+
global.MutationObserver = class {
|
|
20
|
+
disconnect() {}
|
|
21
|
+
|
|
22
|
+
observe() {}
|
|
23
|
+
}
|
|
24
|
+
|
|
18
25
|
module.exports = {
|
|
19
26
|
require: [
|
|
20
27
|
'@instructure/canvas-theme',
|
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,17 @@ 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.0 - 2023-09-26
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- An issue where media controls don't respond in Safari
|
|
12
|
+
- An issue where embedded Studio videos cause unresponsiveness
|
|
13
|
+
- A potential race condition in postMessage forwarding
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- Ignore a11y check on elements with a background image or gradient
|
|
17
|
+
- Remove math processing percentage indicator
|
|
18
|
+
|
|
8
19
|
## 5.9.0 - 2023-08-30
|
|
9
20
|
|
|
10
21
|
### Fixed
|
|
@@ -45,7 +45,8 @@ const localConfig = {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
-
showMathMenu: true
|
|
48
|
+
showMathMenu: true,
|
|
49
|
+
messageStyle: 'none'
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
class Mathml {
|
|
@@ -106,7 +107,7 @@ class Mathml {
|
|
|
106
107
|
window.MathJax.Hub.Register.MessageHook('Math Processing Error', function (message) {
|
|
107
108
|
var _elem$parentElement;
|
|
108
109
|
|
|
109
|
-
const elem = message[1]; // ".math_equation_latex" is the elem we added for MathJax to typeset the image equation
|
|
110
|
+
const elem = Array.isArray(message[1]) ? message[1][0] : message[1]; // ".math_equation_latex" is the elem we added for MathJax to typeset the image equation
|
|
110
111
|
|
|
111
112
|
if ((_elem$parentElement = elem.parentElement) !== null && _elem$parentElement !== void 0 && _elem$parentElement.classList.contains('math_equation_latex')) {
|
|
112
113
|
var _elem$parentElement$p;
|
|
@@ -123,7 +124,7 @@ class Mathml {
|
|
|
123
124
|
}
|
|
124
125
|
});
|
|
125
126
|
window.MathJax.Hub.Register.MessageHook('End Math', function (message) {
|
|
126
|
-
const elem = message[1];
|
|
127
|
+
const elem = Array.isArray(message[1]) ? message[1][0] : message[1];
|
|
127
128
|
mathImageHelper.removeStrayEquationImages(elem);
|
|
128
129
|
mathImageHelper.nearlyInfiniteStyleFix(elem);
|
|
129
130
|
elem.querySelectorAll('.math_equation_latex').forEach(m => m.classList.add('fade-in-equation'));
|
|
@@ -138,7 +139,8 @@ class Mathml {
|
|
|
138
139
|
// Since we want to ignore <math> in .hidden-readable spans, let's remove the MathJunk™
|
|
139
140
|
// right after MathJax adds it.
|
|
140
141
|
window.MathJax.Hub.Register.MessageHook('End Math', function (message) {
|
|
141
|
-
|
|
142
|
+
const elm = Array.isArray(message[1]) ? message[1][0] : message[1];
|
|
143
|
+
$(elm).find('.hidden-readable [class^="MathJax"], .hidden-readable [id^="MathJax"]').remove();
|
|
142
144
|
});
|
|
143
145
|
} // leaving this here so I don't have to keep looking up how to see all messages
|
|
144
146
|
// window.MathJax.Hub.Startup.signal.Interest(function (message) {
|
|
@@ -315,7 +317,8 @@ const mathImageHelper = {
|
|
|
315
317
|
},
|
|
316
318
|
|
|
317
319
|
catchEquationImages(refnode) {
|
|
318
|
-
// find equation images and replace with inline LaTeX
|
|
320
|
+
refnode = Array.isArray(refnode) ? refnode[0] : refnode; // find equation images and replace with inline LaTeX
|
|
321
|
+
|
|
319
322
|
const eqimgs = refnode.querySelectorAll('img.equation_image');
|
|
320
323
|
|
|
321
324
|
if (eqimgs.length > 0) {
|
package/es/rce/RCEWrapper.js
CHANGED
|
@@ -2719,7 +2719,7 @@ class RCEWrapper extends React.Component {
|
|
|
2719
2719
|
};
|
|
2720
2720
|
|
|
2721
2721
|
this.forwardPostMessages = () => {
|
|
2722
|
-
const windowReferences =
|
|
2722
|
+
const windowReferences = [];
|
|
2723
2723
|
const rceWindow = this.editor.getWin(); // explicitly assign name for reference by parent window
|
|
2724
2724
|
|
|
2725
2725
|
rceWindow.name = `${RCEWrapper.editorFrameName}_${this.id}`;
|
|
@@ -2734,25 +2734,44 @@ class RCEWrapper extends React.Component {
|
|
|
2734
2734
|
} catch (err) {
|
|
2735
2735
|
// unparseable message may not be meant for our handlers
|
|
2736
2736
|
return false;
|
|
2737
|
-
}
|
|
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
|
|
2738
2740
|
|
|
2739
|
-
if (e.origin === rceWindow.origin) {
|
|
2740
|
-
// message is from Canvas window, forward to tool
|
|
2741
|
-
const targetOrigin = message.toolOrigin;
|
|
2742
2741
|
|
|
2743
|
-
|
|
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) {
|
|
2744
2751
|
return false;
|
|
2745
2752
|
}
|
|
2746
2753
|
|
|
2747
|
-
|
|
2748
|
-
delete message.toolOrigin;
|
|
2749
|
-
targetWindow === null || targetWindow === void 0 ? void 0 : targetWindow.postMessage(message, targetOrigin);
|
|
2754
|
+
targetWindow === null || targetWindow === void 0 ? void 0 : targetWindow.postMessage(messageWithoutSourceToolInfo, targetOrigin);
|
|
2750
2755
|
} else {
|
|
2751
2756
|
// message is from tool, forward to Canvas window
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
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);
|
|
2756
2775
|
}
|
|
2757
2776
|
};
|
|
2758
2777
|
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
20
|
import React from 'react';
|
|
21
|
-
import { Flex } from '@instructure/ui-flex';
|
|
22
21
|
import { Heading } from '@instructure/ui-heading';
|
|
23
22
|
import { CloseButton } from '@instructure/ui-buttons';
|
|
24
23
|
import { View } from '@instructure/ui-view';
|
|
@@ -33,12 +32,12 @@ export function ExternalToolDialogModal(props) {
|
|
|
33
32
|
onOpen: props.onOpen,
|
|
34
33
|
onClose: props.onClose,
|
|
35
34
|
mountNode: props.mountNode
|
|
36
|
-
}, /*#__PURE__*/React.createElement(Modal.Header, null, /*#__PURE__*/React.createElement(
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
}, /*#__PURE__*/React.createElement(Modal.Header, null, /*#__PURE__*/React.createElement(Heading, null, props.name), /*#__PURE__*/React.createElement(CloseButton, {
|
|
36
|
+
placement: "end",
|
|
37
|
+
offset: "medium",
|
|
39
38
|
onClick: props.onCloseButton,
|
|
40
39
|
screenReaderLabel: formatMessage('Close')
|
|
41
|
-
}))
|
|
40
|
+
})), /*#__PURE__*/React.createElement(Modal.Body, {
|
|
42
41
|
padding: "0"
|
|
43
42
|
}, /*#__PURE__*/React.createElement(View, {
|
|
44
43
|
as: "div",
|
|
@@ -22,6 +22,7 @@ import { CloseButton, Button } from '@instructure/ui-buttons';
|
|
|
22
22
|
import { Heading } from '@instructure/ui-heading';
|
|
23
23
|
import { Spinner } from '@instructure/ui-spinner';
|
|
24
24
|
import { Flex } from '@instructure/ui-flex';
|
|
25
|
+
import { View } from '@instructure/ui-view';
|
|
25
26
|
import ErrorBoundary from './ErrorBoundary';
|
|
26
27
|
import Bridge from '../../../bridge/Bridge';
|
|
27
28
|
import formatMessage from '../../../format-message';
|
|
@@ -463,19 +464,18 @@ export default function CanvasContentTray(props) {
|
|
|
463
464
|
}, /*#__PURE__*/React.createElement(Flex.Item, {
|
|
464
465
|
padding: "medium",
|
|
465
466
|
shadow: "above"
|
|
466
|
-
}, /*#__PURE__*/React.createElement(
|
|
467
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
468
|
+
as: "div",
|
|
467
469
|
margin: "none none medium none"
|
|
468
|
-
}, /*#__PURE__*/React.createElement(Flex.Item, {
|
|
469
|
-
shouldgrow: true,
|
|
470
|
-
shouldshrink: true
|
|
471
470
|
}, /*#__PURE__*/React.createElement(Heading, {
|
|
472
471
|
level: "h2"
|
|
473
|
-
}, getHeader())
|
|
472
|
+
}, getHeader()), /*#__PURE__*/React.createElement(CloseButton, {
|
|
474
473
|
placement: "end",
|
|
474
|
+
offset: "medium",
|
|
475
475
|
onClick: handleDismissTray,
|
|
476
476
|
"data-testid": "CloseButton_ContentTray",
|
|
477
477
|
screenReaderLabel: formatMessage('Close')
|
|
478
|
-
}))
|
|
478
|
+
})), isEditTray && /*#__PURE__*/React.createElement(LinkDisplay, {
|
|
479
479
|
linkText: linkText,
|
|
480
480
|
placeholderText: (link === null || link === void 0 ? void 0 : link.title) || placeholderText,
|
|
481
481
|
linkFileName: (link === null || link === void 0 ? void 0 : link.title) || '',
|
|
@@ -492,8 +492,8 @@ export default function CanvasContentTray(props) {
|
|
|
492
492
|
isContentLoading: isLoading(storeProps),
|
|
493
493
|
use_rce_icon_maker: props.use_rce_icon_maker
|
|
494
494
|
}))), /*#__PURE__*/React.createElement(Flex.Item, {
|
|
495
|
-
|
|
496
|
-
|
|
495
|
+
shouldGrow: true,
|
|
496
|
+
shouldShrink: true,
|
|
497
497
|
margin: "xx-small xxx-small 0",
|
|
498
498
|
elementRef: el => scrollingAreaRef.current = el
|
|
499
499
|
}, /*#__PURE__*/React.createElement(Flex, {
|
|
@@ -32,7 +32,7 @@ export const DISPLAY_AS_EMBED = 'embed';
|
|
|
32
32
|
export const DISPLAY_AS_EMBED_DISABLED = 'embed-disabled';
|
|
33
33
|
export const DISPLAY_AS_DOWNLOAD_LINK = 'download-link';
|
|
34
34
|
export function asImageEmbed($element) {
|
|
35
|
-
const nodeName = $element.nodeName.toLowerCase();
|
|
35
|
+
const nodeName = $element === null || $element === void 0 ? void 0 : $element.nodeName.toLowerCase();
|
|
36
36
|
|
|
37
37
|
if (nodeName !== 'img') {
|
|
38
38
|
return null;
|
|
@@ -44,9 +44,11 @@ export function asImageEmbed($element) {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
export function asLink($element, editor) {
|
|
47
|
+
var _$link;
|
|
48
|
+
|
|
47
49
|
let $link = $element;
|
|
48
50
|
|
|
49
|
-
if ($link.tagName !== 'A') {
|
|
51
|
+
if (((_$link = $link) === null || _$link === void 0 ? void 0 : _$link.tagName) !== 'A') {
|
|
50
52
|
// the user may have selected some text that is w/in a link
|
|
51
53
|
// but didn't include the <a>. Let's see if that's true
|
|
52
54
|
$link = editor.dom.getParent($link, 'a[href]');
|
|
@@ -213,7 +215,7 @@ function isMediaElement($element, mediaType) {
|
|
|
213
215
|
|
|
214
216
|
// the video is hosted in an iframe, but tinymce
|
|
215
217
|
// wraps it in a span with swizzled attribute names
|
|
216
|
-
if (!($element !== null && $element !== void 0 && $element.getAttribute)) {
|
|
218
|
+
if (!($element !== null && $element !== void 0 && $element.getAttribute) || !$element) {
|
|
217
219
|
return false;
|
|
218
220
|
}
|
|
219
221
|
|
|
@@ -242,6 +244,8 @@ export function isAudioElement($element) {
|
|
|
242
244
|
export function findMediaPlayerIframe(elem) {
|
|
243
245
|
var _elem$firstElementChi;
|
|
244
246
|
|
|
247
|
+
if (!elem) return null;
|
|
248
|
+
|
|
245
249
|
if (elem.tagName === 'IFRAME') {
|
|
246
250
|
// we have the iframe
|
|
247
251
|
return elem;
|
|
@@ -25,7 +25,6 @@ import { useMouseWheel } from './useMouseWheel';
|
|
|
25
25
|
import { useKeyMouseTouchEvents } from './useKeyMouseEvents';
|
|
26
26
|
import checkerboardStyle from '../CheckerboardStyling';
|
|
27
27
|
import { View } from '@instructure/ui-view';
|
|
28
|
-
import { getBrowser } from '../../../getBrowser';
|
|
29
28
|
/**
|
|
30
29
|
* Remove the node contents and append the svg element.
|
|
31
30
|
*/
|
|
@@ -86,17 +85,19 @@ export const Preview = _ref2 => {
|
|
|
86
85
|
translateY: tempTranslateY,
|
|
87
86
|
rotation,
|
|
88
87
|
scaleRatio: tempScaleRatio
|
|
89
|
-
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
function isSafariVersion15OrLesser() {
|
|
91
|
+
const match = /Version\/(\d+).+Safari/.exec(navigator.userAgent);
|
|
92
|
+
return match ? parseInt(match[1], 10) < 16 : false;
|
|
93
|
+
} // Clip is not supported in Safari until v16.
|
|
90
94
|
// It's needed here to prevent a strange screenreader
|
|
91
95
|
// behavior that makes the cropper look bad. 'hidden'
|
|
92
96
|
// suffices when clip is not available, although it's not perfect
|
|
93
97
|
// TODO: remove when Safari versions >= 16 are more commonplace
|
|
94
98
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
version
|
|
98
|
-
} = getBrowser();
|
|
99
|
-
const overflow = name === 'Safari' && parseFloat(version) < 16 ? 'hidden' : 'clip';
|
|
99
|
+
|
|
100
|
+
const overflow = isSafariVersion15OrLesser() ? 'hidden' : 'clip';
|
|
100
101
|
return /*#__PURE__*/React.createElement("div", {
|
|
101
102
|
style: {
|
|
102
103
|
justifyContent: 'center',
|
|
@@ -81,8 +81,8 @@ export const LinkDisplay = _ref => {
|
|
|
81
81
|
size: "x-small"
|
|
82
82
|
}))), /*#__PURE__*/React.createElement(Flex.Item, {
|
|
83
83
|
padding: "0 x-small 0 0",
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
shouldGrow: true,
|
|
85
|
+
shouldShrink: true,
|
|
86
86
|
textAlign: "start"
|
|
87
87
|
}, /*#__PURE__*/React.createElement(View, {
|
|
88
88
|
as: "div"
|
|
@@ -30,6 +30,15 @@ export default {
|
|
|
30
30
|
return true;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
for (let e = elem; e; e = e.parentElement) {
|
|
34
|
+
const bgimage = window.getComputedStyle(e).getPropertyValue('background-image');
|
|
35
|
+
|
|
36
|
+
if (bgimage !== 'none' && bgimage !== '') {
|
|
37
|
+
// ignore background images and gradients
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
33
42
|
return contrast(elem);
|
|
34
43
|
},
|
|
35
44
|
data: smallTextContrast.data,
|
|
@@ -32,6 +32,15 @@ export default {
|
|
|
32
32
|
return true;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
for (let e = elem; e; e = e.parentElement) {
|
|
36
|
+
const bgimage = window.getComputedStyle(e).getPropertyValue('background-image');
|
|
37
|
+
|
|
38
|
+
if (bgimage !== 'none' && bgimage !== '') {
|
|
39
|
+
// ignore background images and gradients
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
35
44
|
return contrast(elem);
|
|
36
45
|
},
|
|
37
46
|
data: elem => {
|
|
@@ -373,7 +373,7 @@ const locale = {
|
|
|
373
373
|
"message": "{ count, plural,\n one {# Objekt geladen}\n other {# Objekte geladen}\n}"
|
|
374
374
|
},
|
|
375
375
|
"course_documents_104d76e0": {
|
|
376
|
-
"message": "
|
|
376
|
+
"message": "Kursdokumente"
|
|
377
377
|
},
|
|
378
378
|
"course_files_62deb8f8": {
|
|
379
379
|
"message": "Kursdateien"
|
|
@@ -2278,16 +2278,16 @@ const locale = {
|
|
|
2278
2278
|
"message": "Wird von Screenreadern verwendet, um das Video zu beschreiben."
|
|
2279
2279
|
},
|
|
2280
2280
|
"user_documents_c206e61f": {
|
|
2281
|
-
"message": "
|
|
2281
|
+
"message": "Meine Dokumente"
|
|
2282
2282
|
},
|
|
2283
2283
|
"user_files_78e21703": {
|
|
2284
2284
|
"message": "Benutzerdateien"
|
|
2285
2285
|
},
|
|
2286
2286
|
"user_images_b6490852": {
|
|
2287
|
-
"message": "
|
|
2287
|
+
"message": "Meine Bilder"
|
|
2288
2288
|
},
|
|
2289
2289
|
"user_media_14fbf656": {
|
|
2290
|
-
"message": "
|
|
2290
|
+
"message": "Meine Medien"
|
|
2291
2291
|
},
|
|
2292
2292
|
"vector_notation_cf6086ab": {
|
|
2293
2293
|
"message": "Vektor (Notation)"
|
package/jest/jest-setup.js
CHANGED
|
@@ -41,7 +41,6 @@ const ignoredErrors = [
|
|
|
41
41
|
/The prop `videoOptions.naturalHeight` is marked as required in `VideoOptionsTray`/,
|
|
42
42
|
/The prop `sortBy.order` is marked as required in `MediaPanel`/,
|
|
43
43
|
/Invalid prop `images.searchString` of type `string` supplied to `Images`/,
|
|
44
|
-
/Invalid URL: undefined/,
|
|
45
44
|
/failed updating video captions/,
|
|
46
45
|
/You seem to have overlapping act\(\) calls/,
|
|
47
46
|
/A theme registry has already been initialized/,
|
|
@@ -45,7 +45,8 @@ const localConfig = {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
-
showMathMenu: true
|
|
48
|
+
showMathMenu: true,
|
|
49
|
+
messageStyle: 'none'
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
class Mathml {
|
|
@@ -106,7 +107,7 @@ class Mathml {
|
|
|
106
107
|
window.MathJax.Hub.Register.MessageHook('Math Processing Error', function (message) {
|
|
107
108
|
var _elem$parentElement;
|
|
108
109
|
|
|
109
|
-
const elem = message[1]; // ".math_equation_latex" is the elem we added for MathJax to typeset the image equation
|
|
110
|
+
const elem = Array.isArray(message[1]) ? message[1][0] : message[1]; // ".math_equation_latex" is the elem we added for MathJax to typeset the image equation
|
|
110
111
|
|
|
111
112
|
if ((_elem$parentElement = elem.parentElement) !== null && _elem$parentElement !== void 0 && _elem$parentElement.classList.contains('math_equation_latex')) {
|
|
112
113
|
var _elem$parentElement$p;
|
|
@@ -123,7 +124,7 @@ class Mathml {
|
|
|
123
124
|
}
|
|
124
125
|
});
|
|
125
126
|
window.MathJax.Hub.Register.MessageHook('End Math', function (message) {
|
|
126
|
-
const elem = message[1];
|
|
127
|
+
const elem = Array.isArray(message[1]) ? message[1][0] : message[1];
|
|
127
128
|
mathImageHelper.removeStrayEquationImages(elem);
|
|
128
129
|
mathImageHelper.nearlyInfiniteStyleFix(elem);
|
|
129
130
|
elem.querySelectorAll('.math_equation_latex').forEach(m => m.classList.add('fade-in-equation'));
|
|
@@ -138,7 +139,8 @@ class Mathml {
|
|
|
138
139
|
// Since we want to ignore <math> in .hidden-readable spans, let's remove the MathJunk™
|
|
139
140
|
// right after MathJax adds it.
|
|
140
141
|
window.MathJax.Hub.Register.MessageHook('End Math', function (message) {
|
|
141
|
-
|
|
142
|
+
const elm = Array.isArray(message[1]) ? message[1][0] : message[1];
|
|
143
|
+
$(elm).find('.hidden-readable [class^="MathJax"], .hidden-readable [id^="MathJax"]').remove();
|
|
142
144
|
});
|
|
143
145
|
} // leaving this here so I don't have to keep looking up how to see all messages
|
|
144
146
|
// window.MathJax.Hub.Startup.signal.Interest(function (message) {
|
|
@@ -315,7 +317,8 @@ const mathImageHelper = {
|
|
|
315
317
|
},
|
|
316
318
|
|
|
317
319
|
catchEquationImages(refnode) {
|
|
318
|
-
// find equation images and replace with inline LaTeX
|
|
320
|
+
refnode = Array.isArray(refnode) ? refnode[0] : refnode; // find equation images and replace with inline LaTeX
|
|
321
|
+
|
|
319
322
|
const eqimgs = refnode.querySelectorAll('img.equation_image');
|
|
320
323
|
|
|
321
324
|
if (eqimgs.length > 0) {
|
package/lib/rce/RCEWrapper.js
CHANGED
|
@@ -2719,7 +2719,7 @@ class RCEWrapper extends React.Component {
|
|
|
2719
2719
|
};
|
|
2720
2720
|
|
|
2721
2721
|
this.forwardPostMessages = () => {
|
|
2722
|
-
const windowReferences =
|
|
2722
|
+
const windowReferences = [];
|
|
2723
2723
|
const rceWindow = this.editor.getWin(); // explicitly assign name for reference by parent window
|
|
2724
2724
|
|
|
2725
2725
|
rceWindow.name = `${RCEWrapper.editorFrameName}_${this.id}`;
|
|
@@ -2734,25 +2734,44 @@ class RCEWrapper extends React.Component {
|
|
|
2734
2734
|
} catch (err) {
|
|
2735
2735
|
// unparseable message may not be meant for our handlers
|
|
2736
2736
|
return false;
|
|
2737
|
-
}
|
|
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
|
|
2738
2740
|
|
|
2739
|
-
if (e.origin === rceWindow.origin) {
|
|
2740
|
-
// message is from Canvas window, forward to tool
|
|
2741
|
-
const targetOrigin = message.toolOrigin;
|
|
2742
2741
|
|
|
2743
|
-
|
|
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) {
|
|
2744
2751
|
return false;
|
|
2745
2752
|
}
|
|
2746
2753
|
|
|
2747
|
-
|
|
2748
|
-
delete message.toolOrigin;
|
|
2749
|
-
targetWindow === null || targetWindow === void 0 ? void 0 : targetWindow.postMessage(message, targetOrigin);
|
|
2754
|
+
targetWindow === null || targetWindow === void 0 ? void 0 : targetWindow.postMessage(messageWithoutSourceToolInfo, targetOrigin);
|
|
2750
2755
|
} else {
|
|
2751
2756
|
// message is from tool, forward to Canvas window
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
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);
|
|
2756
2775
|
}
|
|
2757
2776
|
};
|
|
2758
2777
|
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
20
|
import React from 'react';
|
|
21
|
-
import { Flex } from '@instructure/ui-flex';
|
|
22
21
|
import { Heading } from '@instructure/ui-heading';
|
|
23
22
|
import { CloseButton } from '@instructure/ui-buttons';
|
|
24
23
|
import { View } from '@instructure/ui-view';
|
|
@@ -33,12 +32,12 @@ export function ExternalToolDialogModal(props) {
|
|
|
33
32
|
onOpen: props.onOpen,
|
|
34
33
|
onClose: props.onClose,
|
|
35
34
|
mountNode: props.mountNode
|
|
36
|
-
}, /*#__PURE__*/React.createElement(Modal.Header, null, /*#__PURE__*/React.createElement(
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
}, /*#__PURE__*/React.createElement(Modal.Header, null, /*#__PURE__*/React.createElement(Heading, null, props.name), /*#__PURE__*/React.createElement(CloseButton, {
|
|
36
|
+
placement: "end",
|
|
37
|
+
offset: "medium",
|
|
39
38
|
onClick: props.onCloseButton,
|
|
40
39
|
screenReaderLabel: formatMessage('Close')
|
|
41
|
-
}))
|
|
40
|
+
})), /*#__PURE__*/React.createElement(Modal.Body, {
|
|
42
41
|
padding: "0"
|
|
43
42
|
}, /*#__PURE__*/React.createElement(View, {
|
|
44
43
|
as: "div",
|
|
@@ -22,6 +22,7 @@ import { CloseButton, Button } from '@instructure/ui-buttons';
|
|
|
22
22
|
import { Heading } from '@instructure/ui-heading';
|
|
23
23
|
import { Spinner } from '@instructure/ui-spinner';
|
|
24
24
|
import { Flex } from '@instructure/ui-flex';
|
|
25
|
+
import { View } from '@instructure/ui-view';
|
|
25
26
|
import ErrorBoundary from './ErrorBoundary';
|
|
26
27
|
import Bridge from '../../../bridge/Bridge';
|
|
27
28
|
import formatMessage from '../../../format-message';
|
|
@@ -463,19 +464,18 @@ export default function CanvasContentTray(props) {
|
|
|
463
464
|
}, /*#__PURE__*/React.createElement(Flex.Item, {
|
|
464
465
|
padding: "medium",
|
|
465
466
|
shadow: "above"
|
|
466
|
-
}, /*#__PURE__*/React.createElement(
|
|
467
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
468
|
+
as: "div",
|
|
467
469
|
margin: "none none medium none"
|
|
468
|
-
}, /*#__PURE__*/React.createElement(Flex.Item, {
|
|
469
|
-
shouldgrow: true,
|
|
470
|
-
shouldshrink: true
|
|
471
470
|
}, /*#__PURE__*/React.createElement(Heading, {
|
|
472
471
|
level: "h2"
|
|
473
|
-
}, getHeader())
|
|
472
|
+
}, getHeader()), /*#__PURE__*/React.createElement(CloseButton, {
|
|
474
473
|
placement: "end",
|
|
474
|
+
offset: "medium",
|
|
475
475
|
onClick: handleDismissTray,
|
|
476
476
|
"data-testid": "CloseButton_ContentTray",
|
|
477
477
|
screenReaderLabel: formatMessage('Close')
|
|
478
|
-
}))
|
|
478
|
+
})), isEditTray && /*#__PURE__*/React.createElement(LinkDisplay, {
|
|
479
479
|
linkText: linkText,
|
|
480
480
|
placeholderText: (link === null || link === void 0 ? void 0 : link.title) || placeholderText,
|
|
481
481
|
linkFileName: (link === null || link === void 0 ? void 0 : link.title) || '',
|
|
@@ -492,8 +492,8 @@ export default function CanvasContentTray(props) {
|
|
|
492
492
|
isContentLoading: isLoading(storeProps),
|
|
493
493
|
use_rce_icon_maker: props.use_rce_icon_maker
|
|
494
494
|
}))), /*#__PURE__*/React.createElement(Flex.Item, {
|
|
495
|
-
|
|
496
|
-
|
|
495
|
+
shouldGrow: true,
|
|
496
|
+
shouldShrink: true,
|
|
497
497
|
margin: "xx-small xxx-small 0",
|
|
498
498
|
elementRef: el => scrollingAreaRef.current = el
|
|
499
499
|
}, /*#__PURE__*/React.createElement(Flex, {
|
|
@@ -32,7 +32,7 @@ export const DISPLAY_AS_EMBED = 'embed';
|
|
|
32
32
|
export const DISPLAY_AS_EMBED_DISABLED = 'embed-disabled';
|
|
33
33
|
export const DISPLAY_AS_DOWNLOAD_LINK = 'download-link';
|
|
34
34
|
export function asImageEmbed($element) {
|
|
35
|
-
const nodeName = $element.nodeName.toLowerCase();
|
|
35
|
+
const nodeName = $element === null || $element === void 0 ? void 0 : $element.nodeName.toLowerCase();
|
|
36
36
|
|
|
37
37
|
if (nodeName !== 'img') {
|
|
38
38
|
return null;
|
|
@@ -44,9 +44,11 @@ export function asImageEmbed($element) {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
export function asLink($element, editor) {
|
|
47
|
+
var _$link;
|
|
48
|
+
|
|
47
49
|
let $link = $element;
|
|
48
50
|
|
|
49
|
-
if ($link.tagName !== 'A') {
|
|
51
|
+
if (((_$link = $link) === null || _$link === void 0 ? void 0 : _$link.tagName) !== 'A') {
|
|
50
52
|
// the user may have selected some text that is w/in a link
|
|
51
53
|
// but didn't include the <a>. Let's see if that's true
|
|
52
54
|
$link = editor.dom.getParent($link, 'a[href]');
|
|
@@ -213,7 +215,7 @@ function isMediaElement($element, mediaType) {
|
|
|
213
215
|
|
|
214
216
|
// the video is hosted in an iframe, but tinymce
|
|
215
217
|
// wraps it in a span with swizzled attribute names
|
|
216
|
-
if (!($element !== null && $element !== void 0 && $element.getAttribute)) {
|
|
218
|
+
if (!($element !== null && $element !== void 0 && $element.getAttribute) || !$element) {
|
|
217
219
|
return false;
|
|
218
220
|
}
|
|
219
221
|
|
|
@@ -242,6 +244,8 @@ export function isAudioElement($element) {
|
|
|
242
244
|
export function findMediaPlayerIframe(elem) {
|
|
243
245
|
var _elem$firstElementChi;
|
|
244
246
|
|
|
247
|
+
if (!elem) return null;
|
|
248
|
+
|
|
245
249
|
if (elem.tagName === 'IFRAME') {
|
|
246
250
|
// we have the iframe
|
|
247
251
|
return elem;
|
|
@@ -25,7 +25,6 @@ import { useMouseWheel } from './useMouseWheel';
|
|
|
25
25
|
import { useKeyMouseTouchEvents } from './useKeyMouseEvents';
|
|
26
26
|
import checkerboardStyle from '../CheckerboardStyling';
|
|
27
27
|
import { View } from '@instructure/ui-view';
|
|
28
|
-
import { getBrowser } from '../../../getBrowser';
|
|
29
28
|
/**
|
|
30
29
|
* Remove the node contents and append the svg element.
|
|
31
30
|
*/
|
|
@@ -86,17 +85,19 @@ export const Preview = _ref2 => {
|
|
|
86
85
|
translateY: tempTranslateY,
|
|
87
86
|
rotation,
|
|
88
87
|
scaleRatio: tempScaleRatio
|
|
89
|
-
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
function isSafariVersion15OrLesser() {
|
|
91
|
+
const match = /Version\/(\d+).+Safari/.exec(navigator.userAgent);
|
|
92
|
+
return match ? parseInt(match[1], 10) < 16 : false;
|
|
93
|
+
} // Clip is not supported in Safari until v16.
|
|
90
94
|
// It's needed here to prevent a strange screenreader
|
|
91
95
|
// behavior that makes the cropper look bad. 'hidden'
|
|
92
96
|
// suffices when clip is not available, although it's not perfect
|
|
93
97
|
// TODO: remove when Safari versions >= 16 are more commonplace
|
|
94
98
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
version
|
|
98
|
-
} = getBrowser();
|
|
99
|
-
const overflow = name === 'Safari' && parseFloat(version) < 16 ? 'hidden' : 'clip';
|
|
99
|
+
|
|
100
|
+
const overflow = isSafariVersion15OrLesser() ? 'hidden' : 'clip';
|
|
100
101
|
return /*#__PURE__*/React.createElement("div", {
|
|
101
102
|
style: {
|
|
102
103
|
justifyContent: 'center',
|
|
@@ -81,8 +81,8 @@ export const LinkDisplay = _ref => {
|
|
|
81
81
|
size: "x-small"
|
|
82
82
|
}))), /*#__PURE__*/React.createElement(Flex.Item, {
|
|
83
83
|
padding: "0 x-small 0 0",
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
shouldGrow: true,
|
|
85
|
+
shouldShrink: true,
|
|
86
86
|
textAlign: "start"
|
|
87
87
|
}, /*#__PURE__*/React.createElement(View, {
|
|
88
88
|
as: "div"
|
|
@@ -30,6 +30,15 @@ export default {
|
|
|
30
30
|
return true;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
for (let e = elem; e; e = e.parentElement) {
|
|
34
|
+
const bgimage = window.getComputedStyle(e).getPropertyValue('background-image');
|
|
35
|
+
|
|
36
|
+
if (bgimage !== 'none' && bgimage !== '') {
|
|
37
|
+
// ignore background images and gradients
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
33
42
|
return contrast(elem);
|
|
34
43
|
},
|
|
35
44
|
data: smallTextContrast.data,
|
|
@@ -32,6 +32,15 @@ export default {
|
|
|
32
32
|
return true;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
for (let e = elem; e; e = e.parentElement) {
|
|
36
|
+
const bgimage = window.getComputedStyle(e).getPropertyValue('background-image');
|
|
37
|
+
|
|
38
|
+
if (bgimage !== 'none' && bgimage !== '') {
|
|
39
|
+
// ignore background images and gradients
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
35
44
|
return contrast(elem);
|
|
36
45
|
},
|
|
37
46
|
data: elem => {
|
|
@@ -373,7 +373,7 @@ const locale = {
|
|
|
373
373
|
"message": "{ count, plural,\n one {# Objekt geladen}\n other {# Objekte geladen}\n}"
|
|
374
374
|
},
|
|
375
375
|
"course_documents_104d76e0": {
|
|
376
|
-
"message": "
|
|
376
|
+
"message": "Kursdokumente"
|
|
377
377
|
},
|
|
378
378
|
"course_files_62deb8f8": {
|
|
379
379
|
"message": "Kursdateien"
|
|
@@ -2278,16 +2278,16 @@ const locale = {
|
|
|
2278
2278
|
"message": "Wird von Screenreadern verwendet, um das Video zu beschreiben."
|
|
2279
2279
|
},
|
|
2280
2280
|
"user_documents_c206e61f": {
|
|
2281
|
-
"message": "
|
|
2281
|
+
"message": "Meine Dokumente"
|
|
2282
2282
|
},
|
|
2283
2283
|
"user_files_78e21703": {
|
|
2284
2284
|
"message": "Benutzerdateien"
|
|
2285
2285
|
},
|
|
2286
2286
|
"user_images_b6490852": {
|
|
2287
|
-
"message": "
|
|
2287
|
+
"message": "Meine Bilder"
|
|
2288
2288
|
},
|
|
2289
2289
|
"user_media_14fbf656": {
|
|
2290
|
-
"message": "
|
|
2290
|
+
"message": "Meine Medien"
|
|
2291
2291
|
},
|
|
2292
2292
|
"vector_notation_cf6086ab": {
|
|
2293
2293
|
"message": "Vektor (Notation)"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/canvas-rce",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.10.0",
|
|
4
4
|
"description": "A component wrapping Canvas's usage of Tinymce",
|
|
5
5
|
"main": "es/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"@instructure/debounce": "^7",
|
|
79
79
|
"@instructure/emotion": "^8.38.1",
|
|
80
80
|
"@instructure/k5uploader": "*",
|
|
81
|
-
"@instructure/media-capture": "
|
|
81
|
+
"@instructure/media-capture": "^9.0.0",
|
|
82
82
|
"@instructure/ui-a11y-content": "^7",
|
|
83
83
|
"@instructure/ui-a11y-utils": "^7",
|
|
84
84
|
"@instructure/ui-alerts": "^7",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"@instructure/ui-img": "^7",
|
|
100
100
|
"@instructure/ui-link": "^7",
|
|
101
101
|
"@instructure/ui-list": "^7",
|
|
102
|
-
"@instructure/ui-media-player": "
|
|
102
|
+
"@instructure/ui-media-player": "^9.0.0",
|
|
103
103
|
"@instructure/ui-menu": "^7",
|
|
104
104
|
"@instructure/ui-modal": "^7",
|
|
105
105
|
"@instructure/ui-motion": "^7",
|
|
@@ -215,7 +215,7 @@
|
|
|
215
215
|
"testcafe-browser-provider-selenium": "^1.2.0",
|
|
216
216
|
"testcafe-react-selectors": "^3.3.0",
|
|
217
217
|
"ts-node": "^10.9.1",
|
|
218
|
-
"typescript": "^5.
|
|
218
|
+
"typescript": "^5.2.2",
|
|
219
219
|
"url-loader": "^4.1.1",
|
|
220
220
|
"webpack": "^5",
|
|
221
221
|
"webpack-merge": "^5",
|
package/es/rce/getBrowser.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (C) 2022 - present Instructure, Inc.
|
|
3
|
-
*
|
|
4
|
-
* This file is part of Canvas.
|
|
5
|
-
*
|
|
6
|
-
* Canvas is free software: you can redistribute it and/or modify it under
|
|
7
|
-
* the terms of the GNU Affero General Public License as published by the Free
|
|
8
|
-
* Software Foundation, version 3 of the License.
|
|
9
|
-
*
|
|
10
|
-
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
11
|
-
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
12
|
-
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
13
|
-
* details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU Affero General Public License along
|
|
16
|
-
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
|
-
// From packages/parse-browser-info/index.js
|
|
19
|
-
export function getBrowser() {
|
|
20
|
-
const ua = navigator.userAgent;
|
|
21
|
-
let tem;
|
|
22
|
-
let M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
|
|
23
|
-
|
|
24
|
-
if (/trident/i.test(M[1])) {
|
|
25
|
-
tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
|
|
26
|
-
return {
|
|
27
|
-
name: 'IE',
|
|
28
|
-
version: tem[1] || ''
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (M[1] === 'Chrome') {
|
|
33
|
-
tem = ua.match(/\bOPR|Edge\/(\d+)/);
|
|
34
|
-
|
|
35
|
-
if (tem != null) {
|
|
36
|
-
return {
|
|
37
|
-
name: 'Opera',
|
|
38
|
-
version: tem[1]
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
|
|
44
|
-
|
|
45
|
-
if ((tem = ua.match(/version\/(\d+)/i)) != null) {
|
|
46
|
-
M.splice(1, 1, tem[1]);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
name: M[0],
|
|
51
|
-
version: M[1]
|
|
52
|
-
};
|
|
53
|
-
}
|
package/lib/rce/getBrowser.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (C) 2022 - present Instructure, Inc.
|
|
3
|
-
*
|
|
4
|
-
* This file is part of Canvas.
|
|
5
|
-
*
|
|
6
|
-
* Canvas is free software: you can redistribute it and/or modify it under
|
|
7
|
-
* the terms of the GNU Affero General Public License as published by the Free
|
|
8
|
-
* Software Foundation, version 3 of the License.
|
|
9
|
-
*
|
|
10
|
-
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
11
|
-
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
12
|
-
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
13
|
-
* details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU Affero General Public License along
|
|
16
|
-
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
|
-
// From packages/parse-browser-info/index.js
|
|
19
|
-
export function getBrowser() {
|
|
20
|
-
const ua = navigator.userAgent;
|
|
21
|
-
let tem;
|
|
22
|
-
let M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
|
|
23
|
-
|
|
24
|
-
if (/trident/i.test(M[1])) {
|
|
25
|
-
tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
|
|
26
|
-
return {
|
|
27
|
-
name: 'IE',
|
|
28
|
-
version: tem[1] || ''
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (M[1] === 'Chrome') {
|
|
33
|
-
tem = ua.match(/\bOPR|Edge\/(\d+)/);
|
|
34
|
-
|
|
35
|
-
if (tem != null) {
|
|
36
|
-
return {
|
|
37
|
-
name: 'Opera',
|
|
38
|
-
version: tem[1]
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
|
|
44
|
-
|
|
45
|
-
if ((tem = ua.match(/version\/(\d+)/i)) != null) {
|
|
46
|
-
M.splice(1, 1, tem[1]);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
name: M[0],
|
|
51
|
-
version: M[1]
|
|
52
|
-
};
|
|
53
|
-
}
|