@markput/react 0.14.0 → 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,144 +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/shared/editorContracts.d.ts
10767
- type TokenPath = readonly number[];
10768
- type TokenAddress = {
10769
- readonly path: TokenPath;
10770
- readonly parseGeneration: number;
10771
- };
10772
- type Result<T, Reason extends string> = {
10773
- ok: true;
10774
- value: T;
10775
- } | {
10776
- ok: false;
10777
- reason: Reason;
10778
- };
10779
- type DomRef = (element: HTMLElement | null) => void;
10780
- type RawRange = {
10781
- readonly start: number;
10782
- readonly end: number;
10783
- };
10784
- type RawSelection = {
10785
- readonly range: RawRange;
10786
- readonly direction?: 'forward' | 'backward';
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;
10787
10944
  };
10788
- type NodeLocationResult = Result<{
10789
- readonly address: TokenAddress;
10790
- readonly tokenElement: HTMLElement;
10791
- readonly textElement?: HTMLElement;
10792
- readonly rowElement?: HTMLElement;
10793
- }, 'notIndexed' | 'outsideEditor' | 'control'>;
10794
- type RawSelectionResult = Result<RawSelection, 'notIndexed' | 'outsideEditor' | 'control' | 'mixedBoundary' | 'invalidBoundary'>;
10795
- type BoundaryPositionResult = Result<number, 'notIndexed' | 'outsideEditor' | 'control' | 'invalidBoundary' | 'composing'>;
10796
- type EditResult = {
10797
- ok: true;
10798
- value: string;
10799
- accepted: 'immediate' | 'pendingControlledEcho';
10800
- } | {
10801
- ok: false;
10802
- reason: 'readOnly' | 'invalidRange' | 'stale';
10803
- };
10804
- type CaretRecovery = {
10805
- readonly kind: 'caret';
10806
- readonly rawPosition: number;
10807
- readonly affinity?: 'before' | 'after';
10808
- } | {
10809
- readonly kind: 'selection';
10810
- readonly selection: RawSelection;
10811
- };
10812
- type OptionalMarkFieldPatch = {
10813
- readonly kind: 'set';
10814
- readonly value: string;
10815
- } | {
10816
- readonly kind: 'clear';
10817
- };
10818
- type MarkPatch = {
10819
- readonly value?: string;
10820
- readonly meta?: OptionalMarkFieldPatch;
10821
- readonly slot?: OptionalMarkFieldPatch;
10822
- };
10823
- type MarkSnapshot = {
10824
- readonly value: string;
10825
- readonly meta: string | undefined;
10826
- readonly slot: string | undefined;
10827
- readonly readOnly: boolean;
10828
- };
10829
- type MarkInfo = {
10830
- readonly address: TokenAddress;
10831
- readonly depth: number;
10832
- readonly hasNestedMarks: boolean;
10833
- readonly key: string;
10834
- };
10835
- type TokenShapeSnapshot = {
10836
- readonly kind: 'text';
10837
- } | {
10838
- readonly kind: 'mark';
10839
- readonly descriptor: MarkupDescriptor;
10840
- readonly descriptorIndex: number;
10841
- };
10842
- type DomIndex = {
10843
- readonly generation: number;
10844
- };
10845
- type CaretLocation = {
10846
- readonly address: TokenAddress;
10847
- readonly role: 'row' | 'token' | 'text' | 'markDescendant';
10848
- };
10849
- type DomDiagnostic = {
10850
- readonly kind: 'missingRole' | 'stalePath' | 'outsideEditor' | 'controlBoundary' | 'mixedBoundary' | 'invalidBoundary' | 'renderReentry' | 'recoveryFailed' | 'missingContainer' | 'ambiguousStructure';
10851
- readonly path?: TokenPath;
10852
- readonly reason: string;
10853
- };
10854
- type EditSource = 'input' | 'paste' | 'cut' | 'overlay' | 'mark' | 'block' | 'drag';
10855
10945
  //#endregion
10856
- //#region ../../core/src/features/caret/CaretFeature.d.ts
10857
- declare class CaretFeature implements Feature {
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 {
10858
10997
  #private;
10859
- private readonly _store;
10860
- readonly recovery: Signal<CaretRecovery | undefined>;
10861
- readonly location: Signal<CaretLocation | undefined>;
10862
- readonly selecting: Signal<"drag" | "all" | undefined>;
10863
- constructor(_store: Store);
10864
- enable(): void;
10865
- disable(): void;
10866
- placeAt(rawPosition: number, affinity?: 'before' | 'after'): Result<void, 'notIndexed' | 'invalidBoundary'>;
10867
- focus(address: TokenAddress, boundary?: 'start' | 'end'): Result<void, 'notIndexed' | 'stale'>;
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;
10868
11009
  }
10869
11010
  //#endregion
10870
- //#region ../../core/src/shared/signals/signal.d.ts
10871
- interface Signal<T> {
10872
- (): T;
10873
- (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;
10874
11041
  }
10875
- type SignalValues<T> = { [K in keyof T]: T[K] extends Signal<infer V> | Computed<infer V> ? V : T[K] };
10876
- interface Computed<T> {
10877
- (): 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;
10878
11060
  }
10879
- interface Event<T = void> {
10880
- (payload: T): void;
10881
- 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;
10882
11073
  }
10883
11074
  //#endregion
10884
- //#region ../../core/src/features/props/PropsFeature.d.ts
10885
- declare class PropsFeature {
10886
- private readonly _store;
10887
- readonly value: Signal<string | undefined>;
10888
- readonly defaultValue: Signal<string | undefined>;
10889
- readonly onChange: Signal<((value: string) => void) | undefined>;
10890
- readonly options: Signal<CoreOption[]>;
10891
- readonly readOnly: Signal<boolean>;
10892
- readonly layout: Signal<"inline" | "block">;
10893
- readonly draggable: Signal<boolean | DraggableConfig>;
10894
- readonly showOverlayOn: Signal<OverlayTrigger>;
10895
- readonly Span: Signal<_$react.ElementType | undefined>;
10896
- readonly Mark: Signal<_$react.ElementType | undefined>;
10897
- readonly Overlay: Signal<_$react.ElementType | undefined>;
10898
- readonly className: Signal<string | undefined>;
10899
- readonly style: Signal<CSSProperties$1 | undefined>;
10900
- readonly slots: Signal<CoreSlots | undefined>;
10901
- readonly slotProps: Signal<CoreSlotProps | undefined>;
10902
- constructor(_store: Store);
10903
- 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);
10904
11099
  }
10905
11100
  //#endregion
10906
11101
  //#region ../../core/src/store/BlockStore.d.ts
@@ -10935,65 +11130,6 @@ declare class BlockRegistry {
10935
11130
  get(token: object): BlockStore;
10936
11131
  }
10937
11132
  //#endregion
10938
- //#region ../../core/src/features/clipboard/ClipboardFeature.d.ts
10939
- declare class ClipboardFeature {
10940
- #private;
10941
- private readonly store;
10942
- constructor(store: Store);
10943
- enable(): void;
10944
- disable(): void;
10945
- }
10946
- //#endregion
10947
- //#region ../../core/src/features/dom/DomFeature.d.ts
10948
- declare class DomFeature {
10949
- #private;
10950
- private readonly _store;
10951
- readonly index: Computed<DomIndex | undefined>;
10952
- readonly container: Signal<HTMLElement | null>;
10953
- readonly diagnostics: Event<DomDiagnostic>;
10954
- constructor(_store: Store);
10955
- enable(): void;
10956
- disable(): void;
10957
- compositionStarted(): void;
10958
- compositionEnded(): void;
10959
- controlFor(ownerPath?: TokenPath): DomRef;
10960
- childrenFor(ownerPath: TokenPath): DomRef;
10961
- reconcile(): void;
10962
- locateNode(node: Node): NodeLocationResult;
10963
- placeCaretAtRawPosition(rawPosition: number, affinity?: 'before' | 'after'): Result<void, 'notIndexed' | 'invalidBoundary'>;
10964
- focusAddress(address: TokenAddress, boundary?: 'start' | 'end'): Result<void, 'notIndexed' | 'stale'>;
10965
- rawPositionFromBoundary(node: Node, offset: number, affinity?: 'before' | 'after'): BoundaryPositionResult;
10966
- readRawSelection(): RawSelectionResult;
10967
- }
10968
- //#endregion
10969
- //#region ../../core/src/features/drag/DragFeature.d.ts
10970
- declare class DragFeature {
10971
- #private;
10972
- private readonly store;
10973
- readonly action: Event<DragAction>;
10974
- constructor(store: Store);
10975
- enable(): void;
10976
- disable(): void;
10977
- }
10978
- //#endregion
10979
- //#region ../../core/src/features/keyboard/KeyboardFeature.d.ts
10980
- declare class KeyboardFeature implements Feature {
10981
- #private;
10982
- private readonly _store;
10983
- constructor(_store: Store);
10984
- enable(): void;
10985
- disable(): void;
10986
- }
10987
- //#endregion
10988
- //#region ../../core/src/features/lifecycle/LifecycleFeature.d.ts
10989
- declare class LifecycleFeature implements Feature {
10990
- readonly mounted: Event<void>;
10991
- readonly unmounted: Event<void>;
10992
- readonly rendered: Event<void>;
10993
- enable(): void;
10994
- disable(): void;
10995
- }
10996
- //#endregion
10997
11133
  //#region ../../core/src/features/mark/MarkController.d.ts
10998
11134
  declare class MarkController {
10999
11135
  #private;
@@ -11006,52 +11142,20 @@ declare class MarkController {
11006
11142
  get meta(): string | undefined;
11007
11143
  get slot(): string | undefined;
11008
11144
  get readOnly(): boolean;
11009
- remove(): EditResult;
11010
- update(patch: MarkPatch): EditResult;
11011
- }
11012
- //#endregion
11013
- //#region ../../core/src/features/slots/types.d.ts
11014
- interface MarkSlot {
11015
- (): (token: Token) => readonly [Slot, Record<string, unknown>];
11016
- }
11017
- interface OverlaySlot {
11018
- (): (option?: CoreOption, defaultComponent?: Slot) => readonly [Slot, Record<string, unknown>];
11145
+ remove(): void;
11146
+ update(patch: MarkPatch): void;
11019
11147
  }
11020
11148
  //#endregion
11021
- //#region ../../core/src/features/slots/SlotsFeature.d.ts
11022
- declare class SlotsFeature implements Feature {
11023
- private readonly _store;
11024
- readonly isBlock: Computed<boolean>;
11025
- readonly isDraggable: Computed<boolean>;
11026
- readonly containerComponent: Computed<Slot>;
11027
- readonly containerProps: Computed<{
11028
- className: string | undefined;
11029
- style?: CSSProperties$1;
11030
- [key: string]: unknown;
11031
- }>;
11032
- readonly blockComponent: Computed<Slot>;
11033
- readonly blockProps: Computed<Record<string, unknown> | undefined>;
11034
- readonly spanComponent: Computed<Slot>;
11035
- readonly spanProps: Computed<Record<string, unknown> | undefined>;
11036
- constructor(_store: Store);
11037
- enable(): void;
11038
- disable(): void;
11039
- }
11040
- //#endregion
11041
- //#region ../../core/src/features/mark/MarkFeature.d.ts
11042
- declare class MarkFeature implements Feature {
11043
- private readonly _store;
11044
- readonly enabled: Computed<boolean>;
11045
- readonly slot: MarkSlot;
11046
- constructor(_store: Store);
11047
- enable(): void;
11048
- disable(): void;
11049
- }
11050
- //#endregion
11051
- //#region ../../core/src/features/overlay/OverlayFeature.d.ts
11052
- declare class OverlayFeature implements Feature {
11149
+ //#region ../../core/src/features/overlay/OverlayController.d.ts
11150
+ declare class OverlayController {
11053
11151
  #private;
11054
- 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;
11055
11159
  readonly match: Signal<OverlayMatch | undefined>;
11056
11160
  readonly element: Signal<HTMLElement | null>;
11057
11161
  readonly slot: OverlaySlot;
@@ -11060,62 +11164,19 @@ declare class OverlayFeature implements Feature {
11060
11164
  match: OverlayMatch;
11061
11165
  }>;
11062
11166
  readonly close: Event<void>;
11063
- constructor(_store: Store);
11064
- enable(): void;
11065
- disable(): void;
11066
- }
11067
- //#endregion
11068
- //#region ../../core/src/features/parsing/tokenIndex.d.ts
11069
- type TokenIndex = {
11070
- readonly generation: number;
11071
- pathFor(token: Token): TokenPath | undefined;
11072
- addressFor(path: TokenPath): TokenAddress | undefined;
11073
- resolve(path: TokenPath): Token | undefined;
11074
- resolveAddress(address: TokenAddress, expected?: TokenShapeSnapshot): Result<Token, 'stale'>;
11075
- key(path: TokenPath): string;
11076
- equals(a: TokenPath, b: TokenPath): boolean;
11077
- };
11078
- //#endregion
11079
- //#region ../../core/src/features/parsing/ParseFeature.d.ts
11080
- declare class ParsingFeature implements Feature {
11081
- #private;
11082
- private readonly _store;
11083
- readonly tokens: Signal<Token[]>;
11084
- readonly index: Computed<TokenIndex>;
11085
- readonly parser: Computed<Parser | undefined>;
11086
- readonly reparse: Event<void>;
11087
- constructor(_store: Store);
11088
- parseValue(value: string): Token[];
11089
- acceptTokens(tokens: Token[]): void;
11090
- enable(): void;
11091
- disable(): void;
11092
- sync(value?: string): void;
11093
- }
11094
- //#endregion
11095
- //#region ../../core/src/features/value/ValueFeature.d.ts
11096
- declare class ValueFeature implements Feature {
11097
- #private;
11098
- private readonly _store;
11099
- readonly current: Signal<string>;
11100
- readonly isControlledMode: Computed<boolean>;
11101
- readonly change: Event<void>;
11102
- constructor(_store: Store);
11103
- enable(): void;
11104
- disable(): void;
11105
- replaceRange(range: RawRange, replacement: string, options?: {
11106
- recover?: CaretRecovery;
11107
- source?: EditSource;
11108
- }): EditResult;
11109
- replaceAll(next: string, options?: {
11110
- recover?: CaretRecovery;
11111
- source?: EditSource;
11112
- }): EditResult;
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);
11113
11172
  }
11114
11173
  //#endregion
11115
11174
  //#region ../../core/src/shared/classes/MarkputHandler.d.ts
11116
11175
  declare class MarkputHandler {
11117
- private readonly store;
11118
- constructor(store: Store);
11176
+ private readonly dom;
11177
+ private readonly overlayFeature;
11178
+ private readonly parsing;
11179
+ constructor(dom: DomController, overlayFeature: OverlayController, parsing: ParseController);
11119
11180
  get container(): HTMLElement | null;
11120
11181
  get overlay(): HTMLElement | null;
11121
11182
  focus(): void;
@@ -11131,146 +11192,90 @@ declare class KeyGenerator {
11131
11192
  declare class Store {
11132
11193
  readonly key: KeyGenerator;
11133
11194
  readonly blocks: BlockRegistry;
11134
- readonly props: PropsFeature;
11135
- readonly handler: MarkputHandler;
11136
- readonly lifecycle: LifecycleFeature;
11137
- readonly value: ValueFeature;
11195
+ readonly lifecycle: Lifecycle;
11196
+ readonly props: PropsModel;
11197
+ readonly value: ValueModel;
11138
11198
  readonly mark: MarkFeature;
11139
- readonly overlay: OverlayFeature;
11140
11199
  readonly slots: SlotsFeature;
11141
- readonly caret: CaretFeature;
11142
- readonly keyboard: KeyboardFeature;
11143
- readonly dom: DomFeature;
11144
- readonly drag: DragFeature;
11145
- readonly clipboard: ClipboardFeature;
11146
- readonly parsing: ParsingFeature;
11147
- 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;
11148
11209
  }
11149
11210
  //#endregion
11150
- //#region ../../core/src/shared/types.d.ts
11151
- /**
11152
- * Registry interface used as a module-augmentation target. Framework packages
11153
- * add a `default` property whose type is the framework's component type.
11154
- *
11155
- * @example React augmentation
11156
- * declare module '@markput/core' {
11157
- * interface SlotRegistry {
11158
- * default: import('react').ElementType
11159
- * }
11160
- * }
11161
- *
11162
- * Without augmentation, `Slot` falls back to `unknown`.
11163
- */
11164
- interface SlotRegistry {}
11165
- /** Framework-provided component type. Resolves to `unknown` unless `SlotRegistry` is augmented. */
11166
- type Slot = keyof SlotRegistry extends never ? unknown : SlotRegistry[keyof SlotRegistry];
11167
- /**
11168
- * Core option for markups - Framework-agnostic configuration.
11169
- * Extended by framework-specific Option types (e.g., React Option).
11170
- *
11171
- * Architecture:
11172
- * - CoreOption: Contains only markup pattern (framework-independent)
11173
- * - trigger configuration: Handled by framework layer via getTrigger function in TriggerFinder
11174
- * - Separation of concerns: Core focuses on markup parsing, framework handles overlay triggers
11175
- */
11176
- interface CoreOption {
11177
- /**
11178
- * Template string in which the mark is rendered.
11179
- * Must contain placeholders: `__value__`, `__meta__`, and/or `__slot__`
11180
- *
11181
- * Placeholder types:
11182
- * - `__value__` - main content (plain text, no nesting)
11183
- * - `__meta__` - additional metadata (plain text, no nesting)
11184
- * - `__slot__` - content supporting nested structures
11185
- *
11186
- * @example
11187
- * // Simple value
11188
- * "@[__value__]"
11189
- *
11190
- * @example
11191
- * // Value with metadata
11192
- * "@[__value__](__meta__)"
11193
- *
11194
- * @example
11195
- * // Nested content support
11196
- * "@[__slot__]"
11197
- */
11198
- markup?: Markup;
11199
- overlay?: {
11200
- trigger?: string;
11201
- };
11202
- }
11203
- type OverlayMatch<TOption = CoreOption> = {
11204
- /**
11205
- * Found value via a overlayMatch
11206
- */
11207
- value: string;
11208
- /**
11209
- * Triggered value
11210
- */
11211
- source: string;
11212
- /**
11213
- * Piece of text, in which was a overlayMatch
11214
- */
11215
- span: string;
11216
- /**
11217
- * Html element, in which was a overlayMatch
11218
- */
11219
- node: Node;
11220
- range: RawRange;
11221
- /**
11222
- * OverlayMatch's option
11223
- */
11224
- option: TOption;
11211
+ //#region ../../core/src/shared/editorContracts.d.ts
11212
+ type TokenPath = readonly number[];
11213
+ type TokenAddress = {
11214
+ readonly path: TokenPath;
11215
+ readonly parseGeneration: number;
11225
11216
  };
11226
- type OverlayTrigger = Array<'change' | 'selectionChange'> | 'change' | 'selectionChange' | 'none';
11227
- type CSSProperties$1 = Properties<string | number>;
11228
- type DataAttributes = Record<`data${Capitalize<string>}`, string | number | boolean | undefined>;
11229
- interface CoreSlots {
11230
- container?: Slot;
11231
- block?: Slot;
11232
- span?: Slot;
11233
- }
11234
- interface CoreSlotProps {
11235
- container?: Record<string, unknown> & {
11236
- className?: string;
11237
- style?: CSSProperties$1;
11238
- };
11239
- block?: Record<string, unknown> & {
11240
- className?: string;
11241
- style?: CSSProperties$1;
11242
- };
11243
- span?: Record<string, unknown> & {
11244
- className?: string;
11245
- style?: CSSProperties$1;
11246
- };
11247
- }
11248
- interface DraggableConfig {
11249
- alwaysShowHandle?: boolean;
11250
- }
11251
- type DragAction = {
11252
- type: 'reorder';
11253
- source: number;
11254
- target: number;
11217
+ type Result<T, Reason extends string> = {
11218
+ ok: true;
11219
+ value: T;
11255
11220
  } | {
11256
- type: 'add';
11257
- 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;
11258
11244
  } | {
11259
- type: 'delete';
11260
- 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';
11261
11266
  } | {
11262
- type: 'duplicate';
11263
- 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;
11264
11278
  };
11265
- interface DragActions {
11266
- action: {
11267
- (action: DragAction): void;
11268
- };
11269
- }
11270
- interface Feature {
11271
- enable(): void;
11272
- disable(): void;
11273
- }
11274
11279
  //#endregion
11275
11280
  //#region src/types.d.ts
11276
11281
  /**