BlockLoop.jsx 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. import React from 'react'
  2. import LazyLoad from 'react-lazyload'
  3. import cls from 'classnames'
  4. import Block from './base/Block'
  5. import BlockChildren from './base/BlockChildren'
  6. import BlockOrder from './base/BlockOrder'
  7. import BlockDel from './base/BlockDel'
  8. import BlockCite from './base/BlockCite'
  9. import BlockMemo from './base/BlockMemo'
  10. import BlockLoopOption from './base/loop/BlockLoopOption'
  11. import BlockLoopCustom from './base/loop/BlockLoopCustom'
  12. export default class BlockLoop extends Block {
  13. constructor(props) {
  14. super(props)
  15. }
  16. render() {
  17. let jengaContent = document.getElementsByClassName('jenga-content')[0]
  18. let getRelChildComs = () => {
  19. return this.state.hasChildren ? (
  20. <React.Fragment>
  21. {this.state.isExpand ? (
  22. <span
  23. className={cls(
  24. 'index-line',
  25. 'index-main-line',
  26. 'index-line-' + this.getNextLineColor()
  27. )}
  28. />
  29. ) : null}
  30. <button
  31. className={cls(
  32. 'btn-clear btn-toggle-sub btn-expand',
  33. 'btn-toggle-sub-' +
  34. (this.state.isExpand ? 'expand-' : 'collapse-') +
  35. this.getLineColor()
  36. )}
  37. onClick={this.onToggleBlockExpand}
  38. />
  39. </React.Fragment>
  40. ) : (
  41. <div
  42. className={cls(
  43. 'btn-clear btn-toggle-sub btn-toggle-sub-empty',
  44. 'btn-toggle-sub-empty-' + this.getLineColor()
  45. )}
  46. />
  47. )
  48. }
  49. return (
  50. <LazyLoad height={26} overflow={true} scrollContainer={jengaContent}>
  51. <div className="block-wrap block-wrap-loop f--h">
  52. <span
  53. className={cls('index-line', 'index-line-' + this.getLineColor(), {
  54. 'index-last-line': this.props.isLast,
  55. 'index-virtual-layer': this.props.virtualLayer
  56. })}
  57. style={this.indexLeftStyle()}
  58. />
  59. <div
  60. className={cls('flex-1', {
  61. 'flex-wrap-disabled': !this.state.isEnable
  62. })}
  63. >
  64. <div
  65. className={cls('block-item block-loop f--h', {
  66. 'block-active': this.state.isActive
  67. })}
  68. // onDragOver={this.onDragOver}
  69. // onDrop={this.onDrop}
  70. onClick={this.onSelectBlock}
  71. onContextMenu={this.onContextMenu}
  72. >
  73. <BlockDel
  74. isActive={this.state.isActive}
  75. layer={this.props.layer}
  76. bid={this.props.bid}
  77. />
  78. <BlockOrder
  79. layer={this.props.layer}
  80. bid={this.props.bid}
  81. eventNodeId={this.props.eventNodeId}
  82. extraGapGroupLayer={this.extraGapGroupLayer()}
  83. />
  84. <div
  85. className="block-gap"
  86. style={{
  87. left: -this.getGapLeft() + 'px',
  88. padding: '0 ' + this.getGapLeft() / 2 + 'px'
  89. }}
  90. />
  91. {getRelChildComs()}
  92. <div
  93. id={'block-main-' + this.props.bid}
  94. className="block-main flex-1 f--h"
  95. style={this.blockMainStyle()}
  96. draggable={true}
  97. // onDragStart={this.onDragStart}
  98. // onDragEnd={this.onDragEnd}
  99. >
  100. <div
  101. id={'over-cover-' + this.props.bid}
  102. className="over-cover"
  103. />
  104. <BlockLoopOption
  105. bid={this.props.bid}
  106. isEnable={this.state.isEnable}
  107. eventNodeId={this.props.eventNodeId}
  108. />
  109. <BlockLoopCustom
  110. bid={this.props.bid}
  111. layer={this.props.layer}
  112. groupLayer={this.props.groupLayer}
  113. nestGroupLayer={this.props.nestGroupLayer}
  114. extraGapGroupLayer={this.extraGapGroupLayer()}
  115. eventNodeId={this.props.eventNodeId}
  116. />
  117. </div>
  118. <BlockCite
  119. bid={this.props.bid}
  120. eventNodeId={this.props.eventNodeId}
  121. />
  122. <BlockMemo
  123. className="block-loop-memo"
  124. active={this.state.isActive}
  125. bid={this.props.bid}
  126. eventNodeId={this.props.eventNodeId}
  127. />
  128. </div>
  129. {this.state.isExpand ? (
  130. <BlockChildren
  131. loops={this.getLoops()}
  132. layer={this.props.layer + 1}
  133. groupLayer={this.props.groupLayer}
  134. nestGroupLayer={0}
  135. offspringInNestGroupLayer={this.props.nestGroupLayer}
  136. extraGapGroupLayer={this.extraGapGroupLayer()}
  137. parentBid={this.props.bid}
  138. eventNodeId={this.props.eventNodeId}
  139. visibleBlockIds={this.props.visibleBlockIds}
  140. />
  141. ) : null}
  142. </div>
  143. </div>
  144. </LazyLoad>
  145. )
  146. }
  147. }