chore: address requested changes

This commit is contained in:
Elian Doran
2026-03-28 12:17:18 +02:00
parent 7f6a43c2fa
commit b4802e9abf
3 changed files with 11 additions and 7 deletions

View File

@@ -180,6 +180,10 @@ function createMockExpressResponse() {
res._headers[name] = value;
return res;
},
removeHeader(name: string) {
delete res._headers[name];
return res;
},
status(code: number) {
res._status = code;
return res;

View File

@@ -20,7 +20,7 @@ export default function FormRadioGroup({ values, ...restProps }: FormRadioProps)
if (!el) return null;
const { value, label, inlineDescription } = el;
return (
<div className="form-checkbox">
<div className="form-checkbox" key={value}>
<FormRadio
value={value}
label={label} inlineDescription={inlineDescription}
@@ -40,7 +40,7 @@ export function FormInlineRadioGroup({ values, ...restProps }: FormRadioProps) {
{values.map((el) => {
if (!el) return null;
const { value, label, inlineDescription } = el;
return <FormRadio value={value} label={label} inlineDescription={inlineDescription} {...restProps} />;
return <FormRadio key={value} value={value} label={label} inlineDescription={inlineDescription} {...restProps} />;
})}
</div>
);

View File

@@ -4,12 +4,12 @@ import { RenderMarkdownResponse, ToMarkdownResponse } from "@triliumnext/commons
import type { Request } from "express";
import markdown from "../../services/export/markdown.js";
import { markdownImportService } from "../..";
import { markdownImportService, ValidationError } from "../..";
function renderMarkdown(req: Request) {
const { markdownContent } = req.body;
if (!markdownContent || typeof markdownContent !== 'string') {
throw new Error('markdownContent parameter is required and must be a string');
if (typeof markdownContent !== 'string') {
throw new ValidationError('markdownContent parameter is required and must be a string');
}
return {
htmlContent: markdownImportService.renderToHtml(markdownContent, "")
@@ -18,8 +18,8 @@ function renderMarkdown(req: Request) {
function toMarkdown(req: Request) {
const { htmlContent } = req.body;
if (!htmlContent || typeof htmlContent !== 'string') {
throw new Error('htmlContent parameter is required and must be a string');
if (typeof htmlContent !== 'string') {
throw new ValidationError('htmlContent parameter is required and must be a string');
}
return {
markdownContent: markdown.toMarkdown(htmlContent)