forked from MapComplete/MapComplete
Merge master
This commit is contained in:
commit
1b01f75905
186 changed files with 4169 additions and 2235 deletions
|
|
@ -38,12 +38,12 @@
|
|||
<slot name="close-button">
|
||||
<!-- The close button is placed _after_ the default slot in order to always paint it on top -->
|
||||
<div
|
||||
class="absolute right-10 top-10 cursor-pointer border-none p-0 m-0 bg-white rounded-full border-0"
|
||||
class="absolute right-10 top-10 m-0 cursor-pointer rounded-full border-0 border-none bg-white p-0"
|
||||
style="margin: -0.25rem"
|
||||
on:click={() => dispatch("close")}
|
||||
use:ariaLabel={Translations.t.general.backToMap}
|
||||
>
|
||||
<XCircleIcon class="w-8 h-8" />
|
||||
<XCircleIcon class="h-8 w-8" />
|
||||
</div>
|
||||
</slot>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -30,18 +30,18 @@ export default class Hotkeys {
|
|||
public static RegisterHotkey(
|
||||
key: (
|
||||
| {
|
||||
ctrl: string
|
||||
}
|
||||
ctrl: string
|
||||
}
|
||||
| {
|
||||
shift: string
|
||||
}
|
||||
shift: string
|
||||
}
|
||||
| {
|
||||
alt: string
|
||||
}
|
||||
alt: string
|
||||
}
|
||||
| {
|
||||
nomod: string
|
||||
}
|
||||
) & {
|
||||
nomod: string
|
||||
}
|
||||
) & {
|
||||
onUp?: boolean
|
||||
},
|
||||
documentation: string | Translation,
|
||||
|
|
@ -63,7 +63,7 @@ export default class Hotkeys {
|
|||
return
|
||||
}
|
||||
if (key["ctrl"] !== undefined) {
|
||||
document.addEventListener("keydown", function(event) {
|
||||
document.addEventListener("keydown", function (event) {
|
||||
if (event.ctrlKey && event.key === keycode) {
|
||||
if (action() !== false) {
|
||||
event.preventDefault()
|
||||
|
|
@ -71,7 +71,7 @@ export default class Hotkeys {
|
|||
}
|
||||
})
|
||||
} else if (key["shift"] !== undefined) {
|
||||
document.addEventListener(type, function(event) {
|
||||
document.addEventListener(type, function (event) {
|
||||
if (Hotkeys.textElementSelected(event)) {
|
||||
// A text element is selected, we don't do anything special
|
||||
return
|
||||
|
|
@ -83,7 +83,7 @@ export default class Hotkeys {
|
|||
}
|
||||
})
|
||||
} else if (key["alt"] !== undefined) {
|
||||
document.addEventListener(type, function(event) {
|
||||
document.addEventListener(type, function (event) {
|
||||
if (event.altKey && event.key === keycode) {
|
||||
if (action() !== false) {
|
||||
event.preventDefault()
|
||||
|
|
@ -91,7 +91,7 @@ export default class Hotkeys {
|
|||
}
|
||||
})
|
||||
} else if (key["nomod"] !== undefined) {
|
||||
document.addEventListener(type, function(event) {
|
||||
document.addEventListener(type, function (event) {
|
||||
if (Hotkeys.textElementSelected(event) && keycode !== "Escape") {
|
||||
// A text element is selected, we don't do anything special
|
||||
return
|
||||
|
|
@ -106,18 +106,17 @@ export default class Hotkeys {
|
|||
}
|
||||
}
|
||||
|
||||
static prepareDocumentation(docs: {
|
||||
key: { ctrl?: string; shift?: string; alt?: string; nomod?: string; onUp?: boolean }
|
||||
documentation: string | Translation
|
||||
alsoTriggeredBy: Translation[]
|
||||
}[]){
|
||||
static prepareDocumentation(
|
||||
docs: {
|
||||
key: { ctrl?: string; shift?: string; alt?: string; nomod?: string; onUp?: boolean }
|
||||
documentation: string | Translation
|
||||
alsoTriggeredBy: Translation[]
|
||||
}[]
|
||||
) {
|
||||
let byKey: [string, string | Translation, Translation[] | undefined][] = docs
|
||||
.map(({ key, documentation, alsoTriggeredBy }) => {
|
||||
const modifiers = Object.keys(key).filter(
|
||||
(k) => k !== "nomod" && k !== "onUp"
|
||||
)
|
||||
let keycode: string =
|
||||
key["ctrl"] ?? key["shift"] ?? key["alt"] ?? key["nomod"]
|
||||
const modifiers = Object.keys(key).filter((k) => k !== "nomod" && k !== "onUp")
|
||||
let keycode: string = key["ctrl"] ?? key["shift"] ?? key["alt"] ?? key["nomod"]
|
||||
if (keycode.length == 1) {
|
||||
keycode = keycode.toUpperCase()
|
||||
}
|
||||
|
|
@ -128,7 +127,7 @@ export default class Hotkeys {
|
|||
return <[string, string | Translation, Translation[] | undefined]>[
|
||||
modifiers.join("+"),
|
||||
documentation,
|
||||
alsoTriggeredBy
|
||||
alsoTriggeredBy,
|
||||
]
|
||||
})
|
||||
.sort()
|
||||
|
|
@ -141,36 +140,41 @@ export default class Hotkeys {
|
|||
return byKey
|
||||
}
|
||||
|
||||
static generateDocumentationFor(docs: {
|
||||
key: { ctrl?: string; shift?: string; alt?: string; nomod?: string; onUp?: boolean }
|
||||
documentation: string | Translation
|
||||
alsoTriggeredBy: Translation[]
|
||||
}[], language: string): string {
|
||||
|
||||
static generateDocumentationFor(
|
||||
docs: {
|
||||
key: { ctrl?: string; shift?: string; alt?: string; nomod?: string; onUp?: boolean }
|
||||
documentation: string | Translation
|
||||
alsoTriggeredBy: Translation[]
|
||||
}[],
|
||||
language: string
|
||||
): string {
|
||||
const tr = Translations.t.hotkeyDocumentation
|
||||
function t(t: Translation | string){
|
||||
if(typeof t === "string"){
|
||||
function t(t: Translation | string) {
|
||||
if (typeof t === "string") {
|
||||
return t
|
||||
}
|
||||
return t.textFor(language)
|
||||
}
|
||||
const contents: string[][] = this.prepareDocumentation(docs)
|
||||
.map(([key, doc, alsoTriggeredBy]) => {
|
||||
let keyEl: string = [key, ...(alsoTriggeredBy??[])].map(k => "`"+t(k)+"`").join(" ")
|
||||
return [keyEl, t(doc)]
|
||||
})
|
||||
const contents: string[][] = this.prepareDocumentation(docs).map(
|
||||
([key, doc, alsoTriggeredBy]) => {
|
||||
let keyEl: string = [key, ...(alsoTriggeredBy ?? [])]
|
||||
.map((k) => "`" + t(k) + "`")
|
||||
.join(" ")
|
||||
return [keyEl, t(doc)]
|
||||
}
|
||||
)
|
||||
return [
|
||||
"# "+t(tr.title),
|
||||
"# " + t(tr.title),
|
||||
t(tr.intro),
|
||||
MarkdownUtils.table(
|
||||
[t(tr.key), t(tr.action)],
|
||||
contents
|
||||
)
|
||||
].join("\n")
|
||||
MarkdownUtils.table([t(tr.key), t(tr.action)], contents),
|
||||
].join("\n")
|
||||
}
|
||||
|
||||
public static generateDocumentation(language?: string){
|
||||
return Hotkeys.generateDocumentationFor(Hotkeys._docs.data, language?? Locale.language.data)
|
||||
public static generateDocumentation(language?: string) {
|
||||
return Hotkeys.generateDocumentationFor(
|
||||
Hotkeys._docs.data,
|
||||
language ?? Locale.language.data
|
||||
)
|
||||
}
|
||||
|
||||
private static textElementSelected(event: KeyboardEvent): boolean {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import Combine from "./Combine"
|
|||
import Translations from "../i18n/Translations"
|
||||
import BaseUIElement from "../BaseUIElement"
|
||||
import SvelteUIElement from "./SvelteUIElement"
|
||||
import {default as LoadingSvg} from "../../assets/svg/Loading.svelte"
|
||||
import { default as LoadingSvg } from "../../assets/svg/Loading.svelte"
|
||||
export default class Loading extends Combine {
|
||||
constructor(msg?: BaseUIElement | string) {
|
||||
const t = Translations.W(msg) ?? Translations.t.general.loading
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export default class SvelteUIElement<
|
|||
|
||||
constructor(svelteElement, props?: Props, events?: Events, slots?: Slots) {
|
||||
super()
|
||||
this._svelteComponent = <any> svelteElement
|
||||
this._svelteComponent = <any>svelteElement
|
||||
this._props = props ?? <Props>{}
|
||||
this._events = events
|
||||
this._slots = slots
|
||||
|
|
@ -49,15 +49,15 @@ export default class SvelteUIElement<
|
|||
return el
|
||||
}
|
||||
|
||||
public getClass(){
|
||||
if(this.clss.size === 0){
|
||||
public getClass() {
|
||||
if (this.clss.size === 0) {
|
||||
return undefined
|
||||
}
|
||||
return this.clss
|
||||
}
|
||||
|
||||
public getStyle(){
|
||||
if(this.style === ""){
|
||||
public getStyle() {
|
||||
if (this.style === "") {
|
||||
return undefined
|
||||
}
|
||||
return this.style
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ export default class TableOfContents {
|
|||
const intro = md.substring(0, firstTitleIndex)
|
||||
const splitPoint = intro.lastIndexOf("\n")
|
||||
|
||||
return md.substring(0, splitPoint) +"\n" + toc + md.substring(splitPoint)
|
||||
return md.substring(0, splitPoint) + "\n" + toc + md.substring(splitPoint)
|
||||
}
|
||||
|
||||
public static generateStructure(
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@
|
|||
let elem: HTMLElement
|
||||
let html: HTMLElement
|
||||
let isSvelte = false
|
||||
let uiElement : BaseUIElement | SvelteUIElement | undefined
|
||||
let uiElement: BaseUIElement | SvelteUIElement | undefined
|
||||
let svelteElem: SvelteUIElement
|
||||
onMount(() => {
|
||||
uiElement = typeof construct === "function" ? construct() : construct
|
||||
|
||||
if (uiElement?.["isSvelte"]) {
|
||||
isSvelte = true
|
||||
svelteElem = <SvelteUIElement> uiElement
|
||||
svelteElem = <SvelteUIElement>uiElement
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -32,7 +32,12 @@
|
|||
</script>
|
||||
|
||||
{#if isSvelte}
|
||||
<svelte:component this={svelteElem?._svelteComponent} {...svelteElem._props} class={svelteElem.getClass()} style={svelteElem.getStyle()}/>
|
||||
<svelte:component
|
||||
this={svelteElem?._svelteComponent}
|
||||
{...svelteElem._props}
|
||||
class={svelteElem.getClass()}
|
||||
style={svelteElem.getStyle()}
|
||||
/>
|
||||
{:else}
|
||||
<span bind:this={elem} />
|
||||
{/if}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue