@bizapps/design-system-testing 1.6.0 → 1.7.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/editor.cjs +434 -202
- package/dist/editor.cjs.map +1 -1
- package/dist/editor.d.cts +94 -2
- package/dist/editor.d.ts +94 -2
- package/dist/editor.js +431 -205
- package/dist/editor.js.map +1 -1
- package/package.json +17 -17
package/dist/editor.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { Editor } from '@tiptap/react';
|
|
3
|
+
import { Editor, JSONContent, EditorOptions } from '@tiptap/react';
|
|
4
4
|
import * as _tiptap_core from '@tiptap/core';
|
|
5
5
|
import { ImageOptions } from '@tiptap/extension-image';
|
|
6
6
|
|
|
@@ -164,6 +164,98 @@ interface InsertImageDialogProps {
|
|
|
164
164
|
*/
|
|
165
165
|
declare function InsertImageDialog({ open, onOpenChange, labels, url, onUrlChange, alt, onAltChange, file, onFileChange, uploading, onApply, onCancel, removable, onRemove, maxSizeBytes, accept, }: InsertImageDialogProps): react.JSX.Element;
|
|
166
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Whatever `useEditor` accepts in its `extensions` array.
|
|
169
|
+
*
|
|
170
|
+
* Derived from Tiptap's own option rather than imported as AnyExtension: the
|
|
171
|
+
* name resolves to a structurally different declaration depending on which copy
|
|
172
|
+
* of @tiptap/core is in scope, and the two do not assign to each other.
|
|
173
|
+
*/
|
|
174
|
+
type EditorExtension = EditorOptions['extensions'][number];
|
|
175
|
+
/** Every string the built-in toolbar and menus need. All already translated. */
|
|
176
|
+
interface RichTextEditorLabels {
|
|
177
|
+
/** Names the editable area for assistive tech. Required — it has no visible label. */
|
|
178
|
+
editor: string;
|
|
179
|
+
bold: string;
|
|
180
|
+
italic: string;
|
|
181
|
+
heading: string;
|
|
182
|
+
underline: string;
|
|
183
|
+
strikethrough: string;
|
|
184
|
+
quote: string;
|
|
185
|
+
insertLink: string;
|
|
186
|
+
insertImage: string;
|
|
187
|
+
resizeImage: string;
|
|
188
|
+
lists: {
|
|
189
|
+
trigger: string;
|
|
190
|
+
bullet: string;
|
|
191
|
+
ordered: string;
|
|
192
|
+
};
|
|
193
|
+
table: TableMenuLabels;
|
|
194
|
+
highlight: string;
|
|
195
|
+
}
|
|
196
|
+
interface UseRichTextEditorOptions {
|
|
197
|
+
labels: RichTextEditorLabels;
|
|
198
|
+
/** Fires on every document change, with the current ProseMirror JSON. */
|
|
199
|
+
onUpdate?: (doc: JSONContent) => void;
|
|
200
|
+
/** Initial document. */
|
|
201
|
+
content?: JSONContent | string;
|
|
202
|
+
/** Opens the consumer's link dialog. Wire the toolbar's link button to it. */
|
|
203
|
+
onInsertLink?: () => void;
|
|
204
|
+
/** Opens the consumer's image dialog. */
|
|
205
|
+
onInsertImage?: () => void;
|
|
206
|
+
/**
|
|
207
|
+
* Marks and nodes this product's document contract requires — a brand font,
|
|
208
|
+
* a colour palette, anything a server-side whitelist validates. They are
|
|
209
|
+
* appended to the built-in set rather than replacing it.
|
|
210
|
+
*/
|
|
211
|
+
extraExtensions?: EditorExtension[];
|
|
212
|
+
/**
|
|
213
|
+
* Extra toolbar entries, and where they go. `after` names a built-in id
|
|
214
|
+
* (`heading`, `highlight`, `strike`, `image`…); omit it to append at the end.
|
|
215
|
+
*/
|
|
216
|
+
extraToolbar?: {
|
|
217
|
+
after?: string;
|
|
218
|
+
items: ToolbarItem[];
|
|
219
|
+
}[];
|
|
220
|
+
/** Merged on top of the built-in content styles. */
|
|
221
|
+
contentClassName?: string;
|
|
222
|
+
/** Allows data: URIs in images. Off by default: uploads belong in storage. */
|
|
223
|
+
allowBase64Images?: boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Merged into the editor's `editorProps`. For behaviour only a product can
|
|
226
|
+
* define — clamping pasted tables to a contract's row limit, say.
|
|
227
|
+
*
|
|
228
|
+
* `attributes` and `handleClick` are set by the hook and are not overridable:
|
|
229
|
+
* they carry the accessible name and the link shortcut, which are the
|
|
230
|
+
* defaults consumers were getting wrong by hand.
|
|
231
|
+
*/
|
|
232
|
+
editorProps?: Omit<NonNullable<EditorOptions['editorProps']>, 'attributes' | 'handleClick'>;
|
|
233
|
+
}
|
|
234
|
+
interface UseRichTextEditorResult {
|
|
235
|
+
editor: Editor | null;
|
|
236
|
+
/** Ready for `<RichTextEditor items={...} />`. */
|
|
237
|
+
toolbar: ToolbarItem[];
|
|
238
|
+
/** True when the caret has no selection, so a new link needs its own text. */
|
|
239
|
+
linkNeedsText: boolean;
|
|
240
|
+
/** Reads the caret's current href — pre-fill the dialog with it. */
|
|
241
|
+
currentLinkHref: () => string;
|
|
242
|
+
/** Applies a link, inserting `text` when there is no selection to wrap. */
|
|
243
|
+
applyLink: (href: string, text?: string) => void;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Builds a configured Tiptap editor and its toolbar.
|
|
247
|
+
*
|
|
248
|
+
* Everything a rich text editor needs to behave correctly is set up here —
|
|
249
|
+
* Ctrl/Cmd-click on links, the accessible name for the editable area, the
|
|
250
|
+
* repaint-on-transaction the toolbar's pressed state depends on, the content
|
|
251
|
+
* styles — so a consumer cannot end up with a subtly different editor by
|
|
252
|
+
* forgetting one of them.
|
|
253
|
+
*
|
|
254
|
+
* What stays with the consumer is what only it can know: the marks its document
|
|
255
|
+
* contract allows, and the copy. Both arrive as options.
|
|
256
|
+
*/
|
|
257
|
+
declare function useRichTextEditor({ labels, onUpdate, content, onInsertLink, onInsertImage, extraExtensions, extraToolbar, contentClassName, allowBase64Images, editorProps, }: UseRichTextEditorOptions): UseRichTextEditorResult;
|
|
258
|
+
|
|
167
259
|
/**
|
|
168
260
|
* One entry in the palette.
|
|
169
261
|
*
|
|
@@ -315,4 +407,4 @@ interface ResizableImageOptions {
|
|
|
315
407
|
*/
|
|
316
408
|
declare function createResizableImage(options: ResizableImageOptions): _tiptap_core.Node<ImageOptions & ResizableImageOptions, any>;
|
|
317
409
|
|
|
318
|
-
export { ColorMenu, type ColorMenuLabels, type ColorMenuProps, type ColorSwatch, EDITOR_CONTENT_STYLE, InsertImageDialog, type InsertImageDialogLabels, type InsertImageDialogProps, InsertLinkDialog, type InsertLinkDialogLabels, type InsertLinkDialogProps, LinkBubbleMenu, type LinkBubbleMenuLabels, type LinkBubbleMenuProps, ListMenu, type ListMenuProps, type ListOption, type ResizableImageOptions, RichTextEditor, type RichTextEditorProps, RichTextToolbar, type RichTextToolbarProps, TableMenu, type TableMenuLabels, type TableMenuProps, type ToolbarItem, createResizableImage };
|
|
410
|
+
export { ColorMenu, type ColorMenuLabels, type ColorMenuProps, type ColorSwatch, EDITOR_CONTENT_STYLE, InsertImageDialog, type InsertImageDialogLabels, type InsertImageDialogProps, InsertLinkDialog, type InsertLinkDialogLabels, type InsertLinkDialogProps, LinkBubbleMenu, type LinkBubbleMenuLabels, type LinkBubbleMenuProps, ListMenu, type ListMenuProps, type ListOption, type ResizableImageOptions, RichTextEditor, type RichTextEditorLabels, type RichTextEditorProps, RichTextToolbar, type RichTextToolbarProps, TableMenu, type TableMenuLabels, type TableMenuProps, type ToolbarItem, type UseRichTextEditorOptions, type UseRichTextEditorResult, createResizableImage, useRichTextEditor };
|
package/dist/editor.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { Editor } from '@tiptap/react';
|
|
3
|
+
import { Editor, JSONContent, EditorOptions } from '@tiptap/react';
|
|
4
4
|
import * as _tiptap_core from '@tiptap/core';
|
|
5
5
|
import { ImageOptions } from '@tiptap/extension-image';
|
|
6
6
|
|
|
@@ -164,6 +164,98 @@ interface InsertImageDialogProps {
|
|
|
164
164
|
*/
|
|
165
165
|
declare function InsertImageDialog({ open, onOpenChange, labels, url, onUrlChange, alt, onAltChange, file, onFileChange, uploading, onApply, onCancel, removable, onRemove, maxSizeBytes, accept, }: InsertImageDialogProps): react.JSX.Element;
|
|
166
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Whatever `useEditor` accepts in its `extensions` array.
|
|
169
|
+
*
|
|
170
|
+
* Derived from Tiptap's own option rather than imported as AnyExtension: the
|
|
171
|
+
* name resolves to a structurally different declaration depending on which copy
|
|
172
|
+
* of @tiptap/core is in scope, and the two do not assign to each other.
|
|
173
|
+
*/
|
|
174
|
+
type EditorExtension = EditorOptions['extensions'][number];
|
|
175
|
+
/** Every string the built-in toolbar and menus need. All already translated. */
|
|
176
|
+
interface RichTextEditorLabels {
|
|
177
|
+
/** Names the editable area for assistive tech. Required — it has no visible label. */
|
|
178
|
+
editor: string;
|
|
179
|
+
bold: string;
|
|
180
|
+
italic: string;
|
|
181
|
+
heading: string;
|
|
182
|
+
underline: string;
|
|
183
|
+
strikethrough: string;
|
|
184
|
+
quote: string;
|
|
185
|
+
insertLink: string;
|
|
186
|
+
insertImage: string;
|
|
187
|
+
resizeImage: string;
|
|
188
|
+
lists: {
|
|
189
|
+
trigger: string;
|
|
190
|
+
bullet: string;
|
|
191
|
+
ordered: string;
|
|
192
|
+
};
|
|
193
|
+
table: TableMenuLabels;
|
|
194
|
+
highlight: string;
|
|
195
|
+
}
|
|
196
|
+
interface UseRichTextEditorOptions {
|
|
197
|
+
labels: RichTextEditorLabels;
|
|
198
|
+
/** Fires on every document change, with the current ProseMirror JSON. */
|
|
199
|
+
onUpdate?: (doc: JSONContent) => void;
|
|
200
|
+
/** Initial document. */
|
|
201
|
+
content?: JSONContent | string;
|
|
202
|
+
/** Opens the consumer's link dialog. Wire the toolbar's link button to it. */
|
|
203
|
+
onInsertLink?: () => void;
|
|
204
|
+
/** Opens the consumer's image dialog. */
|
|
205
|
+
onInsertImage?: () => void;
|
|
206
|
+
/**
|
|
207
|
+
* Marks and nodes this product's document contract requires — a brand font,
|
|
208
|
+
* a colour palette, anything a server-side whitelist validates. They are
|
|
209
|
+
* appended to the built-in set rather than replacing it.
|
|
210
|
+
*/
|
|
211
|
+
extraExtensions?: EditorExtension[];
|
|
212
|
+
/**
|
|
213
|
+
* Extra toolbar entries, and where they go. `after` names a built-in id
|
|
214
|
+
* (`heading`, `highlight`, `strike`, `image`…); omit it to append at the end.
|
|
215
|
+
*/
|
|
216
|
+
extraToolbar?: {
|
|
217
|
+
after?: string;
|
|
218
|
+
items: ToolbarItem[];
|
|
219
|
+
}[];
|
|
220
|
+
/** Merged on top of the built-in content styles. */
|
|
221
|
+
contentClassName?: string;
|
|
222
|
+
/** Allows data: URIs in images. Off by default: uploads belong in storage. */
|
|
223
|
+
allowBase64Images?: boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Merged into the editor's `editorProps`. For behaviour only a product can
|
|
226
|
+
* define — clamping pasted tables to a contract's row limit, say.
|
|
227
|
+
*
|
|
228
|
+
* `attributes` and `handleClick` are set by the hook and are not overridable:
|
|
229
|
+
* they carry the accessible name and the link shortcut, which are the
|
|
230
|
+
* defaults consumers were getting wrong by hand.
|
|
231
|
+
*/
|
|
232
|
+
editorProps?: Omit<NonNullable<EditorOptions['editorProps']>, 'attributes' | 'handleClick'>;
|
|
233
|
+
}
|
|
234
|
+
interface UseRichTextEditorResult {
|
|
235
|
+
editor: Editor | null;
|
|
236
|
+
/** Ready for `<RichTextEditor items={...} />`. */
|
|
237
|
+
toolbar: ToolbarItem[];
|
|
238
|
+
/** True when the caret has no selection, so a new link needs its own text. */
|
|
239
|
+
linkNeedsText: boolean;
|
|
240
|
+
/** Reads the caret's current href — pre-fill the dialog with it. */
|
|
241
|
+
currentLinkHref: () => string;
|
|
242
|
+
/** Applies a link, inserting `text` when there is no selection to wrap. */
|
|
243
|
+
applyLink: (href: string, text?: string) => void;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Builds a configured Tiptap editor and its toolbar.
|
|
247
|
+
*
|
|
248
|
+
* Everything a rich text editor needs to behave correctly is set up here —
|
|
249
|
+
* Ctrl/Cmd-click on links, the accessible name for the editable area, the
|
|
250
|
+
* repaint-on-transaction the toolbar's pressed state depends on, the content
|
|
251
|
+
* styles — so a consumer cannot end up with a subtly different editor by
|
|
252
|
+
* forgetting one of them.
|
|
253
|
+
*
|
|
254
|
+
* What stays with the consumer is what only it can know: the marks its document
|
|
255
|
+
* contract allows, and the copy. Both arrive as options.
|
|
256
|
+
*/
|
|
257
|
+
declare function useRichTextEditor({ labels, onUpdate, content, onInsertLink, onInsertImage, extraExtensions, extraToolbar, contentClassName, allowBase64Images, editorProps, }: UseRichTextEditorOptions): UseRichTextEditorResult;
|
|
258
|
+
|
|
167
259
|
/**
|
|
168
260
|
* One entry in the palette.
|
|
169
261
|
*
|
|
@@ -315,4 +407,4 @@ interface ResizableImageOptions {
|
|
|
315
407
|
*/
|
|
316
408
|
declare function createResizableImage(options: ResizableImageOptions): _tiptap_core.Node<ImageOptions & ResizableImageOptions, any>;
|
|
317
409
|
|
|
318
|
-
export { ColorMenu, type ColorMenuLabels, type ColorMenuProps, type ColorSwatch, EDITOR_CONTENT_STYLE, InsertImageDialog, type InsertImageDialogLabels, type InsertImageDialogProps, InsertLinkDialog, type InsertLinkDialogLabels, type InsertLinkDialogProps, LinkBubbleMenu, type LinkBubbleMenuLabels, type LinkBubbleMenuProps, ListMenu, type ListMenuProps, type ListOption, type ResizableImageOptions, RichTextEditor, type RichTextEditorProps, RichTextToolbar, type RichTextToolbarProps, TableMenu, type TableMenuLabels, type TableMenuProps, type ToolbarItem, createResizableImage };
|
|
410
|
+
export { ColorMenu, type ColorMenuLabels, type ColorMenuProps, type ColorSwatch, EDITOR_CONTENT_STYLE, InsertImageDialog, type InsertImageDialogLabels, type InsertImageDialogProps, InsertLinkDialog, type InsertLinkDialogLabels, type InsertLinkDialogProps, LinkBubbleMenu, type LinkBubbleMenuLabels, type LinkBubbleMenuProps, ListMenu, type ListMenuProps, type ListOption, type ResizableImageOptions, RichTextEditor, type RichTextEditorLabels, type RichTextEditorProps, RichTextToolbar, type RichTextToolbarProps, TableMenu, type TableMenuLabels, type TableMenuProps, type ToolbarItem, type UseRichTextEditorOptions, type UseRichTextEditorResult, createResizableImage, useRichTextEditor };
|