LinkEditModal.jsx 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. import React from 'react';
  2. import { Modal, ModalHeader, ModalBody } from 'reactstrap';
  3. export default class LinkEditModal extends React.PureComponent {
  4. constructor(props) {
  5. super(props);
  6. this.state = {
  7. show: false,
  8. isUseRelativePath: false,
  9. inputValue: '~.cloud.~',
  10. labelInputValue: 'ここがリンク',
  11. };
  12. this.cancel = this.cancel.bind(this);
  13. this.toggleIsUseRelativePath = this.toggleIsUseRelativePath.bind(this);
  14. this.showLog = this.showLog.bind(this);
  15. }
  16. show() {
  17. this.setState({ show: true });
  18. }
  19. cancel() {
  20. this.hide();
  21. }
  22. hide() {
  23. this.setState({
  24. show: false,
  25. });
  26. }
  27. toggleIsUseRelativePath() {
  28. this.setState({ isUseRelativePath: !this.state.isUseRelativePath });
  29. }
  30. renderPreview() {
  31. // TODO GW-2658
  32. }
  33. insertLinkIntoEditor() {
  34. // TODO GW-2659
  35. }
  36. showLog() {
  37. console.log(this.state.inputValue);
  38. }
  39. handleInputChange(linkValue) {
  40. this.setState({ inputValue: linkValue });
  41. }
  42. labelInputChange(labelValue) {
  43. this.setState({ labelInputValue: labelValue });
  44. }
  45. render() {
  46. return (
  47. <Modal isOpen={this.state.show} toggle={this.cancel} size="lg">
  48. <ModalHeader tag="h4" toggle={this.cancel} className="bg-primary text-light">
  49. Edit Links
  50. </ModalHeader>
  51. <ModalBody className="container">
  52. <div className="row">
  53. <div className="col">
  54. <div className="form-gorup my-3">
  55. <label htmlFor="linkInput">Link</label>
  56. <div className="input-group">
  57. <input
  58. className="form-control"
  59. id="linkInput"
  60. type="text"
  61. placeholder="/foo/bar/31536000"
  62. aria-describedby="button-addon"
  63. value={this.state.inputValue}
  64. onChange={e => this.handleInputChange(e.target.value)}
  65. />
  66. <div className="input-group-append">
  67. <button type="button" id="button-addon" className="btn btn-secondary" onClick={this.showLog}>
  68. Preview
  69. </button>
  70. </div>
  71. </div>
  72. </div>
  73. <div className="d-block d-lg-none">
  74. {this.renderPreview}
  75. render preview
  76. </div>
  77. <div className="linkedit-tabs">
  78. <ul className="nav nav-tabs" role="tabist">
  79. <li className="nav-item">
  80. <a className="nav-link active" href="#Pukiwiki" role="tab" data-toggle="tab">
  81. Pukiwiki
  82. </a>
  83. </li>
  84. <li className="nav-item">
  85. <a className="nav-link" href="#Crowi" role="tab" data-toggle="tab">
  86. Crowi
  87. </a>
  88. </li>
  89. <li className="nav-item">
  90. <a className="nav-link" href="#MD" role="tab" data-toggle="tab">
  91. MD
  92. </a>
  93. </li>
  94. </ul>
  95. <div className="tab-content pt-3">
  96. <div id="Pukiwiki" className="tab-pane active" role="tabpanel">
  97. <form className="form-group">
  98. <div className="form-group">
  99. <label htmlFor="pukiwikiLink">Label</label>
  100. <input
  101. type="text"
  102. className="form-control"
  103. id="pukiwikiLink"
  104. value={this.state.labelInputValue}
  105. onChange={e => this.labelInputChange(e.target.value)}
  106. >
  107. </input>
  108. </div>
  109. <span className="p-2">[[{this.state.labelInputValue} &gt; {this.state.inputValue}]]</span>
  110. <div>
  111. </div>
  112. <div className="form-inline">
  113. <div className="custom-control custom-checkbox custom-checkbox-info">
  114. <input className="custom-control-input" id="relativePath" type="checkbox" checked={this.state.isUseRelativePath} />
  115. <label className="custom-control-label" htmlFor="relativePath" onClick={this.toggleIsUseRelativePath}>
  116. Use relative path
  117. </label>
  118. </div>
  119. <button type="button" className="btn btn-primary ml-auto">
  120. Done
  121. </button>
  122. </div>
  123. </form>
  124. </div>
  125. <div id="Crowi" className="tab-pane" role="tabpanel">
  126. <form className="form-group">
  127. <div className="form-group">
  128. <label htmlFor="crowiLink">Label</label>
  129. <input type="text" className="form-control" id="crowiLink"></input>
  130. </div>
  131. <div>
  132. <span>URI</span>
  133. </div>
  134. <div className="d-flex">
  135. <button type="button" className="btn btn-primary ml-auto">
  136. Done
  137. </button>
  138. </div>
  139. </form>
  140. </div>
  141. <div id="MD" className="tab-pane" role="tabpanel">
  142. <form className="form-group">
  143. <div className="form-group">
  144. <label htmlFor="MDLink">Label</label>
  145. <input type="text" className="form-control" id="MDLink"></input>
  146. </div>
  147. <div>
  148. <span>URI</span>
  149. </div>
  150. <div className="form-inline">
  151. <div className="custom-control custom-checkbox custom-checkbox-info">
  152. <input className="custom-control-input" id="relativePath" type="checkbox" checked={this.state.isUseRelativePath} />
  153. <label className="custom-control-label" htmlFor="relativePath" onClick={this.toggleIsUseRelativePath}>
  154. Use relative path
  155. </label>
  156. </div>
  157. <button type="button" className="btn btn-primary ml-auto">
  158. Done
  159. </button>
  160. </div>
  161. </form>
  162. </div>
  163. </div>
  164. </div>
  165. </div>
  166. <div className="col d-none d-lg-block">
  167. {this.renderPreview}
  168. render preview
  169. </div>
  170. </div>
  171. </ModalBody>
  172. </Modal>
  173. );
  174. }
  175. }