Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions src/PresentationEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,25 @@
'tint',
]);

function shiftShapeAdjacent(
shapeTree: Element,
element: Element,
selected: Set<Element>,
direction: 1 | -1,
intersectingOnly: boolean
): boolean {
const target = intersectingOnly
? adjacentIntersectingUnselectedShape(element, selected, direction)
: adjacentUnselectedShape(element, selected, direction);
if (!target) return false;

if (direction === 1) {
shapeTree.insertBefore(element, target.nextSibling);
} else {
shapeTree.insertBefore(element, target);
}
return true;

function getRunFontSizePt(run: Element): number | null {
const runProperties = getElementChildren(run)
.find((element) => element.localName === 'rPr' && element.namespaceURI === DRAWINGML_NAMESPACE) ?? null;
Expand Down Expand Up @@ -2746,19 +2765,15 @@
for (let index = ordered.length - 1; index >= 0; index--) {
const element = ordered[index];
if (!element) continue;
const next = options.intersectingOnly
? adjacentIntersectingUnselectedShape(element, selected, 1)
: adjacentUnselectedShape(element, selected, 1);
if (options.intersectingOnly && next) intersectionTargetCount += 1;
if (next) shapeTree.insertBefore(element, next.nextSibling);
if (shiftShapeAdjacent(shapeTree, element, selected, 1, Boolean(options.intersectingOnly)) && options.intersectingOnly) {
intersectionTargetCount += 1;
}
}
} else {
for (const element of ordered) {
const previous = options.intersectingOnly
? adjacentIntersectingUnselectedShape(element, selected, -1)
: adjacentUnselectedShape(element, selected, -1);
if (options.intersectingOnly && previous) intersectionTargetCount += 1;
if (previous) shapeTree.insertBefore(element, previous);
if (shiftShapeAdjacent(shapeTree, element, selected, -1, Boolean(options.intersectingOnly)) && options.intersectingOnly) {
intersectionTargetCount += 1;
}
}
}

Expand Down Expand Up @@ -3942,3 +3957,3 @@
return `${slideIndex}:${shapeIndex}`;
}
}
Loading