2840 lines
103 KiB
JavaScript
2840 lines
103 KiB
JavaScript
/*
|
||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||
if you want to view the source, please visit the github repository of this plugin
|
||
*/
|
||
|
||
var __defProp = Object.defineProperty;
|
||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||
var __export = (target, all) => {
|
||
for (var name in all)
|
||
__defProp(target, name, { get: all[name], enumerable: true });
|
||
};
|
||
var __copyProps = (to, from, except, desc) => {
|
||
if (from && typeof from === "object" || typeof from === "function") {
|
||
for (let key of __getOwnPropNames(from))
|
||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||
}
|
||
return to;
|
||
};
|
||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||
|
||
// src/main.ts
|
||
var main_exports = {};
|
||
__export(main_exports, {
|
||
default: () => FileExplorerPlusPlugin
|
||
});
|
||
module.exports = __toCommonJS(main_exports);
|
||
var import_obsidian6 = require("obsidian");
|
||
|
||
// node_modules/monkey-around/dist/index.mjs
|
||
function around(obj, factories) {
|
||
const removers = Object.keys(factories).map((key) => around1(obj, key, factories[key]));
|
||
return removers.length === 1 ? removers[0] : function() {
|
||
removers.forEach((r) => r());
|
||
};
|
||
}
|
||
function around1(obj, method, createWrapper) {
|
||
const inherited = obj[method], hadOwn = obj.hasOwnProperty(method), original = hadOwn ? inherited : function() {
|
||
return Object.getPrototypeOf(obj)[method].apply(this, arguments);
|
||
};
|
||
let current = createWrapper(original);
|
||
if (inherited)
|
||
Object.setPrototypeOf(current, inherited);
|
||
Object.setPrototypeOf(wrapper, current);
|
||
obj[method] = wrapper;
|
||
return remove;
|
||
function wrapper(...args) {
|
||
if (current === original && obj[method] === wrapper)
|
||
remove();
|
||
return current.apply(this, args);
|
||
}
|
||
function remove() {
|
||
if (obj[method] === wrapper) {
|
||
if (hadOwn)
|
||
obj[method] = original;
|
||
else
|
||
delete obj[method];
|
||
}
|
||
if (current === original)
|
||
return;
|
||
current = original;
|
||
Object.setPrototypeOf(wrapper, inherited || Function);
|
||
}
|
||
}
|
||
|
||
// src/settings.ts
|
||
var import_obsidian4 = require("obsidian");
|
||
|
||
// node_modules/@popperjs/core/lib/enums.js
|
||
var top = "top";
|
||
var bottom = "bottom";
|
||
var right = "right";
|
||
var left = "left";
|
||
var auto = "auto";
|
||
var basePlacements = [top, bottom, right, left];
|
||
var start = "start";
|
||
var end = "end";
|
||
var clippingParents = "clippingParents";
|
||
var viewport = "viewport";
|
||
var popper = "popper";
|
||
var reference = "reference";
|
||
var variationPlacements = /* @__PURE__ */ basePlacements.reduce(function(acc, placement) {
|
||
return acc.concat([placement + "-" + start, placement + "-" + end]);
|
||
}, []);
|
||
var placements = /* @__PURE__ */ [].concat(basePlacements, [auto]).reduce(function(acc, placement) {
|
||
return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
|
||
}, []);
|
||
var beforeRead = "beforeRead";
|
||
var read = "read";
|
||
var afterRead = "afterRead";
|
||
var beforeMain = "beforeMain";
|
||
var main = "main";
|
||
var afterMain = "afterMain";
|
||
var beforeWrite = "beforeWrite";
|
||
var write = "write";
|
||
var afterWrite = "afterWrite";
|
||
var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getNodeName.js
|
||
function getNodeName(element) {
|
||
return element ? (element.nodeName || "").toLowerCase() : null;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getWindow.js
|
||
function getWindow(node) {
|
||
if (node == null) {
|
||
return window;
|
||
}
|
||
if (node.toString() !== "[object Window]") {
|
||
var ownerDocument = node.ownerDocument;
|
||
return ownerDocument ? ownerDocument.defaultView || window : window;
|
||
}
|
||
return node;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/instanceOf.js
|
||
function isElement(node) {
|
||
var OwnElement = getWindow(node).Element;
|
||
return node instanceof OwnElement || node instanceof Element;
|
||
}
|
||
function isHTMLElement(node) {
|
||
var OwnElement = getWindow(node).HTMLElement;
|
||
return node instanceof OwnElement || node instanceof HTMLElement;
|
||
}
|
||
function isShadowRoot(node) {
|
||
if (typeof ShadowRoot === "undefined") {
|
||
return false;
|
||
}
|
||
var OwnElement = getWindow(node).ShadowRoot;
|
||
return node instanceof OwnElement || node instanceof ShadowRoot;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/applyStyles.js
|
||
function applyStyles(_ref) {
|
||
var state = _ref.state;
|
||
Object.keys(state.elements).forEach(function(name) {
|
||
var style = state.styles[name] || {};
|
||
var attributes = state.attributes[name] || {};
|
||
var element = state.elements[name];
|
||
if (!isHTMLElement(element) || !getNodeName(element)) {
|
||
return;
|
||
}
|
||
Object.assign(element.style, style);
|
||
Object.keys(attributes).forEach(function(name2) {
|
||
var value = attributes[name2];
|
||
if (value === false) {
|
||
element.removeAttribute(name2);
|
||
} else {
|
||
element.setAttribute(name2, value === true ? "" : value);
|
||
}
|
||
});
|
||
});
|
||
}
|
||
function effect(_ref2) {
|
||
var state = _ref2.state;
|
||
var initialStyles = {
|
||
popper: {
|
||
position: state.options.strategy,
|
||
left: "0",
|
||
top: "0",
|
||
margin: "0"
|
||
},
|
||
arrow: {
|
||
position: "absolute"
|
||
},
|
||
reference: {}
|
||
};
|
||
Object.assign(state.elements.popper.style, initialStyles.popper);
|
||
state.styles = initialStyles;
|
||
if (state.elements.arrow) {
|
||
Object.assign(state.elements.arrow.style, initialStyles.arrow);
|
||
}
|
||
return function() {
|
||
Object.keys(state.elements).forEach(function(name) {
|
||
var element = state.elements[name];
|
||
var attributes = state.attributes[name] || {};
|
||
var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]);
|
||
var style = styleProperties.reduce(function(style2, property) {
|
||
style2[property] = "";
|
||
return style2;
|
||
}, {});
|
||
if (!isHTMLElement(element) || !getNodeName(element)) {
|
||
return;
|
||
}
|
||
Object.assign(element.style, style);
|
||
Object.keys(attributes).forEach(function(attribute) {
|
||
element.removeAttribute(attribute);
|
||
});
|
||
});
|
||
};
|
||
}
|
||
var applyStyles_default = {
|
||
name: "applyStyles",
|
||
enabled: true,
|
||
phase: "write",
|
||
fn: applyStyles,
|
||
effect,
|
||
requires: ["computeStyles"]
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getBasePlacement.js
|
||
function getBasePlacement(placement) {
|
||
return placement.split("-")[0];
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/math.js
|
||
var max = Math.max;
|
||
var min = Math.min;
|
||
var round = Math.round;
|
||
|
||
// node_modules/@popperjs/core/lib/utils/userAgent.js
|
||
function getUAString() {
|
||
var uaData = navigator.userAgentData;
|
||
if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
|
||
return uaData.brands.map(function(item) {
|
||
return item.brand + "/" + item.version;
|
||
}).join(" ");
|
||
}
|
||
return navigator.userAgent;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/isLayoutViewport.js
|
||
function isLayoutViewport() {
|
||
return !/^((?!chrome|android).)*safari/i.test(getUAString());
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getBoundingClientRect.js
|
||
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
||
if (includeScale === void 0) {
|
||
includeScale = false;
|
||
}
|
||
if (isFixedStrategy === void 0) {
|
||
isFixedStrategy = false;
|
||
}
|
||
var clientRect = element.getBoundingClientRect();
|
||
var scaleX = 1;
|
||
var scaleY = 1;
|
||
if (includeScale && isHTMLElement(element)) {
|
||
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
||
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
||
}
|
||
var _ref = isElement(element) ? getWindow(element) : window, visualViewport = _ref.visualViewport;
|
||
var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
||
var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
|
||
var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
|
||
var width = clientRect.width / scaleX;
|
||
var height = clientRect.height / scaleY;
|
||
return {
|
||
width,
|
||
height,
|
||
top: y,
|
||
right: x + width,
|
||
bottom: y + height,
|
||
left: x,
|
||
x,
|
||
y
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getLayoutRect.js
|
||
function getLayoutRect(element) {
|
||
var clientRect = getBoundingClientRect(element);
|
||
var width = element.offsetWidth;
|
||
var height = element.offsetHeight;
|
||
if (Math.abs(clientRect.width - width) <= 1) {
|
||
width = clientRect.width;
|
||
}
|
||
if (Math.abs(clientRect.height - height) <= 1) {
|
||
height = clientRect.height;
|
||
}
|
||
return {
|
||
x: element.offsetLeft,
|
||
y: element.offsetTop,
|
||
width,
|
||
height
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/contains.js
|
||
function contains(parent, child) {
|
||
var rootNode = child.getRootNode && child.getRootNode();
|
||
if (parent.contains(child)) {
|
||
return true;
|
||
} else if (rootNode && isShadowRoot(rootNode)) {
|
||
var next = child;
|
||
do {
|
||
if (next && parent.isSameNode(next)) {
|
||
return true;
|
||
}
|
||
next = next.parentNode || next.host;
|
||
} while (next);
|
||
}
|
||
return false;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getComputedStyle.js
|
||
function getComputedStyle(element) {
|
||
return getWindow(element).getComputedStyle(element);
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/isTableElement.js
|
||
function isTableElement(element) {
|
||
return ["table", "td", "th"].indexOf(getNodeName(element)) >= 0;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js
|
||
function getDocumentElement(element) {
|
||
return ((isElement(element) ? element.ownerDocument : (
|
||
// $FlowFixMe[prop-missing]
|
||
element.document
|
||
)) || window.document).documentElement;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getParentNode.js
|
||
function getParentNode(element) {
|
||
if (getNodeName(element) === "html") {
|
||
return element;
|
||
}
|
||
return (
|
||
// this is a quicker (but less type safe) way to save quite some bytes from the bundle
|
||
// $FlowFixMe[incompatible-return]
|
||
// $FlowFixMe[prop-missing]
|
||
element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
||
element.parentNode || // DOM Element detected
|
||
(isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
|
||
// $FlowFixMe[incompatible-call]: HTMLElement is a Node
|
||
getDocumentElement(element)
|
||
);
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getOffsetParent.js
|
||
function getTrueOffsetParent(element) {
|
||
if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
|
||
getComputedStyle(element).position === "fixed") {
|
||
return null;
|
||
}
|
||
return element.offsetParent;
|
||
}
|
||
function getContainingBlock(element) {
|
||
var isFirefox = /firefox/i.test(getUAString());
|
||
var isIE = /Trident/i.test(getUAString());
|
||
if (isIE && isHTMLElement(element)) {
|
||
var elementCss = getComputedStyle(element);
|
||
if (elementCss.position === "fixed") {
|
||
return null;
|
||
}
|
||
}
|
||
var currentNode = getParentNode(element);
|
||
if (isShadowRoot(currentNode)) {
|
||
currentNode = currentNode.host;
|
||
}
|
||
while (isHTMLElement(currentNode) && ["html", "body"].indexOf(getNodeName(currentNode)) < 0) {
|
||
var css = getComputedStyle(currentNode);
|
||
if (css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || ["transform", "perspective"].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === "filter" || isFirefox && css.filter && css.filter !== "none") {
|
||
return currentNode;
|
||
} else {
|
||
currentNode = currentNode.parentNode;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
function getOffsetParent(element) {
|
||
var window2 = getWindow(element);
|
||
var offsetParent = getTrueOffsetParent(element);
|
||
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
|
||
offsetParent = getTrueOffsetParent(offsetParent);
|
||
}
|
||
if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static")) {
|
||
return window2;
|
||
}
|
||
return offsetParent || getContainingBlock(element) || window2;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getMainAxisFromPlacement.js
|
||
function getMainAxisFromPlacement(placement) {
|
||
return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/within.js
|
||
function within(min2, value, max2) {
|
||
return max(min2, min(value, max2));
|
||
}
|
||
function withinMaxClamp(min2, value, max2) {
|
||
var v = within(min2, value, max2);
|
||
return v > max2 ? max2 : v;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getFreshSideObject.js
|
||
function getFreshSideObject() {
|
||
return {
|
||
top: 0,
|
||
right: 0,
|
||
bottom: 0,
|
||
left: 0
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/mergePaddingObject.js
|
||
function mergePaddingObject(paddingObject) {
|
||
return Object.assign({}, getFreshSideObject(), paddingObject);
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/expandToHashMap.js
|
||
function expandToHashMap(value, keys) {
|
||
return keys.reduce(function(hashMap, key) {
|
||
hashMap[key] = value;
|
||
return hashMap;
|
||
}, {});
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/arrow.js
|
||
var toPaddingObject = function toPaddingObject2(padding, state) {
|
||
padding = typeof padding === "function" ? padding(Object.assign({}, state.rects, {
|
||
placement: state.placement
|
||
})) : padding;
|
||
return mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
|
||
};
|
||
function arrow(_ref) {
|
||
var _state$modifiersData$;
|
||
var state = _ref.state, name = _ref.name, options = _ref.options;
|
||
var arrowElement = state.elements.arrow;
|
||
var popperOffsets2 = state.modifiersData.popperOffsets;
|
||
var basePlacement = getBasePlacement(state.placement);
|
||
var axis = getMainAxisFromPlacement(basePlacement);
|
||
var isVertical = [left, right].indexOf(basePlacement) >= 0;
|
||
var len = isVertical ? "height" : "width";
|
||
if (!arrowElement || !popperOffsets2) {
|
||
return;
|
||
}
|
||
var paddingObject = toPaddingObject(options.padding, state);
|
||
var arrowRect = getLayoutRect(arrowElement);
|
||
var minProp = axis === "y" ? top : left;
|
||
var maxProp = axis === "y" ? bottom : right;
|
||
var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets2[axis] - state.rects.popper[len];
|
||
var startDiff = popperOffsets2[axis] - state.rects.reference[axis];
|
||
var arrowOffsetParent = getOffsetParent(arrowElement);
|
||
var clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
|
||
var centerToReference = endDiff / 2 - startDiff / 2;
|
||
var min2 = paddingObject[minProp];
|
||
var max2 = clientSize - arrowRect[len] - paddingObject[maxProp];
|
||
var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
|
||
var offset2 = within(min2, center, max2);
|
||
var axisProp = axis;
|
||
state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset2, _state$modifiersData$.centerOffset = offset2 - center, _state$modifiersData$);
|
||
}
|
||
function effect2(_ref2) {
|
||
var state = _ref2.state, options = _ref2.options;
|
||
var _options$element = options.element, arrowElement = _options$element === void 0 ? "[data-popper-arrow]" : _options$element;
|
||
if (arrowElement == null) {
|
||
return;
|
||
}
|
||
if (typeof arrowElement === "string") {
|
||
arrowElement = state.elements.popper.querySelector(arrowElement);
|
||
if (!arrowElement) {
|
||
return;
|
||
}
|
||
}
|
||
if (!contains(state.elements.popper, arrowElement)) {
|
||
return;
|
||
}
|
||
state.elements.arrow = arrowElement;
|
||
}
|
||
var arrow_default = {
|
||
name: "arrow",
|
||
enabled: true,
|
||
phase: "main",
|
||
fn: arrow,
|
||
effect: effect2,
|
||
requires: ["popperOffsets"],
|
||
requiresIfExists: ["preventOverflow"]
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getVariation.js
|
||
function getVariation(placement) {
|
||
return placement.split("-")[1];
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/computeStyles.js
|
||
var unsetSides = {
|
||
top: "auto",
|
||
right: "auto",
|
||
bottom: "auto",
|
||
left: "auto"
|
||
};
|
||
function roundOffsetsByDPR(_ref, win) {
|
||
var x = _ref.x, y = _ref.y;
|
||
var dpr = win.devicePixelRatio || 1;
|
||
return {
|
||
x: round(x * dpr) / dpr || 0,
|
||
y: round(y * dpr) / dpr || 0
|
||
};
|
||
}
|
||
function mapToStyles(_ref2) {
|
||
var _Object$assign2;
|
||
var popper2 = _ref2.popper, popperRect = _ref2.popperRect, placement = _ref2.placement, variation = _ref2.variation, offsets = _ref2.offsets, position = _ref2.position, gpuAcceleration = _ref2.gpuAcceleration, adaptive = _ref2.adaptive, roundOffsets = _ref2.roundOffsets, isFixed = _ref2.isFixed;
|
||
var _offsets$x = offsets.x, x = _offsets$x === void 0 ? 0 : _offsets$x, _offsets$y = offsets.y, y = _offsets$y === void 0 ? 0 : _offsets$y;
|
||
var _ref3 = typeof roundOffsets === "function" ? roundOffsets({
|
||
x,
|
||
y
|
||
}) : {
|
||
x,
|
||
y
|
||
};
|
||
x = _ref3.x;
|
||
y = _ref3.y;
|
||
var hasX = offsets.hasOwnProperty("x");
|
||
var hasY = offsets.hasOwnProperty("y");
|
||
var sideX = left;
|
||
var sideY = top;
|
||
var win = window;
|
||
if (adaptive) {
|
||
var offsetParent = getOffsetParent(popper2);
|
||
var heightProp = "clientHeight";
|
||
var widthProp = "clientWidth";
|
||
if (offsetParent === getWindow(popper2)) {
|
||
offsetParent = getDocumentElement(popper2);
|
||
if (getComputedStyle(offsetParent).position !== "static" && position === "absolute") {
|
||
heightProp = "scrollHeight";
|
||
widthProp = "scrollWidth";
|
||
}
|
||
}
|
||
offsetParent = offsetParent;
|
||
if (placement === top || (placement === left || placement === right) && variation === end) {
|
||
sideY = bottom;
|
||
var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : (
|
||
// $FlowFixMe[prop-missing]
|
||
offsetParent[heightProp]
|
||
);
|
||
y -= offsetY - popperRect.height;
|
||
y *= gpuAcceleration ? 1 : -1;
|
||
}
|
||
if (placement === left || (placement === top || placement === bottom) && variation === end) {
|
||
sideX = right;
|
||
var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : (
|
||
// $FlowFixMe[prop-missing]
|
||
offsetParent[widthProp]
|
||
);
|
||
x -= offsetX - popperRect.width;
|
||
x *= gpuAcceleration ? 1 : -1;
|
||
}
|
||
}
|
||
var commonStyles = Object.assign({
|
||
position
|
||
}, adaptive && unsetSides);
|
||
var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
|
||
x,
|
||
y
|
||
}, getWindow(popper2)) : {
|
||
x,
|
||
y
|
||
};
|
||
x = _ref4.x;
|
||
y = _ref4.y;
|
||
if (gpuAcceleration) {
|
||
var _Object$assign;
|
||
return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? "0" : "", _Object$assign[sideX] = hasX ? "0" : "", _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
|
||
}
|
||
return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : "", _Object$assign2[sideX] = hasX ? x + "px" : "", _Object$assign2.transform = "", _Object$assign2));
|
||
}
|
||
function computeStyles(_ref5) {
|
||
var state = _ref5.state, options = _ref5.options;
|
||
var _options$gpuAccelerat = options.gpuAcceleration, gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat, _options$adaptive = options.adaptive, adaptive = _options$adaptive === void 0 ? true : _options$adaptive, _options$roundOffsets = options.roundOffsets, roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
|
||
var commonStyles = {
|
||
placement: getBasePlacement(state.placement),
|
||
variation: getVariation(state.placement),
|
||
popper: state.elements.popper,
|
||
popperRect: state.rects.popper,
|
||
gpuAcceleration,
|
||
isFixed: state.options.strategy === "fixed"
|
||
};
|
||
if (state.modifiersData.popperOffsets != null) {
|
||
state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
|
||
offsets: state.modifiersData.popperOffsets,
|
||
position: state.options.strategy,
|
||
adaptive,
|
||
roundOffsets
|
||
})));
|
||
}
|
||
if (state.modifiersData.arrow != null) {
|
||
state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
|
||
offsets: state.modifiersData.arrow,
|
||
position: "absolute",
|
||
adaptive: false,
|
||
roundOffsets
|
||
})));
|
||
}
|
||
state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
||
"data-popper-placement": state.placement
|
||
});
|
||
}
|
||
var computeStyles_default = {
|
||
name: "computeStyles",
|
||
enabled: true,
|
||
phase: "beforeWrite",
|
||
fn: computeStyles,
|
||
data: {}
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/eventListeners.js
|
||
var passive = {
|
||
passive: true
|
||
};
|
||
function effect3(_ref) {
|
||
var state = _ref.state, instance = _ref.instance, options = _ref.options;
|
||
var _options$scroll = options.scroll, scroll = _options$scroll === void 0 ? true : _options$scroll, _options$resize = options.resize, resize = _options$resize === void 0 ? true : _options$resize;
|
||
var window2 = getWindow(state.elements.popper);
|
||
var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
|
||
if (scroll) {
|
||
scrollParents.forEach(function(scrollParent) {
|
||
scrollParent.addEventListener("scroll", instance.update, passive);
|
||
});
|
||
}
|
||
if (resize) {
|
||
window2.addEventListener("resize", instance.update, passive);
|
||
}
|
||
return function() {
|
||
if (scroll) {
|
||
scrollParents.forEach(function(scrollParent) {
|
||
scrollParent.removeEventListener("scroll", instance.update, passive);
|
||
});
|
||
}
|
||
if (resize) {
|
||
window2.removeEventListener("resize", instance.update, passive);
|
||
}
|
||
};
|
||
}
|
||
var eventListeners_default = {
|
||
name: "eventListeners",
|
||
enabled: true,
|
||
phase: "write",
|
||
fn: function fn() {
|
||
},
|
||
effect: effect3,
|
||
data: {}
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getOppositePlacement.js
|
||
var hash = {
|
||
left: "right",
|
||
right: "left",
|
||
bottom: "top",
|
||
top: "bottom"
|
||
};
|
||
function getOppositePlacement(placement) {
|
||
return placement.replace(/left|right|bottom|top/g, function(matched) {
|
||
return hash[matched];
|
||
});
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getOppositeVariationPlacement.js
|
||
var hash2 = {
|
||
start: "end",
|
||
end: "start"
|
||
};
|
||
function getOppositeVariationPlacement(placement) {
|
||
return placement.replace(/start|end/g, function(matched) {
|
||
return hash2[matched];
|
||
});
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getWindowScroll.js
|
||
function getWindowScroll(node) {
|
||
var win = getWindow(node);
|
||
var scrollLeft = win.pageXOffset;
|
||
var scrollTop = win.pageYOffset;
|
||
return {
|
||
scrollLeft,
|
||
scrollTop
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getWindowScrollBarX.js
|
||
function getWindowScrollBarX(element) {
|
||
return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getViewportRect.js
|
||
function getViewportRect(element, strategy) {
|
||
var win = getWindow(element);
|
||
var html = getDocumentElement(element);
|
||
var visualViewport = win.visualViewport;
|
||
var width = html.clientWidth;
|
||
var height = html.clientHeight;
|
||
var x = 0;
|
||
var y = 0;
|
||
if (visualViewport) {
|
||
width = visualViewport.width;
|
||
height = visualViewport.height;
|
||
var layoutViewport = isLayoutViewport();
|
||
if (layoutViewport || !layoutViewport && strategy === "fixed") {
|
||
x = visualViewport.offsetLeft;
|
||
y = visualViewport.offsetTop;
|
||
}
|
||
}
|
||
return {
|
||
width,
|
||
height,
|
||
x: x + getWindowScrollBarX(element),
|
||
y
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getDocumentRect.js
|
||
function getDocumentRect(element) {
|
||
var _element$ownerDocumen;
|
||
var html = getDocumentElement(element);
|
||
var winScroll = getWindowScroll(element);
|
||
var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
||
var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
||
var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
||
var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
|
||
var y = -winScroll.scrollTop;
|
||
if (getComputedStyle(body || html).direction === "rtl") {
|
||
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
||
}
|
||
return {
|
||
width,
|
||
height,
|
||
x,
|
||
y
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/isScrollParent.js
|
||
function isScrollParent(element) {
|
||
var _getComputedStyle = getComputedStyle(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
|
||
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getScrollParent.js
|
||
function getScrollParent(node) {
|
||
if (["html", "body", "#document"].indexOf(getNodeName(node)) >= 0) {
|
||
return node.ownerDocument.body;
|
||
}
|
||
if (isHTMLElement(node) && isScrollParent(node)) {
|
||
return node;
|
||
}
|
||
return getScrollParent(getParentNode(node));
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/listScrollParents.js
|
||
function listScrollParents(element, list) {
|
||
var _element$ownerDocumen;
|
||
if (list === void 0) {
|
||
list = [];
|
||
}
|
||
var scrollParent = getScrollParent(element);
|
||
var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
|
||
var win = getWindow(scrollParent);
|
||
var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
||
var updatedList = list.concat(target);
|
||
return isBody ? updatedList : (
|
||
// $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
|
||
updatedList.concat(listScrollParents(getParentNode(target)))
|
||
);
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/rectToClientRect.js
|
||
function rectToClientRect(rect) {
|
||
return Object.assign({}, rect, {
|
||
left: rect.x,
|
||
top: rect.y,
|
||
right: rect.x + rect.width,
|
||
bottom: rect.y + rect.height
|
||
});
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getClippingRect.js
|
||
function getInnerBoundingClientRect(element, strategy) {
|
||
var rect = getBoundingClientRect(element, false, strategy === "fixed");
|
||
rect.top = rect.top + element.clientTop;
|
||
rect.left = rect.left + element.clientLeft;
|
||
rect.bottom = rect.top + element.clientHeight;
|
||
rect.right = rect.left + element.clientWidth;
|
||
rect.width = element.clientWidth;
|
||
rect.height = element.clientHeight;
|
||
rect.x = rect.left;
|
||
rect.y = rect.top;
|
||
return rect;
|
||
}
|
||
function getClientRectFromMixedType(element, clippingParent, strategy) {
|
||
return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
||
}
|
||
function getClippingParents(element) {
|
||
var clippingParents2 = listScrollParents(getParentNode(element));
|
||
var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle(element).position) >= 0;
|
||
var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
|
||
if (!isElement(clipperElement)) {
|
||
return [];
|
||
}
|
||
return clippingParents2.filter(function(clippingParent) {
|
||
return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
|
||
});
|
||
}
|
||
function getClippingRect(element, boundary, rootBoundary, strategy) {
|
||
var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element) : [].concat(boundary);
|
||
var clippingParents2 = [].concat(mainClippingParents, [rootBoundary]);
|
||
var firstClippingParent = clippingParents2[0];
|
||
var clippingRect = clippingParents2.reduce(function(accRect, clippingParent) {
|
||
var rect = getClientRectFromMixedType(element, clippingParent, strategy);
|
||
accRect.top = max(rect.top, accRect.top);
|
||
accRect.right = min(rect.right, accRect.right);
|
||
accRect.bottom = min(rect.bottom, accRect.bottom);
|
||
accRect.left = max(rect.left, accRect.left);
|
||
return accRect;
|
||
}, getClientRectFromMixedType(element, firstClippingParent, strategy));
|
||
clippingRect.width = clippingRect.right - clippingRect.left;
|
||
clippingRect.height = clippingRect.bottom - clippingRect.top;
|
||
clippingRect.x = clippingRect.left;
|
||
clippingRect.y = clippingRect.top;
|
||
return clippingRect;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/computeOffsets.js
|
||
function computeOffsets(_ref) {
|
||
var reference2 = _ref.reference, element = _ref.element, placement = _ref.placement;
|
||
var basePlacement = placement ? getBasePlacement(placement) : null;
|
||
var variation = placement ? getVariation(placement) : null;
|
||
var commonX = reference2.x + reference2.width / 2 - element.width / 2;
|
||
var commonY = reference2.y + reference2.height / 2 - element.height / 2;
|
||
var offsets;
|
||
switch (basePlacement) {
|
||
case top:
|
||
offsets = {
|
||
x: commonX,
|
||
y: reference2.y - element.height
|
||
};
|
||
break;
|
||
case bottom:
|
||
offsets = {
|
||
x: commonX,
|
||
y: reference2.y + reference2.height
|
||
};
|
||
break;
|
||
case right:
|
||
offsets = {
|
||
x: reference2.x + reference2.width,
|
||
y: commonY
|
||
};
|
||
break;
|
||
case left:
|
||
offsets = {
|
||
x: reference2.x - element.width,
|
||
y: commonY
|
||
};
|
||
break;
|
||
default:
|
||
offsets = {
|
||
x: reference2.x,
|
||
y: reference2.y
|
||
};
|
||
}
|
||
var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
|
||
if (mainAxis != null) {
|
||
var len = mainAxis === "y" ? "height" : "width";
|
||
switch (variation) {
|
||
case start:
|
||
offsets[mainAxis] = offsets[mainAxis] - (reference2[len] / 2 - element[len] / 2);
|
||
break;
|
||
case end:
|
||
offsets[mainAxis] = offsets[mainAxis] + (reference2[len] / 2 - element[len] / 2);
|
||
break;
|
||
default:
|
||
}
|
||
}
|
||
return offsets;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/detectOverflow.js
|
||
function detectOverflow(state, options) {
|
||
if (options === void 0) {
|
||
options = {};
|
||
}
|
||
var _options = options, _options$placement = _options.placement, placement = _options$placement === void 0 ? state.placement : _options$placement, _options$strategy = _options.strategy, strategy = _options$strategy === void 0 ? state.strategy : _options$strategy, _options$boundary = _options.boundary, boundary = _options$boundary === void 0 ? clippingParents : _options$boundary, _options$rootBoundary = _options.rootBoundary, rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary, _options$elementConte = _options.elementContext, elementContext = _options$elementConte === void 0 ? popper : _options$elementConte, _options$altBoundary = _options.altBoundary, altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary, _options$padding = _options.padding, padding = _options$padding === void 0 ? 0 : _options$padding;
|
||
var paddingObject = mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
|
||
var altContext = elementContext === popper ? reference : popper;
|
||
var popperRect = state.rects.popper;
|
||
var element = state.elements[altBoundary ? altContext : elementContext];
|
||
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
|
||
var referenceClientRect = getBoundingClientRect(state.elements.reference);
|
||
var popperOffsets2 = computeOffsets({
|
||
reference: referenceClientRect,
|
||
element: popperRect,
|
||
strategy: "absolute",
|
||
placement
|
||
});
|
||
var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets2));
|
||
var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
|
||
var overflowOffsets = {
|
||
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
||
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
||
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
||
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
||
};
|
||
var offsetData = state.modifiersData.offset;
|
||
if (elementContext === popper && offsetData) {
|
||
var offset2 = offsetData[placement];
|
||
Object.keys(overflowOffsets).forEach(function(key) {
|
||
var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
|
||
var axis = [top, bottom].indexOf(key) >= 0 ? "y" : "x";
|
||
overflowOffsets[key] += offset2[axis] * multiply;
|
||
});
|
||
}
|
||
return overflowOffsets;
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/computeAutoPlacement.js
|
||
function computeAutoPlacement(state, options) {
|
||
if (options === void 0) {
|
||
options = {};
|
||
}
|
||
var _options = options, placement = _options.placement, boundary = _options.boundary, rootBoundary = _options.rootBoundary, padding = _options.padding, flipVariations = _options.flipVariations, _options$allowedAutoP = _options.allowedAutoPlacements, allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
|
||
var variation = getVariation(placement);
|
||
var placements2 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function(placement2) {
|
||
return getVariation(placement2) === variation;
|
||
}) : basePlacements;
|
||
var allowedPlacements = placements2.filter(function(placement2) {
|
||
return allowedAutoPlacements.indexOf(placement2) >= 0;
|
||
});
|
||
if (allowedPlacements.length === 0) {
|
||
allowedPlacements = placements2;
|
||
}
|
||
var overflows = allowedPlacements.reduce(function(acc, placement2) {
|
||
acc[placement2] = detectOverflow(state, {
|
||
placement: placement2,
|
||
boundary,
|
||
rootBoundary,
|
||
padding
|
||
})[getBasePlacement(placement2)];
|
||
return acc;
|
||
}, {});
|
||
return Object.keys(overflows).sort(function(a, b) {
|
||
return overflows[a] - overflows[b];
|
||
});
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/flip.js
|
||
function getExpandedFallbackPlacements(placement) {
|
||
if (getBasePlacement(placement) === auto) {
|
||
return [];
|
||
}
|
||
var oppositePlacement = getOppositePlacement(placement);
|
||
return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
|
||
}
|
||
function flip(_ref) {
|
||
var state = _ref.state, options = _ref.options, name = _ref.name;
|
||
if (state.modifiersData[name]._skip) {
|
||
return;
|
||
}
|
||
var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis, specifiedFallbackPlacements = options.fallbackPlacements, padding = options.padding, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, _options$flipVariatio = options.flipVariations, flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio, allowedAutoPlacements = options.allowedAutoPlacements;
|
||
var preferredPlacement = state.options.placement;
|
||
var basePlacement = getBasePlacement(preferredPlacement);
|
||
var isBasePlacement = basePlacement === preferredPlacement;
|
||
var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
|
||
var placements2 = [preferredPlacement].concat(fallbackPlacements).reduce(function(acc, placement2) {
|
||
return acc.concat(getBasePlacement(placement2) === auto ? computeAutoPlacement(state, {
|
||
placement: placement2,
|
||
boundary,
|
||
rootBoundary,
|
||
padding,
|
||
flipVariations,
|
||
allowedAutoPlacements
|
||
}) : placement2);
|
||
}, []);
|
||
var referenceRect = state.rects.reference;
|
||
var popperRect = state.rects.popper;
|
||
var checksMap = /* @__PURE__ */ new Map();
|
||
var makeFallbackChecks = true;
|
||
var firstFittingPlacement = placements2[0];
|
||
for (var i = 0; i < placements2.length; i++) {
|
||
var placement = placements2[i];
|
||
var _basePlacement = getBasePlacement(placement);
|
||
var isStartVariation = getVariation(placement) === start;
|
||
var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
|
||
var len = isVertical ? "width" : "height";
|
||
var overflow = detectOverflow(state, {
|
||
placement,
|
||
boundary,
|
||
rootBoundary,
|
||
altBoundary,
|
||
padding
|
||
});
|
||
var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
|
||
if (referenceRect[len] > popperRect[len]) {
|
||
mainVariationSide = getOppositePlacement(mainVariationSide);
|
||
}
|
||
var altVariationSide = getOppositePlacement(mainVariationSide);
|
||
var checks = [];
|
||
if (checkMainAxis) {
|
||
checks.push(overflow[_basePlacement] <= 0);
|
||
}
|
||
if (checkAltAxis) {
|
||
checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
|
||
}
|
||
if (checks.every(function(check) {
|
||
return check;
|
||
})) {
|
||
firstFittingPlacement = placement;
|
||
makeFallbackChecks = false;
|
||
break;
|
||
}
|
||
checksMap.set(placement, checks);
|
||
}
|
||
if (makeFallbackChecks) {
|
||
var numberOfChecks = flipVariations ? 3 : 1;
|
||
var _loop = function _loop2(_i2) {
|
||
var fittingPlacement = placements2.find(function(placement2) {
|
||
var checks2 = checksMap.get(placement2);
|
||
if (checks2) {
|
||
return checks2.slice(0, _i2).every(function(check) {
|
||
return check;
|
||
});
|
||
}
|
||
});
|
||
if (fittingPlacement) {
|
||
firstFittingPlacement = fittingPlacement;
|
||
return "break";
|
||
}
|
||
};
|
||
for (var _i = numberOfChecks; _i > 0; _i--) {
|
||
var _ret = _loop(_i);
|
||
if (_ret === "break") break;
|
||
}
|
||
}
|
||
if (state.placement !== firstFittingPlacement) {
|
||
state.modifiersData[name]._skip = true;
|
||
state.placement = firstFittingPlacement;
|
||
state.reset = true;
|
||
}
|
||
}
|
||
var flip_default = {
|
||
name: "flip",
|
||
enabled: true,
|
||
phase: "main",
|
||
fn: flip,
|
||
requiresIfExists: ["offset"],
|
||
data: {
|
||
_skip: false
|
||
}
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/hide.js
|
||
function getSideOffsets(overflow, rect, preventedOffsets) {
|
||
if (preventedOffsets === void 0) {
|
||
preventedOffsets = {
|
||
x: 0,
|
||
y: 0
|
||
};
|
||
}
|
||
return {
|
||
top: overflow.top - rect.height - preventedOffsets.y,
|
||
right: overflow.right - rect.width + preventedOffsets.x,
|
||
bottom: overflow.bottom - rect.height + preventedOffsets.y,
|
||
left: overflow.left - rect.width - preventedOffsets.x
|
||
};
|
||
}
|
||
function isAnySideFullyClipped(overflow) {
|
||
return [top, right, bottom, left].some(function(side) {
|
||
return overflow[side] >= 0;
|
||
});
|
||
}
|
||
function hide(_ref) {
|
||
var state = _ref.state, name = _ref.name;
|
||
var referenceRect = state.rects.reference;
|
||
var popperRect = state.rects.popper;
|
||
var preventedOffsets = state.modifiersData.preventOverflow;
|
||
var referenceOverflow = detectOverflow(state, {
|
||
elementContext: "reference"
|
||
});
|
||
var popperAltOverflow = detectOverflow(state, {
|
||
altBoundary: true
|
||
});
|
||
var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
|
||
var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
|
||
var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
|
||
var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
|
||
state.modifiersData[name] = {
|
||
referenceClippingOffsets,
|
||
popperEscapeOffsets,
|
||
isReferenceHidden,
|
||
hasPopperEscaped
|
||
};
|
||
state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
||
"data-popper-reference-hidden": isReferenceHidden,
|
||
"data-popper-escaped": hasPopperEscaped
|
||
});
|
||
}
|
||
var hide_default = {
|
||
name: "hide",
|
||
enabled: true,
|
||
phase: "main",
|
||
requiresIfExists: ["preventOverflow"],
|
||
fn: hide
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/offset.js
|
||
function distanceAndSkiddingToXY(placement, rects, offset2) {
|
||
var basePlacement = getBasePlacement(placement);
|
||
var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
|
||
var _ref = typeof offset2 === "function" ? offset2(Object.assign({}, rects, {
|
||
placement
|
||
})) : offset2, skidding = _ref[0], distance = _ref[1];
|
||
skidding = skidding || 0;
|
||
distance = (distance || 0) * invertDistance;
|
||
return [left, right].indexOf(basePlacement) >= 0 ? {
|
||
x: distance,
|
||
y: skidding
|
||
} : {
|
||
x: skidding,
|
||
y: distance
|
||
};
|
||
}
|
||
function offset(_ref2) {
|
||
var state = _ref2.state, options = _ref2.options, name = _ref2.name;
|
||
var _options$offset = options.offset, offset2 = _options$offset === void 0 ? [0, 0] : _options$offset;
|
||
var data = placements.reduce(function(acc, placement) {
|
||
acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset2);
|
||
return acc;
|
||
}, {});
|
||
var _data$state$placement = data[state.placement], x = _data$state$placement.x, y = _data$state$placement.y;
|
||
if (state.modifiersData.popperOffsets != null) {
|
||
state.modifiersData.popperOffsets.x += x;
|
||
state.modifiersData.popperOffsets.y += y;
|
||
}
|
||
state.modifiersData[name] = data;
|
||
}
|
||
var offset_default = {
|
||
name: "offset",
|
||
enabled: true,
|
||
phase: "main",
|
||
requires: ["popperOffsets"],
|
||
fn: offset
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/popperOffsets.js
|
||
function popperOffsets(_ref) {
|
||
var state = _ref.state, name = _ref.name;
|
||
state.modifiersData[name] = computeOffsets({
|
||
reference: state.rects.reference,
|
||
element: state.rects.popper,
|
||
strategy: "absolute",
|
||
placement: state.placement
|
||
});
|
||
}
|
||
var popperOffsets_default = {
|
||
name: "popperOffsets",
|
||
enabled: true,
|
||
phase: "read",
|
||
fn: popperOffsets,
|
||
data: {}
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/utils/getAltAxis.js
|
||
function getAltAxis(axis) {
|
||
return axis === "x" ? "y" : "x";
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/modifiers/preventOverflow.js
|
||
function preventOverflow(_ref) {
|
||
var state = _ref.state, options = _ref.options, name = _ref.name;
|
||
var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, padding = options.padding, _options$tether = options.tether, tether = _options$tether === void 0 ? true : _options$tether, _options$tetherOffset = options.tetherOffset, tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
|
||
var overflow = detectOverflow(state, {
|
||
boundary,
|
||
rootBoundary,
|
||
padding,
|
||
altBoundary
|
||
});
|
||
var basePlacement = getBasePlacement(state.placement);
|
||
var variation = getVariation(state.placement);
|
||
var isBasePlacement = !variation;
|
||
var mainAxis = getMainAxisFromPlacement(basePlacement);
|
||
var altAxis = getAltAxis(mainAxis);
|
||
var popperOffsets2 = state.modifiersData.popperOffsets;
|
||
var referenceRect = state.rects.reference;
|
||
var popperRect = state.rects.popper;
|
||
var tetherOffsetValue = typeof tetherOffset === "function" ? tetherOffset(Object.assign({}, state.rects, {
|
||
placement: state.placement
|
||
})) : tetherOffset;
|
||
var normalizedTetherOffsetValue = typeof tetherOffsetValue === "number" ? {
|
||
mainAxis: tetherOffsetValue,
|
||
altAxis: tetherOffsetValue
|
||
} : Object.assign({
|
||
mainAxis: 0,
|
||
altAxis: 0
|
||
}, tetherOffsetValue);
|
||
var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
|
||
var data = {
|
||
x: 0,
|
||
y: 0
|
||
};
|
||
if (!popperOffsets2) {
|
||
return;
|
||
}
|
||
if (checkMainAxis) {
|
||
var _offsetModifierState$;
|
||
var mainSide = mainAxis === "y" ? top : left;
|
||
var altSide = mainAxis === "y" ? bottom : right;
|
||
var len = mainAxis === "y" ? "height" : "width";
|
||
var offset2 = popperOffsets2[mainAxis];
|
||
var min2 = offset2 + overflow[mainSide];
|
||
var max2 = offset2 - overflow[altSide];
|
||
var additive = tether ? -popperRect[len] / 2 : 0;
|
||
var minLen = variation === start ? referenceRect[len] : popperRect[len];
|
||
var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
|
||
var arrowElement = state.elements.arrow;
|
||
var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
|
||
width: 0,
|
||
height: 0
|
||
};
|
||
var arrowPaddingObject = state.modifiersData["arrow#persistent"] ? state.modifiersData["arrow#persistent"].padding : getFreshSideObject();
|
||
var arrowPaddingMin = arrowPaddingObject[mainSide];
|
||
var arrowPaddingMax = arrowPaddingObject[altSide];
|
||
var arrowLen = within(0, referenceRect[len], arrowRect[len]);
|
||
var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
|
||
var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
|
||
var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
|
||
var clientOffset = arrowOffsetParent ? mainAxis === "y" ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
|
||
var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
|
||
var tetherMin = offset2 + minOffset - offsetModifierValue - clientOffset;
|
||
var tetherMax = offset2 + maxOffset - offsetModifierValue;
|
||
var preventedOffset = within(tether ? min(min2, tetherMin) : min2, offset2, tether ? max(max2, tetherMax) : max2);
|
||
popperOffsets2[mainAxis] = preventedOffset;
|
||
data[mainAxis] = preventedOffset - offset2;
|
||
}
|
||
if (checkAltAxis) {
|
||
var _offsetModifierState$2;
|
||
var _mainSide = mainAxis === "x" ? top : left;
|
||
var _altSide = mainAxis === "x" ? bottom : right;
|
||
var _offset = popperOffsets2[altAxis];
|
||
var _len = altAxis === "y" ? "height" : "width";
|
||
var _min = _offset + overflow[_mainSide];
|
||
var _max = _offset - overflow[_altSide];
|
||
var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
|
||
var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
|
||
var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
|
||
var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
|
||
var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
|
||
popperOffsets2[altAxis] = _preventedOffset;
|
||
data[altAxis] = _preventedOffset - _offset;
|
||
}
|
||
state.modifiersData[name] = data;
|
||
}
|
||
var preventOverflow_default = {
|
||
name: "preventOverflow",
|
||
enabled: true,
|
||
phase: "main",
|
||
fn: preventOverflow,
|
||
requiresIfExists: ["offset"]
|
||
};
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getHTMLElementScroll.js
|
||
function getHTMLElementScroll(element) {
|
||
return {
|
||
scrollLeft: element.scrollLeft,
|
||
scrollTop: element.scrollTop
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getNodeScroll.js
|
||
function getNodeScroll(node) {
|
||
if (node === getWindow(node) || !isHTMLElement(node)) {
|
||
return getWindowScroll(node);
|
||
} else {
|
||
return getHTMLElementScroll(node);
|
||
}
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/dom-utils/getCompositeRect.js
|
||
function isElementScaled(element) {
|
||
var rect = element.getBoundingClientRect();
|
||
var scaleX = round(rect.width) / element.offsetWidth || 1;
|
||
var scaleY = round(rect.height) / element.offsetHeight || 1;
|
||
return scaleX !== 1 || scaleY !== 1;
|
||
}
|
||
function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
||
if (isFixed === void 0) {
|
||
isFixed = false;
|
||
}
|
||
var isOffsetParentAnElement = isHTMLElement(offsetParent);
|
||
var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
|
||
var documentElement = getDocumentElement(offsetParent);
|
||
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
|
||
var scroll = {
|
||
scrollLeft: 0,
|
||
scrollTop: 0
|
||
};
|
||
var offsets = {
|
||
x: 0,
|
||
y: 0
|
||
};
|
||
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
||
if (getNodeName(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
|
||
isScrollParent(documentElement)) {
|
||
scroll = getNodeScroll(offsetParent);
|
||
}
|
||
if (isHTMLElement(offsetParent)) {
|
||
offsets = getBoundingClientRect(offsetParent, true);
|
||
offsets.x += offsetParent.clientLeft;
|
||
offsets.y += offsetParent.clientTop;
|
||
} else if (documentElement) {
|
||
offsets.x = getWindowScrollBarX(documentElement);
|
||
}
|
||
}
|
||
return {
|
||
x: rect.left + scroll.scrollLeft - offsets.x,
|
||
y: rect.top + scroll.scrollTop - offsets.y,
|
||
width: rect.width,
|
||
height: rect.height
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/orderModifiers.js
|
||
function order(modifiers) {
|
||
var map = /* @__PURE__ */ new Map();
|
||
var visited = /* @__PURE__ */ new Set();
|
||
var result = [];
|
||
modifiers.forEach(function(modifier) {
|
||
map.set(modifier.name, modifier);
|
||
});
|
||
function sort(modifier) {
|
||
visited.add(modifier.name);
|
||
var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
|
||
requires.forEach(function(dep) {
|
||
if (!visited.has(dep)) {
|
||
var depModifier = map.get(dep);
|
||
if (depModifier) {
|
||
sort(depModifier);
|
||
}
|
||
}
|
||
});
|
||
result.push(modifier);
|
||
}
|
||
modifiers.forEach(function(modifier) {
|
||
if (!visited.has(modifier.name)) {
|
||
sort(modifier);
|
||
}
|
||
});
|
||
return result;
|
||
}
|
||
function orderModifiers(modifiers) {
|
||
var orderedModifiers = order(modifiers);
|
||
return modifierPhases.reduce(function(acc, phase) {
|
||
return acc.concat(orderedModifiers.filter(function(modifier) {
|
||
return modifier.phase === phase;
|
||
}));
|
||
}, []);
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/debounce.js
|
||
function debounce(fn2) {
|
||
var pending;
|
||
return function() {
|
||
if (!pending) {
|
||
pending = new Promise(function(resolve) {
|
||
Promise.resolve().then(function() {
|
||
pending = void 0;
|
||
resolve(fn2());
|
||
});
|
||
});
|
||
}
|
||
return pending;
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/utils/mergeByName.js
|
||
function mergeByName(modifiers) {
|
||
var merged = modifiers.reduce(function(merged2, current) {
|
||
var existing = merged2[current.name];
|
||
merged2[current.name] = existing ? Object.assign({}, existing, current, {
|
||
options: Object.assign({}, existing.options, current.options),
|
||
data: Object.assign({}, existing.data, current.data)
|
||
}) : current;
|
||
return merged2;
|
||
}, {});
|
||
return Object.keys(merged).map(function(key) {
|
||
return merged[key];
|
||
});
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/createPopper.js
|
||
var DEFAULT_OPTIONS = {
|
||
placement: "bottom",
|
||
modifiers: [],
|
||
strategy: "absolute"
|
||
};
|
||
function areValidElements() {
|
||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||
args[_key] = arguments[_key];
|
||
}
|
||
return !args.some(function(element) {
|
||
return !(element && typeof element.getBoundingClientRect === "function");
|
||
});
|
||
}
|
||
function popperGenerator(generatorOptions) {
|
||
if (generatorOptions === void 0) {
|
||
generatorOptions = {};
|
||
}
|
||
var _generatorOptions = generatorOptions, _generatorOptions$def = _generatorOptions.defaultModifiers, defaultModifiers2 = _generatorOptions$def === void 0 ? [] : _generatorOptions$def, _generatorOptions$def2 = _generatorOptions.defaultOptions, defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
|
||
return function createPopper2(reference2, popper2, options) {
|
||
if (options === void 0) {
|
||
options = defaultOptions;
|
||
}
|
||
var state = {
|
||
placement: "bottom",
|
||
orderedModifiers: [],
|
||
options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
|
||
modifiersData: {},
|
||
elements: {
|
||
reference: reference2,
|
||
popper: popper2
|
||
},
|
||
attributes: {},
|
||
styles: {}
|
||
};
|
||
var effectCleanupFns = [];
|
||
var isDestroyed = false;
|
||
var instance = {
|
||
state,
|
||
setOptions: function setOptions(setOptionsAction) {
|
||
var options2 = typeof setOptionsAction === "function" ? setOptionsAction(state.options) : setOptionsAction;
|
||
cleanupModifierEffects();
|
||
state.options = Object.assign({}, defaultOptions, state.options, options2);
|
||
state.scrollParents = {
|
||
reference: isElement(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
|
||
popper: listScrollParents(popper2)
|
||
};
|
||
var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers2, state.options.modifiers)));
|
||
state.orderedModifiers = orderedModifiers.filter(function(m) {
|
||
return m.enabled;
|
||
});
|
||
runModifierEffects();
|
||
return instance.update();
|
||
},
|
||
// Sync update – it will always be executed, even if not necessary. This
|
||
// is useful for low frequency updates where sync behavior simplifies the
|
||
// logic.
|
||
// For high frequency updates (e.g. `resize` and `scroll` events), always
|
||
// prefer the async Popper#update method
|
||
forceUpdate: function forceUpdate() {
|
||
if (isDestroyed) {
|
||
return;
|
||
}
|
||
var _state$elements = state.elements, reference3 = _state$elements.reference, popper3 = _state$elements.popper;
|
||
if (!areValidElements(reference3, popper3)) {
|
||
return;
|
||
}
|
||
state.rects = {
|
||
reference: getCompositeRect(reference3, getOffsetParent(popper3), state.options.strategy === "fixed"),
|
||
popper: getLayoutRect(popper3)
|
||
};
|
||
state.reset = false;
|
||
state.placement = state.options.placement;
|
||
state.orderedModifiers.forEach(function(modifier) {
|
||
return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
|
||
});
|
||
for (var index = 0; index < state.orderedModifiers.length; index++) {
|
||
if (state.reset === true) {
|
||
state.reset = false;
|
||
index = -1;
|
||
continue;
|
||
}
|
||
var _state$orderedModifie = state.orderedModifiers[index], fn2 = _state$orderedModifie.fn, _state$orderedModifie2 = _state$orderedModifie.options, _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2, name = _state$orderedModifie.name;
|
||
if (typeof fn2 === "function") {
|
||
state = fn2({
|
||
state,
|
||
options: _options,
|
||
name,
|
||
instance
|
||
}) || state;
|
||
}
|
||
}
|
||
},
|
||
// Async and optimistically optimized update – it will not be executed if
|
||
// not necessary (debounced to run at most once-per-tick)
|
||
update: debounce(function() {
|
||
return new Promise(function(resolve) {
|
||
instance.forceUpdate();
|
||
resolve(state);
|
||
});
|
||
}),
|
||
destroy: function destroy() {
|
||
cleanupModifierEffects();
|
||
isDestroyed = true;
|
||
}
|
||
};
|
||
if (!areValidElements(reference2, popper2)) {
|
||
return instance;
|
||
}
|
||
instance.setOptions(options).then(function(state2) {
|
||
if (!isDestroyed && options.onFirstUpdate) {
|
||
options.onFirstUpdate(state2);
|
||
}
|
||
});
|
||
function runModifierEffects() {
|
||
state.orderedModifiers.forEach(function(_ref) {
|
||
var name = _ref.name, _ref$options = _ref.options, options2 = _ref$options === void 0 ? {} : _ref$options, effect4 = _ref.effect;
|
||
if (typeof effect4 === "function") {
|
||
var cleanupFn = effect4({
|
||
state,
|
||
name,
|
||
instance,
|
||
options: options2
|
||
});
|
||
var noopFn = function noopFn2() {
|
||
};
|
||
effectCleanupFns.push(cleanupFn || noopFn);
|
||
}
|
||
});
|
||
}
|
||
function cleanupModifierEffects() {
|
||
effectCleanupFns.forEach(function(fn2) {
|
||
return fn2();
|
||
});
|
||
effectCleanupFns = [];
|
||
}
|
||
return instance;
|
||
};
|
||
}
|
||
|
||
// node_modules/@popperjs/core/lib/popper.js
|
||
var defaultModifiers = [eventListeners_default, popperOffsets_default, computeStyles_default, applyStyles_default, offset_default, flip_default, preventOverflow_default, arrow_default, hide_default];
|
||
var createPopper = /* @__PURE__ */ popperGenerator({
|
||
defaultModifiers
|
||
});
|
||
|
||
// src/ui/suggest.ts
|
||
var import_obsidian = require("obsidian");
|
||
var wrapAround = (value, size) => {
|
||
return (value % size + size) % size;
|
||
};
|
||
var Suggest = class {
|
||
constructor(owner, containerEl, scope) {
|
||
this.owner = owner;
|
||
this.containerEl = containerEl;
|
||
containerEl.on("click", ".suggestion-item", this.onSuggestionClick.bind(this));
|
||
containerEl.on("mousemove", ".suggestion-item", this.onSuggestionMouseover.bind(this));
|
||
scope.register([], "ArrowUp", (event) => {
|
||
if (!event.isComposing) {
|
||
this.setSelectedItem(this.selectedItem - 1, true);
|
||
return false;
|
||
}
|
||
});
|
||
scope.register([], "ArrowDown", (event) => {
|
||
if (!event.isComposing) {
|
||
this.setSelectedItem(this.selectedItem + 1, true);
|
||
return false;
|
||
}
|
||
});
|
||
scope.register([], "Enter", (event) => {
|
||
if (!event.isComposing) {
|
||
this.useSelectedItem(event);
|
||
return false;
|
||
}
|
||
});
|
||
}
|
||
onSuggestionClick(event, el) {
|
||
event.preventDefault();
|
||
const item = this.suggestions.indexOf(el);
|
||
this.setSelectedItem(item, false);
|
||
this.useSelectedItem(event);
|
||
}
|
||
onSuggestionMouseover(_event, el) {
|
||
const item = this.suggestions.indexOf(el);
|
||
this.setSelectedItem(item, false);
|
||
}
|
||
setSuggestions(values) {
|
||
this.containerEl.empty();
|
||
const suggestionEls = [];
|
||
values.forEach((value) => {
|
||
const suggestionEl = this.containerEl.createDiv("suggestion-item");
|
||
this.owner.renderSuggestion(value, suggestionEl);
|
||
suggestionEls.push(suggestionEl);
|
||
});
|
||
this.values = values;
|
||
this.suggestions = suggestionEls;
|
||
this.setSelectedItem(0, false);
|
||
}
|
||
useSelectedItem(event) {
|
||
const currentValue = this.values[this.selectedItem];
|
||
if (currentValue) {
|
||
this.owner.selectSuggestion(currentValue, event);
|
||
}
|
||
}
|
||
setSelectedItem(selectedIndex, scrollIntoView) {
|
||
const normalizedIndex = wrapAround(selectedIndex, this.suggestions.length);
|
||
const prevSelectedSuggestion = this.suggestions[this.selectedItem];
|
||
const selectedSuggestion = this.suggestions[normalizedIndex];
|
||
prevSelectedSuggestion == null ? void 0 : prevSelectedSuggestion.removeClass("is-selected");
|
||
selectedSuggestion == null ? void 0 : selectedSuggestion.addClass("is-selected");
|
||
this.selectedItem = normalizedIndex;
|
||
if (scrollIntoView) {
|
||
selectedSuggestion.scrollIntoView(false);
|
||
}
|
||
}
|
||
};
|
||
var TextInputSuggest = class {
|
||
constructor(app, inputEl) {
|
||
this.app = app;
|
||
this.inputEl = inputEl;
|
||
this.scope = new import_obsidian.Scope();
|
||
this.suggestEl = createDiv("suggestion-container");
|
||
const suggestion = this.suggestEl.createDiv("suggestion");
|
||
this.suggest = new Suggest(this, suggestion, this.scope);
|
||
this.scope.register([], "Escape", this.close.bind(this));
|
||
this.inputEl.addEventListener("input", this.onInputChanged.bind(this));
|
||
this.inputEl.addEventListener("focus", this.onInputChanged.bind(this));
|
||
this.inputEl.addEventListener("blur", this.close.bind(this));
|
||
this.suggestEl.on("mousedown", ".suggestion-container", (event) => {
|
||
event.preventDefault();
|
||
});
|
||
}
|
||
onInputChanged() {
|
||
const inputStr = this.inputEl.value;
|
||
const suggestions = this.getSuggestions(inputStr).slice(0, 10);
|
||
if (suggestions.length > 0) {
|
||
this.suggest.setSuggestions(suggestions);
|
||
this.open(this.app.dom.appContainerEl, this.inputEl);
|
||
}
|
||
}
|
||
open(container, inputEl) {
|
||
this.app.keymap.pushScope(this.scope);
|
||
container.appendChild(this.suggestEl);
|
||
this.popper = createPopper(inputEl, this.suggestEl, {
|
||
placement: "bottom-start",
|
||
modifiers: [
|
||
{
|
||
name: "sameWidth",
|
||
enabled: true,
|
||
fn: ({ state, instance }) => {
|
||
const targetWidth = `${state.rects.reference.width}px`;
|
||
if (state.styles.popper.width === targetWidth) {
|
||
return;
|
||
}
|
||
state.styles.popper.width = targetWidth;
|
||
instance.update();
|
||
},
|
||
phase: "beforeWrite",
|
||
requires: ["computeStyles"]
|
||
}
|
||
]
|
||
});
|
||
}
|
||
close() {
|
||
this.app.keymap.popScope(this.scope);
|
||
this.suggest.setSuggestions([]);
|
||
this.popper.destroy();
|
||
this.suggestEl.detach();
|
||
}
|
||
};
|
||
var PathSuggest = class extends TextInputSuggest {
|
||
getSuggestions(inputStr) {
|
||
const abstractFiles = this.app.vault.getAllLoadedFiles();
|
||
const paths = [];
|
||
const lowerCaseInputStr = inputStr.toLowerCase();
|
||
abstractFiles.forEach((path) => {
|
||
if (path.path.toLowerCase().contains(lowerCaseInputStr)) {
|
||
paths.push(path);
|
||
}
|
||
});
|
||
return paths;
|
||
}
|
||
renderSuggestion(file, el) {
|
||
el.setText(file.path);
|
||
}
|
||
selectSuggestion(file) {
|
||
this.inputEl.value = file.path;
|
||
this.inputEl.trigger("input");
|
||
this.close();
|
||
}
|
||
};
|
||
|
||
// src/ui/modals.ts
|
||
var import_obsidian3 = require("obsidian");
|
||
|
||
// src/utils.ts
|
||
var import_obsidian2 = require("obsidian");
|
||
|
||
// node_modules/wildcard-match/build/index.es.mjs
|
||
function escapeRegExpChar(char) {
|
||
if (char === "-" || char === "^" || char === "$" || char === "+" || char === "." || char === "(" || char === ")" || char === "|" || char === "[" || char === "]" || char === "{" || char === "}" || char === "*" || char === "?" || char === "\\") {
|
||
return "\\".concat(char);
|
||
} else {
|
||
return char;
|
||
}
|
||
}
|
||
function escapeRegExpString(str) {
|
||
var result = "";
|
||
for (var i = 0; i < str.length; i++) {
|
||
result += escapeRegExpChar(str[i]);
|
||
}
|
||
return result;
|
||
}
|
||
function transform(pattern, separator) {
|
||
if (separator === void 0) {
|
||
separator = true;
|
||
}
|
||
if (Array.isArray(pattern)) {
|
||
var regExpPatterns = pattern.map(function(p) {
|
||
return "^".concat(transform(p, separator), "$");
|
||
});
|
||
return "(?:".concat(regExpPatterns.join("|"), ")");
|
||
}
|
||
var separatorSplitter = "";
|
||
var separatorMatcher = "";
|
||
var wildcard = ".";
|
||
if (separator === true) {
|
||
separatorSplitter = "/";
|
||
separatorMatcher = "[/\\\\]";
|
||
wildcard = "[^/\\\\]";
|
||
} else if (separator) {
|
||
separatorSplitter = separator;
|
||
separatorMatcher = escapeRegExpString(separatorSplitter);
|
||
if (separatorMatcher.length > 1) {
|
||
separatorMatcher = "(?:".concat(separatorMatcher, ")");
|
||
wildcard = "((?!".concat(separatorMatcher, ").)");
|
||
} else {
|
||
wildcard = "[^".concat(separatorMatcher, "]");
|
||
}
|
||
}
|
||
var requiredSeparator = separator ? "".concat(separatorMatcher, "+?") : "";
|
||
var optionalSeparator = separator ? "".concat(separatorMatcher, "*?") : "";
|
||
var segments = separator ? pattern.split(separatorSplitter) : [pattern];
|
||
var result = "";
|
||
for (var s = 0; s < segments.length; s++) {
|
||
var segment = segments[s];
|
||
var nextSegment = segments[s + 1];
|
||
var currentSeparator = "";
|
||
if (!segment && s > 0) {
|
||
continue;
|
||
}
|
||
if (separator) {
|
||
if (s === segments.length - 1) {
|
||
currentSeparator = optionalSeparator;
|
||
} else if (nextSegment !== "**") {
|
||
currentSeparator = requiredSeparator;
|
||
} else {
|
||
currentSeparator = "";
|
||
}
|
||
}
|
||
if (separator && segment === "**") {
|
||
if (currentSeparator) {
|
||
result += s === 0 ? "" : currentSeparator;
|
||
result += "(?:".concat(wildcard, "*?").concat(currentSeparator, ")*?");
|
||
}
|
||
continue;
|
||
}
|
||
for (var c = 0; c < segment.length; c++) {
|
||
var char = segment[c];
|
||
if (char === "\\") {
|
||
if (c < segment.length - 1) {
|
||
result += escapeRegExpChar(segment[c + 1]);
|
||
c++;
|
||
}
|
||
} else if (char === "?") {
|
||
result += wildcard;
|
||
} else if (char === "*") {
|
||
result += "".concat(wildcard, "*?");
|
||
} else {
|
||
result += escapeRegExpChar(char);
|
||
}
|
||
}
|
||
result += currentSeparator;
|
||
}
|
||
return result;
|
||
}
|
||
function isMatch(regexp, sample) {
|
||
if (typeof sample !== "string") {
|
||
throw new TypeError("Sample must be a string, but ".concat(typeof sample, " given"));
|
||
}
|
||
return regexp.test(sample);
|
||
}
|
||
function wildcardMatch(pattern, options) {
|
||
if (typeof pattern !== "string" && !Array.isArray(pattern)) {
|
||
throw new TypeError("The first argument must be a single pattern string or an array of patterns, but ".concat(typeof pattern, " given"));
|
||
}
|
||
if (typeof options === "string" || typeof options === "boolean") {
|
||
options = { separator: options };
|
||
}
|
||
if (arguments.length === 2 && !(typeof options === "undefined" || typeof options === "object" && options !== null && !Array.isArray(options))) {
|
||
throw new TypeError("The second argument must be an options object or a string/boolean separator, but ".concat(typeof options, " given"));
|
||
}
|
||
options = options || {};
|
||
if (options.separator === "\\") {
|
||
throw new Error("\\ is not a valid separator because it is used for escaping. Try setting the separator to `true` instead");
|
||
}
|
||
var regexpPattern = transform(pattern, options.separator);
|
||
var regexp = new RegExp("^".concat(regexpPattern, "$"), options.flags);
|
||
var fn2 = isMatch.bind(null, regexp);
|
||
fn2.options = options;
|
||
fn2.pattern = pattern;
|
||
fn2.regexp = regexp;
|
||
return fn2;
|
||
}
|
||
|
||
// src/utils.ts
|
||
function changeVirtualElementPin(vEl, pin) {
|
||
var _a;
|
||
if (pin && !vEl.el.hasClass("tree-item-pinned")) {
|
||
vEl.el.addClass("tree-item-pinned");
|
||
const pinDiv = document.createElement("div");
|
||
pinDiv.addClass("file-explorer-plus");
|
||
pinDiv.addClass("pin-icon");
|
||
(0, import_obsidian2.setIcon)(pinDiv, "pin");
|
||
(_a = vEl.el.firstChild) == null ? void 0 : _a.insertBefore(pinDiv, vEl.el.firstChild.firstChild);
|
||
} else if (!pin) {
|
||
vEl.el.removeClass("tree-item-pinned");
|
||
const pinIcons = Array.from(vEl.el.firstChild.children).filter((el) => el.hasClass("pin-icon"));
|
||
pinIcons.forEach((icon) => {
|
||
var _a2;
|
||
return (_a2 = vEl.el.firstChild) == null ? void 0 : _a2.removeChild(icon);
|
||
});
|
||
}
|
||
return vEl;
|
||
}
|
||
function checkPathFilter(filter, file) {
|
||
if (!filter.active || filter.pattern === "") {
|
||
return false;
|
||
}
|
||
if (filter.type == "FILES" && file instanceof import_obsidian2.TFolder) {
|
||
return false;
|
||
}
|
||
if (filter.type == "DIRECTORIES" && file instanceof import_obsidian2.TFile) {
|
||
return false;
|
||
}
|
||
if (filter.patternType === "REGEX") {
|
||
const re = new RegExp(filter.pattern);
|
||
if (re.test(file.path) || re.test(file.path.replace(/.md$/g, "")) || re.test(file.basename || file.name)) {
|
||
return true;
|
||
}
|
||
} else if (filter.patternType === "WILDCARD") {
|
||
const isMatch2 = wildcardMatch(filter.pattern);
|
||
if (isMatch2(file.path) || isMatch2(file.path.replace(/.md$/g, "")) || isMatch2(file.basename || file.name)) {
|
||
return true;
|
||
}
|
||
} else {
|
||
if (file.path === filter.pattern || file.path.replace(/.md$/g, "") == filter.pattern || (file.basename || file.name) === filter.pattern)
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
function checkTagFilter(filter, file) {
|
||
var _a;
|
||
if (file instanceof import_obsidian2.TFolder) {
|
||
return false;
|
||
}
|
||
if (!filter.active || filter.pattern === "") {
|
||
return false;
|
||
}
|
||
const cachedMetadata = this.app.metadataCache.getFileCache(file);
|
||
if (!cachedMetadata) {
|
||
return false;
|
||
}
|
||
const tags = (cachedMetadata.tags || []).map((tag) => tag.tag.replace(/^#/, ""));
|
||
const frontmatterTags = ((_a = cachedMetadata.frontmatter) == null ? void 0 : _a.tags) || [];
|
||
const allTags = [...new Set(tags.concat(frontmatterTags))];
|
||
if (filter.patternType === "REGEX") {
|
||
const re = new RegExp(filter.pattern);
|
||
return allTags.some((tag) => {
|
||
if (re.test(tag)) {
|
||
return true;
|
||
}
|
||
return false;
|
||
});
|
||
} else if (filter.patternType === "WILDCARD") {
|
||
const isMatch2 = wildcardMatch(filter.pattern);
|
||
return allTags.some((tag) => {
|
||
if (isMatch2(tag)) {
|
||
return true;
|
||
}
|
||
return false;
|
||
});
|
||
} else if (filter.patternType === "STRICT") {
|
||
return allTags.some((tag) => {
|
||
if (tag === filter.pattern) {
|
||
return true;
|
||
}
|
||
return false;
|
||
});
|
||
}
|
||
return false;
|
||
}
|
||
|
||
// src/ui/modals.ts
|
||
var InputFilterNameModal = class extends import_obsidian3.FuzzySuggestModal {
|
||
constructor(plugin, actionType) {
|
||
super(plugin.app);
|
||
this.plugin = plugin;
|
||
this.actionType = actionType;
|
||
this.setPlaceholder("Type name of a filter...");
|
||
}
|
||
getItems() {
|
||
var _a, _b, _c, _d;
|
||
let filters = [];
|
||
if (this.actionType === "PIN") {
|
||
filters = filters.concat(((_a = this.plugin.settings) == null ? void 0 : _a.pinFilters.tags) || []);
|
||
filters = filters.concat(((_b = this.plugin.settings) == null ? void 0 : _b.pinFilters.paths) || []);
|
||
} else if (this.actionType === "HIDE") {
|
||
filters = filters.concat(((_c = this.plugin.settings) == null ? void 0 : _c.hideFilters.tags) || []);
|
||
filters = filters.concat(((_d = this.plugin.settings) == null ? void 0 : _d.hideFilters.paths) || []);
|
||
}
|
||
filters = filters.filter((x) => x.name !== "");
|
||
filters = [...new Set(filters)];
|
||
return filters;
|
||
}
|
||
getItemText(filter) {
|
||
return `${filter.name} (${filter.active ? "Enabled" : "Disabled"})`;
|
||
}
|
||
onChooseItem(chosenFilter) {
|
||
var _a;
|
||
if (this.actionType === "PIN") {
|
||
this.plugin.settings.pinFilters.tags = this.plugin.settings.pinFilters.tags.map((filter) => {
|
||
if (filter.name === chosenFilter.name) {
|
||
filter.active = !filter.active;
|
||
}
|
||
return filter;
|
||
});
|
||
this.plugin.settings.pinFilters.paths = this.plugin.settings.pinFilters.paths.map((filter) => {
|
||
if (filter.name === chosenFilter.name) {
|
||
filter.active = !filter.active;
|
||
}
|
||
return filter;
|
||
});
|
||
} else if (this.actionType === "HIDE") {
|
||
this.plugin.settings.hideFilters.tags = this.plugin.settings.hideFilters.tags.map((filter) => {
|
||
if (filter.name === chosenFilter.name) {
|
||
filter.active = !filter.active;
|
||
}
|
||
return filter;
|
||
});
|
||
this.plugin.settings.hideFilters.paths = this.plugin.settings.hideFilters.paths.map((filter) => {
|
||
if (filter.name === chosenFilter.name) {
|
||
filter.active = !filter.active;
|
||
}
|
||
return filter;
|
||
});
|
||
}
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
}
|
||
};
|
||
var PathsActivatedModal = class extends import_obsidian3.Modal {
|
||
constructor(plugin, actionType, specificFilter, filterType) {
|
||
super(plugin.app);
|
||
this.plugin = plugin;
|
||
this.actionType = actionType;
|
||
this.specificFilter = specificFilter;
|
||
this.filterType = filterType;
|
||
}
|
||
onOpen() {
|
||
const { contentEl } = this;
|
||
const files = this.app.vault.getAllLoadedFiles();
|
||
let pathsActivated;
|
||
let pathFilters;
|
||
let tagFilters;
|
||
if (this.actionType === "HIDE") {
|
||
pathFilters = this.plugin.settings.hideFilters.paths;
|
||
tagFilters = this.plugin.settings.hideFilters.tags;
|
||
} else if (this.actionType === "PIN") {
|
||
pathFilters = this.plugin.settings.pinFilters.paths;
|
||
tagFilters = this.plugin.settings.pinFilters.tags;
|
||
}
|
||
if (this.specificFilter) {
|
||
pathsActivated = files.filter((file) => {
|
||
if (this.filterType === "PATH") {
|
||
return checkPathFilter(this.specificFilter, file);
|
||
} else if (this.filterType === "TAG") {
|
||
return checkTagFilter(this.specificFilter, file);
|
||
}
|
||
return false;
|
||
});
|
||
} else {
|
||
pathsActivated = this.actionType === "HIDE" ? this.plugin.getPathsToHide(files) : this.plugin.getPathsToPin(files);
|
||
}
|
||
pathsActivated = pathsActivated.map((file) => {
|
||
const pathFiltersActivated = pathFilters.map((filter) => {
|
||
if (checkPathFilter(filter, file)) {
|
||
if (filter.name && filter.name !== "") {
|
||
return filter.name;
|
||
} else {
|
||
return filter.pattern;
|
||
}
|
||
}
|
||
return void 0;
|
||
}).filter((x) => !!x);
|
||
const tagFiltersActivated = tagFilters.map((filter) => {
|
||
if (checkTagFilter(filter, file)) {
|
||
if (filter.name && filter.name !== "") {
|
||
return filter.name;
|
||
} else {
|
||
return filter.pattern;
|
||
}
|
||
}
|
||
return void 0;
|
||
}).filter((x) => !!x);
|
||
file.filtersActivated = pathFiltersActivated.join(", ") + tagFiltersActivated.join(", ");
|
||
return file;
|
||
});
|
||
contentEl.addClasses(["file-explorer-plus", "filters-activated-modal"]);
|
||
const data = [["Path", "Type", "Filters"]];
|
||
for (const path of pathsActivated) {
|
||
const row = [];
|
||
if (path instanceof import_obsidian3.TFile) {
|
||
const link = contentEl.createEl("a");
|
||
link.onClickEvent(() => {
|
||
this.app.workspace.getLeaf("tab").openFile(path);
|
||
});
|
||
link.textContent = path.path;
|
||
row.push(link);
|
||
} else {
|
||
row.push(path.path);
|
||
}
|
||
if (path instanceof import_obsidian3.TFile) {
|
||
row.push("File");
|
||
} else if (path instanceof import_obsidian3.TFolder) {
|
||
row.push("Folder");
|
||
} else {
|
||
row.push("Unknown");
|
||
}
|
||
row.push(path.filtersActivated);
|
||
data.push(row);
|
||
}
|
||
const table = generateTable(data);
|
||
contentEl.appendChild(table);
|
||
}
|
||
onClose() {
|
||
const { contentEl } = this;
|
||
contentEl.empty();
|
||
}
|
||
};
|
||
function generateTable(data) {
|
||
const table = document.createElement("table", {});
|
||
const thead = document.createElement("thead");
|
||
const tbody = document.createElement("tbody");
|
||
table.appendChild(thead);
|
||
table.appendChild(tbody);
|
||
for (let i = 0; i < data.length; i++) {
|
||
const row = data[i];
|
||
const tableRow = document.createElement("tr");
|
||
if (i === 0) {
|
||
thead.appendChild(tableRow);
|
||
} else {
|
||
tbody.appendChild(tableRow);
|
||
}
|
||
for (let j = 0; j < row.length; j++) {
|
||
let cell;
|
||
if (i === 0) {
|
||
cell = document.createElement("th");
|
||
cell.textContent = data[i][j];
|
||
} else {
|
||
cell = document.createElement("td");
|
||
if (typeof data[i][j] === "string") {
|
||
cell.textContent = data[i][j];
|
||
} else {
|
||
cell.appendChild(data[i][j]);
|
||
}
|
||
}
|
||
tableRow.appendChild(cell);
|
||
}
|
||
}
|
||
return table;
|
||
}
|
||
|
||
// src/settings.ts
|
||
var UNSEEN_FILES_DEFAULT_SETTINGS = {
|
||
hideStrictPathFilters: true,
|
||
pinFilters: {
|
||
active: true,
|
||
tags: [
|
||
{
|
||
name: "",
|
||
active: true,
|
||
pattern: "",
|
||
patternType: "STRICT"
|
||
}
|
||
],
|
||
paths: [
|
||
{
|
||
name: "",
|
||
active: true,
|
||
type: "FILES_AND_DIRECTORIES",
|
||
pattern: "",
|
||
patternType: "WILDCARD"
|
||
}
|
||
]
|
||
},
|
||
hideFilters: {
|
||
active: true,
|
||
tags: [
|
||
{
|
||
name: "",
|
||
active: true,
|
||
pattern: "",
|
||
patternType: "STRICT"
|
||
}
|
||
],
|
||
paths: [
|
||
{
|
||
name: "",
|
||
active: true,
|
||
type: "FILES_AND_DIRECTORIES",
|
||
pattern: "",
|
||
patternType: "WILDCARD"
|
||
}
|
||
]
|
||
}
|
||
};
|
||
var FileExplorerPlusSettingTab = class extends import_obsidian4.PluginSettingTab {
|
||
constructor(app, plugin) {
|
||
super(app, plugin);
|
||
this.plugin = plugin;
|
||
}
|
||
display() {
|
||
this.cleanSettings();
|
||
this.containerEl.empty();
|
||
this.containerEl.addClass("file-explorer-plus");
|
||
new import_obsidian4.Setting(this.containerEl).setName("Hide strict path filters in settings").setDesc(
|
||
"Hide path filters with type strict from both the pin and hide filter tables below. Good for decluttering the filter tables. These are created when pinning or hiding a file straight in the file explorer."
|
||
).addToggle((toggle) => {
|
||
toggle.setTooltip("Active").setValue(this.plugin.settings.hideStrictPathFilters).onChange((isActive) => {
|
||
this.plugin.settings.hideStrictPathFilters = isActive;
|
||
this.plugin.saveSettings();
|
||
this.display();
|
||
});
|
||
});
|
||
this.containerEl.createEl("h2", { text: "Pin filters", attr: { class: "settings-header" } });
|
||
new import_obsidian4.Setting(this.containerEl).setName("Enable pin filters").setDesc("Toggle whether or not pin filters for paths and folders should be active.").addToggle((toggle) => {
|
||
toggle.setTooltip("Active").setValue(this.plugin.settings.pinFilters.active).onChange((isActive) => {
|
||
var _a;
|
||
this.plugin.settings.pinFilters.active = isActive;
|
||
this.plugin.saveSettings();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
});
|
||
new import_obsidian4.Setting(this.containerEl).setName("View paths pinned by filters").setDesc("View paths that are currently being pinned by the active filters below.").addButton((button) => {
|
||
button.setButtonText("View").onClick(() => {
|
||
new PathsActivatedModal(this.plugin, "PIN").open();
|
||
});
|
||
});
|
||
this.pinTagFiltersSettings();
|
||
this.pinPathFiltersSettings();
|
||
this.containerEl.createEl("h2", { text: "Hide filters", attr: { class: "settings-header" } });
|
||
new import_obsidian4.Setting(this.containerEl).setName("Enable hide filters").setDesc("Toggle whether or not hide filters for paths and folders should be active.").addToggle((toggle) => {
|
||
toggle.setTooltip("Active").setValue(this.plugin.settings.hideFilters.active).onChange((isActive) => {
|
||
var _a;
|
||
this.plugin.settings.hideFilters.active = isActive;
|
||
this.plugin.saveSettings();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
});
|
||
new import_obsidian4.Setting(this.containerEl).setName("View paths hidden by filters").setDesc("View paths that are currently being hidden by the active filters below.").addButton((button) => {
|
||
button.setButtonText("View").onClick(() => {
|
||
new PathsActivatedModal(this.plugin, "HIDE").open();
|
||
});
|
||
});
|
||
this.hideTagFiltersSettings();
|
||
this.hidePathFiltersSettings();
|
||
}
|
||
cleanSettings() {
|
||
this.plugin.settings.hideFilters.tags = this.plugin.settings.hideFilters.tags.filter((filter, index, arr) => {
|
||
if (index == arr.length - 1) {
|
||
return true;
|
||
}
|
||
return filter.pattern !== "" && arr.findIndex((x) => x.pattern === filter.pattern) === index;
|
||
});
|
||
this.plugin.settings.hideFilters.paths = this.plugin.settings.hideFilters.paths.filter((filter, index, arr) => {
|
||
if (index == arr.length - 1) {
|
||
return true;
|
||
}
|
||
return filter.pattern !== "" && arr.findIndex((x) => x.pattern === filter.pattern) === index;
|
||
});
|
||
}
|
||
pinTagFiltersSettings() {
|
||
this.containerEl.createEl("h2", { text: "Tag filters" });
|
||
this.plugin.settings.pinFilters.tags.forEach((filter, index) => {
|
||
new import_obsidian4.Setting(this.containerEl).addText((text) => {
|
||
text.setPlaceholder("Name (optional)").setValue(filter.name).onChange((newName) => {
|
||
this.plugin.settings.pinFilters.tags[index].name = newName;
|
||
this.plugin.saveSettings();
|
||
});
|
||
}).addText((text) => {
|
||
text.setPlaceholder("Tag pattern (required)").setValue(filter.pattern).onChange((newPattern) => {
|
||
var _a;
|
||
this.plugin.settings.pinFilters.tags[index].pattern = newPattern;
|
||
this.plugin.saveSettings();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
}).addDropdown((dropdown) => {
|
||
dropdown.addOptions({
|
||
WILDCARD: "Wildcard",
|
||
REGEX: "Regex",
|
||
STRICT: "Strict"
|
||
}).setValue(filter.patternType).onChange((newPatternType) => {
|
||
var _a;
|
||
this.plugin.settings.pinFilters.tags[index].patternType = newPatternType;
|
||
this.plugin.saveSettings();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
}).addToggle((toggle) => {
|
||
toggle.setTooltip("Active").setValue(filter.active).onChange((isActive) => {
|
||
var _a;
|
||
this.plugin.settings.pinFilters.tags[index].active = isActive;
|
||
this.plugin.saveSettings();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
}).addExtraButton((button) => {
|
||
button.setIcon("calculator").setTooltip("View paths pinned by this filter").onClick(() => {
|
||
new PathsActivatedModal(this.plugin, "PIN", filter, "TAG").open();
|
||
});
|
||
}).addExtraButton((button) => {
|
||
button.setIcon("cross").setTooltip("Delete").onClick(() => {
|
||
var _a;
|
||
this.plugin.settings.pinFilters.tags.splice(index, 1);
|
||
this.plugin.saveSettings();
|
||
this.display();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
});
|
||
});
|
||
new import_obsidian4.Setting(this.containerEl).addButton((button) => {
|
||
button.setButtonText("Add new pin filter for tags").setCta().onClick(() => {
|
||
this.plugin.settings.pinFilters.tags.push({
|
||
name: "",
|
||
active: true,
|
||
pattern: "",
|
||
patternType: "STRICT"
|
||
});
|
||
this.plugin.saveSettings();
|
||
this.display();
|
||
});
|
||
});
|
||
}
|
||
pinPathFiltersSettings() {
|
||
this.containerEl.createEl("h2", { text: "Path filters" });
|
||
this.plugin.settings.pinFilters.paths.forEach((filter, index) => {
|
||
if (this.plugin.settings.hideStrictPathFilters && filter.patternType === "STRICT") {
|
||
return;
|
||
}
|
||
new import_obsidian4.Setting(this.containerEl).addText((text) => {
|
||
text.setPlaceholder("Name (optional)").setValue(filter.name).onChange((newName) => {
|
||
this.plugin.settings.pinFilters.paths[index].name = newName;
|
||
this.plugin.saveSettings();
|
||
});
|
||
}).addSearch((text) => {
|
||
new PathSuggest(this.app, text.inputEl);
|
||
text.setPlaceholder("Path pattern (required)").setValue(filter.pattern).onChange((newPattern) => {
|
||
var _a;
|
||
this.plugin.settings.pinFilters.paths[index].pattern = newPattern;
|
||
this.plugin.saveSettings();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
}).addDropdown((dropdown) => {
|
||
dropdown.addOptions({
|
||
FILES_AND_DIRECTORIES: "Files and folders",
|
||
FILES: "Files",
|
||
DIRECTORIES: "Folders"
|
||
}).setValue(filter.type).onChange((newType) => {
|
||
var _a;
|
||
this.plugin.settings.pinFilters.paths[index].type = newType;
|
||
this.plugin.saveSettings();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
}).addDropdown((dropdown) => {
|
||
dropdown.addOptions({
|
||
WILDCARD: "Wildcard",
|
||
REGEX: "Regex",
|
||
STRICT: "Strict"
|
||
}).setValue(filter.patternType).onChange((newPatternType) => {
|
||
var _a;
|
||
this.plugin.settings.pinFilters.paths[index].patternType = newPatternType;
|
||
this.plugin.saveSettings();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
}).addToggle((toggle) => {
|
||
toggle.setTooltip("Active").setValue(filter.active).onChange((isActive) => {
|
||
var _a;
|
||
this.plugin.settings.pinFilters.paths[index].active = isActive;
|
||
this.plugin.saveSettings();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
}).addExtraButton((button) => {
|
||
button.setIcon("calculator").setTooltip("View paths pinned by this filter").onClick(() => {
|
||
new PathsActivatedModal(this.plugin, "PIN", filter, "PATH").open();
|
||
});
|
||
}).addExtraButton((button) => {
|
||
button.setIcon("cross").setTooltip("Delete").onClick(() => {
|
||
var _a;
|
||
this.plugin.settings.pinFilters.paths.splice(index, 1);
|
||
this.plugin.saveSettings();
|
||
this.display();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
});
|
||
});
|
||
new import_obsidian4.Setting(this.containerEl).addButton((button) => {
|
||
button.setButtonText("Add new pin filter for paths").setCta().onClick(() => {
|
||
this.plugin.settings.pinFilters.paths.push({
|
||
name: "",
|
||
active: true,
|
||
type: "FILES_AND_DIRECTORIES",
|
||
pattern: "",
|
||
patternType: "WILDCARD"
|
||
});
|
||
this.plugin.saveSettings();
|
||
this.display();
|
||
});
|
||
});
|
||
}
|
||
hideTagFiltersSettings() {
|
||
this.containerEl.createEl("h2", { text: "Tag filters" });
|
||
this.plugin.settings.hideFilters.tags.forEach((filter, index) => {
|
||
new import_obsidian4.Setting(this.containerEl).addText((text) => {
|
||
text.setPlaceholder("Name (optional)").setValue(filter.name).onChange((newName) => {
|
||
this.plugin.settings.hideFilters.tags[index].name = newName;
|
||
this.plugin.saveSettings();
|
||
});
|
||
}).addText((text) => {
|
||
text.setPlaceholder("Tag pattern (required)").setValue(filter.pattern).onChange((newPattern) => {
|
||
var _a;
|
||
this.plugin.settings.hideFilters.tags[index].pattern = newPattern;
|
||
this.plugin.saveSettings();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
}).addDropdown((dropdown) => {
|
||
dropdown.addOptions({
|
||
WILDCARD: "Wildcard",
|
||
REGEX: "Regex",
|
||
STRICT: "Strict"
|
||
}).setValue(filter.patternType).onChange((newPatternType) => {
|
||
var _a;
|
||
this.plugin.settings.hideFilters.tags[index].patternType = newPatternType;
|
||
this.plugin.saveSettings();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
}).addToggle((toggle) => {
|
||
toggle.setTooltip("Active").setValue(filter.active).onChange((isActive) => {
|
||
var _a;
|
||
this.plugin.settings.hideFilters.tags[index].active = isActive;
|
||
this.plugin.saveSettings();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
}).addExtraButton((button) => {
|
||
button.setIcon("calculator").setTooltip("View paths hidden by this filter").onClick(() => {
|
||
new PathsActivatedModal(this.plugin, "HIDE", filter, "TAG").open();
|
||
});
|
||
}).addExtraButton((button) => {
|
||
button.setIcon("cross").setTooltip("Delete").onClick(() => {
|
||
var _a;
|
||
this.plugin.settings.hideFilters.tags.splice(index, 1);
|
||
this.plugin.saveSettings();
|
||
this.display();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
});
|
||
});
|
||
new import_obsidian4.Setting(this.containerEl).addButton((button) => {
|
||
button.setButtonText("Add new hide filter for tags").setCta().onClick(() => {
|
||
this.plugin.settings.hideFilters.tags.push({
|
||
name: "",
|
||
active: true,
|
||
pattern: "",
|
||
patternType: "STRICT"
|
||
});
|
||
this.plugin.saveSettings();
|
||
this.display();
|
||
});
|
||
});
|
||
}
|
||
hidePathFiltersSettings() {
|
||
this.containerEl.createEl("h2", { text: "Path filters" });
|
||
this.plugin.settings.hideFilters.paths.forEach((filter, index) => {
|
||
if (this.plugin.settings.hideStrictPathFilters && filter.patternType === "STRICT") {
|
||
return;
|
||
}
|
||
new import_obsidian4.Setting(this.containerEl).addText((text) => {
|
||
text.setPlaceholder("Name (optional)").setValue(filter.name).onChange((newName) => {
|
||
this.plugin.settings.hideFilters.paths[index].name = newName;
|
||
this.plugin.saveSettings();
|
||
});
|
||
}).addSearch((text) => {
|
||
new PathSuggest(this.app, text.inputEl);
|
||
text.setPlaceholder("Path pattern (required)").setValue(filter.pattern).onChange((newPattern) => {
|
||
var _a;
|
||
this.plugin.settings.hideFilters.paths[index].pattern = newPattern;
|
||
this.plugin.saveSettings();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
}).addDropdown((dropdown) => {
|
||
dropdown.addOptions({
|
||
FILES_AND_DIRECTORIES: "Files and folders",
|
||
FILES: "Files",
|
||
DIRECTORIES: "Folders"
|
||
}).setValue(filter.type).onChange((newType) => {
|
||
var _a;
|
||
this.plugin.settings.hideFilters.paths[index].type = newType;
|
||
this.plugin.saveSettings();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
}).addDropdown((dropdown) => {
|
||
dropdown.addOptions({
|
||
WILDCARD: "Wildcard",
|
||
REGEX: "Regex",
|
||
STRICT: "Strict"
|
||
}).setValue(filter.patternType).onChange((newPatternType) => {
|
||
var _a;
|
||
this.plugin.settings.hideFilters.paths[index].patternType = newPatternType;
|
||
this.plugin.saveSettings();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
}).addToggle((toggle) => {
|
||
toggle.setTooltip("Active").setValue(filter.active).onChange((isActive) => {
|
||
var _a;
|
||
this.plugin.settings.hideFilters.paths[index].active = isActive;
|
||
this.plugin.saveSettings();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
}).addExtraButton((button) => {
|
||
button.setIcon("calculator").setTooltip("View paths hidden by this filter").onClick(() => {
|
||
new PathsActivatedModal(this.plugin, "HIDE", filter, "PATH").open();
|
||
});
|
||
}).addExtraButton((button) => {
|
||
button.setIcon("cross").setTooltip("Delete").onClick(() => {
|
||
var _a;
|
||
this.plugin.settings.hideFilters.paths.splice(index, 1);
|
||
this.plugin.saveSettings();
|
||
this.display();
|
||
(_a = this.plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
});
|
||
});
|
||
new import_obsidian4.Setting(this.containerEl).addButton((button) => {
|
||
button.setButtonText("Add new hide filter for paths").setCta().onClick(() => {
|
||
this.plugin.settings.hideFilters.paths.push({
|
||
name: "",
|
||
active: true,
|
||
type: "FILES_AND_DIRECTORIES",
|
||
pattern: "",
|
||
patternType: "WILDCARD"
|
||
});
|
||
this.plugin.saveSettings();
|
||
this.display();
|
||
});
|
||
});
|
||
}
|
||
};
|
||
|
||
// src/handlers.ts
|
||
var import_obsidian5 = require("obsidian");
|
||
function addCommands(plugin) {
|
||
plugin.addCommand({
|
||
id: "toggle-pin-filter",
|
||
name: "Toggle pin filter",
|
||
callback: () => {
|
||
new InputFilterNameModal(plugin, "PIN").open();
|
||
}
|
||
});
|
||
plugin.addCommand({
|
||
id: "toggle-hide-filter",
|
||
name: "Toggle hide filter",
|
||
callback: () => {
|
||
new InputFilterNameModal(plugin, "HIDE").open();
|
||
}
|
||
});
|
||
plugin.addCommand({
|
||
id: "toggle-global-pin-filters",
|
||
name: "Toggle all pin filters",
|
||
callback: () => {
|
||
var _a;
|
||
plugin.settings.pinFilters.active = !plugin.settings.pinFilters.active;
|
||
plugin.saveSettings();
|
||
(_a = plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
}
|
||
});
|
||
plugin.addCommand({
|
||
id: "toggle-global-hide-filters",
|
||
name: "Toggle all hide filters",
|
||
callback: () => {
|
||
var _a;
|
||
plugin.settings.hideFilters.active = !plugin.settings.hideFilters.active;
|
||
plugin.saveSettings();
|
||
(_a = plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
}
|
||
});
|
||
}
|
||
function addOnTagChange(plugin) {
|
||
plugin.registerEvent(
|
||
plugin.app.metadataCache.on("changed", (path, data, cache) => {
|
||
var _a, _b;
|
||
const isPinned = plugin.getFileExplorer().fileItems[path.path].info.pinned;
|
||
const isHidden = plugin.getFileExplorer().fileItems[path.path].info.hidden;
|
||
const shouldBePinned = plugin.settings.pinFilters.tags.some((filter) => checkTagFilter(filter, path));
|
||
const shouldBeHidden = plugin.settings.hideFilters.tags.some((filter) => checkTagFilter(filter, path));
|
||
if (isPinned !== shouldBePinned && !shouldBeHidden) {
|
||
(_a = plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
return;
|
||
}
|
||
if (isHidden !== shouldBeHidden) {
|
||
(_b = plugin.getFileExplorer()) == null ? void 0 : _b.requestSort();
|
||
}
|
||
})
|
||
);
|
||
}
|
||
function addOnRename(plugin) {
|
||
plugin.registerEvent(
|
||
plugin.app.vault.on("rename", (path, oldPath) => {
|
||
const hideFilterPreviousIndex = plugin.settings.hideFilters.paths.findIndex((pathFilter) => {
|
||
if (pathFilter.patternType === "STRICT" && pathFilter.pattern === oldPath) {
|
||
return true;
|
||
}
|
||
return false;
|
||
});
|
||
if (hideFilterPreviousIndex !== -1) {
|
||
plugin.settings.hideFilters.paths[hideFilterPreviousIndex].pattern = path.path;
|
||
}
|
||
const pinFilterPreviousIndex = plugin.settings.pinFilters.paths.findIndex((pathFilter) => {
|
||
if (pathFilter.patternType === "STRICT" && pathFilter.pattern === oldPath) {
|
||
return true;
|
||
}
|
||
return false;
|
||
});
|
||
if (pinFilterPreviousIndex !== -1) {
|
||
plugin.settings.pinFilters.paths[pinFilterPreviousIndex].pattern = path.path;
|
||
}
|
||
})
|
||
);
|
||
}
|
||
function addOnDelete(plugin) {
|
||
plugin.registerEvent(
|
||
plugin.app.vault.on("delete", (path) => {
|
||
const hideFilterPreviousIndex = plugin.settings.hideFilters.paths.findIndex((pathFilter) => {
|
||
if (pathFilter.patternType === "STRICT" && pathFilter.pattern === path.path) {
|
||
return true;
|
||
}
|
||
return false;
|
||
});
|
||
if (hideFilterPreviousIndex !== -1) {
|
||
plugin.settings.hideFilters.paths.splice(hideFilterPreviousIndex, 1);
|
||
}
|
||
const pinFilterPreviousIndex = plugin.settings.pinFilters.paths.findIndex((pathFilter) => {
|
||
if (pathFilter.patternType === "STRICT" && pathFilter.pattern === path.path) {
|
||
return true;
|
||
}
|
||
return false;
|
||
});
|
||
if (pinFilterPreviousIndex !== -1) {
|
||
plugin.settings.pinFilters.paths.splice(pinFilterPreviousIndex, 1);
|
||
}
|
||
})
|
||
);
|
||
}
|
||
function addCommandsToFileMenu(plugin) {
|
||
plugin.registerEvent(
|
||
plugin.app.workspace.on("file-menu", (menu, path) => {
|
||
if (path instanceof import_obsidian5.TFile) {
|
||
menu.addSeparator().addItem((item) => {
|
||
const index = plugin.settings.pinFilters.paths.findIndex(
|
||
(filter) => filter.patternType === "STRICT" && filter.type === "FILES" && filter.pattern === path.path
|
||
);
|
||
if (index === -1 || !plugin.settings.pinFilters.paths[index].active) {
|
||
item.setTitle("Pin File").setIcon("pin").onClick(() => {
|
||
var _a;
|
||
if (index === -1) {
|
||
plugin.settings.pinFilters.paths.push({
|
||
name: "",
|
||
active: true,
|
||
type: "FILES",
|
||
pattern: path.path,
|
||
patternType: "STRICT"
|
||
});
|
||
} else {
|
||
plugin.settings.pinFilters.paths[index].active = true;
|
||
}
|
||
plugin.saveSettings();
|
||
if (plugin.settings.pinFilters.active) {
|
||
(_a = plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
}
|
||
});
|
||
} else {
|
||
item.setTitle("Unpin File").setIcon("pin-off").onClick(() => {
|
||
var _a;
|
||
plugin.settings.pinFilters.paths.splice(index, 1);
|
||
plugin.saveSettings();
|
||
(_a = plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
}
|
||
}).addItem((item) => {
|
||
const index = plugin.settings.hideFilters.paths.findIndex(
|
||
(filter) => filter.patternType === "STRICT" && filter.type === "FILES" && filter.pattern === path.path
|
||
);
|
||
if (index === -1 || !plugin.settings.hideFilters.paths[index].active) {
|
||
item.setTitle("Hide File").setIcon("eye-off").onClick(() => {
|
||
var _a;
|
||
if (index === -1) {
|
||
plugin.settings.hideFilters.paths.push({
|
||
name: "",
|
||
active: true,
|
||
type: "FILES",
|
||
pattern: path.path,
|
||
patternType: "STRICT"
|
||
});
|
||
} else {
|
||
plugin.settings.hideFilters.paths[index].active = true;
|
||
}
|
||
plugin.saveSettings();
|
||
if (plugin.settings.hideFilters.active) {
|
||
(_a = plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
}
|
||
});
|
||
} else {
|
||
item.setTitle("Unhide File").setIcon("eye").onClick(() => {
|
||
var _a;
|
||
plugin.settings.hideFilters.paths.splice(index, 1);
|
||
plugin.saveSettings();
|
||
(_a = plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
}
|
||
});
|
||
} else {
|
||
menu.addSeparator().addItem((item) => {
|
||
const index = plugin.settings.pinFilters.paths.findIndex(
|
||
(filter) => filter.patternType === "STRICT" && filter.type === "DIRECTORIES" && filter.pattern === path.path
|
||
);
|
||
if (index === -1 || !plugin.settings.pinFilters.paths[index].active) {
|
||
item.setTitle("Pin Folder").setIcon("pin").onClick(() => {
|
||
var _a;
|
||
if (index === -1) {
|
||
plugin.settings.pinFilters.paths.push({
|
||
name: "",
|
||
active: true,
|
||
type: "DIRECTORIES",
|
||
pattern: path.path,
|
||
patternType: "STRICT"
|
||
});
|
||
} else {
|
||
plugin.settings.pinFilters.paths[index].active = true;
|
||
}
|
||
plugin.saveSettings();
|
||
if (plugin.settings.pinFilters.active) {
|
||
(_a = plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
}
|
||
});
|
||
} else {
|
||
item.setTitle("Unpin Folder").setIcon("pin-off").onClick(() => {
|
||
var _a;
|
||
plugin.settings.pinFilters.paths.splice(index, 1);
|
||
plugin.saveSettings();
|
||
(_a = plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
}
|
||
}).addItem((item) => {
|
||
const index = plugin.settings.hideFilters.paths.findIndex(
|
||
(filter) => filter.patternType === "STRICT" && filter.type === "DIRECTORIES" && filter.pattern === path.path
|
||
);
|
||
if (index === -1 || !plugin.settings.hideFilters.paths[index].active) {
|
||
item.setTitle("Hide Folder").setIcon("eye-off").onClick(() => {
|
||
var _a;
|
||
if (index === -1) {
|
||
plugin.settings.hideFilters.paths.push({
|
||
name: "",
|
||
active: true,
|
||
type: "DIRECTORIES",
|
||
pattern: path.path,
|
||
patternType: "STRICT"
|
||
});
|
||
} else {
|
||
plugin.settings.hideFilters.paths[index].active = true;
|
||
}
|
||
plugin.saveSettings();
|
||
if (plugin.settings.hideFilters.active) {
|
||
(_a = plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
}
|
||
});
|
||
} else {
|
||
item.setTitle("Unhide Folder").setIcon("eye").onClick(() => {
|
||
var _a;
|
||
plugin.settings.hideFilters.paths.splice(index, 1);
|
||
plugin.saveSettings();
|
||
(_a = plugin.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
}
|
||
});
|
||
}
|
||
})
|
||
);
|
||
}
|
||
|
||
// src/main.ts
|
||
var FileExplorerPlusPlugin = class extends import_obsidian6.Plugin {
|
||
async onload() {
|
||
await this.loadSettings();
|
||
addCommandsToFileMenu(this);
|
||
addOnRename(this);
|
||
addOnDelete(this);
|
||
addOnTagChange(this);
|
||
addCommands(this);
|
||
this.addSettingTab(new FileExplorerPlusSettingTab(this.app, this));
|
||
this.app.workspace.onLayoutReady(() => {
|
||
var _a;
|
||
this.patchFileExplorer();
|
||
(_a = this.getFileExplorer()) == null ? void 0 : _a.requestSort();
|
||
});
|
||
this.app.workspace.on("layout-change", () => {
|
||
var _a, _b;
|
||
if (!((_a = this.getFileExplorer()) == null ? void 0 : _a.fileExplorerPlusPatched)) {
|
||
this.patchFileExplorer();
|
||
(_b = this.getFileExplorer()) == null ? void 0 : _b.requestSort();
|
||
}
|
||
});
|
||
}
|
||
getFileExplorerContainer() {
|
||
var _a;
|
||
return (_a = this.app.workspace.getLeavesOfType("file-explorer")) == null ? void 0 : _a.first();
|
||
}
|
||
getFileExplorer() {
|
||
const fileExplorerContainer = this.getFileExplorerContainer();
|
||
return fileExplorerContainer == null ? void 0 : fileExplorerContainer.view;
|
||
}
|
||
patchFileExplorer() {
|
||
const fileExplorer = this.getFileExplorer();
|
||
if (!fileExplorer) {
|
||
throw Error("Could not find file explorer");
|
||
}
|
||
const plugin = this;
|
||
const leaf = this.app.workspace.getLeaf(true);
|
||
this.register(
|
||
around(Object.getPrototypeOf(fileExplorer), {
|
||
getSortedFolderItems(old) {
|
||
return function(...args) {
|
||
let sortedChildren = old.call(this, ...args);
|
||
let paths = sortedChildren.map((el) => el.file);
|
||
if (plugin.settings.hideFilters.active) {
|
||
const pathsToHide = plugin.getPathsToHide(paths);
|
||
const pathsToHideLookUp = pathsToHide.reduce(
|
||
(acc, path) => {
|
||
acc[path.path] = true;
|
||
return acc;
|
||
},
|
||
{}
|
||
);
|
||
sortedChildren = sortedChildren.filter((vEl) => {
|
||
if (pathsToHideLookUp[vEl.file.path]) {
|
||
vEl.info.hidden = true;
|
||
return false;
|
||
} else {
|
||
vEl.info.hidden = false;
|
||
return true;
|
||
}
|
||
});
|
||
}
|
||
paths = sortedChildren.map((el) => el.file);
|
||
if (plugin.settings.pinFilters.active) {
|
||
const pathsToPin = plugin.getPathsToPin(paths);
|
||
const pathsToPinLookUp = pathsToPin.reduce(
|
||
(acc, path) => {
|
||
acc[path.path] = true;
|
||
return acc;
|
||
},
|
||
{}
|
||
);
|
||
const pinnedVirtualElements = sortedChildren.filter((vEl) => {
|
||
if (pathsToPinLookUp[vEl.file.path]) {
|
||
vEl = changeVirtualElementPin(vEl, true);
|
||
vEl.info.pinned = true;
|
||
return true;
|
||
} else {
|
||
vEl = changeVirtualElementPin(vEl, false);
|
||
vEl.info.pinned = false;
|
||
return false;
|
||
}
|
||
});
|
||
const notPinnedVirtualElements = sortedChildren.filter((vEl) => {
|
||
if (pathsToPinLookUp[vEl.file.path]) {
|
||
return false;
|
||
} else {
|
||
return true;
|
||
}
|
||
});
|
||
sortedChildren = pinnedVirtualElements.concat(notPinnedVirtualElements);
|
||
} else {
|
||
sortedChildren = sortedChildren.map((vEl) => changeVirtualElementPin(vEl, false));
|
||
}
|
||
return sortedChildren;
|
||
};
|
||
}
|
||
})
|
||
);
|
||
leaf.detach();
|
||
fileExplorer.fileExplorerPlusPatched = true;
|
||
}
|
||
onunload() {
|
||
const fileExplorer = this.getFileExplorer();
|
||
if (!fileExplorer) {
|
||
return;
|
||
}
|
||
for (const path in fileExplorer.fileItems) {
|
||
fileExplorer.fileItems[path] = changeVirtualElementPin(fileExplorer.fileItems[path], false);
|
||
}
|
||
fileExplorer.requestSort();
|
||
fileExplorer.fileExplorerPlusPatched = false;
|
||
}
|
||
async loadSettings() {
|
||
this.settings = Object.assign({}, UNSEEN_FILES_DEFAULT_SETTINGS, await this.loadData());
|
||
}
|
||
async saveSettings() {
|
||
await this.saveData(this.settings);
|
||
}
|
||
getPathsToPin(paths) {
|
||
return paths.filter((path) => {
|
||
if (!path) {
|
||
return false;
|
||
}
|
||
const pathFilterActivated = this.settings.pinFilters.paths.some((filter) => checkPathFilter(filter, path));
|
||
if (pathFilterActivated) {
|
||
return true;
|
||
}
|
||
const tagFilterActivated = this.settings.pinFilters.tags.some((filter) => checkTagFilter(filter, path));
|
||
if (tagFilterActivated) {
|
||
return true;
|
||
}
|
||
return false;
|
||
});
|
||
}
|
||
getPathsToHide(paths) {
|
||
return paths.filter((path) => {
|
||
if (!path) {
|
||
return false;
|
||
}
|
||
const pathFilterActivated = this.settings.hideFilters.paths.some((filter) => checkPathFilter(filter, path));
|
||
if (pathFilterActivated) {
|
||
return true;
|
||
}
|
||
const tagFilterActivated = this.settings.hideFilters.tags.some((filter) => checkTagFilter(filter, path));
|
||
if (tagFilterActivated) {
|
||
return true;
|
||
}
|
||
return false;
|
||
});
|
||
}
|
||
};
|