diff --git a/src/RTE/index.tsx b/src/RTE/index.tsx index 74669b3..b4cdd78 100644 --- a/src/RTE/index.tsx +++ b/src/RTE/index.tsx @@ -158,6 +158,13 @@ export class RTEPlugin { break; } + case "hoveringToolbarOptions": { + this.pluginMetaData.registry.hoveringToolbarOptions = { + autoWidth: value?.autoWidth + } + break; + } + case "elementType": { const isInline = (typeof value === "string" && value === "inline") || diff --git a/src/RTE/types.tsx b/src/RTE/types.tsx index e200849..ed3d7c6 100644 --- a/src/RTE/types.tsx +++ b/src/RTE/types.tsx @@ -204,11 +204,15 @@ type IDynamicFunction = ( | Exclude | Exclude[]; +type IHoveringToolbarOptions = { + autoWidth?: boolean; +} export declare interface IConfig { title: string; icon: React.ReactElement | null; display: IDisplayOnOptions | IDisplayOnOptions[]; elementType: IElementTypeOptions | IElementTypeOptions[] | IDynamicFunction; + hoveringToolbarOptions?: IHoveringToolbarOptions; render?: (...params: any) => ReactElement; shouldOverride?: (element: IRteElementType) => boolean; } @@ -230,6 +234,9 @@ export declare interface IRegistry { inMainToolbar: boolean; inHoveringToolbar: boolean; }; + hoveringToolbarOptions?: { + autoWidth: true; + } isContentstackElement: boolean; beforeChildrenRender?: (...params: any) => any; beforeElementRender?: (...params: any) => any; diff --git a/src/entry.ts b/src/entry.ts index 58de2b8..a8281a2 100755 --- a/src/entry.ts +++ b/src/entry.ts @@ -5,6 +5,7 @@ import Field from "./field"; import { IFieldInitData, IFieldModifierLocationInitData, + IRTEInitData, ISidebarInitData, } from "./types"; import { Entry as EntryType } from "../src/types/entry.types"; @@ -35,6 +36,7 @@ class Entry { initializationData: | IFieldInitData | ISidebarInitData + | IRTEInitData | IFieldModifierLocationInitData, connection: typeof postRobot, emitter: EventEmitter, diff --git a/src/stack/index.ts b/src/stack/index.ts index b482835..aeae48d 100755 --- a/src/stack/index.ts +++ b/src/stack/index.ts @@ -3,6 +3,7 @@ import ContentType from './api/content-type/index'; import { onData, onError } from "../utils/utils"; import { BranchDetail, GetAllStacksOptions, StackAdditionalData, StackDetail, StackSearchQuery } from '../types/stack.types'; import { IManagementTokenDetails } from '../types'; +import { GenericObjectType } from "../types/common.types"; /** @@ -272,6 +273,18 @@ class Stack { getCurrentBranch(): BranchDetail | null { return this._currentBranch; } + + /** + * Returns variant groups details. + * @returns variant groups details. + */ + getVariantById(variant_uid:string) { + if (!variant_uid) { + return Promise.reject(new Error('variant uid is required')); + } + const options = { params: {uid : variant_uid}, action: 'getVariantById' }; + return this._connection.sendToParent('stackQuery', options).then(onData).catch(onError); + } } export default Stack; diff --git a/src/types.ts b/src/types.ts index f840ef6..ccc68e7 100644 --- a/src/types.ts +++ b/src/types.ts @@ -132,6 +132,9 @@ export declare interface IFullPageLocationInitData extends ICommonInitData { export declare interface IRTEInitData extends ICommonInitData { config?: GenericObjectType; type: LocationType.RTE; + entry: Entry; + content_type: ContentType; + locale: string; } export declare interface IAppConfigInitData extends ICommonInitData { diff --git a/src/types/entry.types.ts b/src/types/entry.types.ts index 90083a2..0919335 100644 --- a/src/types/entry.types.ts +++ b/src/types/entry.types.ts @@ -1,5 +1,5 @@ import Field from "../field"; -import { AnyProperty } from "./common.types"; +import { AnyProperty, GenericObjectType } from "./common.types"; export declare interface IGetFieldOptions { /** @@ -47,4 +47,6 @@ export interface Entry extends AnyProperty { publish_details: Array; locale: string; url?: string; + variant_uid?: string; + _variant?: GenericObjectType } diff --git a/src/uiLocation.ts b/src/uiLocation.ts index 141d845..049c187 100755 --- a/src/uiLocation.ts +++ b/src/uiLocation.ts @@ -19,6 +19,7 @@ import { IDashboardWidget, IFieldModifierLocation, IFullPageLocation, + IRTEInitData, ISidebarWidget, InitializationData, LocationType, @@ -108,6 +109,7 @@ class UiLocation { SidebarWidget: ISidebarWidget | null; CustomField: ICustomField | null; RTEPlugin: IRTEPluginInitializer | null; + RTELocation: GenericObjectType | null; AppConfigWidget: IAppConfigWidget | null; AssetSidebarWidget: AssetSidebarWidget | null; FullPage: IFullPageLocation | null; @@ -144,6 +146,7 @@ class UiLocation { CustomField: null, SidebarWidget: null, RTEPlugin: null, + RTELocation: null, AppConfigWidget: null, AssetSidebarWidget: null, FullPage: null, @@ -216,6 +219,13 @@ class UiLocation { case LocationType.RTE: { import("./RTE").then(({ rtePluginInitializer }) => { this.location.RTEPlugin = rtePluginInitializer; + this.location.RTELocation = { + entry: new Entry( + initializationData as IRTEInitData, + postRobot, + emitter + ), + }; }); break; }