forked from MapComplete/MapComplete
Remove all usages of 'nano-markdown', use centralized 'Markdown.svelte'-instead
This commit is contained in:
parent
181965efd9
commit
fc6d86397e
8 changed files with 27 additions and 106 deletions
96
package-lock.json
generated
96
package-lock.json
generated
|
@ -52,9 +52,8 @@
|
||||||
"lz-string": "^1.4.4",
|
"lz-string": "^1.4.4",
|
||||||
"mangrove-reviews-typescript": "^1.1.0",
|
"mangrove-reviews-typescript": "^1.1.0",
|
||||||
"maplibre-gl": "^4.1.1",
|
"maplibre-gl": "^4.1.1",
|
||||||
"markdown-it": "^14.1.0",
|
"marked": "^12.0.2",
|
||||||
"monaco-editor": "^0.46.0",
|
"monaco-editor": "^0.46.0",
|
||||||
"nano-markdown": "^1.2.2",
|
|
||||||
"opening_hours": "^3.6.0",
|
"opening_hours": "^3.6.0",
|
||||||
"osm-auth": "^2.2.0",
|
"osm-auth": "^2.2.0",
|
||||||
"osmtogeojson": "^3.0.0-beta.5",
|
"osmtogeojson": "^3.0.0-beta.5",
|
||||||
|
@ -11320,14 +11319,6 @@
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/linkify-it": {
|
|
||||||
"version": "5.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz",
|
|
||||||
"integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==",
|
|
||||||
"dependencies": {
|
|
||||||
"uc.micro": "^2.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/local-pkg": {
|
"node_modules/local-pkg": {
|
||||||
"version": "0.4.3",
|
"version": "0.4.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -11549,27 +11540,17 @@
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
"node_modules/markdown-it": {
|
"node_modules/marked": {
|
||||||
"version": "14.1.0",
|
"version": "12.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/marked/-/marked-12.0.2.tgz",
|
||||||
"integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==",
|
"integrity": "sha512-qXUm7e/YKFoqFPYPa3Ukg9xlI5cyAtGmyEIzMfW//m6kXwCy2Ps9DYf5ioijFKQ8qyuscrHoY04iJGctu2Kg0Q==",
|
||||||
"dependencies": {
|
|
||||||
"argparse": "^2.0.1",
|
|
||||||
"entities": "^4.4.0",
|
|
||||||
"linkify-it": "^5.0.0",
|
|
||||||
"mdurl": "^2.0.0",
|
|
||||||
"punycode.js": "^2.3.1",
|
|
||||||
"uc.micro": "^2.1.0"
|
|
||||||
},
|
|
||||||
"bin": {
|
"bin": {
|
||||||
"markdown-it": "bin/markdown-it.mjs"
|
"marked": "bin/marked.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mdurl": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz",
|
|
||||||
"integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w=="
|
|
||||||
},
|
|
||||||
"node_modules/memoize": {
|
"node_modules/memoize": {
|
||||||
"version": "10.0.0",
|
"version": "10.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/memoize/-/memoize-10.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/memoize/-/memoize-10.0.0.tgz",
|
||||||
|
@ -11945,10 +11926,6 @@
|
||||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/nano-markdown": {
|
|
||||||
"version": "1.2.2",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/nanoid": {
|
"node_modules/nanoid": {
|
||||||
"version": "3.3.1",
|
"version": "3.3.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -12933,14 +12910,6 @@
|
||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/punycode.js": {
|
|
||||||
"version": "2.3.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz",
|
|
||||||
"integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/qrcode-generator": {
|
"node_modules/qrcode-generator": {
|
||||||
"version": "1.4.4",
|
"version": "1.4.4",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
|
@ -16080,11 +16049,6 @@
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/uc.micro": {
|
|
||||||
"version": "2.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz",
|
|
||||||
"integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A=="
|
|
||||||
},
|
|
||||||
"node_modules/ufo": {
|
"node_modules/ufo": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
|
@ -24688,14 +24652,6 @@
|
||||||
"lilconfig": {
|
"lilconfig": {
|
||||||
"version": "2.0.6"
|
"version": "2.0.6"
|
||||||
},
|
},
|
||||||
"linkify-it": {
|
|
||||||
"version": "5.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz",
|
|
||||||
"integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==",
|
|
||||||
"requires": {
|
|
||||||
"uc.micro": "^2.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"local-pkg": {
|
"local-pkg": {
|
||||||
"version": "0.4.3"
|
"version": "0.4.3"
|
||||||
},
|
},
|
||||||
|
@ -24845,23 +24801,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"markdown-it": {
|
"marked": {
|
||||||
"version": "14.1.0",
|
"version": "12.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/marked/-/marked-12.0.2.tgz",
|
||||||
"integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==",
|
"integrity": "sha512-qXUm7e/YKFoqFPYPa3Ukg9xlI5cyAtGmyEIzMfW//m6kXwCy2Ps9DYf5ioijFKQ8qyuscrHoY04iJGctu2Kg0Q=="
|
||||||
"requires": {
|
|
||||||
"argparse": "^2.0.1",
|
|
||||||
"entities": "^4.4.0",
|
|
||||||
"linkify-it": "^5.0.0",
|
|
||||||
"mdurl": "^2.0.0",
|
|
||||||
"punycode.js": "^2.3.1",
|
|
||||||
"uc.micro": "^2.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"mdurl": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz",
|
|
||||||
"integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w=="
|
|
||||||
},
|
},
|
||||||
"memoize": {
|
"memoize": {
|
||||||
"version": "10.0.0",
|
"version": "10.0.0",
|
||||||
|
@ -25098,9 +25041,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nano-markdown": {
|
|
||||||
"version": "1.2.2"
|
|
||||||
},
|
|
||||||
"nanoid": {
|
"nanoid": {
|
||||||
"version": "3.3.1"
|
"version": "3.3.1"
|
||||||
},
|
},
|
||||||
|
@ -25642,11 +25582,6 @@
|
||||||
"punycode": {
|
"punycode": {
|
||||||
"version": "2.3.0"
|
"version": "2.3.0"
|
||||||
},
|
},
|
||||||
"punycode.js": {
|
|
||||||
"version": "2.3.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz",
|
|
||||||
"integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA=="
|
|
||||||
},
|
|
||||||
"qrcode-generator": {
|
"qrcode-generator": {
|
||||||
"version": "1.4.4"
|
"version": "1.4.4"
|
||||||
},
|
},
|
||||||
|
@ -27846,11 +27781,6 @@
|
||||||
"typewise-core": {
|
"typewise-core": {
|
||||||
"version": "1.2.0"
|
"version": "1.2.0"
|
||||||
},
|
},
|
||||||
"uc.micro": {
|
|
||||||
"version": "2.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz",
|
|
||||||
"integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A=="
|
|
||||||
},
|
|
||||||
"ufo": {
|
"ufo": {
|
||||||
"version": "1.0.1"
|
"version": "1.0.1"
|
||||||
},
|
},
|
||||||
|
|
|
@ -170,7 +170,7 @@
|
||||||
"lz-string": "^1.4.4",
|
"lz-string": "^1.4.4",
|
||||||
"mangrove-reviews-typescript": "^1.1.0",
|
"mangrove-reviews-typescript": "^1.1.0",
|
||||||
"maplibre-gl": "^4.1.1",
|
"maplibre-gl": "^4.1.1",
|
||||||
"markdown-it": "^14.1.0",
|
"marked": "^12.0.2",
|
||||||
"monaco-editor": "^0.46.0",
|
"monaco-editor": "^0.46.0",
|
||||||
"opening_hours": "^3.6.0",
|
"opening_hours": "^3.6.0",
|
||||||
"osm-auth": "^2.2.0",
|
"osm-auth": "^2.2.0",
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import markdownit from "markdown-it"
|
|
||||||
import { UIEventSource } from "../../Logic/UIEventSource"
|
import { UIEventSource } from "../../Logic/UIEventSource"
|
||||||
const md = markdownit()
|
import { marked } from "marked"
|
||||||
export let src: string
|
export let src: string
|
||||||
export let srcWritable: UIEventSource<string> = undefined
|
export let srcWritable: UIEventSource<string> = undefined
|
||||||
srcWritable?.addCallbackAndRunD(t => {
|
srcWritable?.addCallbackAndRunD(t => {
|
||||||
src = t
|
src = t
|
||||||
})
|
})
|
||||||
if(typeof src !== "string") {
|
if(src !== undefined && typeof src !== "string") {
|
||||||
|
console.trace("Got a non-string object in Markdown", src)
|
||||||
throw "Markdown.svelte got a non-string object"
|
throw "Markdown.svelte got a non-string object"
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{#if src?.length > 0}
|
{#if src?.length > 0}
|
||||||
{@html md.render(src)}
|
{@html marked.parse(src)}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
import { UIEventSource } from "../../../Logic/UIEventSource"
|
import { UIEventSource } from "../../../Logic/UIEventSource"
|
||||||
import BasicTagInput from "../../Studio/TagInput/BasicTagInput.svelte"
|
import BasicTagInput from "../../Studio/TagInput/BasicTagInput.svelte"
|
||||||
import { TagUtils } from "../../../Logic/Tags/TagUtils"
|
import { TagUtils } from "../../../Logic/Tags/TagUtils"
|
||||||
import nmd from "nano-markdown"
|
|
||||||
import FromHtml from "../../Base/FromHtml.svelte"
|
import FromHtml from "../../Base/FromHtml.svelte"
|
||||||
|
import Markdown from "../../Base/Markdown.svelte"
|
||||||
export let value: UIEventSource<undefined | string>
|
export let value: UIEventSource<undefined | string>
|
||||||
export let args: string[] = []
|
export let args: string[] = []
|
||||||
let uploadableOnly: boolean = args[0] === "uploadableOnly"
|
let uploadableOnly: boolean = args[0] === "uploadableOnly"
|
||||||
|
@ -34,6 +34,6 @@
|
||||||
{#if $dropdownFocussed}
|
{#if $dropdownFocussed}
|
||||||
<div class="m-2 border border-dashed border-black p-2">
|
<div class="m-2 border border-dashed border-black p-2">
|
||||||
<b>{documentation.name}</b>
|
<b>{documentation.name}</b>
|
||||||
<FromHtml src={nmd(documentation.docs)} />
|
<Markdown src={documentation.docs} />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
import { ImmutableStore, Store } from "../../Logic/UIEventSource"
|
import { ImmutableStore, Store } from "../../Logic/UIEventSource"
|
||||||
import TagRenderingEditable from "../Popup/TagRendering/TagRenderingEditable.svelte"
|
import TagRenderingEditable from "../Popup/TagRendering/TagRenderingEditable.svelte"
|
||||||
import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig"
|
import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig"
|
||||||
import nmd from "nano-markdown"
|
|
||||||
import type { QuestionableTagRenderingConfigJson } from "../../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson.js"
|
import type { QuestionableTagRenderingConfigJson } from "../../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson.js"
|
||||||
import type { TagRenderingConfigJson } from "../../Models/ThemeConfig/Json/TagRenderingConfigJson"
|
import type { TagRenderingConfigJson } from "../../Models/ThemeConfig/Json/TagRenderingConfigJson"
|
||||||
import FromHtml from "../Base/FromHtml.svelte"
|
import FromHtml from "../Base/FromHtml.svelte"
|
||||||
import ShowConversionMessage from "./ShowConversionMessage.svelte"
|
import ShowConversionMessage from "./ShowConversionMessage.svelte"
|
||||||
import NextButton from "../Base/NextButton.svelte"
|
import NextButton from "../Base/NextButton.svelte"
|
||||||
|
import Markdown from "../Base/Markdown.svelte"
|
||||||
|
|
||||||
export let state: EditLayerState
|
export let state: EditLayerState
|
||||||
export let path: ReadonlyArray<string | number>
|
export let path: ReadonlyArray<string | number>
|
||||||
|
@ -62,13 +62,6 @@
|
||||||
let messages = state.messagesFor(path)
|
let messages = state.messagesFor(path)
|
||||||
|
|
||||||
let description = schema.description
|
let description = schema.description
|
||||||
if (description) {
|
|
||||||
try {
|
|
||||||
description = nmd(description)
|
|
||||||
} catch (e) {
|
|
||||||
console.error("Could not convert description to markdown", { description })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
|
@ -82,7 +75,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
</NextButton>
|
</NextButton>
|
||||||
{#if description}
|
{#if description}
|
||||||
<FromHtml src={description} />
|
<Markdown src={description}/>
|
||||||
{/if}
|
{/if}
|
||||||
{#each $messages as message}
|
{#each $messages as message}
|
||||||
<ShowConversionMessage {message} />
|
<ShowConversionMessage {message} />
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
import type { ConfigMeta } from "./configMeta"
|
import type { ConfigMeta } from "./configMeta"
|
||||||
import TagRenderingEditable from "../Popup/TagRendering/TagRenderingEditable.svelte"
|
import TagRenderingEditable from "../Popup/TagRendering/TagRenderingEditable.svelte"
|
||||||
import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig"
|
import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig"
|
||||||
import nmd from "nano-markdown"
|
|
||||||
import type { QuestionableTagRenderingConfigJson } from "../../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson"
|
import type { QuestionableTagRenderingConfigJson } from "../../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson"
|
||||||
import EditLayerState from "./EditLayerState"
|
import EditLayerState from "./EditLayerState"
|
||||||
import { onDestroy } from "svelte"
|
import { onDestroy } from "svelte"
|
||||||
|
@ -68,11 +67,12 @@
|
||||||
type = type.substring(0, type.length - 2)
|
type = type.substring(0, type.length - 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
const configJson: QuestionableTagRenderingConfigJson = {
|
const configJson: QuestionableTagRenderingConfigJson & {questionHintIsMd: boolean} = {
|
||||||
id: path.join("_"),
|
id: path.join("_"),
|
||||||
render: rendervalue,
|
render: rendervalue,
|
||||||
question: schema.hints.question,
|
question: schema.hints.question,
|
||||||
questionHint: nmd(schema.description),
|
questionHint: schema.description,
|
||||||
|
questionHintIsMd: true,
|
||||||
freeform:
|
freeform:
|
||||||
schema.type === "boolean"
|
schema.type === "boolean"
|
||||||
? undefined
|
? undefined
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
import { onDestroy } from "svelte"
|
import { onDestroy } from "svelte"
|
||||||
import SchemaBasedInput from "./SchemaBasedInput.svelte"
|
import SchemaBasedInput from "./SchemaBasedInput.svelte"
|
||||||
import type { JsonSchemaType } from "./jsonSchema"
|
import type { JsonSchemaType } from "./jsonSchema"
|
||||||
// @ts-ignore
|
|
||||||
import nmd from "nano-markdown"
|
|
||||||
import ShowConversionMessage from "./ShowConversionMessage.svelte"
|
import ShowConversionMessage from "./ShowConversionMessage.svelte"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import nmd from "nano-markdown"
|
|
||||||
import { createEventDispatcher } from "svelte"
|
import { createEventDispatcher } from "svelte"
|
||||||
import WalkthroughStep from "./WalkthroughStep.svelte"
|
import WalkthroughStep from "./WalkthroughStep.svelte"
|
||||||
import FromHtml from "../Base/FromHtml.svelte"
|
import FromHtml from "../Base/FromHtml.svelte"
|
||||||
|
import Markdown from "../Base/Markdown.svelte"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Markdown
|
* Markdown
|
||||||
|
@ -31,5 +31,5 @@
|
||||||
totalPages={pages.length}
|
totalPages={pages.length}
|
||||||
pageNumber={currentPage}
|
pageNumber={currentPage}
|
||||||
>
|
>
|
||||||
<FromHtml src={nmd(pages[currentPage])} />
|
<Markdown src={pages[currentPage]} />
|
||||||
</WalkthroughStep>
|
</WalkthroughStep>
|
||||||
|
|
Loading…
Reference in a new issue