From b71a169cc510991fe604144514a8840dc63a4787 Mon Sep 17 00:00:00 2001 From: KetanKBaboo Date: Thu, 14 May 2026 15:40:48 +0530 Subject: [PATCH] review changes --- frontend/src/components/OBSViewDialog.tsx | 7 ------- frontend/src/utils/obsParser.ts | 21 ++++++--------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/frontend/src/components/OBSViewDialog.tsx b/frontend/src/components/OBSViewDialog.tsx index 9a81b0e..eac2959 100644 --- a/frontend/src/components/OBSViewDialog.tsx +++ b/frontend/src/components/OBSViewDialog.tsx @@ -156,13 +156,6 @@ export const OBSViewDialog = ({ return; } - if (meta.story_no !== selectedStory.story_no) { - toast.info( - "Story number cannot be changed. You can edit only the title text.", - ); - return; - } - try { await updateMutation.mutateAsync({ resource_id: resourceId, diff --git a/frontend/src/utils/obsParser.ts b/frontend/src/utils/obsParser.ts index 9fbc44e..9934902 100644 --- a/frontend/src/utils/obsParser.ts +++ b/frontend/src/utils/obsParser.ts @@ -6,7 +6,7 @@ const ISL_HEADERS = ["storyNo", "title", "url", "description"]; // Supports: // # 1. Creation // # 1۔ تخلیق -const OBS_HEADING_REGEX = /^#+\s*(\d+)\s*[^\p{L}\p{N}]\s*(.+)$/u; +const OBS_HEADING_REGEX = /^#+\s*(\p{N}+)\s*[^\p{L}\p{N}]\s*(.+)$/u; const cleanHeader = (header: string) => header @@ -17,10 +17,7 @@ const cleanHeader = (header: string) => export const isISLOBSCSV = (headers: string[]) => ISL_HEADERS.every((h) => headers.map(cleanHeader).includes(h.toLowerCase())); -function extractHeadingData(headingLine: string): { - story_no: number; - title: string; -} { +function extractHeadingData(headingLine: string): { title: string } { const normalized = headingLine.normalize("NFC"); const match = normalized.match(OBS_HEADING_REGEX); @@ -31,10 +28,7 @@ function extractHeadingData(headingLine: string): { ); } - return { - story_no: Number(match[1]), - title: match[2].trim(), - }; + return { title: match[2].trim() }; } export function parseISLOBSCSV(file: File): Promise { @@ -69,7 +63,7 @@ export function parseISLOBSCSV(file: File): Promise { export async function parseOBSMarkdown(file: File): Promise { const content = await file.text(); - + const story_no = parseInt(file.name.replace(/\.md$/i, ""), 10); const lines = normalizeContent(content).split("\n"); const headingLine = lines.find((l) => l.trim().startsWith("#")); @@ -78,7 +72,7 @@ export async function parseOBSMarkdown(file: File): Promise { throw new Error("Invalid OBS markdown: missing heading"); } - const { story_no, title } = extractHeadingData(headingLine); + const { title } = extractHeadingData(headingLine); return { story_no, @@ -95,10 +89,7 @@ export async function parseOBSMarkdownFiles( return stories.sort((a, b) => a.story_no - b.story_no); } -export function extractOBSMetadataFromMarkdown(markdown: string): { - story_no: number; - title: string; -} { +export function extractOBSMetadataFromMarkdown(markdown: string): { title: string } { const lines = normalizeContent(markdown).split("\n"); const headingLine = lines.find((l) => l.trim().startsWith("#"));