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
|
@ -1,17 +1,17 @@
|
|||
<script lang="ts">
|
||||
import markdownit from "markdown-it"
|
||||
import { UIEventSource } from "../../Logic/UIEventSource"
|
||||
const md = markdownit()
|
||||
import { marked } from "marked"
|
||||
export let src: string
|
||||
export let srcWritable: UIEventSource<string> = undefined
|
||||
srcWritable?.addCallbackAndRunD(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"
|
||||
}
|
||||
</script>
|
||||
{#if src?.length > 0}
|
||||
{@html md.render(src)}
|
||||
{@html marked.parse(src)}
|
||||
{/if}
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
import { UIEventSource } from "../../../Logic/UIEventSource"
|
||||
import BasicTagInput from "../../Studio/TagInput/BasicTagInput.svelte"
|
||||
import { TagUtils } from "../../../Logic/Tags/TagUtils"
|
||||
import nmd from "nano-markdown"
|
||||
import FromHtml from "../../Base/FromHtml.svelte"
|
||||
import Markdown from "../../Base/Markdown.svelte"
|
||||
export let value: UIEventSource<undefined | string>
|
||||
export let args: string[] = []
|
||||
let uploadableOnly: boolean = args[0] === "uploadableOnly"
|
||||
|
@ -34,6 +34,6 @@
|
|||
{#if $dropdownFocussed}
|
||||
<div class="m-2 border border-dashed border-black p-2">
|
||||
<b>{documentation.name}</b>
|
||||
<FromHtml src={nmd(documentation.docs)} />
|
||||
<Markdown src={documentation.docs} />
|
||||
</div>
|
||||
{/if}
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
import { ImmutableStore, Store } from "../../Logic/UIEventSource"
|
||||
import TagRenderingEditable from "../Popup/TagRendering/TagRenderingEditable.svelte"
|
||||
import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig"
|
||||
import nmd from "nano-markdown"
|
||||
import type { QuestionableTagRenderingConfigJson } from "../../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson.js"
|
||||
import type { TagRenderingConfigJson } from "../../Models/ThemeConfig/Json/TagRenderingConfigJson"
|
||||
import FromHtml from "../Base/FromHtml.svelte"
|
||||
import ShowConversionMessage from "./ShowConversionMessage.svelte"
|
||||
import NextButton from "../Base/NextButton.svelte"
|
||||
import Markdown from "../Base/Markdown.svelte"
|
||||
|
||||
export let state: EditLayerState
|
||||
export let path: ReadonlyArray<string | number>
|
||||
|
@ -62,13 +62,6 @@
|
|||
let messages = state.messagesFor(path)
|
||||
|
||||
let description = schema.description
|
||||
if (description) {
|
||||
try {
|
||||
description = nmd(description)
|
||||
} catch (e) {
|
||||
console.error("Could not convert description to markdown", { description })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex">
|
||||
|
@ -82,7 +75,7 @@
|
|||
{/if}
|
||||
</NextButton>
|
||||
{#if description}
|
||||
<FromHtml src={description} />
|
||||
<Markdown src={description}/>
|
||||
{/if}
|
||||
{#each $messages as message}
|
||||
<ShowConversionMessage {message} />
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
import type { ConfigMeta } from "./configMeta"
|
||||
import TagRenderingEditable from "../Popup/TagRendering/TagRenderingEditable.svelte"
|
||||
import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig"
|
||||
import nmd from "nano-markdown"
|
||||
import type { QuestionableTagRenderingConfigJson } from "../../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson"
|
||||
import EditLayerState from "./EditLayerState"
|
||||
import { onDestroy } from "svelte"
|
||||
|
@ -68,11 +67,12 @@
|
|||
type = type.substring(0, type.length - 2)
|
||||
}
|
||||
|
||||
const configJson: QuestionableTagRenderingConfigJson = {
|
||||
const configJson: QuestionableTagRenderingConfigJson & {questionHintIsMd: boolean} = {
|
||||
id: path.join("_"),
|
||||
render: rendervalue,
|
||||
question: schema.hints.question,
|
||||
questionHint: nmd(schema.description),
|
||||
questionHint: schema.description,
|
||||
questionHintIsMd: true,
|
||||
freeform:
|
||||
schema.type === "boolean"
|
||||
? undefined
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
import { onDestroy } from "svelte"
|
||||
import SchemaBasedInput from "./SchemaBasedInput.svelte"
|
||||
import type { JsonSchemaType } from "./jsonSchema"
|
||||
// @ts-ignore
|
||||
import nmd from "nano-markdown"
|
||||
import ShowConversionMessage from "./ShowConversionMessage.svelte"
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<script lang="ts">
|
||||
import nmd from "nano-markdown"
|
||||
import { createEventDispatcher } from "svelte"
|
||||
import WalkthroughStep from "./WalkthroughStep.svelte"
|
||||
import FromHtml from "../Base/FromHtml.svelte"
|
||||
import Markdown from "../Base/Markdown.svelte"
|
||||
|
||||
/**
|
||||
* Markdown
|
||||
|
@ -31,5 +31,5 @@
|
|||
totalPages={pages.length}
|
||||
pageNumber={currentPage}
|
||||
>
|
||||
<FromHtml src={nmd(pages[currentPage])} />
|
||||
<Markdown src={pages[currentPage]} />
|
||||
</WalkthroughStep>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue