mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Convert from window to globalThis in demo web app script file.
This commit is contained in:
parent
30bb7e4f8e
commit
29ebb28f10
1 changed files with 10 additions and 10 deletions
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
(function main() {
|
(function main() {
|
||||||
// Dependencies
|
// Dependencies
|
||||||
var markdownit = window.markdownit;
|
var markdownit = globalThis.markdownit;
|
||||||
var markdownlint = window.markdownlint.library;
|
var markdownlint = globalThis.markdownlint.library;
|
||||||
var helpers = window.markdownlint.helpers;
|
var helpers = globalThis.markdownlint.helpers;
|
||||||
var micromark = window.micromarkBrowser;
|
var micromark = globalThis.micromarkBrowser;
|
||||||
var micromarkHtml = window.micromarkHtmlBrowser;
|
var micromarkHtml = globalThis.micromarkHtmlBrowser;
|
||||||
|
|
||||||
// DOM elements
|
// DOM elements
|
||||||
var markdown = document.getElementById("markdown");
|
var markdown = document.getElementById("markdown");
|
||||||
|
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
// Renders Markdown to HTML
|
// Renders Markdown to HTML
|
||||||
function render(markdown) {
|
function render(markdown) {
|
||||||
const match = /^\?renderer=([a-z-]+)$/.exec(window.location.search);
|
const match = /^\?renderer=([a-z-]+)$/.exec(globalThis.location.search);
|
||||||
const renderer = match ? match[1] : "micromark";
|
const renderer = match ? match[1] : "micromark";
|
||||||
if (renderer === "markdown-it") {
|
if (renderer === "markdown-it") {
|
||||||
return markdownit({ "html": true }).render(markdown);
|
return markdownit({ "html": true }).render(markdown);
|
||||||
|
|
@ -211,9 +211,9 @@
|
||||||
|
|
||||||
// Updates the URL hash and copies the URL to the clipboard
|
// Updates the URL hash and copies the URL to the clipboard
|
||||||
function onCopyLinkClick(e) {
|
function onCopyLinkClick(e) {
|
||||||
window.location.hash = encodeURIComponent(hashPrefix + markdown.value);
|
globalThis.location.hash = encodeURIComponent(hashPrefix + markdown.value);
|
||||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||||
navigator.clipboard.writeText(window.location).then(noop, noop);
|
navigator.clipboard.writeText(globalThis.location).then(noop, noop);
|
||||||
} else {
|
} else {
|
||||||
/* eslint-disable-next-line no-alert */
|
/* eslint-disable-next-line no-alert */
|
||||||
alert("Document URL updated, select and copy it now.");
|
alert("Document URL updated, select and copy it now.");
|
||||||
|
|
@ -261,9 +261,9 @@
|
||||||
].join("\n");
|
].join("\n");
|
||||||
|
|
||||||
// Update Markdown from hash (if present)
|
// Update Markdown from hash (if present)
|
||||||
if (window.location.hash) {
|
if (globalThis.location.hash) {
|
||||||
try {
|
try {
|
||||||
var decodedHash = decodeURIComponent(window.location.hash.substring(1));
|
var decodedHash = decodeURIComponent(globalThis.location.hash.substring(1));
|
||||||
if (hashPrefix === decodedHash.substring(0, hashPrefix.length)) {
|
if (hashPrefix === decodedHash.substring(0, hashPrefix.length)) {
|
||||||
markdown.value = decodedHash.substring(hashPrefix.length);
|
markdown.value = decodedHash.substring(hashPrefix.length);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue