import Backbone from 'backbone'; import { ModelDestroyOptions, _StringKey } from 'backbone'; declare class Selectable extends Model { } declare class Selected extends Collection { getByComponent(component: Component): Selectable; addComponent(component: Component, opts: any): Selectable; getComponent(model: Selectable): Component; hasComponent(component: Component): boolean; lastComponent(): Component | undefined; allComponents(): Component[]; removeComponent(component: Component | Component[], opts: any): Selectable; } export interface CssComposerConfig { /** * Style prefix. * @default 'css-' */ stylePrefix?: string; /** * Default CSS style rules */ rules?: Array; } export declare class CssRules extends Collection { editor: EditorModel; constructor(props: any, opt: any); toJSON(opts?: any): any[]; onAdd(model: CssRule, c: CssRules, o: any): void; onRemove(removed: CssRule): void; /** @ts-ignore */ add(models: any, opt?: any): any[]; } declare class CssRulesView extends View { atRules: Record; config: Record; em: EditorModel; pfx: string; renderStarted?: boolean; private ruleContainers; private ruleViews; constructor(o: any); private clearRuleViews; remove(): this; /** * Add to collection * @param {Object} model * @private * */ addTo(model: CssRule): void; /** * Add new object to collection * @param {Object} model * @param {Object} fragmentEl * @return {Object} * @private * */ addToCollection(model: CssRule, fragmentEl?: DocumentFragment): HTMLElement | undefined; getMediaWidth(mediaText: string): string; sortRules(a: number, b: number): number; render(): this; } declare enum CssEvents { /** * @event `css:mount` CSS rule is mounted in the canvas. * @example * editor.on('css:mount', ({ rule }) => { ... }); */ mount = "css:mount", mountBefore = "css:mount:before" } declare class CssRuleView extends View { config: any; constructor(o?: any); get frameView(): FrameView; get em(): EditorModel; remove(): this; updateStyles(): void; /** @ts-ignore */ tagName(): string; render(): this; } export interface DataSourceOptions extends CombinedModelConstructorOptions<{ em: EditorModel; }, DataSource> { } export declare class DataSource extends Model> { transformers: DataSourceTransformers; /** * Returns the default properties for the data source. * These include an empty array of records and an empty object of transformers. * * @returns {Object} The default attributes for the data source. * @name defaults */ defaults(): DataSourceType; /** * Initializes a new instance of the `DataSource` class. * It sets up the transformers and initializes the collection of records. * If the `records` property is not an instance of `DataRecords`, it will be converted into one. * * @param {DataSourceProps} props - Properties to initialize the data source. * @param {DataSourceOptions} opts - Options to initialize the data source. * @name constructor */ constructor(props: DataSourceProps, opts: DataSourceOptions); /** * Retrieves the collection of records associated with this data source. * * @returns {DataRecords} The collection of data records. * @name records */ get records(): NonNullable>; /** * Retrieves the collection of records associated with this data source. * * @returns {DataRecords} The collection of data records. * @name records */ get schema(): DataSourceSchema; /** * Retrieves the editor model associated with this data source. * * @returns {EditorModel} The editor model. * @name em */ get em(): EditorModel; /** * Indicates if the data source has a provider for records. */ get hasProvider(): boolean; /** * Handles the `add` event for records in the data source. * This method triggers a change event on the newly added record. * * @param {DataRecord} dr - The data record that was added. * @private * @name onAdd */ onAdd(dr: DataRecord): void; /** * Adds a new record to the data source. * * @param {DRProps} record - The properties of the record to add. * @param {AddOptions} [opts] - Options to apply when adding the record. * @returns {DataRecord} The added data record. * @name addRecord */ addRecord(record: DRProps, opts?: AddOptions): DataRecord; /** * Retrieves a record from the data source by its ID. * * @param {string | number} id - The ID of the record to retrieve. * @returns {DataRecord | undefined} The data record, or `undefined` if no record is found with the given ID. * @name getRecord */ getRecord(id: string | number): DataRecord | undefined; isRecordIndex(id: string | number): boolean; /** * Retrieves all records from the data source. * Each record is processed with the `getRecord` method to apply any read transformers. * * @returns {Array | undefined>} An array of data records. * @name getRecords */ getRecords(): DataRecord[]; getContext(): Record>; /** * Retrieves all records from the data source with resolved relations based on the schema. */ getResolvedRecords(): { [x: string]: any; id?: string | undefined; mutable?: boolean | undefined; }[]; loadProvider(): Promise; /** * Removes a record from the data source by its ID. * * @param {string | number} id - The ID of the record to remove. * @param {RemoveOptions} [opts] - Options to apply when removing the record. * @returns {DataRecord | undefined} The removed data record, or `undefined` if no record is found with the given ID. * @name removeRecord */ removeRecord(id: string | number, opts?: RemoveOptions): DataRecord; /** * Replaces the existing records in the data source with a new set of records. * * @param {Array} records - An array of data record properties to set. * @returns {Array} An array of the added data records. * @name setRecords */ setRecords(records: DRProps[]): void; /** * Update the schema. * @example * dataSource.upSchema({ name: { type: 'string' } }); */ upSchema(schema: Partial, opts?: SetOptions): void; /** * Get schema field definition. * @example * const fieldSchema = dataSource.getSchemaField('name'); * fieldSchema.type; // 'string' */ getSchemaField(fieldKey: keyof DRProps): DataSourceSchema[keyof DRProps]; private handleChanges; } export declare class DataRecords extends Collection> { dataSource: DataSource; constructor(models: DataRecord[] | DataRecordProps[], options: { dataSource: DataSource; }); getRecord(id: string | number): DataRecord | undefined; isIndexKey(id: string | number): boolean; private getRecordByIndex; private getIndex; } export declare class DataRecord extends Model { mutable: boolean; constructor(props: T, opts?: {}); get cl(): DataRecords; get dataSource(): DataSource; get em(): EditorModel; get index(): number; getContext(): Partial; /** * Handles changes to the record's attributes. * This method triggers a change event for each property that has been altered. * * @private * @name handleChange */ handleChange(m: DataRecord, opts: SetOptions): void; /** * Get the path of the record. * The path is a string that represents the location of the record within the data source. * Optionally, include a property name to create a more specific path. * * @param {String} [prop] - Optional property name to include in the path. * @param {Object} [opts] - Options for path generation. * @param {Boolean} [opts.useIndex] - Whether to use the index of the record in the path. * @returns {String} - The path of the record. * @name getPath * @example * const pathRecord = record.getPath(); * // e.g., 'SOURCE_ID.record1' * const pathRecord2 = record.getPath('myProp'); * // e.g., 'SOURCE_ID.record1.myProp' */ getPath(prop?: string, opts?: { useIndex?: boolean; }): string; /** * Get both ID-based and index-based paths of the record. * Returns an array containing the paths using both ID and index. * * @param {String} [prop] - Optional property name to include in the paths. * @returns {Array} - An array of paths. * @name getPaths * @example * const paths = record.getPaths(); * // e.g., ['SOURCE_ID.record1', 'SOURCE_ID.0'] */ getPaths(prop?: string): string[]; /** * Trigger a change event for the record. * Optionally, include a property name to trigger a change event for a specific property. * * @param {String} [prop] - Optional property name to trigger a change event for a specific property. * @name triggerChange */ triggerChange(prop?: string, options?: SetOptions): void; /** * Set a property on the record, optionally using transformers. * If transformers are defined for the record, they will be applied to the value before setting it. * * @param {String|Object} attributeName - The name of the attribute to set, or an object of key-value pairs. * @param {any} [value] - The value to set for the attribute. * @param {Object} [options] - Options to apply when setting the attribute. * @param {Boolean} [options.avoidTransformers] - If true, transformers will not be applied. * @returns {DataRecord} - The instance of the DataRecord. * @name set * @example * record.set('name', 'newValue'); * // Sets 'name' property to 'newValue' */ set>(attributeName: DeepPartialDot | A, value?: SetOptions | T[A] | undefined, options?: SetOptions | undefined): this; } export interface DataWatchersOptions { skipWatcherUpdates?: boolean; fromDataSource?: boolean; parsedImportSource?: DataBindingImportSource; dataBindingImportPolicy?: DataBindingImportPolicy; } export interface ModelResolverWatcherOptions { em: EditorModel; } export type WatchableModel = StyleableModel | undefined; export interface CategoryViewConfig { em: EditorModel; pStylePrefix?: string; stylePrefix?: string; } declare class CategoryView extends View { em: EditorModel; config: CategoryViewConfig; pfx: string; caretR: string; caretD: string; iconClass: string; activeClass: string; iconEl?: HTMLElement; typeEl?: HTMLElement; catName: string; events(): { "click [data-title]": string; }; template({ pfx, label, catName }: { pfx: string; label: string; catName: string; }): string; /** @ts-ignore */ attributes(): Record; constructor(o: any, config: CategoryViewConfig, catName: string); updateVisibility(): void; open(): void; close(): void; toggle(): void; getIconEl(): HTMLElement; getTypeEl(): HTMLElement; append(el: HTMLElement): void; render(): this; } interface CategoryProperties { /** * Category id. */ id: string; /** * Category label. */ label: string; /** * Category open state. * @default true */ open?: boolean; /** * Category order. */ order?: string | number; /** * Category attributes. * @default {} */ attributes?: Record; } export interface ItemsByCategory { category?: Category; items: T[]; } export declare class Category extends Model { view?: CategoryView; defaults(): { id: string; label: string; open: boolean; attributes: {}; }; getId(): string; getLabel(): string; } export interface TraitManagerConfig { /** * Style prefix. * @default 'trt-' */ stylePrefix?: string; /** * Specify the element to use as a container, string (query) or HTMLElement. * With the empty value, nothing will be rendered. * @default '' */ appendTo?: string | HTMLElement; /** * Avoid rendering the default Trait Manager UI. * More about it here: [Custom Trait Manager](https://grapesjs.com/docs/modules/Traits.html#custom-trait-manager). * @default false */ custom?: boolean; optionsTarget?: Record[]; } declare class TraitView extends View { pfx: string; ppfx: string; config: any; clsField: string; elInput: HTMLInputElement; input?: HTMLInputElement; $input?: JQuery; eventCapture: string[]; noLabel?: boolean; em: EditorModel; target: Component; createLabel?: (data: { label: string; component: Component; trait: TraitView; }) => string | HTMLElement; createInput?: (data: ReturnType) => string | HTMLElement; events: any; appendInput: boolean; /** @ts-ignore */ attributes(): Record; templateLabel(cmp?: Component): string; templateInput(data: ReturnType): string; constructor(o?: any); getClbOpts(): { component: Component; trait: Trait; elInput: HTMLInputElement; }; removeView(): void; init(): void; removed(): void; onRender(props: ReturnType): void; onUpdate(props: ReturnType): void; onEvent(props: ReturnType & { event: Event; }): void; /** * Fires when the input is changed * @private */ onChange(event: Event): void; getValueForTarget(): any; setInputValue(value: string): void; /** * On change callback * @private */ onValueChange(_m: Trait, _v: string, opts?: SetOptions & { fromTarget?: boolean; }): void; /** * Render label * @private */ renderLabel(): void; /** * Returns label for the input * @return {string} * @private */ getLabel(): any; /** * Returns current target component */ getComponent(): Component; /** * Returns input element * @return {HTMLElement} * @private */ getInputEl(): HTMLInputElement | undefined; getInputElem(): HTMLInputElement; getModelValue(): any; getElInput(): HTMLInputElement; /** * Renders input * @private * */ renderField(): void; hasLabel(): boolean; rerender(): void; postUpdate(): void; render(): this; } declare class DomainViews extends View { config?: any; items: any[]; ns?: string; itemView?: any; itemsView: any; itemType: string; reuseView: boolean; constructor(opts?: any, config?: any, autoAdd?: boolean); /** * Add new model to the collection * @param {Model} model * @private * */ addTo(model: any): void; itemViewNotFound(type: string): void; /** * Render new model inside the view * @param {Model} model * @param {Object} fragment Fragment collection * @private * */ add(model: any, fragment?: DocumentFragment): void; render(): this; onRender(): void; onRemoveBefore(items?: any, opts?: any): void; onRemove(items?: any, opts?: any): void; remove(opts?: {}): this; clearItems(): void; } export interface TraitsViewProps { el?: HTMLElement; collection: any[]; editor: EditorModel; config: TraitManagerConfigModule; } declare class TraitsView extends DomainViews { reuseView: boolean; em: EditorModel; pfx: string; ppfx: string; renderedCategories: Map; config: TraitManagerConfigModule; traitContClass: string; catsClass: string; classNoCat: string; catsEl?: HTMLElement; traitsEl?: HTMLElement; rendered?: boolean; itemsView: TraitManager["types"]; collection: Traits; constructor(props: TraitsViewProps, itemsView: TraitManager["types"]); /** * Update view collection * @private */ updatedCollection(): void; /** * Render new model inside the view * @param {Model} model * @param {Object} fragment Fragment collection * @private * */ add(model: Trait, fragment?: DocumentFragment): void; getCategoriesEl(): HTMLElement; getTraitsEl(): HTMLElement; append(el: HTMLElement | DocumentFragment): void; render(): this; } declare class TraitManager extends Module { __ctn?: HTMLElement; view?: TraitsView; TraitsView: typeof TraitsView; events: typeof TraitsEvents; state: Model; types: TraitViewTypes; /** * Get configuration object * @name getConfig * @function * @returns {Object} */ /** * Initialize module * @private */ constructor(em: EditorModel); /** * Select traits from a component. * @param {[Component]} component * @example * tm.select(someComponent); */ select(component?: Component): void; /** * Get trait categories from the currently selected component. * @returns {Array} * @example * const traitCategories: Category[] = tm.getCategories(); * */ getCategories(): Category[]; /** * Get traits from the currently selected component. * @returns {Array<[Trait]>} * @example * const currentTraits: Trait[] = tm.getTraits(); */ getTraits(): Trait[]; /** * Get traits by category from the currently selected component. * @example * tm.getTraitsByCategory(); * // Returns an array of items of this type * // > { category?: Category; items: Trait[] } * * // NOTE: The item without category is the one containing traits without category. * * // You can also get the same output format by passing your own array of Traits * const myFilteredTraits: Trait[] = [...]; * tm.getTraitsByCategory(myFilteredTraits); */ getTraitsByCategory(traits?: Trait[]): TraitsByCategory[]; /** * Get component from the currently selected traits. * @example * tm.getComponent(); * // Component {} */ getComponent(): Component | undefined; /** * Add new trait type. * More about it here: [Define new Trait type](https://grapesjs.com/docs/modules/Traits.html#define-new-trait-type). * @param {string} name Type name. * @param {Object} methods Object representing the trait. */ addType(name: string, methods: CustomTrait): void; removeType(name: string): (new (o: any) => TraitView) | undefined; /** * Get trait type * @param {string} name Type name * @returns {Object} * @private * const traitView = tm.getType('text'); */ getType(name: string): new (o: any) => TraitView; /** * Get all trait types * @returns {Object} * @private */ getTypes(): TraitViewTypes; /** * * Get Traits viewer * @private */ getTraitsViewer(): TraitsView | undefined; getCurrent(): Trait[]; render(): HTMLElement; postRender(): void; __onSelect(): void; __trgCustom(opts?: TraitCustomData): void; __customData(): TraitCustomData; __upSel(): void; __onUp(): void; } export type CategoryCollectionParams = ConstructorParameters>; export interface CategoryOptions { events?: { update?: string; }; em?: EditorModel; } export declare class Categories extends Collection { constructor(models?: CategoryCollectionParams[0], opts?: CategoryOptions); /** @ts-ignore */ add(model: (CategoryProperties | Category)[] | CategoryProperties | Category, opts?: AddOptions): Category; get(id: string | Category): Category; } export interface ModelWithCategoryProps { category?: string | CategoryProperties; } declare abstract class CollectionWithCategories> extends Collection { abstract getCategories(): Categories; initCategory(model: T): Category | undefined; } declare class TraitFactory { config: Partial; constructor(config?: Partial); /** * Build props object by their name */ build(prop: string | TraitProperties, em: EditorModel): Trait; private buildFromString; } export declare class Traits extends CollectionWithCategories { em: EditorModel; target: Component; tf: TraitFactory; categories: Categories; constructor(coll: TraitProperties[], options: { em: EditorModel; }); get module(): TraitManager; getCategories(): Categories; handleReset(coll: TraitProperties[], { previousModels }?: { previousModels?: Trait[]; }): void; handleAdd(model: Trait): void; setTarget(target: Component): void; add(model: string | TraitProperties | Trait, options?: AddOptions): Trait; add(models: Array, options?: AddOptions): Trait[]; } /** * @property {String} id Trait id, eg. `my-trait-id`. * @property {String} type Trait type, defines how the trait should be rendered. Possible values: `text` (default), `number`, `select`, `checkbox`, `color`, `button` * @property {String} label The trait label to show for the rendered trait. * @property {String} name The name of the trait used as a key for the attribute/property. By default, the name is used as attribute name or property in case `changeProp` in enabled. * @property {String} default Default value to use in case the value is not defined on the component. * @property {String} placeholder Placeholder to show inside the default input (if the UI type allows it). * @property {String} [category=''] Trait category. * @property {Boolean} changeProp If `true`, the trait value is applied on the component property, otherwise, on component attributes. * * @module docsjs.Trait * */ export declare class Trait extends Model { target: Component; em: EditorModel; view?: TraitView; el?: HTMLElement; defaults(): { type: string; label: string; name: string; unit: string; step: number; value: string; default: string; placeholder: string; category: string; changeProp: boolean; options: never[]; }; constructor(prop: TraitProperties, em: EditorModel); get parent(): Traits; get category(): Category | undefined; get component(): Component; get changeProp(): boolean; setTarget(component: Component): void; /** * Get the trait id. * @returns {String} */ getId(): string | number; /** * Get the trait type. * @returns {String} */ getType(): string; /** * Get the trait name. * @returns {String} */ getName(): string; /** * Get the trait label. * @param {Object} [opts={}] Options. * @param {Boolean} [opts.locale=true] Use the locale string from i18n module. * @returns {String} */ getLabel(opts?: { locale?: boolean; }): any; /** * Get the trait value. * The value is taken from component attributes by default or from properties if the trait has the `changeProp` enabled. * @param {Object} [opts={}] Options. * @param {Boolean} [opts.useType=false] Get the value based on type (eg. the checkbox will always return a boolean). * @returns {any} */ getValue(opts?: TraitGetValueOptions): any; /** * Update the trait value. * The value is applied on component attributes by default or on properties if the trait has the `changeProp` enabled. * @param {any} value Value of the trait. * @param {Object} [opts={}] Options. * @param {Boolean} [opts.partial] If `true` the update won't be considered complete (not stored in UndoManager). */ setValue(value: any, opts?: TraitSetValueOptions): void; /** * Get default value. */ getDefault(): any; /** * Get trait options. */ getOptions(): TraitOption[]; /** * Get current selected option or by id. * @param {String} [id] Option id. * @returns {Object | null} */ getOption(id?: string): TraitOption | undefined; /** * Get the option id from the option object. * @param {Object} option Option object * @returns {String} Option id */ getOptionId(option: TraitOption): string; /** * Get option label. * @param {String|Object} id Option id or the option object * @param {Object} [opts={}] Options * @param {Boolean} [opts.locale=true] Use the locale string from i18n module * @returns {String} Option label */ getOptionLabel(id: string | TraitOption, opts?: LocaleOptions): string; /** * Get category label. * @param {Object} [opts={}] Options. * @param {Boolean} [opts.locale=true] Use the locale string from i18n module. * @returns {String} */ getCategoryLabel(opts?: LocaleOptions): string; /** * Run the trait command (used on the button trait type). */ runCommand(): any; props(): Partial; targetUpdated(): void; getTargetValue(opts?: TraitGetValueOptions): any; setTargetValue(value: any, opts?: SetOptions): void; setValueFromInput(value: any, final?: boolean, opts?: SetOptions): void; getInitValue(): any; } export interface TraitViewTypes { [id: string]: { new (o: any): TraitView; }; } export interface ITraitView { noLabel?: TraitView["noLabel"]; eventCapture?: TraitView["eventCapture"]; templateInput?: TraitView["templateInput"]; onEvent?: TraitView["onEvent"]; onUpdate?: TraitView["onUpdate"]; createInput?: TraitView["createInput"]; createLabel?: TraitView["createLabel"]; } export type CustomTrait = ITraitView & T & ThisType; export interface TraitModuleStateProps { component?: Component; traits: Trait[]; } export interface TraitsByCategory extends ItemsByCategory { } export interface TraitManagerConfigModule extends TraitManagerConfig { pStylePrefix?: string; em: EditorModel; } export interface TraitCustomData { container?: HTMLElement; } export interface TraitSelectEventData { component?: Component; traits: Trait[]; } export interface TraitValueEventData { trait: Trait; component: Component; value: any; } export interface TraitCategoryUpdateEventData { category: Category; changes: Partial; options: ObjectAny; } export interface TraitAllEventData { event: string; trait?: Trait; component?: Component; value?: any; category?: Category; changes?: Partial; options?: ObjectAny; container?: HTMLElement; } export interface TraitProperties { /** * Trait type, defines how the trait should be rendered. * Possible values: `text` (default), `number`, `select`, `checkbox`, `color`, `button` */ type?: string; /** * The name of the trait used as a key for the attribute/property. * By default, the name is used as attribute name or property in case `changeProp` in enabled. */ name?: string; /** * Trait id, eg. `my-trait-id`. * If not specified, the `name` will be used as id. */ id?: string | number; /** * Trait category. * @default '' */ category?: string | CategoryProperties; /** * The trait label to show for the rendered trait. */ label?: string | false; /** * If `true`, the trait value is applied on the component property, otherwise, on component attributes. * @default false */ changeProp?: boolean; /** * Instead of relying on component props/attributes, define your own * logic on how to get the trait value. */ getValue?: (props: { editor: Editor; trait: Trait; component: Component; }) => any; /** * In conjunction with the `getValue`, define your own logic for updating the trait value. */ setValue?: (props: { value: any; editor: Editor; trait: Trait; component: Component; partial: boolean; options: TraitSetValueOptions; emitUpdate: () => void; }) => void; /** * Custom true value for checkbox type. * @default 'true' */ valueTrue?: string; /** * Custom false value for checkbox type. * * @default 'false' */ valueFalse?: string; /** * Minimum number value for number type. */ min?: number; /** * Maximum number value for number type. */ max?: number; unit?: string; /** * Number of steps for number type. */ step?: number; value?: any; target?: Component; default?: any; /** * Placeholder to show inside the default input (if the UI type allows it). */ placeholder?: string; /** * Array of options for the select type. */ options?: TraitOption[]; /** * Label text to use for the button type. */ text?: string; labelButton?: string; /** * Command to use for the button type. */ command?: string | ((editor: Editor, trait: Trait) => any); full?: boolean; attributes?: Record; } export interface TraitSetValueOptions { partial?: boolean; [key: string]: unknown; } export interface TraitGetValueOptions { /** * Get the value based on type. * With this option enabled, the returned value is normalized based on the * trait type (eg. the checkbox will always return a boolean). * @default false */ useType?: boolean; /** * If false, return the value * If true and the value is a data resolver, return the data resolver props * @default false */ skipResolve?: boolean; } export interface TraitOption { id: string; label?: string; [key: string]: unknown; } declare enum TraitsEvents { /** * @event `trait:select` New traits selected (eg. by changing a component). * @example * editor.on('trait:select', ({ traits, component }) => { ... }); */ select = "trait:select", /** * @event `trait:value` Trait value updated. * @example * editor.on('trait:value', ({ trait, component, value }) => { ... }); */ value = "trait:value", update = "trait:update", /** * @event `trait:category:update` Trait category updated. * @example * editor.on('trait:category:update', ({ category, changes }) => { ... }); */ categoryUpdate = "trait:category:update", /** * @event `trait:custom` Event to use in case of [custom Trait Manager UI](https://grapesjs.com/docs/modules/Traits.html#custom-trait-manager). * @example * editor.on('trait:custom', ({ container }) => { ... }); */ custom = "trait:custom", /** * @event `trait` Catch-all event for all the events mentioned above. An object containing all the available data about the triggered event is passed as an argument to the callback. * @example * editor.on('trait', ({ event, model, ... }) => { ... }); */ all = "trait" } /**{END_EVENTS}*/ export type TraitEvent = `${TraitsEvents}`; export interface TraitEventCallback { [TraitsEvents.select]: [ TraitSelectEventData ]; [TraitsEvents.value]: [ TraitValueEventData ]; [TraitsEvents.update]: [ TraitValueEventData ]; [TraitsEvents.categoryUpdate]: [ TraitCategoryUpdateEventData ]; [TraitsEvents.custom]: [ TraitCustomData ]; [TraitsEvents.all]: [ TraitAllEventData ]; } export interface PageManagerConfig extends ModuleConfig { /** * Default pages. */ pages?: PageProperties[]; /** * ID of the page to select on editor load. */ selected?: string; } export interface SelectableOption { /** * Select the page. */ select?: boolean; } export interface AbortOption { abort?: boolean; } declare enum PagesEvents { /** * @event `page:add` Added new page. The page is passed as an argument to the callback. * @example * editor.on('page:add', (page) => { ... }); */ add = "page:add", addBefore = "page:add:before", /** * @event `page:remove` Page removed. The page is passed as an argument to the callback. * @example * editor.on('page:remove', (page) => { ... }); */ remove = "page:remove", removeBefore = "page:remove:before", /** * @event `page:select` New page selected. The newly selected page and the previous one, are passed as arguments to the callback. * @example * editor.on('page:select', (page, previousPage) => { ... }); */ select = "page:select", selectBefore = "page:select:before", /** * @event `page:update` Page updated. The updated page and the object containing changes are passed as arguments to the callback. * @example * editor.on('page:update', (page, changes) => { ... }); */ update = "page:update", /** * @event `page:frame:add` Frame added to a page. The frame and options are passed as arguments to the callback. * @example * editor.on('page:frame:add', (frame, options) => { ... }); */ frameAdd = "page:frame:add", /** * @event `page:frame:remove` Frame removed from a page. The frame and options are passed as arguments to the callback. * @example * editor.on('page:frame:remove', (frame, options) => { ... }); */ frameRemove = "page:frame:remove", /** * @event `page:frame:update` Frame updated. The frame, changed properties, and options are passed as arguments to the callback. * @example * editor.on('page:frame:update', (frame, changes, options) => { ... }); */ frameUpdate = "page:frame:update", /** * @event `page` Catch-all event for all the events mentioned above. An object containing all the available data about the triggered event is passed as an argument to the callback. * Frame events use their `page:frame:*` names and include the frame and, for updates, the changed properties. * @example * editor.on('page', ({ event, page, frame, changes, options }) => { ... }); */ all = "page" } /**{END_EVENTS}*/ export type PageEvent = `${PagesEvents}`; export interface PagesEventCallback { [PagesEvents.add]: [ Page, AddOptions ]; [PagesEvents.addBefore]: [ PageProperties, AddPage: () => Page | undefined, AddOptions & SelectableOption & AbortOption ]; [PagesEvents.remove]: EventCallbackRemove; [PagesEvents.removeBefore]: EventCallbackRemoveBefore; [PagesEvents.select]: [ Page, Page | undefined ]; [PagesEvents.selectBefore]: [ Page, SetOptions ]; [PagesEvents.update]: EventCallbackUpdate; [PagesEvents.frameAdd]: [ Frame, AddOptions ]; [PagesEvents.frameRemove]: [ Frame, RemoveOptions ]; [PagesEvents.frameUpdate]: [ Frame, ObjectAny, SetOptions ]; [PagesEvents.all]: [ { event: string; page: Page; options: ObjectAny; frame?: Frame; changes?: ObjectAny; } ]; } export interface FramesOptions { page?: Page; } export declare class Frames extends ModuleCollection { loadedItems: number; itemsToLoad: number; page?: Page; constructor(module: CanvasModule, models?: Frame[] | Array>, options?: FramesOptions); private get pageEvents(); get em(): EditorModel; registerFrame(frame: Frame): void; onAdd(frame: Frame, _collection: Frames, options?: AddOptions): void; onReset(_collection: Frames, options?: RemoveOptions & { previousModels?: Frame[]; }): void; onRemove(frame: Frame, _collection: Frames, options?: RemoveOptions): void; onUpdate(frame: Frame, options?: SetOptions): void; initRefs(): void; toJSON(opts?: Parameters[0]): any[]; itemLoaded(): void; listenToLoad(): void; listenToLoadItems(on: boolean): void; } export interface DataResolverListenerProps { em: EditorModel; resolver: DataResolver; onUpdate: (value: any) => void; } declare class DataResolverListener { private listeners; private em; private onUpdate; private model; resolver: DataResolver; constructor(props: DataResolverListenerProps); private onChange; private createListener; listenToResolver(): void; private listenToConditionalVariable; private listenToDataVariable; private onRecordChange; private removeListeners; destroy(): void; } export interface DomComponentsConfig { stylePrefix?: string; /** * Could be used for default components. */ components?: Record[]; /** * If the component is draggable you can drag the component itself (not only from the toolbar). * @default true */ draggableComponents?: boolean; /** * Experimental: Disable text inner components. * With this option, you're able to decide which inner component inside text should be * disabled (eg. no select, no hover, no layer visibility) once edited. * @default false * @example * // disable all inner childs * disableTextInnerChilds: true, * // disable all except link components * disableTextInnerChilds: (child) => !child.is('link'), */ disableTextInnerChilds?: boolean | ((cmp: Component) => boolean | void); /** * You can setup a custom component definition processor before adding it into the editor. * It might be useful to transform custom objects (es. some framework specific JSX) to GrapesJS component one. * This custom function will be executed on ANY new added component to the editor so make smart checks/conditions * to avoid doing useless executions * By default, GrapesJS supports already elements generated from React JSX preset * @example * processor: (obj) => { * if (obj.$$typeof) { // eg. this is a React Element * const gjsComponent = { * type: obj.type, * components: obj.props.children, * ... * }; * ... * return gjsComponent; * } * } */ processor?: (obj: any) => Record | undefined; /** * List of HTML void elements. * https://www.w3.org/TR/2011/WD-html-markup-20110113/syntax.html#void-elements */ voidElements?: string[]; /** * Experimental: Use the frame document for DOM element creation. * This option might be useful when elements require the local document context to * work properly (eg. Web Components). */ useFrameDoc?: boolean; /** * Experimental! * By default, the editor ensures unique attribute IDs for all components inside the project, no matter of the page. * With this option enabled, the editor will keep same attributes IDs for components across different pages. * This allows multiple components cross pages (eg.