this._timer = null;
this._element = element;
this._key = Core.getStoragePrefix() + this._element.dataset.autosave;
- //this._overlay = null;
this._cleanup();
// remove attribute to prevent Redactor's built-in autosave to kick in
delete this._element.dataset.autosave;
document.addEventListener("visibilitychange", () => this._onVisibilityChange());
}
_onVisibilityChange() {
- if (document.hidden) {
- this._isActive = false;
- this._isPending = true;
- }
- else {
- this._isActive = true;
- this._isPending = false;
- }
+ this._isActive = !document.hidden;
+ this._isPending = document.hidden;
}
/**
* Returns the initial value for the textarea, used to inject message
return [highlighter, prism_meta_1.default[highlighter].title];
});
// sort by label
- values.sort((a, b) => {
- if (a[1] < b[1]) {
- return -1;
- }
- else if (a[1] > b[1]) {
- return 1;
- }
- return 0;
- });
- values.forEach((value) => {
- highlighters += `<option value="${value[0]}">${StringUtil.escapeHTML(value[1])}</option>`;
- });
+ values.sort((a, b) => a[1].localeCompare(b[1]));
+ highlighters += values
+ .map(([highlighter, title]) => {
+ return `<option value="${highlighter}">${StringUtil.escapeHTML(title)}</option>`;
+ })
+ .join("\n");
document.getElementById(idHighlighter).innerHTML = highlighters;
},
onShow: () => {
StringUtil = tslib_1.__importStar(StringUtil);
CloseOverlay_1 = tslib_1.__importDefault(CloseOverlay_1);
let _dropdownContainer = null;
+ const DropDownPixelOffset = 7;
class UiRedactorMention {
constructor(redactor) {
this._active = false;
this._hideDropdown();
return;
}
- offset.top += 7; // add a little vertical gap
+ offset.top += DropDownPixelOffset;
const dropdownMenu = this._dropdownMenu;
dropdownMenu.style.setProperty("left", `${offset.left}px`, "");
dropdownMenu.style.setProperty("top", `${offset.top}px`, "");
this._selectItem(0);
if (offset.top + dropdownMenu.offsetHeight + 10 > window.innerHeight + (window.scrollY || window.pageYOffset)) {
- const top = offset.top - dropdownMenu.offsetHeight - 2 * this._lineHeight + 7;
+ const top = offset.top - dropdownMenu.offsetHeight - 2 * this._lineHeight + DropDownPixelOffset;
dropdownMenu.style.setProperty("top", `${top}px`, "");
}
}
constructor(element: HTMLTextAreaElement) {
this._element = element;
this._key = Core.getStoragePrefix() + this._element.dataset.autosave!;
- //this._overlay = null;
this._cleanup();
}
protected _onVisibilityChange(): void {
- if (document.hidden) {
- this._isActive = false;
- this._isPending = true;
- } else {
- this._isActive = true;
- this._isPending = false;
- }
+ this._isActive = !document.hidden;
+ this._isPending = document.hidden;
}
/**
});
// sort by label
- values.sort((a, b) => {
- if (a[1] < b[1]) {
- return -1;
- } else if (a[1] > b[1]) {
- return 1;
- }
-
- return 0;
- });
+ values.sort((a, b) => a[1].localeCompare(b[1]));
- values.forEach((value) => {
- highlighters += `<option value="${value[0]}">${StringUtil.escapeHTML(value[1])}</option>`;
- });
+ highlighters += values
+ .map(([highlighter, title]) => {
+ return `<option value="${highlighter}">${StringUtil.escapeHTML(title)}</option>`;
+ })
+ .join("\n");
document.getElementById(idHighlighter)!.innerHTML = highlighters;
},
let _dropdownContainer: HTMLElement | null = null;
+const DropDownPixelOffset = 7;
+
class UiRedactorMention {
protected _active = false;
protected _dropdownActive = false;
return;
}
- offset.top += 7; // add a little vertical gap
+ offset.top += DropDownPixelOffset;
const dropdownMenu = this._dropdownMenu!;
dropdownMenu.style.setProperty("left", `${offset.left}px`, "");
this._selectItem(0);
if (offset.top + dropdownMenu.offsetHeight + 10 > window.innerHeight + (window.scrollY || window.pageYOffset)) {
- const top = offset.top - dropdownMenu.offsetHeight - 2 * this._lineHeight! + 7;
+ const top = offset.top - dropdownMenu.offsetHeight - 2 * this._lineHeight! + DropDownPixelOffset;
dropdownMenu.style.setProperty("top", `${top}px`, "");
}
}