forked from MapComplete/MapComplete
chore: automated housekeeping...
This commit is contained in:
parent
a190597905
commit
087e639020
382 changed files with 29496 additions and 2675 deletions
|
|
@ -3,54 +3,54 @@
|
|||
</div>
|
||||
|
||||
<style>
|
||||
:global(.sidebar-unit) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: var(--background-color);
|
||||
padding: 0.5rem;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
:global(.sidebar-unit) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: var(--background-color);
|
||||
padding: 0.5rem;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
:global(.sidebar-unit > h3) {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0.5rem;
|
||||
padding: 0.25rem;
|
||||
top: 0;
|
||||
position: sticky;
|
||||
z-index: 1;
|
||||
padding-top: 0.5rem;
|
||||
background: var(--background-color);
|
||||
}
|
||||
:global(.sidebar-unit > h3) {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0.5rem;
|
||||
padding: 0.25rem;
|
||||
top: 0;
|
||||
position: sticky;
|
||||
z-index: 1;
|
||||
padding-top: 0.5rem;
|
||||
background: var(--background-color);
|
||||
}
|
||||
|
||||
:global(
|
||||
:global(
|
||||
.sidebar-button svg,
|
||||
.sidebar-button img,
|
||||
.sidebar-unit > button img,
|
||||
.sidebar-unit > button svg
|
||||
) {
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
margin-right: 0.5rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
margin-right: 0.5rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
:global(.sidebar-button .weblate-link > svg) {
|
||||
width: 0.75rem;
|
||||
height: 0.75rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
:global(.sidebar-button .weblate-link > svg) {
|
||||
width: 0.75rem;
|
||||
height: 0.75rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
:global(.sidebar-button, .sidebar-unit > a, .sidebar-unit > button) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-radius: 0.25rem !important;
|
||||
padding: 0.4rem 0.75rem !important;
|
||||
text-decoration: none !important;
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
}
|
||||
:global(.sidebar-button, .sidebar-unit > a, .sidebar-unit > button) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-radius: 0.25rem !important;
|
||||
padding: 0.4rem 0.75rem !important;
|
||||
text-decoration: none !important;
|
||||
width: 100%;
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
:global(
|
||||
:global(
|
||||
.sidebar-button > svg,
|
||||
.sidebar-button > img,
|
||||
.sidebar-unit > a img,
|
||||
|
|
@ -58,11 +58,11 @@
|
|||
.sidebar-unit > button svg,
|
||||
.sidebar-unit > button img
|
||||
) {
|
||||
margin-right: 0.5rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
margin-right: 0.5rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
:global(.sidebar-button:hover, .sidebar-unit > a:hover, .sidebar-unit > button:hover) {
|
||||
background: var(--low-interaction-background) !important;
|
||||
}
|
||||
:global(.sidebar-button:hover, .sidebar-unit > a:hover, .sidebar-unit > button:hover) {
|
||||
background: var(--low-interaction-background) !important;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -25,14 +25,19 @@ export default class SvelteUIElement<
|
|||
private tag: "div" | "span" = "div"
|
||||
public readonly isSvelte = true
|
||||
|
||||
constructor(svelteElement : {
|
||||
new (args: {
|
||||
target: HTMLElement
|
||||
props: Props
|
||||
events?: Events
|
||||
slots?: Slots
|
||||
}): SvelteComponentTyped<Props, Events, Slots>
|
||||
}, props?: Props, events?: Events, slots?: Slots) {
|
||||
constructor(
|
||||
svelteElement: {
|
||||
new (args: {
|
||||
target: HTMLElement
|
||||
props: Props
|
||||
events?: Events
|
||||
slots?: Slots
|
||||
}): SvelteComponentTyped<Props, Events, Slots>
|
||||
},
|
||||
props?: Props,
|
||||
events?: Events,
|
||||
slots?: Slots
|
||||
) {
|
||||
super()
|
||||
this._svelteComponent = <any>svelteElement
|
||||
this._props = props ?? <Props>{}
|
||||
|
|
|
|||
|
|
@ -50,11 +50,14 @@ export default class TableOfContents {
|
|||
|
||||
public static insertTocIntoMd(md: string, maxDepth: number): string {
|
||||
// parse_html has a limit on how much html it can parse. We strip away the actual content, only keeping the titles
|
||||
const mdStripped = md.split("\n\n").filter(l => l.trim().startsWith("#")).join("\n\n")
|
||||
const mdStripped = md
|
||||
.split("\n\n")
|
||||
.filter((l) => l.trim().startsWith("#"))
|
||||
.join("\n\n")
|
||||
const htmlSource = <string>marked.parse(mdStripped)
|
||||
const el = parse_html(htmlSource)
|
||||
const structure = TableOfContents.generateStructure(<any>el)
|
||||
if(structure.length <= 1){
|
||||
if (structure.length <= 1) {
|
||||
return md
|
||||
}
|
||||
const firstTitle = structure[1]
|
||||
|
|
@ -93,7 +96,7 @@ export default class TableOfContents {
|
|||
if (depthDiff === 0) {
|
||||
topLevelCount++
|
||||
toc += `${topLevelCount}. ${link}\n`
|
||||
} else if (depthDiff <= 3 &&(maxDepth === undefined || depthDiff < maxDepth)) {
|
||||
} else if (depthDiff <= 3 && (maxDepth === undefined || depthDiff < maxDepth)) {
|
||||
toc += `${separators[depthDiff]} ${link}\n`
|
||||
}
|
||||
}
|
||||
|
|
@ -116,12 +119,12 @@ export default class TableOfContents {
|
|||
return []
|
||||
}
|
||||
return Array.from(html.childNodes ?? []).flatMap((child) => {
|
||||
const tag: string = child["tagName"]?.toLowerCase()
|
||||
if (tag?.match(/h[0-9]/)) {
|
||||
const depth = Number(tag.substring(1))
|
||||
return [{ depth, title: child.textContent, el: <Element> child }]
|
||||
}
|
||||
return TableOfContents.generateStructure(<Element>child)
|
||||
})
|
||||
const tag: string = child["tagName"]?.toLowerCase()
|
||||
if (tag?.match(/h[0-9]/)) {
|
||||
const depth = Number(tag.substring(1))
|
||||
return [{ depth, title: child.textContent, el: <Element>child }]
|
||||
}
|
||||
return TableOfContents.generateStructure(<Element>child)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
let err = false
|
||||
onMount(() => {
|
||||
try {
|
||||
|
||||
uiElement = typeof construct === "function" ? construct() : construct
|
||||
|
||||
if (uiElement?.["isSvelte"]) {
|
||||
|
|
@ -26,7 +25,6 @@
|
|||
if (html !== undefined) {
|
||||
elem?.replaceWith(html)
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error("Could not construct a ToSvelte:", e)
|
||||
err = true
|
||||
|
|
@ -38,6 +36,7 @@
|
|||
uiElement?.Destroy()
|
||||
})
|
||||
</script>
|
||||
|
||||
{#if err}
|
||||
<div class="alert">Something went wrong</div>
|
||||
{:else if isSvelte}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue