@@ -1966,7 +1966,12 @@ function prepareUrlAnnotation(params) {
19661966 * @param {String } annotationType
19671967 * @returns {Function } handler for provided annotation type
19681968 */
1969- function getTranslationByAnnotationType ( annotationType ) {
1969+ function getTranslationByAnnotationType ( annotationType , annotationFieldType ) {
1970+ // invalid annotation
1971+ if ( annotationType === 'text' && annotationFieldType === 'FILEUPLOADER' ) {
1972+ return null ;
1973+ }
1974+
19701975 const imageEmuSize = {
19711976 w : 4286250 ,
19721977 h : 4286250 ,
@@ -2012,7 +2017,7 @@ const translateFieldAttrsToMarks = (attrs = {}) => {
20122017function translateFieldAnnotation ( params ) {
20132018 const { node, isFinalDoc, fieldsHighlightColor } = params ;
20142019 const { attrs = { } } = node ;
2015- const annotationHandler = getTranslationByAnnotationType ( attrs . type ) ;
2020+ const annotationHandler = getTranslationByAnnotationType ( attrs . type , attrs . fieldType ) ;
20162021 if ( ! annotationHandler ) return { } ;
20172022
20182023 let processedNode ;
@@ -2284,8 +2289,15 @@ export class DocxExporter {
22842289 if ( name === 'w:instrText' ) {
22852290 tags . push ( elements [ 0 ] . text ) ;
22862291 } else if ( name === 'w:t' || name === 'w:delText' || name === 'wp:posOffset' ) {
2287- const text = this . #replaceSpecialCharacters( elements [ 0 ] . text ) ;
2288- tags . push ( text ) ;
2292+ try {
2293+ // test for valid string
2294+ let text = String ( elements [ 0 ] . text ) ;
2295+ text = this . #replaceSpecialCharacters( text ) ;
2296+ tags . push ( text ) ;
2297+ } catch ( error ) {
2298+ console . error ( 'Text element does not contain valid string:' , error ) ;
2299+ throw new Error ( 'Invalid text element in XML generation' ) ;
2300+ }
22892301 } else {
22902302 if ( elements ) {
22912303 for ( let child of elements ) {
0 commit comments