File tree Expand file tree Collapse file tree
packages/super-editor/src/core/super-converter Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { SuperConverter } from './SuperConverter.js';
55import { toKebabCase } from '@harbour-enterprises/common' ;
66import {
77 emuToPixels ,
8+ getTextIndentExportValue ,
89 inchesToTwips ,
910 linesToTwips ,
1011 pixelsToEightPoints ,
@@ -281,7 +282,7 @@ function generateParagraphProperties(node) {
281282 if ( hanging || hanging === 0 ) attributes [ 'w:hanging' ] = pixelsToTwips ( hanging ) ;
282283
283284 if ( textIndent && ! attributes [ 'w:left' ] ) {
284- attributes [ 'w:left' ] = inchesToTwips ( textIndent ) ;
285+ attributes [ 'w:left' ] = getTextIndentExportValue ( textIndent ) ;
285286 }
286287
287288 const indentElement = {
@@ -293,7 +294,7 @@ function generateParagraphProperties(node) {
293294 const indentElement = {
294295 name : 'w:ind' ,
295296 attributes : {
296- 'w:left' : inchesToTwips ( textIndent ) ,
297+ 'w:left' : getTextIndentExportValue ( textIndent ) ,
297298 } ,
298299 } ;
299300 pPrElements . push ( indentElement ) ;
Original file line number Diff line number Diff line change @@ -84,6 +84,22 @@ function ptToTwips(pt) {
8484 return pt * 20 ;
8585}
8686
87+ /**
88+ * Get the export value for text indent
89+ * @param {string|number } indent - The text indent value to export
90+ * @returns {number } - The export value in twips
91+ */
92+ const getTextIndentExportValue = ( indent ) => {
93+ const [ value , unit ] = parseSizeUnit ( indent ) ;
94+ const functionsMap = {
95+ pt : ptToTwips ,
96+ in : inchesToTwips ,
97+ } ;
98+
99+ const exportValue = functionsMap [ unit ] ? functionsMap [ unit ] ( value ) : pixelsToTwips ( value ) ;
100+ return exportValue ;
101+ } ;
102+
87103const getArrayBufferFromUrl = async ( input , isHeadless ) => {
88104 // Check if it's a full URL or blob/file/data URI
89105 const isLikelyUrl = / ^ h t t p s ? : | ^ b l o b : | ^ f i l e : | ^ d a t a : / i. test ( input ) ;
@@ -230,4 +246,5 @@ export {
230246 getLineHeightValueString ,
231247 deobfuscateFont ,
232248 hasSomeParentWithClass ,
249+ getTextIndentExportValue ,
233250} ;
You can’t perform that action at this time.
0 commit comments