import { type OpID, type RawCoPlainText } from "cojson"; import { AnonymousJazzAgent, CoValue, CoValueClass, CoValueJazzApi, ID, Settled, Resolved, SubscribeListenerOptions, TypeSym, inspect, CorePlainTextSchema, CoValueCreateOptionsInternal } from "../internal.js"; import { Account } from "./account.js"; import { Group } from "./group.js"; import { type CoreRichTextSchema } from "../implementation/zodSchema/schemaTypes/RichTextSchema.js"; export type TextPos = OpID; export declare class CoPlainText extends String implements CoValue { static coValueSchema?: CorePlainTextSchema | CoreRichTextSchema; [TypeSym]: "CoPlainText"; $jazz: CoTextJazzApi; $isLoaded: true; /** @internal */ constructor(options: { fromRaw: RawCoPlainText; } | { text: string; owner: Account | Group; } | undefined); /** * Create a new `CoPlainText` with the given text and owner. * * The owner (a Group or Account) determines access rights to the CoPlainText. * * The CoPlainText will immediately be persisted and synced to connected peers. * * @example * ```ts * const text = CoPlainText.create("Hello, world!", { owner: me }); * ``` * * @category Creation * @deprecated Use `co.plainText(...).create` instead. */ static create(this: CoValueClass, text: string, options?: CoValueCreateOptionsInternal): T; get length(): number; toString(): string; valueOf(): string; toJSON(): string; [inspect](): string; insertBefore(idx: number, text: string): void; insertAfter(idx: number, text: string): void; deleteRange(range: { from: number; to: number; }): void; posBefore(idx: number): TextPos | undefined; posAfter(idx: number): TextPos | undefined; idxBefore(pos: TextPos): number | undefined; idxAfter(pos: TextPos): number | undefined; /** @category Internals */ static fromRaw(this: CoValueClass & typeof CoPlainText, raw: RawCoPlainText): V & CoPlainText; /** * Load a `CoPlainText` with a given ID, as a given account. * * @category Subscription & Loading * @deprecated Use `co.plainText(...).load` instead. */ static load(this: CoValueClass, id: ID, options?: { loadAs?: Account | AnonymousJazzAgent; }): Promise>; /** * Load and subscribe to a `CoPlainText` with a given ID, as a given account. * * Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener. * * Check out the `load` methods on `CoMap`/`CoList`/`CoStream`/`Group`/`Account` to see which depth structures are valid to nest. * * Returns an unsubscribe function that you should call when you no longer need updates. * * Also see the `useCoState` hook to reactively subscribe to a CoValue in a React component. * * @category Subscription & Loading * @deprecated Use `co.plainText(...).subscribe` instead. */ static subscribe(this: CoValueClass, id: ID, listener: (value: Resolved, unsubscribe: () => void) => void): () => void; static subscribe(this: CoValueClass, id: ID, options: Omit, "resolve">, listener: (value: Resolved, unsubscribe: () => void) => void): () => void; /** * Allow CoPlainText to behave like a primitive string in most contexts (e.g., * string concatenation, template literals, React rendering, etc.) by implementing * Symbol.toPrimitive. This eliminates the need to call .toString() explicitly. * * The 'hint' parameter indicates the preferred type of conversion: * - 'string': prefer string conversion * - 'number': prefer number conversion (attempt to parse the text as a number) * - 'default': usually treat as string */ [Symbol.toPrimitive](hint: string): string | number; } export declare class CoTextJazzApi extends CoValueJazzApi { private coText; raw: RawCoPlainText; constructor(coText: T, raw: RawCoPlainText); get owner(): Group; /** * Apply text, modifying the text in place. Calculates the diff and applies it to the CoValue. * * @category Mutation */ applyDiff(other: string): void; /** * Given an already loaded `CoPlainText`, subscribe to updates to the `CoPlainText` and ensure that the specified fields are loaded to the specified depth. * * Works like `CoPlainText.subscribe()`, but you don't need to pass the ID or the account to load as again. * * Returns an unsubscribe function that you should call when you no longer need updates. * * @category Subscription & Loading **/ subscribe(this: CoTextJazzApi, listener: (value: Resolved, unsubscribe: () => void) => void): () => void; } //# sourceMappingURL=coPlainText.d.ts.map