Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/super-editor/src/core/super-converter/exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { EditorState } from 'prosemirror-state';
import { SuperConverter } from './SuperConverter.js';
import {
emuToPixels,
getTextIndentExportValue,
inchesToTwips,
linesToTwips,
pixelsToEightPoints,
Expand Down Expand Up @@ -280,7 +281,7 @@ function generateParagraphProperties(node) {
if (hanging || hanging === 0) attributes['w:hanging'] = pixelsToTwips(hanging);

if (textIndent && !attributes['w:left']) {
attributes['w:left'] = inchesToTwips(textIndent);
attributes['w:left'] = getTextIndentExportValue(textIndent);
}

const indentElement = {
Expand All @@ -292,7 +293,7 @@ function generateParagraphProperties(node) {
const indentElement = {
name: 'w:ind',
attributes: {
'w:left': inchesToTwips(textIndent),
'w:left': getTextIndentExportValue(textIndent),
},
};
pPrElements.push(indentElement);
Expand Down
17 changes: 17 additions & 0 deletions packages/super-editor/src/core/super-converter/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@ function ptToTwips(pt) {
return pt * 20;
}

/**
* Get the export value for text indent
* @param {string|number} indent - The text indent value to export
* @returns {number} - The export value in twips
*/
const getTextIndentExportValue = (indent) => {
const [value, unit] = parseSizeUnit(indent);
const functionsMap = {
pt: ptToTwips,
in: inchesToTwips,
};

const exportValue = functionsMap[unit] ? functionsMap[unit](value) : pixelsToTwips(value);
return exportValue;
};

const getArrayBufferFromUrl = async (input, isHeadless) => {
// Check if it's a full URL or blob/file/data URI
const isLikelyUrl = /^https?:|^blob:|^file:|^data:/i.test(input);
Expand Down Expand Up @@ -230,4 +246,5 @@ export {
getLineHeightValueString,
deobfuscateFont,
hasSomeParentWithClass,
getTextIndentExportValue,
};
Loading