Skip to content
Closed
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
58 changes: 48 additions & 10 deletions src/powerpoint/ui/NativePowerPointView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4824,14 +4824,33 @@ export class NativePowerPointView extends FileView {
}

private applySelectionClasses(): void {
this.svgEl?.querySelectorAll('g[data-ooxml-shape-idx]').forEach((shape) => {
if (!this.svgEl) return;

const currentlySelected = this.svgEl.getElementsByClassName('native-powerpoint-shape-selected');
const alreadySelected = new Set<number>();
const toRemove: Element[] = [];

for (let i = 0; i < currentlySelected.length; i++) {
const shape = currentlySelected[i];
if (!shape) continue;
const index = getShapeIndex(shape);
if (index !== null && this.selectedShapeIndices.has(index)) {
shape.addClass('native-powerpoint-shape-selected');
if (index === null || !this.selectedShapeIndices.has(index)) {
toRemove.push(shape);
} else {
shape.removeClass('native-powerpoint-shape-selected');
alreadySelected.add(index);
}
});
}

for (let i = 0; i < toRemove.length; i++) {
toRemove[i]?.removeClass('native-powerpoint-shape-selected');
}

for (const index of this.selectedShapeIndices) {
if (!alreadySelected.has(index)) {
const shape = this.svgEl.querySelector(`g[data-ooxml-shape-idx="${index}"]`);
if (shape) shape.addClass('native-powerpoint-shape-selected');
}
}
}

private clearSelection(options: { skipTextCommit?: boolean } = {}): void {
Expand Down Expand Up @@ -12288,14 +12307,33 @@ export class NativePowerPointView extends FileView {
}

private previewSelectionClasses(indices: Set<number>): void {
this.svgEl?.querySelectorAll('g[data-ooxml-shape-idx]').forEach((shape) => {
if (!this.svgEl) return;

const currentlySelected = this.svgEl.getElementsByClassName('native-powerpoint-shape-selected');
const alreadySelected = new Set<number>();
const toRemove: Element[] = [];

for (let i = 0; i < currentlySelected.length; i++) {
const shape = currentlySelected[i];
if (!shape) continue;
const index = getShapeIndex(shape);
if (index !== null && indices.has(index)) {
shape.addClass('native-powerpoint-shape-selected');
if (index === null || !indices.has(index)) {
toRemove.push(shape);
} else {
shape.removeClass('native-powerpoint-shape-selected');
alreadySelected.add(index);
}
});
}

for (let i = 0; i < toRemove.length; i++) {
toRemove[i]?.removeClass('native-powerpoint-shape-selected');
}

for (const index of indices) {
if (!alreadySelected.has(index)) {
const shape = this.svgEl.querySelector(`g[data-ooxml-shape-idx="${index}"]`);
if (shape) shape.addClass('native-powerpoint-shape-selected');
}
}
}

private beginMarquee(event: PointerEvent, additive: boolean): void {
Expand Down
Loading