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
}
[20500] Fix | Delete
disableEditing() {
[20501] Fix | Delete
this.editorDiv.setAttribute("role", "comment");
[20502] Fix | Delete
this.editorDiv.removeAttribute("aria-multiline");
[20503] Fix | Delete
}
[20504] Fix | Delete
enableEditing() {
[20505] Fix | Delete
this.editorDiv.setAttribute("role", "textbox");
[20506] Fix | Delete
this.editorDiv.setAttribute("aria-multiline", true);
[20507] Fix | Delete
}
[20508] Fix | Delete
render() {
[20509] Fix | Delete
if (this.div) {
[20510] Fix | Delete
return this.div;
[20511] Fix | Delete
}
[20512] Fix | Delete
let baseX, baseY;
[20513] Fix | Delete
if (this.width) {
[20514] Fix | Delete
baseX = this.x;
[20515] Fix | Delete
baseY = this.y;
[20516] Fix | Delete
}
[20517] Fix | Delete
super.render();
[20518] Fix | Delete
this.editorDiv = document.createElement("div");
[20519] Fix | Delete
this.editorDiv.className = "internal";
[20520] Fix | Delete
this.editorDiv.setAttribute("id", this.#editorDivId);
[20521] Fix | Delete
this.editorDiv.setAttribute("data-l10n-id", "pdfjs-free-text");
[20522] Fix | Delete
this.enableEditing();
[20523] Fix | Delete
AnnotationEditor._l10nPromise.get("pdfjs-free-text-default-content").then(msg => this.editorDiv?.setAttribute("default-content", msg));
[20524] Fix | Delete
this.editorDiv.contentEditable = true;
[20525] Fix | Delete
const {
[20526] Fix | Delete
style
[20527] Fix | Delete
} = this.editorDiv;
[20528] Fix | Delete
style.fontSize = `calc(${this.#fontSize}px * var(--scale-factor))`;
[20529] Fix | Delete
style.color = this.#color;
[20530] Fix | Delete
this.div.append(this.editorDiv);
[20531] Fix | Delete
this.overlayDiv = document.createElement("div");
[20532] Fix | Delete
this.overlayDiv.classList.add("overlay", "enabled");
[20533] Fix | Delete
this.div.append(this.overlayDiv);
[20534] Fix | Delete
bindEvents(this, this.div, ["dblclick", "keydown"]);
[20535] Fix | Delete
if (this.width) {
[20536] Fix | Delete
const [parentWidth, parentHeight] = this.parentDimensions;
[20537] Fix | Delete
if (this.annotationElementId) {
[20538] Fix | Delete
const {
[20539] Fix | Delete
position
[20540] Fix | Delete
} = this.#initialData;
[20541] Fix | Delete
let [tx, ty] = this.getInitialTranslation();
[20542] Fix | Delete
[tx, ty] = this.pageTranslationToScreen(tx, ty);
[20543] Fix | Delete
const [pageWidth, pageHeight] = this.pageDimensions;
[20544] Fix | Delete
const [pageX, pageY] = this.pageTranslation;
[20545] Fix | Delete
let posX, posY;
[20546] Fix | Delete
switch (this.rotation) {
[20547] Fix | Delete
case 0:
[20548] Fix | Delete
posX = baseX + (position[0] - pageX) / pageWidth;
[20549] Fix | Delete
posY = baseY + this.height - (position[1] - pageY) / pageHeight;
[20550] Fix | Delete
break;
[20551] Fix | Delete
case 90:
[20552] Fix | Delete
posX = baseX + (position[0] - pageX) / pageWidth;
[20553] Fix | Delete
posY = baseY - (position[1] - pageY) / pageHeight;
[20554] Fix | Delete
[tx, ty] = [ty, -tx];
[20555] Fix | Delete
break;
[20556] Fix | Delete
case 180:
[20557] Fix | Delete
posX = baseX - this.width + (position[0] - pageX) / pageWidth;
[20558] Fix | Delete
posY = baseY - (position[1] - pageY) / pageHeight;
[20559] Fix | Delete
[tx, ty] = [-tx, -ty];
[20560] Fix | Delete
break;
[20561] Fix | Delete
case 270:
[20562] Fix | Delete
posX = baseX + (position[0] - pageX - this.height * pageHeight) / pageWidth;
[20563] Fix | Delete
posY = baseY + (position[1] - pageY - this.width * pageWidth) / pageHeight;
[20564] Fix | Delete
[tx, ty] = [-ty, tx];
[20565] Fix | Delete
break;
[20566] Fix | Delete
}
[20567] Fix | Delete
this.setAt(posX * parentWidth, posY * parentHeight, tx, ty);
[20568] Fix | Delete
} else {
[20569] Fix | Delete
this.setAt(baseX * parentWidth, baseY * parentHeight, this.width * parentWidth, this.height * parentHeight);
[20570] Fix | Delete
}
[20571] Fix | Delete
this.#setContent();
[20572] Fix | Delete
this._isDraggable = true;
[20573] Fix | Delete
this.editorDiv.contentEditable = false;
[20574] Fix | Delete
} else {
[20575] Fix | Delete
this._isDraggable = false;
[20576] Fix | Delete
this.editorDiv.contentEditable = true;
[20577] Fix | Delete
}
[20578] Fix | Delete
return this.div;
[20579] Fix | Delete
}
[20580] Fix | Delete
static #getNodeContent(node) {
[20581] Fix | Delete
return (node.nodeType === Node.TEXT_NODE ? node.nodeValue : node.innerText).replaceAll(EOL_PATTERN, "");
[20582] Fix | Delete
}
[20583] Fix | Delete
editorDivPaste(event) {
[20584] Fix | Delete
const clipboardData = event.clipboardData || window.clipboardData;
[20585] Fix | Delete
const {
[20586] Fix | Delete
types
[20587] Fix | Delete
} = clipboardData;
[20588] Fix | Delete
if (types.length === 1 && types[0] === "text/plain") {
[20589] Fix | Delete
return;
[20590] Fix | Delete
}
[20591] Fix | Delete
event.preventDefault();
[20592] Fix | Delete
const paste = FreeTextEditor.#deserializeContent(clipboardData.getData("text") || "").replaceAll(EOL_PATTERN, "\n");
[20593] Fix | Delete
if (!paste) {
[20594] Fix | Delete
return;
[20595] Fix | Delete
}
[20596] Fix | Delete
const selection = window.getSelection();
[20597] Fix | Delete
if (!selection.rangeCount) {
[20598] Fix | Delete
return;
[20599] Fix | Delete
}
[20600] Fix | Delete
this.editorDiv.normalize();
[20601] Fix | Delete
selection.deleteFromDocument();
[20602] Fix | Delete
const range = selection.getRangeAt(0);
[20603] Fix | Delete
if (!paste.includes("\n")) {
[20604] Fix | Delete
range.insertNode(document.createTextNode(paste));
[20605] Fix | Delete
this.editorDiv.normalize();
[20606] Fix | Delete
selection.collapseToStart();
[20607] Fix | Delete
return;
[20608] Fix | Delete
}
[20609] Fix | Delete
const {
[20610] Fix | Delete
startContainer,
[20611] Fix | Delete
startOffset
[20612] Fix | Delete
} = range;
[20613] Fix | Delete
const bufferBefore = [];
[20614] Fix | Delete
const bufferAfter = [];
[20615] Fix | Delete
if (startContainer.nodeType === Node.TEXT_NODE) {
[20616] Fix | Delete
const parent = startContainer.parentElement;
[20617] Fix | Delete
bufferAfter.push(startContainer.nodeValue.slice(startOffset).replaceAll(EOL_PATTERN, ""));
[20618] Fix | Delete
if (parent !== this.editorDiv) {
[20619] Fix | Delete
let buffer = bufferBefore;
[20620] Fix | Delete
for (const child of this.editorDiv.childNodes) {
[20621] Fix | Delete
if (child === parent) {
[20622] Fix | Delete
buffer = bufferAfter;
[20623] Fix | Delete
continue;
[20624] Fix | Delete
}
[20625] Fix | Delete
buffer.push(FreeTextEditor.#getNodeContent(child));
[20626] Fix | Delete
}
[20627] Fix | Delete
}
[20628] Fix | Delete
bufferBefore.push(startContainer.nodeValue.slice(0, startOffset).replaceAll(EOL_PATTERN, ""));
[20629] Fix | Delete
} else if (startContainer === this.editorDiv) {
[20630] Fix | Delete
let buffer = bufferBefore;
[20631] Fix | Delete
let i = 0;
[20632] Fix | Delete
for (const child of this.editorDiv.childNodes) {
[20633] Fix | Delete
if (i++ === startOffset) {
[20634] Fix | Delete
buffer = bufferAfter;
[20635] Fix | Delete
}
[20636] Fix | Delete
buffer.push(FreeTextEditor.#getNodeContent(child));
[20637] Fix | Delete
}
[20638] Fix | Delete
}
[20639] Fix | Delete
this.#content = `${bufferBefore.join("\n")}${paste}${bufferAfter.join("\n")}`;
[20640] Fix | Delete
this.#setContent();
[20641] Fix | Delete
const newRange = new Range();
[20642] Fix | Delete
let beforeLength = bufferBefore.reduce((acc, line) => acc + line.length, 0);
[20643] Fix | Delete
for (const {
[20644] Fix | Delete
firstChild
[20645] Fix | Delete
} of this.editorDiv.childNodes) {
[20646] Fix | Delete
if (firstChild.nodeType === Node.TEXT_NODE) {
[20647] Fix | Delete
const length = firstChild.nodeValue.length;
[20648] Fix | Delete
if (beforeLength <= length) {
[20649] Fix | Delete
newRange.setStart(firstChild, beforeLength);
[20650] Fix | Delete
newRange.setEnd(firstChild, beforeLength);
[20651] Fix | Delete
break;
[20652] Fix | Delete
}
[20653] Fix | Delete
beforeLength -= length;
[20654] Fix | Delete
}
[20655] Fix | Delete
}
[20656] Fix | Delete
selection.removeAllRanges();
[20657] Fix | Delete
selection.addRange(newRange);
[20658] Fix | Delete
}
[20659] Fix | Delete
#setContent() {
[20660] Fix | Delete
this.editorDiv.replaceChildren();
[20661] Fix | Delete
if (!this.#content) {
[20662] Fix | Delete
return;
[20663] Fix | Delete
}
[20664] Fix | Delete
for (const line of this.#content.split("\n")) {
[20665] Fix | Delete
const div = document.createElement("div");
[20666] Fix | Delete
div.append(line ? document.createTextNode(line) : document.createElement("br"));
[20667] Fix | Delete
this.editorDiv.append(div);
[20668] Fix | Delete
}
[20669] Fix | Delete
}
[20670] Fix | Delete
#serializeContent() {
[20671] Fix | Delete
return this.#content.replaceAll("\xa0", " ");
[20672] Fix | Delete
}
[20673] Fix | Delete
static #deserializeContent(content) {
[20674] Fix | Delete
return content.replaceAll(" ", "\xa0");
[20675] Fix | Delete
}
[20676] Fix | Delete
get contentDiv() {
[20677] Fix | Delete
return this.editorDiv;
[20678] Fix | Delete
}
[20679] Fix | Delete
static deserialize(data, parent, uiManager) {
[20680] Fix | Delete
let initialData = null;
[20681] Fix | Delete
if (data instanceof FreeTextAnnotationElement) {
[20682] Fix | Delete
const {
[20683] Fix | Delete
data: {
[20684] Fix | Delete
defaultAppearanceData: {
[20685] Fix | Delete
fontSize,
[20686] Fix | Delete
fontColor
[20687] Fix | Delete
},
[20688] Fix | Delete
rect,
[20689] Fix | Delete
rotation,
[20690] Fix | Delete
id
[20691] Fix | Delete
},
[20692] Fix | Delete
textContent,
[20693] Fix | Delete
textPosition,
[20694] Fix | Delete
parent: {
[20695] Fix | Delete
page: {
[20696] Fix | Delete
pageNumber
[20697] Fix | Delete
}
[20698] Fix | Delete
}
[20699] Fix | Delete
} = data;
[20700] Fix | Delete
if (!textContent || textContent.length === 0) {
[20701] Fix | Delete
return null;
[20702] Fix | Delete
}
[20703] Fix | Delete
initialData = data = {
[20704] Fix | Delete
annotationType: AnnotationEditorType.FREETEXT,
[20705] Fix | Delete
color: Array.from(fontColor),
[20706] Fix | Delete
fontSize,
[20707] Fix | Delete
value: textContent.join("\n"),
[20708] Fix | Delete
position: textPosition,
[20709] Fix | Delete
pageIndex: pageNumber - 1,
[20710] Fix | Delete
rect: rect.slice(0),
[20711] Fix | Delete
rotation,
[20712] Fix | Delete
id,
[20713] Fix | Delete
deleted: false
[20714] Fix | Delete
};
[20715] Fix | Delete
}
[20716] Fix | Delete
const editor = super.deserialize(data, parent, uiManager);
[20717] Fix | Delete
editor.#fontSize = data.fontSize;
[20718] Fix | Delete
editor.#color = Util.makeHexColor(...data.color);
[20719] Fix | Delete
editor.#content = FreeTextEditor.#deserializeContent(data.value);
[20720] Fix | Delete
editor.annotationElementId = data.id || null;
[20721] Fix | Delete
editor.#initialData = initialData;
[20722] Fix | Delete
return editor;
[20723] Fix | Delete
}
[20724] Fix | Delete
serialize(isForCopying = false) {
[20725] Fix | Delete
if (this.isEmpty()) {
[20726] Fix | Delete
return null;
[20727] Fix | Delete
}
[20728] Fix | Delete
if (this.deleted) {
[20729] Fix | Delete
return {
[20730] Fix | Delete
pageIndex: this.pageIndex,
[20731] Fix | Delete
id: this.annotationElementId,
[20732] Fix | Delete
deleted: true
[20733] Fix | Delete
};
[20734] Fix | Delete
}
[20735] Fix | Delete
const padding = FreeTextEditor._internalPadding * this.parentScale;
[20736] Fix | Delete
const rect = this.getRect(padding, padding);
[20737] Fix | Delete
const color = AnnotationEditor._colorManager.convert(this.isAttachedToDOM ? getComputedStyle(this.editorDiv).color : this.#color);
[20738] Fix | Delete
const serialized = {
[20739] Fix | Delete
annotationType: AnnotationEditorType.FREETEXT,
[20740] Fix | Delete
color,
[20741] Fix | Delete
fontSize: this.#fontSize,
[20742] Fix | Delete
value: this.#serializeContent(),
[20743] Fix | Delete
pageIndex: this.pageIndex,
[20744] Fix | Delete
rect,
[20745] Fix | Delete
rotation: this.rotation,
[20746] Fix | Delete
structTreeParentId: this._structTreeParentId
[20747] Fix | Delete
};
[20748] Fix | Delete
if (isForCopying) {
[20749] Fix | Delete
return serialized;
[20750] Fix | Delete
}
[20751] Fix | Delete
if (this.annotationElementId && !this.#hasElementChanged(serialized)) {
[20752] Fix | Delete
return null;
[20753] Fix | Delete
}
[20754] Fix | Delete
serialized.id = this.annotationElementId;
[20755] Fix | Delete
return serialized;
[20756] Fix | Delete
}
[20757] Fix | Delete
#hasElementChanged(serialized) {
[20758] Fix | Delete
const {
[20759] Fix | Delete
value,
[20760] Fix | Delete
fontSize,
[20761] Fix | Delete
color,
[20762] Fix | Delete
pageIndex
[20763] Fix | Delete
} = this.#initialData;
[20764] Fix | Delete
return this._hasBeenMoved || serialized.value !== value || serialized.fontSize !== fontSize || serialized.color.some((c, i) => c !== color[i]) || serialized.pageIndex !== pageIndex;
[20765] Fix | Delete
}
[20766] Fix | Delete
renderAnnotationElement(annotation) {
[20767] Fix | Delete
const content = super.renderAnnotationElement(annotation);
[20768] Fix | Delete
if (this.deleted) {
[20769] Fix | Delete
return content;
[20770] Fix | Delete
}
[20771] Fix | Delete
const {
[20772] Fix | Delete
style
[20773] Fix | Delete
} = content;
[20774] Fix | Delete
style.fontSize = `calc(${this.#fontSize}px * var(--scale-factor))`;
[20775] Fix | Delete
style.color = this.#color;
[20776] Fix | Delete
content.replaceChildren();
[20777] Fix | Delete
for (const line of this.#content.split("\n")) {
[20778] Fix | Delete
const div = document.createElement("div");
[20779] Fix | Delete
div.append(line ? document.createTextNode(line) : document.createElement("br"));
[20780] Fix | Delete
content.append(div);
[20781] Fix | Delete
}
[20782] Fix | Delete
const padding = FreeTextEditor._internalPadding * this.parentScale;
[20783] Fix | Delete
annotation.updateEdited({
[20784] Fix | Delete
rect: this.getRect(padding, padding),
[20785] Fix | Delete
popupContent: this.#content
[20786] Fix | Delete
});
[20787] Fix | Delete
return content;
[20788] Fix | Delete
}
[20789] Fix | Delete
resetAnnotationElement(annotation) {
[20790] Fix | Delete
super.resetAnnotationElement(annotation);
[20791] Fix | Delete
annotation.resetEdited();
[20792] Fix | Delete
}
[20793] Fix | Delete
}
[20794] Fix | Delete
[20795] Fix | Delete
;// CONCATENATED MODULE: ./src/display/editor/outliner.js
[20796] Fix | Delete
[20797] Fix | Delete
[20798] Fix | Delete
[20799] Fix | Delete
[20800] Fix | Delete
[20801] Fix | Delete
[20802] Fix | Delete
[20803] Fix | Delete
[20804] Fix | Delete
[20805] Fix | Delete
[20806] Fix | Delete
[20807] Fix | Delete
[20808] Fix | Delete
[20809] Fix | Delete
[20810] Fix | Delete
[20811] Fix | Delete
class Outliner {
[20812] Fix | Delete
#box;
[20813] Fix | Delete
#verticalEdges = [];
[20814] Fix | Delete
#intervals = [];
[20815] Fix | Delete
constructor(boxes, borderWidth = 0, innerMargin = 0, isLTR = true) {
[20816] Fix | Delete
let minX = Infinity;
[20817] Fix | Delete
let maxX = -Infinity;
[20818] Fix | Delete
let minY = Infinity;
[20819] Fix | Delete
let maxY = -Infinity;
[20820] Fix | Delete
const NUMBER_OF_DIGITS = 4;
[20821] Fix | Delete
const EPSILON = 10 ** -NUMBER_OF_DIGITS;
[20822] Fix | Delete
for (const {
[20823] Fix | Delete
x,
[20824] Fix | Delete
y,
[20825] Fix | Delete
width,
[20826] Fix | Delete
height
[20827] Fix | Delete
} of boxes) {
[20828] Fix | Delete
const x1 = Math.floor((x - borderWidth) / EPSILON) * EPSILON;
[20829] Fix | Delete
const x2 = Math.ceil((x + width + borderWidth) / EPSILON) * EPSILON;
[20830] Fix | Delete
const y1 = Math.floor((y - borderWidth) / EPSILON) * EPSILON;
[20831] Fix | Delete
const y2 = Math.ceil((y + height + borderWidth) / EPSILON) * EPSILON;
[20832] Fix | Delete
const left = [x1, y1, y2, true];
[20833] Fix | Delete
const right = [x2, y1, y2, false];
[20834] Fix | Delete
this.#verticalEdges.push(left, right);
[20835] Fix | Delete
minX = Math.min(minX, x1);
[20836] Fix | Delete
maxX = Math.max(maxX, x2);
[20837] Fix | Delete
minY = Math.min(minY, y1);
[20838] Fix | Delete
maxY = Math.max(maxY, y2);
[20839] Fix | Delete
}
[20840] Fix | Delete
const bboxWidth = maxX - minX + 2 * innerMargin;
[20841] Fix | Delete
const bboxHeight = maxY - minY + 2 * innerMargin;
[20842] Fix | Delete
const shiftedMinX = minX - innerMargin;
[20843] Fix | Delete
const shiftedMinY = minY - innerMargin;
[20844] Fix | Delete
const lastEdge = this.#verticalEdges.at(isLTR ? -1 : -2);
[20845] Fix | Delete
const lastPoint = [lastEdge[0], lastEdge[2]];
[20846] Fix | Delete
for (const edge of this.#verticalEdges) {
[20847] Fix | Delete
const [x, y1, y2] = edge;
[20848] Fix | Delete
edge[0] = (x - shiftedMinX) / bboxWidth;
[20849] Fix | Delete
edge[1] = (y1 - shiftedMinY) / bboxHeight;
[20850] Fix | Delete
edge[2] = (y2 - shiftedMinY) / bboxHeight;
[20851] Fix | Delete
}
[20852] Fix | Delete
this.#box = {
[20853] Fix | Delete
x: shiftedMinX,
[20854] Fix | Delete
y: shiftedMinY,
[20855] Fix | Delete
width: bboxWidth,
[20856] Fix | Delete
height: bboxHeight,
[20857] Fix | Delete
lastPoint
[20858] Fix | Delete
};
[20859] Fix | Delete
}
[20860] Fix | Delete
getOutlines() {
[20861] Fix | Delete
this.#verticalEdges.sort((a, b) => a[0] - b[0] || a[1] - b[1] || a[2] - b[2]);
[20862] Fix | Delete
const outlineVerticalEdges = [];
[20863] Fix | Delete
for (const edge of this.#verticalEdges) {
[20864] Fix | Delete
if (edge[3]) {
[20865] Fix | Delete
outlineVerticalEdges.push(...this.#breakEdge(edge));
[20866] Fix | Delete
this.#insert(edge);
[20867] Fix | Delete
} else {
[20868] Fix | Delete
this.#remove(edge);
[20869] Fix | Delete
outlineVerticalEdges.push(...this.#breakEdge(edge));
[20870] Fix | Delete
}
[20871] Fix | Delete
}
[20872] Fix | Delete
return this.#getOutlines(outlineVerticalEdges);
[20873] Fix | Delete
}
[20874] Fix | Delete
#getOutlines(outlineVerticalEdges) {
[20875] Fix | Delete
const edges = [];
[20876] Fix | Delete
const allEdges = new Set();
[20877] Fix | Delete
for (const edge of outlineVerticalEdges) {
[20878] Fix | Delete
const [x, y1, y2] = edge;
[20879] Fix | Delete
edges.push([x, y1, edge], [x, y2, edge]);
[20880] Fix | Delete
}
[20881] Fix | Delete
edges.sort((a, b) => a[1] - b[1] || a[0] - b[0]);
[20882] Fix | Delete
for (let i = 0, ii = edges.length; i < ii; i += 2) {
[20883] Fix | Delete
const edge1 = edges[i][2];
[20884] Fix | Delete
const edge2 = edges[i + 1][2];
[20885] Fix | Delete
edge1.push(edge2);
[20886] Fix | Delete
edge2.push(edge1);
[20887] Fix | Delete
allEdges.add(edge1);
[20888] Fix | Delete
allEdges.add(edge2);
[20889] Fix | Delete
}
[20890] Fix | Delete
const outlines = [];
[20891] Fix | Delete
let outline;
[20892] Fix | Delete
while (allEdges.size > 0) {
[20893] Fix | Delete
const edge = allEdges.values().next().value;
[20894] Fix | Delete
let [x, y1, y2, edge1, edge2] = edge;
[20895] Fix | Delete
allEdges.delete(edge);
[20896] Fix | Delete
let lastPointX = x;
[20897] Fix | Delete
let lastPointY = y1;
[20898] Fix | Delete
outline = [x, y2];
[20899] Fix | Delete
outlines.push(outline);
[20900] Fix | Delete
while (true) {
[20901] Fix | Delete
let e;
[20902] Fix | Delete
if (allEdges.has(edge1)) {
[20903] Fix | Delete
e = edge1;
[20904] Fix | Delete
} else if (allEdges.has(edge2)) {
[20905] Fix | Delete
e = edge2;
[20906] Fix | Delete
} else {
[20907] Fix | Delete
break;
[20908] Fix | Delete
}
[20909] Fix | Delete
allEdges.delete(e);
[20910] Fix | Delete
[x, y1, y2, edge1, edge2] = e;
[20911] Fix | Delete
if (lastPointX !== x) {
[20912] Fix | Delete
outline.push(lastPointX, lastPointY, x, lastPointY === y1 ? y1 : y2);
[20913] Fix | Delete
lastPointX = x;
[20914] Fix | Delete
}
[20915] Fix | Delete
lastPointY = lastPointY === y1 ? y2 : y1;
[20916] Fix | Delete
}
[20917] Fix | Delete
outline.push(lastPointX, lastPointY);
[20918] Fix | Delete
}
[20919] Fix | Delete
return new HighlightOutline(outlines, this.#box);
[20920] Fix | Delete
}
[20921] Fix | Delete
#binarySearch(y) {
[20922] Fix | Delete
const array = this.#intervals;
[20923] Fix | Delete
let start = 0;
[20924] Fix | Delete
let end = array.length - 1;
[20925] Fix | Delete
while (start <= end) {
[20926] Fix | Delete
const middle = start + end >> 1;
[20927] Fix | Delete
const y1 = array[middle][0];
[20928] Fix | Delete
if (y1 === y) {
[20929] Fix | Delete
return middle;
[20930] Fix | Delete
}
[20931] Fix | Delete
if (y1 < y) {
[20932] Fix | Delete
start = middle + 1;
[20933] Fix | Delete
} else {
[20934] Fix | Delete
end = middle - 1;
[20935] Fix | Delete
}
[20936] Fix | Delete
}
[20937] Fix | Delete
return end + 1;
[20938] Fix | Delete
}
[20939] Fix | Delete
#insert([, y1, y2]) {
[20940] Fix | Delete
const index = this.#binarySearch(y1);
[20941] Fix | Delete
this.#intervals.splice(index, 0, [y1, y2]);
[20942] Fix | Delete
}
[20943] Fix | Delete
#remove([, y1, y2]) {
[20944] Fix | Delete
const index = this.#binarySearch(y1);
[20945] Fix | Delete
for (let i = index; i < this.#intervals.length; i++) {
[20946] Fix | Delete
const [start, end] = this.#intervals[i];
[20947] Fix | Delete
if (start !== y1) {
[20948] Fix | Delete
break;
[20949] Fix | Delete
}
[20950] Fix | Delete
if (start === y1 && end === y2) {
[20951] Fix | Delete
this.#intervals.splice(i, 1);
[20952] Fix | Delete
return;
[20953] Fix | Delete
}
[20954] Fix | Delete
}
[20955] Fix | Delete
for (let i = index - 1; i >= 0; i--) {
[20956] Fix | Delete
const [start, end] = this.#intervals[i];
[20957] Fix | Delete
if (start !== y1) {
[20958] Fix | Delete
break;
[20959] Fix | Delete
}
[20960] Fix | Delete
if (start === y1 && end === y2) {
[20961] Fix | Delete
this.#intervals.splice(i, 1);
[20962] Fix | Delete
return;
[20963] Fix | Delete
}
[20964] Fix | Delete
}
[20965] Fix | Delete
}
[20966] Fix | Delete
#breakEdge(edge) {
[20967] Fix | Delete
const [x, y1, y2] = edge;
[20968] Fix | Delete
const results = [[x, y1, y2]];
[20969] Fix | Delete
const index = this.#binarySearch(y2);
[20970] Fix | Delete
for (let i = 0; i < index; i++) {
[20971] Fix | Delete
const [start, end] = this.#intervals[i];
[20972] Fix | Delete
for (let j = 0, jj = results.length; j < jj; j++) {
[20973] Fix | Delete
const [, y3, y4] = results[j];
[20974] Fix | Delete
if (end <= y3 || y4 <= start) {
[20975] Fix | Delete
continue;
[20976] Fix | Delete
}
[20977] Fix | Delete
if (y3 >= start) {
[20978] Fix | Delete
if (y4 > end) {
[20979] Fix | Delete
results[j][1] = end;
[20980] Fix | Delete
} else {
[20981] Fix | Delete
if (jj === 1) {
[20982] Fix | Delete
return [];
[20983] Fix | Delete
}
[20984] Fix | Delete
results.splice(j, 1);
[20985] Fix | Delete
j--;
[20986] Fix | Delete
jj--;
[20987] Fix | Delete
}
[20988] Fix | Delete
continue;
[20989] Fix | Delete
}
[20990] Fix | Delete
results[j][2] = start;
[20991] Fix | Delete
if (y4 > end) {
[20992] Fix | Delete
results.push([x, end, y4]);
[20993] Fix | Delete
}
[20994] Fix | Delete
}
[20995] Fix | Delete
}
[20996] Fix | Delete
return results;
[20997] Fix | Delete
}
[20998] Fix | Delete
}
[20999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function