From b20bcce98943bc1a7a413f4a945670ab11861481 Mon Sep 17 00:00:00 2001 From: Parvin Date: Mon, 7 Apr 2025 15:33:55 +0300 Subject: [PATCH 01/14] Add htmlRenderEnabled option to Tour for enabling HTML rendering in steps --- src/packages/hint/option.ts | 3 +++ src/packages/tooltip/tooltip.ts | 10 +++++++++- src/packages/tour/components/TourTooltip.ts | 3 +++ src/packages/tour/option.ts | 3 +++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/packages/hint/option.ts b/src/packages/hint/option.ts index d64c5eb67..4c4885b10 100644 --- a/src/packages/hint/option.ts +++ b/src/packages/hint/option.ts @@ -28,6 +28,8 @@ export interface HintOptions { autoPosition: boolean; /* Precedence of positions, when auto is enabled */ positionPrecedence: TooltipPosition[]; + /* Optional property to determine if content should be rendered as HTML */ + htmlRenderEnabled?: boolean; } export function getDefaultHintOptions(): HintOptions { @@ -45,5 +47,6 @@ export function getDefaultHintOptions(): HintOptions { helperElementPadding: 10, autoPosition: true, positionPrecedence: ["bottom", "top", "right", "left"], + htmlRenderEnabled: true, }; } diff --git a/src/packages/tooltip/tooltip.ts b/src/packages/tooltip/tooltip.ts index c7adb9b52..95de42d6b 100644 --- a/src/packages/tooltip/tooltip.ts +++ b/src/packages/tooltip/tooltip.ts @@ -315,6 +315,8 @@ export type TooltipProps = { autoPosition: boolean; positionPrecedence: TooltipPosition[]; + htmlRenderEnabled?: boolean; + onClick?: (e: any) => void; className?: string; }; @@ -330,9 +332,11 @@ export const Tooltip = ( transitionDuration = 0, // auto-alignment properties - autoPosition = true, positionPrecedence = [], className, + htmlRenderEnabled = false, + autoPosition = false, + onClick, }: TooltipProps, children?: ChildDom[] @@ -417,6 +421,10 @@ export const Tooltip = ( } }); + if (htmlRenderEnabled) { + // if the content is HTML, we need to set the innerHTML of the tooltip + } + const tooltip = div( { style: () => diff --git a/src/packages/tour/components/TourTooltip.ts b/src/packages/tour/components/TourTooltip.ts index a56e15536..90568dfef 100644 --- a/src/packages/tour/components/TourTooltip.ts +++ b/src/packages/tour/components/TourTooltip.ts @@ -406,6 +406,7 @@ export type TourTooltipProps = Omit< dontShowAgain: boolean; dontShowAgainLabel: string; onDontShowAgainChange: (checked: boolean) => void; + htmlRenderEnabled?: boolean; }; export const TourTooltip = ({ @@ -442,6 +443,7 @@ export const TourTooltip = ({ dontShowAgain, onDontShowAgainChange, dontShowAgainLabel, + htmlRenderEnabled, ...props }: TourTooltipProps) => { const children = []; @@ -498,6 +500,7 @@ export const TourTooltip = ({ element: step.element as HTMLElement, hintMode: false, position, + htmlRenderEnabled: false, }, children ); diff --git a/src/packages/tour/option.ts b/src/packages/tour/option.ts index 913212511..0092a0268 100644 --- a/src/packages/tour/option.ts +++ b/src/packages/tour/option.ts @@ -72,6 +72,8 @@ export interface TourOptions { buttonClass: string; /* additional classes to put on progress bar */ progressBarAdditionalClass: string; + /* Optional property to determine if content should be rendered as HTML */ + htmlRenderEnabled?: boolean; } export function getDefaultTourOptions(): TourOptions { @@ -113,5 +115,6 @@ export function getDefaultTourOptions(): TourOptions { buttonClass: "introjs-button", progressBarAdditionalClass: "", + htmlRenderEnabled: true, }; } From b479dfe3cf9ff2738625609a9491b2c906d4d0c1 Mon Sep 17 00:00:00 2001 From: Parvin Date: Wed, 9 Apr 2025 10:18:52 +0300 Subject: [PATCH 02/14] chore: update PR comment --- src/packages/tooltip/tooltip.ts | 7 +++---- src/packages/tour/components/TourTooltip.ts | 3 --- src/packages/tour/option.ts | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/packages/tooltip/tooltip.ts b/src/packages/tooltip/tooltip.ts index 95de42d6b..92bd2571a 100644 --- a/src/packages/tooltip/tooltip.ts +++ b/src/packages/tooltip/tooltip.ts @@ -315,7 +315,7 @@ export type TooltipProps = { autoPosition: boolean; positionPrecedence: TooltipPosition[]; - htmlRenderEnabled?: boolean; + renderAsHtml?: boolean; onClick?: (e: any) => void; className?: string; @@ -334,8 +334,7 @@ export const Tooltip = ( // auto-alignment properties positionPrecedence = [], className, - htmlRenderEnabled = false, - autoPosition = false, + autoPosition = true, onClick, }: TooltipProps, @@ -421,7 +420,7 @@ export const Tooltip = ( } }); - if (htmlRenderEnabled) { + if (renderAsHtml) { // if the content is HTML, we need to set the innerHTML of the tooltip } diff --git a/src/packages/tour/components/TourTooltip.ts b/src/packages/tour/components/TourTooltip.ts index 90568dfef..a56e15536 100644 --- a/src/packages/tour/components/TourTooltip.ts +++ b/src/packages/tour/components/TourTooltip.ts @@ -406,7 +406,6 @@ export type TourTooltipProps = Omit< dontShowAgain: boolean; dontShowAgainLabel: string; onDontShowAgainChange: (checked: boolean) => void; - htmlRenderEnabled?: boolean; }; export const TourTooltip = ({ @@ -443,7 +442,6 @@ export const TourTooltip = ({ dontShowAgain, onDontShowAgainChange, dontShowAgainLabel, - htmlRenderEnabled, ...props }: TourTooltipProps) => { const children = []; @@ -500,7 +498,6 @@ export const TourTooltip = ({ element: step.element as HTMLElement, hintMode: false, position, - htmlRenderEnabled: false, }, children ); diff --git a/src/packages/tour/option.ts b/src/packages/tour/option.ts index 0092a0268..f24c904f2 100644 --- a/src/packages/tour/option.ts +++ b/src/packages/tour/option.ts @@ -73,7 +73,7 @@ export interface TourOptions { /* additional classes to put on progress bar */ progressBarAdditionalClass: string; /* Optional property to determine if content should be rendered as HTML */ - htmlRenderEnabled?: boolean; + tooltipRenderAsHtml?: boolean; } export function getDefaultTourOptions(): TourOptions { @@ -115,6 +115,6 @@ export function getDefaultTourOptions(): TourOptions { buttonClass: "introjs-button", progressBarAdditionalClass: "", - htmlRenderEnabled: true, + tooltipRenderAsHtml: true, }; } From 06be56b64b88f0ad3b9c3c5dcddc4078d981bd15 Mon Sep 17 00:00:00 2001 From: Parvin Date: Wed, 9 Apr 2025 10:23:57 +0300 Subject: [PATCH 03/14] chore: update PR comment --- src/packages/hint/option.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/packages/hint/option.ts b/src/packages/hint/option.ts index 4c4885b10..0ebc47176 100644 --- a/src/packages/hint/option.ts +++ b/src/packages/hint/option.ts @@ -29,7 +29,7 @@ export interface HintOptions { /* Precedence of positions, when auto is enabled */ positionPrecedence: TooltipPosition[]; /* Optional property to determine if content should be rendered as HTML */ - htmlRenderEnabled?: boolean; + tooltipRenderAsHtml?: boolean; } export function getDefaultHintOptions(): HintOptions { @@ -47,6 +47,6 @@ export function getDefaultHintOptions(): HintOptions { helperElementPadding: 10, autoPosition: true, positionPrecedence: ["bottom", "top", "right", "left"], - htmlRenderEnabled: true, + tooltipRenderAsHtml: true, }; } From 1aef38da794d553f2383d96599e453dd331a6398 Mon Sep 17 00:00:00 2001 From: Parvin Date: Thu, 10 Apr 2025 11:22:27 +0300 Subject: [PATCH 04/14] feat: add component for rendering HTML in tooltip --- example/html-tooltip/index.html | 3 ++- src/packages/tooltip/tooltip.ts | 4 --- src/packages/tooltip/tooltipContent.ts | 29 +++++++++++++++++++++ src/packages/tour/components/TourRoot.ts | 1 + src/packages/tour/components/TourTooltip.ts | 11 +++++++- 5 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 src/packages/tooltip/tooltipContent.ts diff --git a/example/html-tooltip/index.html b/example/html-tooltip/index.html index 5c0d6329a..633fa964d 100644 --- a/example/html-tooltip/index.html +++ b/example/html-tooltip/index.html @@ -71,8 +71,9 @@

Section Six

diff --git a/example/programmatic/index.html b/example/programmatic/index.html index f1acc4a9e..978a0a326 100644 --- a/example/programmatic/index.html +++ b/example/programmatic/index.html @@ -71,7 +71,7 @@

Section Six

diff --git a/example/withoutElement/index.html b/example/withoutElement/index.html index 10f478411..a0c9e55ce 100644 --- a/example/withoutElement/index.html +++ b/example/withoutElement/index.html @@ -71,7 +71,7 @@

Section Six