|
|
@@ -1,17 +1,13 @@
|
|
|
export default class Linker {
|
|
|
|
|
|
constructor(
|
|
|
- type,
|
|
|
- label,
|
|
|
- link,
|
|
|
- isUsePermanentLink = false,
|
|
|
- permalink = '',
|
|
|
+ type = this.types.markdownLink,
|
|
|
+ label = '',
|
|
|
+ link = '',
|
|
|
) {
|
|
|
this.type = type;
|
|
|
this.label = label;
|
|
|
this.link = link;
|
|
|
- this.isUsePermanentLink = isUsePermanentLink;
|
|
|
- this.permalink = permalink;
|
|
|
|
|
|
this.generateMarkdownText = this.generateMarkdownText.bind(this);
|
|
|
}
|
|
|
@@ -30,25 +26,19 @@ export default class Linker {
|
|
|
}
|
|
|
|
|
|
generateMarkdownText() {
|
|
|
- let reshapedLink = this.link;
|
|
|
-
|
|
|
- if (this.isUsePermanentLink && this.permalink != null) {
|
|
|
- reshapedLink = this.permalink;
|
|
|
- }
|
|
|
-
|
|
|
if (this.label === '') {
|
|
|
- this.label = reshapedLink;
|
|
|
+ this.label = this.link;
|
|
|
}
|
|
|
|
|
|
if (this.type === Linker.types.pukiwikiLink) {
|
|
|
- if (this.label === reshapedLink) return `[[${reshapedLink}]]`;
|
|
|
- return `[[${this.label}>${reshapedLink}]]`;
|
|
|
+ if (this.label === this.link) return `[[${this.link}]]`;
|
|
|
+ return `[[${this.label}>${this.link}]]`;
|
|
|
}
|
|
|
if (this.type === Linker.types.growiLink) {
|
|
|
- return `[${reshapedLink}]`;
|
|
|
+ return `[${this.link}]`;
|
|
|
}
|
|
|
if (this.type === Linker.types.markdownLink) {
|
|
|
- return `[${this.label}](${reshapedLink})`;
|
|
|
+ return `[${this.label}](${this.link})`;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -82,15 +72,10 @@ export default class Linker {
|
|
|
link = label;
|
|
|
}
|
|
|
|
|
|
- const isUsePermanentLink = false;
|
|
|
- const permalink = '';
|
|
|
-
|
|
|
return new Linker(
|
|
|
type,
|
|
|
label,
|
|
|
link,
|
|
|
- isUsePermanentLink,
|
|
|
- permalink,
|
|
|
);
|
|
|
}
|
|
|
|