@paperbits/core
Version:
Paperbits core components.
38 lines (30 loc) • 1.07 kB
text/typescript
import * as ko from "knockout";
import template from "./pageHyperlinkDetails.html";
import { Component, Param, Event, OnMounted } from "@paperbits/common/ko/decorators";
import { HyperlinkModel } from "@paperbits/common/permalinks";
import { NavigationTarget } from "@paperbits/common/html";
export class PageHyperlinkDetails {
public target: ko.Observable<string>;
constructor() {
this.target = ko.observable();
}
public hyperlink: HyperlinkModel;
public onHyperlinkChange: (hyperlink: HyperlinkModel) => void;
public async initialize(): Promise<void> {
this.target(this.hyperlink.target || NavigationTarget.Self);
this.target.subscribe(this.applyChanges);
}
public applyChanges(): void {
this.hyperlink.target = this.target();
if (this.onHyperlinkChange) {
this.onHyperlinkChange(this.hyperlink);
}
}
}