@markput/react 0.12.1 → 0.14.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
@@ -38,35 +38,6 @@ declare const GAP_TYPE: {
38
38
  };
39
39
  type GapType = (typeof GAP_TYPE)[keyof typeof GAP_TYPE];
40
40
  //#endregion
41
- //#region ../../core/src/features/parsing/parser/core/SegmentMatcher.d.ts
42
- /**
43
- * Segment definition - can be a static string or a dynamic pattern
44
- * For dynamic patterns: [before, after, exclusions]
45
- */
46
- type SegmentDefinition = string | readonly [before: string, after: string, exclusions: string];
47
- //#endregion
48
- //#region ../../core/src/features/parsing/parser/core/MarkupDescriptor.d.ts
49
- /**
50
- * Descriptor for segment-based markup parsing
51
- * Converts markup templates into arrays of static or dynamic segments
52
- */
53
- interface MarkupDescriptor {
54
- /** Original markup template string */
55
- markup: Markup;
56
- /** Index of this markup in the original markups array */
57
- index: number;
58
- /** Array of segment definitions (can be static strings or dynamic patterns) */
59
- segments: SegmentDefinition[];
60
- /** Type of content in each gap between segments */
61
- gapTypes: GapType[];
62
- /** True if this markup contains a __slot__ placeholder */
63
- hasSlot: boolean;
64
- /** True if this markup contains exactly two __value__ placeholders */
65
- hasTwoValues: boolean;
66
- /** Global indices of segments in registry segments array (parallel to segments array) */
67
- segmentGlobalIndices: number[];
68
- }
69
- //#endregion
70
41
  //#region ../../core/src/features/parsing/parser/types.d.ts
71
42
  type Token = TextToken | MarkToken;
72
43
  interface TextToken {
@@ -118,6 +89,63 @@ type SlotMarkup = `${string}${typeof PLACEHOLDER.Slot}${string}`;
118
89
  */
119
90
  type Markup = ValueMarkup | `${ValueMarkup}${MetaMarkup}` | `${ValueMarkup}${MetaMarkup}${SlotMarkup}` | `${ValueMarkup}${SlotMarkup}` | `${ValueMarkup}${SlotMarkup}${MetaMarkup}` | SlotMarkup | `${SlotMarkup}${MetaMarkup}` | `${SlotMarkup}${MetaMarkup}${ValueMarkup}` | `${SlotMarkup}${ValueMarkup}` | `${SlotMarkup}${ValueMarkup}${MetaMarkup}` | `${MetaMarkup}${ValueMarkup}` | `${MetaMarkup}${ValueMarkup}${SlotMarkup}` | `${MetaMarkup}${SlotMarkup}` | `${MetaMarkup}${SlotMarkup}${ValueMarkup}`;
120
91
  //#endregion
92
+ //#region ../../core/src/features/parsing/parser/core/SegmentMatcher.d.ts
93
+ /**
94
+ * Segment definition - can be a static string or a dynamic pattern
95
+ * For dynamic patterns: [before, after, exclusions]
96
+ */
97
+ type SegmentDefinition = string | readonly [before: string, after: string, exclusions: string];
98
+ //#endregion
99
+ //#region ../../core/src/features/parsing/parser/core/MarkupDescriptor.d.ts
100
+ /**
101
+ * Descriptor for segment-based markup parsing
102
+ * Converts markup templates into arrays of static or dynamic segments
103
+ */
104
+ interface MarkupDescriptor {
105
+ /** Original markup template string */
106
+ markup: Markup;
107
+ /** Index of this markup in the original markups array */
108
+ index: number;
109
+ /** Array of segment definitions (can be static strings or dynamic patterns) */
110
+ segments: SegmentDefinition[];
111
+ /** Type of content in each gap between segments */
112
+ gapTypes: GapType[];
113
+ /** True if this markup contains a __slot__ placeholder */
114
+ hasSlot: boolean;
115
+ /** True if this markup contains exactly two __value__ placeholders */
116
+ hasTwoValues: boolean;
117
+ /** Global indices of segments in registry segments array (parallel to segments array) */
118
+ segmentGlobalIndices: number[];
119
+ }
120
+ //#endregion
121
+ //#region ../../core/src/shared/signals/signal.d.ts
122
+ interface Signal<T> {
123
+ (): T;
124
+ (value: T | undefined): void;
125
+ }
126
+ type SignalValues<T> = { [K in keyof T]: T[K] extends Signal<infer V> | Computed<infer V> ? V : T[K] };
127
+ interface Computed<T> {
128
+ (): T;
129
+ }
130
+ interface Event<T = void> {
131
+ (payload: T): void;
132
+ read(): T | undefined;
133
+ }
134
+ //#endregion
135
+ //#region ../../core/src/features/lifecycle/Lifecycle.d.ts
136
+ declare class Lifecycle {
137
+ readonly mounted: Event<void>;
138
+ readonly unmounted: Event<void>;
139
+ readonly rendered: Event<void>;
140
+ /**
141
+ * Run `setup` when the editor is mounted. Any reactive subscription
142
+ * created inside `setup` (`watch`, `listen`, `effect`, nested
143
+ * `effectScope`) is automatically disposed on `unmounted` and re-created
144
+ * on the next `mounted`.
145
+ */
146
+ onMounted(setup: () => void): void;
147
+ }
148
+ //#endregion
121
149
  //#region ../../../node_modules/.pnpm/csstype@3.2.3/node_modules/csstype/index.d.ts
122
150
  interface StandardLonghandProperties<TLength = (string & {}) | 0, TTime = string & {}> {
123
151
  /**
@@ -10547,6 +10575,147 @@ declare namespace DataType {
10547
10575
  type VisualBox = "border-box" | "content-box" | "padding-box";
10548
10576
  }
10549
10577
  //#endregion
10578
+ //#region ../../core/src/shared/types.d.ts
10579
+ /**
10580
+ * Registry interface used as a module-augmentation target. Framework packages
10581
+ * add a `default` property whose type is the framework's component type.
10582
+ *
10583
+ * @example React augmentation
10584
+ * declare module '@markput/core' {
10585
+ * interface SlotRegistry {
10586
+ * default: import('react').ElementType
10587
+ * }
10588
+ * }
10589
+ *
10590
+ * Without augmentation, `Slot` falls back to `unknown`.
10591
+ */
10592
+ interface SlotRegistry {}
10593
+ /** Framework-provided component type. Resolves to `unknown` unless `SlotRegistry` is augmented. */
10594
+ type Slot = keyof SlotRegistry extends never ? unknown : SlotRegistry[keyof SlotRegistry];
10595
+ /**
10596
+ * Core option for markups - Framework-agnostic configuration.
10597
+ * Extended by framework-specific Option types (e.g., React Option).
10598
+ *
10599
+ * Architecture:
10600
+ * - CoreOption: Contains only markup pattern (framework-independent)
10601
+ * - trigger configuration: Handled by framework layer via getTrigger function in TriggerFinder
10602
+ * - Separation of concerns: Core focuses on markup parsing, framework handles overlay triggers
10603
+ */
10604
+ interface CoreOption {
10605
+ /**
10606
+ * Template string in which the mark is rendered.
10607
+ * Must contain placeholders: `__value__`, `__meta__`, and/or `__slot__`
10608
+ *
10609
+ * Placeholder types:
10610
+ * - `__value__` - main content (plain text, no nesting)
10611
+ * - `__meta__` - additional metadata (plain text, no nesting)
10612
+ * - `__slot__` - content supporting nested structures
10613
+ *
10614
+ * @example
10615
+ * // Simple value
10616
+ * "@[__value__]"
10617
+ *
10618
+ * @example
10619
+ * // Value with metadata
10620
+ * "@[__value__](__meta__)"
10621
+ *
10622
+ * @example
10623
+ * // Nested content support
10624
+ * "@[__slot__]"
10625
+ */
10626
+ markup?: Markup;
10627
+ overlay?: {
10628
+ trigger?: string;
10629
+ };
10630
+ }
10631
+ type OverlayMatch<TOption = CoreOption> = {
10632
+ /**
10633
+ * Found value via a overlayMatch
10634
+ */
10635
+ value: string;
10636
+ /**
10637
+ * Triggered value
10638
+ */
10639
+ source: string;
10640
+ /**
10641
+ * Piece of text, in which was a overlayMatch
10642
+ */
10643
+ span: string;
10644
+ /**
10645
+ * Html element, in which was a overlayMatch
10646
+ */
10647
+ node: Node;
10648
+ range: Range$1;
10649
+ /**
10650
+ * OverlayMatch's option
10651
+ */
10652
+ option: TOption;
10653
+ };
10654
+ type OverlayTrigger = Array<'change' | 'selectionChange'> | 'change' | 'selectionChange' | 'none';
10655
+ type CSSProperties$1 = Properties<string | number>;
10656
+ type DataAttributes = Record<`data${Capitalize<string>}`, string | number | boolean | undefined>;
10657
+ interface CoreSlots {
10658
+ container?: Slot;
10659
+ block?: Slot;
10660
+ span?: Slot;
10661
+ }
10662
+ interface CoreSlotProps {
10663
+ container?: Record<string, unknown> & {
10664
+ className?: string;
10665
+ style?: CSSProperties$1;
10666
+ };
10667
+ block?: Record<string, unknown> & {
10668
+ className?: string;
10669
+ style?: CSSProperties$1;
10670
+ };
10671
+ span?: Record<string, unknown> & {
10672
+ className?: string;
10673
+ style?: CSSProperties$1;
10674
+ };
10675
+ }
10676
+ interface DraggableConfig {
10677
+ alwaysShowHandle?: boolean;
10678
+ }
10679
+ type DragAction = {
10680
+ type: 'reorder';
10681
+ source: number;
10682
+ target: number;
10683
+ } | {
10684
+ type: 'add';
10685
+ afterIndex: number;
10686
+ } | {
10687
+ type: 'delete';
10688
+ index: number;
10689
+ } | {
10690
+ type: 'duplicate';
10691
+ index: number;
10692
+ };
10693
+ interface DragActions {
10694
+ action: {
10695
+ (action: DragAction): void;
10696
+ };
10697
+ }
10698
+ //#endregion
10699
+ //#region ../../core/src/features/props/PropsModel.d.ts
10700
+ declare class PropsModel {
10701
+ readonly value: Signal<string | undefined>;
10702
+ readonly defaultValue: Signal<string | undefined>;
10703
+ readonly onChange: Signal<((value: string) => void) | undefined>;
10704
+ readonly options: Signal<CoreOption[]>;
10705
+ readonly readOnly: Signal<boolean>;
10706
+ readonly layout: Signal<"inline" | "block">;
10707
+ readonly draggable: Signal<boolean | DraggableConfig>;
10708
+ readonly showOverlayOn: Signal<OverlayTrigger>;
10709
+ readonly Span: Signal<_$react.ElementType | undefined>;
10710
+ readonly Mark: Signal<_$react.ElementType | undefined>;
10711
+ readonly Overlay: Signal<_$react.ElementType | undefined>;
10712
+ readonly className: Signal<string | undefined>;
10713
+ readonly style: Signal<CSSProperties$1 | undefined>;
10714
+ readonly slots: Signal<CoreSlots | undefined>;
10715
+ readonly slotProps: Signal<CoreSlotProps | undefined>;
10716
+ set(values: Partial<SignalValues<typeof this>>): void;
10717
+ }
10718
+ //#endregion
10550
10719
  //#region ../../core/src/features/parsing/parser/Parser.d.ts
10551
10720
  /**
10552
10721
  * Parser - High-performance tree-based markup parser
@@ -10763,51 +10932,170 @@ declare function annotate(markup: Markup, params: {
10763
10932
  */
10764
10933
  declare function denote(value: string, callback: (mark: MarkToken) => string, markups: Markup[]): string;
10765
10934
  //#endregion
10766
- //#region ../../core/src/features/caret/CaretFeature.d.ts
10767
- declare class CaretFeature implements Feature {
10935
+ //#region ../../core/src/features/parsing/tokenIndex.d.ts
10936
+ type TokenIndex = {
10937
+ readonly generation: number;
10938
+ pathFor(token: Token): TokenPath | undefined;
10939
+ addressFor(path: TokenPath): TokenAddress | undefined;
10940
+ resolve(path: TokenPath): Token | undefined;
10941
+ resolveAddress(address: TokenAddress, expected?: TokenShapeSnapshot): Result<Token, 'stale'>;
10942
+ key(path: TokenPath): string;
10943
+ equals(a: TokenPath, b: TokenPath): boolean;
10944
+ };
10945
+ //#endregion
10946
+ //#region ../../core/src/features/slots/types.d.ts
10947
+ interface MarkSlot {
10948
+ (): (token: Token) => readonly [Slot, Record<string, unknown>];
10949
+ }
10950
+ interface OverlaySlot {
10951
+ (): (option?: CoreOption, defaultComponent?: Slot) => readonly [Slot, Record<string, unknown>];
10952
+ }
10953
+ //#endregion
10954
+ //#region ../../core/src/features/slots/SlotsFeature.d.ts
10955
+ declare class SlotsFeature {
10956
+ private readonly props;
10957
+ readonly isBlock: Computed<boolean>;
10958
+ readonly isDraggable: Computed<boolean>;
10959
+ readonly containerComponent: Computed<Slot>;
10960
+ readonly containerProps: Computed<{
10961
+ className: string | undefined;
10962
+ style?: CSSProperties$1;
10963
+ [key: string]: unknown;
10964
+ }>;
10965
+ readonly blockComponent: Computed<Slot>;
10966
+ readonly blockProps: Computed<Record<string, unknown> | undefined>;
10967
+ readonly spanComponent: Computed<Slot>;
10968
+ readonly spanProps: Computed<Record<string, unknown> | undefined>;
10969
+ constructor(props: PropsModel);
10970
+ }
10971
+ //#endregion
10972
+ //#region ../../core/src/features/mark/MarkFeature.d.ts
10973
+ declare class MarkFeature {
10974
+ private readonly props;
10975
+ readonly enabled: Computed<boolean>;
10976
+ readonly slot: MarkSlot;
10977
+ constructor(props: PropsModel);
10978
+ }
10979
+ //#endregion
10980
+ //#region ../../core/src/features/value/ValueModel.d.ts
10981
+ declare class ValueModel {
10982
+ private readonly props;
10983
+ readonly isControlledMode: Computed<boolean>;
10984
+ readonly current: Signal<string>;
10985
+ constructor(props: PropsModel);
10986
+ /**
10987
+ * Attempts to replace `range` with `replacement`. Returns `true` when the
10988
+ * edit was accepted (range valid and not read-only), `false` otherwise.
10989
+ * Callers use the return value to gate downstream side effects such as
10990
+ * caret placement.
10991
+ */
10992
+ replace(range: Range$1, replacement: string): boolean;
10993
+ }
10994
+ //#endregion
10995
+ //#region ../../core/src/features/parsing/ParseController.d.ts
10996
+ declare class ParseController {
10768
10997
  #private;
10769
- private readonly _store;
10770
- readonly recovery: Signal<Recovery | undefined>;
10771
- readonly selecting: Signal<"drag" | "all" | undefined>;
10772
- constructor(_store: Store);
10773
- enable(): void;
10774
- disable(): void;
10998
+ private readonly lifecycle;
10999
+ private readonly value;
11000
+ private readonly mark;
11001
+ private readonly props;
11002
+ private readonly slots;
11003
+ readonly tokens: Signal<Token[]>;
11004
+ readonly index: Computed<TokenIndex>;
11005
+ readonly parser: Computed<Parser | undefined>;
11006
+ readonly reparse: Event<void>;
11007
+ constructor(lifecycle: Lifecycle, value: ValueModel, mark: MarkFeature, props: PropsModel, slots: SlotsFeature);
11008
+ acceptTokens(tokens: Token[]): void;
10775
11009
  }
10776
11010
  //#endregion
10777
- //#region ../../core/src/shared/signals/signal.d.ts
10778
- interface Signal<T> {
10779
- (): T;
10780
- (value: T | undefined): void;
11011
+ //#region ../../core/src/features/dom/DomController.d.ts
11012
+ declare class DomController {
11013
+ #private;
11014
+ private readonly lifecycle;
11015
+ private readonly props;
11016
+ private readonly parsing;
11017
+ private readonly value;
11018
+ readonly index: Computed<DomIndex | undefined>;
11019
+ readonly container: Signal<HTMLElement | null>;
11020
+ readonly diagnostics: Event<DomDiagnostic>;
11021
+ readonly indexed: Event<void>;
11022
+ readonly readOnly: Computed<boolean>;
11023
+ constructor(lifecycle: Lifecycle, props: PropsModel, parsing: ParseController, value: ValueModel);
11024
+ compositionStarted(): void;
11025
+ compositionEnded(): void;
11026
+ controlFor(ownerPath?: TokenPath): DomRef;
11027
+ childrenFor(ownerPath: TokenPath): DomRef;
11028
+ reconcile(opts?: {
11029
+ isUserSelecting?: boolean;
11030
+ }): void;
11031
+ locateNode(node: Node): NodeLocationResult;
11032
+ placeAt(rawPosition: number, affinity?: 'before' | 'after'): Result<{
11033
+ applied: number;
11034
+ }, 'notIndexed' | 'invalidBoundary'>;
11035
+ placeRange(range: Range$1): Result<{
11036
+ applied: Range$1;
11037
+ }, 'notIndexed' | 'invalidBoundary'>;
11038
+ focusAddress(address: TokenAddress, boundary?: 'start' | 'end'): Result<void, 'notIndexed' | 'stale'>;
11039
+ rawPositionFromBoundary(node: Node, offset: number, affinity?: 'before' | 'after'): BoundaryPositionResult;
11040
+ readRawSelection(): RawSelectionResult;
10781
11041
  }
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;
11042
+ //#endregion
11043
+ //#region ../../core/src/features/caret/CaretModel.d.ts
11044
+ declare class CaretModel {
11045
+ #private;
11046
+ private readonly lifecycle;
11047
+ private readonly dom;
11048
+ private readonly value;
11049
+ readonly selection: Signal<Range$1 | undefined>;
11050
+ readonly position: Signal<number | undefined>;
11051
+ /**
11052
+ * Whether the user is actively selecting text (mouse drag, keyboard
11053
+ * Shift+Arrow, etc.). Drives {@link DomController.reconcile} to freeze
11054
+ * structural text surfaces (contenteditable=false) while selecting.
11055
+ */
11056
+ readonly isUserSelecting: Signal<boolean>;
11057
+ readonly isAllSelected: Computed<boolean>;
11058
+ constructor(lifecycle: Lifecycle, dom: DomController, value: ValueModel);
11059
+ selectAll(): void;
10785
11060
  }
10786
- interface Event<T = void> {
10787
- (payload: T): void;
10788
- read(): T | undefined;
11061
+ //#endregion
11062
+ //#region ../../core/src/features/edit/EditController.d.ts
11063
+ /**
11064
+ * Single write path for text edits — delegates gating to {@link ValueModel.replace}
11065
+ * and only moves the caret when the edit is accepted. Wrapped in {@link batch}
11066
+ * so subscribers observe a consistent value/selection pair on one tick.
11067
+ */
11068
+ declare class EditController {
11069
+ private readonly value;
11070
+ private readonly caret;
11071
+ constructor(value: ValueModel, caret: CaretModel);
11072
+ replace(range: Range$1, replacement: string): void;
10789
11073
  }
10790
11074
  //#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;
11075
+ //#region ../../core/src/features/clipboard/ClipboardController.d.ts
11076
+ declare class ClipboardController {
11077
+ #private;
11078
+ private readonly lifecycle;
11079
+ private readonly edit;
11080
+ private readonly dom;
11081
+ private readonly parsing;
11082
+ constructor(lifecycle: Lifecycle, edit: EditController, dom: DomController, parsing: ParseController);
11083
+ }
11084
+ //#endregion
11085
+ //#region ../../core/src/features/drag/DragController.d.ts
11086
+ declare class DragController {
11087
+ #private;
11088
+ private readonly props;
11089
+ private readonly value;
11090
+ private readonly parsing;
11091
+ private readonly caret;
11092
+ readonly action: Event<DragAction>;
11093
+ constructor(props: PropsModel, value: ValueModel, parsing: ParseController, caret: CaretModel);
11094
+ }
11095
+ //#endregion
11096
+ //#region ../../core/src/features/keyboard/KeyboardController.d.ts
11097
+ declare class KeyboardController {
11098
+ constructor(lifecycle: Lifecycle, dom: DomController, value: ValueModel, caret: CaretModel, edit: EditController, slots: SlotsFeature, parsing: ParseController, props: PropsModel);
10811
11099
  }
10812
11100
  //#endregion
10813
11101
  //#region ../../core/src/store/BlockStore.d.ts
@@ -10842,182 +11130,32 @@ declare class BlockRegistry {
10842
11130
  get(token: object): BlockStore;
10843
11131
  }
10844
11132
  //#endregion
10845
- //#region ../../core/src/features/clipboard/ClipboardFeature.d.ts
10846
- declare class ClipboardFeature {
10847
- #private;
10848
- private readonly store;
10849
- constructor(store: Store);
10850
- enable(): void;
10851
- disable(): void;
10852
- }
10853
- //#endregion
10854
- //#region ../../core/src/features/dom/DomFeature.d.ts
10855
- declare class DomFeature {
10856
- #private;
10857
- private readonly _store;
10858
- constructor(_store: Store);
10859
- enable(): void;
10860
- disable(): void;
10861
- reconcile(): void;
10862
- }
10863
- //#endregion
10864
- //#region ../../core/src/features/drag/DragFeature.d.ts
10865
- declare class DragFeature {
10866
- #private;
10867
- private readonly store;
10868
- readonly action: Event<DragAction>;
10869
- constructor(store: Store);
10870
- enable(): void;
10871
- disable(): void;
10872
- }
10873
- //#endregion
10874
- //#region ../../core/src/features/keyboard/KeyboardFeature.d.ts
10875
- declare class KeyboardFeature implements Feature {
11133
+ //#region ../../core/src/features/mark/MarkController.d.ts
11134
+ declare class MarkController {
10876
11135
  #private;
10877
- private readonly _store;
10878
- constructor(_store: Store);
10879
- enable(): void;
10880
- disable(): void;
10881
- }
10882
- //#endregion
10883
- //#region ../../core/src/shared/classes/MarkputHandler.d.ts
10884
- declare class MarkputHandler {
10885
11136
  private readonly store;
10886
- constructor(store: Store);
10887
- get container(): HTMLDivElement | null;
10888
- get overlay(): HTMLElement | null;
10889
- focus(): void;
10890
- }
10891
- //#endregion
10892
- //#region ../../core/src/shared/classes/KeyGenerator.d.ts
10893
- declare class KeyGenerator {
10894
- #private;
10895
- get(object: object): number | undefined;
10896
- }
10897
- //#endregion
10898
- //#region ../../core/src/shared/classes/NodeProxy.d.ts
10899
- declare class NodeProxy {
10900
- #private;
10901
- get target(): HTMLElement | undefined;
10902
- set target(value: Node | HTMLElement | EventTarget | undefined | null);
10903
- get next(): NodeProxy;
10904
- get prev(): NodeProxy;
10905
- get isSpan(): boolean;
10906
- get isMark(): boolean;
10907
- get isEditable(): boolean;
10908
- get isCaretAtBeginning(): boolean;
10909
- get isCaretAtEnd(): boolean;
10910
- get index(): number;
10911
- get caret(): number;
10912
- set caret(value: number);
10913
- get length(): number;
10914
- get content(): string;
10915
- set content(value: string | undefined);
10916
- get head(): HTMLElement | null;
10917
- get tail(): HTMLElement | null;
10918
- get isFocused(): boolean;
10919
- constructor(target: Node | EventTarget | null | undefined, store: Store);
10920
- setCaretToEnd(): void;
10921
- focus(): void;
10922
- clear(): void;
10923
- }
10924
- //#endregion
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;
10934
- }
10935
- //#endregion
10936
- //#region ../../core/src/features/mark/MarkHandler.d.ts
10937
- interface RefAccessor<T> {
10938
- current: T | null;
10939
- }
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);
11137
+ private readonly address;
11138
+ private readonly snapshot;
11139
+ constructor(store: Store, address: TokenAddress, snapshot: MarkSnapshot, shape: TokenShapeSnapshot);
11140
+ static fromToken(store: Store, token: MarkToken): MarkController;
11141
+ get value(): string;
10954
11142
  get meta(): string | undefined;
10955
- set meta(v: string | undefined);
10956
11143
  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>];
11144
+ get readOnly(): boolean;
11145
+ remove(): void;
11146
+ update(patch: MarkPatch): void;
10975
11147
  }
10976
11148
  //#endregion
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 {
11000
- #private;
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);
11008
- enable(): void;
11009
- disable(): void;
11010
- }
11011
- //#endregion
11012
- //#region ../../core/src/features/mark/types.d.ts
11013
- interface MarkOptions {
11014
- controlled?: boolean;
11015
- }
11016
- //#endregion
11017
- //#region ../../core/src/features/overlay/OverlayFeature.d.ts
11018
- declare class OverlayFeature implements Feature {
11149
+ //#region ../../core/src/features/overlay/OverlayController.d.ts
11150
+ declare class OverlayController {
11019
11151
  #private;
11020
- private readonly _store;
11152
+ private readonly lifecycle;
11153
+ private readonly props;
11154
+ private readonly value;
11155
+ private readonly dom;
11156
+ private readonly caret;
11157
+ private readonly edit;
11158
+ private readonly parsing;
11021
11159
  readonly match: Signal<OverlayMatch | undefined>;
11022
11160
  readonly element: Signal<HTMLElement | null>;
11023
11161
  readonly slot: OverlaySlot;
@@ -11026,194 +11164,118 @@ declare class OverlayFeature implements Feature {
11026
11164
  match: OverlayMatch;
11027
11165
  }>;
11028
11166
  readonly close: Event<void>;
11029
- constructor(_store: Store);
11030
- enable(): void;
11031
- disable(): void;
11167
+ readonly position: Computed<{
11168
+ left: number;
11169
+ top: number;
11170
+ }>;
11171
+ constructor(lifecycle: Lifecycle, props: PropsModel, value: ValueModel, dom: DomController, caret: CaretModel, edit: EditController, parsing: ParseController);
11032
11172
  }
11033
11173
  //#endregion
11034
- //#region ../../core/src/features/parsing/ParseFeature.d.ts
11035
- declare class ParsingFeature implements Feature {
11036
- #private;
11037
- private readonly _store;
11038
- readonly tokens: Signal<Token[]>;
11039
- readonly parser: Computed<Parser | undefined>;
11040
- readonly reparse: Event<void>;
11041
- constructor(_store: Store);
11042
- enable(): void;
11043
- disable(): void;
11044
- sync(): void;
11174
+ //#region ../../core/src/shared/classes/MarkputHandler.d.ts
11175
+ declare class MarkputHandler {
11176
+ private readonly dom;
11177
+ private readonly overlayFeature;
11178
+ private readonly parsing;
11179
+ constructor(dom: DomController, overlayFeature: OverlayController, parsing: ParseController);
11180
+ get container(): HTMLElement | null;
11181
+ get overlay(): HTMLElement | null;
11182
+ focus(): void;
11045
11183
  }
11046
11184
  //#endregion
11047
- //#region ../../core/src/features/value/ValueFeature.d.ts
11048
- declare class ValueFeature implements Feature {
11185
+ //#region ../../core/src/shared/classes/KeyGenerator.d.ts
11186
+ declare class KeyGenerator {
11049
11187
  #private;
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);
11056
- enable(): void;
11057
- disable(): void;
11188
+ get(object: object): number | undefined;
11058
11189
  }
11059
11190
  //#endregion
11060
11191
  //#region ../../core/src/store/Store.d.ts
11061
11192
  declare class Store {
11062
11193
  readonly key: KeyGenerator;
11063
11194
  readonly blocks: BlockRegistry;
11064
- readonly nodes: {
11065
- focus: NodeProxy;
11066
- input: NodeProxy;
11067
- };
11068
- readonly props: PropsFeature;
11069
- readonly handler: MarkputHandler;
11070
- readonly lifecycle: LifecycleFeature;
11071
- readonly value: ValueFeature;
11195
+ readonly lifecycle: Lifecycle;
11196
+ readonly props: PropsModel;
11197
+ readonly value: ValueModel;
11072
11198
  readonly mark: MarkFeature;
11073
- readonly overlay: OverlayFeature;
11074
11199
  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;
11081
- constructor();
11200
+ readonly parsing: ParseController;
11201
+ readonly dom: DomController;
11202
+ readonly caret: CaretModel;
11203
+ readonly edit: EditController;
11204
+ readonly overlay: OverlayController;
11205
+ readonly keyboard: KeyboardController;
11206
+ readonly drag: DragController;
11207
+ readonly clipboard: ClipboardController;
11208
+ readonly handler: MarkputHandler;
11082
11209
  }
11083
11210
  //#endregion
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];
11101
- /**
11102
- * Core option for markups - Framework-agnostic configuration.
11103
- * Extended by framework-specific Option types (e.g., React Option).
11104
- *
11105
- * Architecture:
11106
- * - CoreOption: Contains only markup pattern (framework-independent)
11107
- * - trigger configuration: Handled by framework layer via getTrigger function in TriggerFinder
11108
- * - Separation of concerns: Core focuses on markup parsing, framework handles overlay triggers
11109
- */
11110
- interface CoreOption {
11111
- /**
11112
- * Template string in which the mark is rendered.
11113
- * Must contain placeholders: `__value__`, `__meta__`, and/or `__slot__`
11114
- *
11115
- * Placeholder types:
11116
- * - `__value__` - main content (plain text, no nesting)
11117
- * - `__meta__` - additional metadata (plain text, no nesting)
11118
- * - `__slot__` - content supporting nested structures
11119
- *
11120
- * @example
11121
- * // Simple value
11122
- * "@[__value__]"
11123
- *
11124
- * @example
11125
- * // Value with metadata
11126
- * "@[__value__](__meta__)"
11127
- *
11128
- * @example
11129
- * // Nested content support
11130
- * "@[__slot__]"
11131
- */
11132
- markup?: Markup;
11133
- overlay?: {
11134
- trigger?: string;
11135
- };
11136
- }
11137
- type OverlayMatch<TOption = CoreOption> = {
11138
- /**
11139
- * Found value via a overlayMatch
11140
- */
11141
- value: string;
11142
- /**
11143
- * Triggered value
11144
- */
11145
- source: string;
11146
- /**
11147
- * Piece of text, in which was a overlayMatch
11148
- */
11149
- span: string;
11150
- /**
11151
- * Html element, in which was a overlayMatch
11152
- */
11153
- node: Node;
11154
- /**
11155
- * Start position of a overlayMatch
11156
- */
11157
- index: number;
11158
- /**
11159
- * OverlayMatch's option
11160
- */
11161
- option: TOption;
11162
- };
11163
- type Recovery = {
11164
- anchor: NodeProxy;
11165
- isNext?: boolean;
11166
- caret: number;
11167
- childIndex?: number;
11211
+ //#region ../../core/src/shared/editorContracts.d.ts
11212
+ type TokenPath = readonly number[];
11213
+ type TokenAddress = {
11214
+ readonly path: TokenPath;
11215
+ readonly parseGeneration: number;
11168
11216
  };
11169
- type OverlayTrigger = Array<'change' | 'selectionChange'> | 'change' | 'selectionChange' | 'none';
11170
- type CSSProperties$1 = Properties<string | number>;
11171
- type DataAttributes = Record<`data${Capitalize<string>}`, string | number | boolean | undefined>;
11172
- interface CoreSlots {
11173
- container?: Slot;
11174
- block?: Slot;
11175
- span?: Slot;
11176
- }
11177
- interface CoreSlotProps {
11178
- container?: Record<string, unknown> & {
11179
- className?: string;
11180
- style?: CSSProperties$1;
11181
- };
11182
- block?: Record<string, unknown> & {
11183
- className?: string;
11184
- style?: CSSProperties$1;
11185
- };
11186
- span?: Record<string, unknown> & {
11187
- className?: string;
11188
- style?: CSSProperties$1;
11189
- };
11190
- }
11191
- interface DraggableConfig {
11192
- alwaysShowHandle?: boolean;
11193
- }
11194
- type DragAction = {
11195
- type: 'reorder';
11196
- source: number;
11197
- target: number;
11217
+ type Result<T, Reason extends string> = {
11218
+ ok: true;
11219
+ value: T;
11198
11220
  } | {
11199
- type: 'add';
11200
- afterIndex: number;
11221
+ ok: false;
11222
+ reason: Reason;
11223
+ };
11224
+ type DomRef = (element: HTMLElement | null) => void;
11225
+ type Range$1 = {
11226
+ readonly start: number;
11227
+ readonly end: number;
11228
+ };
11229
+ type RawSelection = {
11230
+ readonly range: Range$1;
11231
+ readonly direction?: 'forward' | 'backward';
11232
+ };
11233
+ type NodeLocationResult = Result<{
11234
+ readonly address: TokenAddress;
11235
+ readonly tokenElement: HTMLElement;
11236
+ readonly textElement?: HTMLElement;
11237
+ readonly rowElement?: HTMLElement;
11238
+ }, 'notIndexed' | 'outsideEditor' | 'control'>;
11239
+ type RawSelectionResult = Result<RawSelection, 'notIndexed' | 'outsideEditor' | 'control' | 'mixedBoundary' | 'invalidBoundary'>;
11240
+ type BoundaryPositionResult = Result<number, 'notIndexed' | 'outsideEditor' | 'control' | 'invalidBoundary' | 'composing'>;
11241
+ type OptionalMarkFieldPatch = {
11242
+ readonly kind: 'set';
11243
+ readonly value: string;
11201
11244
  } | {
11202
- type: 'delete';
11203
- index: number;
11245
+ readonly kind: 'clear';
11246
+ };
11247
+ type MarkPatch = {
11248
+ readonly value?: string;
11249
+ readonly meta?: OptionalMarkFieldPatch;
11250
+ readonly slot?: OptionalMarkFieldPatch;
11251
+ };
11252
+ type MarkSnapshot = {
11253
+ readonly value: string;
11254
+ readonly meta: string | undefined;
11255
+ readonly slot: string | undefined;
11256
+ readonly readOnly: boolean;
11257
+ };
11258
+ type MarkInfo = {
11259
+ readonly address: TokenAddress;
11260
+ readonly depth: number;
11261
+ readonly hasNestedMarks: boolean;
11262
+ readonly key: string;
11263
+ };
11264
+ type TokenShapeSnapshot = {
11265
+ readonly kind: 'text';
11204
11266
  } | {
11205
- type: 'duplicate';
11206
- index: number;
11267
+ readonly kind: 'mark';
11268
+ readonly descriptor: MarkupDescriptor;
11269
+ readonly descriptorIndex: number;
11270
+ };
11271
+ type DomIndex = {
11272
+ readonly generation: number;
11273
+ };
11274
+ type DomDiagnostic = {
11275
+ readonly kind: 'missingRole' | 'stalePath' | 'outsideEditor' | 'controlBoundary' | 'mixedBoundary' | 'invalidBoundary' | 'renderReentry' | 'recoveryFailed' | 'missingContainer' | 'ambiguousStructure';
11276
+ readonly path?: TokenPath;
11277
+ readonly reason: string;
11207
11278
  };
11208
- interface DragActions {
11209
- action: {
11210
- (action: DragAction): void;
11211
- };
11212
- }
11213
- interface Feature {
11214
- enable(): void;
11215
- disable(): void;
11216
- }
11217
11279
  //#endregion
11218
11280
  //#region src/types.d.ts
11219
11281
  /**
@@ -11346,7 +11408,10 @@ interface MarkedInputProps<TMarkProps = MarkProps, TOverlayProps extends CoreOpt
11346
11408
  declare function MarkedInput<TMarkProps = MarkProps, TOverlayProps extends CoreOption['overlay'] = OverlayProps>(props: MarkedInputProps<TMarkProps, TOverlayProps>): _$react_jsx_runtime0.JSX.Element;
11347
11409
  //#endregion
11348
11410
  //#region src/lib/hooks/useMark.d.ts
11349
- declare const useMark: <T extends HTMLElement = HTMLElement>(options?: MarkOptions) => MarkHandler<T>;
11411
+ declare const useMark: () => MarkController;
11412
+ //#endregion
11413
+ //#region src/lib/hooks/useMarkInfo.d.ts
11414
+ declare const useMarkInfo: () => MarkInfo;
11350
11415
  //#endregion
11351
11416
  //#region src/lib/hooks/useOverlay.d.ts
11352
11417
  interface OverlayHandler {
@@ -11370,5 +11435,5 @@ type ObjectSelector = Record<string, Selectable<unknown> | unknown>;
11370
11435
  declare function useMarkput<T>(selector: (store: Store) => Selectable<T>): T;
11371
11436
  declare function useMarkput<R extends ObjectSelector>(selector: (store: Store) => R): SignalValues<R>;
11372
11437
  //#endregion
11373
- 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 };
11438
+ export { MarkController, type MarkProps, type MarkToken, MarkedInput, type MarkedInputProps, MarkputHandler, type Markup, type Option, type OverlayHandler, type OverlayProps, type TextToken, type Token, annotate, denote, useMark, useMarkInfo, useMarkput, useOverlay };
11374
11439
  //# sourceMappingURL=index.d.ts.map