Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/embedpre.../assets/pdf/build
File: script.js
class Outline {
[21000] Fix | Delete
toSVGPath() {
[21001] Fix | Delete
throw new Error("Abstract method `toSVGPath` must be implemented.");
[21002] Fix | Delete
}
[21003] Fix | Delete
get box() {
[21004] Fix | Delete
throw new Error("Abstract getter `box` must be implemented.");
[21005] Fix | Delete
}
[21006] Fix | Delete
serialize(_bbox, _rotation) {
[21007] Fix | Delete
throw new Error("Abstract method `serialize` must be implemented.");
[21008] Fix | Delete
}
[21009] Fix | Delete
get free() {
[21010] Fix | Delete
return this instanceof FreeHighlightOutline;
[21011] Fix | Delete
}
[21012] Fix | Delete
}
[21013] Fix | Delete
class HighlightOutline extends Outline {
[21014] Fix | Delete
#box;
[21015] Fix | Delete
#outlines;
[21016] Fix | Delete
constructor(outlines, box) {
[21017] Fix | Delete
super();
[21018] Fix | Delete
this.#outlines = outlines;
[21019] Fix | Delete
this.#box = box;
[21020] Fix | Delete
}
[21021] Fix | Delete
toSVGPath() {
[21022] Fix | Delete
const buffer = [];
[21023] Fix | Delete
for (const polygon of this.#outlines) {
[21024] Fix | Delete
let [prevX, prevY] = polygon;
[21025] Fix | Delete
buffer.push(`M${prevX} ${prevY}`);
[21026] Fix | Delete
for (let i = 2; i < polygon.length; i += 2) {
[21027] Fix | Delete
const x = polygon[i];
[21028] Fix | Delete
const y = polygon[i + 1];
[21029] Fix | Delete
if (x === prevX) {
[21030] Fix | Delete
buffer.push(`V${y}`);
[21031] Fix | Delete
prevY = y;
[21032] Fix | Delete
} else if (y === prevY) {
[21033] Fix | Delete
buffer.push(`H${x}`);
[21034] Fix | Delete
prevX = x;
[21035] Fix | Delete
}
[21036] Fix | Delete
}
[21037] Fix | Delete
buffer.push("Z");
[21038] Fix | Delete
}
[21039] Fix | Delete
return buffer.join(" ");
[21040] Fix | Delete
}
[21041] Fix | Delete
serialize([blX, blY, trX, trY], _rotation) {
[21042] Fix | Delete
const outlines = [];
[21043] Fix | Delete
const width = trX - blX;
[21044] Fix | Delete
const height = trY - blY;
[21045] Fix | Delete
for (const outline of this.#outlines) {
[21046] Fix | Delete
const points = new Array(outline.length);
[21047] Fix | Delete
for (let i = 0; i < outline.length; i += 2) {
[21048] Fix | Delete
points[i] = blX + outline[i] * width;
[21049] Fix | Delete
points[i + 1] = trY - outline[i + 1] * height;
[21050] Fix | Delete
}
[21051] Fix | Delete
outlines.push(points);
[21052] Fix | Delete
}
[21053] Fix | Delete
return outlines;
[21054] Fix | Delete
}
[21055] Fix | Delete
get box() {
[21056] Fix | Delete
return this.#box;
[21057] Fix | Delete
}
[21058] Fix | Delete
}
[21059] Fix | Delete
class FreeOutliner {
[21060] Fix | Delete
#box;
[21061] Fix | Delete
#bottom = [];
[21062] Fix | Delete
#innerMargin;
[21063] Fix | Delete
#isLTR;
[21064] Fix | Delete
#top = [];
[21065] Fix | Delete
#last = new Float64Array(18);
[21066] Fix | Delete
#lastX;
[21067] Fix | Delete
#lastY;
[21068] Fix | Delete
#min;
[21069] Fix | Delete
#min_dist;
[21070] Fix | Delete
#scaleFactor;
[21071] Fix | Delete
#thickness;
[21072] Fix | Delete
#points = [];
[21073] Fix | Delete
static #MIN_DIST = 8;
[21074] Fix | Delete
static #MIN_DIFF = 2;
[21075] Fix | Delete
static #MIN = FreeOutliner.#MIN_DIST + FreeOutliner.#MIN_DIFF;
[21076] Fix | Delete
constructor({
[21077] Fix | Delete
x,
[21078] Fix | Delete
y
[21079] Fix | Delete
}, box, scaleFactor, thickness, isLTR, innerMargin = 0) {
[21080] Fix | Delete
this.#box = box;
[21081] Fix | Delete
this.#thickness = thickness * scaleFactor;
[21082] Fix | Delete
this.#isLTR = isLTR;
[21083] Fix | Delete
this.#last.set([NaN, NaN, NaN, NaN, x, y], 6);
[21084] Fix | Delete
this.#innerMargin = innerMargin;
[21085] Fix | Delete
this.#min_dist = FreeOutliner.#MIN_DIST * scaleFactor;
[21086] Fix | Delete
this.#min = FreeOutliner.#MIN * scaleFactor;
[21087] Fix | Delete
this.#scaleFactor = scaleFactor;
[21088] Fix | Delete
this.#points.push(x, y);
[21089] Fix | Delete
}
[21090] Fix | Delete
get free() {
[21091] Fix | Delete
return true;
[21092] Fix | Delete
}
[21093] Fix | Delete
isEmpty() {
[21094] Fix | Delete
return isNaN(this.#last[8]);
[21095] Fix | Delete
}
[21096] Fix | Delete
#getLastCoords() {
[21097] Fix | Delete
const lastTop = this.#last.subarray(4, 6);
[21098] Fix | Delete
const lastBottom = this.#last.subarray(16, 18);
[21099] Fix | Delete
const [x, y, width, height] = this.#box;
[21100] Fix | Delete
return [(this.#lastX + (lastTop[0] - lastBottom[0]) / 2 - x) / width, (this.#lastY + (lastTop[1] - lastBottom[1]) / 2 - y) / height, (this.#lastX + (lastBottom[0] - lastTop[0]) / 2 - x) / width, (this.#lastY + (lastBottom[1] - lastTop[1]) / 2 - y) / height];
[21101] Fix | Delete
}
[21102] Fix | Delete
add({
[21103] Fix | Delete
x,
[21104] Fix | Delete
y
[21105] Fix | Delete
}) {
[21106] Fix | Delete
this.#lastX = x;
[21107] Fix | Delete
this.#lastY = y;
[21108] Fix | Delete
const [layerX, layerY, layerWidth, layerHeight] = this.#box;
[21109] Fix | Delete
let [x1, y1, x2, y2] = this.#last.subarray(8, 12);
[21110] Fix | Delete
const diffX = x - x2;
[21111] Fix | Delete
const diffY = y - y2;
[21112] Fix | Delete
const d = Math.hypot(diffX, diffY);
[21113] Fix | Delete
if (d < this.#min) {
[21114] Fix | Delete
return false;
[21115] Fix | Delete
}
[21116] Fix | Delete
const diffD = d - this.#min_dist;
[21117] Fix | Delete
const K = diffD / d;
[21118] Fix | Delete
const shiftX = K * diffX;
[21119] Fix | Delete
const shiftY = K * diffY;
[21120] Fix | Delete
let x0 = x1;
[21121] Fix | Delete
let y0 = y1;
[21122] Fix | Delete
x1 = x2;
[21123] Fix | Delete
y1 = y2;
[21124] Fix | Delete
x2 += shiftX;
[21125] Fix | Delete
y2 += shiftY;
[21126] Fix | Delete
this.#points?.push(x, y);
[21127] Fix | Delete
const nX = -shiftY / diffD;
[21128] Fix | Delete
const nY = shiftX / diffD;
[21129] Fix | Delete
const thX = nX * this.#thickness;
[21130] Fix | Delete
const thY = nY * this.#thickness;
[21131] Fix | Delete
this.#last.set(this.#last.subarray(2, 8), 0);
[21132] Fix | Delete
this.#last.set([x2 + thX, y2 + thY], 4);
[21133] Fix | Delete
this.#last.set(this.#last.subarray(14, 18), 12);
[21134] Fix | Delete
this.#last.set([x2 - thX, y2 - thY], 16);
[21135] Fix | Delete
if (isNaN(this.#last[6])) {
[21136] Fix | Delete
if (this.#top.length === 0) {
[21137] Fix | Delete
this.#last.set([x1 + thX, y1 + thY], 2);
[21138] Fix | Delete
this.#top.push(NaN, NaN, NaN, NaN, (x1 + thX - layerX) / layerWidth, (y1 + thY - layerY) / layerHeight);
[21139] Fix | Delete
this.#last.set([x1 - thX, y1 - thY], 14);
[21140] Fix | Delete
this.#bottom.push(NaN, NaN, NaN, NaN, (x1 - thX - layerX) / layerWidth, (y1 - thY - layerY) / layerHeight);
[21141] Fix | Delete
}
[21142] Fix | Delete
this.#last.set([x0, y0, x1, y1, x2, y2], 6);
[21143] Fix | Delete
return !this.isEmpty();
[21144] Fix | Delete
}
[21145] Fix | Delete
this.#last.set([x0, y0, x1, y1, x2, y2], 6);
[21146] Fix | Delete
const angle = Math.abs(Math.atan2(y0 - y1, x0 - x1) - Math.atan2(shiftY, shiftX));
[21147] Fix | Delete
if (angle < Math.PI / 2) {
[21148] Fix | Delete
[x1, y1, x2, y2] = this.#last.subarray(2, 6);
[21149] Fix | Delete
this.#top.push(NaN, NaN, NaN, NaN, ((x1 + x2) / 2 - layerX) / layerWidth, ((y1 + y2) / 2 - layerY) / layerHeight);
[21150] Fix | Delete
[x1, y1, x0, y0] = this.#last.subarray(14, 18);
[21151] Fix | Delete
this.#bottom.push(NaN, NaN, NaN, NaN, ((x0 + x1) / 2 - layerX) / layerWidth, ((y0 + y1) / 2 - layerY) / layerHeight);
[21152] Fix | Delete
return true;
[21153] Fix | Delete
}
[21154] Fix | Delete
[x0, y0, x1, y1, x2, y2] = this.#last.subarray(0, 6);
[21155] Fix | Delete
this.#top.push(((x0 + 5 * x1) / 6 - layerX) / layerWidth, ((y0 + 5 * y1) / 6 - layerY) / layerHeight, ((5 * x1 + x2) / 6 - layerX) / layerWidth, ((5 * y1 + y2) / 6 - layerY) / layerHeight, ((x1 + x2) / 2 - layerX) / layerWidth, ((y1 + y2) / 2 - layerY) / layerHeight);
[21156] Fix | Delete
[x2, y2, x1, y1, x0, y0] = this.#last.subarray(12, 18);
[21157] Fix | Delete
this.#bottom.push(((x0 + 5 * x1) / 6 - layerX) / layerWidth, ((y0 + 5 * y1) / 6 - layerY) / layerHeight, ((5 * x1 + x2) / 6 - layerX) / layerWidth, ((5 * y1 + y2) / 6 - layerY) / layerHeight, ((x1 + x2) / 2 - layerX) / layerWidth, ((y1 + y2) / 2 - layerY) / layerHeight);
[21158] Fix | Delete
return true;
[21159] Fix | Delete
}
[21160] Fix | Delete
toSVGPath() {
[21161] Fix | Delete
if (this.isEmpty()) {
[21162] Fix | Delete
return "";
[21163] Fix | Delete
}
[21164] Fix | Delete
const top = this.#top;
[21165] Fix | Delete
const bottom = this.#bottom;
[21166] Fix | Delete
const lastTop = this.#last.subarray(4, 6);
[21167] Fix | Delete
const lastBottom = this.#last.subarray(16, 18);
[21168] Fix | Delete
const [x, y, width, height] = this.#box;
[21169] Fix | Delete
const [lastTopX, lastTopY, lastBottomX, lastBottomY] = this.#getLastCoords();
[21170] Fix | Delete
if (isNaN(this.#last[6]) && !this.isEmpty()) {
[21171] Fix | Delete
return `M${(this.#last[2] - x) / width} ${(this.#last[3] - y) / height} L${(this.#last[4] - x) / width} ${(this.#last[5] - y) / height} L${lastTopX} ${lastTopY} L${lastBottomX} ${lastBottomY} L${(this.#last[16] - x) / width} ${(this.#last[17] - y) / height} L${(this.#last[14] - x) / width} ${(this.#last[15] - y) / height} Z`;
[21172] Fix | Delete
}
[21173] Fix | Delete
const buffer = [];
[21174] Fix | Delete
buffer.push(`M${top[4]} ${top[5]}`);
[21175] Fix | Delete
for (let i = 6; i < top.length; i += 6) {
[21176] Fix | Delete
if (isNaN(top[i])) {
[21177] Fix | Delete
buffer.push(`L${top[i + 4]} ${top[i + 5]}`);
[21178] Fix | Delete
} else {
[21179] Fix | Delete
buffer.push(`C${top[i]} ${top[i + 1]} ${top[i + 2]} ${top[i + 3]} ${top[i + 4]} ${top[i + 5]}`);
[21180] Fix | Delete
}
[21181] Fix | Delete
}
[21182] Fix | Delete
buffer.push(`L${(lastTop[0] - x) / width} ${(lastTop[1] - y) / height} L${lastTopX} ${lastTopY} L${lastBottomX} ${lastBottomY} L${(lastBottom[0] - x) / width} ${(lastBottom[1] - y) / height}`);
[21183] Fix | Delete
for (let i = bottom.length - 6; i >= 6; i -= 6) {
[21184] Fix | Delete
if (isNaN(bottom[i])) {
[21185] Fix | Delete
buffer.push(`L${bottom[i + 4]} ${bottom[i + 5]}`);
[21186] Fix | Delete
} else {
[21187] Fix | Delete
buffer.push(`C${bottom[i]} ${bottom[i + 1]} ${bottom[i + 2]} ${bottom[i + 3]} ${bottom[i + 4]} ${bottom[i + 5]}`);
[21188] Fix | Delete
}
[21189] Fix | Delete
}
[21190] Fix | Delete
buffer.push(`L${bottom[4]} ${bottom[5]} Z`);
[21191] Fix | Delete
return buffer.join(" ");
[21192] Fix | Delete
}
[21193] Fix | Delete
getOutlines() {
[21194] Fix | Delete
const top = this.#top;
[21195] Fix | Delete
const bottom = this.#bottom;
[21196] Fix | Delete
const last = this.#last;
[21197] Fix | Delete
const lastTop = last.subarray(4, 6);
[21198] Fix | Delete
const lastBottom = last.subarray(16, 18);
[21199] Fix | Delete
const [layerX, layerY, layerWidth, layerHeight] = this.#box;
[21200] Fix | Delete
const points = new Float64Array((this.#points?.length ?? 0) + 2);
[21201] Fix | Delete
for (let i = 0, ii = points.length - 2; i < ii; i += 2) {
[21202] Fix | Delete
points[i] = (this.#points[i] - layerX) / layerWidth;
[21203] Fix | Delete
points[i + 1] = (this.#points[i + 1] - layerY) / layerHeight;
[21204] Fix | Delete
}
[21205] Fix | Delete
points[points.length - 2] = (this.#lastX - layerX) / layerWidth;
[21206] Fix | Delete
points[points.length - 1] = (this.#lastY - layerY) / layerHeight;
[21207] Fix | Delete
const [lastTopX, lastTopY, lastBottomX, lastBottomY] = this.#getLastCoords();
[21208] Fix | Delete
if (isNaN(last[6]) && !this.isEmpty()) {
[21209] Fix | Delete
const outline = new Float64Array(36);
[21210] Fix | Delete
outline.set([NaN, NaN, NaN, NaN, (last[2] - layerX) / layerWidth, (last[3] - layerY) / layerHeight, NaN, NaN, NaN, NaN, (last[4] - layerX) / layerWidth, (last[5] - layerY) / layerHeight, NaN, NaN, NaN, NaN, lastTopX, lastTopY, NaN, NaN, NaN, NaN, lastBottomX, lastBottomY, NaN, NaN, NaN, NaN, (last[16] - layerX) / layerWidth, (last[17] - layerY) / layerHeight, NaN, NaN, NaN, NaN, (last[14] - layerX) / layerWidth, (last[15] - layerY) / layerHeight], 0);
[21211] Fix | Delete
return new FreeHighlightOutline(outline, points, this.#box, this.#scaleFactor, this.#innerMargin, this.#isLTR);
[21212] Fix | Delete
}
[21213] Fix | Delete
const outline = new Float64Array(this.#top.length + 24 + this.#bottom.length);
[21214] Fix | Delete
let N = top.length;
[21215] Fix | Delete
for (let i = 0; i < N; i += 2) {
[21216] Fix | Delete
if (isNaN(top[i])) {
[21217] Fix | Delete
outline[i] = outline[i + 1] = NaN;
[21218] Fix | Delete
continue;
[21219] Fix | Delete
}
[21220] Fix | Delete
outline[i] = top[i];
[21221] Fix | Delete
outline[i + 1] = top[i + 1];
[21222] Fix | Delete
}
[21223] Fix | Delete
outline.set([NaN, NaN, NaN, NaN, (lastTop[0] - layerX) / layerWidth, (lastTop[1] - layerY) / layerHeight, NaN, NaN, NaN, NaN, lastTopX, lastTopY, NaN, NaN, NaN, NaN, lastBottomX, lastBottomY, NaN, NaN, NaN, NaN, (lastBottom[0] - layerX) / layerWidth, (lastBottom[1] - layerY) / layerHeight], N);
[21224] Fix | Delete
N += 24;
[21225] Fix | Delete
for (let i = bottom.length - 6; i >= 6; i -= 6) {
[21226] Fix | Delete
for (let j = 0; j < 6; j += 2) {
[21227] Fix | Delete
if (isNaN(bottom[i + j])) {
[21228] Fix | Delete
outline[N] = outline[N + 1] = NaN;
[21229] Fix | Delete
N += 2;
[21230] Fix | Delete
continue;
[21231] Fix | Delete
}
[21232] Fix | Delete
outline[N] = bottom[i + j];
[21233] Fix | Delete
outline[N + 1] = bottom[i + j + 1];
[21234] Fix | Delete
N += 2;
[21235] Fix | Delete
}
[21236] Fix | Delete
}
[21237] Fix | Delete
outline.set([NaN, NaN, NaN, NaN, bottom[4], bottom[5]], N);
[21238] Fix | Delete
return new FreeHighlightOutline(outline, points, this.#box, this.#scaleFactor, this.#innerMargin, this.#isLTR);
[21239] Fix | Delete
}
[21240] Fix | Delete
}
[21241] Fix | Delete
class FreeHighlightOutline extends Outline {
[21242] Fix | Delete
#box;
[21243] Fix | Delete
#bbox = null;
[21244] Fix | Delete
#innerMargin;
[21245] Fix | Delete
#isLTR;
[21246] Fix | Delete
#points;
[21247] Fix | Delete
#scaleFactor;
[21248] Fix | Delete
#outline;
[21249] Fix | Delete
constructor(outline, points, box, scaleFactor, innerMargin, isLTR) {
[21250] Fix | Delete
super();
[21251] Fix | Delete
this.#outline = outline;
[21252] Fix | Delete
this.#points = points;
[21253] Fix | Delete
this.#box = box;
[21254] Fix | Delete
this.#scaleFactor = scaleFactor;
[21255] Fix | Delete
this.#innerMargin = innerMargin;
[21256] Fix | Delete
this.#isLTR = isLTR;
[21257] Fix | Delete
this.#computeMinMax(isLTR);
[21258] Fix | Delete
const {
[21259] Fix | Delete
x,
[21260] Fix | Delete
y,
[21261] Fix | Delete
width,
[21262] Fix | Delete
height
[21263] Fix | Delete
} = this.#bbox;
[21264] Fix | Delete
for (let i = 0, ii = outline.length; i < ii; i += 2) {
[21265] Fix | Delete
outline[i] = (outline[i] - x) / width;
[21266] Fix | Delete
outline[i + 1] = (outline[i + 1] - y) / height;
[21267] Fix | Delete
}
[21268] Fix | Delete
for (let i = 0, ii = points.length; i < ii; i += 2) {
[21269] Fix | Delete
points[i] = (points[i] - x) / width;
[21270] Fix | Delete
points[i + 1] = (points[i + 1] - y) / height;
[21271] Fix | Delete
}
[21272] Fix | Delete
}
[21273] Fix | Delete
toSVGPath() {
[21274] Fix | Delete
const buffer = [`M${this.#outline[4]} ${this.#outline[5]}`];
[21275] Fix | Delete
for (let i = 6, ii = this.#outline.length; i < ii; i += 6) {
[21276] Fix | Delete
if (isNaN(this.#outline[i])) {
[21277] Fix | Delete
buffer.push(`L${this.#outline[i + 4]} ${this.#outline[i + 5]}`);
[21278] Fix | Delete
continue;
[21279] Fix | Delete
}
[21280] Fix | Delete
buffer.push(`C${this.#outline[i]} ${this.#outline[i + 1]} ${this.#outline[i + 2]} ${this.#outline[i + 3]} ${this.#outline[i + 4]} ${this.#outline[i + 5]}`);
[21281] Fix | Delete
}
[21282] Fix | Delete
buffer.push("Z");
[21283] Fix | Delete
return buffer.join(" ");
[21284] Fix | Delete
}
[21285] Fix | Delete
serialize([blX, blY, trX, trY], rotation) {
[21286] Fix | Delete
const width = trX - blX;
[21287] Fix | Delete
const height = trY - blY;
[21288] Fix | Delete
let outline;
[21289] Fix | Delete
let points;
[21290] Fix | Delete
switch (rotation) {
[21291] Fix | Delete
case 0:
[21292] Fix | Delete
outline = this.#rescale(this.#outline, blX, trY, width, -height);
[21293] Fix | Delete
points = this.#rescale(this.#points, blX, trY, width, -height);
[21294] Fix | Delete
break;
[21295] Fix | Delete
case 90:
[21296] Fix | Delete
outline = this.#rescaleAndSwap(this.#outline, blX, blY, width, height);
[21297] Fix | Delete
points = this.#rescaleAndSwap(this.#points, blX, blY, width, height);
[21298] Fix | Delete
break;
[21299] Fix | Delete
case 180:
[21300] Fix | Delete
outline = this.#rescale(this.#outline, trX, blY, -width, height);
[21301] Fix | Delete
points = this.#rescale(this.#points, trX, blY, -width, height);
[21302] Fix | Delete
break;
[21303] Fix | Delete
case 270:
[21304] Fix | Delete
outline = this.#rescaleAndSwap(this.#outline, trX, trY, -width, -height);
[21305] Fix | Delete
points = this.#rescaleAndSwap(this.#points, trX, trY, -width, -height);
[21306] Fix | Delete
break;
[21307] Fix | Delete
}
[21308] Fix | Delete
return {
[21309] Fix | Delete
outline: Array.from(outline),
[21310] Fix | Delete
points: [Array.from(points)]
[21311] Fix | Delete
};
[21312] Fix | Delete
}
[21313] Fix | Delete
#rescale(src, tx, ty, sx, sy) {
[21314] Fix | Delete
const dest = new Float64Array(src.length);
[21315] Fix | Delete
for (let i = 0, ii = src.length; i < ii; i += 2) {
[21316] Fix | Delete
dest[i] = tx + src[i] * sx;
[21317] Fix | Delete
dest[i + 1] = ty + src[i + 1] * sy;
[21318] Fix | Delete
}
[21319] Fix | Delete
return dest;
[21320] Fix | Delete
}
[21321] Fix | Delete
#rescaleAndSwap(src, tx, ty, sx, sy) {
[21322] Fix | Delete
const dest = new Float64Array(src.length);
[21323] Fix | Delete
for (let i = 0, ii = src.length; i < ii; i += 2) {
[21324] Fix | Delete
dest[i] = tx + src[i + 1] * sx;
[21325] Fix | Delete
dest[i + 1] = ty + src[i] * sy;
[21326] Fix | Delete
}
[21327] Fix | Delete
return dest;
[21328] Fix | Delete
}
[21329] Fix | Delete
#computeMinMax(isLTR) {
[21330] Fix | Delete
const outline = this.#outline;
[21331] Fix | Delete
let lastX = outline[4];
[21332] Fix | Delete
let lastY = outline[5];
[21333] Fix | Delete
let minX = lastX;
[21334] Fix | Delete
let minY = lastY;
[21335] Fix | Delete
let maxX = lastX;
[21336] Fix | Delete
let maxY = lastY;
[21337] Fix | Delete
let lastPointX = lastX;
[21338] Fix | Delete
let lastPointY = lastY;
[21339] Fix | Delete
const ltrCallback = isLTR ? Math.max : Math.min;
[21340] Fix | Delete
for (let i = 6, ii = outline.length; i < ii; i += 6) {
[21341] Fix | Delete
if (isNaN(outline[i])) {
[21342] Fix | Delete
minX = Math.min(minX, outline[i + 4]);
[21343] Fix | Delete
minY = Math.min(minY, outline[i + 5]);
[21344] Fix | Delete
maxX = Math.max(maxX, outline[i + 4]);
[21345] Fix | Delete
maxY = Math.max(maxY, outline[i + 5]);
[21346] Fix | Delete
if (lastPointY < outline[i + 5]) {
[21347] Fix | Delete
lastPointX = outline[i + 4];
[21348] Fix | Delete
lastPointY = outline[i + 5];
[21349] Fix | Delete
} else if (lastPointY === outline[i + 5]) {
[21350] Fix | Delete
lastPointX = ltrCallback(lastPointX, outline[i + 4]);
[21351] Fix | Delete
}
[21352] Fix | Delete
} else {
[21353] Fix | Delete
const bbox = Util.bezierBoundingBox(lastX, lastY, ...outline.slice(i, i + 6));
[21354] Fix | Delete
minX = Math.min(minX, bbox[0]);
[21355] Fix | Delete
minY = Math.min(minY, bbox[1]);
[21356] Fix | Delete
maxX = Math.max(maxX, bbox[2]);
[21357] Fix | Delete
maxY = Math.max(maxY, bbox[3]);
[21358] Fix | Delete
if (lastPointY < bbox[3]) {
[21359] Fix | Delete
lastPointX = bbox[2];
[21360] Fix | Delete
lastPointY = bbox[3];
[21361] Fix | Delete
} else if (lastPointY === bbox[3]) {
[21362] Fix | Delete
lastPointX = ltrCallback(lastPointX, bbox[2]);
[21363] Fix | Delete
}
[21364] Fix | Delete
}
[21365] Fix | Delete
lastX = outline[i + 4];
[21366] Fix | Delete
lastY = outline[i + 5];
[21367] Fix | Delete
}
[21368] Fix | Delete
const x = minX - this.#innerMargin,
[21369] Fix | Delete
y = minY - this.#innerMargin,
[21370] Fix | Delete
width = maxX - minX + 2 * this.#innerMargin,
[21371] Fix | Delete
height = maxY - minY + 2 * this.#innerMargin;
[21372] Fix | Delete
this.#bbox = {
[21373] Fix | Delete
x,
[21374] Fix | Delete
y,
[21375] Fix | Delete
width,
[21376] Fix | Delete
height,
[21377] Fix | Delete
lastPoint: [lastPointX, lastPointY]
[21378] Fix | Delete
};
[21379] Fix | Delete
}
[21380] Fix | Delete
get box() {
[21381] Fix | Delete
return this.#bbox;
[21382] Fix | Delete
}
[21383] Fix | Delete
getNewOutline(thickness, innerMargin) {
[21384] Fix | Delete
const {
[21385] Fix | Delete
x,
[21386] Fix | Delete
y,
[21387] Fix | Delete
width,
[21388] Fix | Delete
height
[21389] Fix | Delete
} = this.#bbox;
[21390] Fix | Delete
const [layerX, layerY, layerWidth, layerHeight] = this.#box;
[21391] Fix | Delete
const sx = width * layerWidth;
[21392] Fix | Delete
const sy = height * layerHeight;
[21393] Fix | Delete
const tx = x * layerWidth + layerX;
[21394] Fix | Delete
const ty = y * layerHeight + layerY;
[21395] Fix | Delete
const outliner = new FreeOutliner({
[21396] Fix | Delete
x: this.#points[0] * sx + tx,
[21397] Fix | Delete
y: this.#points[1] * sy + ty
[21398] Fix | Delete
}, this.#box, this.#scaleFactor, thickness, this.#isLTR, innerMargin ?? this.#innerMargin);
[21399] Fix | Delete
for (let i = 2; i < this.#points.length; i += 2) {
[21400] Fix | Delete
outliner.add({
[21401] Fix | Delete
x: this.#points[i] * sx + tx,
[21402] Fix | Delete
y: this.#points[i + 1] * sy + ty
[21403] Fix | Delete
});
[21404] Fix | Delete
}
[21405] Fix | Delete
return outliner.getOutlines();
[21406] Fix | Delete
}
[21407] Fix | Delete
}
[21408] Fix | Delete
[21409] Fix | Delete
;// CONCATENATED MODULE: ./src/display/editor/color_picker.js
[21410] Fix | Delete
[21411] Fix | Delete
[21412] Fix | Delete
[21413] Fix | Delete
class ColorPicker {
[21414] Fix | Delete
#boundKeyDown = this.#keyDown.bind(this);
[21415] Fix | Delete
#boundPointerDown = this.#pointerDown.bind(this);
[21416] Fix | Delete
#button = null;
[21417] Fix | Delete
#buttonSwatch = null;
[21418] Fix | Delete
#defaultColor;
[21419] Fix | Delete
#dropdown = null;
[21420] Fix | Delete
#dropdownWasFromKeyboard = false;
[21421] Fix | Delete
#isMainColorPicker = false;
[21422] Fix | Delete
#editor = null;
[21423] Fix | Delete
#eventBus;
[21424] Fix | Delete
#uiManager = null;
[21425] Fix | Delete
#type;
[21426] Fix | Delete
static get _keyboardManager() {
[21427] Fix | Delete
return shadow(this, "_keyboardManager", new KeyboardManager([[["Escape", "mac+Escape"], ColorPicker.prototype._hideDropdownFromKeyboard], [[" ", "mac+ "], ColorPicker.prototype._colorSelectFromKeyboard], [["ArrowDown", "ArrowRight", "mac+ArrowDown", "mac+ArrowRight"], ColorPicker.prototype._moveToNext], [["ArrowUp", "ArrowLeft", "mac+ArrowUp", "mac+ArrowLeft"], ColorPicker.prototype._moveToPrevious], [["Home", "mac+Home"], ColorPicker.prototype._moveToBeginning], [["End", "mac+End"], ColorPicker.prototype._moveToEnd]]));
[21428] Fix | Delete
}
[21429] Fix | Delete
constructor({
[21430] Fix | Delete
editor = null,
[21431] Fix | Delete
uiManager = null
[21432] Fix | Delete
}) {
[21433] Fix | Delete
if (editor) {
[21434] Fix | Delete
this.#isMainColorPicker = false;
[21435] Fix | Delete
this.#type = AnnotationEditorParamsType.HIGHLIGHT_COLOR;
[21436] Fix | Delete
this.#editor = editor;
[21437] Fix | Delete
} else {
[21438] Fix | Delete
this.#isMainColorPicker = true;
[21439] Fix | Delete
this.#type = AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR;
[21440] Fix | Delete
}
[21441] Fix | Delete
this.#uiManager = editor?._uiManager || uiManager;
[21442] Fix | Delete
this.#eventBus = this.#uiManager._eventBus;
[21443] Fix | Delete
this.#defaultColor = editor?.color || this.#uiManager?.highlightColors.values().next().value || "#FFFF98";
[21444] Fix | Delete
}
[21445] Fix | Delete
renderButton() {
[21446] Fix | Delete
const button = this.#button = document.createElement("button");
[21447] Fix | Delete
button.className = "colorPicker";
[21448] Fix | Delete
button.tabIndex = "0";
[21449] Fix | Delete
button.setAttribute("data-l10n-id", "pdfjs-editor-colorpicker-button");
[21450] Fix | Delete
button.setAttribute("aria-haspopup", true);
[21451] Fix | Delete
button.addEventListener("click", this.#openDropdown.bind(this));
[21452] Fix | Delete
button.addEventListener("keydown", this.#boundKeyDown);
[21453] Fix | Delete
const swatch = this.#buttonSwatch = document.createElement("span");
[21454] Fix | Delete
swatch.className = "swatch";
[21455] Fix | Delete
swatch.setAttribute("aria-hidden", true);
[21456] Fix | Delete
swatch.style.backgroundColor = this.#defaultColor;
[21457] Fix | Delete
button.append(swatch);
[21458] Fix | Delete
return button;
[21459] Fix | Delete
}
[21460] Fix | Delete
renderMainDropdown() {
[21461] Fix | Delete
const dropdown = this.#dropdown = this.#getDropdownRoot();
[21462] Fix | Delete
dropdown.setAttribute("aria-orientation", "horizontal");
[21463] Fix | Delete
dropdown.setAttribute("aria-labelledby", "highlightColorPickerLabel");
[21464] Fix | Delete
return dropdown;
[21465] Fix | Delete
}
[21466] Fix | Delete
#getDropdownRoot() {
[21467] Fix | Delete
const div = document.createElement("div");
[21468] Fix | Delete
div.addEventListener("contextmenu", noContextMenu);
[21469] Fix | Delete
div.className = "dropdown";
[21470] Fix | Delete
div.role = "listbox";
[21471] Fix | Delete
div.setAttribute("aria-multiselectable", false);
[21472] Fix | Delete
div.setAttribute("aria-orientation", "vertical");
[21473] Fix | Delete
div.setAttribute("data-l10n-id", "pdfjs-editor-colorpicker-dropdown");
[21474] Fix | Delete
for (const [name, color] of this.#uiManager.highlightColors) {
[21475] Fix | Delete
const button = document.createElement("button");
[21476] Fix | Delete
button.tabIndex = "0";
[21477] Fix | Delete
button.role = "option";
[21478] Fix | Delete
button.setAttribute("data-color", color);
[21479] Fix | Delete
button.title = name;
[21480] Fix | Delete
button.setAttribute("data-l10n-id", `pdfjs-editor-colorpicker-${name}`);
[21481] Fix | Delete
const swatch = document.createElement("span");
[21482] Fix | Delete
button.append(swatch);
[21483] Fix | Delete
swatch.className = "swatch";
[21484] Fix | Delete
swatch.style.backgroundColor = color;
[21485] Fix | Delete
button.setAttribute("aria-selected", color === this.#defaultColor);
[21486] Fix | Delete
button.addEventListener("click", this.#colorSelect.bind(this, color));
[21487] Fix | Delete
div.append(button);
[21488] Fix | Delete
}
[21489] Fix | Delete
div.addEventListener("keydown", this.#boundKeyDown);
[21490] Fix | Delete
return div;
[21491] Fix | Delete
}
[21492] Fix | Delete
#colorSelect(color, event) {
[21493] Fix | Delete
event.stopPropagation();
[21494] Fix | Delete
this.#eventBus.dispatch("switchannotationeditorparams", {
[21495] Fix | Delete
source: this,
[21496] Fix | Delete
type: this.#type,
[21497] Fix | Delete
value: color
[21498] Fix | Delete
});
[21499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function