@real1ty-obsidian-plugins/utils 2.10.0 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/core/color-utils.d.ts +17 -0
  2. package/dist/core/color-utils.d.ts.map +1 -0
  3. package/dist/core/color-utils.js +29 -0
  4. package/dist/core/color-utils.js.map +1 -0
  5. package/dist/core/css-utils.d.ts +39 -0
  6. package/dist/core/css-utils.d.ts.map +1 -0
  7. package/dist/core/css-utils.js +60 -0
  8. package/dist/core/css-utils.js.map +1 -0
  9. package/dist/core/index.d.ts +3 -0
  10. package/dist/core/index.d.ts.map +1 -1
  11. package/dist/core/index.js +3 -0
  12. package/dist/core/index.js.map +1 -1
  13. package/dist/core/property-renderer.d.ts +9 -0
  14. package/dist/core/property-renderer.d.ts.map +1 -0
  15. package/dist/core/property-renderer.js +42 -0
  16. package/dist/core/property-renderer.js.map +1 -0
  17. package/dist/file/file-utils.d.ts +28 -0
  18. package/dist/file/file-utils.d.ts.map +1 -0
  19. package/dist/file/file-utils.js +55 -0
  20. package/dist/file/file-utils.js.map +1 -0
  21. package/dist/file/file.d.ts +51 -1
  22. package/dist/file/file.d.ts.map +1 -1
  23. package/dist/file/file.js +69 -10
  24. package/dist/file/file.js.map +1 -1
  25. package/dist/file/index.d.ts +1 -0
  26. package/dist/file/index.d.ts.map +1 -1
  27. package/dist/file/index.js +1 -0
  28. package/dist/file/index.js.map +1 -1
  29. package/dist/file/link-parser.d.ts +28 -0
  30. package/dist/file/link-parser.d.ts.map +1 -1
  31. package/dist/file/link-parser.js +59 -0
  32. package/dist/file/link-parser.js.map +1 -1
  33. package/dist/string/filename-utils.d.ts +46 -0
  34. package/dist/string/filename-utils.d.ts.map +1 -0
  35. package/dist/string/filename-utils.js +65 -0
  36. package/dist/string/filename-utils.js.map +1 -0
  37. package/dist/string/index.d.ts +1 -0
  38. package/dist/string/index.d.ts.map +1 -1
  39. package/dist/string/index.js +1 -0
  40. package/dist/string/index.js.map +1 -1
  41. package/package.json +2 -1
  42. package/src/core/color-utils.ts +29 -0
  43. package/src/core/css-utils.ts +64 -0
  44. package/src/core/index.ts +3 -0
  45. package/src/core/property-renderer.ts +62 -0
  46. package/src/file/file-utils.ts +67 -0
  47. package/src/file/file.ts +90 -8
  48. package/src/file/index.ts +1 -0
  49. package/src/file/link-parser.ts +71 -0
  50. package/src/string/filename-utils.ts +77 -0
  51. package/src/string/index.ts +1 -0
@@ -0,0 +1,17 @@
1
+ export declare function parseColor(color: string): {
2
+ h: number;
3
+ s: number;
4
+ l: number;
5
+ } | null;
6
+ /**
7
+ * Generates an array of evenly distributed HSL colors for visualization.
8
+ * Uses the HSL color space to create visually distinct colors by distributing
9
+ * them evenly around the color wheel.
10
+ *
11
+ * @param count - Number of colors to generate
12
+ * @param saturation - Saturation percentage (0-100), defaults to 70
13
+ * @param lightness - Lightness percentage (0-100), defaults to 60
14
+ * @returns Array of HSL color strings
15
+ */
16
+ export declare function generateColors(count: number, saturation?: number, lightness?: number): string[];
17
+ //# sourceMappingURL=color-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-utils.d.ts","sourceRoot":"","sources":["../../src/core/color-utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAMpF;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,SAAK,EAAE,SAAS,SAAK,GAAG,MAAM,EAAE,CAQvF"}
@@ -0,0 +1,29 @@
1
+ import { colord } from "colord";
2
+ export function parseColor(color) {
3
+ const parsed = colord(color);
4
+ if (!parsed.isValid()) {
5
+ return null;
6
+ }
7
+ return parsed.toHsl();
8
+ }
9
+ /**
10
+ * Generates an array of evenly distributed HSL colors for visualization.
11
+ * Uses the HSL color space to create visually distinct colors by distributing
12
+ * them evenly around the color wheel.
13
+ *
14
+ * @param count - Number of colors to generate
15
+ * @param saturation - Saturation percentage (0-100), defaults to 70
16
+ * @param lightness - Lightness percentage (0-100), defaults to 60
17
+ * @returns Array of HSL color strings
18
+ */
19
+ export function generateColors(count, saturation = 70, lightness = 60) {
20
+ if (count <= 0)
21
+ return [];
22
+ const colors = [];
23
+ for (let i = 0; i < count; i++) {
24
+ const hue = (i * 360) / count;
25
+ colors.push(`hsl(${hue}, ${saturation}%, ${lightness}%)`);
26
+ }
27
+ return colors;
28
+ }
29
+ //# sourceMappingURL=color-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-utils.js","sourceRoot":"","sources":["../../src/core/color-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,UAAU,UAAU,CAAC,KAAa;IACvC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;AACvB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,UAAU,GAAG,EAAE,EAAE,SAAS,GAAG,EAAE;IAC5E,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IAC1B,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,OAAO,GAAG,KAAK,UAAU,MAAM,SAAS,IAAI,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import { colord } from \"colord\";\n\nexport function parseColor(color: string): { h: number; s: number; l: number } | null {\n\tconst parsed = colord(color);\n\tif (!parsed.isValid()) {\n\t\treturn null;\n\t}\n\treturn parsed.toHsl();\n}\n\n/**\n * Generates an array of evenly distributed HSL colors for visualization.\n * Uses the HSL color space to create visually distinct colors by distributing\n * them evenly around the color wheel.\n *\n * @param count - Number of colors to generate\n * @param saturation - Saturation percentage (0-100), defaults to 70\n * @param lightness - Lightness percentage (0-100), defaults to 60\n * @returns Array of HSL color strings\n */\nexport function generateColors(count: number, saturation = 70, lightness = 60): string[] {\n\tif (count <= 0) return [];\n\tconst colors: string[] = [];\n\tfor (let i = 0; i < count; i++) {\n\t\tconst hue = (i * 360) / count;\n\t\tcolors.push(`hsl(${hue}, ${saturation}%, ${lightness}%)`);\n\t}\n\treturn colors;\n}\n"]}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Prefixes class names with the standard plugin prefix.
3
+ * Handles multiple class names and automatically adds the prefix.
4
+ *
5
+ * @example
6
+ * cls("calendar-view") => "prisma-calendar-view"
7
+ * cls("button", "active") => "prisma-button prisma-active"
8
+ * cls("modal calendar") => "prisma-modal prisma-calendar"
9
+ */
10
+ export declare function cls(...classNames: string[]): string;
11
+ /**
12
+ * Adds prefixed class names to an element.
13
+ *
14
+ * @example
15
+ * addCls(element, "active", "selected")
16
+ */
17
+ export declare function addCls(element: HTMLElement, ...classNames: string[]): void;
18
+ /**
19
+ * Removes prefixed class names from an element.
20
+ *
21
+ * @example
22
+ * removeCls(element, "active", "selected")
23
+ */
24
+ export declare function removeCls(element: HTMLElement, ...classNames: string[]): void;
25
+ /**
26
+ * Toggles prefixed class names on an element.
27
+ *
28
+ * @example
29
+ * toggleCls(element, "active")
30
+ */
31
+ export declare function toggleCls(element: HTMLElement, className: string, force?: boolean): boolean;
32
+ /**
33
+ * Checks if element has a prefixed class.
34
+ *
35
+ * @example
36
+ * hasCls(element, "active")
37
+ */
38
+ export declare function hasCls(element: HTMLElement, className: string): boolean;
39
+ //# sourceMappingURL=css-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-utils.d.ts","sourceRoot":"","sources":["../../src/core/css-utils.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,GAAG,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,CAMnD;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,CAK1E;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,CAK7E;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAE3F;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAEvE"}
@@ -0,0 +1,60 @@
1
+ const CSS_PREFIX = "prisma-";
2
+ /**
3
+ * Prefixes class names with the standard plugin prefix.
4
+ * Handles multiple class names and automatically adds the prefix.
5
+ *
6
+ * @example
7
+ * cls("calendar-view") => "prisma-calendar-view"
8
+ * cls("button", "active") => "prisma-button prisma-active"
9
+ * cls("modal calendar") => "prisma-modal prisma-calendar"
10
+ */
11
+ export function cls(...classNames) {
12
+ return classNames
13
+ .flatMap((name) => name.split(/\s+/))
14
+ .filter((name) => name.length > 0)
15
+ .map((name) => `${CSS_PREFIX}${name}`)
16
+ .join(" ");
17
+ }
18
+ /**
19
+ * Adds prefixed class names to an element.
20
+ *
21
+ * @example
22
+ * addCls(element, "active", "selected")
23
+ */
24
+ export function addCls(element, ...classNames) {
25
+ const classes = cls(...classNames);
26
+ if (classes) {
27
+ element.classList.add(...classes.split(/\s+/));
28
+ }
29
+ }
30
+ /**
31
+ * Removes prefixed class names from an element.
32
+ *
33
+ * @example
34
+ * removeCls(element, "active", "selected")
35
+ */
36
+ export function removeCls(element, ...classNames) {
37
+ const classes = cls(...classNames);
38
+ if (classes) {
39
+ element.classList.remove(...classes.split(/\s+/));
40
+ }
41
+ }
42
+ /**
43
+ * Toggles prefixed class names on an element.
44
+ *
45
+ * @example
46
+ * toggleCls(element, "active")
47
+ */
48
+ export function toggleCls(element, className, force) {
49
+ return element.classList.toggle(cls(className), force);
50
+ }
51
+ /**
52
+ * Checks if element has a prefixed class.
53
+ *
54
+ * @example
55
+ * hasCls(element, "active")
56
+ */
57
+ export function hasCls(element, className) {
58
+ return element.classList.contains(cls(className));
59
+ }
60
+ //# sourceMappingURL=css-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-utils.js","sourceRoot":"","sources":["../../src/core/css-utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,SAAS,CAAC;AAE7B;;;;;;;;GAQG;AACH,MAAM,UAAU,GAAG,CAAC,GAAG,UAAoB;IAC1C,OAAO,UAAU;SACf,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACpC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;SACjC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,UAAU,GAAG,IAAI,EAAE,CAAC;SACrC,IAAI,CAAC,GAAG,CAAC,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,OAAoB,EAAE,GAAG,UAAoB;IACnE,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC;IACnC,IAAI,OAAO,EAAE,CAAC;QACb,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAChD,CAAC;AACF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,OAAoB,EAAE,GAAG,UAAoB;IACtE,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC;IACnC,IAAI,OAAO,EAAE,CAAC;QACb,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IACnD,CAAC;AACF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,OAAoB,EAAE,SAAiB,EAAE,KAAe;IACjF,OAAO,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,OAAoB,EAAE,SAAiB;IAC7D,OAAO,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;AACnD,CAAC","sourcesContent":["const CSS_PREFIX = \"prisma-\";\n\n/**\n * Prefixes class names with the standard plugin prefix.\n * Handles multiple class names and automatically adds the prefix.\n *\n * @example\n * cls(\"calendar-view\") => \"prisma-calendar-view\"\n * cls(\"button\", \"active\") => \"prisma-button prisma-active\"\n * cls(\"modal calendar\") => \"prisma-modal prisma-calendar\"\n */\nexport function cls(...classNames: string[]): string {\n\treturn classNames\n\t\t.flatMap((name) => name.split(/\\s+/))\n\t\t.filter((name) => name.length > 0)\n\t\t.map((name) => `${CSS_PREFIX}${name}`)\n\t\t.join(\" \");\n}\n\n/**\n * Adds prefixed class names to an element.\n *\n * @example\n * addCls(element, \"active\", \"selected\")\n */\nexport function addCls(element: HTMLElement, ...classNames: string[]): void {\n\tconst classes = cls(...classNames);\n\tif (classes) {\n\t\telement.classList.add(...classes.split(/\\s+/));\n\t}\n}\n\n/**\n * Removes prefixed class names from an element.\n *\n * @example\n * removeCls(element, \"active\", \"selected\")\n */\nexport function removeCls(element: HTMLElement, ...classNames: string[]): void {\n\tconst classes = cls(...classNames);\n\tif (classes) {\n\t\telement.classList.remove(...classes.split(/\\s+/));\n\t}\n}\n\n/**\n * Toggles prefixed class names on an element.\n *\n * @example\n * toggleCls(element, \"active\")\n */\nexport function toggleCls(element: HTMLElement, className: string, force?: boolean): boolean {\n\treturn element.classList.toggle(cls(className), force);\n}\n\n/**\n * Checks if element has a prefixed class.\n *\n * @example\n * hasCls(element, \"active\")\n */\nexport function hasCls(element: HTMLElement, className: string): boolean {\n\treturn element.classList.contains(cls(className));\n}\n"]}
@@ -1,6 +1,9 @@
1
+ export * from "./color-utils";
2
+ export * from "./css-utils";
1
3
  export * from "./evaluator";
2
4
  export * from "./expression-utils";
3
5
  export * from "./frontmatter-value";
4
6
  export * from "./generate";
7
+ export * from "./property-renderer";
5
8
  export * from "./validation";
6
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC"}
@@ -1,6 +1,9 @@
1
+ export * from "./color-utils";
2
+ export * from "./css-utils";
1
3
  export * from "./evaluator";
2
4
  export * from "./expression-utils";
3
5
  export * from "./frontmatter-value";
4
6
  export * from "./generate";
7
+ export * from "./property-renderer";
5
8
  export * from "./validation";
6
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC","sourcesContent":["export * from \"./evaluator\";\nexport * from \"./expression-utils\";\nexport * from \"./frontmatter-value\";\nexport * from \"./generate\";\nexport * from \"./validation\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC","sourcesContent":["export * from \"./color-utils\";\nexport * from \"./css-utils\";\nexport * from \"./evaluator\";\nexport * from \"./expression-utils\";\nexport * from \"./frontmatter-value\";\nexport * from \"./generate\";\nexport * from \"./property-renderer\";\nexport * from \"./validation\";\n"]}
@@ -0,0 +1,9 @@
1
+ export interface PropertyRendererConfig {
2
+ createLink: (text: string, path: string, isObsidianLink: boolean) => HTMLElement;
3
+ createText: (text: string) => HTMLElement | Text;
4
+ createSeparator?: () => HTMLElement | Text;
5
+ }
6
+ export declare function renderPropertyValue(container: HTMLElement, value: any, config: PropertyRendererConfig): void;
7
+ export declare function createTextNode(text: string): Text;
8
+ export declare function createDefaultSeparator(): Text;
9
+ //# sourceMappingURL=property-renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property-renderer.d.ts","sourceRoot":"","sources":["../../src/core/property-renderer.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,sBAAsB;IACtC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,KAAK,WAAW,CAAC;IACjF,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,WAAW,GAAG,IAAI,CAAC;IACjD,eAAe,CAAC,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;CAC3C;AAED,wBAAgB,mBAAmB,CAClC,SAAS,EAAE,WAAW,EACtB,KAAK,EAAE,GAAG,EACV,MAAM,EAAE,sBAAsB,GAC5B,IAAI,CAqBN;AAsBD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEjD;AAED,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
@@ -0,0 +1,42 @@
1
+ import { getObsidianLinkAlias, getObsidianLinkPath, isObsidianLink } from "../file/link-parser";
2
+ export function renderPropertyValue(container, value, config) {
3
+ // Handle arrays - render each item separately
4
+ if (Array.isArray(value)) {
5
+ const hasClickableLinks = value.some(isObsidianLink);
6
+ if (hasClickableLinks) {
7
+ for (let index = 0; index < value.length; index++) {
8
+ if (index > 0 && config.createSeparator) {
9
+ container.appendChild(config.createSeparator());
10
+ }
11
+ renderSingleValue(container, value[index], config);
12
+ }
13
+ }
14
+ else {
15
+ // Plain array - just join with commas
16
+ const textNode = config.createText(value.join(", "));
17
+ container.appendChild(textNode);
18
+ }
19
+ return;
20
+ }
21
+ renderSingleValue(container, value, config);
22
+ }
23
+ function renderSingleValue(container, value, config) {
24
+ const stringValue = String(value).trim();
25
+ if (isObsidianLink(stringValue)) {
26
+ const displayText = getObsidianLinkAlias(stringValue);
27
+ const linkPath = getObsidianLinkPath(stringValue);
28
+ const link = config.createLink(displayText, linkPath, true);
29
+ container.appendChild(link);
30
+ return;
31
+ }
32
+ // Regular text
33
+ const textNode = config.createText(stringValue);
34
+ container.appendChild(textNode);
35
+ }
36
+ export function createTextNode(text) {
37
+ return document.createTextNode(text);
38
+ }
39
+ export function createDefaultSeparator() {
40
+ return document.createTextNode(", ");
41
+ }
42
+ //# sourceMappingURL=property-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property-renderer.js","sourceRoot":"","sources":["../../src/core/property-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAQhG,MAAM,UAAU,mBAAmB,CAClC,SAAsB,EACtB,KAAU,EACV,MAA8B;IAE9B,8CAA8C;IAC9C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAErD,IAAI,iBAAiB,EAAE,CAAC;YACvB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;gBACnD,IAAI,KAAK,GAAG,CAAC,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;oBACzC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC;gBACjD,CAAC;gBACD,iBAAiB,CAAC,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;YACpD,CAAC;QACF,CAAC;aAAM,CAAC;YACP,sCAAsC;YACtC,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACrD,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;QACD,OAAO;IACR,CAAC;IAED,iBAAiB,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,iBAAiB,CACzB,SAAsB,EACtB,KAAU,EACV,MAA8B;IAE9B,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IAEzC,IAAI,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC;QACjC,MAAM,WAAW,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;QACtD,MAAM,QAAQ,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC;QAClD,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC5D,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAC5B,OAAO;IACR,CAAC;IAED,eAAe;IACf,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAChD,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAY;IAC1C,OAAO,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,sBAAsB;IACrC,OAAO,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import { getObsidianLinkAlias, getObsidianLinkPath, isObsidianLink } from \"../file/link-parser\";\n\nexport interface PropertyRendererConfig {\n\tcreateLink: (text: string, path: string, isObsidianLink: boolean) => HTMLElement;\n\tcreateText: (text: string) => HTMLElement | Text;\n\tcreateSeparator?: () => HTMLElement | Text;\n}\n\nexport function renderPropertyValue(\n\tcontainer: HTMLElement,\n\tvalue: any,\n\tconfig: PropertyRendererConfig\n): void {\n\t// Handle arrays - render each item separately\n\tif (Array.isArray(value)) {\n\t\tconst hasClickableLinks = value.some(isObsidianLink);\n\n\t\tif (hasClickableLinks) {\n\t\t\tfor (let index = 0; index < value.length; index++) {\n\t\t\t\tif (index > 0 && config.createSeparator) {\n\t\t\t\t\tcontainer.appendChild(config.createSeparator());\n\t\t\t\t}\n\t\t\t\trenderSingleValue(container, value[index], config);\n\t\t\t}\n\t\t} else {\n\t\t\t// Plain array - just join with commas\n\t\t\tconst textNode = config.createText(value.join(\", \"));\n\t\t\tcontainer.appendChild(textNode);\n\t\t}\n\t\treturn;\n\t}\n\n\trenderSingleValue(container, value, config);\n}\n\nfunction renderSingleValue(\n\tcontainer: HTMLElement,\n\tvalue: any,\n\tconfig: PropertyRendererConfig\n): void {\n\tconst stringValue = String(value).trim();\n\n\tif (isObsidianLink(stringValue)) {\n\t\tconst displayText = getObsidianLinkAlias(stringValue);\n\t\tconst linkPath = getObsidianLinkPath(stringValue);\n\t\tconst link = config.createLink(displayText, linkPath, true);\n\t\tcontainer.appendChild(link);\n\t\treturn;\n\t}\n\n\t// Regular text\n\tconst textNode = config.createText(stringValue);\n\tcontainer.appendChild(textNode);\n}\n\nexport function createTextNode(text: string): Text {\n\treturn document.createTextNode(text);\n}\n\nexport function createDefaultSeparator(): Text {\n\treturn document.createTextNode(\", \");\n}\n"]}
@@ -0,0 +1,28 @@
1
+ import type { App } from "obsidian";
2
+ import { TFile } from "obsidian";
3
+ /**
4
+ * Gets a TFile by path or throws an error if not found.
5
+ * Useful when you need to ensure a file exists before proceeding.
6
+ */
7
+ export declare const getTFileOrThrow: (app: App, path: string) => TFile;
8
+ /**
9
+ * Executes an operation on a file's frontmatter.
10
+ * Wrapper around Obsidian's processFrontMatter for more concise usage.
11
+ */
12
+ export declare const withFrontmatter: (app: App, file: TFile, update: (fm: Record<string, unknown>) => void) => Promise<void>;
13
+ /**
14
+ * Creates a backup copy of a file's frontmatter.
15
+ * Useful for undo/redo operations or temporary modifications.
16
+ */
17
+ export declare const backupFrontmatter: (app: App, file: TFile) => Promise<Record<string, unknown>>;
18
+ /**
19
+ * Restores a file's frontmatter from a backup.
20
+ * Clears existing frontmatter and replaces with the backup.
21
+ */
22
+ export declare const restoreFrontmatter: (app: App, file: TFile, original: Record<string, unknown>) => Promise<void>;
23
+ /**
24
+ * Extracts the content that appears after the frontmatter section.
25
+ * Returns the entire content if no frontmatter is found.
26
+ */
27
+ export declare const extractContentAfterFrontmatter: (fullContent: string) => string;
28
+ //# sourceMappingURL=file-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-utils.d.ts","sourceRoot":"","sources":["../../src/file/file-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,GAAG,EAAE,MAAM,MAAM,KAAG,KAIxD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAC3B,KAAK,GAAG,EACR,MAAM,KAAK,EACX,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,kBACO,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAU,KAAK,GAAG,EAAE,MAAM,KAAK,qCAM5D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAC9B,KAAK,GAAG,EACR,MAAM,KAAK,EACX,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,kBAO/B,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,8BAA8B,GAAI,aAAa,MAAM,KAAG,MAWpE,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { __awaiter } from "tslib";
2
+ import { TFile } from "obsidian";
3
+ /**
4
+ * Gets a TFile by path or throws an error if not found.
5
+ * Useful when you need to ensure a file exists before proceeding.
6
+ */
7
+ export const getTFileOrThrow = (app, path) => {
8
+ const f = app.vault.getAbstractFileByPath(path);
9
+ if (!(f instanceof TFile))
10
+ throw new Error(`File not found: ${path}`);
11
+ return f;
12
+ };
13
+ /**
14
+ * Executes an operation on a file's frontmatter.
15
+ * Wrapper around Obsidian's processFrontMatter for more concise usage.
16
+ */
17
+ export const withFrontmatter = (app, file, update) => __awaiter(void 0, void 0, void 0, function* () { return app.fileManager.processFrontMatter(file, update); });
18
+ /**
19
+ * Creates a backup copy of a file's frontmatter.
20
+ * Useful for undo/redo operations or temporary modifications.
21
+ */
22
+ export const backupFrontmatter = (app, file) => __awaiter(void 0, void 0, void 0, function* () {
23
+ let copy = {};
24
+ yield withFrontmatter(app, file, (fm) => {
25
+ copy = Object.assign({}, fm);
26
+ });
27
+ return copy;
28
+ });
29
+ /**
30
+ * Restores a file's frontmatter from a backup.
31
+ * Clears existing frontmatter and replaces with the backup.
32
+ */
33
+ export const restoreFrontmatter = (app, file, original) => __awaiter(void 0, void 0, void 0, function* () {
34
+ return withFrontmatter(app, file, (fm) => {
35
+ for (const k of Object.keys(fm)) {
36
+ delete fm[k];
37
+ }
38
+ Object.assign(fm, original);
39
+ });
40
+ });
41
+ /**
42
+ * Extracts the content that appears after the frontmatter section.
43
+ * Returns the entire content if no frontmatter is found.
44
+ */
45
+ export const extractContentAfterFrontmatter = (fullContent) => {
46
+ const frontmatterRegex = /^---\s*\n([\s\S]*?)\n---\s*\n/;
47
+ const match = fullContent.match(frontmatterRegex);
48
+ if (match) {
49
+ // Return content after frontmatter
50
+ return fullContent.substring(match.index + match[0].length);
51
+ }
52
+ // If no frontmatter found, return the entire content
53
+ return fullContent;
54
+ };
55
+ //# sourceMappingURL=file-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-utils.js","sourceRoot":"","sources":["../../src/file/file-utils.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAQ,EAAE,IAAY,EAAS,EAAE;IAChE,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAChD,IAAI,CAAC,CAAC,CAAC,YAAY,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,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AAC,SAAS,CAAC,KAAK,CAAC,KAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC9D,CAAC;IAED,qDAAqD;IACrD,OAAO,WAAW,CAAC;AACpB,CAAC,CAAC","sourcesContent":["import type { App } from \"obsidian\";\nimport { TFile } from \"obsidian\";\n\n/**\n * Gets a TFile by path or throws an error if not found.\n * Useful when you need to ensure a file exists before proceeding.\n */\nexport const getTFileOrThrow = (app: App, path: string): TFile => {\n\tconst f = app.vault.getAbstractFileByPath(path);\n\tif (!(f instanceof TFile)) throw new Error(`File not found: ${path}`);\n\treturn f;\n};\n\n/**\n * Executes an operation on a file's frontmatter.\n * Wrapper around Obsidian's processFrontMatter for more concise usage.\n */\nexport const withFrontmatter = async (\n\tapp: App,\n\tfile: TFile,\n\tupdate: (fm: Record<string, unknown>) => void\n) => app.fileManager.processFrontMatter(file, update);\n\n/**\n * Creates a backup copy of a file's frontmatter.\n * Useful for undo/redo operations or temporary modifications.\n */\nexport const backupFrontmatter = async (app: App, file: TFile) => {\n\tlet copy: Record<string, unknown> = {};\n\tawait withFrontmatter(app, file, (fm) => {\n\t\tcopy = { ...fm };\n\t});\n\treturn copy;\n};\n\n/**\n * Restores a file's frontmatter from a backup.\n * Clears existing frontmatter and replaces with the backup.\n */\nexport const restoreFrontmatter = async (\n\tapp: App,\n\tfile: TFile,\n\toriginal: Record<string, unknown>\n) =>\n\twithFrontmatter(app, file, (fm) => {\n\t\tfor (const k of Object.keys(fm)) {\n\t\t\tdelete fm[k];\n\t\t}\n\t\tObject.assign(fm, original);\n\t});\n\n/**\n * Extracts the content that appears after the frontmatter section.\n * Returns the entire content if no frontmatter is found.\n */\nexport const extractContentAfterFrontmatter = (fullContent: string): string => {\n\tconst frontmatterRegex = /^---\\s*\\n([\\s\\S]*?)\\n---\\s*\\n/;\n\tconst match = fullContent.match(frontmatterRegex);\n\n\tif (match) {\n\t\t// Return content after frontmatter\n\t\treturn fullContent.substring(match.index! + match[0].length);\n\t}\n\n\t// If no frontmatter found, return the entire content\n\treturn fullContent;\n};\n"]}
@@ -257,7 +257,57 @@ export declare function getChildrenByFolder(app: App, filePath: string): string[
257
257
  * ```
258
258
  */
259
259
  export declare function findRootNodesInFolder(app: App, folderPath: string): string[];
260
- export declare const sanitizeForFilename: (input: string) => string;
260
+ export interface SanitizeFilenameOptions {
261
+ /**
262
+ * Style of sanitization to apply.
263
+ * - "kebab": Convert to lowercase, replace spaces with hyphens (default, backwards compatible)
264
+ * - "preserve": Preserve spaces and case, only remove invalid characters
265
+ */
266
+ style?: "kebab" | "preserve";
267
+ }
268
+ /**
269
+ * Sanitizes a string for use as a filename.
270
+ * Defaults to kebab-case style for backwards compatibility.
271
+ *
272
+ * @param input - String to sanitize
273
+ * @param options - Sanitization options
274
+ * @returns Sanitized filename string
275
+ *
276
+ * @example
277
+ * // Default kebab-case style (backwards compatible)
278
+ * sanitizeForFilename("My File Name") // "my-file-name"
279
+ *
280
+ * // Preserve spaces and case
281
+ * sanitizeForFilename("My File Name", { style: "preserve" }) // "My File Name"
282
+ */
283
+ export declare const sanitizeForFilename: (input: string, options?: SanitizeFilenameOptions) => string;
284
+ /**
285
+ * Sanitizes filename using kebab-case style.
286
+ * - Removes invalid characters
287
+ * - Converts to lowercase
288
+ * - Replaces spaces with hyphens
289
+ *
290
+ * Best for: CLI tools, URLs, slugs, technical files
291
+ *
292
+ * @example
293
+ * sanitizeFilenameKebabCase("My File Name") // "my-file-name"
294
+ * sanitizeFilenameKebabCase("Travel Around The World") // "travel-around-the-world"
295
+ */
296
+ export declare const sanitizeFilenameKebabCase: (input: string) => string;
297
+ /**
298
+ * Sanitizes filename while preserving spaces and case.
299
+ * - Removes invalid characters only
300
+ * - Preserves spaces and original casing
301
+ * - Removes trailing dots (Windows compatibility)
302
+ *
303
+ * Best for: Note titles, human-readable filenames, Obsidian notes
304
+ *
305
+ * @example
306
+ * sanitizeFilenamePreserveSpaces("My File Name") // "My File Name"
307
+ * sanitizeFilenamePreserveSpaces("Travel Around The World") // "Travel Around The World"
308
+ * sanitizeFilenamePreserveSpaces("File<Invalid>Chars") // "FileInvalidChars"
309
+ */
310
+ export declare const sanitizeFilenamePreserveSpaces: (input: string) => string;
261
311
  export declare const getFilenameFromPath: (filePath: string) => string;
262
312
  export declare const isFileInConfiguredDirectory: (filePath: string, directory: string) => boolean;
263
313
  //# sourceMappingURL=file.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/file/file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAiB,KAAK,EAAE,MAAM,UAAU,CAAC;AAMhD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CActE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5D;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAoCxD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAuBrD;AAMD,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;IAC7C,KAAK,EAAE,cAAc,GAAG,IAAI,CAAC;CAC7B;AAED;;;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AG,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAe3E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAoDxE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAE5E;AAMD,MAAM,WAAW,uBAAuB;IACvC;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;CAC7B;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mBAAmB,GAC/B,OAAO,MAAM,EACb,UAAS,uBAA4B,KACnC,MASF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB,GAAI,OAAO,MAAM,KAAG,MAczD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,8BAA8B,GAAI,OAAO,MAAM,KAAG,MAU9D,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,UAAU,MAAM,KAAG,MAEtD,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,UAAU,MAAM,EAAE,WAAW,MAAM,KAAG,OAGjF,CAAC"}
package/dist/file/file.js CHANGED
@@ -445,16 +445,75 @@ export function getChildrenByFolder(app, filePath) {
445
445
  export function findRootNodesInFolder(app, folderPath) {
446
446
  return getFilesInFolder(app, folderPath).map((file) => file.path);
447
447
  }
448
- // ============================================================================
449
- // Legacy Utility Functions (kept for backwards compatibility)
450
- // ============================================================================
451
- export const sanitizeForFilename = (input) => {
452
- return input
453
- .replace(/[<>:"/\\|?*]/g, "") // Remove invalid filename characters
454
- .replace(/\s+/g, "-") // Replace spaces with hyphens
455
- .replace(/-+/g, "-") // Replace multiple hyphens with single
456
- .replace(/^-|-$/g, "") // Remove leading/trailing hyphens
457
- .toLowerCase();
448
+ /**
449
+ * Sanitizes a string for use as a filename.
450
+ * Defaults to kebab-case style for backwards compatibility.
451
+ *
452
+ * @param input - String to sanitize
453
+ * @param options - Sanitization options
454
+ * @returns Sanitized filename string
455
+ *
456
+ * @example
457
+ * // Default kebab-case style (backwards compatible)
458
+ * sanitizeForFilename("My File Name") // "my-file-name"
459
+ *
460
+ * // Preserve spaces and case
461
+ * sanitizeForFilename("My File Name", { style: "preserve" }) // "My File Name"
462
+ */
463
+ export const sanitizeForFilename = (input, options = {}) => {
464
+ const { style = "kebab" } = options;
465
+ if (style === "preserve") {
466
+ return sanitizeFilenamePreserveSpaces(input);
467
+ }
468
+ // Default: kebab-case style (legacy behavior)
469
+ return sanitizeFilenameKebabCase(input);
470
+ };
471
+ /**
472
+ * Sanitizes filename using kebab-case style.
473
+ * - Removes invalid characters
474
+ * - Converts to lowercase
475
+ * - Replaces spaces with hyphens
476
+ *
477
+ * Best for: CLI tools, URLs, slugs, technical files
478
+ *
479
+ * @example
480
+ * sanitizeFilenameKebabCase("My File Name") // "my-file-name"
481
+ * sanitizeFilenameKebabCase("Travel Around The World") // "travel-around-the-world"
482
+ */
483
+ export const sanitizeFilenameKebabCase = (input) => {
484
+ return (input
485
+ // Remove invalid filename characters
486
+ .replace(/[<>:"/\\|?*]/g, "")
487
+ // Replace spaces with hyphens
488
+ .replace(/\s+/g, "-")
489
+ // Replace multiple hyphens with single
490
+ .replace(/-+/g, "-")
491
+ // Remove leading/trailing hyphens
492
+ .replace(/^-|-$/g, "")
493
+ // Convert to lowercase
494
+ .toLowerCase());
495
+ };
496
+ /**
497
+ * Sanitizes filename while preserving spaces and case.
498
+ * - Removes invalid characters only
499
+ * - Preserves spaces and original casing
500
+ * - Removes trailing dots (Windows compatibility)
501
+ *
502
+ * Best for: Note titles, human-readable filenames, Obsidian notes
503
+ *
504
+ * @example
505
+ * sanitizeFilenamePreserveSpaces("My File Name") // "My File Name"
506
+ * sanitizeFilenamePreserveSpaces("Travel Around The World") // "Travel Around The World"
507
+ * sanitizeFilenamePreserveSpaces("File<Invalid>Chars") // "FileInvalidChars"
508
+ */
509
+ export const sanitizeFilenamePreserveSpaces = (input) => {
510
+ return (input
511
+ // Remove invalid filename characters (cross-platform compatibility)
512
+ .replace(/[<>:"/\\|?*]/g, "")
513
+ // Remove trailing dots (invalid on Windows)
514
+ .replace(/\.+$/g, "")
515
+ // Remove leading/trailing whitespace
516
+ .trim());
458
517
  };
459
518
  export const getFilenameFromPath = (filePath) => {
460
519
  return filePath.split("/").pop() || "Unknown";