Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f98177938f | ||
|
|
8ffb9162d3 |
@@ -356,11 +356,24 @@ export default function ReportEditor() {
|
|||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = (event) => {
|
reader.onload = (event) => {
|
||||||
const src = event.target?.result as string;
|
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.innerHTML = `
|
||||||
<span class="delete-btn" contenteditable="false">×</span>
|
<span class="delete-btn" contenteditable="false">×</span>
|
||||||
<img src="${src}" style="max-width: 100%; height: auto; display: block; margin: 0 auto;" draggable="false">
|
<img src="${src}" style="max-width:${mw};max-height:${mh};display:block;object-fit:contain;object-position:left top;" draggable="false">
|
||||||
`;
|
`;
|
||||||
placeholder.classList.add('has-image');
|
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;
|
if (editorRef.current) contentRef.current = editorRef.current.innerHTML;
|
||||||
saveDraftToStorage();
|
saveDraftToStorage();
|
||||||
};
|
};
|
||||||
@@ -409,12 +422,25 @@ export default function ReportEditor() {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (placeholder.classList.contains('has-image')) {
|
if (placeholder.classList.contains('has-image')) {
|
||||||
placeholder.classList.remove('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 = `
|
placeholder.innerHTML = `
|
||||||
<span class="delete-btn" contenteditable="false">×</span>
|
<span class="delete-btn" contenteditable="false">×</span>
|
||||||
<span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">插入/点击放置图片</span>
|
<span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);display:block;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">${text}</span>
|
||||||
`;
|
`;
|
||||||
placeholder.style.border = '1px dashed #cbd5e1';
|
placeholder.style.border = '1px dashed #cbd5e1';
|
||||||
placeholder.style.background = '#f8fafc';
|
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;
|
if (editorRef.current) contentRef.current = editorRef.current.innerHTML;
|
||||||
saveDraftToStorage();
|
saveDraftToStorage();
|
||||||
} else {
|
} 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 = () => {
|
const insertTable = () => {
|
||||||
editorRef.current?.focus();
|
editorRef.current?.focus();
|
||||||
setTableModal({ isOpen: true, rows: '2', cols: '3' });
|
setTableModal({ isOpen: true, rows: '2', cols: '3' });
|
||||||
@@ -1413,9 +1452,9 @@ export default function ReportEditor() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-1 pr-3 mr-3 border-r border-border">
|
<div className="flex gap-1 pr-3 mr-3 border-r border-border">
|
||||||
<button onClick={() => execCmd('justifyLeft')} className="w-9 h-9 flex items-center justify-center rounded-lg hover:bg-white text-text-muted hover:text-text-main transition-colors" title="左对齐"><AlignLeft size={16} /></button>
|
<button onMouseDown={(e) => e.preventDefault()} onClick={() => changeAlignment('left')} className="w-9 h-9 flex items-center justify-center rounded-lg hover:bg-white text-text-muted hover:text-text-main transition-colors" title="左对齐"><AlignLeft size={16} /></button>
|
||||||
<button onClick={() => execCmd('justifyCenter')} className="w-9 h-9 flex items-center justify-center rounded-lg hover:bg-white text-text-muted hover:text-text-main transition-colors" title="居中"><AlignCenter size={16} /></button>
|
<button onMouseDown={(e) => e.preventDefault()} onClick={() => changeAlignment('center')} className="w-9 h-9 flex items-center justify-center rounded-lg hover:bg-white text-text-muted hover:text-text-main transition-colors" title="居中"><AlignCenter size={16} /></button>
|
||||||
<button onClick={() => execCmd('justifyRight')} className="w-9 h-9 flex items-center justify-center rounded-lg hover:bg-white text-text-muted hover:text-text-main transition-colors" title="右对齐"><AlignRight size={16} /></button>
|
<button onMouseDown={(e) => e.preventDefault()} onClick={() => changeAlignment('right')} className="w-9 h-9 flex items-center justify-center rounded-lg hover:bg-white text-text-muted hover:text-text-main transition-colors" title="右对齐"><AlignRight size={16} /></button>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-1">
|
<div className="flex gap-1">
|
||||||
<button onClick={insertTable} className="w-9 h-9 flex items-center justify-center rounded-lg hover:bg-white text-text-muted hover:text-text-main transition-colors" title="表格"><Table size={16} /></button>
|
<button onClick={insertTable} className="w-9 h-9 flex items-center justify-center rounded-lg hover:bg-white text-text-muted hover:text-text-main transition-colors" title="表格"><Table size={16} /></button>
|
||||||
@@ -1821,13 +1860,6 @@ export default function ReportEditor() {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="flex gap-2 overflow-x-auto pb-2 no-scrollbar items-center">
|
<div className="flex gap-2 overflow-x-auto pb-2 no-scrollbar items-center">
|
||||||
<button
|
|
||||||
onClick={() => videoInputRef.current?.click()}
|
|
||||||
className="shrink-0 w-24 h-[68px] flex flex-col items-center justify-center gap-1 border-2 border-dashed border-border rounded-xl hover:border-accent hover:bg-slate-50 transition-all text-text-muted hover:text-accent"
|
|
||||||
>
|
|
||||||
<Video size={18} />
|
|
||||||
<span className="text-[10px] font-bold">上传视频</span>
|
|
||||||
</button>
|
|
||||||
{videos.map((v, i) => (
|
{videos.map((v, i) => (
|
||||||
<div
|
<div
|
||||||
key={v.id}
|
key={v.id}
|
||||||
@@ -1853,6 +1885,13 @@ export default function ReportEditor() {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
<button
|
||||||
|
onClick={() => videoInputRef.current?.click()}
|
||||||
|
className="shrink-0 w-24 h-[68px] flex flex-col items-center justify-center gap-1 border-2 border-dashed border-border rounded-xl hover:border-accent hover:bg-slate-50 transition-all text-text-muted hover:text-accent"
|
||||||
|
>
|
||||||
|
<Video size={18} />
|
||||||
|
<span className="text-[10px] font-bold">上传视频</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{currentVideoIndex !== -1 && videos.length > 0 && (
|
{currentVideoIndex !== -1 && videos.length > 0 && (
|
||||||
@@ -1996,14 +2035,14 @@ export default function ReportEditor() {
|
|||||||
const id = 'ph_' + Date.now();
|
const id = 'ph_' + Date.now();
|
||||||
let html: string;
|
let html: string;
|
||||||
if (inTable) {
|
if (inTable) {
|
||||||
const styleStr = 'display:flex;align-items:center;justify-content:center;border:1px dashed #cbd5e1;background:#f8fafc;cursor:pointer;width:100%;height:100%;max-width:200px;max-height:200px;min-height:60px;margin:0 auto;';
|
const styleStr = 'position:relative;display:flex;align-items:center;justify-content:center;border:1px dashed #cbd5e1;background:#f8fafc;cursor:pointer;width:100%;height:100%;max-width:200px;max-height:200px;min-height:60px;margin:0 auto;';
|
||||||
html = `<div id="${id}" class="image-placeholder" data-placeholder="true" contenteditable="false"${modeAttr} style="${styleStr}"><span class="delete-btn" contenteditable="false">×</span><span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;">${hintText}</span></div>`;
|
html = `<div id="${id}" class="image-placeholder" data-placeholder="true" contenteditable="false"${modeAttr} style="${styleStr}"><span class="delete-btn" contenteditable="false">×</span><span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);display:block;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">${hintText}</span></div>`;
|
||||||
} else {
|
} else {
|
||||||
let styleStr = 'display:inline-block;text-align:center;border:1px dashed #cbd5e1;background:#f8fafc;vertical-align:middle;margin:0 4px;cursor:pointer;position:relative;';
|
let styleStr = 'display:inline-block;text-align:center;border:1px dashed #cbd5e1;background:#f8fafc;vertical-align:middle;margin:0 4px;cursor:pointer;position:relative;';
|
||||||
styleStr += `width:${w}px;height:${h}px;max-width:${w}px;max-height:${h}px;line-height:${h}px;`;
|
styleStr += `width:${w}px;height:${h}px;max-width:${w}px;max-height:${h}px;line-height:${h}px;`;
|
||||||
const showShortText = w > 0 && w < 80;
|
const showShortText = w > 0 && w < 80;
|
||||||
const text = showShortText ? '插图' : hintText;
|
const text = showShortText ? '插图' : hintText;
|
||||||
html = `<span id="${id}" class="image-placeholder" data-placeholder="true" contenteditable="false"${modeAttr} style="${styleStr}"><span class="delete-btn" contenteditable="false">×</span><span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;display:inline-block;vertical-align:middle;line-height:normal;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">${text}</span></span>​`;
|
html = `<span id="${id}" class="image-placeholder" data-placeholder="true" contenteditable="false"${modeAttr} style="${styleStr}"><span class="delete-btn" contenteditable="false">×</span><span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);display:block;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">${text}</span></span>​`;
|
||||||
}
|
}
|
||||||
execCmd('insertHTML', html);
|
execCmd('insertHTML', html);
|
||||||
setPlaceholderModal({...placeholderModal, isOpen: false});
|
setPlaceholderModal({...placeholderModal, isOpen: false});
|
||||||
|
|||||||
@@ -385,6 +385,18 @@ export default function TemplateManage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
saveTemplateContent();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const saveTemplateContent = () => {
|
const saveTemplateContent = () => {
|
||||||
if (!currentTemplateId || !editorRef.current) return;
|
if (!currentTemplateId || !editorRef.current) return;
|
||||||
const allTemplates = storage.get<Template[]>('templates', []);
|
const allTemplates = storage.get<Template[]>('templates', []);
|
||||||
@@ -813,9 +825,9 @@ export default function TemplateManage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-1 pr-3 mr-3 border-r border-border">
|
<div className="flex gap-1 pr-3 mr-3 border-r border-border">
|
||||||
<button onMouseDown={(e) => e.preventDefault()} onClick={() => execCmd('justifyLeft')} className="w-9 h-9 flex items-center justify-center rounded-lg hover:bg-white text-text-muted hover:text-text-main transition-colors" title="左对齐"><AlignLeft size={16} /></button>
|
<button onMouseDown={(e) => e.preventDefault()} onClick={() => changeAlignment('left')} className="w-9 h-9 flex items-center justify-center rounded-lg hover:bg-white text-text-muted hover:text-text-main transition-colors" title="左对齐"><AlignLeft size={16} /></button>
|
||||||
<button onMouseDown={(e) => e.preventDefault()} onClick={() => execCmd('justifyCenter')} className="w-9 h-9 flex items-center justify-center rounded-lg hover:bg-white text-text-muted hover:text-text-main transition-colors" title="居中"><AlignCenter size={16} /></button>
|
<button onMouseDown={(e) => e.preventDefault()} onClick={() => changeAlignment('center')} className="w-9 h-9 flex items-center justify-center rounded-lg hover:bg-white text-text-muted hover:text-text-main transition-colors" title="居中"><AlignCenter size={16} /></button>
|
||||||
<button onMouseDown={(e) => e.preventDefault()} onClick={() => execCmd('justifyRight')} className="w-9 h-9 flex items-center justify-center rounded-lg hover:bg-white text-text-muted hover:text-text-main transition-colors" title="右对齐"><AlignRight size={16} /></button>
|
<button onMouseDown={(e) => e.preventDefault()} onClick={() => changeAlignment('right')} className="w-9 h-9 flex items-center justify-center rounded-lg hover:bg-white text-text-muted hover:text-text-main transition-colors" title="右对齐"><AlignRight size={16} /></button>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-1">
|
<div className="flex gap-1">
|
||||||
<button onMouseDown={(e) => e.preventDefault()} onClick={insertTable} className="w-9 h-9 flex items-center justify-center rounded-lg hover:bg-white text-text-muted hover:text-text-main transition-colors" title="插入表格"><Table size={16} /></button>
|
<button onMouseDown={(e) => e.preventDefault()} onClick={insertTable} className="w-9 h-9 flex items-center justify-center rounded-lg hover:bg-white text-text-muted hover:text-text-main transition-colors" title="插入表格"><Table size={16} /></button>
|
||||||
@@ -1363,14 +1375,14 @@ export default function TemplateManage() {
|
|||||||
const id = 'ph_' + Date.now();
|
const id = 'ph_' + Date.now();
|
||||||
let html: string;
|
let html: string;
|
||||||
if (inTable) {
|
if (inTable) {
|
||||||
const styleStr = 'display:flex;align-items:center;justify-content:center;border:1px dashed #cbd5e1;background:#f8fafc;cursor:pointer;width:100%;height:100%;max-width:200px;max-height:200px;min-height:60px;margin:0 auto;';
|
const styleStr = 'position:relative;display:flex;align-items:center;justify-content:center;border:1px dashed #cbd5e1;background:#f8fafc;cursor:pointer;width:100%;height:100%;max-width:200px;max-height:200px;min-height:60px;margin:0 auto;';
|
||||||
html = `<div id="${id}" class="image-placeholder" data-placeholder="true" contenteditable="false"${modeAttr} style="${styleStr}"><span class="delete-btn" contenteditable="false">×</span><span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;">${hintText}</span></div>`;
|
html = `<div id="${id}" class="image-placeholder" data-placeholder="true" contenteditable="false"${modeAttr} style="${styleStr}"><span class="delete-btn" contenteditable="false">×</span><span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);display:block;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">${hintText}</span></div>`;
|
||||||
} else {
|
} else {
|
||||||
let styleStr = 'display:inline-block;text-align:center;border:1px dashed #cbd5e1;background:#f8fafc;vertical-align:middle;margin:0 4px;cursor:pointer;position:relative;';
|
let styleStr = 'display:inline-block;text-align:center;border:1px dashed #cbd5e1;background:#f8fafc;vertical-align:middle;margin:0 4px;cursor:pointer;position:relative;';
|
||||||
styleStr += `width:${w}px;height:${h}px;max-width:${w}px;max-height:${h}px;line-height:${h}px;`;
|
styleStr += `width:${w}px;height:${h}px;max-width:${w}px;max-height:${h}px;line-height:${h}px;`;
|
||||||
const showShortText = w > 0 && w < 80;
|
const showShortText = w > 0 && w < 80;
|
||||||
const text = showShortText ? '插图' : hintText;
|
const text = showShortText ? '插图' : hintText;
|
||||||
html = `<span id="${id}" class="image-placeholder" data-placeholder="true" contenteditable="false"${modeAttr} style="${styleStr}"><span class="delete-btn" contenteditable="false">×</span><span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;display:inline-block;vertical-align:middle;line-height:normal;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">${text}</span></span>​`;
|
html = `<span id="${id}" class="image-placeholder" data-placeholder="true" contenteditable="false"${modeAttr} style="${styleStr}"><span class="delete-btn" contenteditable="false">×</span><span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);display:block;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">${text}</span></span>​`;
|
||||||
}
|
}
|
||||||
const wrapper = document.createElement('div');
|
const wrapper = document.createElement('div');
|
||||||
wrapper.innerHTML = html;
|
wrapper.innerHTML = html;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export const defaultReportContent = `
|
|||||||
<div style="display: flex; justify-content: center; align-items: center; gap: 12px; margin-bottom: 4px;">
|
<div style="display: flex; justify-content: center; align-items: center; gap: 12px; margin-bottom: 4px;">
|
||||||
<span class="image-placeholder" data-placeholder="true" contenteditable="false" data-mode="manual" style="position:relative;display:inline-flex;align-items:center;justify-content:center;width:65px;height:65px;border:1px dashed #cbd5e1;background:#f8fafc;vertical-align:middle;cursor:pointer;">
|
<span class="image-placeholder" data-placeholder="true" contenteditable="false" data-mode="manual" style="position:relative;display:inline-flex;align-items:center;justify-content:center;width:65px;height:65px;border:1px dashed #cbd5e1;background:#f8fafc;vertical-align:middle;cursor:pointer;">
|
||||||
<span class="delete-btn" contenteditable="false">×</span>
|
<span class="delete-btn" contenteditable="false">×</span>
|
||||||
<span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">插入图片</span>
|
<span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);display:block;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">插入图片</span>
|
||||||
</span>
|
</span>
|
||||||
<div style="text-align: center;">
|
<div style="text-align: center;">
|
||||||
<div style="font-size: 14pt; font-family: SimSun; border-bottom: 1px solid #000; padding-bottom: 0; margin-bottom: 8px; display: inline-block; line-height: 1;">西 安 交 通 大 学 第 一 附 属 医 院</div>
|
<div style="font-size: 14pt; font-family: SimSun; border-bottom: 1px solid #000; padding-bottom: 0; margin-bottom: 8px; display: inline-block; line-height: 1;">西 安 交 通 大 学 第 一 附 属 医 院</div>
|
||||||
@@ -81,46 +81,46 @@ export const defaultReportContent = `
|
|||||||
<table style="width: 100%; border-collapse: collapse; margin: 20px 0; table-layout: fixed;">
|
<table style="width: 100%; border-collapse: collapse; margin: 20px 0; table-layout: fixed;">
|
||||||
<tbody><tr>
|
<tbody><tr>
|
||||||
<td style="width: 33%; text-align: center; padding: 10px; vertical-align: top; border: 1px solid #e2e8f0;">
|
<td style="width: 33%; text-align: center; padding: 10px; vertical-align: top; border: 1px solid #e2e8f0;">
|
||||||
<div class="image-placeholder" data-placeholder="true" contenteditable="false" data-mode="frame" style="border: 1px dashed #cbd5e1; background: #f8fafc; width: 100%; height: 100%; max-width: 200px; max-height: 200px; min-height: 60px; margin: 0px auto; display: flex; align-items: center; justify-content: center; cursor: pointer;">
|
<div class="image-placeholder" data-placeholder="true" contenteditable="false" data-mode="frame" style="position:relative;border: 1px dashed #cbd5e1; background: #f8fafc; width: 100%; height: 100%; max-width: 200px; max-height: 200px; min-height: 60px; margin: 0px auto; display: flex; align-items: center; justify-content: center; cursor: pointer;">
|
||||||
<span class="delete-btn" contenteditable="false">×</span>
|
<span class="delete-btn" contenteditable="false">×</span>
|
||||||
<span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">插入/点击放置图片</span>
|
<span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);display:block;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">插入/点击放置图片</span>
|
||||||
</div>
|
</div>
|
||||||
<p style="color: #64748b; font-size: 13px; margin: 0; padding: 0; line-height: 1.5;">图A 腹腔镜探查</p>
|
<p style="color: #64748b; font-size: 13px; margin: 0; padding: 0; line-height: 1.5;">图A 腹腔镜探查</p>
|
||||||
</td>
|
</td>
|
||||||
<td style="width: 33%; text-align: center; padding: 10px; vertical-align: top; border: 1px solid #e2e8f0;">
|
<td style="width: 33%; text-align: center; padding: 10px; vertical-align: top; border: 1px solid #e2e8f0;">
|
||||||
<div class="image-placeholder" data-placeholder="true" contenteditable="false" data-mode="frame" style="border: 1px dashed #cbd5e1; background: #f8fafc; width: 100%; height: 100%; max-width: 200px; max-height: 200px; min-height: 60px; margin: 0px auto; display: flex; align-items: center; justify-content: center; cursor: pointer;">
|
<div class="image-placeholder" data-placeholder="true" contenteditable="false" data-mode="frame" style="position:relative;border: 1px dashed #cbd5e1; background: #f8fafc; width: 100%; height: 100%; max-width: 200px; max-height: 200px; min-height: 60px; margin: 0px auto; display: flex; align-items: center; justify-content: center; cursor: pointer;">
|
||||||
<span class="delete-btn" contenteditable="false">×</span>
|
<span class="delete-btn" contenteditable="false">×</span>
|
||||||
<span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">插入/点击放置图片</span>
|
<span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);display:block;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">插入/点击放置图片</span>
|
||||||
</div>
|
</div>
|
||||||
<p style="color: #64748b; font-size: 13px; margin: 0; padding: 0; line-height: 1.5;">图B 胆囊管夹闭与离断</p>
|
<p style="color: #64748b; font-size: 13px; margin: 0; padding: 0; line-height: 1.5;">图B 胆囊管夹闭与离断</p>
|
||||||
</td>
|
</td>
|
||||||
<td style="width: 33%; text-align: center; padding: 10px; vertical-align: top; border: 1px solid #e2e8f0;">
|
<td style="width: 33%; text-align: center; padding: 10px; vertical-align: top; border: 1px solid #e2e8f0;">
|
||||||
<div class="image-placeholder" data-placeholder="true" contenteditable="false" data-mode="frame" style="border: 1px dashed #cbd5e1; background: #f8fafc; width: 100%; height: 100%; max-width: 200px; max-height: 200px; min-height: 60px; margin: 0px auto; display: flex; align-items: center; justify-content: center; cursor: pointer;">
|
<div class="image-placeholder" data-placeholder="true" contenteditable="false" data-mode="frame" style="position:relative;border: 1px dashed #cbd5e1; background: #f8fafc; width: 100%; height: 100%; max-width: 200px; max-height: 200px; min-height: 60px; margin: 0px auto; display: flex; align-items: center; justify-content: center; cursor: pointer;">
|
||||||
<span class="delete-btn" contenteditable="false">×</span>
|
<span class="delete-btn" contenteditable="false">×</span>
|
||||||
<span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">插入/点击放置图片</span>
|
<span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);display:block;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">插入/点击放置图片</span>
|
||||||
</div>
|
</div>
|
||||||
<p style="color: #64748b; font-size: 13px; margin: 0; padding: 0; line-height: 1.5;">图C 胆囊动脉夹闭与离断</p>
|
<p style="color: #64748b; font-size: 13px; margin: 0; padding: 0; line-height: 1.5;">图C 胆囊动脉夹闭与离断</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width: 33%; text-align: center; padding: 10px; vertical-align: top; border: 1px solid #e2e8f0;">
|
<td style="width: 33%; text-align: center; padding: 10px; vertical-align: top; border: 1px solid #e2e8f0;">
|
||||||
<div class="image-placeholder" data-placeholder="true" contenteditable="false" data-mode="frame" style="border: 1px dashed #cbd5e1; background: #f8fafc; width: 100%; height: 100%; max-width: 200px; max-height: 200px; min-height: 60px; margin: 0px auto; display: flex; align-items: center; justify-content: center; cursor: pointer;">
|
<div class="image-placeholder" data-placeholder="true" contenteditable="false" data-mode="frame" style="position:relative;border: 1px dashed #cbd5e1; background: #f8fafc; width: 100%; height: 100%; max-width: 200px; max-height: 200px; min-height: 60px; margin: 0px auto; display: flex; align-items: center; justify-content: center; cursor: pointer;">
|
||||||
<span class="delete-btn" contenteditable="false">×</span>
|
<span class="delete-btn" contenteditable="false">×</span>
|
||||||
<span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">插入/点击放置图片</span>
|
<span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);display:block;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">插入/点击放置图片</span>
|
||||||
</div>
|
</div>
|
||||||
<p style="color: #64748b; font-size: 13px; margin: 0; padding: 0; line-height: 1.5;">图D 胆囊剥离与床面止血</p>
|
<p style="color: #64748b; font-size: 13px; margin: 0; padding: 0; line-height: 1.5;">图D 胆囊剥离与床面止血</p>
|
||||||
</td>
|
</td>
|
||||||
<td style="width: 33%; text-align: center; padding: 10px; vertical-align: top; border: 1px solid #e2e8f0;">
|
<td style="width: 33%; text-align: center; padding: 10px; vertical-align: top; border: 1px solid #e2e8f0;">
|
||||||
<div class="image-placeholder" data-placeholder="true" contenteditable="false" data-mode="frame" style="border: 1px dashed #cbd5e1; background: #f8fafc; width: 100%; height: 100%; max-width: 200px; max-height: 200px; min-height: 60px; margin: 0px auto; display: flex; align-items: center; justify-content: center; cursor: pointer;">
|
<div class="image-placeholder" data-placeholder="true" contenteditable="false" data-mode="frame" style="position:relative;border: 1px dashed #cbd5e1; background: #f8fafc; width: 100%; height: 100%; max-width: 200px; max-height: 200px; min-height: 60px; margin: 0px auto; display: flex; align-items: center; justify-content: center; cursor: pointer;">
|
||||||
<span class="delete-btn" contenteditable="false">×</span>
|
<span class="delete-btn" contenteditable="false">×</span>
|
||||||
<span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">插入/点击放置图片</span>
|
<span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);display:block;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">插入/点击放置图片</span>
|
||||||
</div>
|
</div>
|
||||||
<p style="color: #64748b; font-size: 13px; margin: 0; padding: 0; line-height: 1.5;">图E 胆囊取出与钛夹确认</p>
|
<p style="color: #64748b; font-size: 13px; margin: 0; padding: 0; line-height: 1.5;">图E 胆囊取出与钛夹确认</p>
|
||||||
</td>
|
</td>
|
||||||
<td style="width: 33%; text-align: center; padding: 10px; vertical-align: top; border: 1px solid #e2e8f0;">
|
<td style="width: 33%; text-align: center; padding: 10px; vertical-align: top; border: 1px solid #e2e8f0;">
|
||||||
<div class="image-placeholder" data-placeholder="true" contenteditable="false" data-mode="frame" style="border: 1px dashed #cbd5e1; background: #f8fafc; width: 100%; height: 100%; max-width: 200px; max-height: 200px; min-height: 60px; margin: 0px auto; display: flex; align-items: center; justify-content: center; cursor: pointer;">
|
<div class="image-placeholder" data-placeholder="true" contenteditable="false" data-mode="frame" style="position:relative;border: 1px dashed #cbd5e1; background: #f8fafc; width: 100%; height: 100%; max-width: 200px; max-height: 200px; min-height: 60px; margin: 0px auto; display: flex; align-items: center; justify-content: center; cursor: pointer;">
|
||||||
<span class="delete-btn" contenteditable="false">×</span>
|
<span class="delete-btn" contenteditable="false">×</span>
|
||||||
<span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">插入/点击放置图片</span>
|
<span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);display:block;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">插入/点击放置图片</span>
|
||||||
</div>
|
</div>
|
||||||
<p style="color: #64748b; font-size: 13px; margin: 0; padding: 0; line-height: 1.5;">图F 止血材料覆盖及检查</p>
|
<p style="color: #64748b; font-size: 13px; margin: 0; padding: 0; line-height: 1.5;">图F 止血材料覆盖及检查</p>
|
||||||
</td>
|
</td>
|
||||||
@@ -145,7 +145,7 @@ export const defaultReportContent = `
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p style="text-align: right; font-family: SimSun; font-size: 12pt; line-height: 1.5; margin: 0; padding: 0; white-space: nowrap;">
|
<p style="text-align: right; font-family: SimSun; font-size: 12pt; line-height: 1.5; margin: 0; padding: 0; white-space: nowrap;">
|
||||||
手术者签名:<span class="image-placeholder" data-placeholder="true" contenteditable="false" data-mode="manual" style="display:inline-block;text-align:center;width:200px;height:40px;line-height:40px;border:1px dashed #cbd5e1;background:#f8fafc;vertical-align:middle;margin:0 4px;cursor:pointer;position:relative;"><span class="delete-btn" contenteditable="false">×</span><span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;display:inline-block;vertical-align:middle;line-height:normal;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">插入/点击放置图片</span></span>
|
手术者签名:<span class="image-placeholder" data-placeholder="true" contenteditable="false" data-mode="manual" style="display:inline-block;text-align:center;width:200px;height:40px;line-height:40px;border:1px dashed #cbd5e1;background:#f8fafc;vertical-align:middle;margin:0 4px;cursor:pointer;position:relative;"><span class="delete-btn" contenteditable="false">×</span><span class="placeholder-text" style="color:#94a3b8;font-size:11px;pointer-events:none;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);display:block;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">插入/点击放置图片</span></span>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p style="margin: 0; padding: 0; line-height: 1.5;"> </p>
|
<p style="margin: 0; padding: 0; line-height: 1.5;"> </p>
|
||||||
|
|||||||
101
工程分析/实现方案-2026-04-18-19-37-56.md
Normal file
101
工程分析/实现方案-2026-04-18-19-37-56.md
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
# 实现方案 —— 2026-04-18-19-37-56
|
||||||
|
|
||||||
|
## 方案目标
|
||||||
|
修复编辑器中的 4 个体验问题,提升视频面板、图片占位符和对齐功能的稳定性。
|
||||||
|
|
||||||
|
## 需求 1:视频上传按钮位置调整
|
||||||
|
|
||||||
|
### 修改文件
|
||||||
|
`src/pages/ReportEditor.tsx`
|
||||||
|
|
||||||
|
### 修改内容
|
||||||
|
在「视频分析」面板的缩略图滚动容器中,将 `<button>上传视频</button>` 从 `videos.map()` 之前移至之后。保持按钮样式和点击逻辑不变。
|
||||||
|
|
||||||
|
## 需求 2:图片占位符提示文字绝对居中
|
||||||
|
|
||||||
|
### 修改文件
|
||||||
|
`src/pages/ReportEditor.tsx`、`src/pages/TemplateManage.tsx`、`src/utils/defaultContent.ts`
|
||||||
|
|
||||||
|
### 修改内容
|
||||||
|
将 `.placeholder-text` 的样式改为绝对定位居中:
|
||||||
|
```css
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
```
|
||||||
|
|
||||||
|
需要确保 `.image-placeholder` 父容器带有 `position: relative;`(默认模板和运行时插入逻辑中已具备)。
|
||||||
|
|
||||||
|
修改位置:
|
||||||
|
1. `defaultContent.ts` 中 8 个占位符的 `.placeholder-text` style
|
||||||
|
2. `ReportEditor.tsx` 中 `placeholderModal` 确认插入时的 `.placeholder-text` style
|
||||||
|
3. `TemplateManage.tsx` 中 `placeholderModal` 确认插入时的 `.placeholder-text` style
|
||||||
|
4. `ReportEditor.tsx` 和 `TemplateManage.tsx` 中 `handleEditorClick` 删除图片后重建 `.placeholder-text` 的 innerHTML
|
||||||
|
|
||||||
|
## 需求 3:删除图片后占位符恢复原始大小
|
||||||
|
|
||||||
|
### 修改文件
|
||||||
|
`src/pages/ReportEditor.tsx`、`src/pages/TemplateManage.tsx`
|
||||||
|
|
||||||
|
### 修改内容
|
||||||
|
在 `handleEditorClick` 中处理 `.delete-btn` 点击、恢复占位符为空的逻辑中,增加尺寸恢复:
|
||||||
|
```ts
|
||||||
|
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';
|
||||||
|
```
|
||||||
|
|
||||||
|
同时需要恢复其他被修改的样式:
|
||||||
|
- `border: 1px dashed #cbd5e1`
|
||||||
|
- `background: #f8fafc`
|
||||||
|
- `vertical-align: middle`(inline-block 占位符)
|
||||||
|
- `justify-content: center; align-items: center`(flex 占位符)
|
||||||
|
|
||||||
|
由于无法直接区分 flex 和 inline-block,可以通过检查 `placeholder.style.display` 或简单地将 `justifyContent` 和 `alignItems` 重置为 `center`(对 inline-block 无影响)。
|
||||||
|
|
||||||
|
## 需求 4:对齐按钮改用安全的 DOM 操作
|
||||||
|
|
||||||
|
### 修改文件
|
||||||
|
`src/pages/ReportEditor.tsx`、`src/pages/TemplateManage.tsx`
|
||||||
|
|
||||||
|
### 修改内容
|
||||||
|
1. **新增 `changeAlignment` 方法**:
|
||||||
|
```ts
|
||||||
|
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, h4, h5, h6, li');
|
||||||
|
if (block) {
|
||||||
|
(block as HTMLElement).style.textAlign = align;
|
||||||
|
if (editorRef.current) {
|
||||||
|
contentRef.current = editorRef.current.innerHTML;
|
||||||
|
saveDraftToStorage(); // ReportEditor
|
||||||
|
// saveTemplateContent(); // TemplateManage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **替换工具栏按钮**:将三个对齐按钮的 `onClick={() => execCmd('justifyLeft')}` 等替换为 `onClick={() => changeAlignment('left')}` 等。保留 `onMouseDown={(e) => e.preventDefault()}` 以防止编辑器失焦。
|
||||||
|
|
||||||
|
## 涉及文件及修改点
|
||||||
|
| 文件 | 修改点 |
|
||||||
|
|------|--------|
|
||||||
|
| `src/pages/ReportEditor.tsx` | 视频按钮位置;placeholder-text 样式(3 处:插入、删除恢复、Modal);删除恢复时尺寸复原;新增 changeAlignment;替换对齐按钮 |
|
||||||
|
| `src/pages/TemplateManage.tsx` | placeholder-text 样式(3 处);删除恢复时尺寸复原;新增 changeAlignment;替换对齐按钮 |
|
||||||
|
| `src/utils/defaultContent.ts` | 8 个占位符的 placeholder-text 样式更新为绝对居中 |
|
||||||
|
|
||||||
|
## 风险与注意事项
|
||||||
|
1. `changeAlignment` 中 `closest('p, div, ...')` 如果选中了编辑器根容器(`contenteditable` div),可能会对齐整个文档。但由于工具栏按钮要求编辑器已聚焦,通常选区在正文内部,风险较低。
|
||||||
|
2. 占位符删除恢复时,`maxWidth`/`maxHeight` 的回退逻辑需确保在所有场景下(默认模板、运行时插入)都能正确读取。
|
||||||
|
3. 绝对居中的 `position:absolute` 需要父容器 `position:relative`,需验证所有占位符均满足。
|
||||||
48
工程分析/测试方案-2026-04-18-19-37-56.md
Normal file
48
工程分析/测试方案-2026-04-18-19-37-56.md
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# 测试方案 —— 2026-04-18-19-37-56
|
||||||
|
|
||||||
|
## 测试目标
|
||||||
|
验证 4 项编辑器体验修复的正确性和稳定性。
|
||||||
|
|
||||||
|
## 测试用例
|
||||||
|
|
||||||
|
### TC-1:视频上传按钮位于列表末尾
|
||||||
|
**前置条件**:已上传至少一个视频。
|
||||||
|
**步骤**:
|
||||||
|
1. 切换到「视频分析」Tab。
|
||||||
|
**预期结果**:
|
||||||
|
- 视频缩略图列表中,已有视频在前,「上传视频」按钮在最后。
|
||||||
|
- 点击上传按钮可正常打开文件选择器。
|
||||||
|
|
||||||
|
### TC-2:图片占位符提示文字绝对居中
|
||||||
|
**前置条件**:默认模板已加载。
|
||||||
|
**步骤**:
|
||||||
|
1. 查看顶部 Logo 占位符和表格内图片占位符。
|
||||||
|
**预期结果**:
|
||||||
|
- 「插入图片」或「插入/点击放置图片」文字在占位框正中心,不偏上也不偏下。
|
||||||
|
- 占位符高度不同时(65px vs 200px),文字始终居中。
|
||||||
|
|
||||||
|
### TC-3:删除图片后占位符恢复原始大小
|
||||||
|
**前置条件**:模板中有 200×200 的图片占位符,已插入图片。
|
||||||
|
**步骤**:
|
||||||
|
1. 点击图片上的「×」删除按钮。
|
||||||
|
**预期结果**:
|
||||||
|
- 占位符恢复为虚线框,宽度恢复为 200px,高度恢复为 200px。
|
||||||
|
- 提示文字居中显示。
|
||||||
|
- 占位符仍可重新插入图片。
|
||||||
|
|
||||||
|
### TC-4:对齐按钮不破坏混合排版
|
||||||
|
**前置条件**:默认模板已加载,「手术者签名:」行包含文字和签名占位符。
|
||||||
|
**步骤**:
|
||||||
|
1. 将光标放在「手术者签名:」这一行。
|
||||||
|
2. 分别点击「左对齐」「居中」「右对齐」按钮。
|
||||||
|
**预期结果**:
|
||||||
|
- 整行(文字 + 占位符)作为一个整体对齐,不会换行分离。
|
||||||
|
- `.field-value` 所在行同样适用,对齐时不破坏字段与文字的同行关系。
|
||||||
|
|
||||||
|
## 回归测试
|
||||||
|
- 确保视频上传、播放、关键帧摘取功能正常。
|
||||||
|
- 确保图片占位符的插入、拖拽、自动帧填充功能正常。
|
||||||
|
- 确保打印样式正常,图片和字段显示正确。
|
||||||
|
|
||||||
|
## 测试通过标准
|
||||||
|
所有用例均通过,无控制台报错,排版结构完整。
|
||||||
30
工程分析/经验记录.md
30
工程分析/经验记录.md
@@ -971,3 +971,33 @@ if ((settings.autoInsertDelay || 0) > 0) {
|
|||||||
- 当为 `image-placeholder` 修改填充后的样式行为时,必须同步检索所有填充入口(`fillPlaceholderSrc`、`fillPlaceholder`、自动帧插入、拖拽填充等),并同步到 `TemplateManage.tsx`。
|
- 当为 `image-placeholder` 修改填充后的样式行为时,必须同步检索所有填充入口(`fillPlaceholderSrc`、`fillPlaceholder`、自动帧插入、拖拽填充等),并同步到 `TemplateManage.tsx`。
|
||||||
- 右侧表单字段容器样式如果统一(如高亮背景),应在所有字段类型的渲染分支中同步添加,避免某些类型遗漏。
|
- 右侧表单字段容器样式如果统一(如高亮背景),应在所有字段类型的渲染分支中同步添加,避免某些类型遗漏。
|
||||||
- 默认模板修改后应通过「新建报告 → 检查 DOM 结构」快速验证。
|
- 默认模板修改后应通过「新建报告 → 检查 DOM 结构」快速验证。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 记录 32:视频分析模块空白修复与图片占位符自适应逻辑重构
|
||||||
|
|
||||||
|
**A. 具体问题**
|
||||||
|
1. 上一轮优化中将「上传视频」按钮移入了 `videos.length > 0` 条件渲染内部,导致无视频时整个「视频分析」面板空白,用户无法上传第一个视频。
|
||||||
|
2. 图片占位符填充后仅将 `height` 设为 `auto`,但宽度仍保持预设值(如 200px),导致图片周围有大量空白,用户希望占位符能紧缩包围图片。
|
||||||
|
|
||||||
|
**B. 产生问题原因**
|
||||||
|
1. **视频按钮位置错误**:重构视频面板时,将上传按钮和缩略图列表全部包裹在 `{videos.length > 0 && (...)}` 中,未意识到上传按钮必须始终可见。
|
||||||
|
2. **占位符尺寸逻辑不完整**:此前仅将 `height` 改为 `auto`,未同步处理 `width`,也未利用 `max-width`/`max-height` 作为硬限制来实现等比例缩放。
|
||||||
|
|
||||||
|
**C. 解决问题方案**
|
||||||
|
1. **修复视频面板**:将上传按钮和缩略图列表移出 `videos.length > 0` 条件,使其始终渲染;仅保留视频播放器和关键帧网格在 `{currentVideoIndex !== -1 && videos.length > 0 && (...)}` 中条件渲染。注意:移出后需同步删除对应的 `</div>)}` 关闭标签,否则会导致 JSX 结构不匹配(esbuild 报错「Unexpected closing tag」)。
|
||||||
|
2. **重构占位符尺寸逻辑**:
|
||||||
|
- **插入时**:在 `placeholderModal` 确认插入的 `styleStr` 中,为 inline-block 占位符追加 `max-width:${w}px;max-height:${h}px;`(表格内占位符原本就有)。
|
||||||
|
- **填充时**:在 `fillPlaceholderSrc`、`fillPlaceholder`、`autoCaptureFrames`(ReportEditor)和 `fillPlaceholderSrc`(TemplateManage)中统一执行以下步骤:
|
||||||
|
- 读取 `placeholder.style.maxWidth || placeholder.style.width` 和 `placeholder.style.maxHeight || placeholder.style.height` 作为硬限制值 `mw` / `mh`
|
||||||
|
- 将 `<img>` 的 style 设为 `max-width:${mw};max-height:${mh};display:block;object-fit:contain;object-position:left top;`
|
||||||
|
- 将占位符外壳设为 `width:auto;height:auto;line-height:normal;max-width:${mw};max-height:${mh};text-align:left;vertical-align:top;justify-content:flex-start;align-items:flex-start;`
|
||||||
|
- 这样,小图片会 shrink-wrap 到实际尺寸,大图片会等比例缩小到限制范围内,且靠左上方放置。
|
||||||
|
|
||||||
|
**D. 后续如何避免问题**
|
||||||
|
- 重构条件渲染的 JSX 结构时,必须仔细核对打开和关闭标签的数量和层级。建议使用编辑器格式化或 build 工具(如 esbuild)立即验证。
|
||||||
|
- `image-placeholder` 的尺寸逻辑涉及「创建时预设」和「填充后自适应」两个阶段,修改时必须同时考虑:
|
||||||
|
- 创建时是否写入了 `max-width`/`max-height`
|
||||||
|
- 填充时是否正确读取并应用这些限制值
|
||||||
|
- 所有填充入口(本地上传、签名插入、系统素材、自动帧插入、拖拽填充)是否同步更新
|
||||||
|
- 默认模板中的占位符如果没有 `max-width`/`max-height`,回退逻辑 `|| placeholder.style.width` 仍能正确获取限制值,但后续修改默认模板时应注意统一添加 `max-width`/`max-height` 以显式声明意图。
|
||||||
|
|||||||
29
工程分析/需求分析-2026-04-18-19-37-56.md
Normal file
29
工程分析/需求分析-2026-04-18-19-37-56.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# 需求分析 —— 2026-04-18-19-37-56
|
||||||
|
|
||||||
|
## 需求来源
|
||||||
|
用户在实际使用中发现 4 个编辑器体验问题,要求进行修复和优化。
|
||||||
|
|
||||||
|
## 需求概述
|
||||||
|
|
||||||
|
### 需求 1:视频上传按钮位置调整
|
||||||
|
在 `ReportEditor` 的「视频分析」面板中,「上传视频」按钮当前位于视频缩略图列表的首位。用户希望将其移至列表末尾,以符合「先列出已有视频,最后提供添加操作」的操作直觉。
|
||||||
|
|
||||||
|
### 需求 2:图片占位符提示文字绝对居中
|
||||||
|
图片占位符(`.image-placeholder`)内的提示文字(如「插入/点击放置图片」)目前未在框中绝对居中。当占位符高度较大或行高不一时,文字会偏上或偏下。用户希望文字在占位符内绝对居中显示。
|
||||||
|
|
||||||
|
### 需求 3:删除图片后占位符恢复原始大小
|
||||||
|
当向图片占位符插入图片后,占位符会收缩到图片实际尺寸(`width:auto; height:auto`)。但点击「×」删除图片后,占位符不会恢复为原始预设大小,而是保持收缩后的尺寸。用户希望删除后占位符能恢复为最初创建时的宽度和高度。
|
||||||
|
|
||||||
|
### 需求 4:对齐按钮导致混合排版换行
|
||||||
|
点击富文本工具栏的「左对齐/居中/右对齐」按钮时,浏览器原生的 `document.execCommand('justifyLeft')` 等命令会粗暴地用 `<div align="left">` 包裹选区,导致包含 `.field-value` 或 `.image-placeholder` 的段落被肢解,文字与输入框/图片强制换行分离。用户希望对齐操作安全地作用于整个段落,不破坏混合排版结构。
|
||||||
|
|
||||||
|
## 涉及文件
|
||||||
|
- `src/pages/ReportEditor.tsx`(需求 1、2、3、4)
|
||||||
|
- `src/pages/TemplateManage.tsx`(需求 2、3、4)
|
||||||
|
- `src/utils/defaultContent.ts`(需求 2、3)
|
||||||
|
|
||||||
|
## 需求影响范围
|
||||||
|
- 视频分析面板布局
|
||||||
|
- 图片占位符的视觉表现和交互反馈
|
||||||
|
- 富文本对齐功能的实现方式
|
||||||
|
- 默认模板中占位符的 HTML 结构
|
||||||
Reference in New Issue
Block a user