Preserve QPowerPoint strikethrough in PPTX
This commit is contained in:
@@ -18,6 +18,7 @@ interface SlideTextBlock {
|
||||
bold?: boolean;
|
||||
italics?: boolean;
|
||||
underline?: boolean;
|
||||
strike?: boolean;
|
||||
color?: string;
|
||||
fontSize?: number;
|
||||
fontFamily?: string;
|
||||
@@ -105,12 +106,14 @@ export async function importPptxFile(file: File): Promise<ImportedPowerPointDeck
|
||||
titleBold: slideTextBlocks[0]?.bold ?? false,
|
||||
...(slideTextBlocks[0]?.italics ? { titleItalics: true } : {}),
|
||||
...(slideTextBlocks[0]?.underline ? { titleUnderline: true } : {}),
|
||||
...(slideTextBlocks[0]?.strike ? { titleStrike: true } : {}),
|
||||
...(slideTextBlocks[0]?.color ? { titleColor: slideTextBlocks[0].color } : {}),
|
||||
...(slideTextBlocks[0]?.fontSize ? { titleFontSize: slideTextBlocks[0].fontSize } : {}),
|
||||
...(slideTextBlocks[0]?.fontFamily ? { titleFontFamily: slideTextBlocks[0].fontFamily } : {}),
|
||||
...(slideTextBlocks[1]?.bold ? { subtitleBold: true } : {}),
|
||||
...(slideTextBlocks[1]?.italics ? { subtitleItalics: true } : {}),
|
||||
...(slideTextBlocks[1]?.underline ? { subtitleUnderline: true } : {}),
|
||||
...(slideTextBlocks[1]?.strike ? { subtitleStrike: true } : {}),
|
||||
...(slideTextBlocks[1]?.color ? { subtitleColor: slideTextBlocks[1].color } : {}),
|
||||
...(slideTextBlocks[1]?.fontSize ? { subtitleFontSize: slideTextBlocks[1].fontSize } : {}),
|
||||
...(slideTextBlocks[1]?.fontFamily ? { subtitleFontFamily: slideTextBlocks[1].fontFamily } : {}),
|
||||
@@ -159,9 +162,11 @@ export async function exportPptxBlob(deck: ExportablePowerPointDeck): Promise<Bl
|
||||
const titleBold = sourceSlide.titleBold ?? true;
|
||||
const titleItalics = Boolean(sourceSlide.titleItalics);
|
||||
const titleUnderline = Boolean(sourceSlide.titleUnderline);
|
||||
const titleStrike = Boolean(sourceSlide.titleStrike);
|
||||
const subtitleBold = Boolean(sourceSlide.subtitleBold);
|
||||
const subtitleItalics = Boolean(sourceSlide.subtitleItalics);
|
||||
const subtitleUnderline = Boolean(sourceSlide.subtitleUnderline);
|
||||
const subtitleStrike = Boolean(sourceSlide.subtitleStrike);
|
||||
const titleHyperlink = normalizedExternalHyperlinkTarget(sourceSlide.titleHyperlink);
|
||||
const subtitleHyperlink = normalizedExternalHyperlinkTarget(sourceSlide.subtitleHyperlink);
|
||||
const slide = pptx.addSlide();
|
||||
@@ -193,6 +198,7 @@ export async function exportPptxBlob(deck: ExportablePowerPointDeck): Promise<Bl
|
||||
bold: titleBold,
|
||||
italic: titleItalics,
|
||||
...(titleUnderline ? { underline: { style: "sng" } } : {}),
|
||||
...(titleStrike ? { strike: "sngStrike" } : {}),
|
||||
color: titleColor,
|
||||
margin: 0.04,
|
||||
breakLine: false,
|
||||
@@ -208,6 +214,7 @@ export async function exportPptxBlob(deck: ExportablePowerPointDeck): Promise<Bl
|
||||
bold: subtitleBold,
|
||||
italic: subtitleItalics,
|
||||
...(subtitleUnderline ? { underline: { style: "sng" } } : {}),
|
||||
...(subtitleStrike ? { strike: "sngStrike" } : {}),
|
||||
color: subtitleColor,
|
||||
valign: "top",
|
||||
fit: "shrink",
|
||||
@@ -248,6 +255,7 @@ function extractSlideTextBlocks(slideXml: unknown, hyperlinkTargets: Record<stri
|
||||
const bold = runTextBold(runProperties);
|
||||
const italics = runTextItalics(runProperties);
|
||||
const underline = runTextUnderline(runProperties);
|
||||
const strike = runTextStrike(runProperties);
|
||||
const color = runTextColor(runProperties);
|
||||
const fontSize = runTextFontSize(runProperties);
|
||||
const fontFamily = runTextFontFamily(runProperties);
|
||||
@@ -258,6 +266,7 @@ function extractSlideTextBlocks(slideXml: unknown, hyperlinkTargets: Record<stri
|
||||
bold,
|
||||
italics,
|
||||
underline,
|
||||
strike,
|
||||
...(color ? { color } : {}),
|
||||
...(fontSize ? { fontSize } : {}),
|
||||
...(fontFamily ? { fontFamily } : {})
|
||||
@@ -706,6 +715,11 @@ function runTextUnderline(runProperties: Record<string, unknown>) {
|
||||
return Boolean(value && value !== "none");
|
||||
}
|
||||
|
||||
function runTextStrike(runProperties: Record<string, unknown>) {
|
||||
const value = stringValue(runProperties.strike ?? runProperties["@_strike"]).trim().toLowerCase();
|
||||
return Boolean(value && value !== "nostrike");
|
||||
}
|
||||
|
||||
function runTextFontSize(runProperties: Record<string, unknown>) {
|
||||
const rawSize = numberAttribute(runProperties, "sz");
|
||||
return rawSize ? normalizeFontSize(rawSize / 100) : undefined;
|
||||
|
||||
Reference in New Issue
Block a user