|
@@ -15,6 +15,7 @@ import AppContainer from '../../services/AppContainer';
|
|
|
import PageContainer from '../../services/PageContainer';
|
|
import PageContainer from '../../services/PageContainer';
|
|
|
|
|
|
|
|
import SearchTypeahead from '../SearchTypeahead';
|
|
import SearchTypeahead from '../SearchTypeahead';
|
|
|
|
|
+import Linker from '../../models/Linker';
|
|
|
|
|
|
|
|
import { withUnstatedContainers } from '../UnstatedUtils';
|
|
import { withUnstatedContainers } from '../UnstatedUtils';
|
|
|
|
|
|
|
@@ -29,7 +30,7 @@ class LinkEditModal extends React.PureComponent {
|
|
|
isUsePermanentLink: false,
|
|
isUsePermanentLink: false,
|
|
|
linkInputValue: '',
|
|
linkInputValue: '',
|
|
|
labelInputValue: '',
|
|
labelInputValue: '',
|
|
|
- linkerType: 'mdLink',
|
|
|
|
|
|
|
+ linkerType: Linker.types.markdownLink,
|
|
|
markdown: '',
|
|
markdown: '',
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -60,7 +61,12 @@ class LinkEditModal extends React.PureComponent {
|
|
|
// defaultMarkdownLink is an instance of Linker
|
|
// defaultMarkdownLink is an instance of Linker
|
|
|
show(defaultMarkdownLink = null) {
|
|
show(defaultMarkdownLink = null) {
|
|
|
// if defaultMarkdownLink is null, set default value in inputs.
|
|
// if defaultMarkdownLink is null, set default value in inputs.
|
|
|
- const {type='mdLink', label='', link=''} = defaultMarkdownLink ;
|
|
|
|
|
|
|
+ const {type=Linker.types.markdownLink, label='', link=''} = defaultMarkdownLink ;
|
|
|
|
|
+
|
|
|
|
|
+ // if type of defaultMarkdownLink is pukiwikiLink when pukiwikiLikeLinker plugin is disable, change type(not change label and link)
|
|
|
|
|
+ if (type == Linker.types.pukiwikiLink && !this.isApplyPukiwikiLikeLinkerPlugin) {
|
|
|
|
|
+ type = Linker.types.markdownLink;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
this.setState({
|
|
this.setState({
|
|
|
show: true,
|
|
show: true,
|
|
@@ -81,7 +87,7 @@ class LinkEditModal extends React.PureComponent {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
toggleIsUseRelativePath() {
|
|
toggleIsUseRelativePath() {
|
|
|
- if (this.state.linkerType === 'growiLink') {
|
|
|
|
|
|
|
+ if (this.state.linkerType === Linker.types.growiLink) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
this.setState({ isUseRelativePath: !this.state.isUseRelativePath });
|
|
this.setState({ isUseRelativePath: !this.state.isUseRelativePath });
|
|
@@ -123,7 +129,7 @@ class LinkEditModal extends React.PureComponent {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
handleSelecteLinkerType(linkerType) {
|
|
handleSelecteLinkerType(linkerType) {
|
|
|
- if (this.state.isUseRelativePath && linkerType === 'growiLink') {
|
|
|
|
|
|
|
+ if (this.state.isUseRelativePath && linkerType === Linker.types.growiLink) {
|
|
|
this.toggleIsUseRelativePath();
|
|
this.toggleIsUseRelativePath();
|
|
|
}
|
|
}
|
|
|
this.setState({ linkerType });
|
|
this.setState({ linkerType });
|
|
@@ -154,13 +160,13 @@ class LinkEditModal extends React.PureComponent {
|
|
|
reshapedLink = path.relative(pageContainer.state.path, linkInputValue);
|
|
reshapedLink = path.relative(pageContainer.state.path, linkInputValue);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (linkerType === 'pukiwikiLink') {
|
|
|
|
|
|
|
+ if (linkerType === Linker.types.pukiwikiLink) {
|
|
|
return `[[${labelInputValue}>${reshapedLink}]]`;
|
|
return `[[${labelInputValue}>${reshapedLink}]]`;
|
|
|
}
|
|
}
|
|
|
- if (linkerType === 'growiLink') {
|
|
|
|
|
|
|
+ if (linkerType === Linker.types.growiLink) {
|
|
|
return `[${reshapedLink}]`;
|
|
return `[${reshapedLink}]`;
|
|
|
}
|
|
}
|
|
|
- if (linkerType === 'mdLink') {
|
|
|
|
|
|
|
+ if (linkerType === Linker.types.markdownLink) {
|
|
|
return `[${labelInputValue}](${reshapedLink})`;
|
|
return `[${labelInputValue}](${reshapedLink})`;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -208,16 +214,16 @@ class LinkEditModal extends React.PureComponent {
|
|
|
<div className="form-group btn-group d-flex" role="group" aria-label="type">
|
|
<div className="form-group btn-group d-flex" role="group" aria-label="type">
|
|
|
<button
|
|
<button
|
|
|
type="button"
|
|
type="button"
|
|
|
- name="mdLink"
|
|
|
|
|
- className={`btn btn-outline-secondary w-100 ${this.state.linkerType === 'mdLink' && 'active'}`}
|
|
|
|
|
|
|
+ name={Linker.types.markdownLink}
|
|
|
|
|
+ className={`btn btn-outline-secondary w-100 ${this.state.linkerType === Linker.types.markdownLink && 'active'}`}
|
|
|
onClick={e => this.handleSelecteLinkerType(e.target.name)}
|
|
onClick={e => this.handleSelecteLinkerType(e.target.name)}
|
|
|
>
|
|
>
|
|
|
Markdown
|
|
Markdown
|
|
|
</button>
|
|
</button>
|
|
|
<button
|
|
<button
|
|
|
type="button"
|
|
type="button"
|
|
|
- name="growiLink"
|
|
|
|
|
- className={`btn btn-outline-secondary w-100 ${this.state.linkerType === 'growiLink' && 'active'}`}
|
|
|
|
|
|
|
+ name={Linker.types.growiLink}
|
|
|
|
|
+ className={`btn btn-outline-secondary w-100 ${this.state.linkerType === Linker.types.growiLink && 'active'}`}
|
|
|
onClick={e => this.handleSelecteLinkerType(e.target.name)}
|
|
onClick={e => this.handleSelecteLinkerType(e.target.name)}
|
|
|
>
|
|
>
|
|
|
Growi Original
|
|
Growi Original
|
|
@@ -225,8 +231,8 @@ class LinkEditModal extends React.PureComponent {
|
|
|
{this.isApplyPukiwikiLikeLinkerPlugin && (
|
|
{this.isApplyPukiwikiLikeLinkerPlugin && (
|
|
|
<button
|
|
<button
|
|
|
type="button"
|
|
type="button"
|
|
|
- name="pukiwikiLink"
|
|
|
|
|
- className={`btn btn-outline-secondary w-100 ${this.state.linkerType === 'pukiwikiLink' && 'active'}`}
|
|
|
|
|
|
|
+ name={Linker.types.pukiwikiLink}
|
|
|
|
|
+ className={`btn btn-outline-secondary w-100 ${this.state.linkerType === Linker.types.pukiwikiLink && 'active'}`}
|
|
|
onClick={e => this.handleSelecteLinkerType(e.target.name)}
|
|
onClick={e => this.handleSelecteLinkerType(e.target.name)}
|
|
|
>
|
|
>
|
|
|
Pukiwiki
|
|
Pukiwiki
|
|
@@ -242,7 +248,7 @@ class LinkEditModal extends React.PureComponent {
|
|
|
id="label"
|
|
id="label"
|
|
|
value={this.state.labelInputValue}
|
|
value={this.state.labelInputValue}
|
|
|
onChange={e => this.handleChangeLabelInput(e.target.value)}
|
|
onChange={e => this.handleChangeLabelInput(e.target.value)}
|
|
|
- disabled={this.state.linkerType === 'growiLink'}
|
|
|
|
|
|
|
+ disabled={this.state.linkerType === Linker.types.growiLink}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
<div className="form-inline">
|
|
<div className="form-inline">
|
|
@@ -252,7 +258,7 @@ class LinkEditModal extends React.PureComponent {
|
|
|
id="relativePath"
|
|
id="relativePath"
|
|
|
type="checkbox"
|
|
type="checkbox"
|
|
|
checked={this.state.isUseRelativePath}
|
|
checked={this.state.isUseRelativePath}
|
|
|
- disabled={this.state.linkerType === 'growiLink'}
|
|
|
|
|
|
|
+ disabled={this.state.linkerType === Linker.types.growiLink}
|
|
|
/>
|
|
/>
|
|
|
<label className="custom-control-label" htmlFor="relativePath" onClick={this.toggleIsUseRelativePath}>
|
|
<label className="custom-control-label" htmlFor="relativePath" onClick={this.toggleIsUseRelativePath}>
|
|
|
Use relative path
|
|
Use relative path
|