@markput/react 0.11.0 → 0.12.1

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
@@ -10755,22 +10763,51 @@ declare function annotate(markup: Markup, params: {
10755
10763
  */
10756
10764
  declare function denote(value: string, callback: (mark: MarkToken) => string, markups: Markup[]): string;
10757
10765
  //#endregion
10758
- //#region ../../core/src/features/arrownav/ArrowNavFeature.d.ts
10759
- declare class ArrowNavFeature {
10766
+ //#region ../../core/src/features/caret/CaretFeature.d.ts
10767
+ declare class CaretFeature implements Feature {
10760
10768
  #private;
10761
- private readonly store;
10762
- constructor(store: Store);
10769
+ private readonly _store;
10770
+ readonly recovery: Signal<Recovery | undefined>;
10771
+ readonly selecting: Signal<"drag" | "all" | undefined>;
10772
+ constructor(_store: Store);
10763
10773
  enable(): void;
10764
10774
  disable(): void;
10765
10775
  }
10766
10776
  //#endregion
10767
- //#region ../../core/src/features/block-editing/BlockEditFeature.d.ts
10768
- declare class BlockEditFeature {
10769
- #private;
10770
- private readonly store;
10771
- constructor(store: Store);
10772
- enable(): void;
10773
- disable(): void;
10777
+ //#region ../../core/src/shared/signals/signal.d.ts
10778
+ interface Signal<T> {
10779
+ (): T;
10780
+ (value: T | undefined): void;
10781
+ }
10782
+ type SignalValues<T> = { [K in keyof T]: T[K] extends Signal<infer V> | Computed<infer V> ? V : T[K] };
10783
+ interface Computed<T> {
10784
+ (): T;
10785
+ }
10786
+ interface Event<T = void> {
10787
+ (payload: T): void;
10788
+ read(): T | undefined;
10789
+ }
10790
+ //#endregion
10791
+ //#region ../../core/src/features/props/PropsFeature.d.ts
10792
+ declare class PropsFeature {
10793
+ private readonly _store;
10794
+ readonly value: Signal<string | undefined>;
10795
+ readonly defaultValue: Signal<string | undefined>;
10796
+ readonly onChange: Signal<((value: string) => void) | undefined>;
10797
+ readonly options: Signal<CoreOption[]>;
10798
+ readonly readOnly: Signal<boolean>;
10799
+ readonly layout: Signal<"inline" | "block">;
10800
+ readonly draggable: Signal<boolean | DraggableConfig>;
10801
+ readonly showOverlayOn: Signal<OverlayTrigger>;
10802
+ readonly Span: Signal<_$react.ElementType | undefined>;
10803
+ readonly Mark: Signal<_$react.ElementType | undefined>;
10804
+ readonly Overlay: Signal<_$react.ElementType | undefined>;
10805
+ readonly className: Signal<string | undefined>;
10806
+ readonly style: Signal<CSSProperties$1 | undefined>;
10807
+ readonly slots: Signal<CoreSlots | undefined>;
10808
+ readonly slotProps: Signal<CoreSlotProps | undefined>;
10809
+ constructor(_store: Store);
10810
+ set(values: Partial<SignalValues<typeof this>>): void;
10774
10811
  }
10775
10812
  //#endregion
10776
10813
  //#region ../../core/src/store/BlockStore.d.ts
@@ -10805,17 +10842,8 @@ declare class BlockRegistry {
10805
10842
  get(token: object): BlockStore;
10806
10843
  }
10807
10844
  //#endregion
10808
- //#region ../../core/src/features/clipboard/CopyFeature.d.ts
10809
- declare class CopyFeature {
10810
- #private;
10811
- private readonly store;
10812
- constructor(store: Store);
10813
- enable(): void;
10814
- disable(): void;
10815
- }
10816
- //#endregion
10817
- //#region ../../core/src/features/drag/DragFeature.d.ts
10818
- declare class DragFeature {
10845
+ //#region ../../core/src/features/clipboard/ClipboardFeature.d.ts
10846
+ declare class ClipboardFeature {
10819
10847
  #private;
10820
10848
  private readonly store;
10821
10849
  constructor(store: Store);
@@ -10823,30 +10851,31 @@ declare class DragFeature {
10823
10851
  disable(): void;
10824
10852
  }
10825
10853
  //#endregion
10826
- //#region ../../core/src/features/editable/ContentEditableFeature.d.ts
10827
- declare class ContentEditableFeature {
10854
+ //#region ../../core/src/features/dom/DomFeature.d.ts
10855
+ declare class DomFeature {
10828
10856
  #private;
10829
- private readonly store;
10830
- constructor(store: Store);
10857
+ private readonly _store;
10858
+ constructor(_store: Store);
10831
10859
  enable(): void;
10832
10860
  disable(): void;
10833
- sync(): void;
10861
+ reconcile(): void;
10834
10862
  }
10835
10863
  //#endregion
10836
- //#region ../../core/src/features/events/SystemListenerFeature.d.ts
10837
- declare class SystemListenerFeature {
10864
+ //#region ../../core/src/features/drag/DragFeature.d.ts
10865
+ declare class DragFeature {
10838
10866
  #private;
10839
10867
  private readonly store;
10868
+ readonly action: Event<DragAction>;
10840
10869
  constructor(store: Store);
10841
10870
  enable(): void;
10842
10871
  disable(): void;
10843
10872
  }
10844
10873
  //#endregion
10845
- //#region ../../core/src/features/focus/FocusFeature.d.ts
10846
- declare class FocusFeature {
10874
+ //#region ../../core/src/features/keyboard/KeyboardFeature.d.ts
10875
+ declare class KeyboardFeature implements Feature {
10847
10876
  #private;
10848
- private readonly store;
10849
- constructor(store: Store);
10877
+ private readonly _store;
10878
+ constructor(_store: Store);
10850
10879
  enable(): void;
10851
10880
  disable(): void;
10852
10881
  }
@@ -10893,65 +10922,141 @@ declare class NodeProxy {
10893
10922
  clear(): void;
10894
10923
  }
10895
10924
  //#endregion
10896
- //#region ../../core/src/shared/signals/signal.d.ts
10897
- interface Signal<T> {
10898
- (): T;
10899
- (value: T | undefined): void;
10925
+ //#region ../../core/src/features/lifecycle/LifecycleFeature.d.ts
10926
+ declare class LifecycleFeature implements Feature {
10927
+ private readonly _store;
10928
+ readonly mounted: Event<void>;
10929
+ readonly unmounted: Event<void>;
10930
+ readonly rendered: Event<void>;
10931
+ constructor(_store: Store);
10932
+ enable(): void;
10933
+ disable(): void;
10900
10934
  }
10901
- type SignalValues<T> = { [K in keyof T]: T[K] extends Signal<infer V> | Computed<infer V> ? V : T[K] };
10902
- interface Computed<T> {
10903
- (): T;
10935
+ //#endregion
10936
+ //#region ../../core/src/features/mark/MarkHandler.d.ts
10937
+ interface RefAccessor<T> {
10938
+ current: T | null;
10904
10939
  }
10905
- interface Event<T = void> {
10906
- (payload: T): void;
10907
- read(): T | undefined;
10940
+ declare class MarkHandler<T extends HTMLElement = HTMLElement> {
10941
+ #private;
10942
+ readonly ref: RefAccessor<T>;
10943
+ constructor(param: {
10944
+ ref: RefAccessor<T>;
10945
+ store: Store;
10946
+ token: MarkToken;
10947
+ });
10948
+ get readOnly(): boolean | undefined;
10949
+ set readOnly(value: boolean | undefined);
10950
+ get content(): string;
10951
+ set content(value: string);
10952
+ get value(): string | undefined;
10953
+ set value(v: string | undefined);
10954
+ get meta(): string | undefined;
10955
+ set meta(v: string | undefined);
10956
+ get slot(): string | undefined;
10957
+ get depth(): number;
10958
+ get hasChildren(): boolean;
10959
+ get parent(): MarkToken | undefined;
10960
+ get tokens(): Token[];
10961
+ change: (props: {
10962
+ content: string;
10963
+ value?: string;
10964
+ meta?: string;
10965
+ }) => void;
10966
+ remove: () => void;
10967
+ }
10968
+ //#endregion
10969
+ //#region ../../core/src/features/slots/types.d.ts
10970
+ interface MarkSlot {
10971
+ (): (token: Token) => readonly [Slot, Record<string, unknown>];
10972
+ }
10973
+ interface OverlaySlot {
10974
+ (): (option?: CoreOption, defaultComponent?: Slot) => readonly [Slot, Record<string, unknown>];
10908
10975
  }
10909
10976
  //#endregion
10910
- //#region ../../core/src/features/input/InputFeature.d.ts
10911
- declare class InputFeature {
10977
+ //#region ../../core/src/features/slots/SlotsFeature.d.ts
10978
+ declare class SlotsFeature implements Feature {
10979
+ private readonly _store;
10980
+ readonly container: Signal<HTMLDivElement | null>;
10981
+ readonly isBlock: Computed<boolean>;
10982
+ readonly isDraggable: Computed<boolean>;
10983
+ readonly containerComponent: Computed<Slot>;
10984
+ readonly containerProps: Computed<{
10985
+ className: string | undefined;
10986
+ style?: CSSProperties$1;
10987
+ [key: string]: unknown;
10988
+ }>;
10989
+ readonly blockComponent: Computed<Slot>;
10990
+ readonly blockProps: Computed<Record<string, unknown> | undefined>;
10991
+ readonly spanComponent: Computed<Slot>;
10992
+ readonly spanProps: Computed<Record<string, unknown> | undefined>;
10993
+ constructor(_store: Store);
10994
+ enable(): void;
10995
+ disable(): void;
10996
+ }
10997
+ //#endregion
10998
+ //#region ../../core/src/features/mark/MarkFeature.d.ts
10999
+ declare class MarkFeature implements Feature {
10912
11000
  #private;
10913
- private readonly store;
10914
- constructor(store: Store);
11001
+ private readonly _store;
11002
+ readonly enabled: Computed<boolean>;
11003
+ readonly slot: MarkSlot;
11004
+ readonly remove: Event<{
11005
+ token: Token;
11006
+ }>;
11007
+ constructor(_store: Store);
10915
11008
  enable(): void;
10916
11009
  disable(): void;
10917
11010
  }
10918
11011
  //#endregion
11012
+ //#region ../../core/src/features/mark/types.d.ts
11013
+ interface MarkOptions {
11014
+ controlled?: boolean;
11015
+ }
11016
+ //#endregion
10919
11017
  //#region ../../core/src/features/overlay/OverlayFeature.d.ts
10920
- declare class OverlayFeature {
11018
+ declare class OverlayFeature implements Feature {
10921
11019
  #private;
10922
- private readonly store;
10923
- constructor(store: Store);
11020
+ private readonly _store;
11021
+ readonly match: Signal<OverlayMatch | undefined>;
11022
+ readonly element: Signal<HTMLElement | null>;
11023
+ readonly slot: OverlaySlot;
11024
+ readonly select: Event<{
11025
+ mark: Token;
11026
+ match: OverlayMatch;
11027
+ }>;
11028
+ readonly close: Event<void>;
11029
+ constructor(_store: Store);
10924
11030
  enable(): void;
10925
11031
  disable(): void;
10926
11032
  }
10927
11033
  //#endregion
10928
11034
  //#region ../../core/src/features/parsing/ParseFeature.d.ts
10929
- declare class ParseFeature {
11035
+ declare class ParsingFeature implements Feature {
10930
11036
  #private;
10931
- private readonly store;
10932
- constructor(store: Store);
11037
+ private readonly _store;
11038
+ readonly tokens: Signal<Token[]>;
11039
+ readonly parser: Computed<Parser | undefined>;
11040
+ readonly reparse: Event<void>;
11041
+ constructor(_store: Store);
10933
11042
  enable(): void;
10934
11043
  disable(): void;
10935
11044
  sync(): void;
10936
11045
  }
10937
11046
  //#endregion
10938
- //#region ../../core/src/features/selection/TextSelectionFeature.d.ts
10939
- declare class TextSelectionFeature {
11047
+ //#region ../../core/src/features/value/ValueFeature.d.ts
11048
+ declare class ValueFeature implements Feature {
10940
11049
  #private;
10941
- private readonly store;
10942
- constructor(store: Store);
11050
+ private readonly _store;
11051
+ readonly last: Signal<string | undefined>;
11052
+ readonly next: Signal<string | undefined>;
11053
+ readonly current: Computed<string>;
11054
+ readonly change: Event<void>;
11055
+ constructor(_store: Store);
10943
11056
  enable(): void;
10944
11057
  disable(): void;
10945
11058
  }
10946
11059
  //#endregion
10947
- //#region ../../core/src/features/slots/types.d.ts
10948
- interface MarkSlot {
10949
- (): (token: Token) => readonly [unknown, unknown];
10950
- }
10951
- interface OverlaySlot {
10952
- (): (option?: CoreOption, defaultComponent?: unknown) => readonly [unknown, unknown];
10953
- }
10954
- //#endregion
10955
11060
  //#region ../../core/src/store/Store.d.ts
10956
11061
  declare class Store {
10957
11062
  readonly key: KeyGenerator;
@@ -10960,94 +11065,39 @@ declare class Store {
10960
11065
  focus: NodeProxy;
10961
11066
  input: NodeProxy;
10962
11067
  };
10963
- readonly props: {
10964
- value: Signal<string | undefined>;
10965
- defaultValue: Signal<string | undefined>;
10966
- onChange: Signal<((value: string) => void) | undefined>;
10967
- options: Signal<CoreOption[]>;
10968
- readOnly: Signal<boolean>;
10969
- layout: Signal<"inline" | "block">;
10970
- draggable: Signal<boolean | DraggableConfig>;
10971
- showOverlayOn: Signal<OverlayTrigger>;
10972
- Span: Signal<unknown>;
10973
- Mark: Signal<unknown>;
10974
- Overlay: Signal<unknown>;
10975
- className: Signal<string | undefined>;
10976
- style: Signal<CSSProperties$1 | undefined>;
10977
- slots: Signal<CoreSlots | undefined>;
10978
- slotProps: Signal<CoreSlotProps | undefined>;
10979
- };
10980
- readonly state: {
10981
- tokens: Signal<Token[]>;
10982
- previousValue: Signal<string | undefined>;
10983
- innerValue: Signal<string | undefined>;
10984
- recovery: Signal<Recovery | undefined>;
10985
- selecting: Signal<"drag" | "all" | undefined>;
10986
- overlayMatch: Signal<OverlayMatch | undefined>;
10987
- };
10988
- readonly computed: {
10989
- hasMark: Computed<boolean>;
10990
- isBlock: Computed<boolean>;
10991
- isDraggable: Computed<boolean>;
10992
- parser: Computed<Parser | undefined>;
10993
- currentValue: Computed<string>;
10994
- containerComponent: Computed<unknown>;
10995
- containerProps: Computed<{
10996
- className: string | undefined;
10997
- style?: CSSProperties$1;
10998
- [key: string]: unknown;
10999
- }>;
11000
- blockComponent: Computed<unknown>;
11001
- blockProps: Computed<Record<string, unknown> | undefined>;
11002
- spanComponent: Computed<unknown>;
11003
- spanProps: Computed<Record<string, unknown> | undefined>;
11004
- overlay: OverlaySlot;
11005
- mark: MarkSlot;
11006
- };
11007
- readonly event: {
11008
- /** 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 */
11009
- parse: Event<void>; /** Removes a mark token from editor content */
11010
- delete: Event<{
11011
- token: Token;
11012
- }>; /** Fires when the user selects an overlay option — annotates markup into the current input span */
11013
- select: Event<{
11014
- mark: Token;
11015
- match: OverlayMatch;
11016
- }>; /** Dismisses the overlay by clearing the current `overlayMatch` */
11017
- clearOverlay: Event<void>; /** Probes the caret/text position for overlay trigger patterns and shows overlay if matched */
11018
- checkOverlay: Event<void>; /** Syncs `contentEditable` attributes and `textContent` of child elements to match token state */
11019
- sync: Event<void>; /** Restores the caret position after a DOM re-render using the saved recovery state */
11020
- recoverFocus: Event<void>; /** Dispatches drag-mode row operations (reorder, add, delete, duplicate) */
11021
- dragAction: Event<DragAction>; /** Signals the framework component has received new props — triggers conditional re-parse if value/options changed */
11022
- updated: Event<void>; /** Fires after the framework has committed new token elements to the DOM — kicks off sync and focus recovery */
11023
- afterTokensRendered: Event<void>; /** Lifecycle: editor component added to the DOM — enables all features */
11024
- mounted: Event<void>; /** Lifecycle: editor component removed from the DOM — disables all features and cleans up subscriptions */
11025
- unmounted: Event<void>;
11026
- };
11027
- readonly refs: {
11028
- container: HTMLDivElement | null;
11029
- overlay: HTMLElement | null;
11030
- };
11068
+ readonly props: PropsFeature;
11031
11069
  readonly handler: MarkputHandler;
11032
- readonly features: {
11033
- overlay: OverlayFeature;
11034
- focus: FocusFeature;
11035
- input: InputFeature;
11036
- blockEditing: BlockEditFeature;
11037
- arrowNav: ArrowNavFeature;
11038
- system: SystemListenerFeature;
11039
- textSelection: TextSelectionFeature;
11040
- contentEditable: ContentEditableFeature;
11041
- drag: DragFeature;
11042
- copy: CopyFeature;
11043
- parse: ParseFeature;
11044
- };
11070
+ readonly lifecycle: LifecycleFeature;
11071
+ readonly value: ValueFeature;
11072
+ readonly mark: MarkFeature;
11073
+ readonly overlay: OverlayFeature;
11074
+ readonly slots: SlotsFeature;
11075
+ readonly caret: CaretFeature;
11076
+ readonly keyboard: KeyboardFeature;
11077
+ readonly dom: DomFeature;
11078
+ readonly drag: DragFeature;
11079
+ readonly clipboard: ClipboardFeature;
11080
+ readonly parsing: ParsingFeature;
11045
11081
  constructor();
11046
- setProps(values: Partial<SignalValues<typeof this.props>>): void;
11047
- bumpTokens(): void;
11048
11082
  }
11049
11083
  //#endregion
11050
11084
  //#region ../../core/src/shared/types.d.ts
11085
+ /**
11086
+ * Registry interface used as a module-augmentation target. Framework packages
11087
+ * add a `default` property whose type is the framework's component type.
11088
+ *
11089
+ * @example React augmentation
11090
+ * declare module '@markput/core' {
11091
+ * interface SlotRegistry {
11092
+ * default: import('react').ElementType
11093
+ * }
11094
+ * }
11095
+ *
11096
+ * Without augmentation, `Slot` falls back to `unknown`.
11097
+ */
11098
+ interface SlotRegistry {}
11099
+ /** Framework-provided component type. Resolves to `unknown` unless `SlotRegistry` is augmented. */
11100
+ type Slot = keyof SlotRegistry extends never ? unknown : SlotRegistry[keyof SlotRegistry];
11051
11101
  /**
11052
11102
  * Core option for markups - Framework-agnostic configuration.
11053
11103
  * Extended by framework-specific Option types (e.g., React Option).
@@ -11120,9 +11170,9 @@ type OverlayTrigger = Array<'change' | 'selectionChange'> | 'change' | 'selectio
11120
11170
  type CSSProperties$1 = Properties<string | number>;
11121
11171
  type DataAttributes = Record<`data${Capitalize<string>}`, string | number | boolean | undefined>;
11122
11172
  interface CoreSlots {
11123
- container?: unknown;
11124
- block?: unknown;
11125
- span?: unknown;
11173
+ container?: Slot;
11174
+ block?: Slot;
11175
+ span?: Slot;
11126
11176
  }
11127
11177
  interface CoreSlotProps {
11128
11178
  container?: Record<string, unknown> & {
@@ -11156,47 +11206,13 @@ type DragAction = {
11156
11206
  index: number;
11157
11207
  };
11158
11208
  interface DragActions {
11159
- dragAction: {
11209
+ action: {
11160
11210
  (action: DragAction): void;
11161
11211
  };
11162
11212
  }
11163
- //#endregion
11164
- //#region ../../core/src/features/mark/MarkHandler.d.ts
11165
- interface RefAccessor<T> {
11166
- current: T | null;
11167
- }
11168
- declare class MarkHandler<T extends HTMLElement = HTMLElement> {
11169
- #private;
11170
- readonly ref: RefAccessor<T>;
11171
- constructor(param: {
11172
- ref: RefAccessor<T>;
11173
- store: Store;
11174
- token: MarkToken;
11175
- });
11176
- get readOnly(): boolean | undefined;
11177
- set readOnly(value: boolean | undefined);
11178
- get content(): string;
11179
- set content(value: string);
11180
- get value(): string | undefined;
11181
- set value(v: string | undefined);
11182
- get meta(): string | undefined;
11183
- set meta(v: string | undefined);
11184
- get slot(): string | undefined;
11185
- get depth(): number;
11186
- get hasChildren(): boolean;
11187
- get parent(): MarkToken | undefined;
11188
- get tokens(): Token[];
11189
- change: (props: {
11190
- content: string;
11191
- value?: string;
11192
- meta?: string;
11193
- }) => void;
11194
- remove: () => void;
11195
- }
11196
- //#endregion
11197
- //#region ../../core/src/features/mark/types.d.ts
11198
- interface MarkOptions {
11199
- controlled?: boolean;
11213
+ interface Feature {
11214
+ enable(): void;
11215
+ disable(): void;
11200
11216
  }
11201
11217
  //#endregion
11202
11218
  //#region src/types.d.ts