Skip to content

Commit

Permalink
Added help center handlers.
Browse files Browse the repository at this point in the history
  • Loading branch information
azaslonov committed Feb 1, 2025
1 parent 5eebdaf commit 72a221a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/editing/widgetContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export interface WidgetContext {
*/
openWidgetEditor: () => void;

/**
* Opens help center with specified article key.
*/
openHelpCenter: (articleKey: string) => void;

/**
* Deletes selected widget.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/tutorials/defaultHelpService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ const defaultHelpCenterUrl = `https://help.paperbits.io`;

export class DefaultHelpService implements HelpService {
public async getHelpContent(articleKey: string): Promise<string> {
return `<iframe class="host" src="${defaultHelpCenterUrl}/${articleKey}"></iframe>`;
return `<iframe class="host" src="${defaultHelpCenterUrl}${articleKey}"></iframe>`;
}
}
2 changes: 1 addition & 1 deletion src/ui/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function openHelpArticleCommand(context: WidgetContext, articleKey: strin
iconClass: "paperbits-icon paperbits-c-question",
position: "top right",
callback: () => {
//
context.openHelpCenter(articleKey);
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/ui/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@ export interface View {
*/
component?: IComponent;

/**
* Help heading.
*/
helpHeading?: string;

/**
* Help text.
*/
helpText?: string;

helpArticle?: string;

/**
* Host element.
*/
Expand Down

0 comments on commit 72a221a

Please sign in to comment.