mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2026-07-23 06:13:38 -04:00
Refactored project structure
This commit is contained in:
@@ -25,7 +25,7 @@ import { Observable, Subject } from "rxjs"
|
||||
|
||||
import { translation } from "~/_"
|
||||
import {
|
||||
getElementOrThrow,
|
||||
getElement,
|
||||
getElements
|
||||
} from "~/browser"
|
||||
|
||||
@@ -85,7 +85,7 @@ export function setupClipboardJS(
|
||||
new ClipboardJS("[data-clipboard-target], [data-clipboard-text]", {
|
||||
text: el => (
|
||||
el.getAttribute("data-clipboard-text")! ||
|
||||
extract(getElementOrThrow(
|
||||
extract(getElement(
|
||||
el.getAttribute("data-clipboard-target")!
|
||||
))
|
||||
)
|
||||
|
||||
@@ -47,9 +47,8 @@ import { configuration, feature } from "~/_"
|
||||
import {
|
||||
Viewport,
|
||||
ViewportOffset,
|
||||
getElement,
|
||||
getElements,
|
||||
replaceElement,
|
||||
getOptionalElement,
|
||||
request,
|
||||
requestXML,
|
||||
setLocation,
|
||||
@@ -166,7 +165,7 @@ export function setupInstantLoading(
|
||||
}
|
||||
|
||||
/* Hack: ensure absolute favicon link to omit 404s when switching */
|
||||
const favicon = getElement<HTMLLinkElement>("link[rel=icon]")
|
||||
const favicon = getOptionalElement<HTMLLinkElement>("link[rel=icon]")
|
||||
if (typeof favicon !== "undefined")
|
||||
favicon.href = favicon.href
|
||||
|
||||
@@ -286,13 +285,13 @@ export function setupInstantLoading(
|
||||
? ["[data-md-component=tabs]"]
|
||||
: []
|
||||
]) {
|
||||
const source = getElement(selector)
|
||||
const target = getElement(selector, replacement)
|
||||
const source = getOptionalElement(selector)
|
||||
const target = getOptionalElement(selector, replacement)
|
||||
if (
|
||||
typeof source !== "undefined" &&
|
||||
typeof target !== "undefined"
|
||||
) {
|
||||
replaceElement(source, target)
|
||||
source.replaceWith(target)
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -308,7 +307,7 @@ export function setupInstantLoading(
|
||||
if (el.src) {
|
||||
for (const name of el.getAttributeNames())
|
||||
script.setAttribute(name, el.getAttribute(name)!)
|
||||
replaceElement(el, script)
|
||||
el.replaceWith(script)
|
||||
|
||||
/* Complete when script is loaded */
|
||||
return new Observable(observer => {
|
||||
@@ -318,7 +317,7 @@ export function setupInstantLoading(
|
||||
/* Complete immediately */
|
||||
} else {
|
||||
script.textContent = el.textContent
|
||||
replaceElement(el, script)
|
||||
el.replaceWith(script)
|
||||
return EMPTY
|
||||
}
|
||||
})
|
||||
|
||||
@@ -24,7 +24,7 @@ import { combineLatest, map } from "rxjs"
|
||||
|
||||
import { configuration } from "~/_"
|
||||
import {
|
||||
getElementOrThrow,
|
||||
getElement,
|
||||
requestJSON
|
||||
} from "~/browser"
|
||||
import { getComponentElements } from "~/components"
|
||||
@@ -60,7 +60,7 @@ export function setupVersionSelector(): void {
|
||||
/* Render version selector and warning */
|
||||
combineLatest([versions$, current$])
|
||||
.subscribe(([versions, current]) => {
|
||||
const topic = getElementOrThrow(".md-header__topic")
|
||||
const topic = getElement(".md-header__topic")
|
||||
topic.appendChild(renderVersionSelector(versions, current))
|
||||
|
||||
/* Check if version state was already determined */
|
||||
|
||||
Reference in New Issue
Block a user