import { AvailableCoValueCore } from "../coValueCore/coValueCore.js"; import { JsonObject } from "../jsonValue.js"; import { OpID, RawCoList } from "./coList.js"; import { CoValueFrontier } from "../knownState.js"; export type StringifiedOpID = string & { __stringifiedOpID: true; }; export declare function stringifyOpID(opID: OpID): StringifiedOpID; type PlaintextIdxMapping = { opIDbeforeIdx: OpID[]; opIDafterIdx: OpID[]; idxAfterOpID: { [opID: StringifiedOpID]: number; }; idxBeforeOpID: { [opID: StringifiedOpID]: number; }; }; /** * A collaborative plain text implementation that supports grapheme-accurate editing. * * Locale support: * - Locale can be specified in the meta field when creating the text: `{ meta: { locale: "ja-JP" } }` * - If no locale is specified, falls back to browser's locale (`navigator.language`) * - If browser locale is not available, defaults to 'en' * * @example * ```typescript * // With specific locale * const textJa = node.createCoValue({ * type: "coplaintext", * ruleset: { type: "unsafeAllowAll" }, * meta: { locale: "ja-JP" }, * ...Crypto.createdNowUnique(), * }); * * // Using browser locale * const text = node.createCoValue({ * type: "coplaintext", * ruleset: { type: "unsafeAllowAll" }, * meta: null, * ...Crypto.createdNowUnique(), * }); * ``` */ export declare class RawCoPlainText extends RawCoList { /** @category 6. Meta */ type: "coplaintext"; _cachedMapping: WeakMap, PlaintextIdxMapping>; constructor(core: AvailableCoValueCore, options?: { atTimeFilter?: number; atFrontierFilter?: CoValueFrontier; }); get mapping(): PlaintextIdxMapping; toString(): string; atTime(time: number): this; atFrontier(frontier: CoValueFrontier): this; /** * Inserts `text` before the character at index `idx`. * If idx is 0, inserts at the start of the text. * * @param idx - The index of the character to insert before * @param text - The text to insert * @param privacy - Whether the operation should be private or trusting * @category 2. Editing */ insertBefore(idx: number, text: string, privacy?: "private" | "trusting"): void; appendChars(text: string[], position: number, privacy?: "private" | "trusting"): void; /** * Inserts `text` after the character at index `idx`. * * @param idx - The index of the character to insert after * @param text - The text to insert * @param privacy - Whether the operation should be private or trusting * @category 2. Editing */ insertAfter(idx: number, text: string, privacy?: "private" | "trusting"): void; deleteRange({ from, to }: { from: number; to: number; }, privacy?: "private" | "trusting"): void; /** @internal Helper method to split text into graphemes */ toGraphemes(text: string): string[]; /** @internal Helper method to join graphemes into a string */ fromGraphemes(graphemes: string[]): string; } export {}; //# sourceMappingURL=coPlainText.d.ts.map