@contello/rich-text 8.21.2 → 8.22.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.
- package/LICENSE +21 -0
- package/dist/index.d.cts +8 -5
- package/dist/index.d.ts +8 -5
- package/package.json +8 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020-2026 entwico GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.cts
CHANGED
|
@@ -108,18 +108,21 @@ type RichTextLink<T extends Record<string, any> = Record<string, any>> = {
|
|
|
108
108
|
type RichTextMark = RichTextUnderlineMark | RichTextBoldMark | RichTextItalicMark | RichTextCodeMark | RichTextStrikeMark | RichTextTextStyleMark | RichTextLink;
|
|
109
109
|
type RichTextTextAlign = 'left' | 'center' | 'right';
|
|
110
110
|
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;
|
|
111
114
|
|
|
112
115
|
/** Converts a single rich text node to its plain text representation. */
|
|
113
|
-
declare function richTextNodeToString(node: RichTextNode): string;
|
|
116
|
+
declare function richTextNodeToString(node: DeepReadonly<RichTextNode>): string;
|
|
114
117
|
/** Converts an array of rich text nodes to plain text, joining them with newlines. */
|
|
115
|
-
declare function richTextNodesToString(nodes: RichTextNode[]): string;
|
|
118
|
+
declare function richTextNodesToString(nodes: readonly DeepReadonly<RichTextNode>[]): string;
|
|
116
119
|
/** Converts a rich text document to its plain text representation. */
|
|
117
|
-
declare function richTextDocumentToString(document: RichTextDocument): string;
|
|
120
|
+
declare function richTextDocumentToString(document: DeepReadonly<RichTextDocument>): string;
|
|
118
121
|
/** Returns `true` if the document has no content or only whitespace. */
|
|
119
|
-
declare function isRichTextDocumentEmpty(document: RichTextDocument): boolean;
|
|
122
|
+
declare function isRichTextDocumentEmpty(document: DeepReadonly<RichTextDocument>): boolean;
|
|
120
123
|
/** Creates a rich text document containing a single paragraph with the given text. */
|
|
121
124
|
declare function createRichTextDocumentFromString(text: string | null | undefined): RichTextDocument;
|
|
122
125
|
/** Parses a JSON string into a {@link RichTextDocument}. Returns an empty document if parsing fails or the input is nullish. */
|
|
123
126
|
declare function parseRichTextDocument(text: string | null | undefined): RichTextDocument;
|
|
124
127
|
|
|
125
|
-
export { 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 };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -108,18 +108,21 @@ type RichTextLink<T extends Record<string, any> = Record<string, any>> = {
|
|
|
108
108
|
type RichTextMark = RichTextUnderlineMark | RichTextBoldMark | RichTextItalicMark | RichTextCodeMark | RichTextStrikeMark | RichTextTextStyleMark | RichTextLink;
|
|
109
109
|
type RichTextTextAlign = 'left' | 'center' | 'right';
|
|
110
110
|
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;
|
|
111
114
|
|
|
112
115
|
/** Converts a single rich text node to its plain text representation. */
|
|
113
|
-
declare function richTextNodeToString(node: RichTextNode): string;
|
|
116
|
+
declare function richTextNodeToString(node: DeepReadonly<RichTextNode>): string;
|
|
114
117
|
/** Converts an array of rich text nodes to plain text, joining them with newlines. */
|
|
115
|
-
declare function richTextNodesToString(nodes: RichTextNode[]): string;
|
|
118
|
+
declare function richTextNodesToString(nodes: readonly DeepReadonly<RichTextNode>[]): string;
|
|
116
119
|
/** Converts a rich text document to its plain text representation. */
|
|
117
|
-
declare function richTextDocumentToString(document: RichTextDocument): string;
|
|
120
|
+
declare function richTextDocumentToString(document: DeepReadonly<RichTextDocument>): string;
|
|
118
121
|
/** Returns `true` if the document has no content or only whitespace. */
|
|
119
|
-
declare function isRichTextDocumentEmpty(document: RichTextDocument): boolean;
|
|
122
|
+
declare function isRichTextDocumentEmpty(document: DeepReadonly<RichTextDocument>): boolean;
|
|
120
123
|
/** Creates a rich text document containing a single paragraph with the given text. */
|
|
121
124
|
declare function createRichTextDocumentFromString(text: string | null | undefined): RichTextDocument;
|
|
122
125
|
/** Parses a JSON string into a {@link RichTextDocument}. Returns an empty document if parsing fails or the input is nullish. */
|
|
123
126
|
declare function parseRichTextDocument(text: string | null | undefined): RichTextDocument;
|
|
124
127
|
|
|
125
|
-
export { 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 };
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contello/rich-text",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.22.0",
|
|
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",
|
|
@@ -10,12 +10,6 @@
|
|
|
10
10
|
"url": "https://github.com/entwico/contello-js",
|
|
11
11
|
"directory": "packages/rich-text"
|
|
12
12
|
},
|
|
13
|
-
"scripts": {
|
|
14
|
-
"build": "tsup",
|
|
15
|
-
"lint": "eslint .",
|
|
16
|
-
"lint:fix": "eslint . --fix",
|
|
17
|
-
"typecheck": "tsc --noEmit"
|
|
18
|
-
},
|
|
19
13
|
"files": [
|
|
20
14
|
"dist"
|
|
21
15
|
],
|
|
@@ -29,5 +23,11 @@
|
|
|
29
23
|
"publishConfig": {
|
|
30
24
|
"access": "public",
|
|
31
25
|
"registry": "https://registry.npmjs.org"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsup",
|
|
29
|
+
"lint": "eslint .",
|
|
30
|
+
"lint:fix": "eslint . --fix",
|
|
31
|
+
"typecheck": "tsc --noEmit"
|
|
32
32
|
}
|
|
33
|
-
}
|
|
33
|
+
}
|