@markput/react 0.10.1 → 0.12.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/index.d.ts CHANGED
@@ -1,6 +1,14 @@
1
+ import * as _$react from "react";
1
2
  import { CSSProperties, ComponentType, ElementType, ReactNode, Ref, RefObject } from "react";
2
3
  import * as _$react_jsx_runtime0 from "react/jsx-runtime";
3
4
 
5
+ //#region src/augment.d.ts
6
+ declare module '@markput/core' {
7
+ interface SlotRegistry {
8
+ default: ElementType;
9
+ }
10
+ } //# sourceMappingURL=augment.d.ts.map
11
+ //#endregion
4
12
  //#region ../../core/src/features/parsing/parser/constants.d.ts
5
13
  /**
6
14
  * Constants for ParserV2 - modern markup parser with nesting support
@@ -10758,7 +10766,7 @@ declare function denote(value: string, callback: (mark: MarkToken) => string, ma
10758
10766
  //#region ../../core/src/features/arrownav/ArrowNavFeature.d.ts
10759
10767
  declare class ArrowNavFeature {
10760
10768
  #private;
10761
- private store;
10769
+ private readonly store;
10762
10770
  constructor(store: Store);
10763
10771
  enable(): void;
10764
10772
  disable(): void;
@@ -10767,7 +10775,7 @@ declare class ArrowNavFeature {
10767
10775
  //#region ../../core/src/features/block-editing/BlockEditFeature.d.ts
10768
10776
  declare class BlockEditFeature {
10769
10777
  #private;
10770
- private store;
10778
+ private readonly store;
10771
10779
  constructor(store: Store);
10772
10780
  enable(): void;
10773
10781
  disable(): void;
@@ -10808,7 +10816,7 @@ declare class BlockRegistry {
10808
10816
  //#region ../../core/src/features/clipboard/CopyFeature.d.ts
10809
10817
  declare class CopyFeature {
10810
10818
  #private;
10811
- private store;
10819
+ private readonly store;
10812
10820
  constructor(store: Store);
10813
10821
  enable(): void;
10814
10822
  disable(): void;
@@ -10817,7 +10825,7 @@ declare class CopyFeature {
10817
10825
  //#region ../../core/src/features/drag/DragFeature.d.ts
10818
10826
  declare class DragFeature {
10819
10827
  #private;
10820
- private store;
10828
+ private readonly store;
10821
10829
  constructor(store: Store);
10822
10830
  enable(): void;
10823
10831
  disable(): void;
@@ -10826,7 +10834,7 @@ declare class DragFeature {
10826
10834
  //#region ../../core/src/features/editable/ContentEditableFeature.d.ts
10827
10835
  declare class ContentEditableFeature {
10828
10836
  #private;
10829
- private store;
10837
+ private readonly store;
10830
10838
  constructor(store: Store);
10831
10839
  enable(): void;
10832
10840
  disable(): void;
@@ -10836,7 +10844,7 @@ declare class ContentEditableFeature {
10836
10844
  //#region ../../core/src/features/events/SystemListenerFeature.d.ts
10837
10845
  declare class SystemListenerFeature {
10838
10846
  #private;
10839
- private store;
10847
+ private readonly store;
10840
10848
  constructor(store: Store);
10841
10849
  enable(): void;
10842
10850
  disable(): void;
@@ -10845,7 +10853,7 @@ declare class SystemListenerFeature {
10845
10853
  //#region ../../core/src/features/focus/FocusFeature.d.ts
10846
10854
  declare class FocusFeature {
10847
10855
  #private;
10848
- private store;
10856
+ private readonly store;
10849
10857
  constructor(store: Store);
10850
10858
  enable(): void;
10851
10859
  disable(): void;
@@ -10853,7 +10861,7 @@ declare class FocusFeature {
10853
10861
  //#endregion
10854
10862
  //#region ../../core/src/shared/classes/MarkputHandler.d.ts
10855
10863
  declare class MarkputHandler {
10856
- private store;
10864
+ private readonly store;
10857
10865
  constructor(store: Store);
10858
10866
  get container(): HTMLDivElement | null;
10859
10867
  get overlay(): HTMLElement | null;
@@ -10876,8 +10884,8 @@ declare class NodeProxy {
10876
10884
  get isSpan(): boolean;
10877
10885
  get isMark(): boolean;
10878
10886
  get isEditable(): boolean;
10879
- get isCaretAtBeginning(): boolean | undefined;
10880
- get isCaretAtEnd(): boolean | undefined;
10887
+ get isCaretAtBeginning(): boolean;
10888
+ get isCaretAtEnd(): boolean;
10881
10889
  get index(): number;
10882
10890
  get caret(): number;
10883
10891
  set caret(value: number);
@@ -10897,30 +10905,20 @@ declare class NodeProxy {
10897
10905
  interface Signal<T> {
10898
10906
  (): T;
10899
10907
  (value: T | undefined): void;
10900
- use(): T;
10901
10908
  }
10902
- /**
10903
- * Derives a plain-value object type from an object of signals.
10904
- * `{ foo: Signal<string>, bar: Signal<number> }` → `{ foo: string, bar: number }`
10905
- */
10906
- type SignalValues<T> = { [K in keyof T]: T[K] extends Signal<infer V> | Computed<infer V> ? V : never };
10909
+ type SignalValues<T> = { [K in keyof T]: T[K] extends Signal<infer V> | Computed<infer V> ? V : T[K] };
10907
10910
  interface Computed<T> {
10908
10911
  (): T;
10909
- use(): T;
10910
10912
  }
10911
10913
  interface Event<T = void> {
10912
- /** Emit — always fires even when payload reference is unchanged. */
10913
10914
  (payload: T): void;
10914
- /** Read/subscribe — auto-tracks inside effects. Returns latest payload or undefined. */
10915
10915
  read(): T | undefined;
10916
- /** Framework hook bridge. */
10917
- use(): T | undefined;
10918
10916
  }
10919
10917
  //#endregion
10920
10918
  //#region ../../core/src/features/input/InputFeature.d.ts
10921
10919
  declare class InputFeature {
10922
10920
  #private;
10923
- private store;
10921
+ private readonly store;
10924
10922
  constructor(store: Store);
10925
10923
  enable(): void;
10926
10924
  disable(): void;
@@ -10929,7 +10927,7 @@ declare class InputFeature {
10929
10927
  //#region ../../core/src/features/overlay/OverlayFeature.d.ts
10930
10928
  declare class OverlayFeature {
10931
10929
  #private;
10932
- private store;
10930
+ private readonly store;
10933
10931
  constructor(store: Store);
10934
10932
  enable(): void;
10935
10933
  disable(): void;
@@ -10938,23 +10936,30 @@ declare class OverlayFeature {
10938
10936
  //#region ../../core/src/features/parsing/ParseFeature.d.ts
10939
10937
  declare class ParseFeature {
10940
10938
  #private;
10941
- private store;
10939
+ private readonly store;
10942
10940
  constructor(store: Store);
10943
10941
  enable(): void;
10944
10942
  disable(): void;
10945
10943
  sync(): void;
10946
- hasChanged(): boolean;
10947
10944
  }
10948
10945
  //#endregion
10949
10946
  //#region ../../core/src/features/selection/TextSelectionFeature.d.ts
10950
10947
  declare class TextSelectionFeature {
10951
10948
  #private;
10952
- private store;
10949
+ private readonly store;
10953
10950
  constructor(store: Store);
10954
10951
  enable(): void;
10955
10952
  disable(): void;
10956
10953
  }
10957
10954
  //#endregion
10955
+ //#region ../../core/src/features/slots/types.d.ts
10956
+ interface MarkSlot {
10957
+ (): (token: Token) => readonly [Slot, Record<string, unknown>];
10958
+ }
10959
+ interface OverlaySlot {
10960
+ (): (option?: CoreOption, defaultComponent?: Slot) => readonly [Slot, Record<string, unknown>];
10961
+ }
10962
+ //#endregion
10958
10963
  //#region ../../core/src/store/Store.d.ts
10959
10964
  declare class Store {
10960
10965
  readonly key: KeyGenerator;
@@ -10963,70 +10968,71 @@ declare class Store {
10963
10968
  focus: NodeProxy;
10964
10969
  input: NodeProxy;
10965
10970
  };
10966
- readonly state: {
10967
- tokens: Signal<Token[]>;
10971
+ readonly props: {
10968
10972
  value: Signal<string | undefined>;
10969
10973
  defaultValue: Signal<string | undefined>;
10970
- previousValue: Signal<string | undefined>;
10971
- innerValue: Signal<string | undefined>;
10972
- recovery: Signal<Recovery | undefined>;
10973
- selecting: Signal<"drag" | "all" | undefined>;
10974
- drag: Signal<boolean | {
10975
- alwaysShowHandle: boolean;
10976
- }>;
10977
- overlayMatch: Signal<OverlayMatch | undefined>;
10978
- overlayTrigger: Signal<((option: CoreOption) => string | undefined) | undefined>;
10979
- showOverlayOn: Signal<OverlayTrigger>;
10980
10974
  onChange: Signal<((value: string) => void) | undefined>;
10981
10975
  options: Signal<CoreOption[]>;
10982
10976
  readOnly: Signal<boolean>;
10983
- Span: Signal<unknown>;
10984
- Mark: Signal<unknown>;
10985
- Overlay: Signal<unknown>;
10977
+ layout: Signal<"inline" | "block">;
10978
+ draggable: Signal<boolean | DraggableConfig>;
10979
+ showOverlayOn: Signal<OverlayTrigger>;
10980
+ Span: Signal<_$react.ElementType | undefined>;
10981
+ Mark: Signal<_$react.ElementType | undefined>;
10982
+ Overlay: Signal<_$react.ElementType | undefined>;
10986
10983
  className: Signal<string | undefined>;
10987
10984
  style: Signal<CSSProperties$1 | undefined>;
10988
10985
  slots: Signal<CoreSlots | undefined>;
10989
10986
  slotProps: Signal<CoreSlotProps | undefined>;
10990
10987
  };
10988
+ readonly state: {
10989
+ tokens: Signal<Token[]>;
10990
+ previousValue: Signal<string | undefined>;
10991
+ innerValue: Signal<string | undefined>;
10992
+ recovery: Signal<Recovery | undefined>;
10993
+ container: Signal<HTMLDivElement | null>;
10994
+ overlay: Signal<HTMLElement | null>;
10995
+ selecting: Signal<"drag" | "all" | undefined>;
10996
+ overlayMatch: Signal<OverlayMatch | undefined>;
10997
+ };
10991
10998
  readonly computed: {
10992
10999
  hasMark: Computed<boolean>;
11000
+ isBlock: Computed<boolean>;
11001
+ isDraggable: Computed<boolean>;
10993
11002
  parser: Computed<Parser | undefined>;
10994
- containerClass: Computed<string | undefined>;
10995
- containerStyle: Computed<unknown>;
10996
- };
10997
- readonly slot: {
10998
- container: Slot;
10999
- block: Slot;
11000
- span: Slot;
11003
+ currentValue: Computed<string>;
11004
+ containerComponent: Computed<Slot>;
11005
+ containerProps: Computed<{
11006
+ className: string | undefined;
11007
+ style?: CSSProperties$1;
11008
+ [key: string]: unknown;
11009
+ }>;
11010
+ blockComponent: Computed<Slot>;
11011
+ blockProps: Computed<Record<string, unknown> | undefined>;
11012
+ spanComponent: Computed<Slot>;
11013
+ spanProps: Computed<Record<string, unknown> | undefined>;
11001
11014
  overlay: OverlaySlot;
11002
11015
  mark: MarkSlot;
11003
11016
  };
11004
- readonly event: {
11017
+ readonly emit: {
11005
11018
  /** Fires after user input or programmatic mark change — triggers serialization, `onChange`, and re-parse */change: Event<void>; /** Triggers a re-parse of tokens from the current content */
11006
- parse: Event<void>; /** Removes a mark token from editor content */
11007
- delete: Event<{
11019
+ reparse: Event<void>; /** Removes a mark token from editor content */
11020
+ markRemove: Event<{
11008
11021
  token: Token;
11009
11022
  }>; /** Fires when the user selects an overlay option — annotates markup into the current input span */
11010
- select: Event<{
11023
+ overlaySelect: Event<{
11011
11024
  mark: Token;
11012
11025
  match: OverlayMatch;
11013
11026
  }>; /** Dismisses the overlay by clearing the current `overlayMatch` */
11014
- clearOverlay: Event<void>; /** Probes the caret/text position for overlay trigger patterns and shows overlay if matched */
11015
- checkOverlay: Event<void>; /** Syncs `contentEditable` attributes and `textContent` of child elements to match token state */
11016
- sync: Event<void>; /** Restores the caret position after a DOM re-render using the saved recovery state */
11017
- recoverFocus: Event<void>; /** Dispatches drag-mode row operations (reorder, add, delete, duplicate) */
11018
- dragAction: Event<DragAction>; /** Signals the framework component has received new props — triggers conditional re-parse if value/options changed */
11019
- updated: Event<void>; /** Fires after the framework has committed new token elements to the DOM — kicks off sync and focus recovery */
11020
- afterTokensRendered: Event<void>; /** Lifecycle: editor component added to the DOM — enables all features */
11027
+ overlayClose: Event<void>; /** Post-render DOM alignment: aligns `contentEditable` attributes and `textContent` of child elements to token state. Emitted synchronously by `FocusFeature` inside the `rendered` handler (framework layout-effect phase). Load-bearing for post-commit DOM consistency do not delete without reproducing this timing. */
11028
+ sync: Event<void>; /** Dispatches drag-mode row operations (reorder, add, delete, duplicate) */
11029
+ drag: Event<DragAction>; /** Fires after the framework has committed new token elements to the DOM — kicks off sync and focus recovery */
11030
+ rendered: Event<void>; /** Lifecycle: editor component added to the DOM enables all features */
11021
11031
  mounted: Event<void>; /** Lifecycle: editor component removed from the DOM — disables all features and cleans up subscriptions */
11022
11032
  unmounted: Event<void>;
11023
11033
  };
11024
- readonly refs: {
11025
- container: HTMLDivElement | null;
11026
- overlay: HTMLElement | null;
11027
- };
11028
11034
  readonly handler: MarkputHandler;
11029
- readonly features: {
11035
+ readonly feature: {
11030
11036
  overlay: OverlayFeature;
11031
11037
  focus: FocusFeature;
11032
11038
  input: InputFeature;
@@ -11040,10 +11046,26 @@ declare class Store {
11040
11046
  parse: ParseFeature;
11041
11047
  };
11042
11048
  constructor();
11043
- setState(values: Partial<SignalValues<typeof this.state>>): void;
11049
+ setProps(values: Partial<SignalValues<typeof this.props>>): void;
11044
11050
  }
11045
11051
  //#endregion
11046
11052
  //#region ../../core/src/shared/types.d.ts
11053
+ /**
11054
+ * Registry interface used as a module-augmentation target. Framework packages
11055
+ * add a `default` property whose type is the framework's component type.
11056
+ *
11057
+ * @example React augmentation
11058
+ * declare module '@markput/core' {
11059
+ * interface SlotRegistry {
11060
+ * default: import('react').ElementType
11061
+ * }
11062
+ * }
11063
+ *
11064
+ * Without augmentation, `Slot` falls back to `unknown`.
11065
+ */
11066
+ interface SlotRegistry {}
11067
+ /** Framework-provided component type. Resolves to `unknown` unless `SlotRegistry` is augmented. */
11068
+ type Slot = keyof SlotRegistry extends never ? unknown : SlotRegistry[keyof SlotRegistry];
11047
11069
  /**
11048
11070
  * Core option for markups - Framework-agnostic configuration.
11049
11071
  * Extended by framework-specific Option types (e.g., React Option).
@@ -11116,9 +11138,9 @@ type OverlayTrigger = Array<'change' | 'selectionChange'> | 'change' | 'selectio
11116
11138
  type CSSProperties$1 = Properties<string | number>;
11117
11139
  type DataAttributes = Record<`data${Capitalize<string>}`, string | number | boolean | undefined>;
11118
11140
  interface CoreSlots {
11119
- container?: unknown;
11120
- block?: unknown;
11121
- span?: unknown;
11141
+ container?: Slot;
11142
+ block?: Slot;
11143
+ span?: Slot;
11122
11144
  }
11123
11145
  interface CoreSlotProps {
11124
11146
  container?: Record<string, unknown> & {
@@ -11134,6 +11156,9 @@ interface CoreSlotProps {
11134
11156
  style?: CSSProperties$1;
11135
11157
  };
11136
11158
  }
11159
+ interface DraggableConfig {
11160
+ alwaysShowHandle?: boolean;
11161
+ }
11137
11162
  type DragAction = {
11138
11163
  type: 'reorder';
11139
11164
  source: number;
@@ -11149,25 +11174,11 @@ type DragAction = {
11149
11174
  index: number;
11150
11175
  };
11151
11176
  interface DragActions {
11152
- dragAction: {
11177
+ drag: {
11153
11178
  (action: DragAction): void;
11154
11179
  };
11155
11180
  }
11156
11181
  //#endregion
11157
- //#region ../../core/src/features/slots/types.d.ts
11158
- interface Slot {
11159
- use(): readonly unknown[];
11160
- get(): readonly unknown[];
11161
- }
11162
- interface MarkSlot {
11163
- use(token: Token): readonly unknown[];
11164
- get(token: Token): readonly unknown[];
11165
- }
11166
- interface OverlaySlot {
11167
- use(option?: CoreOption, defaultComponent?: unknown): readonly unknown[];
11168
- get(option?: CoreOption, defaultComponent?: unknown): readonly unknown[];
11169
- }
11170
- //#endregion
11171
11182
  //#region ../../core/src/features/mark/MarkHandler.d.ts
11172
11183
  interface RefAccessor<T> {
11173
11184
  current: T | null;
@@ -11325,13 +11336,14 @@ interface MarkedInputProps<TMarkProps = MarkProps, TOverlayProps extends CoreOpt
11325
11336
  onChange?: (value: string) => void;
11326
11337
  /** Read-only mode */
11327
11338
  readOnly?: boolean;
11328
- /** Enable drag mode: each individual token (mark or text) becomes its own draggable row.
11329
- * One mark per row, one text fragment per row.
11330
- * Adjacent marks need no separator; adjacent text rows are separated by `\n\n`.
11339
+ /** Layout mode: 'inline' renders tokens in a single flow, 'block' stacks each token as its own row.
11340
+ * @default 'inline'
11331
11341
  */
11332
- drag?: boolean | {
11333
- alwaysShowHandle: boolean;
11334
- };
11342
+ layout?: 'inline' | 'block';
11343
+ /** Enable drag interaction on block rows. Only effective when layout='block'.
11344
+ * @default false
11345
+ */
11346
+ draggable?: boolean | DraggableConfig;
11335
11347
  }
11336
11348
  declare function MarkedInput<TMarkProps = MarkProps, TOverlayProps extends CoreOption['overlay'] = OverlayProps>(props: MarkedInputProps<TMarkProps, TOverlayProps>): _$react_jsx_runtime0.JSX.Element;
11337
11349
  //#endregion
@@ -11349,10 +11361,16 @@ interface OverlayHandler {
11349
11361
  value: string;
11350
11362
  meta?: string;
11351
11363
  }) => void;
11352
- match: OverlayMatch<Option>;
11364
+ match: OverlayMatch<Option> | undefined;
11353
11365
  ref: RefObject<HTMLElement | null>;
11354
11366
  }
11355
11367
  declare function useOverlay(): OverlayHandler;
11356
11368
  //#endregion
11357
- export { MarkHandler, type MarkProps, type MarkToken, MarkedInput, type MarkedInputProps, MarkputHandler, type Markup, type Option, type OverlayHandler, type OverlayProps, type TextToken, type Token, annotate, denote, useMark, useOverlay };
11369
+ //#region src/lib/hooks/useMarkput.d.ts
11370
+ type Selectable<T> = Signal<T> | Computed<T>;
11371
+ type ObjectSelector = Record<string, Selectable<unknown> | unknown>;
11372
+ declare function useMarkput<T>(selector: (store: Store) => Selectable<T>): T;
11373
+ declare function useMarkput<R extends ObjectSelector>(selector: (store: Store) => R): SignalValues<R>;
11374
+ //#endregion
11375
+ export { MarkHandler, type MarkProps, type MarkToken, MarkedInput, type MarkedInputProps, MarkputHandler, type Markup, type Option, type OverlayHandler, type OverlayProps, type TextToken, type Token, annotate, denote, useMark, useMarkput, useOverlay };
11358
11376
  //# sourceMappingURL=index.d.ts.map