@paperbits/core
Version:
Paperbits core components.
37 lines (29 loc) • 985 B
text/typescript
import * as ko from "knockout";
import template from "./mediaHyperlinkDetails.html";
import { Component, Param, Event, OnMounted } from "@paperbits/common/ko/decorators";
import { HyperlinkModel } from "@paperbits/common/permalinks";
export class MediaHyperlinkDetails {
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);
this.target.subscribe(this.applyChanges);
}
public applyChanges(): void {
this.hyperlink.target = this.target();
if (this.onHyperlinkChange) {
this.onHyperlinkChange(this.hyperlink);
}
}
}