Imrove Imports
This commit is contained in:
@@ -89,6 +89,26 @@ const htmlToSlate = (html: string): Descendant[] => {
|
||||
if (tag === 'em' || tag === 'i') newMarks.italic = true;
|
||||
if (tag === 'u') newMarks.underline = true;
|
||||
if (tag === 's' || tag === 'del' || tag === 'strike') newMarks.strikethrough = true;
|
||||
|
||||
// Also detect bold/italic from inline CSS styles (e.g. pasted web content)
|
||||
const style = el.getAttribute('style');
|
||||
if (style) {
|
||||
const fwMatch = style.match(/font-weight\s*:\s*([^;]+)/i);
|
||||
if (fwMatch) {
|
||||
const fw = fwMatch[1].trim().toLowerCase();
|
||||
if (fw === 'bold' || fw === 'bolder' || Number(fw) >= 600) {
|
||||
newMarks.bold = true;
|
||||
}
|
||||
}
|
||||
const fsMatch = style.match(/font-style\s*:\s*([^;]+)/i);
|
||||
if (fsMatch) {
|
||||
const fs = fsMatch[1].trim().toLowerCase();
|
||||
if (fs === 'italic' || fs === 'oblique') {
|
||||
newMarks.italic = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
el.childNodes.forEach(child => processNode(child, newMarks));
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user