2022-07-06 04:47:15 +03:00
|
|
|
import * as wasm from "./pkg";
|
|
|
|
|
2021-12-17 18:03:02 +02:00
|
|
|
import { Run } from "./run";
|
|
|
|
import { Insert } from "./insert";
|
|
|
|
import { Delete } from "./delete";
|
|
|
|
import { BookmarkStart } from "./bookmark-start";
|
|
|
|
import { BookmarkEnd } from "./bookmark-end";
|
|
|
|
import { Comment } from "./comment";
|
|
|
|
import { CommentEnd } from "./comment-end";
|
|
|
|
import { ParagraphChild } from "./paragraph";
|
|
|
|
|
2022-07-06 04:47:15 +03:00
|
|
|
export type HyperlinkType = "anchor" | "external";
|
|
|
|
|
2021-12-17 18:03:02 +02:00
|
|
|
export class Hyperlink {
|
2022-07-06 04:47:15 +03:00
|
|
|
v: string;
|
|
|
|
type: HyperlinkType;
|
2021-12-17 18:03:02 +02:00
|
|
|
children: ParagraphChild[] = [];
|
|
|
|
|
2022-07-06 04:47:15 +03:00
|
|
|
constructor(v: string, t: HyperlinkType) {
|
|
|
|
this.v = v;
|
|
|
|
this.type = t;
|
|
|
|
}
|
|
|
|
|
2021-12-17 18:03:02 +02:00
|
|
|
addRun(run: Run) {
|
|
|
|
this.children.push(run);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
addInsert(ins: Insert) {
|
|
|
|
this.children.push(ins);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
addDelete(del: Delete) {
|
|
|
|
this.children.push(del);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
addBookmarkStart(id: number, name: string) {
|
|
|
|
this.children.push(new BookmarkStart(id, name));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
addBookmarkEnd(id: number) {
|
|
|
|
this.children.push(new BookmarkEnd(id));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
addCommentStart(comment: Comment) {
|
|
|
|
this.children.push(comment);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
addCommentEnd(end: CommentEnd) {
|
|
|
|
this.children.push(end);
|
|
|
|
return this;
|
|
|
|
}
|
2022-07-06 04:47:15 +03:00
|
|
|
}
|
2021-12-17 18:03:02 +02:00
|
|
|
|
2022-07-06 04:47:15 +03:00
|
|
|
export const convertHyperlinkType = (link: Hyperlink): wasm.HyperlinkType => {
|
|
|
|
if (link.type === "anchor") {
|
|
|
|
return wasm.HyperlinkType.Anchor;
|
2021-12-17 18:03:02 +02:00
|
|
|
}
|
2022-07-06 04:47:15 +03:00
|
|
|
return wasm.HyperlinkType.External;
|
|
|
|
};
|