@crashbytes/contentful-richtext-editor 1.0.8 → 1.0.9
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/README.md +433 -204
- package/dist/components/ContentfulEditor.d.ts +8 -3
- package/dist/components/ContentfulEmbedded.d.ts +12 -0
- package/dist/components/Toolbar.d.ts +2 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.esm.js +410 -79
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +415 -77
- package/dist/index.js.map +1 -1
- package/dist/utils/configParser.d.ts +37 -0
- package/dist/utils/contentfulTransform.d.ts +20 -0
- package/dist/utils/types.d.ts +113 -0
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface ContentfulFieldValidation {
|
|
2
|
+
enabledMarks?: string[];
|
|
3
|
+
enabledNodeTypes?: string[];
|
|
4
|
+
}
|
|
5
|
+
export interface ContentfulFieldConfiguration {
|
|
6
|
+
validations?: ContentfulFieldValidation[];
|
|
7
|
+
settings?: {
|
|
8
|
+
helpText?: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export interface ParsedEditorConfig {
|
|
12
|
+
availableHeadings: Array<1 | 2 | 3 | 4 | 5 | 6>;
|
|
13
|
+
availableMarks: Array<'bold' | 'italic' | 'underline'>;
|
|
14
|
+
disabledFeatures: string[];
|
|
15
|
+
allowHyperlinks: boolean;
|
|
16
|
+
allowEmbeddedEntries: boolean;
|
|
17
|
+
allowEmbeddedAssets: boolean;
|
|
18
|
+
allowInlineEntries: boolean;
|
|
19
|
+
allowTables: boolean;
|
|
20
|
+
allowQuotes: boolean;
|
|
21
|
+
allowLists: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Parses Contentful field configuration to determine editor capabilities
|
|
25
|
+
*/
|
|
26
|
+
export declare const parseContentfulFieldConfig: (fieldConfiguration?: ContentfulFieldConfiguration) => ParsedEditorConfig;
|
|
27
|
+
/**
|
|
28
|
+
* Helper function to fetch Contentful field configuration from Management API
|
|
29
|
+
*/
|
|
30
|
+
export declare const fetchContentfulFieldConfig: (spaceId: string, contentTypeId: string, fieldId: string, accessToken: string) => Promise<ContentfulFieldConfiguration | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a mock field configuration for testing purposes
|
|
33
|
+
*/
|
|
34
|
+
export declare const createMockFieldConfig: (options: {
|
|
35
|
+
enabledMarks?: string[];
|
|
36
|
+
enabledNodeTypes?: string[];
|
|
37
|
+
}) => ContentfulFieldConfiguration;
|
|
@@ -25,4 +25,24 @@ export declare const validateContentfulDocument: (document: any) => document is
|
|
|
25
25
|
* Creates an empty Contentful document
|
|
26
26
|
*/
|
|
27
27
|
export declare const createEmptyDocument: () => Document;
|
|
28
|
+
/**
|
|
29
|
+
* Sanitizes a Contentful document by removing invalid nodes/marks based on configuration
|
|
30
|
+
*/
|
|
31
|
+
export declare const sanitizeContentfulDocument: (document: Document, allowedNodeTypes: string[], allowedMarks: string[]) => Document;
|
|
32
|
+
/**
|
|
33
|
+
* Extracts plain text from a Contentful document
|
|
34
|
+
*/
|
|
35
|
+
export declare const extractPlainText: (document: Document) => string;
|
|
36
|
+
/**
|
|
37
|
+
* Counts words in a Contentful document
|
|
38
|
+
*/
|
|
39
|
+
export declare const countWords: (document: Document) => number;
|
|
40
|
+
/**
|
|
41
|
+
* Finds all embedded entries/assets in a document
|
|
42
|
+
*/
|
|
43
|
+
export declare const findEmbeddedContent: (document: Document) => {
|
|
44
|
+
entries: string[];
|
|
45
|
+
assets: string[];
|
|
46
|
+
inlineEntries: string[];
|
|
47
|
+
};
|
|
28
48
|
export {};
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -26,3 +26,116 @@ export interface EmbeddedAsset {
|
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
+
export type { ContentfulFieldValidation, ContentfulFieldConfiguration, ParsedEditorConfig, } from './configParser';
|
|
30
|
+
export interface EditorFeatureConfig {
|
|
31
|
+
bold?: boolean;
|
|
32
|
+
italic?: boolean;
|
|
33
|
+
underline?: boolean;
|
|
34
|
+
code?: boolean;
|
|
35
|
+
link?: boolean;
|
|
36
|
+
headings?: Array<1 | 2 | 3 | 4 | 5 | 6>;
|
|
37
|
+
lists?: boolean;
|
|
38
|
+
quote?: boolean;
|
|
39
|
+
table?: boolean;
|
|
40
|
+
embeddedEntries?: boolean;
|
|
41
|
+
embeddedAssets?: boolean;
|
|
42
|
+
inlineEntries?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface ContentfulNode {
|
|
45
|
+
nodeType: string;
|
|
46
|
+
data: Record<string, any>;
|
|
47
|
+
content?: Array<ContentfulNode | ContentfulText>;
|
|
48
|
+
}
|
|
49
|
+
export interface ContentfulText {
|
|
50
|
+
nodeType: 'text';
|
|
51
|
+
value: string;
|
|
52
|
+
marks?: Array<{
|
|
53
|
+
type: string;
|
|
54
|
+
}>;
|
|
55
|
+
data: Record<string, any>;
|
|
56
|
+
}
|
|
57
|
+
export interface ContentfulDocument extends ContentfulNode {
|
|
58
|
+
nodeType: 'document';
|
|
59
|
+
content: ContentfulNode[];
|
|
60
|
+
}
|
|
61
|
+
export interface TiptapNode {
|
|
62
|
+
type: string;
|
|
63
|
+
attrs?: Record<string, any>;
|
|
64
|
+
content?: TiptapNode[];
|
|
65
|
+
text?: string;
|
|
66
|
+
marks?: Array<{
|
|
67
|
+
type: string;
|
|
68
|
+
attrs?: Record<string, any>;
|
|
69
|
+
}>;
|
|
70
|
+
}
|
|
71
|
+
export interface TiptapDocument extends TiptapNode {
|
|
72
|
+
type: 'doc';
|
|
73
|
+
content: TiptapNode[];
|
|
74
|
+
}
|
|
75
|
+
export interface EditorState {
|
|
76
|
+
canUndo: boolean;
|
|
77
|
+
canRedo: boolean;
|
|
78
|
+
activeMarks: string[];
|
|
79
|
+
activeNodes: string[];
|
|
80
|
+
currentHeading?: number;
|
|
81
|
+
}
|
|
82
|
+
export type OnChangeCallback = (document: any) => void;
|
|
83
|
+
export type OnEmbedCallback = () => Promise<EmbeddedEntry | EmbeddedAsset | null> | void;
|
|
84
|
+
export interface ThemeConfig {
|
|
85
|
+
name: ContentfulEditorTheme;
|
|
86
|
+
className: string;
|
|
87
|
+
toolbarStyle?: 'minimal' | 'full' | 'compact';
|
|
88
|
+
showBorders?: boolean;
|
|
89
|
+
customStyles?: Record<string, string>;
|
|
90
|
+
}
|
|
91
|
+
export interface ValidationRule {
|
|
92
|
+
type: 'required' | 'minLength' | 'maxLength' | 'pattern' | 'custom';
|
|
93
|
+
value?: any;
|
|
94
|
+
message?: string;
|
|
95
|
+
validator?: (value: any) => boolean | string;
|
|
96
|
+
}
|
|
97
|
+
export interface FieldValidationConfig {
|
|
98
|
+
rules?: ValidationRule[];
|
|
99
|
+
showErrors?: boolean;
|
|
100
|
+
validateOnBlur?: boolean;
|
|
101
|
+
validateOnChange?: boolean;
|
|
102
|
+
}
|
|
103
|
+
export interface LocalizationConfig {
|
|
104
|
+
locale: string;
|
|
105
|
+
messages: Record<string, string>;
|
|
106
|
+
rtl?: boolean;
|
|
107
|
+
}
|
|
108
|
+
export interface A11yConfig {
|
|
109
|
+
ariaLabel?: string;
|
|
110
|
+
ariaDescribedBy?: string;
|
|
111
|
+
announceChanges?: boolean;
|
|
112
|
+
keyboardShortcuts?: Record<string, string>;
|
|
113
|
+
}
|
|
114
|
+
export interface AdvancedEditorConfig {
|
|
115
|
+
autofocus?: boolean;
|
|
116
|
+
spellcheck?: boolean;
|
|
117
|
+
autocomplete?: boolean;
|
|
118
|
+
wordWrap?: boolean;
|
|
119
|
+
lineNumbers?: boolean;
|
|
120
|
+
minimap?: boolean;
|
|
121
|
+
dragDrop?: boolean;
|
|
122
|
+
paste?: {
|
|
123
|
+
plainTextOnly?: boolean;
|
|
124
|
+
cleanupPaste?: boolean;
|
|
125
|
+
preserveWhitespace?: boolean;
|
|
126
|
+
};
|
|
127
|
+
history?: {
|
|
128
|
+
depth?: number;
|
|
129
|
+
newGroupDelay?: number;
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
export interface PluginConfig {
|
|
133
|
+
name: string;
|
|
134
|
+
enabled: boolean;
|
|
135
|
+
options?: Record<string, any>;
|
|
136
|
+
}
|
|
137
|
+
export type DeepPartial<T> = {
|
|
138
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
139
|
+
};
|
|
140
|
+
export type RequiredFields<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
141
|
+
export type OptionalFields<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
package/package.json
CHANGED