From f98177938f03c52c1a080829d0e2a170431857f4 Mon Sep 17 00:00:00 2001 From: Administrator Date: Sat, 18 Apr 2026 19:42:47 +0800 Subject: [PATCH] =?UTF-8?q?2026-04-18-19-37-56=20-=20=E5=9B=9B=E9=A1=B9?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E4=BD=93=E9=AA=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=EF=BC=9A=E8=A7=86=E9=A2=91=E6=8C=89=E9=92=AE=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E3=80=81=E5=8D=A0=E4=BD=8D=E7=AC=A6=E6=96=87=E5=AD=97=E5=B1=85?= =?UTF-8?q?=E4=B8=AD=E3=80=81=E5=88=A0=E9=99=A4=E6=81=A2=E5=A4=8D=E5=B0=BA?= =?UTF-8?q?=E5=AF=B8=E3=80=81=E5=AE=89=E5=85=A8=E5=AF=B9=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/ReportEditor.tsx | 69 ++++++++++++---- src/pages/TemplateManage.tsx | 24 ++++-- src/utils/defaultContent.ts | 28 +++---- 工程分析/实现方案-2026-04-18-19-37-56.md | 101 +++++++++++++++++++++++ 工程分析/测试方案-2026-04-18-19-37-56.md | 48 +++++++++++ 工程分析/需求分析-2026-04-18-19-37-56.md | 29 +++++++ 6 files changed, 264 insertions(+), 35 deletions(-) create mode 100644 工程分析/实现方案-2026-04-18-19-37-56.md create mode 100644 工程分析/测试方案-2026-04-18-19-37-56.md create mode 100644 工程分析/需求分析-2026-04-18-19-37-56.md diff --git a/src/pages/ReportEditor.tsx b/src/pages/ReportEditor.tsx index 90a452b..a31d823 100644 --- a/src/pages/ReportEditor.tsx +++ b/src/pages/ReportEditor.tsx @@ -356,11 +356,24 @@ export default function ReportEditor() { const reader = new FileReader(); reader.onload = (event) => { const src = event.target?.result as string; + const mw = placeholder.style.maxWidth || placeholder.style.width || '200px'; + const mh = placeholder.style.maxHeight || placeholder.style.height || '200px'; placeholder.innerHTML = ` × - + `; placeholder.classList.add('has-image'); + placeholder.style.border = 'none'; + placeholder.style.background = 'transparent'; + placeholder.style.width = 'auto'; + placeholder.style.height = 'auto'; + placeholder.style.lineHeight = 'normal'; + placeholder.style.maxWidth = mw; + placeholder.style.maxHeight = mh; + placeholder.style.textAlign = 'left'; + placeholder.style.verticalAlign = 'top'; + placeholder.style.justifyContent = 'flex-start'; + placeholder.style.alignItems = 'flex-start'; if (editorRef.current) contentRef.current = editorRef.current.innerHTML; saveDraftToStorage(); }; @@ -409,12 +422,25 @@ export default function ReportEditor() { e.preventDefault(); if (placeholder.classList.contains('has-image')) { placeholder.classList.remove('has-image'); + const w = parseInt(placeholder.style.maxWidth || placeholder.style.width || '0'); + const text = w > 0 && w < 80 ? '插图' : '插入/点击放置图片'; placeholder.innerHTML = ` × - 插入/点击放置图片 + ${text} `; placeholder.style.border = '1px dashed #cbd5e1'; placeholder.style.background = '#f8fafc'; + const mw = placeholder.style.maxWidth; + const mh = placeholder.style.maxHeight; + if (mw) placeholder.style.width = mw; + if (mh) { + placeholder.style.height = mh; + placeholder.style.lineHeight = mh; + } + placeholder.style.textAlign = 'center'; + placeholder.style.verticalAlign = 'middle'; + placeholder.style.justifyContent = 'center'; + placeholder.style.alignItems = 'center'; if (editorRef.current) contentRef.current = editorRef.current.innerHTML; saveDraftToStorage(); } else { @@ -532,6 +558,19 @@ export default function ReportEditor() { } }; + const changeAlignment = (align: 'left' | 'center' | 'right' | 'justify') => { + const sel = window.getSelection(); + if (!sel || !sel.rangeCount) return; + let node = sel.getRangeAt(0).commonAncestorContainer; + if (node.nodeType === Node.TEXT_NODE) node = node.parentNode as Node; + const block = (node as HTMLElement).closest('p, div, td, h1, h2, h3, li'); + if (block) { + (block as HTMLElement).style.textAlign = align; + if (editorRef.current) contentRef.current = editorRef.current.innerHTML; + saveDraftToStorage(); + } + }; + const insertTable = () => { editorRef.current?.focus(); setTableModal({ isOpen: true, rows: '2', cols: '3' }); @@ -1413,9 +1452,9 @@ export default function ReportEditor() {
- - - + + +