1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

[Editor] Set a unique id for each element in the draw layer

It avoids any conflict with existing elements when an elment is moved from a page
to an other.
This commit is contained in:
Calixte Denizet 2025-01-08 20:44:11 +01:00
parent 115af68f10
commit 586f45b7b8
3 changed files with 75 additions and 6 deletions

View file

@ -24,12 +24,12 @@ import { shadow } from "../shared/util.js";
class DrawLayer {
#parent = null;
#id = 0;
#mapping = new Map();
#toUpdate = new Map();
static #id = 0;
constructor({ pageIndex }) {
this.pageIndex = pageIndex;
}
@ -96,7 +96,7 @@ class DrawLayer {
}
draw(properties, isPathUpdatable = false, hasClip = false) {
const id = this.#id++;
const id = DrawLayer.#id++;
const root = this.#createSVG();
const defs = DrawLayer._svgFactory.createElement("defs");
@ -129,7 +129,7 @@ class DrawLayer {
// it composes with its parent with mix-blend-mode: multiply.
// But the outline has a different mix-blend-mode, so we need to draw it in
// its own SVG.
const id = this.#id++;
const id = DrawLayer.#id++;
const root = this.#createSVG();
const defs = DrawLayer._svgFactory.createElement("defs");
root.append(defs);