@filen/utils 0.0.3 → 0.0.4

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.
package/dist/index.js CHANGED
@@ -6,3 +6,4 @@ export * from "./types";
6
6
  export * from "./misc";
7
7
  export * from "./time";
8
8
  export * from "./checklistParser";
9
+ export * from "./notes";
package/dist/notes.js ADDED
@@ -0,0 +1,39 @@
1
+ import striptags from "striptags";
2
+ export function createNotePreviewFromContentText(type, content) {
3
+ var _a, _b, _c;
4
+ try {
5
+ if (!content || content.length === 0) {
6
+ return "";
7
+ }
8
+ if (type === "rich") {
9
+ if (content.indexOf("<p><br></p>") === -1) {
10
+ return striptags((_a = content.split("\n")[0]) !== null && _a !== void 0 ? _a : "").slice(0, 128);
11
+ }
12
+ return striptags((_b = content.split("<p><br></p>")[0]) !== null && _b !== void 0 ? _b : "").slice(0, 128);
13
+ }
14
+ if (type === "checklist") {
15
+ const ex = content
16
+ .split('<ul data-checked="false">')
17
+ .join("")
18
+ .split('<ul data-checked="true">')
19
+ .join("")
20
+ .split("\n")
21
+ .join("")
22
+ .split("<li>");
23
+ for (const listPoint of ex) {
24
+ const listPointEx = listPoint.split("</li>");
25
+ if (!listPointEx[0]) {
26
+ continue;
27
+ }
28
+ if (listPointEx[0].trim().length > 0) {
29
+ return striptags(listPointEx[0].trim()).slice(0, 128);
30
+ }
31
+ }
32
+ return "";
33
+ }
34
+ return striptags((_c = content.split("\n")[0]) !== null && _c !== void 0 ? _c : "").slice(0, 128);
35
+ }
36
+ catch (_d) {
37
+ return "";
38
+ }
39
+ }
@@ -6,3 +6,4 @@ export * from "./types";
6
6
  export * from "./misc";
7
7
  export * from "./time";
8
8
  export * from "./checklistParser";
9
+ export * from "./notes";
@@ -0,0 +1 @@
1
+ export declare function createNotePreviewFromContentText(type: "rich" | "checklist" | "other", content?: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@filen/utils",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "A collection of utils for Filen",
5
5
  "private": false,
6
6
  "repository": {
@@ -35,6 +35,7 @@
35
35
  "dependencies": {
36
36
  "clsx": "^2.1.1",
37
37
  "node-html-better-parser": "^1.5.8",
38
+ "striptags": "^3.2.0",
38
39
  "tailwind-merge": "^3.3.1",
39
40
  "uuid": "^13.0.0"
40
41
  }