From aaaada61b016ac4159c56862eb246f8e4048fe75 Mon Sep 17 00:00:00 2001 From: andreeapescar Date: Fri, 13 Sep 2024 18:07:07 +0300 Subject: [PATCH 1/4] feat: ability to enable/disable math-rendering-accessible PD-3989 --- src/components.d.ts | 16 + src/components/pie-author/pie-author.tsx | 16 +- src/components/pie-player/pie-player.tsx | 16 +- src/demo/NIB-multi-items-players-latest.html | 10468 +++++++++++++++++ src/demo/NIB-multi-items-players.html | 10459 ++++++++++++++++ 5 files changed, 20969 insertions(+), 6 deletions(-) create mode 100644 src/demo/NIB-multi-items-players-latest.html create mode 100644 src/demo/NIB-multi-items-players.html diff --git a/src/components.d.ts b/src/components.d.ts index 614c627..e781d1c 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -95,6 +95,10 @@ export namespace Components { * external providers can set this if they need to upload the assets to the cloud etc. by default we use data urls */ 'uploadSoundSupport': ExternalUploadSoundSupport; + /** + * If the Player should try to use math-rendering-accessible. Do not set this to TRUE if you're not using item types that were released before having the math-rendering-accessible fix. The versions that can be safely used can be found here: TODO. + */ + 'useMathRenderingAccessible': boolean; 'validateModels': () => Promise; 'version': string; } @@ -154,6 +158,10 @@ export namespace Components { * @param update the updated model */ 'updateElementModel': (update: PieModel) => Promise; + /** + * If the Player should try to use math-rendering-accessible. Do not set this to TRUE if you're not using item types that were released before having the math-rendering-accessible fix. The versions that can be safely used can be found here: TODO. + */ + 'useMathRenderingAccessible': boolean; 'version': string; } interface PiePreviewControl {} @@ -290,6 +298,10 @@ declare namespace LocalJSX { * external providers can set this if they need to upload the assets to the cloud etc. by default we use data urls */ 'uploadSoundSupport'?: ExternalUploadSoundSupport; + /** + * If the Player should try to use math-rendering-accessible. Do not set this to TRUE if you're not using item types that were released before having the math-rendering-accessible fix. The versions that can be safely used can be found here: TODO. + */ + 'useMathRenderingAccessible'?: boolean; 'version'?: string; } interface PieEmbed {} @@ -358,6 +370,10 @@ declare namespace LocalJSX { * In evaluate mode, add a bottom border to visually separate each item in the case of a multi-item */ 'showBottomBorder'?: boolean; + /** + * If the Player should try to use math-rendering-accessible. Do not set this to TRUE if you're not using item types that were released before having the math-rendering-accessible fix. The versions that can be safely used can be found here: TODO. + */ + 'useMathRenderingAccessible'?: boolean; 'version'?: string; } interface PiePreviewControl { diff --git a/src/components/pie-author/pie-author.tsx b/src/components/pie-author/pie-author.tsx index bb9966b..f68f718 100644 --- a/src/components/pie-author/pie-author.tsx +++ b/src/components/pie-author/pie-author.tsx @@ -9,7 +9,7 @@ import { import { _dll_pie_lib__pie_toolbox_math_rendering, - // _dll_pie_lib__pie_toolbox_math_rendering_accessible + _dll_pie_lib__pie_toolbox_math_rendering_accessible } from "@pie-lib/pie-toolbox-math-rendering-module/module"; import {Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch} from "@stencil/core"; import cloneDeep from "lodash/cloneDeep"; @@ -121,6 +121,13 @@ export class Author { */ @Prop() isInsidePieApiAuthor?: boolean = false; + /** + * If the Player should try to use math-rendering-accessible. + * Do not set this to TRUE if you're not using item types that were released before having the math-rendering-accessible fix. + * The versions that can be safely used can be found here: TODO. + */ + @Prop() useMathRenderingAccessible: boolean = false; + pieContentModel: PieContent; pieLoader = new PieLoader(); @@ -741,8 +748,11 @@ export class Author { private renderMath() { setTimeout(() => { - _dll_pie_lib__pie_toolbox_math_rendering.renderMath(this.el); - // _dll_pie_lib__pie_toolbox_math_rendering_accessible.renderMath(this.el); + if (this.useMathRenderingAccessible) { + _dll_pie_lib__pie_toolbox_math_rendering_accessible.renderMath(this.el); + } else { + _dll_pie_lib__pie_toolbox_math_rendering.renderMath(this.el); + } }, 50); } diff --git a/src/components/pie-player/pie-player.tsx b/src/components/pie-player/pie-player.tsx index de418f0..b89986d 100644 --- a/src/components/pie-player/pie-player.tsx +++ b/src/components/pie-player/pie-player.tsx @@ -1,7 +1,7 @@ import {SessionChangedEvent} from "@pie-framework/pie-player-events"; import { _dll_pie_lib__pie_toolbox_math_rendering, - // _dll_pie_lib__pie_toolbox_math_rendering_accessible + _dll_pie_lib__pie_toolbox_math_rendering_accessible } from "@pie-lib/pie-toolbox-math-rendering-module/module"; import { Component, @@ -162,6 +162,13 @@ export class Player { @Prop({mutable: false, reflect: false}) version: string = VERSION; + /** + * If the Player should try to use math-rendering-accessible. + * Do not set this to TRUE if you're not using item types that were released before having the math-rendering-accessible fix. + * The versions that can be safely used can be found here: TODO. + */ + @Prop() useMathRenderingAccessible: boolean = false; + /** * Allow to resize pie-stimulus layout * Set this property to false to not render the resizer. @@ -398,8 +405,11 @@ export class Player { private renderMath() { setTimeout(() => { - _dll_pie_lib__pie_toolbox_math_rendering.renderMath(this.el); - // _dll_pie_lib__pie_toolbox_math_rendering_accessible.renderMath(this.el); + if (this.useMathRenderingAccessible) { + _dll_pie_lib__pie_toolbox_math_rendering_accessible.renderMath(this.el); + } else { + _dll_pie_lib__pie_toolbox_math_rendering.renderMath(this.el); + } }, 50); } diff --git a/src/demo/NIB-multi-items-players-latest.html b/src/demo/NIB-multi-items-players-latest.html new file mode 100644 index 0000000..f5e9947 --- /dev/null +++ b/src/demo/NIB-multi-items-players-latest.html @@ -0,0 +1,10468 @@ + + + + + + + + + MathJax Example + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + diff --git a/src/demo/NIB-multi-items-players.html b/src/demo/NIB-multi-items-players.html new file mode 100644 index 0000000..fd67d1a --- /dev/null +++ b/src/demo/NIB-multi-items-players.html @@ -0,0 +1,10459 @@ + + + + + + + + + MathJax Example + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + From 5499bf66371d8bb6b7a2f7aa99795a842c4173ab Mon Sep 17 00:00:00 2001 From: andreeapescar Date: Fri, 13 Sep 2024 18:33:30 +0300 Subject: [PATCH 2/4] chore: update demo file with multiple test cases --- src/demo/NIB-multi-items-players-latest.html | 28 ++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/demo/NIB-multi-items-players-latest.html b/src/demo/NIB-multi-items-players-latest.html index f5e9947..fbe55b1 100644 --- a/src/demo/NIB-multi-items-players-latest.html +++ b/src/demo/NIB-multi-items-players-latest.html @@ -22,11 +22,12 @@ - - - - + + + + +