Skip to content

Commit

Permalink
docx quote indent fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ibastawisi committed Jan 16, 2025
1 parent 7ac3641 commit 63262bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 3 additions & 5 deletions src/editor/utils/docx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,12 @@ function $mapNodeToDocx(node: LexicalNode): FileChild | ParagraphChild | Paragra
style: 'Quote',
alignment,
indent: {
// start: 15 * 15 * (indent + 1),
hanging: 14 * 15
start: 24 * 15 * (indent + 1),
},
bidirectional: dir === 'rtl',
border: {
left: dir === 'rtl' ? undefined : { size: 30, color: '#ced0d4', style: 'single', space: 8 },
right: dir === 'rtl' ? { size: 30, color: '#ced0d4', style: 'single', space: 8 } : undefined,
left: dir === 'rtl' ? undefined : { size: 30, color: '#ced0d4', style: 'single', space: 12 + 24 * 0.75 * indent },
right: dir === 'rtl' ? { size: 30, color: '#ced0d4', style: 'single', space: 12 + 24 * 0.75 * indent } : undefined,
top: { space: 4, style: 'none' },
bottom: { space: 2, style: 'none' },
},
Expand Down Expand Up @@ -177,7 +176,6 @@ export async function $generateDocxBlob(): Promise<Blob> {
run: { color: '#65676b', },
paragraph: {
spacing: { after: 10 * 15 },
indent: { left: 30 * 15 },
},
},
],
Expand Down
8 changes: 4 additions & 4 deletions src/editor/utils/docx/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ import { ElementNode, TextNode } from "lexical";

export function $convertTextNode(node: TextNode) {
const textContent = node.getTextContent();
const isHeadingText = !!($findMatchingParent(node, $isHeadingNode));
const nearestListItem = $findMatchingParent(node, $isListItemNode);
const isCheckedText = !!(nearestListItem?.getChecked());
const isCheckedText = nearestListItem?.getChecked();
const isLinkText = $findMatchingParent(node, $isLinkNode);
const nearestTableCell = $findMatchingParent(node, $isTableCellNode);
const tableCellColor = nearestTableCell ? $getNodeStyleValueForProperty(nearestTableCell, 'color').replace('inherit', '') : undefined;
const fontsizeInPx = parseInt($getNodeStyleValueForProperty(node, 'font-size'));
const color = $getNodeStyleValueForProperty(node, 'color').replace('inherit', '') || tableCellColor;
const backgroundColor = $getNodeStyleValueForProperty(node, 'background-color').replace('inherit', '') || undefined;
const parent = node.getParent<ElementNode>();
const direction = parent?.getDirection();

const textRun = new TextRun({
text: textContent,
bold: node.hasFormat('bold') || isHeadingText,
bold: node.hasFormat('bold') || undefined,
italics: node.hasFormat('italic'),
strike: node.hasFormat('strikethrough') || isCheckedText,
underline: node.hasFormat('underline') ? { type: "single" } : undefined,
color: $getNodeStyleValueForProperty(node, 'color') || tableCellColor,
color: color,
highlight: node.hasFormat('highlight') ? 'yellow' : undefined,
subScript: node.hasFormat('subscript'),
superScript: node.hasFormat('superscript'),
Expand Down

0 comments on commit 63262bb

Please sign in to comment.