@brightspace-ui/core 2.46.1 → 2.47.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.
|
@@ -196,23 +196,12 @@ class Alert extends LocalizeCoreElement(RtlMixin(LitElement)) {
|
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
close() {
|
|
199
|
-
// deprecated - event names should be present tense
|
|
200
|
-
/** @ignore */
|
|
201
|
-
const didDispatch = this.dispatchEvent(new CustomEvent('d2l-alert-closed', { bubbles: true, composed: true, cancelable: true }));
|
|
202
|
-
if (didDispatch) {
|
|
203
|
-
this.hidden = true;
|
|
204
|
-
}
|
|
205
199
|
if (this.dispatchEvent(new CustomEvent('d2l-alert-close', { bubbles: true, composed: true, cancelable: true }))) {
|
|
206
200
|
this.hidden = true;
|
|
207
201
|
}
|
|
208
202
|
}
|
|
209
203
|
|
|
210
204
|
_onButtonClick() {
|
|
211
|
-
// deprecated - event names should be present tense
|
|
212
|
-
/** @ignore */
|
|
213
|
-
this.dispatchEvent(new CustomEvent(
|
|
214
|
-
'd2l-alert-button-pressed', { bubbles: true, composed: true }
|
|
215
|
-
));
|
|
216
205
|
this.dispatchEvent(new CustomEvent(
|
|
217
206
|
'd2l-alert-button-press', { bubbles: true, composed: true }
|
|
218
207
|
));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import '../colors/colors.js';
|
|
2
|
-
import { codeStyles,
|
|
2
|
+
import { codeStyles, createHtmlBlockRenderer as createCodeRenderer } from '../../helpers/prism.js';
|
|
3
3
|
import { css, html, LitElement } from 'lit';
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
5
|
+
import { createHtmlBlockRenderer as createMathRenderer } from '../../helpers/mathjax.js';
|
|
5
6
|
import { HtmlAttributeObserverController } from '../../controllers/attributeObserver/htmlAttributeObserverController.js';
|
|
6
|
-
import { HtmlBlockMathRenderer } from '../../helpers/mathjax.js';
|
|
7
7
|
import { requestInstance } from '../../mixins/provider-mixin.js';
|
|
8
8
|
import { RtlMixin } from '../../mixins/rtl-mixin.js';
|
|
9
9
|
|
|
@@ -118,10 +118,11 @@ export const htmlBlockContentStyles = css`
|
|
|
118
118
|
|
|
119
119
|
let renderers;
|
|
120
120
|
|
|
121
|
-
const getRenderers = () => {
|
|
121
|
+
const getRenderers = async() => {
|
|
122
122
|
if (renderers) return renderers;
|
|
123
|
-
const
|
|
124
|
-
const
|
|
123
|
+
const rendererLoader = requestInstance(document, 'html-block-renderer-loader');
|
|
124
|
+
const tempRenderers = rendererLoader ? await rendererLoader.getRenderers() : undefined;
|
|
125
|
+
const defaultRenderers = [ createMathRenderer(), createCodeRenderer() ];
|
|
125
126
|
renderers = (tempRenderers ? [ ...defaultRenderers, ...tempRenderers ] : defaultRenderers);
|
|
126
127
|
return renderers;
|
|
127
128
|
};
|
|
@@ -193,13 +194,18 @@ class HtmlBlock extends RtlMixin(LitElement) {
|
|
|
193
194
|
this.noDeferredRendering = false;
|
|
194
195
|
this._hasSlottedContent = false;
|
|
195
196
|
|
|
196
|
-
|
|
197
|
+
this._contextObserverControllerResolve = undefined;
|
|
198
|
+
this._contextObserverControllerInitialized = new Promise(resolve => {
|
|
199
|
+
this._contextObserverControllerResolve = resolve;
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
getRenderers().then(renderers => renderers.reduce((attrs, currentRenderer) => {
|
|
197
203
|
if (currentRenderer.contextAttributes) currentRenderer.contextAttributes.forEach(attr => attrs.push(attr));
|
|
198
204
|
return attrs;
|
|
199
|
-
}, [])
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
205
|
+
}, [])).then(rendererContextAttributes => {
|
|
206
|
+
this._contextObserverController = new HtmlAttributeObserverController(this, ...rendererContextAttributes);
|
|
207
|
+
this._contextObserverControllerResolve();
|
|
208
|
+
});
|
|
203
209
|
}
|
|
204
210
|
|
|
205
211
|
connectedCallback() {
|
|
@@ -245,7 +251,7 @@ class HtmlBlock extends RtlMixin(LitElement) {
|
|
|
245
251
|
if (changedProperties.has('html') && this.html !== undefined && this.html !== null && !this._hasSlottedContent) {
|
|
246
252
|
await this._updateRenderContainer();
|
|
247
253
|
}
|
|
248
|
-
if (this._contextChanged()) {
|
|
254
|
+
if (await this._contextChanged()) {
|
|
249
255
|
if (this._hasSlottedContent) this._render();
|
|
250
256
|
else if (this.html !== undefined && this.html !== null) {
|
|
251
257
|
await this._updateRenderContainer();
|
|
@@ -255,8 +261,12 @@ class HtmlBlock extends RtlMixin(LitElement) {
|
|
|
255
261
|
}
|
|
256
262
|
}
|
|
257
263
|
|
|
258
|
-
_contextChanged() {
|
|
259
|
-
|
|
264
|
+
async _contextChanged() {
|
|
265
|
+
await this._contextObserverControllerInitialized;
|
|
266
|
+
if (!this._contextKeys) {
|
|
267
|
+
this._updateContextKeys();
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
260
270
|
|
|
261
271
|
if (this._contextKeys.size !== this._contextObserverController.values.size) return true;
|
|
262
272
|
for (const [attr, val] of this._contextKeys) {
|
|
@@ -286,8 +296,10 @@ class HtmlBlock extends RtlMixin(LitElement) {
|
|
|
286
296
|
}
|
|
287
297
|
|
|
288
298
|
async _processRenderers(elem) {
|
|
289
|
-
|
|
290
|
-
|
|
299
|
+
await this._contextObserverControllerInitialized;
|
|
300
|
+
const renderers = await getRenderers();
|
|
301
|
+
for (const renderer of renderers) {
|
|
302
|
+
if (renderer.contextAttributes) {
|
|
291
303
|
const contextValues = new Map();
|
|
292
304
|
renderer.contextAttributes.forEach(attr => contextValues.set(attr, this._contextObserverController.values.get(attr)));
|
|
293
305
|
await renderer.render(elem, {
|
package/helpers/mathjax.js
CHANGED
|
@@ -33,7 +33,7 @@ const mathjaxFontMappings = new Map([
|
|
|
33
33
|
let mathJaxLoaded;
|
|
34
34
|
let renderingPromise = Promise.resolve();
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
class HtmlBlockMathRenderer {
|
|
37
37
|
|
|
38
38
|
get contextAttributes() {
|
|
39
39
|
return [mathjaxContextAttribute];
|
|
@@ -77,6 +77,10 @@ export class HtmlBlockMathRenderer {
|
|
|
77
77
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
export function createHtmlBlockRenderer() {
|
|
81
|
+
return new HtmlBlockMathRenderer();
|
|
82
|
+
}
|
|
83
|
+
|
|
80
84
|
export function loadMathJax(mathJaxConfig) {
|
|
81
85
|
|
|
82
86
|
if (mathJaxLoaded) return mathJaxLoaded;
|
package/helpers/prism.js
CHANGED
|
@@ -452,7 +452,7 @@ export async function formatCodeElement(elem) {
|
|
|
452
452
|
Prism.highlightElement(code);
|
|
453
453
|
}
|
|
454
454
|
|
|
455
|
-
|
|
455
|
+
class HtmlBlockCodeRenderer {
|
|
456
456
|
|
|
457
457
|
get canRenderInline() {
|
|
458
458
|
return true;
|
|
@@ -471,3 +471,7 @@ export class HtmlBlockCodeRenderer {
|
|
|
471
471
|
}
|
|
472
472
|
|
|
473
473
|
}
|
|
474
|
+
|
|
475
|
+
export function createHtmlBlockRenderer() {
|
|
476
|
+
return new HtmlBlockCodeRenderer();
|
|
477
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.47.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",
|