react-next-editor-js 0.1.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/README.md +877 -0
- package/dist/chunk-3QWXTDLY.cjs +486 -0
- package/dist/chunk-3QWXTDLY.cjs.map +1 -0
- package/dist/chunk-5F6SPYCN.cjs +180 -0
- package/dist/chunk-5F6SPYCN.cjs.map +1 -0
- package/dist/chunk-6NTSXJX4.js +174 -0
- package/dist/chunk-6NTSXJX4.js.map +1 -0
- package/dist/chunk-7VYJDBH7.js +261 -0
- package/dist/chunk-7VYJDBH7.js.map +1 -0
- package/dist/chunk-DBSFCCBG.cjs +1712 -0
- package/dist/chunk-DBSFCCBG.cjs.map +1 -0
- package/dist/chunk-EFE6RHDL.cjs +4 -0
- package/dist/chunk-EFE6RHDL.cjs.map +1 -0
- package/dist/chunk-G6YRIEK4.js +3 -0
- package/dist/chunk-G6YRIEK4.js.map +1 -0
- package/dist/chunk-GFNFJ3FL.cjs +119 -0
- package/dist/chunk-GFNFJ3FL.cjs.map +1 -0
- package/dist/chunk-IG2YLUFW.js +114 -0
- package/dist/chunk-IG2YLUFW.js.map +1 -0
- package/dist/chunk-JQXTWLHL.js +176 -0
- package/dist/chunk-JQXTWLHL.js.map +1 -0
- package/dist/chunk-NJCEHQV3.cjs +454 -0
- package/dist/chunk-NJCEHQV3.cjs.map +1 -0
- package/dist/chunk-O4GTLC3T.js +478 -0
- package/dist/chunk-O4GTLC3T.js.map +1 -0
- package/dist/chunk-ODHABIIC.cjs +82 -0
- package/dist/chunk-ODHABIIC.cjs.map +1 -0
- package/dist/chunk-PZ5AY32C.js +9 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-Q7SFCCGT.cjs +11 -0
- package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
- package/dist/chunk-QIUIYBCZ.js +80 -0
- package/dist/chunk-QIUIYBCZ.js.map +1 -0
- package/dist/chunk-QROUNVQK.js +450 -0
- package/dist/chunk-QROUNVQK.js.map +1 -0
- package/dist/chunk-T6FR37IC.js +41 -0
- package/dist/chunk-T6FR37IC.js.map +1 -0
- package/dist/chunk-TI44I654.cjs +265 -0
- package/dist/chunk-TI44I654.cjs.map +1 -0
- package/dist/chunk-TXPLBAH5.cjs +47 -0
- package/dist/chunk-TXPLBAH5.cjs.map +1 -0
- package/dist/chunk-U3O54IYI.cjs +187 -0
- package/dist/chunk-U3O54IYI.cjs.map +1 -0
- package/dist/chunk-VLC7SZMT.js +1669 -0
- package/dist/chunk-VLC7SZMT.js.map +1 -0
- package/dist/core/index.cjs +232 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +122 -0
- package/dist/core/index.d.ts +122 -0
- package/dist/core/index.js +7 -0
- package/dist/core/index.js.map +1 -0
- package/dist/defaults-EQD5QKCU.js +4 -0
- package/dist/defaults-EQD5QKCU.js.map +1 -0
- package/dist/defaults-MLYXD2BG.cjs +49 -0
- package/dist/defaults-MLYXD2BG.cjs.map +1 -0
- package/dist/docx-BUrf4PFj.d.ts +49 -0
- package/dist/docx-DLfSdvXm.d.cts +49 -0
- package/dist/docx-LDETXV3L.js +5 -0
- package/dist/docx-LDETXV3L.js.map +1 -0
- package/dist/docx-N2LKIOK3.cjs +14 -0
- package/dist/docx-N2LKIOK3.cjs.map +1 -0
- package/dist/export/index.cjs +54 -0
- package/dist/export/index.cjs.map +1 -0
- package/dist/export/index.d.cts +60 -0
- package/dist/export/index.d.ts +60 -0
- package/dist/export/index.js +9 -0
- package/dist/export/index.js.map +1 -0
- package/dist/html-5BXJPQU3.js +7 -0
- package/dist/html-5BXJPQU3.js.map +1 -0
- package/dist/html-KU2KHLRF.cjs +24 -0
- package/dist/html-KU2KHLRF.cjs.map +1 -0
- package/dist/import/index.cjs +15 -0
- package/dist/import/index.cjs.map +1 -0
- package/dist/import/index.d.cts +37 -0
- package/dist/import/index.d.ts +37 -0
- package/dist/import/index.js +6 -0
- package/dist/import/index.js.map +1 -0
- package/dist/index.cjs +1035 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +248 -0
- package/dist/index.d.ts +248 -0
- package/dist/index.js +885 -0
- package/dist/index.js.map +1 -0
- package/dist/persistence/index.cjs +37 -0
- package/dist/persistence/index.cjs.map +1 -0
- package/dist/persistence/index.d.cts +279 -0
- package/dist/persistence/index.d.ts +279 -0
- package/dist/persistence/index.js +4 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/sanitize-7IZ-SW1f.d.ts +361 -0
- package/dist/sanitize-CvmgqbsA.d.cts +361 -0
- package/dist/server/index.cjs +400 -0
- package/dist/server/index.cjs.map +1 -0
- package/dist/server/index.d.cts +229 -0
- package/dist/server/index.d.ts +229 -0
- package/dist/server/index.js +390 -0
- package/dist/server/index.js.map +1 -0
- package/dist/styles.css +680 -0
- package/dist/types-B4z0Quvv.d.cts +193 -0
- package/dist/types-B4z0Quvv.d.ts +193 -0
- package/package.json +183 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { Component, ReactNode, ErrorInfo, JSX } from 'react';
|
|
3
|
+
import { EditorState, Plugin, Command } from 'prosemirror-state';
|
|
4
|
+
import { EditorView } from 'prosemirror-view';
|
|
5
|
+
import { Schema } from 'prosemirror-model';
|
|
6
|
+
import { D as DocumentJSON, S as SaveStatus, E as EditorMode, F as FeatureFlags, P as PageConfig, c as ToolbarConfig, T as ThemeTokens, a as EditorStrings } from './types-B4z0Quvv.js';
|
|
7
|
+
export { e as PageFooterElement, f as PageRunningElement, b as PageSize, d as ToolbarItemId } from './types-B4z0Quvv.js';
|
|
8
|
+
import { C as CommandSet, E as EditorCommand } from './sanitize-7IZ-SW1f.js';
|
|
9
|
+
export { D as DEFAULT_COLOR_PALETTE, b as DEFAULT_FEATURES, c as DEFAULT_FONT_FAMILIES, d as DEFAULT_FONT_SIZES, e as DEFAULT_PAGE, f as DEFAULT_STRINGS, g as DEFAULT_TOOLBAR_GROUPS, P as PAGE_DIMENSIONS_MM, o as buildPlugins, p as buildSchema, s as countDocument, t as createCommands, u as createDoc, v as createEditorState, y as defaultSchema, W as resolvePageDimensions, X as sanitizeHtml, Z as sanitizeImageSrc, _ as sanitizeUrl, a2 as themeToCssVars } from './sanitize-7IZ-SW1f.js';
|
|
10
|
+
import { T as TextConversionOptions, b as DocxNodeConverter } from './docx-BUrf4PFj.js';
|
|
11
|
+
export { a as DocxExportOptions, d as documentToDocxBlob, c as documentToDocxBuffer, e as documentToText } from './docx-BUrf4PFj.js';
|
|
12
|
+
import { LocalStoreAdapter, RemoteSyncAdapter, StoredDocument } from './persistence/index.js';
|
|
13
|
+
export { AssetUploadAdapter, ConflictError, ConnectivityMonitor, DocumentPersistence, IndexedDBStore, MemoryStore, OutboxEntry, RemoteSaveResult, SaveStatusListener, SyncEngine, requestPersistentStorage } from './persistence/index.js';
|
|
14
|
+
export { ExportFormat, PdfPrintOptions, buildPrintDocument, documentToHtml, downloadBlob, downloadText, exportDocument, printDocumentToPdf } from './export/index.js';
|
|
15
|
+
export { DocxImportOptions, DocxImportResult, importDocx } from './import/index.js';
|
|
16
|
+
import 'docx';
|
|
17
|
+
|
|
18
|
+
/** Imperative handle exposed via `ref` (F-10.15, F-10.16). */
|
|
19
|
+
interface EditorRef {
|
|
20
|
+
/** The current document as ProseMirror JSON (F-8.1). */
|
|
21
|
+
getJSON(): DocumentJSON;
|
|
22
|
+
/** The document as plain text (F-6.18). */
|
|
23
|
+
getText(options?: TextConversionOptions): string;
|
|
24
|
+
/** The document as an HTML fragment. */
|
|
25
|
+
getHTML(): string;
|
|
26
|
+
/** Replace the document content. */
|
|
27
|
+
setContent(content: DocumentJSON | string | null): void;
|
|
28
|
+
/**
|
|
29
|
+
* Import an external `.docx` file, replacing the current content (best-effort,
|
|
30
|
+
* F-7.2). Requires the optional `mammoth` dependency. Returns conversion
|
|
31
|
+
* warnings. The change is undoable and triggers `onChange`/autosave.
|
|
32
|
+
*/
|
|
33
|
+
importDocx(file: ArrayBuffer | Uint8Array | Blob): Promise<{
|
|
34
|
+
warnings: string[];
|
|
35
|
+
}>;
|
|
36
|
+
/** Focus the editing surface. */
|
|
37
|
+
focus(): void;
|
|
38
|
+
/** Whether the document has unsynced local changes. */
|
|
39
|
+
isDirty(): boolean;
|
|
40
|
+
/** Force an immediate local save (flush autosave). */
|
|
41
|
+
save(): Promise<void>;
|
|
42
|
+
/** Purge this document's locally-persisted data (F-12.7). */
|
|
43
|
+
clearLocalData(): Promise<void>;
|
|
44
|
+
/** Trigger an interactive export + download/print. */
|
|
45
|
+
exportAs(format: 'docx' | 'pdf' | 'txt' | 'html', filename?: string): Promise<void>;
|
|
46
|
+
/** Escape hatch: the underlying ProseMirror view (F-10.16). */
|
|
47
|
+
getView(): EditorView | null;
|
|
48
|
+
/** Escape hatch: the current editor state. */
|
|
49
|
+
getState(): EditorState | null;
|
|
50
|
+
/** The schema in use. */
|
|
51
|
+
getSchema(): Schema | null;
|
|
52
|
+
}
|
|
53
|
+
/** Lifecycle/state events (F-10.15). */
|
|
54
|
+
interface EditorEvents {
|
|
55
|
+
/** Fired once the view is mounted and ready. */
|
|
56
|
+
onReady?: (ref: EditorRef) => void;
|
|
57
|
+
/** Fired on every document change with the new JSON. */
|
|
58
|
+
onChange?: (json: DocumentJSON, ref: EditorRef) => void;
|
|
59
|
+
/** Fired when the selection changes. */
|
|
60
|
+
onSelectionChange?: (state: EditorState) => void;
|
|
61
|
+
/** Fired when the local-save / sync status changes (F-9.4). */
|
|
62
|
+
onSaveStatusChange?: (status: SaveStatus, detail?: {
|
|
63
|
+
error?: string;
|
|
64
|
+
}) => void;
|
|
65
|
+
/** Fired when the editor or a feature throws; contained by the error boundary. */
|
|
66
|
+
onError?: (error: Error) => void;
|
|
67
|
+
}
|
|
68
|
+
/** Extension hooks (F-10.13, F-10.14). */
|
|
69
|
+
interface EditorExtensions {
|
|
70
|
+
/** Extra ProseMirror plugins appended to the stack. */
|
|
71
|
+
plugins?: Plugin[];
|
|
72
|
+
/** Custom DOCX node converters keyed by node type (F-6.16). */
|
|
73
|
+
docxNodeConverters?: Record<string, DocxNodeConverter>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Synchronization configuration (F-9.6–F-9.9, F-9.14). When provided alongside
|
|
77
|
+
* a persisted `documentId`, the editor owns a connectivity monitor and a sync
|
|
78
|
+
* engine: offline edits queue in the durable outbox and upload automatically on
|
|
79
|
+
* reconnect, with no user action. Surfaces status through `onSaveStatusChange`.
|
|
80
|
+
*/
|
|
81
|
+
interface SyncConfig {
|
|
82
|
+
/** REST adapter that persists the document JSON to your API (F-9.7). */
|
|
83
|
+
remote: RemoteSyncAdapter;
|
|
84
|
+
/** Auto-flush the outbox on reconnect and after each local save. Default true. */
|
|
85
|
+
auto?: boolean;
|
|
86
|
+
/** Connectivity ping interval in ms (default 30000). */
|
|
87
|
+
pingIntervalMs?: number;
|
|
88
|
+
/** Max upload attempts before a document is parked for manual retry (default 6). */
|
|
89
|
+
maxAttempts?: number;
|
|
90
|
+
/** Invoked when a version conflict is detected (F-9.9). */
|
|
91
|
+
onConflict?: (local: StoredDocument, remote?: {
|
|
92
|
+
version: string | number;
|
|
93
|
+
}) => void;
|
|
94
|
+
}
|
|
95
|
+
/** Local persistence configuration (F-8.x, F-9.2). */
|
|
96
|
+
interface PersistenceConfig {
|
|
97
|
+
/** Enable durable local autosave. Default true when a documentId is given. */
|
|
98
|
+
enabled?: boolean;
|
|
99
|
+
/** Injected store adapter; defaults to the built-in IndexedDB store. */
|
|
100
|
+
store?: LocalStoreAdapter;
|
|
101
|
+
/** Autosave debounce in ms (default 800). */
|
|
102
|
+
debounceMs?: number;
|
|
103
|
+
/** Request persistent storage on mount (F-9.11). Default true. */
|
|
104
|
+
requestPersistent?: boolean;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The single, documented configuration object for the editor (F-10.1). Every
|
|
108
|
+
* field is optional; sensible defaults apply (resolveConfig). Integration points
|
|
109
|
+
* are explicit props/callbacks — no host-app internals are referenced (F-10.11).
|
|
110
|
+
*/
|
|
111
|
+
interface EditorProps extends EditorEvents {
|
|
112
|
+
/** Stable id used for local persistence and sync. */
|
|
113
|
+
documentId?: string;
|
|
114
|
+
/** Initial content for uncontrolled usage. */
|
|
115
|
+
initialContent?: DocumentJSON | string | null;
|
|
116
|
+
/** Controlled value (with `onChange`) for controlled usage (F-10.20). */
|
|
117
|
+
value?: DocumentJSON | null;
|
|
118
|
+
/** Editing mode (F-10.3). `readOnly` is a convenience alias. */
|
|
119
|
+
mode?: EditorMode;
|
|
120
|
+
readOnly?: boolean;
|
|
121
|
+
/** Placeholder text for an empty document (F-4.7). */
|
|
122
|
+
placeholder?: string;
|
|
123
|
+
/** Per-feature toggles (F-10.2). */
|
|
124
|
+
features?: Partial<FeatureFlags>;
|
|
125
|
+
/** Page geometry (F-5.1, F-5.2). */
|
|
126
|
+
page?: Partial<PageConfig>;
|
|
127
|
+
/** Toolbar layout/customization (F-10.6), or false to hide. */
|
|
128
|
+
toolbar?: ToolbarConfig | false;
|
|
129
|
+
/** Show the word/character status bar. Default true. */
|
|
130
|
+
statusBar?: boolean;
|
|
131
|
+
/** Theme tokens (F-10.5). */
|
|
132
|
+
theme?: ThemeTokens;
|
|
133
|
+
/** Localized UI strings (F-10.8). */
|
|
134
|
+
strings?: Partial<EditorStrings>;
|
|
135
|
+
/** Font families offered in the font picker. */
|
|
136
|
+
fontFamilies?: string[];
|
|
137
|
+
/** Font sizes (pt) offered in the size picker. */
|
|
138
|
+
fontSizes?: number[];
|
|
139
|
+
/** Color palette for the color/highlight pickers. */
|
|
140
|
+
colorPalette?: string[];
|
|
141
|
+
/** Extension hooks (F-10.13). */
|
|
142
|
+
extensions?: EditorExtensions;
|
|
143
|
+
/** Local persistence configuration. */
|
|
144
|
+
persistence?: PersistenceConfig;
|
|
145
|
+
/** Synchronization to a REST API (offline edits auto-upload on reconnect). */
|
|
146
|
+
sync?: SyncConfig;
|
|
147
|
+
/** Per-document metadata stored alongside the content. */
|
|
148
|
+
metadata?: Record<string, unknown>;
|
|
149
|
+
/** Root element class and inline style (theming/layout). */
|
|
150
|
+
className?: string;
|
|
151
|
+
style?: React.CSSProperties;
|
|
152
|
+
/** Accessible label for the editing region (NF-4). */
|
|
153
|
+
ariaLabel?: string;
|
|
154
|
+
/** Text direction for the document (NF-6, RTL awareness). Default 'ltr'. */
|
|
155
|
+
dir?: 'ltr' | 'rtl' | 'auto';
|
|
156
|
+
/**
|
|
157
|
+
* Custom content rendered inside the editor's context provider, below the
|
|
158
|
+
* built-in toolbar. Components here may call {@link useEditorContext} to build
|
|
159
|
+
* custom toolbars, panels, or status indicators that reflect live editor
|
|
160
|
+
* state. Use with `toolbar={false}` to fully replace the default toolbar.
|
|
161
|
+
*/
|
|
162
|
+
children?: React.ReactNode;
|
|
163
|
+
}
|
|
164
|
+
/** Value provided through {@link EditorContext} to toolbar and children. */
|
|
165
|
+
interface EditorContextValue {
|
|
166
|
+
view: EditorView | null;
|
|
167
|
+
state: EditorState | null;
|
|
168
|
+
schema: Schema;
|
|
169
|
+
commands: CommandSet;
|
|
170
|
+
strings: EditorStrings;
|
|
171
|
+
features: FeatureFlags;
|
|
172
|
+
fontFamilies: string[];
|
|
173
|
+
fontSizes: number[];
|
|
174
|
+
colorPalette: string[];
|
|
175
|
+
editable: boolean;
|
|
176
|
+
/** Run a ProseMirror command against the live view and refocus. */
|
|
177
|
+
run: (command: Command) => boolean;
|
|
178
|
+
/** Import a `.docx` file, replacing content (best-effort). */
|
|
179
|
+
importDocx: (file: ArrayBuffer | Uint8Array | Blob) => Promise<{
|
|
180
|
+
warnings: string[];
|
|
181
|
+
}>;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* The embeddable rich document editor (F-10.17). Client-only — load via
|
|
186
|
+
* `next/dynamic(() => import('react-next-editor').then(m => m.Editor), { ssr: false })`.
|
|
187
|
+
* Wrapped in an error boundary so a failure never takes down the host (F-11.2).
|
|
188
|
+
*/
|
|
189
|
+
declare const Editor: react.ForwardRefExoticComponent<EditorProps & react.RefAttributes<EditorRef>>;
|
|
190
|
+
|
|
191
|
+
interface ErrorBoundaryProps {
|
|
192
|
+
children: ReactNode;
|
|
193
|
+
onError?: (error: Error) => void;
|
|
194
|
+
fallbackMessage?: string;
|
|
195
|
+
}
|
|
196
|
+
interface ErrorBoundaryState {
|
|
197
|
+
error: Error | null;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Wraps the editor so a failure in one feature/instance cannot bring down the
|
|
201
|
+
* host app (F-11.2). Degrades to a recoverable state with a clear message and a
|
|
202
|
+
* retry button; reports the error via `onError` for monitoring (F-11.8).
|
|
203
|
+
*/
|
|
204
|
+
declare class EditorErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
205
|
+
constructor(props: ErrorBoundaryProps);
|
|
206
|
+
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
207
|
+
componentDidCatch(error: Error, info: ErrorInfo): void;
|
|
208
|
+
private readonly handleReset;
|
|
209
|
+
render(): ReactNode;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Context providing the live view/state/commands to the toolbar and children. */
|
|
213
|
+
declare const EditorContext: react.Context<EditorContextValue | null>;
|
|
214
|
+
/** Access the editor context; throws if used outside an <Editor>. */
|
|
215
|
+
declare function useEditorContext(): EditorContextValue;
|
|
216
|
+
|
|
217
|
+
interface ToolbarProps {
|
|
218
|
+
config?: ToolbarConfig;
|
|
219
|
+
}
|
|
220
|
+
/** Data-driven, keyboard-accessible toolbar (F-1–F-3, F-10.6, NF-4). */
|
|
221
|
+
declare function Toolbar({ config }: ToolbarProps): react.JSX.Element;
|
|
222
|
+
|
|
223
|
+
interface ToolbarButtonProps {
|
|
224
|
+
iconName: string;
|
|
225
|
+
label: string;
|
|
226
|
+
command: EditorCommand;
|
|
227
|
+
}
|
|
228
|
+
/** A single command button reflecting active/enabled state (F-10.6, NF-4). */
|
|
229
|
+
declare function ToolbarButton({ iconName, label, command }: ToolbarButtonProps): react.JSX.Element;
|
|
230
|
+
|
|
231
|
+
declare function ToolbarIcon({ name }: {
|
|
232
|
+
name: string;
|
|
233
|
+
}): JSX.Element;
|
|
234
|
+
|
|
235
|
+
interface StatusBarProps {
|
|
236
|
+
saveStatus: SaveStatus;
|
|
237
|
+
hasPersistence: boolean;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Word/character count (F-4.5) and visible save/sync status (F-9.4, NF-10).
|
|
241
|
+
*
|
|
242
|
+
* The count is an O(n) document walk, so it is recomputed only when the document
|
|
243
|
+
* actually changes (not on selection changes) and is debounced — keeping typing
|
|
244
|
+
* responsive on large documents (NF-1).
|
|
245
|
+
*/
|
|
246
|
+
declare function StatusBar({ saveStatus, hasPersistence }: StatusBarProps): react.JSX.Element;
|
|
247
|
+
|
|
248
|
+
export { CommandSet, DocumentJSON, DocxNodeConverter, Editor, EditorCommand, EditorContext, type EditorContextValue, EditorErrorBoundary, type EditorEvents, type EditorExtensions, EditorMode, type EditorProps, type EditorRef, EditorStrings, FeatureFlags, LocalStoreAdapter, PageConfig, type PersistenceConfig, RemoteSyncAdapter, SaveStatus, StatusBar, StoredDocument, type SyncConfig, TextConversionOptions, ThemeTokens, Toolbar, ToolbarButton, ToolbarConfig, ToolbarIcon, useEditorContext };
|