From 72a221acd5fb70cb8ec5be7c80265a31fb49b1fa Mon Sep 17 00:00:00 2001 From: Alexander Zaslonov Date: Sat, 1 Feb 2025 14:12:14 -0800 Subject: [PATCH] Added help center handlers. --- src/editing/widgetContext.ts | 5 +++++ src/objects.ts | 5 +++++ src/tutorials/defaultHelpService.ts | 2 +- src/ui/commands.ts | 2 +- src/ui/view.ts | 7 +++++++ 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/editing/widgetContext.ts b/src/editing/widgetContext.ts index b980640c..b74c4045 100644 --- a/src/editing/widgetContext.ts +++ b/src/editing/widgetContext.ts @@ -52,6 +52,11 @@ export interface WidgetContext { */ openWidgetEditor: () => void; + /** + * Opens help center with specified article key. + */ + openHelpCenter: (articleKey: string) => void; + /** * Deletes selected widget. */ diff --git a/src/objects.ts b/src/objects.ts index 7b4a0254..20798341 100644 --- a/src/objects.ts +++ b/src/objects.ts @@ -135,6 +135,11 @@ export function cleanupObject(source: object, options?: CleanupOptions): void { } } else if (childNode instanceof Object) { + if (childNode === source) { + console.log(`Ciruclar reference: `, source); + throw new Error(`Ciruclar reference detected. See the message above.`); + } + cleanupObject(childNode, options); if (Object.keys(childNode).length === 0) { diff --git a/src/tutorials/defaultHelpService.ts b/src/tutorials/defaultHelpService.ts index 04d107ad..89541665 100644 --- a/src/tutorials/defaultHelpService.ts +++ b/src/tutorials/defaultHelpService.ts @@ -4,6 +4,6 @@ const defaultHelpCenterUrl = `https://help.paperbits.io`; export class DefaultHelpService implements HelpService { public async getHelpContent(articleKey: string): Promise { - return ``; + return ``; } } diff --git a/src/ui/commands.ts b/src/ui/commands.ts index 6fd0c42d..5e5d50a4 100644 --- a/src/ui/commands.ts +++ b/src/ui/commands.ts @@ -46,7 +46,7 @@ export function openHelpArticleCommand(context: WidgetContext, articleKey: strin iconClass: "paperbits-icon paperbits-c-question", position: "top right", callback: () => { - // + context.openHelpCenter(articleKey); } } } diff --git a/src/ui/view.ts b/src/ui/view.ts index a18efae7..f154011f 100644 --- a/src/ui/view.ts +++ b/src/ui/view.ts @@ -17,11 +17,18 @@ export interface View { */ component?: IComponent; + /** + * Help heading. + */ + helpHeading?: string; + /** * Help text. */ helpText?: string; + helpArticle?: string; + /** * Host element. */