@brightspace-ui/core 2.28.4 → 2.29.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/components/link/link.js +2 -4
- package/components/menu/menu.js +5 -3
- package/helpers/mathjax.js +18 -118
- package/package.json +1 -1
package/components/link/link.js
CHANGED
|
@@ -2,7 +2,6 @@ import '../colors/colors.js';
|
|
|
2
2
|
import { css, html, LitElement } from 'lit';
|
|
3
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
4
4
|
import { FocusMixin } from '../../mixins/focus-mixin.js';
|
|
5
|
-
import { FocusVisiblePolyfillMixin } from '../../mixins/focus-visible-polyfill-mixin.js';
|
|
6
5
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
7
6
|
|
|
8
7
|
export const linkStyles = css`
|
|
@@ -16,8 +15,7 @@ export const linkStyles = css`
|
|
|
16
15
|
bottom: 0.2rem;
|
|
17
16
|
top: 0.2rem;
|
|
18
17
|
}
|
|
19
|
-
.d2l-link:hover,
|
|
20
|
-
.d2l-link.focus-visible {
|
|
18
|
+
.d2l-link:hover, .d2l-link:focus {
|
|
21
19
|
color: var(--d2l-color-celestine-minus-1);
|
|
22
20
|
text-decoration: underline;
|
|
23
21
|
}
|
|
@@ -44,7 +42,7 @@ export const linkStyles = css`
|
|
|
44
42
|
* This component can be used just like the native anchor tag.
|
|
45
43
|
* @slot - The content (e.g., text) that when selected causes navigation
|
|
46
44
|
*/
|
|
47
|
-
class Link extends FocusMixin(
|
|
45
|
+
class Link extends FocusMixin(LitElement) {
|
|
48
46
|
|
|
49
47
|
static get properties() {
|
|
50
48
|
return {
|
package/components/menu/menu.js
CHANGED
|
@@ -224,7 +224,7 @@ class Menu extends FocusVisiblePolyfillMixin(ThemeMixin(HierarchicalViewMixin(Li
|
|
|
224
224
|
return this.shadowRoot && this.shadowRoot.querySelector('d2l-menu-item-return');
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
_getMenuItems() {
|
|
227
|
+
async _getMenuItems() {
|
|
228
228
|
const slot = this.shadowRoot && this.shadowRoot.querySelector('slot');
|
|
229
229
|
if (!slot) return;
|
|
230
230
|
const items = slot.assignedNodes({ flatten: true }).filter((node) => node.nodeType === Node.ELEMENT_NODE);
|
|
@@ -233,6 +233,8 @@ class Menu extends FocusVisiblePolyfillMixin(ThemeMixin(HierarchicalViewMixin(Li
|
|
|
233
233
|
if (returnItem) {
|
|
234
234
|
items.unshift(returnItem);
|
|
235
235
|
}
|
|
236
|
+
// Wait for menu items to have their role attribute set
|
|
237
|
+
await Promise.all(items.map(item => item.updateComplete));
|
|
236
238
|
return items.filter((item) => {
|
|
237
239
|
const role = item.getAttribute('role');
|
|
238
240
|
return (role === 'menuitem' || role === 'menuitemcheckbox' || role === 'menuitemradio' || item.tagName === 'D2L-MENU-ITEM-RETURN');
|
|
@@ -328,8 +330,8 @@ class Menu extends FocusVisiblePolyfillMixin(ThemeMixin(HierarchicalViewMixin(Li
|
|
|
328
330
|
}
|
|
329
331
|
|
|
330
332
|
_onMenuItemsChanged() {
|
|
331
|
-
requestAnimationFrame(() => {
|
|
332
|
-
this._items = this._getMenuItems();
|
|
333
|
+
requestAnimationFrame(async() => {
|
|
334
|
+
this._items = await this._getMenuItems();
|
|
333
335
|
this._updateItemAttributes();
|
|
334
336
|
});
|
|
335
337
|
}
|
package/helpers/mathjax.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const mathjaxContextAttribute = 'data-mathjax-context';
|
|
7
|
-
const mathjaxBaseUrl = 'https://s.brightspace.com/lib/mathjax/3.1
|
|
7
|
+
const mathjaxBaseUrl = 'https://s.brightspace.com/lib/mathjax/3.2.1';
|
|
8
8
|
|
|
9
9
|
const mathjaxFontMappings = new Map([
|
|
10
10
|
['MJXTEX', 'MathJax_Main-Regular'],
|
|
@@ -50,7 +50,7 @@ export class HtmlBlockMathRenderer {
|
|
|
50
50
|
|
|
51
51
|
const mathJaxConfig = {
|
|
52
52
|
deferTypeset: true,
|
|
53
|
-
renderLatex: isLatexSupported,
|
|
53
|
+
renderLatex: isLatexSupported || false,
|
|
54
54
|
outputScale: context.outputScale || 1
|
|
55
55
|
};
|
|
56
56
|
|
|
@@ -60,32 +60,25 @@ export class HtmlBlockMathRenderer {
|
|
|
60
60
|
// This work-around should be removed when linebreaks are natively supported.
|
|
61
61
|
// MathJax issue: https://github.com/mathjax/MathJax/issues/2312
|
|
62
62
|
// A duplicate that explains our exact issue: https://github.com/mathjax/MathJax/issues/2495
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
elm.setAttribute('style', lineBreakStyle);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
await window.MathJax.startup.promise;
|
|
73
|
-
window.MathJax.typesetShadow(elem.getRootNode(), elem);
|
|
74
|
-
return elem;
|
|
75
|
-
}
|
|
63
|
+
elem.querySelectorAll('mspace[linebreak="newline"]').forEach(elm => {
|
|
64
|
+
elm.setAttribute('style', 'display: block; height: 0.5rem;');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
await window.MathJax.startup.promise;
|
|
68
|
+
await window.MathJax.typesetPromise([elem]);
|
|
76
69
|
|
|
77
|
-
|
|
70
|
+
// If we're opting out of deferred rendering, we can rely
|
|
71
|
+
// on the global MathJax styles for rendering.
|
|
72
|
+
if (options.noDeferredRendering) return elem;
|
|
78
73
|
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
temp.attachShadow({ mode: 'open' });
|
|
82
|
-
temp.shadowRoot.innerHTML = `<div><mjx-doc><mjx-head></mjx-head><mjx-body>${inner}</mjx-body></mjx-doc></div>`;
|
|
74
|
+
const styleElm = window.MathJax.chtmlStylesheet().cloneNode(true);
|
|
75
|
+
styleElm.id = 'd2l-mathjax-styles';
|
|
83
76
|
|
|
84
|
-
elem.
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
if (!elem.querySelector(`#${styleElm.id}`)) {
|
|
78
|
+
elem.appendChild(styleElm);
|
|
79
|
+
}
|
|
87
80
|
|
|
88
|
-
return
|
|
81
|
+
return elem;
|
|
89
82
|
}
|
|
90
83
|
|
|
91
84
|
}
|
|
@@ -101,6 +94,7 @@ export function loadMathJax(mathJaxConfig) {
|
|
|
101
94
|
|
|
102
95
|
window.MathJax = {
|
|
103
96
|
chtml: {
|
|
97
|
+
adaptiveCSS: false,
|
|
104
98
|
scale: (mathJaxConfig && mathJaxConfig.outputScale) || 1
|
|
105
99
|
},
|
|
106
100
|
options: {
|
|
@@ -110,100 +104,6 @@ export function loadMathJax(mathJaxConfig) {
|
|
|
110
104
|
},
|
|
111
105
|
loader: { load: loadOptions },
|
|
112
106
|
startup: {
|
|
113
|
-
ready: () => {
|
|
114
|
-
|
|
115
|
-
// Setup for using MathJax for typesetting math in shadowDOM
|
|
116
|
-
// https://github.com/mathjax/MathJax/issues/2195
|
|
117
|
-
|
|
118
|
-
//
|
|
119
|
-
// Get some MathJax objects from the MathJax global
|
|
120
|
-
//
|
|
121
|
-
// (Ideally, you would turn this into a custom component, and
|
|
122
|
-
// then these could be handled by normal imports, but this is
|
|
123
|
-
// just an example and so we use an expedient method of
|
|
124
|
-
// accessing these for now.)
|
|
125
|
-
//
|
|
126
|
-
const mathjax = window.MathJax._.mathjax.mathjax;
|
|
127
|
-
const HTMLAdaptor = window.MathJax._.adaptors.HTMLAdaptor.HTMLAdaptor;
|
|
128
|
-
const HTMLHandler = window.MathJax._.handlers.html.HTMLHandler.HTMLHandler;
|
|
129
|
-
const AbstractHandler = window.MathJax._.core.Handler.AbstractHandler.prototype;
|
|
130
|
-
const startup = window.MathJax.startup;
|
|
131
|
-
|
|
132
|
-
//
|
|
133
|
-
// Extend HTMLAdaptor to handle shadowDOM as the document
|
|
134
|
-
//
|
|
135
|
-
class ShadowAdaptor extends HTMLAdaptor {
|
|
136
|
-
body(doc) {
|
|
137
|
-
return doc.body || (doc.firstChild || {}).lastChild || doc;
|
|
138
|
-
}
|
|
139
|
-
create(kind, ns) {
|
|
140
|
-
const document = (this.document.createElement ? this.document : this.window.document);
|
|
141
|
-
return (ns ?
|
|
142
|
-
document.createElementNS(ns, kind) :
|
|
143
|
-
document.createElement(kind));
|
|
144
|
-
}
|
|
145
|
-
head(doc) {
|
|
146
|
-
return doc.head || (doc.firstChild || {}).firstChild || doc;
|
|
147
|
-
}
|
|
148
|
-
root(doc) {
|
|
149
|
-
return doc.documentElement || doc.firstChild || doc;
|
|
150
|
-
}
|
|
151
|
-
text(text) {
|
|
152
|
-
const document = (this.document.createTextNode ? this.document : this.window.document);
|
|
153
|
-
return document.createTextNode(text);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
//
|
|
158
|
-
// Extend HTMLHandler to handle shadowDOM as document
|
|
159
|
-
//
|
|
160
|
-
class ShadowHandler extends HTMLHandler {
|
|
161
|
-
create(document, options) {
|
|
162
|
-
const adaptor = this.adaptor;
|
|
163
|
-
if (typeof(document) === 'string') {
|
|
164
|
-
document = adaptor.parse(document, 'text/html');
|
|
165
|
-
} else if ((document instanceof adaptor.window.HTMLElement || document instanceof adaptor.window.DocumentFragment) && !(document instanceof window.ShadowRoot)) {
|
|
166
|
-
const child = document;
|
|
167
|
-
document = adaptor.parse('', 'text/html');
|
|
168
|
-
adaptor.append(adaptor.body(document), child);
|
|
169
|
-
}
|
|
170
|
-
//
|
|
171
|
-
// We can't use super.create() here, since that doesn't
|
|
172
|
-
// handle shadowDOM correctly, so call HTMLHandler's parent class
|
|
173
|
-
// directly instead.
|
|
174
|
-
//
|
|
175
|
-
return AbstractHandler.create.call(this, document, options);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
//
|
|
180
|
-
// Register the new handler and adaptor
|
|
181
|
-
//
|
|
182
|
-
startup.registerConstructor('HTMLHandler', ShadowHandler);
|
|
183
|
-
startup.registerConstructor('browserAdaptor', () => new ShadowAdaptor(window));
|
|
184
|
-
|
|
185
|
-
//
|
|
186
|
-
// A service function that creates a new MathDocument from the
|
|
187
|
-
// shadow root with the configured input and output jax, and then
|
|
188
|
-
// renders the document. The MathDocument is returned in case
|
|
189
|
-
// you need to rerender the shadowRoot later.
|
|
190
|
-
//
|
|
191
|
-
window.MathJax.typesetShadow = function(root, elem) {
|
|
192
|
-
const InputJax = startup.getInputJax();
|
|
193
|
-
const OutputJax = startup.getOutputJax();
|
|
194
|
-
const html = mathjax.document(root, { InputJax, OutputJax });
|
|
195
|
-
|
|
196
|
-
if (elem) html.options.elements = [elem];
|
|
197
|
-
|
|
198
|
-
html.render().typeset();
|
|
199
|
-
return html;
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
//
|
|
203
|
-
// Now do the usual startup now that the extensions are in place
|
|
204
|
-
//
|
|
205
|
-
window.MathJax.startup.defaultReady();
|
|
206
|
-
},
|
|
207
107
|
// Defer typesetting if the config is present and deferring is set
|
|
208
108
|
typeset: !(mathJaxConfig && mathJaxConfig.deferTypeset)
|
|
209
109
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.29.1",
|
|
4
4
|
"description": "A collection of accessible, free, open-source web components for building Brightspace applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "https://github.com/BrightspaceUI/core.git",
|