import * as react_jsx_runtime from 'react/jsx-runtime'; import { kintoneAPI } from '@konomi-app/kintone-utilities'; import { SxProps, Theme } from '@mui/material'; import { Node, Extension, JSONContent, Editor } from '@tiptap/core'; /** Supported embeddable item categories */ type EmbeddableItemType = 'fieldCode' | 'app'; /** Keys of kintoneAPI.App that can be embedded */ type AppPropertyKey = 'appId' | 'code' | 'name' | 'description' | 'spaceId' | 'threadId'; /** An embedded item that has been placed into the input */ interface EmbeddedItem { type: EmbeddableItemType; value: string; label: string; } /** A segment of the input: either plain text or an embedded item */ type InputSegment = { kind: 'text'; text: string; } | { kind: 'embedded'; item: EmbeddedItem; }; /** Field property candidate for embedding */ interface FieldCandidate { type: 'fieldCode'; code: string; label: string; fieldType: kintoneAPI.FieldPropertyType; } /** App property candidate for embedding */ interface AppCandidate { type: 'app'; key: AppPropertyKey; label: string; } type EmbeddableCandidate = FieldCandidate | AppCandidate; /** Tab definition for dropdown categories */ interface EmbeddableTab { key: EmbeddableItemType; label: string; candidates: EmbeddableCandidate[]; } /** Props for the EmbeddableInput component */ interface EmbeddableInputProps { /** Current value in serialized format (e.g. "Hello {{fieldCode:name}} from {{app:name}}") */ value: string; /** Called when the value changes */ onChange: (value: string) => void; /** Field properties from kintone app - enables field code embedding */ fieldProperties?: kintoneAPI.FieldProperty[]; /** Single kintone app - enables embedding of app properties (name, code, etc.) */ app?: kintoneAPI.App; /** Label for the input field */ label?: string; /** Placeholder for the input field */ placeholder?: string; /** Whether the input is disabled */ disabled?: boolean; /** Height size: small=40px, medium=56px (default: medium) */ size?: 'small' | 'medium'; /** MUI sx prop */ sx?: SxProps; } /** * A text input field that allows embedding kintone field codes and app properties inline. * * Embedded items are rendered as badge-like chips within the text, * and serialized as `{{fieldCode:XXX}}` or `{{app:XXX}}`. * * A dropdown with search and category tabs appears when the input is focused, * letting users pick items to embed at the cursor position. * * Built on tiptap (ProseMirror) for robust text editing and caret management. */ declare function EmbeddableInput({ value, onChange, fieldProperties, app, label, placeholder, disabled, size, sx, }: EmbeddableInputProps): react_jsx_runtime.JSX.Element; interface EmbeddedBadgeProps { item: EmbeddedItem; onDelete: () => void; disabled?: boolean; } declare function EmbeddedBadge({ item, onDelete, disabled }: EmbeddedBadgeProps): react_jsx_runtime.JSX.Element; interface CandidateDropdownProps { tabs: EmbeddableTab[]; onSelect: (candidate: EmbeddableCandidate) => void; } declare function CandidateDropdown({ tabs, onSelect }: CandidateDropdownProps): react_jsx_runtime.JSX.Element | null; /** * Tiptap Node extension for embedded items (field codes, app properties). * Renders as an inline, atomic (non-editable) badge within the editor. */ declare const EmbeddedItemNode: Node; /** * Extension that prevents Enter from creating new paragraphs, * making the editor behave like a single-line input. */ declare const SingleLine: Extension; /** All app properties available for embedding */ declare const APP_EMBEDDABLE_PROPERTIES: { key: AppPropertyKey; label: string; }[]; /** * Serialize an EmbeddedItem into its string token form. */ declare function serializeItem(item: EmbeddedItem): string; /** * Parse a serialized string into an array of InputSegments. */ declare function parseEmbeddableString(input: string, resolveLabel?: (type: EmbeddedItem['type'], value: string) => string | undefined): InputSegment[]; /** * Convert an array of InputSegments back into a serialized string. */ declare function segmentsToString(segments: InputSegment[]): string; /** * Creates a label resolver for display in the editor. * For fieldCode: resolves to the field label. * For app properties: resolves to the human-readable property name (e.g. "アプリ名"). */ declare function createLabelResolver(fieldProperties?: kintoneAPI.FieldProperty[], _app?: kintoneAPI.App): (type: EmbeddedItem['type'], value: string) => string | undefined; /** * Serialize a tiptap Editor's content into our `{{type:value}}` string format. */ declare function serializeEditorToString(editor: Editor): string; /** * Parse our `{{type:value}}` string format into tiptap-compatible JSONContent. */ declare function parseToEditorContent(input: string, resolveLabel?: (type: EmbeddedItem['type'], value: string) => string | undefined): JSONContent; /** * Resolve a serialized embeddable string into a plain display string. * * - `{{fieldCode:XXX}}` → field label * - `{{app:name}}` → actual app property value * * Unresolved tokens are left as-is. * * @example * resolveEmbeddableString("{{app:name}}のフィールド{{fieldCode:title}}", { * fieldProperties: [...], * app: { appId: '1', code: 'MY_APP', name: 'テストアプリ', ... } * }) * // => 'テストアプリのフィールドタイトル' */ declare function resolveEmbeddableString(input: string, params: { fieldProperties?: kintoneAPI.FieldProperty[]; app?: kintoneAPI.App; }): string; export { APP_EMBEDDABLE_PROPERTIES, type AppCandidate, type AppPropertyKey, CandidateDropdown, type EmbeddableCandidate, EmbeddableInput, type EmbeddableInputProps, type EmbeddableItemType, type EmbeddableTab, EmbeddedBadge, type EmbeddedItem, EmbeddedItemNode, type FieldCandidate, type InputSegment, SingleLine, createLabelResolver, parseEmbeddableString, parseToEditorContent, resolveEmbeddableString, segmentsToString, serializeEditorToString, serializeItem };