Skip to content

Commit 673c29d

Browse files
committed
chore(link): remove unused function
1 parent 400cb9a commit 673c29d

File tree

1 file changed

+0
-78
lines changed

1 file changed

+0
-78
lines changed

src/shapes/hyperlink.ts

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -307,82 +307,4 @@ export class Hyperlink extends Shape {
307307
// 2. Modify the copied slide content XML
308308
await this.updateHyperlinkInSlide();
309309
}
310-
311-
// Helper method to create a hyperlink in a shape
312-
static async addHyperlinkToShape(
313-
archive: IArchive,
314-
slidePath: string,
315-
slideRelsPath: string,
316-
shapeId: string,
317-
hyperlinkTarget: string | number
318-
): Promise<string> {
319-
const slideXml = await XmlHelper.getXmlFromArchive(archive, slidePath);
320-
321-
// Find the shape by ID or name
322-
const shape = XmlHelper.isElementCreationId(shapeId)
323-
? XmlHelper.findByCreationId(slideXml, shapeId)
324-
: XmlHelper.findByName(slideXml, shapeId);
325-
326-
if (!shape) {
327-
throw new Error(`Shape with ID/name "${shapeId}" not found`);
328-
}
329-
330-
// Create a new relationship ID
331-
const relId = await XmlHelper.getNextRelId(archive, slideRelsPath);
332-
333-
// Add the hyperlink relationship to the slide relationships
334-
const relXml = await XmlHelper.getXmlFromArchive(archive, slideRelsPath);
335-
const newRel = relXml.createElement('Relationship');
336-
newRel.setAttribute('Id', relId);
337-
338-
// Improved internal link detection
339-
const isInternalLink = typeof hyperlinkTarget === 'number' ||
340-
(typeof hyperlinkTarget === 'string' && /^\d+$/.test(hyperlinkTarget));
341-
342-
if (isInternalLink) {
343-
// Enhanced internal slide link handling
344-
const slideNumber = typeof hyperlinkTarget === 'number' ?
345-
hyperlinkTarget :
346-
parseInt(hyperlinkTarget, 10);
347-
newRel.setAttribute('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide');
348-
newRel.setAttribute('Target', `../slides/slide${slideNumber}.xml`);
349-
} else {
350-
newRel.setAttribute('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink');
351-
newRel.setAttribute('Target', hyperlinkTarget.toString());
352-
newRel.setAttribute('TargetMode', 'External');
353-
}
354-
355-
relXml.documentElement.appendChild(newRel);
356-
await XmlHelper.writeXmlToArchive(archive, slideRelsPath, relXml);
357-
358-
// Add the hyperlink to the shape
359-
const txBody = shape.getElementsByTagName('p:txBody')[0];
360-
if (txBody) {
361-
const paragraphs = txBody.getElementsByTagName('a:p');
362-
363-
if (paragraphs.length > 0) {
364-
const paragraph = paragraphs[0];
365-
const runs = paragraph.getElementsByTagName('a:r');
366-
367-
if (runs.length > 0) {
368-
const run = runs[0];
369-
const rPr = run.getElementsByTagName('a:rPr')[0];
370-
371-
if (rPr) {
372-
const hlinkClick = slideXml.createElement('a:hlinkClick');
373-
hlinkClick.setAttribute('r:id', relId);
374-
if (isInternalLink) {
375-
hlinkClick.setAttribute('action', 'ppaction://hlinksldjump');
376-
}
377-
hlinkClick.setAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
378-
rPr.appendChild(hlinkClick);
379-
}
380-
}
381-
}
382-
}
383-
384-
await XmlHelper.writeXmlToArchive(archive, slidePath, slideXml);
385-
386-
return relId;
387-
}
388310
}

0 commit comments

Comments
 (0)