|
@@ -35,6 +35,7 @@ class LinkEditModal extends React.PureComponent {
|
|
|
linkerType: Linker.types.markdownLink,
|
|
linkerType: Linker.types.markdownLink,
|
|
|
markdown: '',
|
|
markdown: '',
|
|
|
permalink: '',
|
|
permalink: '',
|
|
|
|
|
+ linkText: '',
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
this.isApplyPukiwikiLikeLinkerPlugin = window.growiRenderer.preProcessors.some(process => process.constructor.name === 'PukiwikiLikeLinker');
|
|
this.isApplyPukiwikiLikeLinkerPlugin = window.growiRenderer.preProcessors.some(process => process.constructor.name === 'PukiwikiLikeLinker');
|
|
@@ -53,15 +54,17 @@ class LinkEditModal extends React.PureComponent {
|
|
|
this.renderPreview = this.renderPreview.bind(this);
|
|
this.renderPreview = this.renderPreview.bind(this);
|
|
|
this.getRootPath = this.getRootPath.bind(this);
|
|
this.getRootPath = this.getRootPath.bind(this);
|
|
|
|
|
|
|
|
- this.getPreviewDebounced = debounce(200, this.getPreview.bind(this));
|
|
|
|
|
|
|
+ this.generateAndSetPreviewDebounced = debounce(200, this.generateAndSetPreview.bind(this));
|
|
|
|
|
+ this.generateAndSetLinkTextPreviewDebounced = debounce(200, this.generateAndSetLinkTextPreview.bind(this));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps, prevState) {
|
|
componentDidUpdate(prevProps, prevState) {
|
|
|
const { linkInputValue: prevLinkInputValue } = prevState;
|
|
const { linkInputValue: prevLinkInputValue } = prevState;
|
|
|
const { linkInputValue } = this.state;
|
|
const { linkInputValue } = this.state;
|
|
|
if (linkInputValue !== prevLinkInputValue) {
|
|
if (linkInputValue !== prevLinkInputValue) {
|
|
|
- this.getPreviewDebounced(linkInputValue);
|
|
|
|
|
|
|
+ this.generateAndSetPreviewDebounced(linkInputValue);
|
|
|
}
|
|
}
|
|
|
|
|
+ this.generateAndSetLinkTextPreviewDebounced();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// defaultMarkdownLink is an instance of Linker
|
|
// defaultMarkdownLink is an instance of Linker
|
|
@@ -160,7 +163,7 @@ class LinkEditModal extends React.PureComponent {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- async getPreview(path) {
|
|
|
|
|
|
|
+ async generateAndSetPreview(path) {
|
|
|
let markdown = '';
|
|
let markdown = '';
|
|
|
let permalink = '';
|
|
let permalink = '';
|
|
|
try {
|
|
try {
|
|
@@ -174,6 +177,12 @@ class LinkEditModal extends React.PureComponent {
|
|
|
this.setState({ markdown, permalink });
|
|
this.setState({ markdown, permalink });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ generateAndSetLinkTextPreview() {
|
|
|
|
|
+ const linker = this.generateLink();
|
|
|
|
|
+ const linkText = linker.generateMarkdownText();
|
|
|
|
|
+ this.setState({ linkText });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
handleChangeTypeahead(selected) {
|
|
handleChangeTypeahead(selected) {
|
|
|
const page = selected[0];
|
|
const page = selected[0];
|
|
|
if (page != null) {
|
|
if (page != null) {
|
|
@@ -203,10 +212,8 @@ class LinkEditModal extends React.PureComponent {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
save() {
|
|
save() {
|
|
|
- const output = this.generateLink();
|
|
|
|
|
-
|
|
|
|
|
if (this.props.onSave != null) {
|
|
if (this.props.onSave != null) {
|
|
|
- this.props.onSave(output);
|
|
|
|
|
|
|
+ this.props.onSave(this.state.linkText);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
this.hide();
|
|
this.hide();
|