@baseline-ui/core 0.62.0 → 0.63.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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { ReactNode, AriaAttributes, DOMAttributes as DOMAttributes$1, AriaRole, CSSProperties, HTMLAttributeAnchorTarget, HTMLAttributeReferrerPolicy, ClipboardEventHandler, CompositionEventHandler, ReactEventHandler, FormEventHandler, MouseEventHandler, TouchEventHandler, PointerEventHandler, UIEventHandler, WheelEventHandler, AnimationEventHandler, TransitionEventHandler, ReactElement, MouseEvent, FocusEvent, SyntheticEvent, KeyboardEvent as KeyboardEvent$2, JSX, HTMLAttributes, RefObject as RefObject$1, LabelHTMLAttributes, ElementType, JSXElementConstructor, ButtonHTMLAttributes, AnchorHTMLAttributes, InputHTMLAttributes, SVGProps, MutableRefObject, Key as Key$1, Dispatch, SetStateAction, Ref } from 'react';
2
+ import React__default, { ReactNode, AriaAttributes, DOMAttributes as DOMAttributes$1, AriaRole, CSSProperties, HTMLAttributeAnchorTarget, HTMLAttributeReferrerPolicy, ClipboardEventHandler, CompositionEventHandler, ReactEventHandler, FormEventHandler, MouseEventHandler, TouchEventHandler, PointerEventHandler, UIEventHandler, WheelEventHandler, AnimationEventHandler, TransitionEventHandler, ReactElement, MouseEvent, FocusEvent, SyntheticEvent, KeyboardEvent as KeyboardEvent$2, JSX, HTMLAttributes, RefObject as RefObject$1, LabelHTMLAttributes, ElementType, JSXElementConstructor, ButtonHTMLAttributes, AnchorHTMLAttributes, InputHTMLAttributes, SVGProps, MutableRefObject, Key as Key$1, Ref, KeyboardEventHandler, Dispatch, SetStateAction } from 'react';
3
3
  import { Theme, Sprinkles } from '@baseline-ui/tokens';
4
4
  import { PanelImperativeHandle, PanelProps as PanelProps$1, SeparatorProps as SeparatorProps$2 } from 'react-resizable-panels';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -5755,10 +5755,6 @@ declare function classNames(...args: any[]): string;
5755
5755
  /**
5756
5756
  * Returns the HTMLElement from a string selector, HTMLElement, or React
5757
5757
  * RefObject.
5758
- *
5759
- * @param element - A string selector, HTMLElement, or React RefObject.
5760
- * @param ownerDocument - The document to use for the querySelector call.
5761
- * @returns The HTMLElement or null if not found.
5762
5758
  */
5763
5759
  declare function getHTMLElement(element: string | HTMLElement | React__default.RefObject<HTMLElement> | null | undefined, ownerDocument: Document): HTMLElement | null | undefined;
5764
5760
  interface FontProperties {
@@ -5781,17 +5777,13 @@ interface FontProperties {
5781
5777
  * });
5782
5778
  * ```
5783
5779
  *
5784
- * @param options - The options for calculating the text dimensions.
5785
- * @param options.text - The text to measure.
5786
- * @param options.fontSize - The font size in pixels. Defaults to 16.
5787
- * @param options.fontFamily - The font family. Defaults to 'Arial'.
5788
- * @param options.fontWeight - The font weight. Defaults to 'normal'.
5789
- * @param options.fontStyle - The font style. Defaults to 'normal'.
5790
- * @param options.font - The full font string. Overrides fontSize, fontFamily,
5791
- * fontWeight, and fontStyle.
5780
+ * @param options.element - A reference element whose owner document is used to
5781
+ * create the measuring canvas (required for correct results inside iframes).
5782
+ * Falls back to the global document when omitted.
5792
5783
  */
5793
- declare function getTextDimensions({ text, fontSize, fontFamily, fontWeight, fontStyle, font, }: {
5784
+ declare function getTextDimensions({ text, fontSize, fontFamily, fontWeight, fontStyle, font, element, }: {
5794
5785
  text: string;
5786
+ element?: Element | null;
5795
5787
  } & FontProperties): {
5796
5788
  width: number;
5797
5789
  height: number;
@@ -5811,51 +5803,32 @@ declare function getTextDimensions({ text, fontSize, fontFamily, fontWeight, fon
5811
5803
  * fontStyle: "normal",
5812
5804
  * });
5813
5805
  *
5814
- * @param options - The options for calculating the font size.
5815
- * @param options.text - The text to fit within the width.
5816
- * @param options.maxWidth - The maximum width the text should fit within.
5817
- * @param options.initialFontSize - The starting font size to use for
5818
- * calculations. Defaults to 50.
5819
- * @param options.fontFamily - The font family to use. Defaults to 'Arial'.
5820
- * @param options.fontWeight - The font weight to use. Defaults to 'normal'.
5821
- * @param options.fontStyle - The font style to use. Defaults to 'normal'.
5822
- * @returns The calculated font size that fits the text within the given width.
5806
+ * @param options.element - A reference element whose owner document is used to
5807
+ * create the measuring canvas. Falls back to the global document when
5808
+ * omitted.
5823
5809
  */
5824
- declare function calculateFontSizeToFitWidth({ text, maxWidth, initialFontSize, fontFamily, fontWeight, fontStyle, }: {
5810
+ declare function calculateFontSizeToFitWidth({ text, maxWidth, initialFontSize, fontFamily, fontWeight, fontStyle, element, }: {
5825
5811
  text: string;
5826
5812
  maxWidth: number;
5827
5813
  initialFontSize: number;
5814
+ element?: Element | null;
5828
5815
  } & Omit<FontProperties, "fontSize">): number;
5829
- /**
5830
- * Returns true if the element is focusable.
5831
- *
5832
- * @param element - The element to check.
5833
- */
5834
5816
  declare function isFocusableElement(element: HTMLElement): boolean;
5835
5817
  declare function findFocusableElements(element: HTMLElement): NodeListOf<Element>;
5836
5818
  /**
5837
- * Returns the active element of the given node. If the node is within a shadow
5838
- * root, the active element of the shadow root will be returned, otherwise the
5839
- * active element of the document will be returned.
5840
- *
5841
- * @param node - The node to get the active element from.
5842
- * @returns The active element of the given node.
5819
+ * Returns the active element of the given node, resolving through a shadow root
5820
+ * when the node lives in one.
5843
5821
  */
5844
5822
  declare function getActiveElement(node?: Node): Element | null;
5845
5823
  /**
5846
5824
  * Returns true if the target is an input that will cause the software keyboard
5847
5825
  * to appear.
5848
- *
5849
- * @param target Element - The element to check.
5850
5826
  */
5851
5827
  declare function isInputThatOpensKeyboard(target: Element): boolean;
5852
5828
  /**
5853
5829
  * Returns the absolute bounds of the element. If the element is within a shadow
5854
5830
  * root, the bounds will be relative to the host element. If the element is not
5855
5831
  * within a shadow root, the bounds will be relative to the document.
5856
- *
5857
- * @param element - The element to get the absolute bounds of.
5858
- * @returns The absolute bounds of the element.
5859
5832
  */
5860
5833
  declare function getAbsoluteBounds(element: HTMLElement): {
5861
5834
  x: number;
@@ -5868,10 +5841,6 @@ declare function getAbsoluteBounds(element: HTMLElement): {
5868
5841
  * position: fixed. If the element is within a shadow root, the position will be
5869
5842
  * relative to the host element so that the element can be positioned correctly
5870
5843
  * within the shadow root.
5871
- *
5872
- * @param element - The element to get the absolute position of.
5873
- * @param coordinates - The coordinates of the element.
5874
- * @returns The absolute position of the element.
5875
5844
  */
5876
5845
  declare function getAbsolutePosition(element: HTMLElement, coordinates?: {
5877
5846
  x: number;
@@ -5926,11 +5895,19 @@ declare function booleanOrObjectToConfig<T extends Record<string, unknown>>(valu
5926
5895
  * ```ts
5927
5896
  * lightenColor("#000000", 10); // #1a1a1a
5928
5897
  * ```
5929
- *
5930
- * @param color
5931
- * @param percent
5932
5898
  */
5933
5899
  declare function lightenColor(color: string, percent: number): string;
5900
+ /**
5901
+ * Compare two (possibly undefined) CSS color strings by value rather than by
5902
+ * serialized form. Browsers normalize colors when they round-trip through the
5903
+ * DOM — `#ac0000` reads back as `rgb(172, 0, 0)`, `rgba(255, 0, 0, 1)` as
5904
+ * `rgb(255, 0, 0)` — so a raw-string compare would treat the same color as
5905
+ * different. Both sides are canonicalized via React Aria's {@link Color}; a
5906
+ * value React Aria cannot parse (a CSS named color, or an invalid value) is
5907
+ * compared by exact string instead — so it matches only an identical string
5908
+ * and never a real, parseable color.
5909
+ */
5910
+ declare function areColorsEqual(a: string | undefined, b: string | undefined): boolean;
5934
5911
 
5935
5912
  /**
5936
5913
  * Checks whether the given value is a valid URL.
@@ -8441,9 +8418,19 @@ interface EditorProps extends StylingProps, AriaLabelingProps {
8441
8418
  * the Cancel button will not be rendered.
8442
8419
  */
8443
8420
  onCancel?: () => void;
8444
- /** The default value of the editor. */
8421
+ /**
8422
+ * The initial value of the editor (uncontrolled). The editor manages its
8423
+ * own state afterwards; later changes to this prop are ignored.
8424
+ */
8445
8425
  defaultValue?: string;
8446
- /** The value of the editor. */
8426
+ /**
8427
+ * The value of the editor (controlled). Provide together with `onChange`;
8428
+ * later changes to this prop update the editor content.
8429
+ *
8430
+ * Backwards compatibility: in rich text mode, `value` without `onChange`
8431
+ * behaves like `defaultValue` (initial content only), matching the
8432
+ * behavior of earlier versions.
8433
+ */
8447
8434
  value?: string;
8448
8435
  /**
8449
8436
  * The function to be called when the value of the editor changes.
@@ -8574,6 +8561,444 @@ interface EditorProps extends StylingProps, AriaLabelingProps {
8574
8561
 
8575
8562
  declare const Editor: React__default.MemoExoticComponent<React__default.ForwardRefExoticComponent<EditorProps & React__default.RefAttributes<HTMLDivElement>>>;
8576
8563
 
8564
+ declare const PARAGRAPH: "p";
8565
+ declare const LINK: "a";
8566
+ declare const MENTION: "mention";
8567
+ declare const MENTION_INPUT: "mention_input";
8568
+ interface RichTextEditorText {
8569
+ text: string;
8570
+ bold?: boolean;
8571
+ italic?: boolean;
8572
+ underline?: boolean;
8573
+ color?: string;
8574
+ backgroundColor?: string;
8575
+ }
8576
+ interface RichTextEditorLink {
8577
+ type: typeof LINK;
8578
+ url: string;
8579
+ children: RichTextEditorText[];
8580
+ }
8581
+ interface RichTextEditorMention {
8582
+ type: typeof MENTION;
8583
+ value: string;
8584
+ displayName: string;
8585
+ children: [RichTextEditorText];
8586
+ }
8587
+ interface RichTextEditorMentionInput {
8588
+ type: typeof MENTION_INPUT;
8589
+ children: [RichTextEditorText];
8590
+ }
8591
+ type RichTextEditorInline = RichTextEditorText | RichTextEditorLink | RichTextEditorMention | RichTextEditorMentionInput;
8592
+ interface RichTextEditorParagraph {
8593
+ type: typeof PARAGRAPH;
8594
+ children: RichTextEditorInline[];
8595
+ }
8596
+ type RichTextEditorDoc = RichTextEditorParagraph[];
8597
+
8598
+ interface ModelPoint {
8599
+ /** [paragraphIndex, inlineIndex within paragraph.children] */
8600
+ path: [number, number];
8601
+ /** Character offset within that inline node's text. */
8602
+ offset: number;
8603
+ }
8604
+ interface ModelRange {
8605
+ anchor: ModelPoint;
8606
+ focus: ModelPoint;
8607
+ }
8608
+
8609
+ type MarkName = "bold" | "italic" | "underline";
8610
+ /** Marks shared by all text content covered by a range. */
8611
+ interface ActiveMarks {
8612
+ bold?: true;
8613
+ italic?: true;
8614
+ underline?: true;
8615
+ color?: string;
8616
+ backgroundColor?: string;
8617
+ }
8618
+
8619
+ /**
8620
+ * EditorCore.ts — framework-free orchestrator for the rich-text editor.
8621
+ *
8622
+ * Wires DOM events on a contenteditable host element to the pure command/model
8623
+ * modules. React is responsible for rendering the host element and toolbar;
8624
+ * EditorCore owns the document state.
8625
+ *
8626
+ * Design notes
8627
+ * ─────────────
8628
+ * - setValue() does NOT record history — external controlled updates are not
8629
+ * user edits.
8630
+ * - No global `document` or `window` access; everything goes through
8631
+ * `el.ownerDocument` / `el.getRootNode()`.
8632
+ * - renderDoc() during edits/sync is guarded against running mid-IME-composition
8633
+ * (the one-time attach-time render predates any composition, so it is exempt).
8634
+ * - Identity-diffing: commands that return the same `doc` reference are no-ops.
8635
+ */
8636
+
8637
+ interface SelectionState {
8638
+ /** Active marks at the current selection (merged with pendingMarks). */
8639
+ marks: ActiveMarks;
8640
+ /** Link covering (or touching) the current selection range, if any. */
8641
+ link: {
8642
+ url: string;
8643
+ range: ModelRange;
8644
+ } | null;
8645
+ /** Current model selection range. */
8646
+ range: ModelRange | null;
8647
+ }
8648
+ interface EditorCoreOptions {
8649
+ /** Called after each user-visible document change; receives serialized HTML. */
8650
+ onChange?: (html: string) => void;
8651
+ /** Called when the selection changes. */
8652
+ onSelectionChange?: (state: SelectionState) => void;
8653
+ /**
8654
+ * Called when "@" at an appropriate position creates a mention_input.
8655
+ * The React layer is expected to open its mention dropdown in response.
8656
+ */
8657
+ onMentionTrigger?: () => void;
8658
+ /**
8659
+ * Called when a doc replacement (a controlled `setValue`) removes an open
8660
+ * mention_input without going through the normal cancel/confirm path. The
8661
+ * React layer must close its dropdown — the orphaned anchor fires no blur.
8662
+ */
8663
+ onMentionInputRemoved?: () => void;
8664
+ /**
8665
+ * When this returns false, typing "@" does not start the mention flow and
8666
+ * the character is inserted natively (e.g. no mentionable users configured).
8667
+ */
8668
+ canStartMention?: () => boolean;
8669
+ /** When this returns true all mutation inputs are blocked (preventDefault'd). */
8670
+ isReadOnly?: () => boolean;
8671
+ /**
8672
+ * Whether the built-in formatting (bold/italic/underline) and history
8673
+ * (undo/redo) shortcuts are active. When this returns false, the matching
8674
+ * native `beforeinput` intents (`formatBold`, `historyUndo`, …) are still
8675
+ * blocked from mutating the DOM but no longer toggle marks or move history —
8676
+ * leaving a consumer free to wire their own. Defaults to enabled.
8677
+ */
8678
+ areKeyboardShortcutsEnabled?: () => boolean;
8679
+ }
8680
+ /** Names of commands that EditorCore can dispatch via exec(). */
8681
+ type CommandName = "toggleMark" | "setMarkValue" | "wrapLink" | "updateLinkUrl" | "unwrapLink" | "deleteRange" | "insertText" | "insertFragment" | "insertSoftBreak" | "insertMentionInput" | "confirmMention" | "removeMentionInput";
8682
+ /** Argument tuple for each command (beyond doc + range which are implicit). */
8683
+ interface CommandArgs {
8684
+ toggleMark: [mark: MarkName];
8685
+ setMarkValue: [key: "color" | "backgroundColor", value?: string];
8686
+ wrapLink: [url: string];
8687
+ updateLinkUrl: [url: string];
8688
+ unwrapLink: [];
8689
+ deleteRange: [];
8690
+ insertText: [text: string];
8691
+ insertFragment: [fragment: RichTextEditorDoc];
8692
+ insertSoftBreak: [];
8693
+ insertMentionInput: [];
8694
+ confirmMention: [user: {
8695
+ id: string;
8696
+ displayName: string;
8697
+ }];
8698
+ removeMentionInput: [restoreText: string];
8699
+ }
8700
+ declare class EditorCore {
8701
+ private doc;
8702
+ /** The last serialized HTML known to us (including setValue calls). */
8703
+ private lastKnownHtml;
8704
+ private cachedRange;
8705
+ private composing;
8706
+ private pending;
8707
+ /**
8708
+ * Number of upcoming selectionchange events that must NOT clear pending marks.
8709
+ *
8710
+ * handleSelectionChange normally clears pending the moment the caret leaves
8711
+ * pending.caretOffset. But a single user keystroke (and insertSoftBreak)
8712
+ * triggers our own writeSelection, which the browser reports back as one or
8713
+ * more selectionchange events — and in shadow DOM (notably Chromium and
8714
+ * Firefox) one of those can arrive with the post-keystroke caret offset before
8715
+ * syncFromDom has updated pending.caretOffset to match. Without this guard,
8716
+ * that transient mismatch clears pending mid-typing, the toolbar flips off,
8717
+ * and the next character is no longer colored. We absorb a small burst of
8718
+ * these self-inflicted events (a single boolean is not enough — shadow DOM can
8719
+ * emit several per action) and re-sync caretOffset to the real caret as they
8720
+ * arrive, so a genuine later caret move still clears pending correctly.
8721
+ *
8722
+ * Confirmed load-bearing: removing it makes the shadow-DOM "color buttons stay
8723
+ * active while typing" CT flake/time out in Chromium.
8724
+ */
8725
+ private preservePendingSelectionChanges;
8726
+ private history;
8727
+ private opts;
8728
+ private el;
8729
+ private pendingExternalRender;
8730
+ private keyboardShortcutsOverride;
8731
+ constructor(opts?: EditorCoreOptions);
8732
+ /**
8733
+ * Sets a per-element keyboard-shortcut override. `undefined` clears it and
8734
+ * restores the editor-level {@link EditorCoreOptions.areKeyboardShortcutsEnabled}.
8735
+ */
8736
+ setKeyboardShortcutsEnabled(enabled: boolean | undefined): void;
8737
+ /**
8738
+ * Renders the current doc into `el`, attaches event listeners and returns a
8739
+ * cleanup function that removes them. Calling attach() a second time without
8740
+ * first calling the returned cleanup is undefined behaviour.
8741
+ */
8742
+ attach(el: HTMLElement): () => void;
8743
+ private readonly handleBeforeInputBound;
8744
+ private readonly handleInputBound;
8745
+ private readonly handlePointerDownBound;
8746
+ private readonly handleCompositionStartBound;
8747
+ private readonly handleCompositionEndBound;
8748
+ private readonly handleSelectionChangeBound;
8749
+ /**
8750
+ * Synchronously refreshes cachedRange from the live DOM selection when that
8751
+ * selection is inside the editor. Leaves cachedRange untouched when the
8752
+ * selection is elsewhere (dialogs, toolbar popovers) or unreadable.
8753
+ */
8754
+ private refreshSelectionFromDom;
8755
+ getDoc(): RichTextEditorDoc;
8756
+ getValue(): string;
8757
+ /**
8758
+ * Sets the document from an HTML string (controlled entry point).
8759
+ *
8760
+ * SKIPS (no-op) when `html` matches the last known serialized value to
8761
+ * break controlled-value loops. Never emits onChange unless `emit: true`.
8762
+ *
8763
+ * NOTE: Does not record history — see module-level design notes.
8764
+ */
8765
+ setValue(html: string, opts?: {
8766
+ emit?: boolean;
8767
+ }): void;
8768
+ private static docHasMentionInput;
8769
+ /**
8770
+ * Dispatches a named command at the current selection.
8771
+ *
8772
+ * Identity-diff: if the command returns the same `doc` reference (no-op),
8773
+ * nothing changes — except for `toggleMark` on a collapsed selection, which
8774
+ * sets pendingMarks and emits onSelectionChange.
8775
+ */
8776
+ exec<K extends CommandName>(name: K, ...args: CommandArgs[K]): void;
8777
+ undo(): void;
8778
+ redo(): void;
8779
+ canUndo(): boolean;
8780
+ canRedo(): boolean;
8781
+ focus(): void;
8782
+ setCaretPosition(absoluteOffset: number): void;
8783
+ /**
8784
+ * Restores a model selection: focuses the editor and writes the range to
8785
+ * both the DOM and cachedRange. Used by toolbar popovers (e.g. the color
8786
+ * picker) that captured the selection before taking focus — on Firefox,
8787
+ * refocusing a contenteditable collapses its DOM selection, so the range
8788
+ * must be re-applied explicitly before dispatching a command.
8789
+ */
8790
+ select(range: ModelRange): void;
8791
+ selectStart(): void;
8792
+ selectEnd(): void;
8793
+ getSelectionState(): SelectionState;
8794
+ private buildSelectionState;
8795
+ private mergePendingMarks;
8796
+ /**
8797
+ * Toggle a pending boolean mark for the collapsed-caret case.
8798
+ *
8799
+ * We store the FULL effective marks snapshot (base + toggle) so that
8800
+ * applyPendingMarks can apply them directly to the just-typed range.
8801
+ * Toggling the same mark a second time returns to the base state.
8802
+ */
8803
+ private setPendingMark;
8804
+ /**
8805
+ * Set or clear a pending color/backgroundColor mark for the collapsed-caret case.
8806
+ * `value === undefined` removes that key from the pending snapshot.
8807
+ */
8808
+ private setPendingColorMark;
8809
+ private emitSelectionChange;
8810
+ /**
8811
+ * Applies a doc+range change, re-renders if attached, emits events.
8812
+ */
8813
+ private applyDocChange;
8814
+ private handleBeforeInput;
8815
+ /**
8816
+ * Returns true when the current caret position is preceded by a word boundary
8817
+ * (or is at the start of a paragraph), matching the pattern /^$|^[\s"']$/.
8818
+ */
8819
+ private shouldTriggerMention;
8820
+ private lastCharOf;
8821
+ private handlePasteInput;
8822
+ /**
8823
+ * Called after an `input` event (or compositionend). Reads the current DOM
8824
+ * back into a model doc and reconciles with internal state.
8825
+ */
8826
+ private syncFromDom;
8827
+ /**
8828
+ * Apply pending marks to the text that was just typed.
8829
+ *
8830
+ * The just-typed range is determined by diffing the pre-input caret absolute
8831
+ * offset against the post-input caret absolute offset.
8832
+ */
8833
+ private applyPendingMarks;
8834
+ /**
8835
+ * Applies the pending mark snapshot to the [preOffset, postOffset] range,
8836
+ * re-deriving the range from absolute offsets before each command (commands
8837
+ * may split nodes and stale a ModelRange). Returns the resulting doc by
8838
+ * identity when no mark changed.
8839
+ */
8840
+ private applyPendingMarkSnapshot;
8841
+ private handleSelectionChange;
8842
+ private dispatchCommand;
8843
+ private collapsedAtDocEnd;
8844
+ private rangesEqual;
8845
+ }
8846
+
8847
+ /**
8848
+ * Public types for the headless editor binding layer.
8849
+ *
8850
+ * The `EditorState` handle is the entire API: all reading (selection, value)
8851
+ * and acting (focus, commands, marks) happens on it. Hooks and the provider
8852
+ * only create the handle or deliver it to a component — they never wrap what
8853
+ * the handle can already do.
8854
+ */
8855
+
8856
+ /**
8857
+ * A live handle to one editor instance. Reactive fields (`selectionState`,
8858
+ * `value`, `isEmpty`, `canUndo`, `canRedo`, `isDisabled`) update across renders;
8859
+ * the methods are stable passthroughs to the underlying {@link EditorCore}.
8860
+ */
8861
+ interface EditorState {
8862
+ /** The underlying framework-free engine (escape hatch). */
8863
+ core: EditorCore;
8864
+ /** Active marks, link, and range at the current selection. */
8865
+ selectionState: SelectionState;
8866
+ /**
8867
+ * Current value as a string. In controlled mode this mirrors the consumer's
8868
+ * (possibly unnormalized) `value` prop; for the engine's own normalized
8869
+ * serialization use {@link getValue}.
8870
+ */
8871
+ value: string;
8872
+ /** Whether the document is empty (drives placeholder visibility). */
8873
+ isEmpty: boolean;
8874
+ /** Whether the editor is read-only. */
8875
+ isDisabled: boolean;
8876
+ /** Whether built-in formatting/history keyboard shortcuts are enabled. */
8877
+ keyboardShortcuts: boolean;
8878
+ canUndo: boolean;
8879
+ canRedo: boolean;
8880
+ focus: EditorCore["focus"];
8881
+ selectStart: EditorCore["selectStart"];
8882
+ selectEnd: EditorCore["selectEnd"];
8883
+ setCaretPosition: EditorCore["setCaretPosition"];
8884
+ undo: EditorCore["undo"];
8885
+ redo: EditorCore["redo"];
8886
+ getValue: EditorCore["getValue"];
8887
+ setValue: EditorCore["setValue"];
8888
+ exec: EditorCore["exec"];
8889
+ /** Whether `mark` is active at the current selection. */
8890
+ isMarkActive: (mark: MarkName) => boolean;
8891
+ /** Toggle a boolean mark (bold/italic/underline). */
8892
+ toggleMark: (mark: MarkName) => void;
8893
+ /** Set or clear a color mark; omit `value` to clear. */
8894
+ setMark: (key: "color" | "backgroundColor", value?: string) => void;
8895
+ }
8896
+ /**
8897
+ * Options for {@link useEditor}. Combines the engine callbacks with the
8898
+ * React-managed props the hook owns the lifecycle for.
8899
+ */
8900
+ interface UseEditorOptions extends Pick<EditorCoreOptions, "onChange" | "onSelectionChange" | "onMentionTrigger" | "onMentionInputRemoved" | "canStartMention" | "isReadOnly"> {
8901
+ /** Controlled value (provide with `onChange`). */
8902
+ value?: string;
8903
+ /** Initial value for uncontrolled use (applied once on mount). */
8904
+ defaultValue?: string;
8905
+ /** When true, the editor is read-only and selection is cleared. */
8906
+ isDisabled?: boolean;
8907
+ /**
8908
+ * Whether the built-in formatting (bold/italic/underline) and history
8909
+ * (undo/redo) keyboard shortcuts are active. Disable to wire your own.
8910
+ *
8911
+ * @default true
8912
+ */
8913
+ keyboardShortcuts?: boolean;
8914
+ }
8915
+
8916
+ /**
8917
+ * Creates and owns a single editor engine, wiring its React lifecycle:
8918
+ * controlled `value` sync, one-time `defaultValue` init, `isDisabled`
8919
+ * read-only handling, and reactive selection/value state. Returns the stable
8920
+ * {@link EditorState} handle — the entire editor API.
8921
+ *
8922
+ * The handle does not attach to the DOM; pass it to {@link useEditable} on the
8923
+ * element you want to make editable.
8924
+ */
8925
+ declare function useEditor(options?: UseEditorOptions): EditorState;
8926
+
8927
+ interface UseEditableOptions {
8928
+ /** A ref to merge with the internal element ref (e.g. for measuring/querying). */
8929
+ ref?: Ref<HTMLDivElement>;
8930
+ /**
8931
+ * Focus the element on mount, optionally positioning the caret at the
8932
+ * start/end. Runs after the engine attaches.
8933
+ */
8934
+ autoFocus?: boolean | "start" | "end";
8935
+ /**
8936
+ * App-specific key handling, invoked before the built-in shortcuts
8937
+ * (bold/italic/underline, undo/redo). Return `true` if the event was handled
8938
+ * to skip the built-ins.
8939
+ */
8940
+ onKeyDown?: (event: KeyboardEvent$1) => boolean | undefined;
8941
+ /**
8942
+ * Whether the built-in formatting/history shortcuts are active. Overrides the
8943
+ * editor's `keyboardShortcuts` setting for this element. Defaults to the
8944
+ * editor's setting (which itself defaults to enabled).
8945
+ */
8946
+ keyboardShortcuts?: boolean;
8947
+ }
8948
+ interface EditableProps {
8949
+ id: string;
8950
+ ref: Ref<HTMLDivElement>;
8951
+ contentEditable: boolean;
8952
+ suppressContentEditableWarning: true;
8953
+ role: "textbox";
8954
+ "aria-multiline": true;
8955
+ onKeyDown?: KeyboardEventHandler;
8956
+ onKeyUp?: KeyboardEventHandler;
8957
+ }
8958
+ /**
8959
+ * Applies the built-in formatting (Ctrl/Cmd+B/I/U) and history (Ctrl/Cmd+Z,
8960
+ * Shift+Z, Ctrl+Y) shortcuts to `editor`. Returns `true` (and calls
8961
+ * `preventDefault`) when the event matched a shortcut, so the caller can stop
8962
+ * further handling. Exported for direct use by custom keydown handlers.
8963
+ */
8964
+ declare function handleEditorShortcut(event: KeyboardEvent$1, editor: EditorState): boolean;
8965
+ /**
8966
+ * Returns `{ editableProps }` to spread on the HTML element you want to make
8967
+ * editable. Owns the element ref, the engine `attach()` lifecycle, the generic
8968
+ * formatting shortcuts (Ctrl/Cmd+B/I/U, undo/redo), and `autoFocus`.
8969
+ *
8970
+ * Pass the editor handle explicitly, or omit it to resolve the nearest
8971
+ * {@link EditorProvider}.
8972
+ */
8973
+ declare function useEditable(editor?: EditorState, options?: UseEditableOptions): {
8974
+ editableProps: EditableProps;
8975
+ };
8976
+
8977
+ interface EditorProviderProps {
8978
+ /** The editor handle returned by `useEditor`. */
8979
+ editor: EditorState;
8980
+ children: React__default.ReactNode;
8981
+ }
8982
+ /**
8983
+ * Shares one editor handle with its subtree. Wrap each editor's UI in its own
8984
+ * `EditorProvider`; hooks inside (`useEditable`, `useEditorContext`) resolve to
8985
+ * this editor via the nearest provider.
8986
+ */
8987
+ declare const EditorProvider: React__default.FC<EditorProviderProps>;
8988
+
8989
+ /**
8990
+ * EditorContext — shares one {@link EditorState} handle with a subtree so a
8991
+ * co-located toolbar can reach the editor without prop-drilling. One provider
8992
+ * per editor; nearest-wins resolution keeps multiple editors isolated.
8993
+ */
8994
+
8995
+ /**
8996
+ * Returns the {@link EditorState} from the nearest {@link EditorProvider}.
8997
+ * Throws if called outside a provider.
8998
+ */
8999
+ declare function useEditorContext(): EditorState;
9000
+ declare const EMPTY_SELECTION_STATE: SelectionState;
9001
+
8577
9002
  interface ScrollControlButtonProps extends StylingProps, Pick<ActionButtonProps, "label"> {
8578
9003
  /**
8579
9004
  * The ref to the scrollable element.
@@ -10365,5 +10790,5 @@ declare namespace reactStately {
10365
10790
  export type { reactStately_Color as Color, reactStately_ListData as ListData, reactStately_TreeData as TreeData };
10366
10791
  }
10367
10792
 
10368
- export { Accordion, AccordionItem, ActionButton, ActionGroup, ActionGroupItem, ActionIconButton, Actionable, AlertDialog, AudioPlayer, Autocomplete, Avatar, Box, ButtonSelect, Calendar, Cell, Checkbox, Code, ColorInput, ColorSwatch, ColorSwatchPicker, Column, ComboBox, DateField, DateFormat, DefaultListOption, DeviceProvider, DeviceProviderContext, Dialog, DialogTitle, Disclosure, DomNodeRenderer, Drawer, Editor, FileInput, FileList$1 as FileList, FileUpload, FocusScope, Focusable, FrameProvider, FreehandCanvas, GlobalToastRegion, GridLayout, GridList, Group, I18nProvider, Icon, IconColorInput, IconColorInputButton, IconSelect, IconSlider, ImageDropZone, ImageGallery, InlineAlert, Kbd, Link, ListBox, ListLayout, LocaleAwareGridLayout, Markdown, Menu, MessageFormat, Modal, ModalClose, ModalContent, ModalTrigger, NumberFormat, NumberInput, Pagination, Panel, PanelGroup, PanelResizeHandle, PointPicker, PointPickerContent, PointPickerDisplay, Popover, PopoverContent, PopoverTrigger, Portal, PortalContainerProvider, Pressable, Preview, ProgressBar, ProgressSpinner, REACT_ARIA_INCOMPATIBLE_KEYS, RadioGroup, RangeCalendar, Reaction, Row, ScrollControlButton, SearchInput, Select, Separator, Size, Skeleton, Slider, StatusCard, Stepper, Switch, TabItem, Table, TableBody, TableHeader, TableLayout, Tabs, Tag, TagGroup, TaggedPagination, Text, TextInput, ThemeProvider, TimeField, ToastQueue, ToggleButton, ToggleIconButton, Toolbar, Tooltip, TreeView, UNSAFE_ListBox, reactAria as UNSAFE_aria, reactStately as UNSAFE_stately, VIRTUALIZER_LAYOUT_DEFAULT_OPTIONS, Virtualizer, VisuallyHidden, WaterfallLayout, announce, booleanOrObjectToConfig, calculateFontSizeToFitWidth, capitalize, clamp, classNames, cleanKeyFromGlobImport, clearAnnouncer, defineMessages, destroyAnnouncer, devWarnOnce, directionVar, disableAnimations, enableAnimations, filterDOMProps, filterTruthyValues, findFocusableElements, getAbsoluteBounds, getAbsolutePosition, getActiveElement, getHTMLElement, getOsSpecificKeyboardShortcutLabel, getOwnerDocument, getPlainText, getSvgPathFromStroke, getTextDimensions, iconMap, invariant, isFocusableElement, isInIframe, isInShadowDOM, isInputThatOpensKeyboard, isInsideOverlayContent, isRect, isUrl, lightenColor, mergeProps, mergeRefs, parseColor, safeSpreadProps, useCollator, useDateFormatter, useDevice, useDragAndDrop, useFilter, useFocusRing, useFocusVisible, useFrameDimensions, useI18n, useId, useImage, useInteractionModality, useIntersectionObserver, useIsFirstRender, useKeyboard, useListData, useLiveInteractionModality, useLocalStorage, useLocale, useMutationObserver, useNumberFormatter, useObjectRef, usePointProximity, usePortalContainer, usePreventFocus, useResizeObserver, useTableDragAndDrop, useTextSelection, useUndoRedo, useUserPreferences };
10369
- export type { AccordionItemProps, AccordionProps, ActionButtonProps, ActionGroupProps, ActionIconButtonProps, ActionableProps, AlertDialogProps, AudioPlayerProps, AutocompleteProps, AvatarProps, BlockProps, BoundaryAxis, BoxProps, ButtonSelectProps, CalendarHeaderVariant, CalendarProps, CalendarSize, CellProps, CheckboxProps, CodeProps, ColorInputProps, ColorPreset, ColorSwatchPickerProps, ColorSwatchProps, ColumnProps, ComboBoxProps, DateFieldPickerType, DateFieldProps, DateFormatProps, Device, DeviceProviderProps, DialogProps, DialogTitleProps, DisclosureProps, DomNodeRendererProps, DrawerProps, EditorHandle, EditorProps, FileInputProps, FileListItem, FileListProps, FileUploadProps, FocusableProps, FrameProviderProps, FreehandCanvasProps, GridListProps, GroupProps, HorizontalBoundaryBehavior, I18nProviderProps, I18nResult, IconColorInputProps, IconComponentProps$1 as IconComponentProps, IconProps, IconSelectProps, IconSliderProps, ImageDropZoneProps, ImageGalleryProps, ImperativePanelGroupHandle, ImperativePanelHandle, InlineAlertProps, IntersectionObserverOptions, KbdProps, Key, LinkProps, ListBoxProps, ListHandle$1 as ListHandle, ListOption, MarkdownProps, MenuItem, MenuProps, MessageDescriptor, MessageFormatProps, MessageFormatter, ModalContentProps, ModalProps, NumberFormatProps, NumberInputProps, PaginationProps, PanelGroupProps, PanelProps, PanelResizeHandleProps, PointPickerContentProps, PointPickerDisplayProps, PointPickerProps, PopoverContentHandle, PopoverContentProps, PopoverProps, PopoverTriggerProps, PortalProps, PressEvent, PreviewProps, ProgressBarProps, ProgressSpinnerProps, RadioGroupProps, RangeCalendarProps, ReactAriaIncompatibleKey, ReactionProps, Rect, ResizeObserverOptions, RowProps, SVGRProps, SafeDOMAttributes, ScrollControlButtonProps, SearchInputProps, SelectProps, SeparatorProps, SetValue, SkeletonProps, SliderProps, StatusCardProps, StepperItem, StepperProps, StylingProps, SwitchProps, TabItemProps, TableBodyProps, TableHeaderProps, TableProps, TabsProps, TagGroupProps, TagProps, TagVariant, TaggedPaginationProps, TextInputProps, TextProps, TextSelectionProps, ThemeProviderProps, TimeFieldProps, ToastProps, ToggleButtonProps, ToggleIconButtonProps, ToolbarProps, TooltipProps, TreeListItem, TreeViewProps, UNSAFE_ListBoxProps, UseTableDragAndDropOptions, VirtualizerProps };
10793
+ export { Accordion, AccordionItem, ActionButton, ActionGroup, ActionGroupItem, ActionIconButton, Actionable, AlertDialog, AudioPlayer, Autocomplete, Avatar, Box, ButtonSelect, Calendar, Cell, Checkbox, Code, ColorInput, ColorSwatch, ColorSwatchPicker, Column, ComboBox, DateField, DateFormat, DefaultListOption, DeviceProvider, DeviceProviderContext, Dialog, DialogTitle, Disclosure, DomNodeRenderer, Drawer, EMPTY_SELECTION_STATE, Editor, EditorCore, EditorProvider, FileInput, FileList$1 as FileList, FileUpload, FocusScope, Focusable, FrameProvider, FreehandCanvas, GlobalToastRegion, GridLayout, GridList, Group, I18nProvider, Icon, IconColorInput, IconColorInputButton, IconSelect, IconSlider, ImageDropZone, ImageGallery, InlineAlert, Kbd, Link, ListBox, ListLayout, LocaleAwareGridLayout, Markdown, Menu, MessageFormat, Modal, ModalClose, ModalContent, ModalTrigger, NumberFormat, NumberInput, Pagination, Panel, PanelGroup, PanelResizeHandle, PointPicker, PointPickerContent, PointPickerDisplay, Popover, PopoverContent, PopoverTrigger, Portal, PortalContainerProvider, Pressable, Preview, ProgressBar, ProgressSpinner, REACT_ARIA_INCOMPATIBLE_KEYS, RadioGroup, RangeCalendar, Reaction, Row, ScrollControlButton, SearchInput, Select, Separator, Size, Skeleton, Slider, StatusCard, Stepper, Switch, TabItem, Table, TableBody, TableHeader, TableLayout, Tabs, Tag, TagGroup, TaggedPagination, Text, TextInput, ThemeProvider, TimeField, ToastQueue, ToggleButton, ToggleIconButton, Toolbar, Tooltip, TreeView, UNSAFE_ListBox, reactAria as UNSAFE_aria, reactStately as UNSAFE_stately, VIRTUALIZER_LAYOUT_DEFAULT_OPTIONS, Virtualizer, VisuallyHidden, WaterfallLayout, announce, areColorsEqual, booleanOrObjectToConfig, calculateFontSizeToFitWidth, capitalize, clamp, classNames, cleanKeyFromGlobImport, clearAnnouncer, defineMessages, destroyAnnouncer, devWarnOnce, directionVar, disableAnimations, enableAnimations, filterDOMProps, filterTruthyValues, findFocusableElements, getAbsoluteBounds, getAbsolutePosition, getActiveElement, getHTMLElement, getOsSpecificKeyboardShortcutLabel, getOwnerDocument, getPlainText, getSvgPathFromStroke, getTextDimensions, handleEditorShortcut, iconMap, invariant, isFocusableElement, isInIframe, isInShadowDOM, isInputThatOpensKeyboard, isInsideOverlayContent, isRect, isUrl, lightenColor, mergeProps, mergeRefs, parseColor, safeSpreadProps, useCollator, useDateFormatter, useDevice, useDragAndDrop, useEditable, useEditor, useEditorContext, useFilter, useFocusRing, useFocusVisible, useFrameDimensions, useI18n, useId, useImage, useInteractionModality, useIntersectionObserver, useIsFirstRender, useKeyboard, useListData, useLiveInteractionModality, useLocalStorage, useLocale, useMutationObserver, useNumberFormatter, useObjectRef, usePointProximity, usePortalContainer, usePreventFocus, useResizeObserver, useTableDragAndDrop, useTextSelection, useUndoRedo, useUserPreferences };
10794
+ export type { AccordionItemProps, AccordionProps, ActionButtonProps, ActionGroupProps, ActionIconButtonProps, ActionableProps, ActiveMarks, AlertDialogProps, AudioPlayerProps, AutocompleteProps, AvatarProps, BlockProps, BoundaryAxis, BoxProps, ButtonSelectProps, CalendarHeaderVariant, CalendarProps, CalendarSize, CellProps, CheckboxProps, CodeProps, ColorInputProps, ColorPreset, ColorSwatchPickerProps, ColorSwatchProps, ColumnProps, ComboBoxProps, CommandArgs, CommandName, DateFieldPickerType, DateFieldProps, DateFormatProps, Device, DeviceProviderProps, DialogProps, DialogTitleProps, DisclosureProps, DomNodeRendererProps, DrawerProps, EditableProps, EditorCoreOptions, EditorHandle, EditorProps, EditorProviderProps, EditorState, FileInputProps, FileListItem, FileListProps, FileUploadProps, FocusableProps, FrameProviderProps, FreehandCanvasProps, GridListProps, GroupProps, HorizontalBoundaryBehavior, I18nProviderProps, I18nResult, IconColorInputProps, IconComponentProps$1 as IconComponentProps, IconProps, IconSelectProps, IconSliderProps, ImageDropZoneProps, ImageGalleryProps, ImperativePanelGroupHandle, ImperativePanelHandle, InlineAlertProps, IntersectionObserverOptions, KbdProps, Key, LinkProps, ListBoxProps, ListHandle$1 as ListHandle, ListOption, MarkName, MarkdownProps, MenuItem, MenuProps, MessageDescriptor, MessageFormatProps, MessageFormatter, ModalContentProps, ModalProps, ModelPoint, ModelRange, NumberFormatProps, NumberInputProps, PaginationProps, PanelGroupProps, PanelProps, PanelResizeHandleProps, PointPickerContentProps, PointPickerDisplayProps, PointPickerProps, PopoverContentHandle, PopoverContentProps, PopoverProps, PopoverTriggerProps, PortalProps, PressEvent, PreviewProps, ProgressBarProps, ProgressSpinnerProps, RadioGroupProps, RangeCalendarProps, ReactAriaIncompatibleKey, ReactionProps, Rect, ResizeObserverOptions, RichTextEditorDoc, RichTextEditorInline, RichTextEditorLink, RichTextEditorMention, RichTextEditorMentionInput, RichTextEditorParagraph, RichTextEditorText, RowProps, SVGRProps, SafeDOMAttributes, ScrollControlButtonProps, SearchInputProps, SelectProps, SelectionState, SeparatorProps, SetValue, SkeletonProps, SliderProps, StatusCardProps, StepperItem, StepperProps, StylingProps, SwitchProps, TabItemProps, TableBodyProps, TableHeaderProps, TableProps, TabsProps, TagGroupProps, TagProps, TagVariant, TaggedPaginationProps, TextInputProps, TextProps, TextSelectionProps, ThemeProviderProps, TimeFieldProps, ToastProps, ToggleButtonProps, ToggleIconButtonProps, ToolbarProps, TooltipProps, TreeListItem, TreeViewProps, UNSAFE_ListBoxProps, UseEditableOptions, UseEditorOptions, UseTableDragAndDropOptions, VirtualizerProps };