You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * Custom paragraph that overwrites `prepForXml` and handles the special case for external links * with fragments the same way as word does: it creates a relationship w/o the fragment and adds * the fragment as `w:anchor` property to the hyperlink. */classMyParagraphextendsParagraph{prepForXml(context){for(constelementofthis.root){if(elementinstanceofExternalHyperlink){let{ link }=element.options;letanchor;constidx=link.indexOf('#');if(idx>0){anchor=link.substring(idx+1);link=link.substring(0,idx);}constindex=this.root.indexOf(element);constconcreteHyperlink=newConcreteHyperlink(element.options.children,uniqueId());context.viewWrapper.Relationships.createRelationship(concreteHyperlink.linkId,'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink',link,'External',);if(anchor){constattrs=findXMLComponent(concreteHyperlink,'_attr');attrs.root.anchor=anchor;}this.root[index]=concreteHyperlink;}}returnsuper.prepForXml(context);}}
Create an external hyperlink with an url with 2 hashes, eg:
in the generated docx, the first part of the fragment is lost:
the generated xml looks like:
and the url with the fragment is stored in the rels:
but when the same is generated in word, it puts an
w:anchor
on the hyperlink and does not have a fragment in the relationship:and the rel:
The text was updated successfully, but these errors were encountered: