Allow patching of ExternalHyperlinks

This commit is contained in:
Dolan Miu
2023-03-08 23:30:51 +00:00
parent 6ad18420e5
commit 0fba450c9a
3 changed files with 125 additions and 24 deletions

View File

@ -1,6 +1,6 @@
import { Element } from "xml-js";
import { RelationshipType } from "@file/relationships/relationship/relationship";
import { RelationshipType, TargetModeType } from "@file/relationships/relationship/relationship";
import { getFirstLevelElements } from "./util";
const getIdFromRelationshipId = (relationshipId: string): number => parseInt(relationshipId.substring(3), 10);
@ -15,7 +15,13 @@ export const getNextRelationshipIndex = (relationships: Element): number => {
);
};
export const appendRelationship = (relationships: Element, id: number, type: RelationshipType, target: string): void => {
export const appendRelationship = (
relationships: Element,
id: number | string,
type: RelationshipType,
target: string,
targetMode?: TargetModeType,
): void => {
const relationshipElements = getFirstLevelElements(relationships, "Relationships");
// eslint-disable-next-line functional/immutable-data
relationshipElements.push({
@ -23,6 +29,7 @@ export const appendRelationship = (relationships: Element, id: number, type: Rel
Id: `rId${id}`,
Type: type,
Target: target,
TargetMode: targetMode,
},
name: "Relationship",
type: "element",