From fc6d86397e8bce87ef5650af0e1df12d494d50e2 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sat, 27 Apr 2024 23:44:54 +0200 Subject: [PATCH] Remove all usages of 'nano-markdown', use centralized 'Markdown.svelte'-instead --- package-lock.json | 96 +++---------------- package.json | 2 +- src/UI/Base/Markdown.svelte | 8 +- .../Helpers/SimpleTagInput.svelte | 4 +- src/UI/Studio/QuestionPreview.svelte | 11 +-- src/UI/Studio/SchemaBasedField.svelte | 6 +- src/UI/Studio/SchemaBasedMultiType.svelte | 2 - src/UI/Walkthrough/Walkthrough.svelte | 4 +- 8 files changed, 27 insertions(+), 106 deletions(-) diff --git a/package-lock.json b/package-lock.json index 13d4999d8..782cf607c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -52,9 +52,8 @@ "lz-string": "^1.4.4", "mangrove-reviews-typescript": "^1.1.0", "maplibre-gl": "^4.1.1", - "markdown-it": "^14.1.0", + "marked": "^12.0.2", "monaco-editor": "^0.46.0", - "nano-markdown": "^1.2.2", "opening_hours": "^3.6.0", "osm-auth": "^2.2.0", "osmtogeojson": "^3.0.0-beta.5", @@ -11320,14 +11319,6 @@ "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": { "version": "0.4.3", "license": "MIT", @@ -11549,27 +11540,17 @@ "version": "2.0.0", "license": "ISC" }, - "node_modules/markdown-it": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", - "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", - "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" - }, + "node_modules/marked": { + "version": "12.0.2", + "resolved": "https://registry.npmjs.org/marked/-/marked-12.0.2.tgz", + "integrity": "sha512-qXUm7e/YKFoqFPYPa3Ukg9xlI5cyAtGmyEIzMfW//m6kXwCy2Ps9DYf5ioijFKQ8qyuscrHoY04iJGctu2Kg0Q==", "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": { "version": "10.0.0", "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_modules/nano-markdown": { - "version": "1.2.2", - "license": "MIT" - }, "node_modules/nanoid": { "version": "3.3.1", "license": "MIT", @@ -12933,14 +12910,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": { "version": "1.4.4", "license": "MIT" @@ -16080,11 +16049,6 @@ "version": "1.2.0", "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": { "version": "1.0.1", "license": "MIT" @@ -24688,14 +24652,6 @@ "lilconfig": { "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": { "version": "0.4.3" }, @@ -24845,23 +24801,10 @@ } } }, - "markdown-it": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", - "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", - "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==" + "marked": { + "version": "12.0.2", + "resolved": "https://registry.npmjs.org/marked/-/marked-12.0.2.tgz", + "integrity": "sha512-qXUm7e/YKFoqFPYPa3Ukg9xlI5cyAtGmyEIzMfW//m6kXwCy2Ps9DYf5ioijFKQ8qyuscrHoY04iJGctu2Kg0Q==" }, "memoize": { "version": "10.0.0", @@ -25098,9 +25041,6 @@ } } }, - "nano-markdown": { - "version": "1.2.2" - }, "nanoid": { "version": "3.3.1" }, @@ -25642,11 +25582,6 @@ "punycode": { "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": { "version": "1.4.4" }, @@ -27846,11 +27781,6 @@ "typewise-core": { "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": { "version": "1.0.1" }, diff --git a/package.json b/package.json index 46b4d6be3..d84fcfa44 100644 --- a/package.json +++ b/package.json @@ -170,7 +170,7 @@ "lz-string": "^1.4.4", "mangrove-reviews-typescript": "^1.1.0", "maplibre-gl": "^4.1.1", - "markdown-it": "^14.1.0", + "marked": "^12.0.2", "monaco-editor": "^0.46.0", "opening_hours": "^3.6.0", "osm-auth": "^2.2.0", diff --git a/src/UI/Base/Markdown.svelte b/src/UI/Base/Markdown.svelte index d11f6a3ca..4b91764ab 100644 --- a/src/UI/Base/Markdown.svelte +++ b/src/UI/Base/Markdown.svelte @@ -1,17 +1,17 @@ {#if src?.length > 0} - {@html md.render(src)} + {@html marked.parse(src)} {/if} diff --git a/src/UI/InputElement/Helpers/SimpleTagInput.svelte b/src/UI/InputElement/Helpers/SimpleTagInput.svelte index bee89682e..3f520250f 100644 --- a/src/UI/InputElement/Helpers/SimpleTagInput.svelte +++ b/src/UI/InputElement/Helpers/SimpleTagInput.svelte @@ -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 export let args: string[] = [] let uploadableOnly: boolean = args[0] === "uploadableOnly" @@ -34,6 +34,6 @@ {#if $dropdownFocussed}
{documentation.name} - +
{/if} diff --git a/src/UI/Studio/QuestionPreview.svelte b/src/UI/Studio/QuestionPreview.svelte index 3bcb6025f..17e4c7d28 100644 --- a/src/UI/Studio/QuestionPreview.svelte +++ b/src/UI/Studio/QuestionPreview.svelte @@ -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 @@ -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 }) - } - }
@@ -82,7 +75,7 @@ {/if} {#if description} - + {/if} {#each $messages as message} diff --git a/src/UI/Studio/SchemaBasedField.svelte b/src/UI/Studio/SchemaBasedField.svelte index ff9c56395..2102b6761 100644 --- a/src/UI/Studio/SchemaBasedField.svelte +++ b/src/UI/Studio/SchemaBasedField.svelte @@ -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 diff --git a/src/UI/Studio/SchemaBasedMultiType.svelte b/src/UI/Studio/SchemaBasedMultiType.svelte index 2df43cbc3..d23f936f7 100644 --- a/src/UI/Studio/SchemaBasedMultiType.svelte +++ b/src/UI/Studio/SchemaBasedMultiType.svelte @@ -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" /** diff --git a/src/UI/Walkthrough/Walkthrough.svelte b/src/UI/Walkthrough/Walkthrough.svelte index d3fda9f12..33d862045 100644 --- a/src/UI/Walkthrough/Walkthrough.svelte +++ b/src/UI/Walkthrough/Walkthrough.svelte @@ -1,8 +1,8 @@