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/clone/wp-conte.../plugins/embedpre.../assets/pdf/build
File: script.js
}
[20000] Fix | Delete
render() {
[20001] Fix | Delete
this.container.classList.add("fileAttachmentAnnotation");
[20002] Fix | Delete
const {
[20003] Fix | Delete
container,
[20004] Fix | Delete
data
[20005] Fix | Delete
} = this;
[20006] Fix | Delete
let trigger;
[20007] Fix | Delete
if (data.hasAppearance || data.fillAlpha === 0) {
[20008] Fix | Delete
trigger = document.createElement("div");
[20009] Fix | Delete
} else {
[20010] Fix | Delete
trigger = document.createElement("img");
[20011] Fix | Delete
trigger.src = `${this.imageResourcesPath}annotation-${/paperclip/i.test(data.name) ? "paperclip" : "pushpin"}.svg`;
[20012] Fix | Delete
if (data.fillAlpha && data.fillAlpha < 1) {
[20013] Fix | Delete
trigger.style = `filter: opacity(${Math.round(data.fillAlpha * 100)}%);`;
[20014] Fix | Delete
}
[20015] Fix | Delete
}
[20016] Fix | Delete
trigger.addEventListener("dblclick", this.#download.bind(this));
[20017] Fix | Delete
this.#trigger = trigger;
[20018] Fix | Delete
const {
[20019] Fix | Delete
isMac
[20020] Fix | Delete
} = util_FeatureTest.platform;
[20021] Fix | Delete
container.addEventListener("keydown", evt => {
[20022] Fix | Delete
if (evt.key === "Enter" && (isMac ? evt.metaKey : evt.ctrlKey)) {
[20023] Fix | Delete
this.#download();
[20024] Fix | Delete
}
[20025] Fix | Delete
});
[20026] Fix | Delete
if (!data.popupRef && this.hasPopupData) {
[20027] Fix | Delete
this._createPopup();
[20028] Fix | Delete
} else {
[20029] Fix | Delete
trigger.classList.add("popupTriggerArea");
[20030] Fix | Delete
}
[20031] Fix | Delete
container.append(trigger);
[20032] Fix | Delete
return container;
[20033] Fix | Delete
}
[20034] Fix | Delete
getElementsToTriggerPopup() {
[20035] Fix | Delete
return this.#trigger;
[20036] Fix | Delete
}
[20037] Fix | Delete
addHighlightArea() {
[20038] Fix | Delete
this.container.classList.add("highlightArea");
[20039] Fix | Delete
}
[20040] Fix | Delete
#download() {
[20041] Fix | Delete
this.downloadManager?.openOrDownloadData(this.content, this.filename);
[20042] Fix | Delete
}
[20043] Fix | Delete
}
[20044] Fix | Delete
class AnnotationLayer {
[20045] Fix | Delete
#accessibilityManager = null;
[20046] Fix | Delete
#annotationCanvasMap = null;
[20047] Fix | Delete
#editableAnnotations = new Map();
[20048] Fix | Delete
constructor({
[20049] Fix | Delete
div,
[20050] Fix | Delete
accessibilityManager,
[20051] Fix | Delete
annotationCanvasMap,
[20052] Fix | Delete
annotationEditorUIManager,
[20053] Fix | Delete
page,
[20054] Fix | Delete
viewport
[20055] Fix | Delete
}) {
[20056] Fix | Delete
this.div = div;
[20057] Fix | Delete
this.#accessibilityManager = accessibilityManager;
[20058] Fix | Delete
this.#annotationCanvasMap = annotationCanvasMap;
[20059] Fix | Delete
this.page = page;
[20060] Fix | Delete
this.viewport = viewport;
[20061] Fix | Delete
this.zIndex = 0;
[20062] Fix | Delete
this._annotationEditorUIManager = annotationEditorUIManager;
[20063] Fix | Delete
}
[20064] Fix | Delete
#appendElement(element, id) {
[20065] Fix | Delete
const contentElement = element.firstChild || element;
[20066] Fix | Delete
contentElement.id = `${AnnotationPrefix}${id}`;
[20067] Fix | Delete
this.div.append(element);
[20068] Fix | Delete
this.#accessibilityManager?.moveElementInDOM(this.div, element, contentElement, false);
[20069] Fix | Delete
}
[20070] Fix | Delete
async render(params) {
[20071] Fix | Delete
const {
[20072] Fix | Delete
annotations
[20073] Fix | Delete
} = params;
[20074] Fix | Delete
const layer = this.div;
[20075] Fix | Delete
setLayerDimensions(layer, this.viewport);
[20076] Fix | Delete
const popupToElements = new Map();
[20077] Fix | Delete
const elementParams = {
[20078] Fix | Delete
data: null,
[20079] Fix | Delete
layer,
[20080] Fix | Delete
linkService: params.linkService,
[20081] Fix | Delete
downloadManager: params.downloadManager,
[20082] Fix | Delete
imageResourcesPath: params.imageResourcesPath || "",
[20083] Fix | Delete
renderForms: params.renderForms !== false,
[20084] Fix | Delete
svgFactory: new DOMSVGFactory(),
[20085] Fix | Delete
annotationStorage: params.annotationStorage || new AnnotationStorage(),
[20086] Fix | Delete
enableScripting: params.enableScripting === true,
[20087] Fix | Delete
hasJSActions: params.hasJSActions,
[20088] Fix | Delete
fieldObjects: params.fieldObjects,
[20089] Fix | Delete
parent: this,
[20090] Fix | Delete
elements: null
[20091] Fix | Delete
};
[20092] Fix | Delete
for (const data of annotations) {
[20093] Fix | Delete
if (data.noHTML) {
[20094] Fix | Delete
continue;
[20095] Fix | Delete
}
[20096] Fix | Delete
const isPopupAnnotation = data.annotationType === AnnotationType.POPUP;
[20097] Fix | Delete
if (!isPopupAnnotation) {
[20098] Fix | Delete
const {
[20099] Fix | Delete
width,
[20100] Fix | Delete
height
[20101] Fix | Delete
} = getRectDims(data.rect);
[20102] Fix | Delete
if (width <= 0 || height <= 0) {
[20103] Fix | Delete
continue;
[20104] Fix | Delete
}
[20105] Fix | Delete
} else {
[20106] Fix | Delete
const elements = popupToElements.get(data.id);
[20107] Fix | Delete
if (!elements) {
[20108] Fix | Delete
continue;
[20109] Fix | Delete
}
[20110] Fix | Delete
elementParams.elements = elements;
[20111] Fix | Delete
}
[20112] Fix | Delete
elementParams.data = data;
[20113] Fix | Delete
const element = AnnotationElementFactory.create(elementParams);
[20114] Fix | Delete
if (!element.isRenderable) {
[20115] Fix | Delete
continue;
[20116] Fix | Delete
}
[20117] Fix | Delete
if (!isPopupAnnotation && data.popupRef) {
[20118] Fix | Delete
const elements = popupToElements.get(data.popupRef);
[20119] Fix | Delete
if (!elements) {
[20120] Fix | Delete
popupToElements.set(data.popupRef, [element]);
[20121] Fix | Delete
} else {
[20122] Fix | Delete
elements.push(element);
[20123] Fix | Delete
}
[20124] Fix | Delete
}
[20125] Fix | Delete
const rendered = element.render();
[20126] Fix | Delete
if (data.hidden) {
[20127] Fix | Delete
rendered.style.visibility = "hidden";
[20128] Fix | Delete
}
[20129] Fix | Delete
this.#appendElement(rendered, data.id);
[20130] Fix | Delete
if (element.annotationEditorType > 0) {
[20131] Fix | Delete
this.#editableAnnotations.set(element.data.id, element);
[20132] Fix | Delete
this._annotationEditorUIManager?.renderAnnotationElement(element);
[20133] Fix | Delete
}
[20134] Fix | Delete
}
[20135] Fix | Delete
this.#setAnnotationCanvasMap();
[20136] Fix | Delete
}
[20137] Fix | Delete
update({
[20138] Fix | Delete
viewport
[20139] Fix | Delete
}) {
[20140] Fix | Delete
const layer = this.div;
[20141] Fix | Delete
this.viewport = viewport;
[20142] Fix | Delete
setLayerDimensions(layer, {
[20143] Fix | Delete
rotation: viewport.rotation
[20144] Fix | Delete
});
[20145] Fix | Delete
this.#setAnnotationCanvasMap();
[20146] Fix | Delete
layer.hidden = false;
[20147] Fix | Delete
}
[20148] Fix | Delete
#setAnnotationCanvasMap() {
[20149] Fix | Delete
if (!this.#annotationCanvasMap) {
[20150] Fix | Delete
return;
[20151] Fix | Delete
}
[20152] Fix | Delete
const layer = this.div;
[20153] Fix | Delete
for (const [id, canvas] of this.#annotationCanvasMap) {
[20154] Fix | Delete
const element = layer.querySelector(`[data-annotation-id="${id}"]`);
[20155] Fix | Delete
if (!element) {
[20156] Fix | Delete
continue;
[20157] Fix | Delete
}
[20158] Fix | Delete
canvas.className = "annotationContent";
[20159] Fix | Delete
const {
[20160] Fix | Delete
firstChild
[20161] Fix | Delete
} = element;
[20162] Fix | Delete
if (!firstChild) {
[20163] Fix | Delete
element.append(canvas);
[20164] Fix | Delete
} else if (firstChild.nodeName === "CANVAS") {
[20165] Fix | Delete
firstChild.replaceWith(canvas);
[20166] Fix | Delete
} else if (!firstChild.classList.contains("annotationContent")) {
[20167] Fix | Delete
firstChild.before(canvas);
[20168] Fix | Delete
} else {
[20169] Fix | Delete
firstChild.after(canvas);
[20170] Fix | Delete
}
[20171] Fix | Delete
}
[20172] Fix | Delete
this.#annotationCanvasMap.clear();
[20173] Fix | Delete
}
[20174] Fix | Delete
getEditableAnnotations() {
[20175] Fix | Delete
return Array.from(this.#editableAnnotations.values());
[20176] Fix | Delete
}
[20177] Fix | Delete
getEditableAnnotation(id) {
[20178] Fix | Delete
return this.#editableAnnotations.get(id);
[20179] Fix | Delete
}
[20180] Fix | Delete
}
[20181] Fix | Delete
[20182] Fix | Delete
;// CONCATENATED MODULE: ./src/display/editor/freetext.js
[20183] Fix | Delete
[20184] Fix | Delete
[20185] Fix | Delete
[20186] Fix | Delete
[20187] Fix | Delete
[20188] Fix | Delete
[20189] Fix | Delete
[20190] Fix | Delete
const EOL_PATTERN = /\r\n?|\n/g;
[20191] Fix | Delete
class FreeTextEditor extends AnnotationEditor {
[20192] Fix | Delete
#boundEditorDivBlur = this.editorDivBlur.bind(this);
[20193] Fix | Delete
#boundEditorDivFocus = this.editorDivFocus.bind(this);
[20194] Fix | Delete
#boundEditorDivInput = this.editorDivInput.bind(this);
[20195] Fix | Delete
#boundEditorDivKeydown = this.editorDivKeydown.bind(this);
[20196] Fix | Delete
#boundEditorDivPaste = this.editorDivPaste.bind(this);
[20197] Fix | Delete
#color;
[20198] Fix | Delete
#content = "";
[20199] Fix | Delete
#editorDivId = `${this.id}-editor`;
[20200] Fix | Delete
#fontSize;
[20201] Fix | Delete
#initialData = null;
[20202] Fix | Delete
static _freeTextDefaultContent = "";
[20203] Fix | Delete
static _internalPadding = 0;
[20204] Fix | Delete
static _defaultColor = null;
[20205] Fix | Delete
static _defaultFontSize = 10;
[20206] Fix | Delete
static get _keyboardManager() {
[20207] Fix | Delete
const proto = FreeTextEditor.prototype;
[20208] Fix | Delete
const arrowChecker = self => self.isEmpty();
[20209] Fix | Delete
const small = AnnotationEditorUIManager.TRANSLATE_SMALL;
[20210] Fix | Delete
const big = AnnotationEditorUIManager.TRANSLATE_BIG;
[20211] Fix | Delete
return shadow(this, "_keyboardManager", new KeyboardManager([[["ctrl+s", "mac+meta+s", "ctrl+p", "mac+meta+p"], proto.commitOrRemove, {
[20212] Fix | Delete
bubbles: true
[20213] Fix | Delete
}], [["ctrl+Enter", "mac+meta+Enter", "Escape", "mac+Escape"], proto.commitOrRemove], [["ArrowLeft", "mac+ArrowLeft"], proto._translateEmpty, {
[20214] Fix | Delete
args: [-small, 0],
[20215] Fix | Delete
checker: arrowChecker
[20216] Fix | Delete
}], [["ctrl+ArrowLeft", "mac+shift+ArrowLeft"], proto._translateEmpty, {
[20217] Fix | Delete
args: [-big, 0],
[20218] Fix | Delete
checker: arrowChecker
[20219] Fix | Delete
}], [["ArrowRight", "mac+ArrowRight"], proto._translateEmpty, {
[20220] Fix | Delete
args: [small, 0],
[20221] Fix | Delete
checker: arrowChecker
[20222] Fix | Delete
}], [["ctrl+ArrowRight", "mac+shift+ArrowRight"], proto._translateEmpty, {
[20223] Fix | Delete
args: [big, 0],
[20224] Fix | Delete
checker: arrowChecker
[20225] Fix | Delete
}], [["ArrowUp", "mac+ArrowUp"], proto._translateEmpty, {
[20226] Fix | Delete
args: [0, -small],
[20227] Fix | Delete
checker: arrowChecker
[20228] Fix | Delete
}], [["ctrl+ArrowUp", "mac+shift+ArrowUp"], proto._translateEmpty, {
[20229] Fix | Delete
args: [0, -big],
[20230] Fix | Delete
checker: arrowChecker
[20231] Fix | Delete
}], [["ArrowDown", "mac+ArrowDown"], proto._translateEmpty, {
[20232] Fix | Delete
args: [0, small],
[20233] Fix | Delete
checker: arrowChecker
[20234] Fix | Delete
}], [["ctrl+ArrowDown", "mac+shift+ArrowDown"], proto._translateEmpty, {
[20235] Fix | Delete
args: [0, big],
[20236] Fix | Delete
checker: arrowChecker
[20237] Fix | Delete
}]]));
[20238] Fix | Delete
}
[20239] Fix | Delete
static _type = "freetext";
[20240] Fix | Delete
static _editorType = AnnotationEditorType.FREETEXT;
[20241] Fix | Delete
constructor(params) {
[20242] Fix | Delete
super({
[20243] Fix | Delete
...params,
[20244] Fix | Delete
name: "freeTextEditor"
[20245] Fix | Delete
});
[20246] Fix | Delete
this.#color = params.color || FreeTextEditor._defaultColor || AnnotationEditor._defaultLineColor;
[20247] Fix | Delete
this.#fontSize = params.fontSize || FreeTextEditor._defaultFontSize;
[20248] Fix | Delete
}
[20249] Fix | Delete
static initialize(l10n, uiManager) {
[20250] Fix | Delete
AnnotationEditor.initialize(l10n, uiManager, {
[20251] Fix | Delete
strings: ["pdfjs-free-text-default-content"]
[20252] Fix | Delete
});
[20253] Fix | Delete
const style = getComputedStyle(document.documentElement);
[20254] Fix | Delete
this._internalPadding = parseFloat(style.getPropertyValue("--freetext-padding"));
[20255] Fix | Delete
}
[20256] Fix | Delete
static updateDefaultParams(type, value) {
[20257] Fix | Delete
switch (type) {
[20258] Fix | Delete
case AnnotationEditorParamsType.FREETEXT_SIZE:
[20259] Fix | Delete
FreeTextEditor._defaultFontSize = value;
[20260] Fix | Delete
break;
[20261] Fix | Delete
case AnnotationEditorParamsType.FREETEXT_COLOR:
[20262] Fix | Delete
FreeTextEditor._defaultColor = value;
[20263] Fix | Delete
break;
[20264] Fix | Delete
}
[20265] Fix | Delete
}
[20266] Fix | Delete
updateParams(type, value) {
[20267] Fix | Delete
switch (type) {
[20268] Fix | Delete
case AnnotationEditorParamsType.FREETEXT_SIZE:
[20269] Fix | Delete
this.#updateFontSize(value);
[20270] Fix | Delete
break;
[20271] Fix | Delete
case AnnotationEditorParamsType.FREETEXT_COLOR:
[20272] Fix | Delete
this.#updateColor(value);
[20273] Fix | Delete
break;
[20274] Fix | Delete
}
[20275] Fix | Delete
}
[20276] Fix | Delete
static get defaultPropertiesToUpdate() {
[20277] Fix | Delete
return [[AnnotationEditorParamsType.FREETEXT_SIZE, FreeTextEditor._defaultFontSize], [AnnotationEditorParamsType.FREETEXT_COLOR, FreeTextEditor._defaultColor || AnnotationEditor._defaultLineColor]];
[20278] Fix | Delete
}
[20279] Fix | Delete
get propertiesToUpdate() {
[20280] Fix | Delete
return [[AnnotationEditorParamsType.FREETEXT_SIZE, this.#fontSize], [AnnotationEditorParamsType.FREETEXT_COLOR, this.#color]];
[20281] Fix | Delete
}
[20282] Fix | Delete
#updateFontSize(fontSize) {
[20283] Fix | Delete
const setFontsize = size => {
[20284] Fix | Delete
this.editorDiv.style.fontSize = `calc(${size}px * var(--scale-factor))`;
[20285] Fix | Delete
this.translate(0, -(size - this.#fontSize) * this.parentScale);
[20286] Fix | Delete
this.#fontSize = size;
[20287] Fix | Delete
this.#setEditorDimensions();
[20288] Fix | Delete
};
[20289] Fix | Delete
const savedFontsize = this.#fontSize;
[20290] Fix | Delete
this.addCommands({
[20291] Fix | Delete
cmd: setFontsize.bind(this, fontSize),
[20292] Fix | Delete
undo: setFontsize.bind(this, savedFontsize),
[20293] Fix | Delete
post: this._uiManager.updateUI.bind(this._uiManager, this),
[20294] Fix | Delete
mustExec: true,
[20295] Fix | Delete
type: AnnotationEditorParamsType.FREETEXT_SIZE,
[20296] Fix | Delete
overwriteIfSameType: true,
[20297] Fix | Delete
keepUndo: true
[20298] Fix | Delete
});
[20299] Fix | Delete
}
[20300] Fix | Delete
#updateColor(color) {
[20301] Fix | Delete
const setColor = col => {
[20302] Fix | Delete
this.#color = this.editorDiv.style.color = col;
[20303] Fix | Delete
};
[20304] Fix | Delete
const savedColor = this.#color;
[20305] Fix | Delete
this.addCommands({
[20306] Fix | Delete
cmd: setColor.bind(this, color),
[20307] Fix | Delete
undo: setColor.bind(this, savedColor),
[20308] Fix | Delete
post: this._uiManager.updateUI.bind(this._uiManager, this),
[20309] Fix | Delete
mustExec: true,
[20310] Fix | Delete
type: AnnotationEditorParamsType.FREETEXT_COLOR,
[20311] Fix | Delete
overwriteIfSameType: true,
[20312] Fix | Delete
keepUndo: true
[20313] Fix | Delete
});
[20314] Fix | Delete
}
[20315] Fix | Delete
_translateEmpty(x, y) {
[20316] Fix | Delete
this._uiManager.translateSelectedEditors(x, y, true);
[20317] Fix | Delete
}
[20318] Fix | Delete
getInitialTranslation() {
[20319] Fix | Delete
const scale = this.parentScale;
[20320] Fix | Delete
return [-FreeTextEditor._internalPadding * scale, -(FreeTextEditor._internalPadding + this.#fontSize) * scale];
[20321] Fix | Delete
}
[20322] Fix | Delete
rebuild() {
[20323] Fix | Delete
if (!this.parent) {
[20324] Fix | Delete
return;
[20325] Fix | Delete
}
[20326] Fix | Delete
super.rebuild();
[20327] Fix | Delete
if (this.div === null) {
[20328] Fix | Delete
return;
[20329] Fix | Delete
}
[20330] Fix | Delete
if (!this.isAttachedToDOM) {
[20331] Fix | Delete
this.parent.add(this);
[20332] Fix | Delete
}
[20333] Fix | Delete
}
[20334] Fix | Delete
enableEditMode() {
[20335] Fix | Delete
if (this.isInEditMode()) {
[20336] Fix | Delete
return;
[20337] Fix | Delete
}
[20338] Fix | Delete
this.parent.setEditingState(false);
[20339] Fix | Delete
this.parent.updateToolbar(AnnotationEditorType.FREETEXT);
[20340] Fix | Delete
super.enableEditMode();
[20341] Fix | Delete
this.overlayDiv.classList.remove("enabled");
[20342] Fix | Delete
this.editorDiv.contentEditable = true;
[20343] Fix | Delete
this._isDraggable = false;
[20344] Fix | Delete
this.div.removeAttribute("aria-activedescendant");
[20345] Fix | Delete
this.editorDiv.addEventListener("keydown", this.#boundEditorDivKeydown);
[20346] Fix | Delete
this.editorDiv.addEventListener("focus", this.#boundEditorDivFocus);
[20347] Fix | Delete
this.editorDiv.addEventListener("blur", this.#boundEditorDivBlur);
[20348] Fix | Delete
this.editorDiv.addEventListener("input", this.#boundEditorDivInput);
[20349] Fix | Delete
this.editorDiv.addEventListener("paste", this.#boundEditorDivPaste);
[20350] Fix | Delete
}
[20351] Fix | Delete
disableEditMode() {
[20352] Fix | Delete
if (!this.isInEditMode()) {
[20353] Fix | Delete
return;
[20354] Fix | Delete
}
[20355] Fix | Delete
this.parent.setEditingState(true);
[20356] Fix | Delete
super.disableEditMode();
[20357] Fix | Delete
this.overlayDiv.classList.add("enabled");
[20358] Fix | Delete
this.editorDiv.contentEditable = false;
[20359] Fix | Delete
this.div.setAttribute("aria-activedescendant", this.#editorDivId);
[20360] Fix | Delete
this._isDraggable = true;
[20361] Fix | Delete
this.editorDiv.removeEventListener("keydown", this.#boundEditorDivKeydown);
[20362] Fix | Delete
this.editorDiv.removeEventListener("focus", this.#boundEditorDivFocus);
[20363] Fix | Delete
this.editorDiv.removeEventListener("blur", this.#boundEditorDivBlur);
[20364] Fix | Delete
this.editorDiv.removeEventListener("input", this.#boundEditorDivInput);
[20365] Fix | Delete
this.editorDiv.removeEventListener("paste", this.#boundEditorDivPaste);
[20366] Fix | Delete
this.div.focus({
[20367] Fix | Delete
preventScroll: true
[20368] Fix | Delete
});
[20369] Fix | Delete
this.isEditing = false;
[20370] Fix | Delete
this.parent.div.classList.add("freetextEditing");
[20371] Fix | Delete
}
[20372] Fix | Delete
focusin(event) {
[20373] Fix | Delete
if (!this._focusEventsAllowed) {
[20374] Fix | Delete
return;
[20375] Fix | Delete
}
[20376] Fix | Delete
super.focusin(event);
[20377] Fix | Delete
if (event.target !== this.editorDiv) {
[20378] Fix | Delete
this.editorDiv.focus();
[20379] Fix | Delete
}
[20380] Fix | Delete
}
[20381] Fix | Delete
onceAdded() {
[20382] Fix | Delete
if (this.width) {
[20383] Fix | Delete
return;
[20384] Fix | Delete
}
[20385] Fix | Delete
this.enableEditMode();
[20386] Fix | Delete
this.editorDiv.focus();
[20387] Fix | Delete
if (this._initialOptions?.isCentered) {
[20388] Fix | Delete
this.center();
[20389] Fix | Delete
}
[20390] Fix | Delete
this._initialOptions = null;
[20391] Fix | Delete
}
[20392] Fix | Delete
isEmpty() {
[20393] Fix | Delete
return !this.editorDiv || this.editorDiv.innerText.trim() === "";
[20394] Fix | Delete
}
[20395] Fix | Delete
remove() {
[20396] Fix | Delete
this.isEditing = false;
[20397] Fix | Delete
if (this.parent) {
[20398] Fix | Delete
this.parent.setEditingState(true);
[20399] Fix | Delete
this.parent.div.classList.add("freetextEditing");
[20400] Fix | Delete
}
[20401] Fix | Delete
super.remove();
[20402] Fix | Delete
}
[20403] Fix | Delete
#extractText() {
[20404] Fix | Delete
const buffer = [];
[20405] Fix | Delete
this.editorDiv.normalize();
[20406] Fix | Delete
for (const child of this.editorDiv.childNodes) {
[20407] Fix | Delete
buffer.push(FreeTextEditor.#getNodeContent(child));
[20408] Fix | Delete
}
[20409] Fix | Delete
return buffer.join("\n");
[20410] Fix | Delete
}
[20411] Fix | Delete
#setEditorDimensions() {
[20412] Fix | Delete
const [parentWidth, parentHeight] = this.parentDimensions;
[20413] Fix | Delete
let rect;
[20414] Fix | Delete
if (this.isAttachedToDOM) {
[20415] Fix | Delete
rect = this.div.getBoundingClientRect();
[20416] Fix | Delete
} else {
[20417] Fix | Delete
const {
[20418] Fix | Delete
currentLayer,
[20419] Fix | Delete
div
[20420] Fix | Delete
} = this;
[20421] Fix | Delete
const savedDisplay = div.style.display;
[20422] Fix | Delete
const savedVisibility = div.classList.contains("hidden");
[20423] Fix | Delete
div.classList.remove("hidden");
[20424] Fix | Delete
div.style.display = "hidden";
[20425] Fix | Delete
currentLayer.div.append(this.div);
[20426] Fix | Delete
rect = div.getBoundingClientRect();
[20427] Fix | Delete
div.remove();
[20428] Fix | Delete
div.style.display = savedDisplay;
[20429] Fix | Delete
div.classList.toggle("hidden", savedVisibility);
[20430] Fix | Delete
}
[20431] Fix | Delete
if (this.rotation % 180 === this.parentRotation % 180) {
[20432] Fix | Delete
this.width = rect.width / parentWidth;
[20433] Fix | Delete
this.height = rect.height / parentHeight;
[20434] Fix | Delete
} else {
[20435] Fix | Delete
this.width = rect.height / parentWidth;
[20436] Fix | Delete
this.height = rect.width / parentHeight;
[20437] Fix | Delete
}
[20438] Fix | Delete
this.fixAndSetPosition();
[20439] Fix | Delete
}
[20440] Fix | Delete
commit() {
[20441] Fix | Delete
if (!this.isInEditMode()) {
[20442] Fix | Delete
return;
[20443] Fix | Delete
}
[20444] Fix | Delete
super.commit();
[20445] Fix | Delete
this.disableEditMode();
[20446] Fix | Delete
const savedText = this.#content;
[20447] Fix | Delete
const newText = this.#content = this.#extractText().trimEnd();
[20448] Fix | Delete
if (savedText === newText) {
[20449] Fix | Delete
return;
[20450] Fix | Delete
}
[20451] Fix | Delete
const setText = text => {
[20452] Fix | Delete
this.#content = text;
[20453] Fix | Delete
if (!text) {
[20454] Fix | Delete
this.remove();
[20455] Fix | Delete
return;
[20456] Fix | Delete
}
[20457] Fix | Delete
this.#setContent();
[20458] Fix | Delete
this._uiManager.rebuild(this);
[20459] Fix | Delete
this.#setEditorDimensions();
[20460] Fix | Delete
};
[20461] Fix | Delete
this.addCommands({
[20462] Fix | Delete
cmd: () => {
[20463] Fix | Delete
setText(newText);
[20464] Fix | Delete
},
[20465] Fix | Delete
undo: () => {
[20466] Fix | Delete
setText(savedText);
[20467] Fix | Delete
},
[20468] Fix | Delete
mustExec: false
[20469] Fix | Delete
});
[20470] Fix | Delete
this.#setEditorDimensions();
[20471] Fix | Delete
}
[20472] Fix | Delete
shouldGetKeyboardEvents() {
[20473] Fix | Delete
return this.isInEditMode();
[20474] Fix | Delete
}
[20475] Fix | Delete
enterInEditMode() {
[20476] Fix | Delete
this.enableEditMode();
[20477] Fix | Delete
this.editorDiv.focus();
[20478] Fix | Delete
}
[20479] Fix | Delete
dblclick(event) {
[20480] Fix | Delete
this.enterInEditMode();
[20481] Fix | Delete
}
[20482] Fix | Delete
keydown(event) {
[20483] Fix | Delete
if (event.target === this.div && event.key === "Enter") {
[20484] Fix | Delete
this.enterInEditMode();
[20485] Fix | Delete
event.preventDefault();
[20486] Fix | Delete
}
[20487] Fix | Delete
}
[20488] Fix | Delete
editorDivKeydown(event) {
[20489] Fix | Delete
FreeTextEditor._keyboardManager.exec(this, event);
[20490] Fix | Delete
}
[20491] Fix | Delete
editorDivFocus(event) {
[20492] Fix | Delete
this.isEditing = true;
[20493] Fix | Delete
}
[20494] Fix | Delete
editorDivBlur(event) {
[20495] Fix | Delete
this.isEditing = false;
[20496] Fix | Delete
}
[20497] Fix | Delete
editorDivInput(event) {
[20498] Fix | Delete
this.parent.div.classList.toggle("freetextEditing", this.isEmpty());
[20499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function