@contello/rich-text 8.22.0 → 8.22.2

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.cjs CHANGED
@@ -1,108 +1,74 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- createRichTextDocumentFromString: () => createRichTextDocumentFromString,
24
- isRichTextDocumentEmpty: () => isRichTextDocumentEmpty,
25
- parseRichTextDocument: () => parseRichTextDocument,
26
- richTextDocumentToString: () => richTextDocumentToString,
27
- richTextNodeToString: () => richTextNodeToString,
28
- richTextNodesToString: () => richTextNodesToString
29
- });
30
- module.exports = __toCommonJS(index_exports);
31
-
32
- // src/helpers.ts
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/helpers.ts
3
+ /** Converts a single rich text node to its plain text representation. */
33
4
  function richTextNodeToString(node) {
34
- if (node.type === "text") {
35
- return node.text;
36
- }
37
- switch (node.type) {
38
- case "heading":
39
- case "paragraph":
40
- case "codeBlock":
41
- case "blockquote":
42
- return (node.content ?? []).map(richTextNodeToString).join("");
43
- case "bulletList":
44
- case "orderedList":
45
- return (node.content ?? []).map((item) => (item.content ?? []).map(richTextNodeToString).join("")).join("");
46
- case "listItem":
47
- return (node.content ?? []).map(richTextNodeToString).join("");
48
- case "horizontalRule":
49
- return "---";
50
- case "hardBreak":
51
- return "\n";
52
- case "table":
53
- return (node.content ?? []).map(
54
- (row) => (row.content ?? []).map((cell) => (cell.content ?? []).map(richTextNodeToString).join("")).join(" | ")
55
- ).join("\n");
56
- case "tableRow":
57
- return (node.content ?? []).map((cell) => (cell.content ?? []).map(richTextNodeToString).join("")).join(" | ");
58
- case "tableCell":
59
- return (node.content ?? []).map(richTextNodeToString).join("");
60
- case "tableHeader":
61
- return (node.content ?? []).map(richTextNodeToString).join("");
62
- }
5
+ if (node.type === "text") return node.text;
6
+ switch (node.type) {
7
+ case "heading":
8
+ case "paragraph":
9
+ case "codeBlock":
10
+ case "blockquote": return (node.content ?? []).map((node) => richTextNodeToString(node)).join("");
11
+ case "bulletList":
12
+ case "orderedList": return (node.content ?? []).map((item) => (item.content ?? []).map((node) => richTextNodeToString(node)).join("")).join("");
13
+ case "listItem": return (node.content ?? []).map((node) => richTextNodeToString(node)).join("");
14
+ case "horizontalRule": return "---";
15
+ case "hardBreak": return "\n";
16
+ case "table": return (node.content ?? []).map((row) => (row.content ?? []).map((cell) => (cell.content ?? []).map((node) => richTextNodeToString(node)).join("")).join(" | ")).join("\n");
17
+ case "tableRow": return (node.content ?? []).map((cell) => (cell.content ?? []).map((node) => richTextNodeToString(node)).join("")).join(" | ");
18
+ case "tableCell": return (node.content ?? []).map((node) => richTextNodeToString(node)).join("");
19
+ case "tableHeader": return (node.content ?? []).map((node) => richTextNodeToString(node)).join("");
20
+ }
63
21
  }
22
+ /** Converts an array of rich text nodes to plain text, joining them with newlines. */
64
23
  function richTextNodesToString(nodes) {
65
- return nodes.map(richTextNodeToString).join("\n");
24
+ return nodes.map((node) => richTextNodeToString(node)).join("\n");
66
25
  }
26
+ /** Converts a rich text document to its plain text representation. */
67
27
  function richTextDocumentToString(document) {
68
- return richTextNodesToString(document.content ?? []);
28
+ return richTextNodesToString(document.content ?? []);
69
29
  }
30
+ /** Returns `true` if the document has no content or only whitespace. */
70
31
  function isRichTextDocumentEmpty(document) {
71
- return (document.content ?? []).length === 0 || (document.content ?? []).every((node) => richTextNodeToString(node).trim() === "");
32
+ return (document.content ?? []).length === 0 || (document.content ?? []).every((node) => richTextNodeToString(node).trim() === "");
72
33
  }
34
+ /** Creates a rich text document containing a single paragraph with the given text. */
73
35
  function createRichTextDocumentFromString(text) {
74
- return {
75
- type: "doc",
76
- content: [
77
- {
78
- type: "paragraph",
79
- content: text ? [{ type: "text", text }] : []
80
- }
81
- ]
82
- };
36
+ return {
37
+ type: "doc",
38
+ content: [{
39
+ type: "paragraph",
40
+ content: text ? [{
41
+ type: "text",
42
+ text
43
+ }] : []
44
+ }]
45
+ };
83
46
  }
84
47
  function createEmptyRichTextDocument() {
85
- return {
86
- type: "doc",
87
- content: []
88
- };
48
+ return {
49
+ type: "doc",
50
+ content: []
51
+ };
89
52
  }
53
+ /**
54
+ * Parses a JSON string into a {@link RichTextDocument}.
55
+ * Returns an empty document if parsing fails or the input is nullish.
56
+ */
90
57
  function parseRichTextDocument(text) {
91
- if (!text) {
92
- return createEmptyRichTextDocument();
93
- }
94
- const parsed = JSON.parse(text);
95
- if (parsed.type !== "doc") {
96
- return createEmptyRichTextDocument();
97
- }
98
- return parsed;
58
+ if (!text) return createEmptyRichTextDocument();
59
+ let parsed;
60
+ try {
61
+ parsed = JSON.parse(text);
62
+ } catch {
63
+ return createEmptyRichTextDocument();
64
+ }
65
+ if (typeof parsed !== "object" || parsed === null || parsed.type !== "doc") return createEmptyRichTextDocument();
66
+ return parsed;
99
67
  }
100
- // Annotate the CommonJS export names for ESM import in node:
101
- 0 && (module.exports = {
102
- createRichTextDocumentFromString,
103
- isRichTextDocumentEmpty,
104
- parseRichTextDocument,
105
- richTextDocumentToString,
106
- richTextNodeToString,
107
- richTextNodesToString
108
- });
68
+ //#endregion
69
+ exports.createRichTextDocumentFromString = createRichTextDocumentFromString;
70
+ exports.isRichTextDocumentEmpty = isRichTextDocumentEmpty;
71
+ exports.parseRichTextDocument = parseRichTextDocument;
72
+ exports.richTextDocumentToString = richTextDocumentToString;
73
+ exports.richTextNodeToString = richTextNodeToString;
74
+ exports.richTextNodesToString = richTextNodesToString;
package/dist/index.d.cts CHANGED
@@ -1,117 +1,117 @@
1
+ //#region src/types.d.ts
1
2
  type RichTextDocument = {
2
- type: 'doc';
3
- content?: Maybe<RichTextNode[]>;
3
+ type: 'doc';
4
+ content?: Maybe<RichTextNode[]>;
4
5
  };
5
6
  type RichTextNode = RichTextHeading | RichTextParagraph | RichTextCodeBlock | RichTextBlockquote | RichTextHorizontalRule | RichTextHardBreak | RichTextBulletList | RichTextOrderedList | RichTextListItem | RichTextTable | RichTextTableRow | RichTextTableHeader | RichTextTableCell | RichTextText;
6
7
  type RichTextHeading = {
7
- type: 'heading';
8
- attrs?: Maybe<{
9
- textAlign?: Maybe<RichTextTextAlign>;
10
- level?: Maybe<1 | 2 | 3 | 4 | 5 | 6>;
11
- }>;
12
- content?: Maybe<RichTextNode[]>;
8
+ type: 'heading';
9
+ attrs?: Maybe<{
10
+ textAlign?: Maybe<RichTextTextAlign>;
11
+ level?: Maybe<1 | 2 | 3 | 4 | 5 | 6>;
12
+ }>;
13
+ content?: Maybe<RichTextNode[]>;
13
14
  };
14
15
  type RichTextParagraph = {
15
- type: 'paragraph';
16
- attrs?: Maybe<{
17
- textAlign?: Maybe<RichTextTextAlign>;
18
- }>;
19
- content?: Maybe<RichTextNode[]>;
16
+ type: 'paragraph';
17
+ attrs?: Maybe<{
18
+ textAlign?: Maybe<RichTextTextAlign>;
19
+ }>;
20
+ content?: Maybe<RichTextNode[]>;
20
21
  };
21
22
  type RichTextCodeBlock = {
22
- type: 'codeBlock';
23
- content?: Maybe<RichTextText[]>;
23
+ type: 'codeBlock';
24
+ content?: Maybe<RichTextText[]>;
24
25
  };
25
26
  type RichTextBlockquote = {
26
- type: 'blockquote';
27
- content?: Maybe<RichTextText[]>;
27
+ type: 'blockquote';
28
+ content?: Maybe<RichTextText[]>;
28
29
  };
29
30
  type RichTextBulletList = {
30
- type: 'bulletList';
31
- content?: Maybe<RichTextListItem[]>;
31
+ type: 'bulletList';
32
+ content?: Maybe<RichTextListItem[]>;
32
33
  };
33
34
  type RichTextOrderedList = {
34
- type: 'orderedList';
35
- attrs?: Maybe<{
36
- start?: Maybe<number>;
37
- }>;
38
- content?: Maybe<RichTextListItem[]>;
35
+ type: 'orderedList';
36
+ attrs?: Maybe<{
37
+ start?: Maybe<number>;
38
+ }>;
39
+ content?: Maybe<RichTextListItem[]>;
39
40
  };
40
41
  type RichTextListItem = {
41
- type: 'listItem';
42
- content?: Maybe<RichTextNode[]>;
42
+ type: 'listItem';
43
+ content?: Maybe<RichTextNode[]>;
43
44
  };
44
45
  type RichTextTable = {
45
- type: 'table';
46
- content?: Maybe<RichTextTableRow[]>;
46
+ type: 'table';
47
+ content?: Maybe<RichTextTableRow[]>;
47
48
  };
48
49
  type RichTextTableRow = {
49
- type: 'tableRow';
50
- content?: Maybe<(RichTextTableHeader | RichTextTableCell)[]>;
50
+ type: 'tableRow';
51
+ content?: Maybe<(RichTextTableHeader | RichTextTableCell)[]>;
51
52
  };
52
53
  type RichTextTableHeader = {
53
- type: 'tableHeader';
54
- attrs?: Maybe<{
55
- colspan: Maybe<number>;
56
- rowspan: Maybe<number>;
57
- colwidth: Maybe<number[]>;
58
- }>;
59
- content?: Maybe<RichTextNode[]>;
54
+ type: 'tableHeader';
55
+ attrs?: Maybe<{
56
+ colspan: Maybe<number>;
57
+ rowspan: Maybe<number>;
58
+ colwidth: Maybe<number[]>;
59
+ }>;
60
+ content?: Maybe<RichTextNode[]>;
60
61
  };
61
62
  type RichTextTableCell = {
62
- type: 'tableCell';
63
- attrs?: Maybe<{
64
- colspan: Maybe<number>;
65
- rowspan: Maybe<number>;
66
- colwidth: Maybe<number[]>;
67
- }>;
68
- content?: Maybe<RichTextNode[]>;
63
+ type: 'tableCell';
64
+ attrs?: Maybe<{
65
+ colspan: Maybe<number>;
66
+ rowspan: Maybe<number>;
67
+ colwidth: Maybe<number[]>;
68
+ }>;
69
+ content?: Maybe<RichTextNode[]>;
69
70
  };
70
71
  type RichTextHorizontalRule = {
71
- type: 'horizontalRule';
72
+ type: 'horizontalRule';
72
73
  };
73
74
  type RichTextHardBreak = {
74
- type: 'hardBreak';
75
+ type: 'hardBreak';
75
76
  };
76
77
  type RichTextText = {
77
- type: 'text';
78
- text: string;
79
- marks?: Maybe<RichTextMark[]>;
78
+ type: 'text';
79
+ text: string;
80
+ marks?: Maybe<RichTextMark[]>;
80
81
  };
81
82
  type RichTextUnderlineMark = {
82
- type: 'underline';
83
+ type: 'underline';
83
84
  };
84
85
  type RichTextBoldMark = {
85
- type: 'bold';
86
+ type: 'bold';
86
87
  };
87
88
  type RichTextItalicMark = {
88
- type: 'italic';
89
+ type: 'italic';
89
90
  };
90
91
  type RichTextCodeMark = {
91
- type: 'code';
92
+ type: 'code';
92
93
  };
93
94
  type RichTextStrikeMark = {
94
- type: 'strike';
95
+ type: 'strike';
95
96
  };
96
97
  type RichTextTextStyleMark = {
97
- type: 'textStyle';
98
- attrs?: Maybe<{
99
- color?: Maybe<string>;
100
- }>;
98
+ type: 'textStyle';
99
+ attrs?: Maybe<{
100
+ color?: Maybe<string>;
101
+ }>;
101
102
  };
102
103
  type RichTextLink<T extends Record<string, any> = Record<string, any>> = {
103
- type: 'link';
104
- attrs?: Maybe<{
105
- data?: Maybe<T>;
106
- }>;
104
+ type: 'link';
105
+ attrs?: Maybe<{
106
+ data?: Maybe<T>;
107
+ }>;
107
108
  };
108
109
  type RichTextMark = RichTextUnderlineMark | RichTextBoldMark | RichTextItalicMark | RichTextCodeMark | RichTextStrikeMark | RichTextTextStyleMark | RichTextLink;
109
110
  type RichTextTextAlign = 'left' | 'center' | 'right';
110
111
  type Maybe<T> = T | null | undefined;
111
- type DeepReadonly<T> = T extends (infer U)[] ? readonly DeepReadonly<U>[] : T extends object ? {
112
- readonly [K in keyof T]: DeepReadonly<T[K]>;
113
- } : T;
114
-
112
+ type DeepReadonly<T> = T extends (infer U)[] ? readonly DeepReadonly<U>[] : T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]> } : T;
113
+ //#endregion
114
+ //#region src/helpers.d.ts
115
115
  /** Converts a single rich text node to its plain text representation. */
116
116
  declare function richTextNodeToString(node: DeepReadonly<RichTextNode>): string;
117
117
  /** Converts an array of rich text nodes to plain text, joining them with newlines. */
@@ -122,7 +122,11 @@ declare function richTextDocumentToString(document: DeepReadonly<RichTextDocumen
122
122
  declare function isRichTextDocumentEmpty(document: DeepReadonly<RichTextDocument>): boolean;
123
123
  /** Creates a rich text document containing a single paragraph with the given text. */
124
124
  declare function createRichTextDocumentFromString(text: string | null | undefined): RichTextDocument;
125
- /** Parses a JSON string into a {@link RichTextDocument}. Returns an empty document if parsing fails or the input is nullish. */
125
+ /**
126
+ * Parses a JSON string into a {@link RichTextDocument}.
127
+ * Returns an empty document if parsing fails or the input is nullish.
128
+ */
126
129
  declare function parseRichTextDocument(text: string | null | undefined): RichTextDocument;
127
-
128
- export { type DeepReadonly, type Maybe, type RichTextBlockquote, type RichTextBoldMark, type RichTextBulletList, type RichTextCodeBlock, type RichTextCodeMark, type RichTextDocument, type RichTextHardBreak, type RichTextHeading, type RichTextHorizontalRule, type RichTextItalicMark, type RichTextLink, type RichTextListItem, type RichTextMark, type RichTextNode, type RichTextOrderedList, type RichTextParagraph, type RichTextStrikeMark, type RichTextTable, type RichTextTableCell, type RichTextTableHeader, type RichTextTableRow, type RichTextText, type RichTextTextAlign, type RichTextTextStyleMark, type RichTextUnderlineMark, createRichTextDocumentFromString, isRichTextDocumentEmpty, parseRichTextDocument, richTextDocumentToString, richTextNodeToString, richTextNodesToString };
130
+ //#endregion
131
+ export { DeepReadonly, Maybe, RichTextBlockquote, RichTextBoldMark, RichTextBulletList, RichTextCodeBlock, RichTextCodeMark, RichTextDocument, RichTextHardBreak, RichTextHeading, RichTextHorizontalRule, RichTextItalicMark, RichTextLink, RichTextListItem, RichTextMark, RichTextNode, RichTextOrderedList, RichTextParagraph, RichTextStrikeMark, RichTextTable, RichTextTableCell, RichTextTableHeader, RichTextTableRow, RichTextText, RichTextTextAlign, RichTextTextStyleMark, RichTextUnderlineMark, createRichTextDocumentFromString, isRichTextDocumentEmpty, parseRichTextDocument, richTextDocumentToString, richTextNodeToString, richTextNodesToString };
132
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/helpers.ts"],"mappings":";KACY,gBAAA;EACV,IAAA;EACA,OAAA,GAAU,KAAK,CAAC,YAAA;AAAA;AAAA,KAIN,YAAA,GACR,eAAA,GACA,iBAAA,GACA,iBAAA,GACA,kBAAA,GACA,sBAAA,GACA,iBAAA,GAEA,kBAAA,GACA,mBAAA,GACA,gBAAA,GAEA,aAAA,GACA,gBAAA,GACA,mBAAA,GACA,iBAAA,GAEA,YAAA;AAAA,KAGQ,eAAA;EACV,IAAA;EACA,KAAA,GAAQ,KAAA;IACN,SAAA,GAAY,KAAA,CAAM,iBAAA;IAClB,KAAA,GAAQ,KAAA;EAAA;EAEV,OAAA,GAAU,KAAA,CAAM,YAAA;AAAA;AAAA,KAGN,iBAAA;EACV,IAAA;EACA,KAAA,GAAQ,KAAA;IACN,SAAA,GAAY,KAAA,CAAM,iBAAA;EAAA;EAEpB,OAAA,GAAU,KAAA,CAAM,YAAA;AAAA;AAAA,KAGN,iBAAA;EACV,IAAA;EACA,OAAA,GAAU,KAAK,CAAC,YAAA;AAAA;AAAA,KAGN,kBAAA;EACV,IAAA;EACA,OAAA,GAAU,KAAK,CAAC,YAAA;AAAA;AAAA,KAIN,kBAAA;EACV,IAAA;EACA,OAAA,GAAU,KAAK,CAAC,gBAAA;AAAA;AAAA,KAGN,mBAAA;EACV,IAAA;EACA,KAAA,GAAQ,KAAA;IAAQ,KAAA,GAAQ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,kBAAA,GACA,gBAAA,GACA,kBAAA,GACA,qBAAA,GACA,YAAA;AAAA,KAEQ,iBAAA;AAAA,KAEA,KAAA,MAAW,CAAC;AAAA,KAIZ,YAAA,MAAkB,CAAA,gCACjB,YAAA,CAAa,CAAA,MACtB,CAAA,yCACyB,CAAA,GAAI,YAAA,CAAa,CAAA,CAAE,CAAA,OAC1C,CAAA;;;AAzKN;AAAA,iBCEgB,oBAAA,CAAqB,IAAA,EAAM,YAAY,CAAC,YAAA;;iBA6CxC,qBAAA,CAAsB,KAAA,WAAgB,YAAY,CAAC,YAAA;;iBAKnD,wBAAA,CAAyB,QAAA,EAAU,YAAY,CAAC,gBAAA;;iBAKhD,uBAAA,CAAwB,QAAA,EAAU,YAAY,CAAC,gBAAA;;iBAQ/C,gCAAA,CAAiC,IAAA,8BAAkC,gBAAgB;AD3DnG;;;;AAAA,iBCkFgB,qBAAA,CAAsB,IAAA,8BAAkC,gBAAgB"}
package/dist/index.d.ts CHANGED
@@ -1,117 +1,117 @@
1
+ //#region src/types.d.ts
1
2
  type RichTextDocument = {
2
- type: 'doc';
3
- content?: Maybe<RichTextNode[]>;
3
+ type: 'doc';
4
+ content?: Maybe<RichTextNode[]>;
4
5
  };
5
6
  type RichTextNode = RichTextHeading | RichTextParagraph | RichTextCodeBlock | RichTextBlockquote | RichTextHorizontalRule | RichTextHardBreak | RichTextBulletList | RichTextOrderedList | RichTextListItem | RichTextTable | RichTextTableRow | RichTextTableHeader | RichTextTableCell | RichTextText;
6
7
  type RichTextHeading = {
7
- type: 'heading';
8
- attrs?: Maybe<{
9
- textAlign?: Maybe<RichTextTextAlign>;
10
- level?: Maybe<1 | 2 | 3 | 4 | 5 | 6>;
11
- }>;
12
- content?: Maybe<RichTextNode[]>;
8
+ type: 'heading';
9
+ attrs?: Maybe<{
10
+ textAlign?: Maybe<RichTextTextAlign>;
11
+ level?: Maybe<1 | 2 | 3 | 4 | 5 | 6>;
12
+ }>;
13
+ content?: Maybe<RichTextNode[]>;
13
14
  };
14
15
  type RichTextParagraph = {
15
- type: 'paragraph';
16
- attrs?: Maybe<{
17
- textAlign?: Maybe<RichTextTextAlign>;
18
- }>;
19
- content?: Maybe<RichTextNode[]>;
16
+ type: 'paragraph';
17
+ attrs?: Maybe<{
18
+ textAlign?: Maybe<RichTextTextAlign>;
19
+ }>;
20
+ content?: Maybe<RichTextNode[]>;
20
21
  };
21
22
  type RichTextCodeBlock = {
22
- type: 'codeBlock';
23
- content?: Maybe<RichTextText[]>;
23
+ type: 'codeBlock';
24
+ content?: Maybe<RichTextText[]>;
24
25
  };
25
26
  type RichTextBlockquote = {
26
- type: 'blockquote';
27
- content?: Maybe<RichTextText[]>;
27
+ type: 'blockquote';
28
+ content?: Maybe<RichTextText[]>;
28
29
  };
29
30
  type RichTextBulletList = {
30
- type: 'bulletList';
31
- content?: Maybe<RichTextListItem[]>;
31
+ type: 'bulletList';
32
+ content?: Maybe<RichTextListItem[]>;
32
33
  };
33
34
  type RichTextOrderedList = {
34
- type: 'orderedList';
35
- attrs?: Maybe<{
36
- start?: Maybe<number>;
37
- }>;
38
- content?: Maybe<RichTextListItem[]>;
35
+ type: 'orderedList';
36
+ attrs?: Maybe<{
37
+ start?: Maybe<number>;
38
+ }>;
39
+ content?: Maybe<RichTextListItem[]>;
39
40
  };
40
41
  type RichTextListItem = {
41
- type: 'listItem';
42
- content?: Maybe<RichTextNode[]>;
42
+ type: 'listItem';
43
+ content?: Maybe<RichTextNode[]>;
43
44
  };
44
45
  type RichTextTable = {
45
- type: 'table';
46
- content?: Maybe<RichTextTableRow[]>;
46
+ type: 'table';
47
+ content?: Maybe<RichTextTableRow[]>;
47
48
  };
48
49
  type RichTextTableRow = {
49
- type: 'tableRow';
50
- content?: Maybe<(RichTextTableHeader | RichTextTableCell)[]>;
50
+ type: 'tableRow';
51
+ content?: Maybe<(RichTextTableHeader | RichTextTableCell)[]>;
51
52
  };
52
53
  type RichTextTableHeader = {
53
- type: 'tableHeader';
54
- attrs?: Maybe<{
55
- colspan: Maybe<number>;
56
- rowspan: Maybe<number>;
57
- colwidth: Maybe<number[]>;
58
- }>;
59
- content?: Maybe<RichTextNode[]>;
54
+ type: 'tableHeader';
55
+ attrs?: Maybe<{
56
+ colspan: Maybe<number>;
57
+ rowspan: Maybe<number>;
58
+ colwidth: Maybe<number[]>;
59
+ }>;
60
+ content?: Maybe<RichTextNode[]>;
60
61
  };
61
62
  type RichTextTableCell = {
62
- type: 'tableCell';
63
- attrs?: Maybe<{
64
- colspan: Maybe<number>;
65
- rowspan: Maybe<number>;
66
- colwidth: Maybe<number[]>;
67
- }>;
68
- content?: Maybe<RichTextNode[]>;
63
+ type: 'tableCell';
64
+ attrs?: Maybe<{
65
+ colspan: Maybe<number>;
66
+ rowspan: Maybe<number>;
67
+ colwidth: Maybe<number[]>;
68
+ }>;
69
+ content?: Maybe<RichTextNode[]>;
69
70
  };
70
71
  type RichTextHorizontalRule = {
71
- type: 'horizontalRule';
72
+ type: 'horizontalRule';
72
73
  };
73
74
  type RichTextHardBreak = {
74
- type: 'hardBreak';
75
+ type: 'hardBreak';
75
76
  };
76
77
  type RichTextText = {
77
- type: 'text';
78
- text: string;
79
- marks?: Maybe<RichTextMark[]>;
78
+ type: 'text';
79
+ text: string;
80
+ marks?: Maybe<RichTextMark[]>;
80
81
  };
81
82
  type RichTextUnderlineMark = {
82
- type: 'underline';
83
+ type: 'underline';
83
84
  };
84
85
  type RichTextBoldMark = {
85
- type: 'bold';
86
+ type: 'bold';
86
87
  };
87
88
  type RichTextItalicMark = {
88
- type: 'italic';
89
+ type: 'italic';
89
90
  };
90
91
  type RichTextCodeMark = {
91
- type: 'code';
92
+ type: 'code';
92
93
  };
93
94
  type RichTextStrikeMark = {
94
- type: 'strike';
95
+ type: 'strike';
95
96
  };
96
97
  type RichTextTextStyleMark = {
97
- type: 'textStyle';
98
- attrs?: Maybe<{
99
- color?: Maybe<string>;
100
- }>;
98
+ type: 'textStyle';
99
+ attrs?: Maybe<{
100
+ color?: Maybe<string>;
101
+ }>;
101
102
  };
102
103
  type RichTextLink<T extends Record<string, any> = Record<string, any>> = {
103
- type: 'link';
104
- attrs?: Maybe<{
105
- data?: Maybe<T>;
106
- }>;
104
+ type: 'link';
105
+ attrs?: Maybe<{
106
+ data?: Maybe<T>;
107
+ }>;
107
108
  };
108
109
  type RichTextMark = RichTextUnderlineMark | RichTextBoldMark | RichTextItalicMark | RichTextCodeMark | RichTextStrikeMark | RichTextTextStyleMark | RichTextLink;
109
110
  type RichTextTextAlign = 'left' | 'center' | 'right';
110
111
  type Maybe<T> = T | null | undefined;
111
- type DeepReadonly<T> = T extends (infer U)[] ? readonly DeepReadonly<U>[] : T extends object ? {
112
- readonly [K in keyof T]: DeepReadonly<T[K]>;
113
- } : T;
114
-
112
+ type DeepReadonly<T> = T extends (infer U)[] ? readonly DeepReadonly<U>[] : T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]> } : T;
113
+ //#endregion
114
+ //#region src/helpers.d.ts
115
115
  /** Converts a single rich text node to its plain text representation. */
116
116
  declare function richTextNodeToString(node: DeepReadonly<RichTextNode>): string;
117
117
  /** Converts an array of rich text nodes to plain text, joining them with newlines. */
@@ -122,7 +122,11 @@ declare function richTextDocumentToString(document: DeepReadonly<RichTextDocumen
122
122
  declare function isRichTextDocumentEmpty(document: DeepReadonly<RichTextDocument>): boolean;
123
123
  /** Creates a rich text document containing a single paragraph with the given text. */
124
124
  declare function createRichTextDocumentFromString(text: string | null | undefined): RichTextDocument;
125
- /** Parses a JSON string into a {@link RichTextDocument}. Returns an empty document if parsing fails or the input is nullish. */
125
+ /**
126
+ * Parses a JSON string into a {@link RichTextDocument}.
127
+ * Returns an empty document if parsing fails or the input is nullish.
128
+ */
126
129
  declare function parseRichTextDocument(text: string | null | undefined): RichTextDocument;
127
-
128
- export { type DeepReadonly, type Maybe, type RichTextBlockquote, type RichTextBoldMark, type RichTextBulletList, type RichTextCodeBlock, type RichTextCodeMark, type RichTextDocument, type RichTextHardBreak, type RichTextHeading, type RichTextHorizontalRule, type RichTextItalicMark, type RichTextLink, type RichTextListItem, type RichTextMark, type RichTextNode, type RichTextOrderedList, type RichTextParagraph, type RichTextStrikeMark, type RichTextTable, type RichTextTableCell, type RichTextTableHeader, type RichTextTableRow, type RichTextText, type RichTextTextAlign, type RichTextTextStyleMark, type RichTextUnderlineMark, createRichTextDocumentFromString, isRichTextDocumentEmpty, parseRichTextDocument, richTextDocumentToString, richTextNodeToString, richTextNodesToString };
130
+ //#endregion
131
+ export { DeepReadonly, Maybe, RichTextBlockquote, RichTextBoldMark, RichTextBulletList, RichTextCodeBlock, RichTextCodeMark, RichTextDocument, RichTextHardBreak, RichTextHeading, RichTextHorizontalRule, RichTextItalicMark, RichTextLink, RichTextListItem, RichTextMark, RichTextNode, RichTextOrderedList, RichTextParagraph, RichTextStrikeMark, RichTextTable, RichTextTableCell, RichTextTableHeader, RichTextTableRow, RichTextText, RichTextTextAlign, RichTextTextStyleMark, RichTextUnderlineMark, createRichTextDocumentFromString, isRichTextDocumentEmpty, parseRichTextDocument, richTextDocumentToString, richTextNodeToString, richTextNodesToString };
132
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/helpers.ts"],"mappings":";KACY,gBAAA;EACV,IAAA;EACA,OAAA,GAAU,KAAK,CAAC,YAAA;AAAA;AAAA,KAIN,YAAA,GACR,eAAA,GACA,iBAAA,GACA,iBAAA,GACA,kBAAA,GACA,sBAAA,GACA,iBAAA,GAEA,kBAAA,GACA,mBAAA,GACA,gBAAA,GAEA,aAAA,GACA,gBAAA,GACA,mBAAA,GACA,iBAAA,GAEA,YAAA;AAAA,KAGQ,eAAA;EACV,IAAA;EACA,KAAA,GAAQ,KAAA;IACN,SAAA,GAAY,KAAA,CAAM,iBAAA;IAClB,KAAA,GAAQ,KAAA;EAAA;EAEV,OAAA,GAAU,KAAA,CAAM,YAAA;AAAA;AAAA,KAGN,iBAAA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AAA,KAGM,gBAAA;EACV,IAAI;AAAA;AAAA,KAGM,kBAAA;EACV,IAAI;AAAA;AAAA,KAGM,gBAAA;EACV,IAAI;AAAA;AAAA,KAGM,kBAAA;EACV,IAAI;AAAA;AAAA,KAGM,qBAAA;EACV,IAAA;EACA,KAAA,GAAQ,KAAK;IAAG,KAAA,GAAQ,KAAA;EAAA;AAAA;AAAA,KAGd,YAAA,WAAuB,MAAA,gBAAsB,MAAA;EACvD,IAAA;EACA,KAAA,GAAQ,KAAA;IACN,IAAA,GAAO,KAAA,CAAM,CAAA;EAAA;AAAA;AAAA,KAIL,YAAA,GACR,qBAAA,GACA,gBAAA,GACA,kBAAA,GACA,gBAAA,GACA,kBAAA,GACA,qBAAA,GACA,YAAA;AAAA,KAEQ,iBAAA;AAAA,KAEA,KAAA,MAAW,CAAC;AAAA,KAIZ,YAAA,MAAkB,CAAA,gCACjB,YAAA,CAAa,CAAA,MACtB,CAAA,yCACyB,CAAA,GAAI,YAAA,CAAa,CAAA,CAAE,CAAA,OAC1C,CAAA;;;AAzKN;AAAA,iBCEgB,oBAAA,CAAqB,IAAA,EAAM,YAAY,CAAC,YAAA;;iBA6CxC,qBAAA,CAAsB,KAAA,WAAgB,YAAY,CAAC,YAAA;;iBAKnD,wBAAA,CAAyB,QAAA,EAAU,YAAY,CAAC,gBAAA;;iBAKhD,uBAAA,CAAwB,QAAA,EAAU,YAAY,CAAC,gBAAA;;iBAQ/C,gCAAA,CAAiC,IAAA,8BAAkC,gBAAgB;AD3DnG;;;;AAAA,iBCkFgB,qBAAA,CAAsB,IAAA,8BAAkC,gBAAgB"}
package/dist/index.js CHANGED
@@ -1,76 +1,70 @@
1
- // src/helpers.ts
1
+ //#region src/helpers.ts
2
+ /** Converts a single rich text node to its plain text representation. */
2
3
  function richTextNodeToString(node) {
3
- if (node.type === "text") {
4
- return node.text;
5
- }
6
- switch (node.type) {
7
- case "heading":
8
- case "paragraph":
9
- case "codeBlock":
10
- case "blockquote":
11
- return (node.content ?? []).map(richTextNodeToString).join("");
12
- case "bulletList":
13
- case "orderedList":
14
- return (node.content ?? []).map((item) => (item.content ?? []).map(richTextNodeToString).join("")).join("");
15
- case "listItem":
16
- return (node.content ?? []).map(richTextNodeToString).join("");
17
- case "horizontalRule":
18
- return "---";
19
- case "hardBreak":
20
- return "\n";
21
- case "table":
22
- return (node.content ?? []).map(
23
- (row) => (row.content ?? []).map((cell) => (cell.content ?? []).map(richTextNodeToString).join("")).join(" | ")
24
- ).join("\n");
25
- case "tableRow":
26
- return (node.content ?? []).map((cell) => (cell.content ?? []).map(richTextNodeToString).join("")).join(" | ");
27
- case "tableCell":
28
- return (node.content ?? []).map(richTextNodeToString).join("");
29
- case "tableHeader":
30
- return (node.content ?? []).map(richTextNodeToString).join("");
31
- }
4
+ if (node.type === "text") return node.text;
5
+ switch (node.type) {
6
+ case "heading":
7
+ case "paragraph":
8
+ case "codeBlock":
9
+ case "blockquote": return (node.content ?? []).map((node) => richTextNodeToString(node)).join("");
10
+ case "bulletList":
11
+ case "orderedList": return (node.content ?? []).map((item) => (item.content ?? []).map((node) => richTextNodeToString(node)).join("")).join("");
12
+ case "listItem": return (node.content ?? []).map((node) => richTextNodeToString(node)).join("");
13
+ case "horizontalRule": return "---";
14
+ case "hardBreak": return "\n";
15
+ case "table": return (node.content ?? []).map((row) => (row.content ?? []).map((cell) => (cell.content ?? []).map((node) => richTextNodeToString(node)).join("")).join(" | ")).join("\n");
16
+ case "tableRow": return (node.content ?? []).map((cell) => (cell.content ?? []).map((node) => richTextNodeToString(node)).join("")).join(" | ");
17
+ case "tableCell": return (node.content ?? []).map((node) => richTextNodeToString(node)).join("");
18
+ case "tableHeader": return (node.content ?? []).map((node) => richTextNodeToString(node)).join("");
19
+ }
32
20
  }
21
+ /** Converts an array of rich text nodes to plain text, joining them with newlines. */
33
22
  function richTextNodesToString(nodes) {
34
- return nodes.map(richTextNodeToString).join("\n");
23
+ return nodes.map((node) => richTextNodeToString(node)).join("\n");
35
24
  }
25
+ /** Converts a rich text document to its plain text representation. */
36
26
  function richTextDocumentToString(document) {
37
- return richTextNodesToString(document.content ?? []);
27
+ return richTextNodesToString(document.content ?? []);
38
28
  }
29
+ /** Returns `true` if the document has no content or only whitespace. */
39
30
  function isRichTextDocumentEmpty(document) {
40
- return (document.content ?? []).length === 0 || (document.content ?? []).every((node) => richTextNodeToString(node).trim() === "");
31
+ return (document.content ?? []).length === 0 || (document.content ?? []).every((node) => richTextNodeToString(node).trim() === "");
41
32
  }
33
+ /** Creates a rich text document containing a single paragraph with the given text. */
42
34
  function createRichTextDocumentFromString(text) {
43
- return {
44
- type: "doc",
45
- content: [
46
- {
47
- type: "paragraph",
48
- content: text ? [{ type: "text", text }] : []
49
- }
50
- ]
51
- };
35
+ return {
36
+ type: "doc",
37
+ content: [{
38
+ type: "paragraph",
39
+ content: text ? [{
40
+ type: "text",
41
+ text
42
+ }] : []
43
+ }]
44
+ };
52
45
  }
53
46
  function createEmptyRichTextDocument() {
54
- return {
55
- type: "doc",
56
- content: []
57
- };
47
+ return {
48
+ type: "doc",
49
+ content: []
50
+ };
58
51
  }
52
+ /**
53
+ * Parses a JSON string into a {@link RichTextDocument}.
54
+ * Returns an empty document if parsing fails or the input is nullish.
55
+ */
59
56
  function parseRichTextDocument(text) {
60
- if (!text) {
61
- return createEmptyRichTextDocument();
62
- }
63
- const parsed = JSON.parse(text);
64
- if (parsed.type !== "doc") {
65
- return createEmptyRichTextDocument();
66
- }
67
- return parsed;
57
+ if (!text) return createEmptyRichTextDocument();
58
+ let parsed;
59
+ try {
60
+ parsed = JSON.parse(text);
61
+ } catch {
62
+ return createEmptyRichTextDocument();
63
+ }
64
+ if (typeof parsed !== "object" || parsed === null || parsed.type !== "doc") return createEmptyRichTextDocument();
65
+ return parsed;
68
66
  }
69
- export {
70
- createRichTextDocumentFromString,
71
- isRichTextDocumentEmpty,
72
- parseRichTextDocument,
73
- richTextDocumentToString,
74
- richTextNodeToString,
75
- richTextNodesToString
76
- };
67
+ //#endregion
68
+ export { createRichTextDocumentFromString, isRichTextDocumentEmpty, parseRichTextDocument, richTextDocumentToString, richTextNodeToString, richTextNodesToString };
69
+
70
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import type { DeepReadonly, RichTextDocument, RichTextNode } from './types';\n\n/** Converts a single rich text node to its plain text representation. */\nexport function richTextNodeToString(node: DeepReadonly<RichTextNode>): string {\n if (node.type === 'text') {\n return node.text;\n }\n\n switch (node.type) {\n case 'heading':\n case 'paragraph':\n case 'codeBlock':\n case 'blockquote': {\n return (node.content ?? []).map((node) => richTextNodeToString(node)).join('');\n }\n case 'bulletList':\n case 'orderedList': {\n return (node.content ?? []).map((item) => (item.content ?? []).map((node) => richTextNodeToString(node)).join('')).join('');\n }\n case 'listItem': {\n return (node.content ?? []).map((node) => richTextNodeToString(node)).join('');\n }\n case 'horizontalRule': {\n return '---';\n }\n case 'hardBreak': {\n return '\\n';\n }\n case 'table': {\n return (node.content ?? [])\n .map((row) =>\n (row.content ?? []).map((cell) => (cell.content ?? []).map((node) => richTextNodeToString(node)).join('')).join(' | '),\n )\n .join('\\n');\n }\n case 'tableRow': {\n return (node.content ?? []).map((cell) => (cell.content ?? []).map((node) => richTextNodeToString(node)).join('')).join(' | ');\n }\n case 'tableCell': {\n return (node.content ?? []).map((node) => richTextNodeToString(node)).join('');\n }\n case 'tableHeader': {\n return (node.content ?? []).map((node) => richTextNodeToString(node)).join('');\n }\n }\n}\n\n/** Converts an array of rich text nodes to plain text, joining them with newlines. */\nexport function richTextNodesToString(nodes: readonly DeepReadonly<RichTextNode>[]): string {\n return nodes.map((node) => richTextNodeToString(node)).join('\\n');\n}\n\n/** Converts a rich text document to its plain text representation. */\nexport function richTextDocumentToString(document: DeepReadonly<RichTextDocument>): string {\n return richTextNodesToString(document.content ?? []);\n}\n\n/** Returns `true` if the document has no content or only whitespace. */\nexport function isRichTextDocumentEmpty(document: DeepReadonly<RichTextDocument>): boolean {\n return (\n (document.content ?? []).length === 0 ||\n (document.content ?? []).every((node) => richTextNodeToString(node).trim() === '')\n );\n}\n\n/** Creates a rich text document containing a single paragraph with the given text. */\nexport function createRichTextDocumentFromString(text: string | null | undefined): RichTextDocument {\n return {\n type: 'doc',\n content: [\n {\n type: 'paragraph',\n content: text ? [{ type: 'text', text }] : [],\n },\n ],\n };\n}\n\nfunction createEmptyRichTextDocument(): RichTextDocument {\n return {\n type: 'doc',\n content: [],\n };\n}\n\n/**\n * Parses a JSON string into a {@link RichTextDocument}.\n * Returns an empty document if parsing fails or the input is nullish.\n */\nexport function parseRichTextDocument(text: string | null | undefined): RichTextDocument {\n if (!text) {\n return createEmptyRichTextDocument();\n }\n\n let parsed: unknown;\n\n try {\n parsed = JSON.parse(text);\n } catch {\n return createEmptyRichTextDocument();\n }\n\n if (typeof parsed !== 'object' || parsed === null || (parsed as { type?: unknown }).type !== 'doc') {\n return createEmptyRichTextDocument();\n }\n\n return parsed as RichTextDocument;\n}\n"],"mappings":";;AAGA,SAAgB,qBAAqB,MAA0C;CAC7E,IAAI,KAAK,SAAS,QAChB,OAAO,KAAK;CAGd,QAAQ,KAAK,MAAb;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,cACH,QAAQ,KAAK,WAAW,CAAC,EAAA,CAAG,KAAK,SAAS,qBAAqB,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE;EAE/E,KAAK;EACL,KAAK,eACH,QAAQ,KAAK,WAAW,CAAC,EAAA,CAAG,KAAK,UAAU,KAAK,WAAW,CAAC,EAAA,CAAG,KAAK,SAAS,qBAAqB,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE;EAE5H,KAAK,YACH,QAAQ,KAAK,WAAW,CAAC,EAAA,CAAG,KAAK,SAAS,qBAAqB,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE;EAE/E,KAAK,kBACH,OAAO;EAET,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S,8BAAgD;CACvD,OAAO;EACL,MAAM;EACN,SAAS,CAAC;CACZ;AACF;;;;;AAMA,SAAgB,sBAAsB,MAAmD;CACvF,IAAI,CAAC,MACH,OAAO,4BAA4B;CAGrC,IAAI;CAEJ,IAAI;EACF,SAAS,KAAK,MAAM,IAAI;CAC1B,QAAQ;EACN,OAAO,4BAA4B;CACrC;CAEA,IAAI,OAAO,WAAW,YAAY,WAAW,QAAS,OAA8B,SAAS,OAC3F,OAAO,4BAA4B;CAGrC,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contello/rich-text",
3
- "version": "8.22.0",
3
+ "version": "8.22.2",
4
4
  "description": "TypeScript types and helpers for working with Contello CMS rich text documents (TipTap/ProseMirror JSON format)",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -25,8 +25,8 @@
25
25
  "registry": "https://registry.npmjs.org"
26
26
  },
27
27
  "scripts": {
28
- "build": "tsup",
29
- "lint": "eslint .",
28
+ "build": "tsdown",
29
+ "lint": "eslint . --cache",
30
30
  "lint:fix": "eslint . --fix",
31
31
  "typecheck": "tsc --noEmit"
32
32
  }