@contello/rich-text 8.13.2-next.1751825927 → 8.13.2-next.1751826612
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.d.ts +149 -2
- package/dist/index.js +9 -5
- package/package.json +24 -21
- package/dist/helpers.d.ts +0 -7
- package/dist/types.d.ts +0 -110
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,149 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export declare function createRichTextDocumentFromString(text: string): RichTextDocument;
|
|
2
|
+
|
|
3
|
+
export declare function isRichTextDocumentEmpty(document: RichTextDocument): boolean;
|
|
4
|
+
|
|
5
|
+
export declare type Maybe<T> = T | null | undefined;
|
|
6
|
+
|
|
7
|
+
export declare function parseRichTextDocument(text: string): RichTextDocument;
|
|
8
|
+
|
|
9
|
+
export declare type RichTextBlockquote = {
|
|
10
|
+
type: 'blockquote';
|
|
11
|
+
content?: Maybe<RichTextText[]>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export declare type RichTextBoldMark = {
|
|
15
|
+
type: 'bold';
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export declare type RichTextBulletList = {
|
|
19
|
+
type: 'bulletList';
|
|
20
|
+
content?: Maybe<RichTextListItem[]>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export declare type RichTextCodeBlock = {
|
|
24
|
+
type: 'codeblock';
|
|
25
|
+
content?: Maybe<RichTextText[]>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export declare type RichTextCodeMark = {
|
|
29
|
+
type: 'code';
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export declare type RichTextDocument = {
|
|
33
|
+
type: 'doc';
|
|
34
|
+
content?: Maybe<RichTextNode[]>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export declare function richTextDocumentToString(document: RichTextDocument): string;
|
|
38
|
+
|
|
39
|
+
export declare type RichTextHardBreak = {
|
|
40
|
+
type: 'hardBreak';
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export declare type RichTextHeading = {
|
|
44
|
+
type: 'heading';
|
|
45
|
+
attrs?: Maybe<{
|
|
46
|
+
textAlign?: Maybe<RichTextTextAlign>;
|
|
47
|
+
level?: Maybe<1 | 2 | 3 | 4 | 5 | 6>;
|
|
48
|
+
}>;
|
|
49
|
+
content?: Maybe<RichTextNode[]>;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export declare type RichTextHorizontalRule = {
|
|
53
|
+
type: 'horizontalRule';
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export declare type RichTextItalicMark = {
|
|
57
|
+
type: 'italic';
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export declare type RichTextLink<T extends Record<string, any> = Record<string, any>> = {
|
|
61
|
+
type: 'link';
|
|
62
|
+
attrs?: Maybe<{
|
|
63
|
+
data?: Maybe<T>;
|
|
64
|
+
}>;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export declare type RichTextListItem = {
|
|
68
|
+
type: 'listItem';
|
|
69
|
+
content?: Maybe<RichTextNode[]>;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export declare type RichTextMark = RichTextUnderlineMark | RichTextBoldMark | RichTextItalicMark | RichTextCodeMark | RichTextStrikeMark | RichTextTextStyleMark | RichTextLink;
|
|
73
|
+
|
|
74
|
+
export declare type RichTextNode = RichTextHeading | RichTextParagraph | RichTextCodeBlock | RichTextBlockquote | RichTextHorizontalRule | RichTextHardBreak | RichTextBulletList | RichTextOrderedList | RichTextListItem | RichTextTable | RichTextTableRow | RichTextTableHeader | RichTextTableCell | RichTextText;
|
|
75
|
+
|
|
76
|
+
export declare function richTextNodesToString(nodes: RichTextNode[]): string;
|
|
77
|
+
|
|
78
|
+
export declare function richTextNodeToString(node: RichTextNode): string;
|
|
79
|
+
|
|
80
|
+
export declare type RichTextOrderedList = {
|
|
81
|
+
type: 'orderedList';
|
|
82
|
+
attrs?: Maybe<{
|
|
83
|
+
start?: Maybe<number>;
|
|
84
|
+
}>;
|
|
85
|
+
content?: Maybe<RichTextListItem[]>;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export declare type RichTextParagraph = {
|
|
89
|
+
type: 'paragraph';
|
|
90
|
+
attrs?: Maybe<{
|
|
91
|
+
textAlign?: Maybe<RichTextTextAlign>;
|
|
92
|
+
}>;
|
|
93
|
+
content?: Maybe<RichTextNode[]>;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export declare type RichTextStrikeMark = {
|
|
97
|
+
type: 'strike';
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export declare type RichTextTable = {
|
|
101
|
+
type: 'table';
|
|
102
|
+
content?: Maybe<RichTextTableRow[]>;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export declare type RichTextTableCell = {
|
|
106
|
+
type: 'tableCell';
|
|
107
|
+
attrs?: Maybe<{
|
|
108
|
+
colspan: Maybe<number>;
|
|
109
|
+
rowspan: Maybe<number>;
|
|
110
|
+
colwidth: Maybe<number[]>;
|
|
111
|
+
}>;
|
|
112
|
+
content?: Maybe<RichTextNode[]>;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export declare type RichTextTableHeader = {
|
|
116
|
+
type: 'tableHeader';
|
|
117
|
+
attrs?: Maybe<{
|
|
118
|
+
colspan: Maybe<number>;
|
|
119
|
+
rowspan: Maybe<number>;
|
|
120
|
+
colwidth: Maybe<number[]>;
|
|
121
|
+
}>;
|
|
122
|
+
content?: Maybe<RichTextNode[]>;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export declare type RichTextTableRow = {
|
|
126
|
+
type: 'tableRow';
|
|
127
|
+
content?: Maybe<(RichTextTableHeader | RichTextTableCell)[]>;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export declare type RichTextText = {
|
|
131
|
+
type: 'text';
|
|
132
|
+
text: string;
|
|
133
|
+
marks?: Maybe<RichTextMark[]>;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export declare type RichTextTextAlign = 'left' | 'center' | 'right';
|
|
137
|
+
|
|
138
|
+
export declare type RichTextTextStyleMark = {
|
|
139
|
+
type: 'textStyle';
|
|
140
|
+
attrs?: Maybe<{
|
|
141
|
+
color?: Maybe<string>;
|
|
142
|
+
}>;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export declare type RichTextUnderlineMark = {
|
|
146
|
+
type: 'underline';
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export { }
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,9 @@ function n(t) {
|
|
|
18
18
|
return `
|
|
19
19
|
`;
|
|
20
20
|
case "table":
|
|
21
|
-
return (t.content ?? []).map(
|
|
21
|
+
return (t.content ?? []).map(
|
|
22
|
+
(e) => (e.content ?? []).map((c) => (c.content ?? []).map(n).join("")).join(" | ")
|
|
23
|
+
).join(`
|
|
22
24
|
`);
|
|
23
25
|
case "tableRow":
|
|
24
26
|
return (t.content ?? []).map((e) => (e.content ?? []).map(n).join("")).join(" | ");
|
|
@@ -41,10 +43,12 @@ function i(t) {
|
|
|
41
43
|
function u(t) {
|
|
42
44
|
return {
|
|
43
45
|
type: "doc",
|
|
44
|
-
content: [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
content: [
|
|
47
|
+
{
|
|
48
|
+
type: "paragraph",
|
|
49
|
+
content: t ? [{ type: "text", text: t }] : []
|
|
50
|
+
}
|
|
51
|
+
]
|
|
48
52
|
};
|
|
49
53
|
}
|
|
50
54
|
function r() {
|
package/package.json
CHANGED
|
@@ -1,38 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contello/rich-text",
|
|
3
|
-
"description": "Contello
|
|
4
|
-
"
|
|
3
|
+
"description": "Contello Rich Text library",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"start": "vite build --watch",
|
|
6
|
+
"build": "rm -rf dist/ && vite build",
|
|
7
|
+
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
|
|
8
|
+
"patch": "node ci/patcher.js"
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@types/node": "^24.0.10",
|
|
12
|
+
"@typescript-eslint/eslint-plugin": "^8.35.1",
|
|
13
|
+
"eslint": "^9.30.1",
|
|
14
|
+
"eslint-config-prettier": "^10.1.5",
|
|
15
|
+
"eslint-plugin-import": "^2.32.0",
|
|
16
|
+
"eslint-plugin-prettier": "^5.5.1",
|
|
17
|
+
"npm-run-all": "^4.1.5",
|
|
18
|
+
"typescript": "^5.8.3",
|
|
19
|
+
"typescript-eslint": "^8.35.1",
|
|
20
|
+
"vite": "^7.0.2",
|
|
21
|
+
"vite-plugin-dts": "^4.5.4"
|
|
22
|
+
},
|
|
5
23
|
"author": "admin@entwico.com",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"type": "module",
|
|
6
26
|
"files": [
|
|
7
27
|
"dist"
|
|
8
28
|
],
|
|
9
|
-
"
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
10
30
|
"exports": {
|
|
11
31
|
".": {
|
|
12
32
|
"import": "./dist/index.js",
|
|
13
33
|
"require": "./dist/index.umd.cjs"
|
|
14
34
|
}
|
|
15
35
|
},
|
|
16
|
-
"license": "MIT",
|
|
17
|
-
"scripts": {
|
|
18
|
-
"start": "vite build --watch",
|
|
19
|
-
"build": "vite build",
|
|
20
|
-
"clear": "rm -rf dist",
|
|
21
|
-
"patch": "node ci/patcher.js",
|
|
22
|
-
"lint": "eslint src/**/*.ts"
|
|
23
|
-
},
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"@typescript-eslint/eslint-plugin": "^5.53.0",
|
|
26
|
-
"@typescript-eslint/parser": "^5.53.0",
|
|
27
|
-
"eslint": "^8.21.0",
|
|
28
|
-
"npm-run-all": "^4.1.5",
|
|
29
|
-
"vite": "^4.1.4",
|
|
30
|
-
"vite-plugin-dts": "^2.0.0-beta.3",
|
|
31
|
-
"typescript": "^4.9.3"
|
|
32
|
-
},
|
|
33
36
|
"publishConfig": {
|
|
34
37
|
"access": "public",
|
|
35
38
|
"registry": "https://registry.npmjs.org"
|
|
36
39
|
},
|
|
37
|
-
"version": "8.13.2-next.
|
|
40
|
+
"version": "8.13.2-next.1751826612"
|
|
38
41
|
}
|
package/dist/helpers.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { RichTextDocument, RichTextNode } from './types';
|
|
2
|
-
export declare function richTextNodeToString(node: RichTextNode): string;
|
|
3
|
-
export declare function richTextNodesToString(nodes: RichTextNode[]): string;
|
|
4
|
-
export declare function richTextDocumentToString(document: RichTextDocument): string;
|
|
5
|
-
export declare function isRichTextDocumentEmpty(document: RichTextDocument): boolean;
|
|
6
|
-
export declare function createRichTextDocumentFromString(text: string): RichTextDocument;
|
|
7
|
-
export declare function parseRichTextDocument(text: string): RichTextDocument;
|
package/dist/types.d.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
export type RichTextDocument = {
|
|
2
|
-
type: 'doc';
|
|
3
|
-
content?: Maybe<RichTextNode[]>;
|
|
4
|
-
};
|
|
5
|
-
export type RichTextNode = RichTextHeading | RichTextParagraph | RichTextCodeBlock | RichTextBlockquote | RichTextHorizontalRule | RichTextHardBreak | RichTextBulletList | RichTextOrderedList | RichTextListItem | RichTextTable | RichTextTableRow | RichTextTableHeader | RichTextTableCell | RichTextText;
|
|
6
|
-
export 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[]>;
|
|
13
|
-
};
|
|
14
|
-
export type RichTextParagraph = {
|
|
15
|
-
type: 'paragraph';
|
|
16
|
-
attrs?: Maybe<{
|
|
17
|
-
textAlign?: Maybe<RichTextTextAlign>;
|
|
18
|
-
}>;
|
|
19
|
-
content?: Maybe<RichTextNode[]>;
|
|
20
|
-
};
|
|
21
|
-
export type RichTextCodeBlock = {
|
|
22
|
-
type: 'codeblock';
|
|
23
|
-
content?: Maybe<RichTextText[]>;
|
|
24
|
-
};
|
|
25
|
-
export type RichTextBlockquote = {
|
|
26
|
-
type: 'blockquote';
|
|
27
|
-
content?: Maybe<RichTextText[]>;
|
|
28
|
-
};
|
|
29
|
-
export type RichTextBulletList = {
|
|
30
|
-
type: 'bulletList';
|
|
31
|
-
content?: Maybe<RichTextListItem[]>;
|
|
32
|
-
};
|
|
33
|
-
export type RichTextOrderedList = {
|
|
34
|
-
type: 'orderedList';
|
|
35
|
-
attrs?: Maybe<{
|
|
36
|
-
start?: Maybe<number>;
|
|
37
|
-
}>;
|
|
38
|
-
content?: Maybe<RichTextListItem[]>;
|
|
39
|
-
};
|
|
40
|
-
export type RichTextListItem = {
|
|
41
|
-
type: 'listItem';
|
|
42
|
-
content?: Maybe<RichTextNode[]>;
|
|
43
|
-
};
|
|
44
|
-
export type RichTextTable = {
|
|
45
|
-
type: 'table';
|
|
46
|
-
content?: Maybe<RichTextTableRow[]>;
|
|
47
|
-
};
|
|
48
|
-
export type RichTextTableRow = {
|
|
49
|
-
type: 'tableRow';
|
|
50
|
-
content?: Maybe<(RichTextTableHeader | RichTextTableCell)[]>;
|
|
51
|
-
};
|
|
52
|
-
export 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[]>;
|
|
60
|
-
};
|
|
61
|
-
export 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[]>;
|
|
69
|
-
};
|
|
70
|
-
export type RichTextHorizontalRule = {
|
|
71
|
-
type: 'horizontalRule';
|
|
72
|
-
};
|
|
73
|
-
export type RichTextHardBreak = {
|
|
74
|
-
type: 'hardBreak';
|
|
75
|
-
};
|
|
76
|
-
export type RichTextText = {
|
|
77
|
-
type: 'text';
|
|
78
|
-
text: string;
|
|
79
|
-
marks?: Maybe<RichTextMark[]>;
|
|
80
|
-
};
|
|
81
|
-
export type RichTextUnderlineMark = {
|
|
82
|
-
type: 'underline';
|
|
83
|
-
};
|
|
84
|
-
export type RichTextBoldMark = {
|
|
85
|
-
type: 'bold';
|
|
86
|
-
};
|
|
87
|
-
export type RichTextItalicMark = {
|
|
88
|
-
type: 'italic';
|
|
89
|
-
};
|
|
90
|
-
export type RichTextCodeMark = {
|
|
91
|
-
type: 'code';
|
|
92
|
-
};
|
|
93
|
-
export type RichTextStrikeMark = {
|
|
94
|
-
type: 'strike';
|
|
95
|
-
};
|
|
96
|
-
export type RichTextTextStyleMark = {
|
|
97
|
-
type: 'textStyle';
|
|
98
|
-
attrs?: Maybe<{
|
|
99
|
-
color?: Maybe<string>;
|
|
100
|
-
}>;
|
|
101
|
-
};
|
|
102
|
-
export type RichTextLink<T extends Record<string, any> = Record<string, any>> = {
|
|
103
|
-
type: 'link';
|
|
104
|
-
attrs?: Maybe<{
|
|
105
|
-
data?: Maybe<T>;
|
|
106
|
-
}>;
|
|
107
|
-
};
|
|
108
|
-
export type RichTextMark = RichTextUnderlineMark | RichTextBoldMark | RichTextItalicMark | RichTextCodeMark | RichTextStrikeMark | RichTextTextStyleMark | RichTextLink;
|
|
109
|
-
export type RichTextTextAlign = 'left' | 'center' | 'right';
|
|
110
|
-
export type Maybe<T> = T | null | undefined;
|