Restore output attribute of py-script tags, add py-script exec lifecycle hooks (#1063)

* Add beforePyScriptExec, afterPyScriptExec lifecycle hooks

* Add stdiodirector plugin for `output`, `stderr` attributes of py-script tag

* Add docs on `output` and `stderr` attributes of py-script tag

* Tests

* Removed output deprecation warning for `output` attribute

* Add createSingularWarning(), with createDeprecationWarning as alias
This commit is contained in:
Jeff Glass
2023-01-10 13:00:29 -06:00
committed by GitHub
parent e1b4415193
commit 470c3489dd
15 changed files with 748 additions and 33 deletions

View File

@@ -111,10 +111,22 @@ export function joinPaths(parts: string[], separator = '/') {
}
export function createDeprecationWarning(msg: string, elementName: string): void {
createSingularWarning(msg, elementName);
}
/** Adds a warning banner with content {msg} at the top of the page if
* and only if no banner containing the {sentinelText} already exists.
* If sentinelText is null, the full text of {msg} is used instead
*
* @param msg {string} The full text content of the warning banner to be displayed
* @param sentinelText {string} [null] The text to match against existing warning banners.
* If null, the full text of 'msg' is used instead.
*/
export function createSingularWarning(msg: string, sentinelText: string | null = null): void {
const banners = document.getElementsByClassName('alert-banner py-warning');
let bannerCount = 0;
for (const banner of banners) {
if (banner.innerHTML.includes(elementName)) {
if (banner.innerHTML.includes(sentinelText ? sentinelText : msg)) {
bannerCount++;
}
}