Home > @uniformdev/canvas-react > useUniformContextualEditing

useUniformContextualEditing() function

Adds contextual editing capability to a Uniform app. This hook is already integrated in <UniformComposition />, you won't need to use it directly, unless you have a custom setup.

Signature:

useUniformContextualEditing: ({ initialCompositionValue, enhance, }: UseUniformContextualEditingProps) => {
    composition: {
        type: string;
        parameters?: {
            [key: string]: {
                value?: unknown;
                type: string;
                connectedData?: {
                    pointer: string;
                    syntax: "jptr";
                    failureAction?: "t" | "p" | "c" | "a";
                    failureLogLevel?: "e" | "w" | "i";
                    failureDefault?: string;
                };
                locales?: {
                    [key: string]: unknown;
                };
                conditions?: {
                    when: {
                        op?: "&" | "|";
                        clauses: ({
                            rule: string;
                            source?: string;
                            op: string;
                            value: string | string[];
                        } | any)[];
                    };
                    value: unknown;
                    id: number;
                }[];
                localesConditions?: {
                    [key: string]: {
                        when: {
                            op?: "&" | "|";
                            clauses: ({
                                rule: string;
                                source?: string;
                                op: string;
                                value: string | string[];
                            } | any)[];
                        };
                        value: unknown;
                        id: number;
                    }[];
                };
            };
        };
        variant?: string;
        projectMapNodes?: {
            id: string;
            path: string;
            projectMapId: string;
            data?: {
                isSearchHit?: boolean;
                queryStrings?: {
                    name: string;
                    value?: string;
                    helpText?: string;
                }[];
                previewValue?: string;
            };
            locales?: {
                [key: string]: {
                    path: string;
                    inherited: boolean;
                };
            };
        }[];
        slots?: {
            [key: string]: {
                type: string;
                parameters?: {
                    [key: string]: {
                        value?: unknown;
                        type: string;
                        connectedData?: {
                            pointer: string;
                            syntax: "jptr";
                            failureAction?: "t" | "p" | "c" | "a";
                            failureLogLevel?: "e" | "w" | "i";
                            failureDefault?: string;
                        };
                        locales?: {
                            [key: string]: unknown;
                        };
                        conditions?: {
                            when: {
                                op?: "&" | "|";
                                clauses: ({
                                    rule: string;
                                    source?: string;
                                    op: string;
                                    value: string | string[];
                                } | any)[];
                            };
                            value: unknown;
                            id: number;
                        }[];
                        localesConditions?: {
                            [key: string]: {
                                when: {
                                    op?: "&" | "|";
                                    clauses: ({
                                        rule: string;
                                        source?: string;
                                        op: string;
                                        value: string | string[];
                                    } | any)[];
                                };
                                value: unknown;
                                id: number;
                            }[];
                        };
                    };
                };
                variant?: string;
                slots?: {
                    [key: string]: any[];
                };
                _id?: string;
                _pattern?: string;
                _dataResources?: {
                    [key: string]: {
                        type: string;
                        isPatternParameter?: boolean;
                        ignorePatternParameterDefault?: boolean;
                        optionalPatternParameter?: boolean;
                        variables?: {
                            [key: string]: string;
                        };
                    };
                };
                _patternDataResources?: {
                    [key: string]: {
                        type: string;
                        isPatternParameter?: boolean;
                        ignorePatternParameterDefault?: boolean;
                        optionalPatternParameter?: boolean;
                        variables?: {
                            [key: string]: string;
                        };
                    };
                };
                _patternError?: "NOTFOUND" | "CYCLIC";
                _overrides?: {
                    [key: string]: {
                        parameters?: {
                            [key: string]: {
                                value?: unknown;
                                type: string;
                                connectedData?: {
                                    pointer: string;
                                    syntax: "jptr";
                                    failureAction?: "t" | "p" | "c" | "a";
                                    failureLogLevel?: "e" | "w" | "i";
                                    failureDefault?: string;
                                };
                                locales?: {
                                    [key: string]: unknown;
                                };
                                conditions?: {
                                    when: {
                                        op?: "&" | "|";
                                        clauses: ({
                                            rule: string;
                                            source?: string;
                                            op: string;
                                            value: string | string[];
                                        } | any)[];
                                    };
                                    value: unknown;
                                    id: number;
                                }[];
                                localesConditions?: {
                                    [key: string]: {
                                        when: {
                                            op?: "&" | "|";
                                            clauses: ({
                                                rule: string;
                                                source?: string;
                                                op: string;
                                                value: string | string[];
                                            } | any)[];
                                        };
                                        value: unknown;
                                        id: number;
                                    }[];
                                };
                            };
                        };
                        slots?: {
                            [key: string]: any[];
                        };
                        variant?: string;
                        dataResources?: {
                            [key: string]: {
                                type: string;
                                isPatternParameter?: boolean;
                                ignorePatternParameterDefault?: boolean;
                                optionalPatternParameter?: boolean;
                                variables?: {
                                    [key: string]: string;
                                };
                            };
                        };
                    };
                };
                _patternOverrides?: {
                    [key: string]: {
                        parameters?: {
                            [key: string]: {
                                value?: unknown;
                                type: string;
                                connectedData?: {
                                    pointer: string;
                                    syntax: "jptr";
                                    failureAction?: "t" | "p" | "c" | "a";
                                    failureLogLevel?: "e" | "w" | "i";
                                    failureDefault?: string;
                                };
                                locales?: {
                                    [key: string]: unknown;
                                };
                                conditions?: {
                                    when: {
                                        op?: "&" | "|";
                                        clauses: ({
                                            rule: string;
                                            source?: string;
                                            op: string;
                                            value: string | string[];
                                        } | any)[];
                                    };
                                    value: unknown;
                                    id: number;
                                }[];
                                localesConditions?: {
                                    [key: string]: {
                                        when: {
                                            op?: "&" | "|";
                                            clauses: ({
                                                rule: string;
                                                source?: string;
                                                op: string;
                                                value: string | string[];
                                            } | any)[];
                                        };
                                        value: unknown;
                                        id: number;
                                    }[];
                                };
                            };
                        };
                        slots?: {
                            [key: string]: any[];
                        };
                        variant?: string;
                        dataResources?: {
                            [key: string]: {
                                type: string;
                                isPatternParameter?: boolean;
                                ignorePatternParameterDefault?: boolean;
                                optionalPatternParameter?: boolean;
                                variables?: {
                                    [key: string]: string;
                                };
                            };
                        };
                    };
                };
                _overridability?: {
                    parameters?: {
                        [key: string]: "yes" | "no";
                    };
                    variants?: boolean;
                    hideLockedParameters?: boolean;
                };
                _locales?: string[];
            }[];
        };
        _id: string;
        _slug?: string | null;
        _name: string;
        _author?: string;
        _authorSubject?: string;
        _creator?: string;
        _creatorSubject?: string;
        _pattern?: string;
        _patternDataResources?: {
            [key: string]: {
                type: string;
                isPatternParameter?: boolean;
                ignorePatternParameterDefault?: boolean;
                optionalPatternParameter?: boolean;
                variables?: {
                    [key: string]: string;
                };
            };
        };
        _dataResources?: {
            [key: string]: {
                type: string;
                isPatternParameter?: boolean;
                ignorePatternParameterDefault?: boolean;
                optionalPatternParameter?: boolean;
                variables?: {
                    [key: string]: string;
                };
            };
        };
        _patternError?: "NOTFOUND" | "CYCLIC";
        _overrides?: {
            [key: string]: {
                parameters?: {
                    [key: string]: {
                        value?: unknown;
                        type: string;
                        connectedData?: {
                            pointer: string;
                            syntax: "jptr";
                            failureAction?: "t" | "p" | "c" | "a";
                            failureLogLevel?: "e" | "w" | "i";
                            failureDefault?: string;
                        };
                        locales?: {
                            [key: string]: unknown;
                        };
                        conditions?: {
                            when: {
                                op?: "&" | "|";
                                clauses: ({
                                    rule: string;
                                    source?: string;
                                    op: string;
                                    value: string | string[];
                                } | any)[];
                            };
                            value: unknown;
                            id: number;
                        }[];
                        localesConditions?: {
                            [key: string]: {
                                when: {
                                    op?: "&" | "|";
                                    clauses: ({
                                        rule: string;
                                        source?: string;
                                        op: string;
                                        value: string | string[];
                                    } | any)[];
                                };
                                value: unknown;
                                id: number;
                            }[];
                        };
                    };
                };
                slots?: {
                    [key: string]: any[];
                };
                variant?: string;
                dataResources?: {
                    [key: string]: {
                        type: string;
                        isPatternParameter?: boolean;
                        ignorePatternParameterDefault?: boolean;
                        optionalPatternParameter?: boolean;
                        variables?: {
                            [key: string]: string;
                        };
                    };
                };
            };
        };
        _patternOverrides?: {
            [key: string]: {
                parameters?: {
                    [key: string]: {
                        value?: unknown;
                        type: string;
                        connectedData?: {
                            pointer: string;
                            syntax: "jptr";
                            failureAction?: "t" | "p" | "c" | "a";
                            failureLogLevel?: "e" | "w" | "i";
                            failureDefault?: string;
                        };
                        locales?: {
                            [key: string]: unknown;
                        };
                        conditions?: {
                            when: {
                                op?: "&" | "|";
                                clauses: ({
                                    rule: string;
                                    source?: string;
                                    op: string;
                                    value: string | string[];
                                } | any)[];
                            };
                            value: unknown;
                            id: number;
                        }[];
                        localesConditions?: {
                            [key: string]: {
                                when: {
                                    op?: "&" | "|";
                                    clauses: ({
                                        rule: string;
                                        source?: string;
                                        op: string;
                                        value: string | string[];
                                    } | any)[];
                                };
                                value: unknown;
                                id: number;
                            }[];
                        };
                    };
                };
                slots?: {
                    [key: string]: any[];
                };
                variant?: string;
                dataResources?: {
                    [key: string]: {
                        type: string;
                        isPatternParameter?: boolean;
                        ignorePatternParameterDefault?: boolean;
                        optionalPatternParameter?: boolean;
                        variables?: {
                            [key: string]: string;
                        };
                    };
                };
            };
        };
        _overridability?: {
            parameters?: {
                [key: string]: "yes" | "no";
            };
            variants?: boolean;
            hideLockedParameters?: boolean;
        };
        _locales?: string[];
    } | undefined;
    isContextualEditing: boolean;
}

Parameters

ParameterTypeDescription
{ initialCompositionValue, enhance, }UseUniformContextualEditingProps

Returns:

{ composition: { type: string; parameters?: { [key: string]: { value?: unknown; type: string; connectedData?: { pointer: string; syntax: "jptr"; failureAction?: "t" | "p" | "c" | "a"; failureLogLevel?: "e" | "w" | "i"; failureDefault?: string; }; locales?: { [key: string]: unknown; }; conditions?: { when: { op?: "&" | "|"; clauses: ({ rule: string; source?: string; op: string; value: string | string[]; } | any)[]; }; value: unknown; id: number; }[]; localesConditions?: { [key: string]: { when: { op?: "&" | "|"; clauses: ({ rule: string; source?: string; op: string; value: string | string[]; } | any)[]; }; value: unknown; id: number; }[]; }; }; }; variant?: string; projectMapNodes?: { id: string; path: string; projectMapId: string; data?: { isSearchHit?: boolean; queryStrings?: { name: string; value?: string; helpText?: string; }[]; previewValue?: string; }; locales?: { [key: string]: { path: string; inherited: boolean; }; }; }[]; slots?: { [key: string]: { type: string; parameters?: { [key: string]: { value?: unknown; type: string; connectedData?: { pointer: string; syntax: "jptr"; failureAction?: "t" | "p" | "c" | "a"; failureLogLevel?: "e" | "w" | "i"; failureDefault?: string; }; locales?: { [key: string]: unknown; }; conditions?: { when: { op?: "&" | "|"; clauses: ({ rule: string; source?: string; op: string; value: string | string[]; } | any)[]; }; value: unknown; id: number; }[]; localesConditions?: { [key: string]: { when: { op?: "&" | "|"; clauses: ({ rule: string; source?: string; op: string; value: string | string[]; } | any)[]; }; value: unknown; id: number; }[]; }; }; }; variant?: string; slots?: { [key: string]: any[]; }; _id?: string; _pattern?: string; _dataResources?: { [key: string]: { type: string; isPatternParameter?: boolean; ignorePatternParameterDefault?: boolean; optionalPatternParameter?: boolean; variables?: { [key: string]: string; }; }; }; _patternDataResources?: { [key: string]: { type: string; isPatternParameter?: boolean; ignorePatternParameterDefault?: boolean; optionalPatternParameter?: boolean; variables?: { [key: string]: string; }; }; }; _patternError?: "NOTFOUND" | "CYCLIC"; _overrides?: { [key: string]: { parameters?: { [key: string]: { value?: unknown; type: string; connectedData?: { pointer: string; syntax: "jptr"; failureAction?: "t" | "p" | "c" | "a"; failureLogLevel?: "e" | "w" | "i"; failureDefault?: string; }; locales?: { [key: string]: unknown; }; conditions?: { when: { op?: "&" | "|"; clauses: ({ rule: string; source?: string; op: string; value: string | string[]; } | any)[]; }; value: unknown; id: number; }[]; localesConditions?: { [key: string]: { when: { op?: "&" | "|"; clauses: ({ rule: string; source?: string; op: string; value: string | string[]; } | any)[]; }; value: unknown; id: number; }[]; }; }; }; slots?: { [key: string]: any[]; }; variant?: string; dataResources?: { [key: string]: { type: string; isPatternParameter?: boolean; ignorePatternParameterDefault?: boolean; optionalPatternParameter?: boolean; variables?: { [key: string]: string; }; }; }; }; }; _patternOverrides?: { [key: string]: { parameters?: { [key: string]: { value?: unknown; type: string; connectedData?: { pointer: string; syntax: "jptr"; failureAction?: "t" | "p" | "c" | "a"; failureLogLevel?: "e" | "w" | "i"; failureDefault?: string; }; locales?: { [key: string]: unknown; }; conditions?: { when: { op?: "&" | "|"; clauses: ({ rule: string; source?: string; op: string; value: string | string[]; } | any)[]; }; value: unknown; id: number; }[]; localesConditions?: { [key: string]: { when: { op?: "&" | "|"; clauses: ({ rule: string; source?: string; op: string; value: string | string[]; } | any)[]; }; value: unknown; id: number; }[]; }; }; }; slots?: { [key: string]: any[]; }; variant?: string; dataResources?: { [key: string]: { type: string; isPatternParameter?: boolean; ignorePatternParameterDefault?: boolean; optionalPatternParameter?: boolean; variables?: { [key: string]: string; }; }; }; }; }; _overridability?: { parameters?: { [key: string]: "yes" | "no"; }; variants?: boolean; hideLockedParameters?: boolean; }; _locales?: string[]; }[]; }; _id: string; _slug?: string | null; _name: string; _author?: string; _authorSubject?: string; _creator?: string; _creatorSubject?: string; _pattern?: string; _patternDataResources?: { [key: string]: { type: string; isPatternParameter?: boolean; ignorePatternParameterDefault?: boolean; optionalPatternParameter?: boolean; variables?: { [key: string]: string; }; }; }; _dataResources?: { [key: string]: { type: string; isPatternParameter?: boolean; ignorePatternParameterDefault?: boolean; optionalPatternParameter?: boolean; variables?: { [key: string]: string; }; }; }; _patternError?: "NOTFOUND" | "CYCLIC"; _overrides?: { [key: string]: { parameters?: { [key: string]: { value?: unknown; type: string; connectedData?: { pointer: string; syntax: "jptr"; failureAction?: "t" | "p" | "c" | "a"; failureLogLevel?: "e" | "w" | "i"; failureDefault?: string; }; locales?: { [key: string]: unknown; }; conditions?: { when: { op?: "&" | "|"; clauses: ({ rule: string; source?: string; op: string; value: string | string[]; } | any)[]; }; value: unknown; id: number; }[]; localesConditions?: { [key: string]: { when: { op?: "&" | "|"; clauses: ({ rule: string; source?: string; op: string; value: string | string[]; } | any)[]; }; value: unknown; id: number; }[]; }; }; }; slots?: { [key: string]: any[]; }; variant?: string; dataResources?: { [key: string]: { type: string; isPatternParameter?: boolean; ignorePatternParameterDefault?: boolean; optionalPatternParameter?: boolean; variables?: { [key: string]: string; }; }; }; }; }; _patternOverrides?: { [key: string]: { parameters?: { [key: string]: { value?: unknown; type: string; connectedData?: { pointer: string; syntax: "jptr"; failureAction?: "t" | "p" | "c" | "a"; failureLogLevel?: "e" | "w" | "i"; failureDefault?: string; }; locales?: { [key: string]: unknown; }; conditions?: { when: { op?: "&" | "|"; clauses: ({ rule: string; source?: string; op: string; value: string | string[]; } | any)[]; }; value: unknown; id: number; }[]; localesConditions?: { [key: string]: { when: { op?: "&" | "|"; clauses: ({ rule: string; source?: string; op: string; value: string | string[]; } | any)[]; }; value: unknown; id: number; }[]; }; }; }; slots?: { [key: string]: any[]; }; variant?: string; dataResources?: { [key: string]: { type: string; isPatternParameter?: boolean; ignorePatternParameterDefault?: boolean; optionalPatternParameter?: boolean; variables?: { [key: string]: string; }; }; }; }; }; _overridability?: { parameters?: { [key: string]: "yes" | "no"; }; variants?: boolean; hideLockedParameters?: boolean; }; _locales?: string[]; } | undefined; isContextualEditing: boolean; }