@bayonai/rich-text-editor 0.1.2 → 1.0.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/BEHAVIOR.md +396 -0
- package/CHANGELOG.md +22 -0
- package/README.md +25 -6
- package/dist/core/blockTree.d.ts +14 -0
- package/dist/core/blockTree.js +126 -0
- package/dist/core/blockTypes.d.ts +6 -0
- package/dist/core/blockTypes.js +5 -0
- package/dist/core/exportImport.d.ts +59 -0
- package/dist/core/exportImport.js +51 -0
- package/dist/core/features.d.ts +59 -0
- package/dist/core/features.js +57 -0
- package/dist/core/imageBlockDiagnostics.d.ts +4 -0
- package/dist/core/imageBlockDiagnostics.js +19 -0
- package/dist/core/proFeatures.d.ts +60 -0
- package/dist/core/proFeatures.js +64 -0
- package/dist/{richText.d.ts → core/richText.d.ts} +2 -0
- package/dist/core/richText.js +566 -0
- package/dist/core/types.d.ts +78 -0
- package/dist/index.d.ts +14 -8
- package/dist/index.js +8 -5
- package/dist/react/editor/RichTextBody.d.ts +28 -0
- package/dist/react/editor/RichTextBody.js +131 -0
- package/dist/react/editor/RichTextEditor.d.ts +138 -0
- package/dist/react/editor/RichTextEditor.js +2925 -0
- package/dist/react/editor/RichTextRenderedBlock.d.ts +20 -0
- package/dist/react/editor/RichTextRenderedBlock.js +162 -0
- package/dist/react/editor/RichTextRenderer.d.ts +13 -0
- package/dist/react/editor/RichTextRenderer.js +16 -0
- package/dist/react/{RichTextTitleInput.d.ts → editor/RichTextTitleInput.d.ts} +11 -1
- package/dist/react/{RichTextTitleInput.js → editor/RichTextTitleInput.js} +17 -2
- package/dist/react/editor/blockActions.d.ts +48 -0
- package/dist/react/editor/blockActions.js +495 -0
- package/dist/react/editor/editorHistory.d.ts +55 -0
- package/dist/react/editor/editorHistory.js +111 -0
- package/dist/react/{editorNavigation.d.ts → editor/editorNavigation.d.ts} +2 -0
- package/dist/react/{editorNavigation.js → editor/editorNavigation.js} +16 -0
- package/dist/react/editor/editorOperations.d.ts +10 -0
- package/dist/react/editor/editorOperations.js +3 -0
- package/dist/react/editor/editorSelection.d.ts +3 -0
- package/dist/react/editor/editorSelection.js +215 -0
- package/dist/react/{editorShortcuts.d.ts → editor/editorShortcuts.d.ts} +10 -0
- package/dist/react/{editorShortcuts.js → editor/editorShortcuts.js} +17 -1
- package/dist/react/{RichTextIcons.d.ts → icons/RichTextIcons.d.ts} +3 -0
- package/dist/react/{RichTextIcons.js → icons/RichTextIcons.js} +9 -0
- package/dist/react/index.d.ts +12 -9
- package/dist/react/index.js +7 -6
- package/dist/react/{EditorSessionProvider.d.ts → session/EditorSessionProvider.d.ts} +2 -2
- package/dist/react/{EditorSessionProvider.js → session/EditorSessionProvider.js} +3 -3
- package/dist/react/{UnsavedChangesDialog.js → session/UnsavedChangesDialog.js} +1 -1
- package/dist/react/styles/RichTextStyles.js +1362 -0
- package/dist/react/{BlockActionTool.d.ts → tools/BlockActionTool.d.ts} +1 -1
- package/dist/react/{BlockActionTool.js → tools/BlockActionTool.js} +6 -2
- package/dist/react/tools/LinkCreationInput.d.ts +9 -0
- package/dist/react/tools/LinkCreationInput.js +38 -0
- package/dist/react/{SelectionFormatToolbar.d.ts → tools/SelectionFormatToolbar.d.ts} +3 -2
- package/dist/react/{SelectionFormatToolbar.js → tools/SelectionFormatToolbar.js} +3 -3
- package/dist/react/tools/SpecialBlockOption.d.ts +9 -0
- package/dist/react/tools/SpecialBlockOption.js +8 -0
- package/dist/react/tools/SpecialBlockTool.d.ts +91 -0
- package/dist/react/tools/SpecialBlockTool.js +125 -0
- package/dist/react/{TranscriptionControl.d.ts → tools/TranscriptionControl.d.ts} +9 -0
- package/dist/react/{TranscriptionControl.js → tools/TranscriptionControl.js} +70 -9
- package/dist/react/tools/blockActionToolState.d.ts +41 -0
- package/dist/react/tools/blockActionToolState.js +177 -0
- package/dist/react/tools/imageBlockDiagnostics.d.ts +2 -0
- package/dist/react/tools/imageBlockDiagnostics.js +12 -0
- package/dist/{session.d.ts → session/session.d.ts} +1 -1
- package/dist-cjs/core/blockTree.js +137 -0
- package/dist-cjs/core/blockTypes.js +9 -0
- package/dist-cjs/core/exportImport.js +56 -0
- package/dist-cjs/core/features.js +62 -0
- package/dist-cjs/core/proFeatures.js +70 -0
- package/dist-cjs/core/richText.js +578 -0
- package/dist-cjs/index.js +22 -6
- package/dist-cjs/react/editor/RichTextBody.js +134 -0
- package/dist-cjs/react/editor/RichTextEditor.js +2956 -0
- package/dist-cjs/react/editor/RichTextRenderedBlock.js +166 -0
- package/dist-cjs/react/editor/RichTextRenderer.js +20 -0
- package/dist-cjs/react/{RichTextTitleInput.js → editor/RichTextTitleInput.js} +18 -2
- package/dist-cjs/react/editor/blockActions.js +518 -0
- package/dist-cjs/react/editor/editorHistory.js +120 -0
- package/dist-cjs/react/{editorNavigation.js → editor/editorNavigation.js} +17 -0
- package/dist-cjs/react/editor/editorOperations.js +6 -0
- package/dist-cjs/react/editor/editorSelection.js +219 -0
- package/dist-cjs/react/{editorShortcuts.js → editor/editorShortcuts.js} +17 -1
- package/dist-cjs/react/{RichTextIcons.js → icons/RichTextIcons.js} +12 -0
- package/dist-cjs/react/index.js +9 -7
- package/dist-cjs/react/{EditorSessionProvider.js → session/EditorSessionProvider.js} +3 -3
- package/dist-cjs/react/{UnsavedChangesDialog.js → session/UnsavedChangesDialog.js} +1 -1
- package/dist-cjs/react/styles/RichTextStyles.js +1365 -0
- package/dist-cjs/react/{BlockActionTool.js → tools/BlockActionTool.js} +6 -2
- package/dist-cjs/react/tools/LinkCreationInput.js +41 -0
- package/dist-cjs/react/{SelectionFormatToolbar.js → tools/SelectionFormatToolbar.js} +3 -3
- package/dist-cjs/react/tools/SpecialBlockOption.js +11 -0
- package/dist-cjs/react/tools/SpecialBlockTool.js +129 -0
- package/dist-cjs/react/{TranscriptionControl.js → tools/TranscriptionControl.js} +71 -9
- package/dist-cjs/react/tools/blockActionToolState.js +186 -0
- package/package.json +3 -2
- package/dist/react/RichTextBody.d.ts +0 -18
- package/dist/react/RichTextBody.js +0 -66
- package/dist/react/RichTextEditor.d.ts +0 -45
- package/dist/react/RichTextEditor.js +0 -1096
- package/dist/react/RichTextRenderedBlock.d.ts +0 -4
- package/dist/react/RichTextRenderedBlock.js +0 -36
- package/dist/react/RichTextRenderer.d.ts +0 -4
- package/dist/react/RichTextRenderer.js +0 -8
- package/dist/react/RichTextStyles.js +0 -719
- package/dist/react/SpecialBlockOption.d.ts +0 -7
- package/dist/react/SpecialBlockOption.js +0 -7
- package/dist/react/SpecialBlockTool.d.ts +0 -42
- package/dist/react/SpecialBlockTool.js +0 -50
- package/dist/react/blockActionToolState.d.ts +0 -18
- package/dist/react/blockActionToolState.js +0 -53
- package/dist/react/blockActions.d.ts +0 -8
- package/dist/react/blockActions.js +0 -111
- package/dist/richText.js +0 -297
- package/dist/types.d.ts +0 -34
- package/dist-cjs/react/RichTextBody.js +0 -69
- package/dist-cjs/react/RichTextEditor.js +0 -1108
- package/dist-cjs/react/RichTextRenderedBlock.js +0 -39
- package/dist-cjs/react/RichTextRenderer.js +0 -11
- package/dist-cjs/react/RichTextStyles.js +0 -722
- package/dist-cjs/react/SpecialBlockOption.js +0 -10
- package/dist-cjs/react/SpecialBlockTool.js +0 -54
- package/dist-cjs/react/blockActionToolState.js +0 -58
- package/dist-cjs/react/blockActions.js +0 -119
- package/dist-cjs/richText.js +0 -307
- /package/dist/{types.js → core/types.js} +0 -0
- /package/dist/{writingStats.d.ts → core/writingStats.d.ts} +0 -0
- /package/dist/{writingStats.js → core/writingStats.js} +0 -0
- /package/dist/react/{RichTextDocumentSurface.d.ts → editor/RichTextDocumentSurface.d.ts} +0 -0
- /package/dist/react/{RichTextDocumentSurface.js → editor/RichTextDocumentSurface.js} +0 -0
- /package/dist/react/{UnsavedChangesDialog.d.ts → session/UnsavedChangesDialog.d.ts} +0 -0
- /package/dist/react/{RichTextStyles.d.ts → styles/RichTextStyles.d.ts} +0 -0
- /package/dist/react/{richTextBlockStyles.d.ts → styles/richTextBlockStyles.d.ts} +0 -0
- /package/dist/react/{richTextBlockStyles.js → styles/richTextBlockStyles.js} +0 -0
- /package/dist/react/{specialBlockStyles.d.ts → styles/specialBlockStyles.d.ts} +0 -0
- /package/dist/react/{specialBlockStyles.js → styles/specialBlockStyles.js} +0 -0
- /package/dist/{saveControl.d.ts → session/saveControl.d.ts} +0 -0
- /package/dist/{saveControl.js → session/saveControl.js} +0 -0
- /package/dist/{session.js → session/session.js} +0 -0
- /package/dist/{sessionRegistry.d.ts → session/sessionRegistry.d.ts} +0 -0
- /package/dist/{sessionRegistry.js → session/sessionRegistry.js} +0 -0
- /package/dist-cjs/{types.js → core/types.js} +0 -0
- /package/dist-cjs/{writingStats.js → core/writingStats.js} +0 -0
- /package/dist-cjs/react/{RichTextDocumentSurface.js → editor/RichTextDocumentSurface.js} +0 -0
- /package/dist-cjs/react/{richTextBlockStyles.js → styles/richTextBlockStyles.js} +0 -0
- /package/dist-cjs/react/{specialBlockStyles.js → styles/specialBlockStyles.js} +0 -0
- /package/dist-cjs/{saveControl.js → session/saveControl.js} +0 -0
- /package/dist-cjs/{session.js → session/session.js} +0 -0
- /package/dist-cjs/{sessionRegistry.js → session/sessionRegistry.js} +0 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
import { type EditorKeyboardShortcutCommand } from "./editorNavigation";
|
|
3
|
+
type RichTextBodyProps = {
|
|
4
|
+
bodyRef: RefObject<HTMLDivElement | null>;
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
label: string;
|
|
7
|
+
onBackspace: () => boolean;
|
|
8
|
+
onDelete: () => boolean;
|
|
9
|
+
onEnter: (event: {
|
|
10
|
+
shiftKey: boolean;
|
|
11
|
+
}) => boolean;
|
|
12
|
+
onFocus: () => void;
|
|
13
|
+
onImageAlignChange: (blockId: string, alignment: "center" | "left" | "right") => void;
|
|
14
|
+
onImageCustomWidthChange: (blockId: string, width: number) => void;
|
|
15
|
+
onImageSizeChange: (blockId: string, displaySize: "small" | "medium" | "full" | "custom") => void;
|
|
16
|
+
onInput: () => void;
|
|
17
|
+
onPasteText: (text: string) => boolean;
|
|
18
|
+
onRedo: () => boolean;
|
|
19
|
+
onSelectionChange: () => void;
|
|
20
|
+
onShortcutCommand: (command: EditorKeyboardShortcutCommand) => void;
|
|
21
|
+
onTab: (event: {
|
|
22
|
+
shiftKey: boolean;
|
|
23
|
+
}) => boolean;
|
|
24
|
+
onToggleCollapse: (blockId: string) => void;
|
|
25
|
+
onUndo: () => boolean;
|
|
26
|
+
};
|
|
27
|
+
export declare function RichTextBody({ bodyRef, disabled, label, onBackspace, onDelete, onEnter, onFocus, onImageAlignChange, onImageCustomWidthChange, onImageSizeChange, onInput, onPasteText, onRedo, onSelectionChange, onShortcutCommand, onTab, onToggleCollapse, onUndo, }: RichTextBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { getEditorHistoryShortcut, getCodeBlockSelectionTarget, getEditorKeyboardShortcut, isSelectAllShortcut, } from "./editorNavigation.js";
|
|
4
|
+
// Renders the editable rich-text body and reports input and selection changes.
|
|
5
|
+
export function RichTextBody({ bodyRef, disabled, label, onBackspace, onDelete, onEnter, onFocus, onImageAlignChange, onImageCustomWidthChange, onImageSizeChange, onInput, onPasteText, onRedo, onSelectionChange, onShortcutCommand, onTab, onToggleCollapse, onUndo, }) {
|
|
6
|
+
return (_jsx("div", { "aria-label": label, className: "bayon-rte-body", contentEditable: !disabled, "data-placeholder": "Tell your story...", dir: "auto", onBlur: onSelectionChange, onClick: (event) => {
|
|
7
|
+
const imageAlignButton = event.target instanceof Element
|
|
8
|
+
? event.target.closest("[data-image-align-action]")
|
|
9
|
+
: null;
|
|
10
|
+
if (imageAlignButton instanceof HTMLElement) {
|
|
11
|
+
const alignment = imageAlignButton.getAttribute("data-image-align-action");
|
|
12
|
+
const blockId = imageAlignButton
|
|
13
|
+
.closest("[data-block-id]")
|
|
14
|
+
?.getAttribute("data-block-id");
|
|
15
|
+
if (blockId &&
|
|
16
|
+
(alignment === "left" ||
|
|
17
|
+
alignment === "center" ||
|
|
18
|
+
alignment === "right")) {
|
|
19
|
+
event.preventDefault();
|
|
20
|
+
onImageAlignChange(blockId, alignment);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const imageSizeButton = event.target instanceof Element
|
|
25
|
+
? event.target.closest("[data-image-size-action]")
|
|
26
|
+
: null;
|
|
27
|
+
if (imageSizeButton instanceof HTMLElement) {
|
|
28
|
+
const displaySize = imageSizeButton.getAttribute("data-image-size-action");
|
|
29
|
+
const blockId = imageSizeButton
|
|
30
|
+
.closest("[data-block-id]")
|
|
31
|
+
?.getAttribute("data-block-id");
|
|
32
|
+
if (blockId &&
|
|
33
|
+
(displaySize === "small" ||
|
|
34
|
+
displaySize === "medium" ||
|
|
35
|
+
displaySize === "full" ||
|
|
36
|
+
displaySize === "custom")) {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
onImageSizeChange(blockId, displaySize);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const toggleButton = event.target instanceof Element
|
|
43
|
+
? event.target.closest("[data-toggle-collapse]")
|
|
44
|
+
: null;
|
|
45
|
+
if (toggleButton instanceof HTMLElement) {
|
|
46
|
+
const blockId = toggleButton
|
|
47
|
+
.closest("[data-block-id]")
|
|
48
|
+
?.getAttribute("data-block-id");
|
|
49
|
+
if (blockId) {
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
onToggleCollapse(blockId);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (event.target instanceof HTMLInputElement &&
|
|
56
|
+
event.target.type === "checkbox") {
|
|
57
|
+
onInput();
|
|
58
|
+
}
|
|
59
|
+
}, onFocus: onFocus, onInput: (event) => {
|
|
60
|
+
if (event.target instanceof HTMLInputElement &&
|
|
61
|
+
event.target.hasAttribute("data-image-custom-width-action")) {
|
|
62
|
+
const blockId = event.target
|
|
63
|
+
.closest("[data-block-id]")
|
|
64
|
+
?.getAttribute("data-block-id");
|
|
65
|
+
const width = Number(event.target.value);
|
|
66
|
+
if (blockId && Number.isFinite(width)) {
|
|
67
|
+
onImageCustomWidthChange(blockId, width);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
onInput();
|
|
72
|
+
}, onKeyDown: (event) => {
|
|
73
|
+
const historyShortcut = getEditorHistoryShortcut(event);
|
|
74
|
+
if (historyShortcut === "undo") {
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
onUndo();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (historyShortcut === "redo") {
|
|
80
|
+
event.preventDefault();
|
|
81
|
+
onRedo();
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (isSelectAllShortcut(event)) {
|
|
85
|
+
const code = getCodeBlockSelectionTarget(event.currentTarget, window.getSelection());
|
|
86
|
+
if (code) {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
selectElementContents(code);
|
|
89
|
+
onSelectionChange();
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (event.key === "Enter" && onEnter(event)) {
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (event.key === "Backspace" && onBackspace()) {
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (event.key === "Delete" && onDelete()) {
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (event.key === "Tab" && onTab(event)) {
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const shortcutCommand = getEditorKeyboardShortcut(event);
|
|
110
|
+
if (shortcutCommand) {
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
onShortcutCommand(shortcutCommand);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
}, onKeyUp: onSelectionChange, onMouseUp: onSelectionChange, onPaste: (event) => {
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
const text = event.clipboardData.getData("text/plain");
|
|
118
|
+
if (onPasteText(text)) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
document.execCommand("insertText", false, text);
|
|
122
|
+
onInput();
|
|
123
|
+
}, ref: bodyRef, role: "textbox", suppressContentEditableWarning: true, tabIndex: disabled ? -1 : 0 }));
|
|
124
|
+
}
|
|
125
|
+
function selectElementContents(element) {
|
|
126
|
+
const range = document.createRange();
|
|
127
|
+
range.selectNodeContents(element);
|
|
128
|
+
const selection = window.getSelection();
|
|
129
|
+
selection?.removeAllRanges();
|
|
130
|
+
selection?.addRange(range);
|
|
131
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { type RichTextDocumentSurfaceBackground } from "./RichTextDocumentSurface";
|
|
2
|
+
import { type BlockDropPlacement } from "../editor/blockActions";
|
|
3
|
+
import { type BlockActionToolPlacement } from "../tools/blockActionToolState";
|
|
4
|
+
import { type RichTextEditorEntitlements, type RichTextFeatureGate, type RichTextLockedFeatureMode } from "../../core/features";
|
|
5
|
+
import type { RichTextBlock } from "../../core/types";
|
|
6
|
+
import { type RichTextHistorySnapshot } from "./editorHistory";
|
|
7
|
+
export type { RichTextHistoryLabel, RichTextHistoryMetadata, RichTextHistorySnapshot, RichTextHistorySnapshotEntry, } from "./editorHistory";
|
|
8
|
+
type SelectionToolbarPlacement = "above" | "below";
|
|
9
|
+
type SelectionToolbarRect = Pick<DOMRect, "bottom" | "height" | "left" | "top" | "width">;
|
|
10
|
+
type SelectionToolbarBodyRect = Pick<DOMRect, "bottom" | "left" | "top">;
|
|
11
|
+
type SelectionToolbarPositionInput = {
|
|
12
|
+
bodyClientWidth: number;
|
|
13
|
+
bodyRect: SelectionToolbarBodyRect;
|
|
14
|
+
rangeRect: SelectionToolbarRect;
|
|
15
|
+
scrollTop: number;
|
|
16
|
+
};
|
|
17
|
+
export type RichTextEditorBehavior = {
|
|
18
|
+
blockActions?: boolean;
|
|
19
|
+
specialBlocks?: boolean;
|
|
20
|
+
textBlockShortcuts?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export type ResolvedRichTextEditorBehavior = Required<RichTextEditorBehavior>;
|
|
23
|
+
export declare const defaultRichTextEditorBehavior: {
|
|
24
|
+
blockActions: true;
|
|
25
|
+
specialBlocks: true;
|
|
26
|
+
textBlockShortcuts: true;
|
|
27
|
+
};
|
|
28
|
+
export declare function resolveRichTextEditorBehavior(behavior?: RichTextEditorBehavior): ResolvedRichTextEditorBehavior;
|
|
29
|
+
type RichTextEditorProps = {
|
|
30
|
+
behavior?: RichTextEditorBehavior;
|
|
31
|
+
bodyLabel: string;
|
|
32
|
+
contentBlocks: RichTextBlock[];
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
documentBackground?: RichTextDocumentSurfaceBackground;
|
|
35
|
+
features?: RichTextEditorEntitlements;
|
|
36
|
+
helperText?: string;
|
|
37
|
+
imageUpload?: RichTextImageUploadHandler;
|
|
38
|
+
lockedFeatureMode?: RichTextLockedFeatureMode;
|
|
39
|
+
onFeatureGate?: (gate: RichTextFeatureGate) => void;
|
|
40
|
+
onContentBlocksChange: (value: RichTextBlock[], change?: RichTextContentChange) => void;
|
|
41
|
+
onHistoryControlsChange?: (controls: RichTextHistoryControls) => void;
|
|
42
|
+
onHistorySnapshotChange?: (snapshot: RichTextHistorySnapshot) => void;
|
|
43
|
+
onTitleChange: (value: string) => void;
|
|
44
|
+
required?: boolean;
|
|
45
|
+
title: string;
|
|
46
|
+
titleLabel: string;
|
|
47
|
+
titleValidationMessage?: string;
|
|
48
|
+
transcriptionEnabled?: boolean;
|
|
49
|
+
transcriptionLanguage?: string;
|
|
50
|
+
transcriptionPortalContainer?: HTMLElement | null;
|
|
51
|
+
};
|
|
52
|
+
export type RichTextContentChange = {
|
|
53
|
+
reason: "image-upload-complete" | "toggle-collapse";
|
|
54
|
+
};
|
|
55
|
+
export type RichTextHistoryControls = {
|
|
56
|
+
canRedo: boolean;
|
|
57
|
+
canUndo: boolean;
|
|
58
|
+
redo: () => boolean;
|
|
59
|
+
undo: () => boolean;
|
|
60
|
+
};
|
|
61
|
+
export type RichTextImageUploadResult = {
|
|
62
|
+
alt?: string;
|
|
63
|
+
url: string;
|
|
64
|
+
};
|
|
65
|
+
type RichTextImageAlignment = "center" | "left" | "right";
|
|
66
|
+
export type RichTextImageUploadHandler = (input: {
|
|
67
|
+
file: File;
|
|
68
|
+
onProgress?: (percentage: number) => void;
|
|
69
|
+
}) => Promise<RichTextImageUploadResult>;
|
|
70
|
+
export declare function RichTextEditor({ behavior, bodyLabel, contentBlocks, disabled, documentBackground, features, helperText, imageUpload, lockedFeatureMode, onFeatureGate, onContentBlocksChange, onHistoryControlsChange, onHistorySnapshotChange, onTitleChange, required, title, titleLabel, titleValidationMessage, transcriptionEnabled, transcriptionLanguage, transcriptionPortalContainer, }: RichTextEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
71
|
+
export declare function getBlockActionAnchorSelector(blockType: RichTextBlock["type"]): "" | "[data-rich-text-image]";
|
|
72
|
+
export declare function getDragIndicatorPosition(placements: BlockActionToolPlacement[], dropTarget: {
|
|
73
|
+
placement: BlockDropPlacement;
|
|
74
|
+
targetBlockId: string;
|
|
75
|
+
}): {
|
|
76
|
+
left: number;
|
|
77
|
+
top: number;
|
|
78
|
+
} | null;
|
|
79
|
+
export declare function getTreeRowBackspaceMarkdown(type: "bullet" | "ordered" | "checkbox" | "toggle"): "" | "1." | "[ ]" | "*";
|
|
80
|
+
export declare function getTreeRowBackspaceFocusPosition(type: "bullet" | "ordered" | "checkbox" | "toggle"): "end" | "start";
|
|
81
|
+
export declare function getTreeRowBackspaceParagraphMarkdown(type: "bullet" | "ordered" | "checkbox" | "toggle", currentMarkdown: string): string;
|
|
82
|
+
export declare function getTreeRowBackspaceFocusPositionForMarkdown(markdown: string): "end" | "start";
|
|
83
|
+
export declare function getTreeRowBackspaceFocusPositionForParagraph(type: "bullet" | "ordered" | "checkbox" | "toggle", currentMarkdown: string): "end" | "start";
|
|
84
|
+
export declare function canBackspaceEmptyToggleTitle(block: RichTextBlock | null | undefined): boolean;
|
|
85
|
+
export declare function areBlockActionToolPlacementsEqual(previousPlacements: BlockActionToolPlacement[], nextPlacements: BlockActionToolPlacement[]): boolean;
|
|
86
|
+
export declare function getDeletionFocusTarget(blocks: RichTextBlock[], blockId: string): {
|
|
87
|
+
blockId: string;
|
|
88
|
+
position: "end";
|
|
89
|
+
} | {
|
|
90
|
+
blockId: string;
|
|
91
|
+
position: "start";
|
|
92
|
+
} | undefined;
|
|
93
|
+
export declare function getEditorHtmlForRichTextBlocks(blocks: RichTextBlock[]): string;
|
|
94
|
+
export declare function buildUploadedImageBlock(upload: RichTextImageUploadResult, options?: {
|
|
95
|
+
alignment?: RichTextImageAlignment;
|
|
96
|
+
id?: string;
|
|
97
|
+
}): RichTextBlock;
|
|
98
|
+
export declare function buildUploadingImageBlock(input: {
|
|
99
|
+
alignment?: RichTextImageAlignment;
|
|
100
|
+
fileName?: string;
|
|
101
|
+
id?: string;
|
|
102
|
+
progress?: number;
|
|
103
|
+
}): RichTextBlock;
|
|
104
|
+
export declare function getImageUploadProgressMessage(progress: number): string;
|
|
105
|
+
export declare function getImageUploadFailureMessage(error: unknown): string;
|
|
106
|
+
export declare function normalizeSoftBreakHtml(html: string): string;
|
|
107
|
+
export declare function hasEditableTrailingWhitespace(value: string): boolean;
|
|
108
|
+
export declare function shouldDelayTypographyNormalization(value: string): boolean;
|
|
109
|
+
export declare function splitTreeRowMarkdownAtTextOffset(markdown: string, offset: number): {
|
|
110
|
+
after: string;
|
|
111
|
+
before: string;
|
|
112
|
+
};
|
|
113
|
+
export declare const splitCheckboxMarkdownAtTextOffset: typeof splitTreeRowMarkdownAtTextOffset;
|
|
114
|
+
export declare function getCheckboxEnterAction(event: {
|
|
115
|
+
shiftKey: boolean;
|
|
116
|
+
}): "line-break" | "next-checkbox";
|
|
117
|
+
export declare function shouldPadTrailingLineBreak(textAfterCursor: string): boolean;
|
|
118
|
+
export declare function resolveTranscriptionConfig(config?: {
|
|
119
|
+
enabled?: boolean;
|
|
120
|
+
language?: string;
|
|
121
|
+
}): {
|
|
122
|
+
enabled: boolean;
|
|
123
|
+
language: string | undefined;
|
|
124
|
+
};
|
|
125
|
+
export declare function appendTranscriptText(currentText: string, transcript: string): string;
|
|
126
|
+
export declare function shouldRefreshEditorBodyHtml(body: HTMLElement, editableHtml: string, nextBlocks: RichTextBlock[]): boolean;
|
|
127
|
+
type ScrollPositionTarget = {
|
|
128
|
+
requestAnimationFrame?: (callback: () => void) => number;
|
|
129
|
+
scrollTo: (x: number, y: number) => void;
|
|
130
|
+
scrollX: number;
|
|
131
|
+
scrollY: number;
|
|
132
|
+
};
|
|
133
|
+
export declare function restoreScrollPositionAfter(scrollTarget: ScrollPositionTarget, callback: () => void): void;
|
|
134
|
+
export declare function getSelectionToolbarPosition({ bodyClientWidth, bodyRect, rangeRect, scrollTop, }: SelectionToolbarPositionInput): {
|
|
135
|
+
left: number;
|
|
136
|
+
placement: SelectionToolbarPlacement;
|
|
137
|
+
top: number;
|
|
138
|
+
};
|