@markput/react 0.14.1 → 0.14.2

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,6 +38,35 @@ 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
41
70
  //#region ../../core/src/features/parsing/parser/types.d.ts
42
71
  type Token = TextToken | MarkToken;
43
72
  interface TextToken {
@@ -65,12 +94,6 @@ interface MarkToken {
65
94
  };
66
95
  children: Token[];
67
96
  }
68
- interface ParseOptions {
69
- /** Return only MarkTokens, drop all TextTokens */
70
- marksOnly?: boolean;
71
- /** Drop zero-length TextTokens (where start === end) */
72
- skipEmptyText?: boolean;
73
- }
74
97
  /**
75
98
  * Template literal types for markup placeholders
76
99
  */
@@ -89,62 +112,59 @@ type SlotMarkup = `${string}${typeof PLACEHOLDER.Slot}${string}`;
89
112
  */
90
113
  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}`;
91
114
  //#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
- }
115
+ //#region ../../core/src/shared/editorContracts.d.ts
116
+ type TokenPath = readonly number[];
117
+ type TokenAddress = {
118
+ readonly path: TokenPath;
119
+ readonly token: Token;
120
+ };
121
+ type Result<T, Reason extends string> = {
122
+ ok: true;
123
+ value: T;
124
+ } | {
125
+ ok: false;
126
+ reason: Reason;
127
+ };
128
+ type DomRef = (element: HTMLElement | null) => void;
129
+ type Range$1 = {
130
+ readonly start: number;
131
+ readonly end: number;
132
+ };
133
+ type RawSelection = {
134
+ readonly range: Range$1;
135
+ readonly direction?: 'forward' | 'backward';
136
+ };
137
+ type NodeLocationResult = Result<{
138
+ readonly address: TokenAddress;
139
+ readonly tokenElement: HTMLElement;
140
+ readonly textElement?: HTMLElement;
141
+ readonly rowElement?: HTMLElement;
142
+ }, 'notIndexed' | 'outsideEditor' | 'control'>;
143
+ type RawSelectionResult = Result<RawSelection, 'notIndexed' | 'outsideEditor' | 'control' | 'mixedBoundary' | 'invalidBoundary'>;
144
+ type BoundaryPositionResult = Result<number, 'notIndexed' | 'outsideEditor' | 'control' | 'invalidBoundary' | 'composing'>;
145
+ type OptionalMarkFieldPatch = {
146
+ readonly kind: 'set';
147
+ readonly value: string;
148
+ } | {
149
+ readonly kind: 'clear';
150
+ };
151
+ type MarkPatch = {
152
+ readonly value?: string;
153
+ readonly meta?: OptionalMarkFieldPatch;
154
+ readonly slot?: OptionalMarkFieldPatch;
155
+ };
156
+ type MarkSnapshot = {
157
+ readonly value: string;
158
+ readonly meta: string | undefined;
159
+ readonly slot: string | undefined;
160
+ readonly readOnly: boolean;
161
+ };
162
+ type MarkInfo = {
163
+ readonly address: TokenAddress;
164
+ readonly depth: number;
165
+ readonly hasNestedMarks: boolean;
166
+ readonly key: string;
167
+ };
148
168
  //#endregion
149
169
  //#region ../../../node_modules/.pnpm/csstype@3.2.3/node_modules/csstype/index.d.ts
150
170
  interface StandardLonghandProperties<TLength = (string & {}) | 0, TTime = string & {}> {
@@ -10599,7 +10619,7 @@ type Slot = keyof SlotRegistry extends never ? unknown : SlotRegistry[keyof Slot
10599
10619
  * Architecture:
10600
10620
  * - CoreOption: Contains only markup pattern (framework-independent)
10601
10621
  * - trigger configuration: Handled by framework layer via getTrigger function in TriggerFinder
10602
- * - Separation of concerns: Core focuses on markup parsing, framework handles overlay triggers
10622
+ * - Separation of concerns: Core focuses on markup tokens, framework handles overlay triggers
10603
10623
  */
10604
10624
  interface CoreOption {
10605
10625
  /**
@@ -10657,7 +10677,6 @@ type DataAttributes = Record<`data${Capitalize<string>}`, string | number | bool
10657
10677
  interface CoreSlots {
10658
10678
  container?: Slot;
10659
10679
  block?: Slot;
10660
- span?: Slot;
10661
10680
  }
10662
10681
  interface CoreSlotProps {
10663
10682
  container?: Record<string, unknown> & {
@@ -10668,10 +10687,6 @@ interface CoreSlotProps {
10668
10687
  className?: string;
10669
10688
  style?: CSSProperties$1;
10670
10689
  };
10671
- span?: Record<string, unknown> & {
10672
- className?: string;
10673
- style?: CSSProperties$1;
10674
- };
10675
10690
  }
10676
10691
  interface DraggableConfig {
10677
10692
  alwaysShowHandle?: boolean;
@@ -10696,14 +10711,31 @@ interface DragActions {
10696
10711
  };
10697
10712
  }
10698
10713
  //#endregion
10699
- //#region ../../core/src/features/props/PropsModel.d.ts
10714
+ //#region ../../core/src/shared/signals/signal.d.ts
10715
+ interface Signal<T> {
10716
+ (): T;
10717
+ (value: T | undefined): boolean;
10718
+ }
10719
+ type SignalValues<T> = { [K in keyof T]: T[K] extends Signal<infer V> | Computed<infer V> ? V : T[K] };
10720
+ type ComputedRecord<C> = { readonly [K in keyof C]: C[K] extends (() => infer R) ? Computed<R> : never };
10721
+ interface Computed<T> {
10722
+ (): T;
10723
+ }
10724
+ interface Event<T = void> {
10725
+ (payload: T): void;
10726
+ read(): T | undefined;
10727
+ }
10728
+ //#endregion
10729
+ //#region ../../core/src/features/state/PropsModel.d.ts
10700
10730
  declare class PropsModel {
10701
10731
  readonly value: Signal<string | undefined>;
10702
10732
  readonly defaultValue: Signal<string | undefined>;
10703
10733
  readonly onChange: Signal<((value: string) => void) | undefined>;
10704
10734
  readonly options: Signal<CoreOption[]>;
10705
10735
  readonly readOnly: Signal<boolean>;
10706
- readonly layout: Signal<"inline" | "block">;
10736
+ readonly layout: Signal<"inline" | "block"> & ComputedRecord<{
10737
+ isBlock: () => boolean;
10738
+ }>;
10707
10739
  readonly draggable: Signal<boolean | DraggableConfig>;
10708
10740
  readonly showOverlayOn: Signal<OverlayTrigger>;
10709
10741
  readonly Span: Signal<_$react.ElementType | undefined>;
@@ -10716,347 +10748,111 @@ declare class PropsModel {
10716
10748
  set(values: Partial<SignalValues<typeof this>>): void;
10717
10749
  }
10718
10750
  //#endregion
10719
- //#region ../../core/src/features/parsing/parser/Parser.d.ts
10720
- /**
10721
- * Parser - High-performance tree-based markup parser
10722
- *
10723
- * Parses text with markup patterns into a nested token tree structure.
10724
- * Supports complex patterns with metadata, nesting, and HTML-like constructs.
10725
- *
10726
- * @example
10727
- * ```typescript
10728
- * const parser = new Parser(['@[__value__](__meta__)', '#[__slot__]'])
10729
- * const tokens = parser.parse('Hello @[world](test) and #[tag]')
10730
- * const text = parser.stringify(tokens)
10731
- * ```
10732
- */
10733
- declare class Parser {
10734
- private readonly registry;
10735
- private readonly segmentMatcher;
10736
- private readonly patternMatcher;
10737
- private readonly treeBuilder;
10738
- private readonly parseOptions;
10739
- /**
10740
- * Creates a new Parser instance with the specified markup patterns
10741
- *
10742
- * @param markups - Array of markup pattern strings with placeholders (can include undefined values):
10743
- * - `__value__` - main content (plain text, no nesting)
10744
- * - `__meta__` - metadata (plain text, no nesting)
10745
- * - `__slot__` - content supporting nested structures
10746
- * - `undefined` - skipped, but original array indices are preserved for descriptor matching
10747
- * @param options - Optional parse options to control token output:
10748
- * - `marksOnly` - return only MarkTokens, drop all TextTokens
10749
- * - `skipEmptyText` - drop zero-length TextTokens (where start === end)
10750
- *
10751
- * @example
10752
- * ```typescript
10753
- * const parser = new Parser([
10754
- * '@[__value__](__meta__)', // @[label](value) - descriptor.index = 0
10755
- * undefined, // skipped
10756
- * '#[__slot__]', // #[nested content] - descriptor.index = 2
10757
- * '**__slot__**' // **bold text** - descriptor.index = 3
10758
- * ])
10759
- * ```
10760
- */
10761
- constructor(markups: (Markup | undefined)[], options?: ParseOptions);
10762
- /**
10763
- * Parses text into tokens (static convenience method)
10764
- *
10765
- * @param value - Text to parse
10766
- * @param options - Options with markup patterns and token filtering
10767
- * @returns Array of tokens (TextToken and MarkToken)
10768
- *
10769
- * @example
10770
- * ```typescript
10771
- * const tokens = Parser.parse('Hello @[world]', {
10772
- * markup: ['@[__value__]']
10773
- * })
10774
- * ```
10775
- */
10776
- static parse(value: string, options?: {
10777
- markup: Markup[];
10778
- } & ParseOptions): Token[];
10779
- /**
10780
- * Converts tokens back to text (static convenience method)
10781
- *
10782
- * @param tokens - Array of tokens to convert
10783
- * @returns Reconstructed text string
10784
- *
10785
- * @example
10786
- * ```typescript
10787
- * const text = Parser.stringify(tokens)
10788
- * ```
10789
- */
10790
- static stringify(tokens: Token[]): string;
10791
- /**
10792
- * Parses text into a nested token tree
10793
- *
10794
- * This is the main parsing method. It processes the input text through
10795
- * three stages:
10796
- * 1. Segment matching - finds all markup segments (O(N + M))
10797
- * 2. Pattern matching - builds complete patterns from segments (O(M))
10798
- * 3. Tree building - constructs nested token tree (O(M·D))
10799
- *
10800
- * @param value - Text to parse
10801
- * @returns Array of tokens representing the parsed structure
10802
- *
10803
- * @example
10804
- * ```typescript
10805
- * const parser = new Parser(['@[__value__](__meta__)'])
10806
- * const tokens = parser.parse('Hello @[world](test)')
10807
- * // Returns: [
10808
- * // TextToken('Hello '),
10809
- * // MarkToken('@[world](test)', value='world', meta='test'),
10810
- * // TextToken('')
10811
- * // ]
10812
- * ```
10813
- */
10814
- parse(value: string): Token[];
10815
- /**
10816
- * Converts tokens back to the original text
10817
- *
10818
- * This is the inverse operation of parse(). It reconstructs the original
10819
- * text from a token tree, preserving all markup and structure.
10820
- *
10821
- * @param tokens - Array of tokens to convert
10822
- * @returns Reconstructed text string
10823
- *
10824
- * @example
10825
- * ```typescript
10826
- * const text = 'Hello @[world](test)'
10827
- * const tokens = parser.parse(text)
10828
- * const reconstructed = parser.stringify(tokens)
10829
- * console.log(reconstructed === text) // true
10830
- * ```
10831
- */
10832
- stringify(tokens: Token[]): string;
10833
- /**
10834
- * Transforms annotated text by processing all mark tokens with a callback
10835
- *
10836
- * This method parses the text, recursively processes all MarkTokens
10837
- * (including nested ones) with the provided callback, and returns
10838
- * the transformed text.
10839
- *
10840
- * @param value - Annotated text to process
10841
- * @param callback - Function to transform each MarkToken
10842
- * @returns Transformed text
10843
- *
10844
- * @example
10845
- * ```typescript
10846
- * // Extract all values
10847
- * const text = '@[Hello](world) and #[tag]'
10848
- * const result = parser.transform(text, mark => mark.value)
10849
- * // Returns: 'Hello and tag'
10850
- *
10851
- * // Custom transformation
10852
- * const result = parser.transform(text, mark =>
10853
- * mark.meta ? `${mark.value}:${mark.meta}` : mark.value
10854
- * )
10855
- * // Returns: 'Hello:world and tag'
10856
- * ```
10857
- */
10858
- transform(value: string, callback: (mark: MarkToken) => string): string;
10859
- /**
10860
- * Escapes markup segments in the given text using backslash
10861
- *
10862
- * This method uses the registry's unique segments and escapes them by adding
10863
- * a backslash before each character of each segment, preventing them from being
10864
- * parsed as markup when the text is processed again.
10865
- *
10866
- * @param text - Text to escape segments in
10867
- * @returns Text with escaped segments
10868
- *
10869
- * @example
10870
- * ```typescript
10871
- * const parser = new Parser(['**__slot__**', '@[__value__]'])
10872
- * const escaped = parser.escape('Hello **world** and @[user]')
10873
- * // Returns: 'Hello \*\*world\*\* and \@[user]'
10874
- * ```
10875
- */
10876
- escape(text: string): string;
10751
+ //#region ../../core/src/features/state/ValueModel.d.ts
10752
+ declare class ValueModel {
10753
+ private readonly props;
10754
+ readonly current: Signal<string>;
10755
+ constructor(props: PropsModel);
10877
10756
  /**
10878
- * Unescapes markup patterns in the given text
10879
- *
10880
- * This method removes escape characters from segments that were previously
10881
- * escaped using escape(), allowing the patterns to be parsed normally.
10882
- *
10883
- * @param text - Text to unescape patterns in
10884
- * @returns Text with unescaped patterns
10885
- *
10886
- * @example
10887
- * ```typescript
10888
- * const parser = new Parser(['**__slot__**', '@[__value__]'])
10889
- * const unescaped = parser.unescape('Hello \*\*world\*\* and \@[user]')
10890
- * // Returns: 'Hello **world** and @[user]'
10891
- * ```
10757
+ * Attempts to replace `range` with `replacement`. Returns `true` when the
10758
+ * edit was accepted (range valid and not read-only), `false` otherwise.
10759
+ * Callers use the return value to gate downstream side effects such as
10760
+ * caret placement.
10892
10761
  */
10893
- unescape(text: string): string;
10762
+ replace(range: Range$1, replacement: string): boolean;
10894
10763
  }
10895
10764
  //#endregion
10896
- //#region ../../core/src/features/parsing/parser/utils/annotate.d.ts
10897
- /**
10898
- * Make annotation from the markup for ParserV2
10899
- *
10900
- * @param markup - Markup pattern with __value__, __meta__, and/or __slot__ placeholders
10901
- * @param params - Object with optional value, meta, and slot strings
10902
- * @returns Annotated string with placeholders replaced
10903
- *
10904
- * @example
10905
- * ```typescript
10906
- * annotate('@[__value__]', { value: 'Hello' }) // '@[Hello]'
10907
- * annotate('@[__value__](__meta__)', { value: 'Hello', meta: 'world' }) // '@[Hello](world)'
10908
- * annotate('@[__slot__]', { slot: 'content' }) // '@[content]'
10909
- * ```
10910
- */
10911
- declare function annotate(markup: Markup, params: {
10912
- value?: string;
10913
- meta?: string;
10914
- slot?: string;
10915
- }): string;
10916
- //#endregion
10917
- //#region ../../core/src/features/parsing/parser/utils/denote.d.ts
10918
- /**
10919
- * Transform annotated text to another text by recursively processing all tokens
10920
- *
10921
- * @param value - Annotated text to process
10922
- * @param callback - Function to transform each MarkToken
10923
- * @param markups - Array of markup patterns to parse
10924
- * @returns Transformed text
10925
- *
10926
- * @example
10927
- * ```typescript
10928
- * const text = '@[Hello](world) and #[nested @[content]]'
10929
- * const result = denote(text, mark => mark.value, ['@[__value__](__meta__)', '#[__slot__]'])
10930
- * // Returns: 'Hello and nested content'
10931
- * ```
10932
- */
10933
- declare function denote(value: string, callback: (mark: MarkToken) => string, markups: Markup[]): string;
10934
- //#endregion
10935
10765
  //#region ../../core/src/features/parsing/tokenIndex.d.ts
10936
10766
  type TokenIndex = {
10937
- readonly generation: number;
10938
10767
  pathFor(token: Token): TokenPath | undefined;
10939
10768
  addressFor(path: TokenPath): TokenAddress | undefined;
10940
10769
  resolve(path: TokenPath): Token | undefined;
10941
- resolveAddress(address: TokenAddress, expected?: TokenShapeSnapshot): Result<Token, 'stale'>;
10770
+ resolveAddress(address: TokenAddress): Result<Token, 'stale'>;
10942
10771
  key(path: TokenPath): string;
10943
- equals(a: TokenPath, b: TokenPath): boolean;
10944
10772
  };
10945
10773
  //#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 {
10774
+ //#region ../../core/src/features/parsing/TokenModel.d.ts
10775
+ declare class TokenModel {
10776
+ #private;
10777
+ private readonly value;
10974
10778
  private readonly props;
10975
- readonly enabled: Computed<boolean>;
10976
- readonly slot: MarkSlot;
10977
- constructor(props: PropsModel);
10779
+ readonly current: Computed<Token[]>;
10780
+ readonly index: Computed<TokenIndex>;
10781
+ constructor(value: ValueModel, props: PropsModel);
10978
10782
  }
10979
10783
  //#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);
10784
+ //#region ../../core/src/features/state/Lifecycle.d.ts
10785
+ declare class Lifecycle {
10786
+ readonly mounted: Event<void>;
10787
+ readonly unmounted: Event<void>;
10788
+ readonly rendered: Event<void>;
10986
10789
  /**
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.
10790
+ * Run `setup` when the editor is mounted. Any reactive subscription
10791
+ * created inside `setup` (`watch`, `listen`, `effect`, nested
10792
+ * `effectScope`) is automatically disposed on `unmounted` and re-created
10793
+ * on the next `mounted`.
10991
10794
  */
10992
- replace(range: Range$1, replacement: string): boolean;
10795
+ onMounted(setup: () => void): void;
10993
10796
  }
10994
10797
  //#endregion
10995
- //#region ../../core/src/features/parsing/ParseController.d.ts
10996
- declare class ParseController {
10997
- #private;
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;
11009
- }
10798
+ //#region ../../core/src/features/dom/DomIndexer.d.ts
10799
+ type PathElements = {
10800
+ path: TokenPath;
10801
+ address: TokenAddress;
10802
+ rowElement?: HTMLElement;
10803
+ tokenElement: HTMLElement;
10804
+ textElement?: HTMLElement;
10805
+ };
11010
10806
  //#endregion
11011
- //#region ../../core/src/features/dom/DomController.d.ts
11012
- declare class DomController {
10807
+ //#region ../../core/src/features/dom/DomModel.d.ts
10808
+ declare class DomModel {
11013
10809
  #private;
11014
- private readonly lifecycle;
11015
- private readonly props;
11016
- private readonly parsing;
11017
- private readonly value;
11018
- readonly index: Computed<DomIndex | undefined>;
11019
10810
  readonly container: Signal<HTMLElement | null>;
11020
- readonly diagnostics: Event<DomDiagnostic>;
11021
10811
  readonly indexed: Event<void>;
11022
- readonly readOnly: Computed<boolean>;
11023
- constructor(lifecycle: Lifecycle, props: PropsModel, parsing: ParseController, value: ValueModel);
10812
+ readonly isUserSelecting: Signal<boolean>;
10813
+ readonly isIndexed: Signal<boolean>;
10814
+ constructor(lifecycle: Lifecycle, props: PropsModel, tokens: TokenModel);
11024
10815
  compositionStarted(): void;
11025
10816
  compositionEnded(): void;
11026
10817
  controlFor(ownerPath?: TokenPath): DomRef;
11027
10818
  childrenFor(ownerPath: TokenPath): DomRef;
11028
- reconcile(opts?: {
11029
- isUserSelecting?: boolean;
11030
- }): void;
10819
+ reconcile(): void;
11031
10820
  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'>;
10821
+ pathElements(): IterableIterator<PathElements>;
10822
+ pathElementsFor(address: TokenAddress): PathElements | undefined;
11039
10823
  rawPositionFromBoundary(node: Node, offset: number, affinity?: 'before' | 'after'): BoundaryPositionResult;
11040
10824
  readRawSelection(): RawSelectionResult;
10825
+ readSelectedContent(): {
10826
+ html: string;
10827
+ text: string;
10828
+ } | undefined;
11041
10829
  }
11042
10830
  //#endregion
11043
- //#region ../../core/src/features/caret/CaretModel.d.ts
11044
- declare class CaretModel {
10831
+ //#region ../../core/src/features/selection/SelectionController.d.ts
10832
+ declare class SelectionController {
11045
10833
  #private;
11046
10834
  private readonly lifecycle;
11047
10835
  private readonly dom;
10836
+ private readonly parsing;
11048
10837
  private readonly value;
11049
- readonly selection: Signal<Range$1 | undefined>;
10838
+ private readonly props;
10839
+ readonly range: Signal<Range$1 | undefined>;
11050
10840
  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
10841
  readonly isAllSelected: Computed<boolean>;
11058
- constructor(lifecycle: Lifecycle, dom: DomController, value: ValueModel);
10842
+ constructor(lifecycle: Lifecycle, dom: DomModel, parsing: TokenModel, value: ValueModel, props: PropsModel);
10843
+ focusFirst(): void;
11059
10844
  selectAll(): void;
10845
+ /**
10846
+ * Place the caret at a known token address. Use this when the caller already
10847
+ * has a {@link TokenAddress} and needs to disambiguate which token owns a
10848
+ * shared boundary position (e.g. a text-token ending at N and a mark-token
10849
+ * starting at N both "own" position N). Position-only callers should write
10850
+ * to `range` instead — the auto-apply effect handles the common case.
10851
+ *
10852
+ * Returns `true` when the address could be resolved and focused, `false`
10853
+ * when the DOM is not yet indexed or the address is stale.
10854
+ */
10855
+ placeAtAddress(address: TokenAddress, boundary?: 'start' | 'end'): boolean;
11060
10856
  }
11061
10857
  //#endregion
11062
10858
  //#region ../../core/src/features/edit/EditController.d.ts
@@ -11067,38 +10863,62 @@ declare class CaretModel {
11067
10863
  */
11068
10864
  declare class EditController {
11069
10865
  private readonly value;
11070
- private readonly caret;
11071
- constructor(value: ValueModel, caret: CaretModel);
10866
+ private readonly selection;
10867
+ constructor(value: ValueModel, selection: SelectionController);
11072
10868
  replace(range: Range$1, replacement: string): void;
11073
10869
  }
11074
10870
  //#endregion
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
- }
10871
+ //#region ../../core/src/features/parsing/parser/utils/annotate.d.ts
10872
+ /**
10873
+ * Make annotation from the markup for ParserV2
10874
+ *
10875
+ * @param markup - Markup pattern with __value__, __meta__, and/or __slot__ placeholders
10876
+ * @param params - Object with optional value, meta, and slot strings
10877
+ * @returns Annotated string with placeholders replaced
10878
+ *
10879
+ * @example
10880
+ * ```typescript
10881
+ * annotate('@[__value__]', { value: 'Hello' }) // '@[Hello]'
10882
+ * annotate('@[__value__](__meta__)', { value: 'Hello', meta: 'world' }) // '@[Hello](world)'
10883
+ * annotate('@[__slot__]', { slot: 'content' }) // '@[content]'
10884
+ * ```
10885
+ */
10886
+ declare function annotate(markup: Markup, params: {
10887
+ value?: string;
10888
+ meta?: string;
10889
+ slot?: string;
10890
+ }): string;
10891
+ //#endregion
10892
+ //#region ../../core/src/features/parsing/parser/utils/denote.d.ts
10893
+ /**
10894
+ * Transform annotated text to another text by recursively processing all tokens
10895
+ *
10896
+ * @param value - Annotated text to process
10897
+ * @param callback - Function to transform each MarkToken
10898
+ * @param markups - Array of markup patterns to parse
10899
+ * @returns Transformed text
10900
+ *
10901
+ * @example
10902
+ * ```typescript
10903
+ * const text = '@[Hello](world) and #[nested @[content]]'
10904
+ * const result = denote(text, mark => mark.value, ['@[__value__](__meta__)', '#[__slot__]'])
10905
+ * // Returns: 'Hello and nested content'
10906
+ * ```
10907
+ */
10908
+ declare function denote(value: string, callback: (mark: MarkToken) => string, markups: Markup[]): string;
11084
10909
  //#endregion
11085
- //#region ../../core/src/features/drag/DragController.d.ts
11086
- declare class DragController {
10910
+ //#region ../../core/src/features/block/BlockController.d.ts
10911
+ declare class BlockController {
11087
10912
  #private;
11088
10913
  private readonly props;
11089
10914
  private readonly value;
11090
- private readonly parsing;
11091
- private readonly caret;
10915
+ private readonly tokens;
10916
+ private readonly selection;
11092
10917
  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);
10918
+ constructor(props: PropsModel, value: ValueModel, tokens: TokenModel, selection: SelectionController);
11099
10919
  }
11100
10920
  //#endregion
11101
- //#region ../../core/src/store/BlockStore.d.ts
10921
+ //#region ../../core/src/features/block/BlockStore.d.ts
11102
10922
  type DropPosition = 'before' | 'after' | null;
11103
10923
  declare class BlockStore {
11104
10924
  #private;
@@ -11118,25 +10938,88 @@ declare class BlockStore {
11118
10938
  attachContainer(el: HTMLElement | null, blockIndex: number, actions: DragActions): void;
11119
10939
  attachGrip(el: HTMLButtonElement | null, blockIndex: number, actions: DragActions): void;
11120
10940
  attachMenu(el: HTMLElement | null): void;
11121
- closeMenu: () => void;
10941
+ closeMenu: () => boolean;
11122
10942
  addBlock: () => void;
11123
10943
  deleteBlock: () => void;
11124
10944
  duplicateBlock: () => void;
11125
10945
  }
11126
10946
  //#endregion
11127
- //#region ../../core/src/store/BlockRegistry.d.ts
10947
+ //#region ../../core/src/features/block/BlockRegistry.d.ts
11128
10948
  declare class BlockRegistry {
11129
10949
  #private;
11130
10950
  get(token: object): BlockStore;
11131
10951
  }
11132
10952
  //#endregion
11133
- //#region ../../core/src/features/mark/MarkController.d.ts
10953
+ //#region ../../core/src/features/clipboard/ClipboardController.d.ts
10954
+ declare class ClipboardController {
10955
+ #private;
10956
+ private readonly lifecycle;
10957
+ private readonly edit;
10958
+ private readonly dom;
10959
+ private readonly tokens;
10960
+ constructor(lifecycle: Lifecycle, edit: EditController, dom: DomModel, tokens: TokenModel);
10961
+ }
10962
+ //#endregion
10963
+ //#region ../../core/src/features/keyboard/KeyboardController.d.ts
10964
+ declare class KeyboardController {
10965
+ constructor(lifecycle: Lifecycle, dom: DomModel, value: ValueModel, selection: SelectionController, edit: EditController, tokens: TokenModel, props: PropsModel);
10966
+ }
10967
+ //#endregion
10968
+ //#region ../../core/src/features/slots/types.d.ts
10969
+ interface MarkSlot {
10970
+ (): (token: Token) => readonly [Slot, Record<string, unknown>];
10971
+ }
10972
+ interface OverlaySlot {
10973
+ (): (option?: CoreOption, defaultComponent?: Slot) => readonly [Slot, Record<string, unknown>];
10974
+ }
10975
+ //#endregion
10976
+ //#region ../../core/src/features/slots/SlotsFeature.d.ts
10977
+ declare class SlotsFeature {
10978
+ private readonly props;
10979
+ readonly containerComponent: Computed<Slot>;
10980
+ readonly containerProps: Computed<{
10981
+ className: string | undefined;
10982
+ style?: CSSProperties$1;
10983
+ [key: string]: unknown;
10984
+ }>;
10985
+ readonly blockComponent: Computed<Slot>;
10986
+ readonly blockProps: Computed<Record<string, unknown> | undefined>;
10987
+ readonly mark: MarkSlot;
10988
+ constructor(props: PropsModel);
10989
+ }
10990
+ //#endregion
10991
+ //#region ../../core/src/shared/classes/KeyGenerator.d.ts
10992
+ declare class KeyGenerator {
10993
+ #private;
10994
+ get(object: object): number | undefined;
10995
+ }
10996
+ //#endregion
10997
+ //#region ../../core/src/store/Store.d.ts
10998
+ declare class Store {
10999
+ readonly key: KeyGenerator;
11000
+ readonly blocks: BlockRegistry;
11001
+ readonly lifecycle: Lifecycle;
11002
+ readonly props: PropsModel;
11003
+ readonly value: ValueModel;
11004
+ readonly tokens: TokenModel;
11005
+ readonly slots: SlotsFeature;
11006
+ readonly dom: DomModel;
11007
+ readonly selection: SelectionController;
11008
+ readonly edit: EditController;
11009
+ readonly overlay: OverlayController;
11010
+ readonly keyboard: KeyboardController;
11011
+ readonly block: BlockController;
11012
+ readonly clipboard: ClipboardController;
11013
+ readonly handler: MarkputHandler;
11014
+ }
11015
+ //#endregion
11016
+ //#region ../../core/src/features/parsing/MarkController.d.ts
11134
11017
  declare class MarkController {
11135
11018
  #private;
11136
11019
  private readonly store;
11137
11020
  private readonly address;
11138
11021
  private readonly snapshot;
11139
- constructor(store: Store, address: TokenAddress, snapshot: MarkSnapshot, shape: TokenShapeSnapshot);
11022
+ constructor(store: Store, address: TokenAddress, snapshot: MarkSnapshot);
11140
11023
  static fromToken(store: Store, token: MarkToken): MarkController;
11141
11024
  get value(): string;
11142
11025
  get meta(): string | undefined;
@@ -11153,9 +11036,9 @@ declare class OverlayController {
11153
11036
  private readonly props;
11154
11037
  private readonly value;
11155
11038
  private readonly dom;
11156
- private readonly caret;
11039
+ private readonly selection;
11157
11040
  private readonly edit;
11158
- private readonly parsing;
11041
+ private readonly tokens;
11159
11042
  readonly match: Signal<OverlayMatch | undefined>;
11160
11043
  readonly element: Signal<HTMLElement | null>;
11161
11044
  readonly slot: OverlaySlot;
@@ -11168,115 +11051,20 @@ declare class OverlayController {
11168
11051
  left: number;
11169
11052
  top: number;
11170
11053
  }>;
11171
- constructor(lifecycle: Lifecycle, props: PropsModel, value: ValueModel, dom: DomController, caret: CaretModel, edit: EditController, parsing: ParseController);
11054
+ constructor(lifecycle: Lifecycle, props: PropsModel, value: ValueModel, dom: DomModel, selection: SelectionController, edit: EditController, tokens: TokenModel);
11172
11055
  }
11173
11056
  //#endregion
11174
- //#region ../../core/src/shared/classes/MarkputHandler.d.ts
11057
+ //#region ../../core/src/store/MarkputHandler.d.ts
11175
11058
  declare class MarkputHandler {
11176
11059
  private readonly dom;
11177
11060
  private readonly overlayFeature;
11178
- private readonly parsing;
11179
- constructor(dom: DomController, overlayFeature: OverlayController, parsing: ParseController);
11061
+ private readonly selection;
11062
+ constructor(dom: DomModel, overlayFeature: OverlayController, selection: SelectionController);
11180
11063
  get container(): HTMLElement | null;
11181
11064
  get overlay(): HTMLElement | null;
11182
11065
  focus(): void;
11183
11066
  }
11184
11067
  //#endregion
11185
- //#region ../../core/src/shared/classes/KeyGenerator.d.ts
11186
- declare class KeyGenerator {
11187
- #private;
11188
- get(object: object): number | undefined;
11189
- }
11190
- //#endregion
11191
- //#region ../../core/src/store/Store.d.ts
11192
- declare class Store {
11193
- readonly key: KeyGenerator;
11194
- readonly blocks: BlockRegistry;
11195
- readonly lifecycle: Lifecycle;
11196
- readonly props: PropsModel;
11197
- readonly value: ValueModel;
11198
- readonly mark: MarkFeature;
11199
- readonly slots: SlotsFeature;
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;
11209
- }
11210
- //#endregion
11211
- //#region ../../core/src/shared/editorContracts.d.ts
11212
- type TokenPath = readonly number[];
11213
- type TokenAddress = {
11214
- readonly path: TokenPath;
11215
- readonly parseGeneration: number;
11216
- };
11217
- type Result<T, Reason extends string> = {
11218
- ok: true;
11219
- value: T;
11220
- } | {
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;
11244
- } | {
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';
11266
- } | {
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;
11278
- };
11279
- //#endregion
11280
11068
  //#region src/types.d.ts
11281
11069
  /**
11282
11070
  * Props passed to Mark components.
@@ -11375,12 +11163,12 @@ interface MarkedInputProps<TMarkProps = MarkProps, TOverlayProps extends CoreOpt
11375
11163
  style?: CSSProperties;
11376
11164
  /**
11377
11165
  * Override internal components using slots
11378
- * @example slots={{ container: 'div', span: 'span' }}
11166
+ * @example slots={{ container: 'div' }}
11379
11167
  */
11380
11168
  slots?: Slots;
11381
11169
  /**
11382
11170
  * Props to pass to slot components
11383
- * @example slotProps={{ container: { onKeyDown: handler }, span: { className: 'custom' } }}
11171
+ * @example slotProps={{ container: { onKeyDown: handler } }}
11384
11172
  */
11385
11173
  slotProps?: SlotProps;
11386
11174
  /**