Skip to content

Commit 08844ba

Browse files
committed
feat: $scrollWidth , $relativPath and $path operators
1 parent afcc695 commit 08844ba

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/utility.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,21 @@ const operatorsMap = {
1818
$hash: () => window.location.hash,
1919
$subdomain: () => getSubdomain() || "",
2020
$object_id: () => ObjectId().toString(),
21-
"ObjectId()": () => ObjectId().toString()
21+
"ObjectId()": () => ObjectId().toString(),
22+
$scrollWidth: (element) => element?.scrollWidth || 0,
23+
$relativePath: () => {
24+
let depth = window.location.pathname.split("/").length - 1;
25+
return depth > 0 ? "../".repeat(depth) : "./";
26+
},
27+
$path: () => {
28+
let path = window.location.pathname;
29+
30+
if (path.split("/").pop().includes(".")) {
31+
path = path.replace(/\/[^\/]+$/, "/");
32+
}
33+
34+
return path === "/" ? "" : path;
35+
}
2236
};
2337

2438
function processOperators(element, value, exclude = []) {

0 commit comments

Comments
 (0)