@qilin-agent/client-ui-conversation 0.0.0-stage → 3.1.4
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/LICENSE +21 -0
- package/README.i18n.yaml +37 -0
- package/README.md +149 -2
- package/README.zh.md +150 -0
- package/lib/client.js +19208 -0
- package/lib/index.js +46 -0
- package/lib/types/client/apply.d.ts +25 -0
- package/lib/types/client/context-occupancy.d.ts +14 -0
- package/lib/types/client/contract/composer-blocks.d.ts +28 -0
- package/lib/types/client/contract/composer-submission.d.ts +8 -0
- package/lib/types/client/contract/context-producer.d.ts +29 -0
- package/lib/types/client/contract/conversation.d.ts +279 -0
- package/lib/types/client/contract/draft-editor.d.ts +102 -0
- package/lib/types/client/contract/groups.d.ts +116 -0
- package/lib/types/client/contract/input.d.ts +361 -0
- package/lib/types/client/contract/records.d.ts +301 -0
- package/lib/types/client/contract/request-inspection.d.ts +132 -0
- package/lib/types/client/contract/slots.d.ts +541 -0
- package/lib/types/client/contract/snapshot.d.ts +20 -0
- package/lib/types/client/contract/system-prompt.d.ts +35 -0
- package/lib/types/client/contract/views.d.ts +36 -0
- package/lib/types/client/conversation/assembler.d.ts +151 -0
- package/lib/types/client/conversation/assembly.d.ts +128 -0
- package/lib/types/client/conversation/definition-registry.d.ts +33 -0
- package/lib/types/client/conversation/event-registry.d.ts +40 -0
- package/lib/types/client/conversation/group-registry.d.ts +30 -0
- package/lib/types/client/conversation/group-store.d.ts +29 -0
- package/lib/types/client/conversation/historical-images.d.ts +49 -0
- package/lib/types/client/conversation/location-index.d.ts +91 -0
- package/lib/types/client/conversation/view-registry.d.ts +12 -0
- package/lib/types/client/image-labels.d.ts +23 -0
- package/lib/types/client/index.d.ts +39 -0
- package/lib/types/client/input/blocks.d.ts +27 -0
- package/lib/types/client/input/decorations.d.ts +32 -0
- package/lib/types/client/input/editor/ComposerContentEditable.d.ts +16 -0
- package/lib/types/client/input/editor/DecoratorPortals.d.ts +14 -0
- package/lib/types/client/input/editor/DraftEditor.d.ts +27 -0
- package/lib/types/client/input/editor/ReferenceChip.d.ts +17 -0
- package/lib/types/client/input/editor/chip-node.d.ts +110 -0
- package/lib/types/client/input/editor/claim-decor.d.ts +23 -0
- package/lib/types/client/input/editor/keymap.d.ts +43 -0
- package/lib/types/client/input/editor/projection.d.ts +93 -0
- package/lib/types/client/input/editor/reference-activation.d.ts +10 -0
- package/lib/types/client/input/editor/runtime.d.ts +123 -0
- package/lib/types/client/input/editor/span-map.d.ts +38 -0
- package/lib/types/client/input/editor/text-ref.d.ts +49 -0
- package/lib/types/client/input/editor/view-binding.d.ts +60 -0
- package/lib/types/client/input/facade.d.ts +303 -0
- package/lib/types/client/input/hub.d.ts +100 -0
- package/lib/types/client/input/machine.d.ts +46 -0
- package/lib/types/client/input/submission-policy.d.ts +52 -0
- package/lib/types/client/layout-policy.d.ts +42 -0
- package/lib/types/client/locales.d.ts +772 -0
- package/lib/types/client/queue/QueueDock.d.ts +27 -0
- package/lib/types/client/service.d.ts +192 -0
- package/lib/types/client/settings/ContentWidthRow.d.ts +26 -0
- package/lib/types/client/settings/EnterBehaviorRow.d.ts +21 -0
- package/lib/types/client/skeleton/ContextMeter.d.ts +14 -0
- package/lib/types/client/skeleton/ConversationContent.d.ts +8 -0
- package/lib/types/client/skeleton/ConversationHeader.d.ts +8 -0
- package/lib/types/client/skeleton/ConversationMainPanel.d.ts +3 -0
- package/lib/types/client/skeleton/ConversationPanel.d.ts +9 -0
- package/lib/types/client/skeleton/ConversationRoot.d.ts +5 -0
- package/lib/types/client/skeleton/ConversationSession.d.ts +21 -0
- package/lib/types/client/skeleton/ConversationWidthControls.d.ts +14 -0
- package/lib/types/client/skeleton/DefaultConversationViews.d.ts +9 -0
- package/lib/types/client/skeleton/EmptyHero.d.ts +49 -0
- package/lib/types/client/skeleton/InputBar.d.ts +18 -0
- package/lib/types/client/skeleton/TodoPanel.d.ts +21 -0
- package/lib/types/client/skeleton/control-row-layout.d.ts +10 -0
- package/lib/types/client/skeleton/safari.d.ts +18 -0
- package/lib/types/client/stop-sequence.d.ts +32 -0
- package/lib/types/client/stop-shortcut.d.ts +17 -0
- package/lib/types/client/stores.d.ts +24 -0
- package/lib/types/client/view-selection.d.ts +11 -0
- package/lib/types/conversation-settings.d.ts +38 -0
- package/lib/types/index.d.ts +9 -0
- package/package.json +106 -3
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Attachment error and limit copy owned by the conversation input flow. */
|
|
2
|
+
import type { ImageAttachmentLimits } from '@qilin-agent/attachment';
|
|
3
|
+
import type { Translate } from '@qilin-agent/client-ui-slots';
|
|
4
|
+
import type { ConversationKey } from './locales.ts';
|
|
5
|
+
/**
|
|
6
|
+
* Byte count as user-facing megabytes (`10MB`, `2.5MB`).
|
|
7
|
+
* @param bytes - the byte count.
|
|
8
|
+
* @returns the rounded megabyte text.
|
|
9
|
+
*/
|
|
10
|
+
export declare function imageSizeText(bytes: number): string;
|
|
11
|
+
/**
|
|
12
|
+
* Product copy for a host attachment rejection (the `details.reason` of
|
|
13
|
+
* `session/attachment-invalid` or `subagent/attachment-invalid`).
|
|
14
|
+
* User-solvable reasons name the limit and the way out;
|
|
15
|
+
* reasons the user cannot act on fold into one send-failed line carrying the
|
|
16
|
+
* reason code for a bug report.
|
|
17
|
+
* @param t - the conversation-namespace translate.
|
|
18
|
+
* @param reason - the wire `details.reason` code.
|
|
19
|
+
* @param limits - projected limits interpolated into count/size copy, when known.
|
|
20
|
+
* @returns the banner text.
|
|
21
|
+
*/
|
|
22
|
+
export declare function attachmentErrorText(t: Translate<ConversationKey>, reason: string, limits?: ImageAttachmentLimits): string;
|
|
23
|
+
//# sourceMappingURL=image-labels.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Browser Conversation assemble core, React adapter, shell, and input plugin. */
|
|
2
|
+
export { apply, Config, inject } from './apply.ts';
|
|
3
|
+
export type { Config as ConversationConfig } from './apply.ts';
|
|
4
|
+
export { UiConversation } from './conversation/assembly.ts';
|
|
5
|
+
export type { ConversationBinding } from './conversation/assembly.ts';
|
|
6
|
+
export type { ConversationGroupRegistry } from './conversation/group-registry.ts';
|
|
7
|
+
export type { ConversationGroupContext, ConversationGroupData, ConversationGroupDataMap, ConversationGroupDefinition, ConversationGroupedView, ConversationGroupInput, GroupKey, GroupNodePosition, GroupReference, GroupSnapshot, GroupUpdate, NodeChange, NodeKey, NodeReference, RenderEntry, } from './contract/groups.ts';
|
|
8
|
+
export { ConversationController, UnsupportedImageMediaTypeError } from './service.ts';
|
|
9
|
+
export type { IConversation } from './service.ts';
|
|
10
|
+
export type { ConversationContextReader, ConversationLocation, ConversationLocationData, ConversationLocationDataScope, ConversationLocationDataSource, ConversationLocationDataStore, ConversationMatch, ConversationMatchResult, ConversationNodeContext, ConversationNodeDefinition, ConversationPreviousContext, ConversationPublication, ConversationStartMatch, ConversationStepDataMap, ConversationTimelineSnapshot, ConversationTurnDataMap, ConversationViewBuilder, ConversationViewDefinition, ConversationViewNode, ConversationViewSnapshotMap, ConversationViewSnapshotStore, StepLocation, TurnLocation, } from './contract/conversation.ts';
|
|
11
|
+
export { EMPTY_CONVERSATION_SNAPSHOT, conversationPhase } from './contract/snapshot.ts';
|
|
12
|
+
export type { ConversationPhase, ConversationSnapshot, } from './contract/snapshot.ts';
|
|
13
|
+
export type { AssistantBlock, AssistantMessageNode, AssistantProviderMetadataView, AssistantRequestConfig, AssistantTiming, CommandNode, CompactionSummaryNode, ContextMessageNode, ConversationNode, ModelRetryNode, PartialAssistant, PreparingToolCall, RunningToolCall, StartedToolCall, SteeringMessageNode, TodoItem, ToolArgs, ToolCallBlock, ToolResultNode, TurnErrorNode, TurnMaxTokensNode, UnknownSurfaceNode, UserMessageNode, } from './contract/records.ts';
|
|
14
|
+
export type { ContextProducerView, ContextRole, KnownContextForm, } from './contract/context-producer.ts';
|
|
15
|
+
export type { ConversationPromptSnapshot, RequestInspectionSnapshot, RequestPromptChange, RequestPromptInspection, RequestPromptInspector, RequestView, SystemPromptNode, } from './contract/request-inspection.ts';
|
|
16
|
+
export { inspectRequestPrompt } from './contract/request-inspection.ts';
|
|
17
|
+
export type { SystemPromptState, SystemPromptInspector } from './contract/system-prompt.ts';
|
|
18
|
+
export type { ConversationStoreState, ViewTab } from './contract/views.ts';
|
|
19
|
+
export { ConversationNodeAssembler } from './conversation/assembler.ts';
|
|
20
|
+
export type { ConversationEventDefinitions, ConversationGroupDefinitions, ConversationViewDefinitions, } from './conversation/assembler.ts';
|
|
21
|
+
export { ConversationDefinitionRegistry } from './conversation/definition-registry.ts';
|
|
22
|
+
export { ConversationEventRegistry } from './conversation/event-registry.ts';
|
|
23
|
+
export { ConversationLocationIndex } from './conversation/location-index.ts';
|
|
24
|
+
export type { ConversationLocationDataChange } from './conversation/location-index.ts';
|
|
25
|
+
export { ConversationViewRegistry } from './conversation/view-registry.ts';
|
|
26
|
+
export type { ConversationKey } from './locales.ts';
|
|
27
|
+
export type { ComposerAttachment, ComposerAttachmentsOwnerProps, ComposerAttachmentsProps, ComposerFileAttachment, ComposerImageAttachment, DraftFileUpload, DraftFileUploads, ComposerBarInjected, ComposerBarOwnerProps, ComposerBarProps, ComposerChainProps, ConversationHeaderActionOwnerProps, ConversationHeaderCornerOwnerProps, ConversationHeaderLineageOwnerProps, ConversationContentInputProps, ConversationContentProps, ConversationInjected, ConversationSessionHeaderInjected, ConversationSessionHeaderSlotProps, ConversationSessionInjected, ConversationSessionSlotProps, ConversationSlotProps, ConversationViewsProps, ConversationWidthControlsInputProps, ConversationWidthControlsProps, ConversationStore, ConvViewOwnerProps, ConvViewProps, EmptyWorkspaceOwnerProps, HeroAgentPresetOwnerProps, HeroBrandMarkOwnerProps, InputControlOwnerProps, InputZone, MessageImageLoader, MessageImageSource, MessageImagesOwnerProps, RenderMessageImages, UseConversation, UseConversationViews, } from './contract/slots.ts';
|
|
28
|
+
export type { BeginCommandRequest, CommandClaim, ConsumeTokenRequest, DraftAttachmentId, InputActions, InputState, InsertReferenceRequest, InsertTextRequest, PickOutcome, SessionInput, SessionInputResolver, SubmitAttachment, SubmitOutcome, } from './contract/input.ts';
|
|
29
|
+
export type { ArbitrateKey, ArbitrateOutcome, ReferenceInsert, TokenSpan } from './contract/draft-editor.ts';
|
|
30
|
+
export type { ComposerBlock, ComposerBlocks } from './contract/composer-blocks.ts';
|
|
31
|
+
declare module '@qilin-agent/kylin' {
|
|
32
|
+
interface Context {
|
|
33
|
+
/** Scope-addressed Conversation actions and per-Session input registry. */
|
|
34
|
+
conversation: import('./service.ts').IConversation;
|
|
35
|
+
/** Target-neutral Conversation registries and per-Session assembly. */
|
|
36
|
+
uiConversation: import('./conversation/assembly.ts').UiConversation;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composer blocks: the one way another plugin stops a session's input.
|
|
3
|
+
*
|
|
4
|
+
* The composer cannot read the plugins that would know — the dependency runs
|
|
5
|
+
* ui-model-selection → ui-conversation, never back — so a blocker pushes here and the
|
|
6
|
+
* bar reads its own session's store. A block carries the localized reason it
|
|
7
|
+
* exists, because the plugin that raised it owns that copy; the composer only
|
|
8
|
+
* knows how to render an inert textarea with a placeholder, exactly as it
|
|
9
|
+
* already does for a session with no workspace.
|
|
10
|
+
*
|
|
11
|
+
* This is an affordance, not enforcement: the Host refuses a prompt it cannot
|
|
12
|
+
* route regardless of what any client disables.
|
|
13
|
+
*/
|
|
14
|
+
import { type SnapshotStore } from '@qilin-agent/client-store';
|
|
15
|
+
import type { SessionId } from '@qilin-agent/session/types';
|
|
16
|
+
import type { ComposerBlock, ComposerBlocks } from '../contract/composer-blocks.ts';
|
|
17
|
+
/** The per-session composer-block registry (one instance per plugin fiber). */
|
|
18
|
+
export declare class ComposerBlockRegistry implements ComposerBlocks {
|
|
19
|
+
private readonly stores;
|
|
20
|
+
/** @inheritdoc */
|
|
21
|
+
set(sessionId: SessionId, block: ComposerBlock | undefined): void;
|
|
22
|
+
/** @inheritdoc */
|
|
23
|
+
storeFor(sessionId: SessionId): SnapshotStore<ComposerBlock | undefined>;
|
|
24
|
+
/** @inheritdoc */
|
|
25
|
+
forget(sessionId: SessionId): void;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=blocks.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plain-text reference scan (the plain-text-reference decision;
|
|
3
|
+
* see .agents/notes/archived/architecture/2026-07-25-web-input-machine-and-slash-pipeline.md):
|
|
4
|
+
* a `/name` or `@name` token whose name is on the trigger's lexicon, and
|
|
5
|
+
* syntax-recognizable `@dir/` folder tokens. Pure derivation — the editor's
|
|
6
|
+
* text-ref entity transform consumes these ranges; editing the text out of
|
|
7
|
+
* match shape simply drops the range next scan.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* One plain-text reference range (the plain-text-reference decision;
|
|
11
|
+
* see .agents/notes/archived/architecture/2026-07-25-web-input-machine-and-slash-pipeline.md):
|
|
12
|
+
* a `/name` or `@name` token
|
|
13
|
+
* whose name is on the trigger's lexicon. Pure derivation — editing the text
|
|
14
|
+
* out of match shape simply drops the range next scan.
|
|
15
|
+
*/
|
|
16
|
+
export interface TextRefRange {
|
|
17
|
+
readonly start: number;
|
|
18
|
+
readonly end: number;
|
|
19
|
+
readonly trigger: '/' | '@';
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Scan the draft for plain-text reference tokens against the hot lexicons.
|
|
23
|
+
* Word-boundary discipline: the trigger must sit at the draft
|
|
24
|
+
* start or after whitespace ('x/name' never matches); the name must be an
|
|
25
|
+
* exact lexicon member; a `/name` token must end at whitespace or the draft
|
|
26
|
+
* end ('/name/x' is a path, '/name。' is prose).
|
|
27
|
+
* @param draft - draft text.
|
|
28
|
+
* @param lexicon - per-trigger name lists (a missing trigger scans nothing).
|
|
29
|
+
* @returns matched ranges in draft order.
|
|
30
|
+
*/
|
|
31
|
+
export declare function scanTextRefs(draft: string, lexicon: ReadonlyMap<'/' | '@', readonly string[]>): TextRefRange[];
|
|
32
|
+
//# sourceMappingURL=decorations.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type { LexicalEditor } from 'lexical';
|
|
3
|
+
/** Host props: the editor binding plus the div passthroughs the bar owns. */
|
|
4
|
+
export interface ComposerContentEditableProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
/** The shell-owned editor; null renders the same div unbound and inert. */
|
|
6
|
+
readonly editor: LexicalEditor | null;
|
|
7
|
+
/** Whether the user may edit (readOnly/disabled states fold in here). */
|
|
8
|
+
readonly editable: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Render the composer's editable surface.
|
|
12
|
+
* @param props - editor binding, editability, and div passthroughs.
|
|
13
|
+
* @returns the resident contenteditable div.
|
|
14
|
+
*/
|
|
15
|
+
export declare function ComposerContentEditable({ editor, editable, ...rest }: ComposerContentEditableProps): ReactNode;
|
|
16
|
+
//# sourceMappingURL=ComposerContentEditable.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { LexicalEditor } from 'lexical';
|
|
3
|
+
/** Portal-loop props. */
|
|
4
|
+
export interface DecoratorPortalsProps {
|
|
5
|
+
/** The bound editor; null (no-session) renders nothing. */
|
|
6
|
+
readonly editor: LexicalEditor | null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Render every decorator's React face into its editor host element.
|
|
10
|
+
* @param props - the editor to observe.
|
|
11
|
+
* @returns the live portal set.
|
|
12
|
+
*/
|
|
13
|
+
export declare function DecoratorPortals({ editor }: DecoratorPortalsProps): ReactNode;
|
|
14
|
+
//# sourceMappingURL=DecoratorPortals.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Stateless text-area presentation over the InputBar's borrowed editor. */
|
|
2
|
+
import type { KeyboardEventHandler, ReactNode, RefObject } from 'react';
|
|
3
|
+
import type { LexicalEditor } from 'lexical';
|
|
4
|
+
import type { InputState } from '../../contract/input.ts';
|
|
5
|
+
/** Text-area values and the scrollport reference retained by InputBar. */
|
|
6
|
+
export interface DraftEditorProps {
|
|
7
|
+
readonly classNames: Readonly<Record<string, string>>;
|
|
8
|
+
readonly editor: LexicalEditor | null;
|
|
9
|
+
readonly scrollRef: RefObject<HTMLDivElement>;
|
|
10
|
+
readonly editable: boolean;
|
|
11
|
+
readonly editorDisabled: boolean;
|
|
12
|
+
readonly phase: InputState['phase'] | 'inert';
|
|
13
|
+
readonly placeholderText: string;
|
|
14
|
+
readonly ariaLabel: string;
|
|
15
|
+
readonly workspaceTrigger: boolean;
|
|
16
|
+
readonly workspacePickerOpen: boolean;
|
|
17
|
+
readonly onWorkspaceKeyDown: KeyboardEventHandler<HTMLDivElement>;
|
|
18
|
+
readonly hint: string | null;
|
|
19
|
+
readonly showPlaceholder: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Render the existing scrollport, editable surface, placeholder, and chip portals.
|
|
23
|
+
* @param props - borrowed editor and presentation values; this component owns no Hooks.
|
|
24
|
+
* @returns the existing text-area DOM without an additional wrapper.
|
|
25
|
+
*/
|
|
26
|
+
export declare function DraftEditor({ classNames: css, editor, scrollRef, editable, editorDisabled, phase, placeholderText, ariaLabel, workspaceTrigger, workspacePickerOpen, onWorkspaceKeyDown, hint, showPlaceholder, }: DraftEditorProps): ReactNode;
|
|
27
|
+
//# sourceMappingURL=DraftEditor.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ReferenceIconKind } from '@qilin-agent/client-ui-primitives';
|
|
3
|
+
/** Display inputs of one chip (the node's cached owner projections). */
|
|
4
|
+
export interface ReferenceChipProps {
|
|
5
|
+
readonly label: string;
|
|
6
|
+
/** Domain glyph; absent renders the trigger marker instead of an icon. */
|
|
7
|
+
readonly appearance?: ReferenceIconKind | undefined;
|
|
8
|
+
/** Owner-resolution failure styling bit. */
|
|
9
|
+
readonly invalid: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Render one inline reference chip.
|
|
13
|
+
* @param props - label, optional domain glyph, and the invalid bit.
|
|
14
|
+
* @returns the chip body (icon + truncating label).
|
|
15
|
+
*/
|
|
16
|
+
export declare function ReferenceChip({ label, appearance, invalid }: ReferenceChipProps): ReactNode;
|
|
17
|
+
//# sourceMappingURL=ReferenceChip.d.ts.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReferenceChipNode: one inline reference as an atomic Lexical decorator.
|
|
3
|
+
* The node IS the occurrence — NodeKey carries identity, the node carries
|
|
4
|
+
* the owner's insert-time projections (label/appearance/clipboardText), and
|
|
5
|
+
* `getTextContent()` answers the clipboard/persistence projection so native
|
|
6
|
+
* copy and the draft mirror stay correct without expansion code. The detect
|
|
7
|
+
* projection (trigger scanning and TokenSpan coordinates) counts every chip
|
|
8
|
+
* as one U+FFFC instead; see projection.ts.
|
|
9
|
+
*/
|
|
10
|
+
import type { JSX } from 'react';
|
|
11
|
+
import type { EditorConfig, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
|
|
12
|
+
import { DecoratorNode } from 'lexical';
|
|
13
|
+
import type { ReferenceInsert } from '../../contract/draft-editor.ts';
|
|
14
|
+
/** JSON form of one chip (Lexical node serialization contract). */
|
|
15
|
+
export type SerializedReferenceChipNode = Spread<{
|
|
16
|
+
source: string;
|
|
17
|
+
ref: string;
|
|
18
|
+
label: string;
|
|
19
|
+
appearance?: ReferenceInsert['appearance'];
|
|
20
|
+
clipboardText: string;
|
|
21
|
+
invalid: boolean;
|
|
22
|
+
}, SerializedLexicalNode>;
|
|
23
|
+
/** One inline reference occurrence as an atomic decorator node. */
|
|
24
|
+
export declare class ReferenceChipNode extends DecoratorNode<JSX.Element> {
|
|
25
|
+
/** Owning source name (serializer routing key). */
|
|
26
|
+
__source: string;
|
|
27
|
+
/** Owner-scoped reference id. */
|
|
28
|
+
__ref: string;
|
|
29
|
+
/** Inline display label (insert-time cache). */
|
|
30
|
+
__label: string;
|
|
31
|
+
/** Optional domain glyph (insert-time cache). */
|
|
32
|
+
__appearance: ReferenceInsert['appearance'];
|
|
33
|
+
/** Clipboard / persistence projection, e.g. `/name` (never the model form). */
|
|
34
|
+
__clipboardText: string;
|
|
35
|
+
/** Owner-resolution failure flag: chip renders invalid; serialization must fail. */
|
|
36
|
+
__invalid: boolean;
|
|
37
|
+
/** Lexical node registry type tag. */
|
|
38
|
+
static getType(): string;
|
|
39
|
+
/**
|
|
40
|
+
* Clone with identity (Lexical writable-copy contract).
|
|
41
|
+
* @param node - node to clone.
|
|
42
|
+
* @returns a copy carrying the same NodeKey.
|
|
43
|
+
*/
|
|
44
|
+
static clone(node: ReferenceChipNode): ReferenceChipNode;
|
|
45
|
+
/**
|
|
46
|
+
* Rebuild one chip from its JSON form.
|
|
47
|
+
* @param json - serialized chip.
|
|
48
|
+
* @returns a fresh node (new key).
|
|
49
|
+
*/
|
|
50
|
+
static importJSON(json: SerializedReferenceChipNode): ReferenceChipNode;
|
|
51
|
+
/**
|
|
52
|
+
* @param insert - the owner's reference insertion (display projections included).
|
|
53
|
+
* @param invalid - owner-resolution failure bit (defaults valid).
|
|
54
|
+
* @param key - Lexical clone-path key; absent for fresh nodes.
|
|
55
|
+
*/
|
|
56
|
+
constructor(insert: Omit<ReferenceInsert, 'appearance'> & {
|
|
57
|
+
appearance?: ReferenceInsert['appearance'];
|
|
58
|
+
}, invalid?: boolean, key?: NodeKey);
|
|
59
|
+
/** Serialize to the JSON node form. */
|
|
60
|
+
exportJSON(): SerializedReferenceChipNode;
|
|
61
|
+
/**
|
|
62
|
+
* Mount the chip's host element; the decorator portal renders into it.
|
|
63
|
+
* @returns an inline, non-editable span carrying the test/e2e anchor.
|
|
64
|
+
*/
|
|
65
|
+
createDOM(_config: EditorConfig): HTMLElement;
|
|
66
|
+
/** Host element never changes shape. */
|
|
67
|
+
updateDOM(): boolean;
|
|
68
|
+
/** Chips sit in the text line. */
|
|
69
|
+
isInline(): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* No keyboard-selected intermediate state: arrows step across the chip in
|
|
72
|
+
* one move and Backspace/Delete remove it whole (the placeholder semantics
|
|
73
|
+
* of the old textarea). `true` would put a NodeSelection between the
|
|
74
|
+
* keystroke and the caret — a state the plain-text binding's handlers all
|
|
75
|
+
* ignore, deadlocking arrows, typing, and deletion at the chip edge.
|
|
76
|
+
*/
|
|
77
|
+
isKeyboardSelectable(): boolean;
|
|
78
|
+
/** Clipboard / persistence projection (native copy reads this). */
|
|
79
|
+
getTextContent(): string;
|
|
80
|
+
/**
|
|
81
|
+
* Flip the owner-resolution failure bit.
|
|
82
|
+
* @param invalid - next bit; no-op writes are the caller's concern.
|
|
83
|
+
*/
|
|
84
|
+
setInvalid(invalid: boolean): void;
|
|
85
|
+
/** Owner-resolution failure bit. */
|
|
86
|
+
isInvalid(): boolean;
|
|
87
|
+
/** Owning source name. */
|
|
88
|
+
getSource(): string;
|
|
89
|
+
/** Owner-scoped reference id. */
|
|
90
|
+
getReference(): string;
|
|
91
|
+
/** Inline display label. */
|
|
92
|
+
getLabel(): string;
|
|
93
|
+
/** Optional domain glyph. */
|
|
94
|
+
getAppearance(): ReferenceInsert['appearance'];
|
|
95
|
+
/** React face rendered into the host element by the decorator portal. */
|
|
96
|
+
decorate(): JSX.Element;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Mint one chip node from a reference insertion.
|
|
100
|
+
* @param insert - the owner's reference insertion.
|
|
101
|
+
* @returns the fresh node.
|
|
102
|
+
*/
|
|
103
|
+
export declare function $createReferenceChipNode(insert: ReferenceInsert): ReferenceChipNode;
|
|
104
|
+
/**
|
|
105
|
+
* Chip type guard.
|
|
106
|
+
* @param node - any node or nullish.
|
|
107
|
+
* @returns whether the node is a ReferenceChipNode.
|
|
108
|
+
*/
|
|
109
|
+
export declare function $isReferenceChipNode(node: LexicalNode | null | undefined): node is ReferenceChipNode;
|
|
110
|
+
//# sourceMappingURL=chip-node.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claim-token highlight: while a command claim holds, the draft's leading
|
|
3
|
+
* token renders in the warn color. A TextNode transform keeps the token in
|
|
4
|
+
* its own styled node (splitting when typing merges text into it), and the
|
|
5
|
+
* shell nudges the first leaf dirty when the claim flips so entering and
|
|
6
|
+
* leaving claimed restyles without a text edit.
|
|
7
|
+
*/
|
|
8
|
+
import type { LexicalEditor } from 'lexical';
|
|
9
|
+
/**
|
|
10
|
+
* Register the claim-token styling transform.
|
|
11
|
+
* @param editor - the shell-owned editor.
|
|
12
|
+
* @param activeToken - live claim token accessor; null while unclaimed.
|
|
13
|
+
* @returns the unregister disposer.
|
|
14
|
+
*/
|
|
15
|
+
export declare function registerClaimDecoration(editor: LexicalEditor, activeToken: () => string | null): () => void;
|
|
16
|
+
/**
|
|
17
|
+
* Nudge the token seat dirty so the transform restyles after a claim flip
|
|
18
|
+
* (claims change phase without a text edit; transforms only run on dirty
|
|
19
|
+
* nodes).
|
|
20
|
+
* @param editor - the shell-owned editor.
|
|
21
|
+
*/
|
|
22
|
+
export declare function refreshClaimDecoration(editor: LexicalEditor): void;
|
|
23
|
+
//# sourceMappingURL=claim-decor.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composer keymap over the Lexical command layer: menu arbitration
|
|
3
|
+
* (arrows/escape/enter), space adjudication, the Enter submit gesture, and
|
|
4
|
+
* paste routing. Registered at CRITICAL priority so it decides before
|
|
5
|
+
* @lexical/plain-text's own Enter/paste defaults; a handler returning false
|
|
6
|
+
* falls through to those defaults (Shift+Enter's line break, ordinary
|
|
7
|
+
* spaces, text paste the bar routes itself).
|
|
8
|
+
*
|
|
9
|
+
* IME guard: a composition-closing Enter/Space must not submit or adjudicate.
|
|
10
|
+
* KeyboardEvent.isComposing covers most engines; Safari delivers the closing
|
|
11
|
+
* keydown AFTER compositionend, so a root-element composition watch holds the
|
|
12
|
+
* guard for 10ms more (the old textarea's proven window); keyCode
|
|
13
|
+
* 229 is the legacy signal engines emit without isComposing.
|
|
14
|
+
* The root's composition attribute suppresses placeholders until both the
|
|
15
|
+
* native composition and the editor's final text reconciliation finish.
|
|
16
|
+
*/
|
|
17
|
+
import type { LexicalEditor } from 'lexical';
|
|
18
|
+
import type { ArbitrateKey, ArbitrateOutcome } from '../../contract/draft-editor.ts';
|
|
19
|
+
/** The bar-supplied behavior behind each intercepted gesture. */
|
|
20
|
+
export interface ComposerKeymapHandlers {
|
|
21
|
+
/** Keyboard arbitration while the menu is open ('pass' when no pipeline). */
|
|
22
|
+
arbitrate(key: ArbitrateKey, composing: boolean): ArbitrateOutcome;
|
|
23
|
+
/** Space adjudication; true = a claim was applied — the keystroke is consumed. */
|
|
24
|
+
space(): boolean;
|
|
25
|
+
/** Dismiss the popupSelect shell (Escape layering: an open overlay closes first). */
|
|
26
|
+
dismissPopup(): void;
|
|
27
|
+
/** Whether Enter may submit right now (locked/busy states refuse). */
|
|
28
|
+
canSubmit(): boolean;
|
|
29
|
+
/** The Enter gesture after every guard passed; `accelerated` = Ctrl/Cmd held. */
|
|
30
|
+
submit(accelerated: boolean): void;
|
|
31
|
+
/** Pasted files (image intake). */
|
|
32
|
+
intakeFiles(files: readonly File[]): void;
|
|
33
|
+
/** Pasted plain text (sanitized insertion through the shell). */
|
|
34
|
+
pasteText(text: string): void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Register the composer keymap on one editor.
|
|
38
|
+
* @param editor - the shell-owned editor.
|
|
39
|
+
* @param handlers - bar-supplied behavior.
|
|
40
|
+
* @returns the unregister disposer.
|
|
41
|
+
*/
|
|
42
|
+
export declare function registerComposerKeymap(editor: LexicalEditor, handlers: ComposerKeymapHandlers): () => void;
|
|
43
|
+
//# sourceMappingURL=keymap.d.ts.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composer editor projections: one EditorState, three pure text views.
|
|
3
|
+
* detectText feeds trigger detection and TokenSpan coordinates (every chip
|
|
4
|
+
* counts as one U+FFFC — the opaque-reference invariant); clipboardText
|
|
5
|
+
* feeds persistence, the InputState draft, and submit-plane decisions
|
|
6
|
+
* (chips expand to their clipboard projection); the model form is not a
|
|
7
|
+
* text view here — submit serializes chip nodes through their owner codec.
|
|
8
|
+
* All $-functions must run inside `editor.read()` / `editor.update()`.
|
|
9
|
+
*/
|
|
10
|
+
import type { LexicalNode, NodeKey, Point } from 'lexical';
|
|
11
|
+
import type { Occurrence } from '../../contract/draft-editor.ts';
|
|
12
|
+
/** The detect-projection stand-in for one chip (object replacement character). */
|
|
13
|
+
export declare const ATOMIC_CHAR = "\uFFFC";
|
|
14
|
+
/** One leaf (or gap) of the composer document in projection coordinates. */
|
|
15
|
+
export interface ComposerSegment {
|
|
16
|
+
/** text/linebreak carry a node; chip is atomic; gap is the newline between block elements. */
|
|
17
|
+
readonly kind: 'text' | 'chip' | 'linebreak' | 'gap';
|
|
18
|
+
/** The backing node; null only for gap. */
|
|
19
|
+
readonly node: LexicalNode | null;
|
|
20
|
+
readonly detectStart: number;
|
|
21
|
+
readonly detectLength: number;
|
|
22
|
+
readonly clipboardStart: number;
|
|
23
|
+
readonly clipboardLength: number;
|
|
24
|
+
/** gap only: the block elements this newline separates. */
|
|
25
|
+
readonly gapBetween?: {
|
|
26
|
+
readonly before: NodeKey;
|
|
27
|
+
readonly after: NodeKey;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** One walk's product: segments plus the indexes point mapping needs. */
|
|
31
|
+
export interface ComposerLayout {
|
|
32
|
+
readonly segments: readonly ComposerSegment[];
|
|
33
|
+
readonly detectLength: number;
|
|
34
|
+
readonly detectText: string;
|
|
35
|
+
readonly clipboardText: string;
|
|
36
|
+
/** Leaf node key → its segment (text/chip/linebreak). */
|
|
37
|
+
readonly byKey: ReadonlyMap<NodeKey, ComposerSegment>;
|
|
38
|
+
/** Element key → ordered child keys (root and every block element). */
|
|
39
|
+
readonly children: ReadonlyMap<NodeKey, readonly NodeKey[]>;
|
|
40
|
+
/** Element key → detect bounds of its content (gaps excluded). */
|
|
41
|
+
readonly bounds: ReadonlyMap<NodeKey, {
|
|
42
|
+
readonly start: number;
|
|
43
|
+
readonly end: number;
|
|
44
|
+
}>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Walk the composer document once, producing every projection segment in
|
|
48
|
+
* document order. Blocks (paragraphs) contribute a one-newline gap between
|
|
49
|
+
* one another in both text projections.
|
|
50
|
+
* @returns the layout for this EditorState.
|
|
51
|
+
*/
|
|
52
|
+
export declare function $composerLayout(): ComposerLayout;
|
|
53
|
+
/**
|
|
54
|
+
* Fold one clipboard-projection offset to its detect-projection twin.
|
|
55
|
+
* Offsets inside a chip's clipboard expansion snap to the chip's trailing
|
|
56
|
+
* edge; callers only pass boundaries that were once a document end (submit
|
|
57
|
+
* snapshots), which never split a chip.
|
|
58
|
+
* @param layout - the current walk product.
|
|
59
|
+
* @param clipboardOffset - offset into the clipboard projection.
|
|
60
|
+
* @returns the detect offset covering the same document position.
|
|
61
|
+
*/
|
|
62
|
+
export declare function detectOffsetOfClipboardOffset(layout: ComposerLayout, clipboardOffset: number): number;
|
|
63
|
+
/** The published projection product consumed by the shell every update. */
|
|
64
|
+
export interface EditorProjection {
|
|
65
|
+
/** Trigger/TokenSpan coordinate text (chip = one U+FFFC). */
|
|
66
|
+
readonly detectText: string;
|
|
67
|
+
/** Persistence/InputState draft text (chip = clipboardText). */
|
|
68
|
+
readonly clipboardText: string;
|
|
69
|
+
/** InputState-compatible occurrence view (clipboardText coordinates). */
|
|
70
|
+
readonly occurrences: readonly Occurrence[];
|
|
71
|
+
/** Range selection in detect coordinates (ordered); null while absent or non-range. */
|
|
72
|
+
readonly selection: {
|
|
73
|
+
readonly start: number;
|
|
74
|
+
readonly end: number;
|
|
75
|
+
} | null;
|
|
76
|
+
/** Collapsed caret in detect coordinates; null while the selection is absent or ranged. */
|
|
77
|
+
readonly caret: number | null;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Fold one selection point to a detect offset.
|
|
81
|
+
* @param layout - the current walk product.
|
|
82
|
+
* @param point - selection anchor/focus point.
|
|
83
|
+
* @returns detect offset, or null when the point references an unknown node.
|
|
84
|
+
*/
|
|
85
|
+
export declare function $detectOffsetOfPoint(layout: ComposerLayout, point: Point): number | null;
|
|
86
|
+
/**
|
|
87
|
+
* Project the composer document and its caret.
|
|
88
|
+
* @param idOf - stable occurrence-id assignment per chip NodeKey (the shell
|
|
89
|
+
* owns the map so ids survive across projections of the same node).
|
|
90
|
+
* @returns the three-view projection product.
|
|
91
|
+
*/
|
|
92
|
+
export declare function $projectComposer(idOf: (key: NodeKey) => number): EditorProjection;
|
|
93
|
+
//# sourceMappingURL=projection.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LexicalEditor } from 'lexical';
|
|
2
|
+
import type { ReferenceInsert } from '../../contract/draft-editor.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Install preview activation for atomic chips and editable reference tokens.
|
|
5
|
+
* @param editor - composer editor.
|
|
6
|
+
* @param open - live source routing; false preserves ordinary editor handling.
|
|
7
|
+
* @returns command disposer.
|
|
8
|
+
*/
|
|
9
|
+
export declare function registerReferenceActivation(editor: LexicalEditor, open: (source: string | undefined, reference: Pick<ReferenceInsert, 'ref' | 'appearance'>) => boolean): () => void;
|
|
10
|
+
//# sourceMappingURL=reference-activation.d.ts.map
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/** The Composer model's private Lexical editor, projections, and node operations. */
|
|
2
|
+
import type { ObservableSnapshot } from '@qilin-agent/client-store';
|
|
3
|
+
import type { LexicalEditor } from 'lexical';
|
|
4
|
+
import type { Occurrence, ReferenceInsert } from '../../contract/draft-editor.ts';
|
|
5
|
+
import type { EditorProjection } from './projection.ts';
|
|
6
|
+
import type { DetectSpan } from './span-map.ts';
|
|
7
|
+
type Lexicon = ReadonlyMap<'/' | '@', readonly string[]>;
|
|
8
|
+
/** Model callbacks read at the same editor registration and update points. */
|
|
9
|
+
interface DraftEditorRuntimeDeps {
|
|
10
|
+
readonly onUpdate: () => void;
|
|
11
|
+
readonly openReference: (source: string | undefined, reference: Pick<ReferenceInsert, 'ref' | 'appearance'>) => boolean;
|
|
12
|
+
readonly activeClaimToken: () => string | null;
|
|
13
|
+
readonly lexicon: () => Lexicon;
|
|
14
|
+
readonly resolveLexicon: () => ObservableSnapshot<Lexicon> | undefined;
|
|
15
|
+
}
|
|
16
|
+
/** One model-owned editor; registration and disposal remain with its model. */
|
|
17
|
+
export declare class DraftEditorRuntime {
|
|
18
|
+
private readonly deps;
|
|
19
|
+
/** The editor bound by the Composer's contenteditable host. */
|
|
20
|
+
readonly editor: LexicalEditor;
|
|
21
|
+
private projected;
|
|
22
|
+
/** Stable occurrence ids per chip NodeKey (undo restores keys, so ids survive it too). */
|
|
23
|
+
private readonly occurrenceIds;
|
|
24
|
+
private occurrenceSeq;
|
|
25
|
+
/** Live lexicon subscription disposer; undefined until the controller resolves. */
|
|
26
|
+
private lexiconOff;
|
|
27
|
+
/** @param deps - model callbacks used by editor listeners and transforms. */
|
|
28
|
+
constructor(deps: DraftEditorRuntimeDeps);
|
|
29
|
+
/**
|
|
30
|
+
* Install editor behavior after the model holds this runtime.
|
|
31
|
+
* @returns unregister callback that also detaches the editor root.
|
|
32
|
+
*/
|
|
33
|
+
register(): () => void;
|
|
34
|
+
/** The latest committed editor projection. */
|
|
35
|
+
get projection(): EditorProjection;
|
|
36
|
+
/**
|
|
37
|
+
* Run one editor edit whose result is observable on return. At the top
|
|
38
|
+
* level this is a discrete update. Inside this editor's own update —
|
|
39
|
+
* command handlers land here synchronously (space/enter picks, paste) —
|
|
40
|
+
* $-functions are already legal, and wrapping them in update() would DEFER
|
|
41
|
+
* them past the synchronous bail answer (and a nested discrete throws);
|
|
42
|
+
* the body runs directly and the outer update commits it.
|
|
43
|
+
* @param fn - the $-edit body.
|
|
44
|
+
*/
|
|
45
|
+
private applyEdit;
|
|
46
|
+
/**
|
|
47
|
+
* Subscribe the text-ref re-scan to the controller's lexicon once the
|
|
48
|
+
* controller resolves. The deps thunk cannot resolve at construction (the
|
|
49
|
+
* shell is created inside the sessions provide materialization), so the
|
|
50
|
+
* first interactive updates retry until it can.
|
|
51
|
+
*/
|
|
52
|
+
private ensureLexiconSubscription;
|
|
53
|
+
/**
|
|
54
|
+
* Re-project inside the existing editor update callback.
|
|
55
|
+
* @returns the projection preceding this read.
|
|
56
|
+
*/
|
|
57
|
+
refreshProjection(): EditorProjection;
|
|
58
|
+
private occurrenceIdOf;
|
|
59
|
+
/**
|
|
60
|
+
* Replace the whole draft (persisted-draft seed and programmatic writes).
|
|
61
|
+
* Placeholder-sanitized; newlines split paragraphs; the caret lands at the
|
|
62
|
+
* end. Merged into history so a seed is not an undoable step of its own.
|
|
63
|
+
* @param text - the full next draft.
|
|
64
|
+
*/
|
|
65
|
+
setDraft(text: string): void;
|
|
66
|
+
/**
|
|
67
|
+
* Insert pasted plain text over the current editor selection
|
|
68
|
+
* (placeholder-sanitized). The paste event's own default is suppressed by
|
|
69
|
+
* the caller; PASTE_TAG makes the paste its own history boundary, so one
|
|
70
|
+
* undo never removes both the paste and typing inside the merge window.
|
|
71
|
+
* @param text - pasted plain text.
|
|
72
|
+
*/
|
|
73
|
+
paste(text: string): void;
|
|
74
|
+
/**
|
|
75
|
+
* The live selection as a detect-coordinate span (menu-launcher synthetic
|
|
76
|
+
* hits replace it on pick); an absent selection answers a collapsed span at
|
|
77
|
+
* the document end.
|
|
78
|
+
* @returns the ordered [start, end) span in detect coordinates.
|
|
79
|
+
*/
|
|
80
|
+
caretSpan(): {
|
|
81
|
+
start: number;
|
|
82
|
+
end: number;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Replace a mapped span without applying the model's phase or revision guards.
|
|
86
|
+
* @param span - detect-coordinate range.
|
|
87
|
+
* @param text - inserted text.
|
|
88
|
+
* @returns whether the range mapped and the edit applied.
|
|
89
|
+
*/
|
|
90
|
+
replaceText(span: DetectSpan, text: string): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Insert an asynchronous text result as one independent undo operation.
|
|
93
|
+
* @param span - owner-validated insertion range.
|
|
94
|
+
* @param text - text sanitized with the same rules as paste.
|
|
95
|
+
* @returns whether the range mapped and the edit applied.
|
|
96
|
+
*/
|
|
97
|
+
insertAsyncText(span: DetectSpan, text: string): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Insert a reference chip with the existing trailing-space rule.
|
|
100
|
+
* @param span - detect-coordinate range.
|
|
101
|
+
* @param ref - reference fields.
|
|
102
|
+
* @param tail - the character following the range before editing.
|
|
103
|
+
* @returns whether the range mapped and the edit applied.
|
|
104
|
+
*/
|
|
105
|
+
insertReference(span: DetectSpan, ref: ReferenceInsert, tail: string): boolean;
|
|
106
|
+
/** Refresh claim-token decoration after the model's claim changes. */
|
|
107
|
+
refreshClaimDecoration(): void;
|
|
108
|
+
/**
|
|
109
|
+
* Clear committed content using the model's suffix decision inside the editor update.
|
|
110
|
+
* @param prefixLength - returns the clipboard-prefix length to remove, or null to clear the root.
|
|
111
|
+
*/
|
|
112
|
+
clearCommittedDraft(prefixLength: (clipboardText: string) => number | null): void;
|
|
113
|
+
/**
|
|
114
|
+
* Rebuild one model-selected failure snapshot, creating fresh reference nodes.
|
|
115
|
+
* @param draft - clipboard text.
|
|
116
|
+
* @param occurrences - reference occurrences in clipboard order.
|
|
117
|
+
*/
|
|
118
|
+
restoreDraft(draft: string, occurrences: readonly Occurrence[]): void;
|
|
119
|
+
/** Cut the editor's undo history after a committed clear or restoration. */
|
|
120
|
+
clearHistory(): void;
|
|
121
|
+
}
|
|
122
|
+
export {};
|
|
123
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect-coordinate span application: the one place that maps a TokenSpan's
|
|
3
|
+
* numeric [start, end) back onto Lexical points and applies an edit there.
|
|
4
|
+
* Every slash/input-* event (begin-command, insert-reference, insert-text,
|
|
5
|
+
* consume-token) lands through here; revision CAS stays with the caller —
|
|
6
|
+
* this module only maps and edits. All functions
|
|
7
|
+
* must run inside `editor.update()`.
|
|
8
|
+
*/
|
|
9
|
+
import type { LexicalNode } from 'lexical';
|
|
10
|
+
/** Half-open [start, end) range in detect coordinates (TokenSpan's plane). */
|
|
11
|
+
export interface DetectSpan {
|
|
12
|
+
readonly start: number;
|
|
13
|
+
readonly end: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Select one detect span (collapsed spans place the caret). Exposed for the
|
|
17
|
+
* shell's caret placement and tests; the replace helpers below build on it.
|
|
18
|
+
* @param span - detect span to select.
|
|
19
|
+
* @returns whether both endpoints mapped.
|
|
20
|
+
*/
|
|
21
|
+
export declare function $selectDetectSpan(span: DetectSpan): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Replace one detect span with plain text (empty text deletes the span).
|
|
24
|
+
* The caret lands after the insertion.
|
|
25
|
+
* @param span - detect span to replace.
|
|
26
|
+
* @param text - replacement text.
|
|
27
|
+
* @returns whether the span mapped and the edit applied.
|
|
28
|
+
*/
|
|
29
|
+
export declare function $replaceDetectSpanWithText(span: DetectSpan, text: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Replace one detect span with nodes (chip insertion path). The caret lands
|
|
32
|
+
* after the last inserted node.
|
|
33
|
+
* @param span - detect span to replace.
|
|
34
|
+
* @param nodes - replacement nodes in order.
|
|
35
|
+
* @returns whether the span mapped and the edit applied.
|
|
36
|
+
*/
|
|
37
|
+
export declare function $replaceDetectSpanWithNodes(span: DetectSpan, nodes: readonly LexicalNode[]): boolean;
|
|
38
|
+
//# sourceMappingURL=span-map.d.ts.map
|