Current section

Files

Jump to
ckeditor5_phoenix dist hooks root-value-sentinel root-value-sentinel.d.ts
Raw

dist/hooks/root-value-sentinel/root-value-sentinel.d.ts

export declare class RootValueSentinel {
/**
* The DOM element being observed for attribute changes.
*/
private el;
/**
* The unique identifier of the editor instance this sentinel is attached to.
*/
private readonly editorId;
/**
* The name of the specific root in a multi-root editor setup.
*/
private readonly rootName;
/**
* The name of the HTML attribute storing the value.
*/
private readonly valueAttrName;
/**
* The name of the HTML attribute storing the root attributes.
*/
private readonly rootAttrsAttrName;
/**
* A flag indicating whether the sentinel has been destroyed, used to prevent operations after cleanup.
*/
private isDestroyed;
/**
* Cleanup callbacks to be executed when the sentinel is destroyed.
*/
private cleanupCallbacks;
/**
* The promise that resolves to the editor instance once it's registered.
* It can be either a MultiRootEditor or a DecoupledEditor, depending on the type of editor being used.
* It will be null if the editor is not registered yet or if the hook is being destroyed before the editor is registered.
*/
private editorPromise;
/**
* When the editor is focused and the value attribute changes, we want to wait until it blurs to
* avoid disrupting the user while typing. This variable holds the pending value that should be applied
* once the editor blurs. It is set to null when there is no pending value or when the user makes changes in the editor,
* indicating that the pending value should be discarded.
*/
private pendingValue;
/**
* Cache the previous value to avoid reacting to attribute changes that don't actually change the value.
* This can happen when the parent LiveView re-renders and sets the same value again, which would otherwise cause an
* unnecessary update in the editor.
*/
private previousValue;
/**
* Updater created once the editor is ready. Tracks which root attributes
* were applied by this sentinel so it can clean them up independently of
* other consumers.
*/
private attrsUpdater;
/**
* When the hook is mounted, we will wait for the editor to be registered and then set the initial value of the root.
* Accepts an options object to configure element, identifiers, and custom attribute names.
*/
constructor({ el, editorId, rootName, valueAttrName, rootAttrsAttrName, }: RootValueSentinelOptions);
/**
* Helper to read and parse attributes from the element.
* It uses dynamically provided attribute names.
*/
private get attrs();
/**
* When the value attribute changes, we want to update the editor root value.
* However, if the editor is focused, we want to wait until it blurs to avoid disrupting the user while typing.
*/
updated(): Promise<void>;
/**
* Sets up focus-aware sync handlers on the editor.
* Registers cleanup via onBeforeDestroy.
*/
private setupSyncHandlers;
/**
* Sets the value of a specific root in the editor.
*/
private setRootValue;
/**
* Disconnects the observer and cleans up editor event listeners.
* This should be called manually when the element is removed from the DOM.
*/
destroy(): void;
}
export type RootValueSentinelOptions = {
/**
* The DOM element being observed for attribute changes.
*/
el: HTMLElement;
/**
* The unique identifier of the editor instance this sentinel is attached to.
*/
editorId: string | null;
/**
* The name of the specific root in a multi-root editor setup.
*/
rootName: string;
/**
* The name of the HTML attribute storing the value. Defaults to 'data-cke-value'.
*/
valueAttrName?: string;
/**
* The name of the HTML attribute storing the root attributes. Defaults to 'data-cke-root-attrs'.
*/
rootAttrsAttrName?: string;
};
//# sourceMappingURL=root-value-sentinel.d.ts.map