@gravity-ui/markdown-editor 15.24.1 → 15.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/build/cjs/bundle/Editor.js +56 -23
  2. package/build/cjs/bundle/Editor.js.map +1 -1
  3. package/build/cjs/extensions/additional/Math/const.d.ts +1 -0
  4. package/build/cjs/extensions/additional/Math/const.js +11 -1
  5. package/build/cjs/extensions/additional/Math/const.js.map +1 -1
  6. package/build/cjs/extensions/additional/Math/index.d.ts +1 -0
  7. package/build/cjs/extensions/additional/Math/index.js +6 -1
  8. package/build/cjs/extensions/additional/Math/index.js.map +1 -1
  9. package/build/cjs/extensions/additional/Math/latex-paste-plugin.d.ts +2 -0
  10. package/build/cjs/extensions/additional/Math/latex-paste-plugin.js +54 -0
  11. package/build/cjs/extensions/additional/Math/latex-paste-plugin.js.map +1 -0
  12. package/build/cjs/extensions/additional/Math/utils.d.ts +7 -0
  13. package/build/cjs/extensions/additional/Math/utils.js +45 -0
  14. package/build/cjs/extensions/additional/Math/utils.js.map +1 -0
  15. package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.css +8 -0
  16. package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.d.ts +3 -0
  17. package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.js +79 -11
  18. package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.js.map +1 -1
  19. package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/TooltipPlugin/TooltipView.css +4 -0
  20. package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/TooltipPlugin/index.d.ts +1 -1
  21. package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/TooltipPlugin/index.js +53 -28
  22. package/build/cjs/extensions/markdown/CodeBlock/CodeBlockHighlight/TooltipPlugin/index.js.map +1 -1
  23. package/build/cjs/extensions/markdown/CodeBlock/CodeBlockSpecs/index.d.ts +7 -0
  24. package/build/cjs/extensions/markdown/CodeBlock/CodeBlockSpecs/index.js +36 -2
  25. package/build/cjs/extensions/markdown/CodeBlock/CodeBlockSpecs/index.js.map +1 -1
  26. package/build/cjs/extensions/markdown/CodeBlock/index.d.ts +2 -1
  27. package/build/cjs/extensions/markdown/CodeBlock/index.js +21 -6
  28. package/build/cjs/extensions/markdown/CodeBlock/index.js.map +1 -1
  29. package/build/cjs/extensions/markdown/Deflist/DeflistSpecs/const.d.ts +3 -0
  30. package/build/cjs/extensions/markdown/Deflist/DeflistSpecs/const.js +4 -1
  31. package/build/cjs/extensions/markdown/Deflist/DeflistSpecs/const.js.map +1 -1
  32. package/build/cjs/extensions/markdown/Deflist/DeflistSpecs/parser.js +9 -1
  33. package/build/cjs/extensions/markdown/Deflist/DeflistSpecs/parser.js.map +1 -1
  34. package/build/cjs/extensions/markdown/Deflist/DeflistSpecs/schema.js +3 -2
  35. package/build/cjs/extensions/markdown/Deflist/DeflistSpecs/schema.js.map +1 -1
  36. package/build/cjs/extensions/markdown/Lists/ListsSpecs/const.d.ts +2 -1
  37. package/build/cjs/extensions/markdown/Lists/ListsSpecs/const.js +1 -0
  38. package/build/cjs/extensions/markdown/Lists/ListsSpecs/const.js.map +1 -1
  39. package/build/cjs/extensions/markdown/Lists/ListsSpecs/parser.js +4 -1
  40. package/build/cjs/extensions/markdown/Lists/ListsSpecs/parser.js.map +1 -1
  41. package/build/cjs/extensions/markdown/Lists/ListsSpecs/schema.js +3 -2
  42. package/build/cjs/extensions/markdown/Lists/ListsSpecs/schema.js.map +1 -1
  43. package/build/cjs/extensions/markdown/Table/TableSpecs/const.d.ts +2 -1
  44. package/build/cjs/extensions/markdown/Table/TableSpecs/const.js +1 -0
  45. package/build/cjs/extensions/markdown/Table/TableSpecs/const.js.map +1 -1
  46. package/build/cjs/extensions/markdown/Table/TableSpecs/parser.js +9 -1
  47. package/build/cjs/extensions/markdown/Table/TableSpecs/parser.js.map +1 -1
  48. package/build/cjs/extensions/markdown/Table/TableSpecs/schema.js +3 -2
  49. package/build/cjs/extensions/markdown/Table/TableSpecs/schema.js.map +1 -1
  50. package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/const.d.ts +1 -0
  51. package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/const.js +1 -0
  52. package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/const.js.map +1 -1
  53. package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/schema.js +30 -17
  54. package/build/cjs/extensions/yfm/Checkbox/CheckboxSpecs/schema.js.map +1 -1
  55. package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/const.d.ts +1 -0
  56. package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/const.js +1 -0
  57. package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/const.js.map +1 -1
  58. package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/parser.js +14 -1
  59. package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/parser.js.map +1 -1
  60. package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/schema.js +4 -1
  61. package/build/cjs/extensions/yfm/YfmCut/YfmCutSpecs/schema.js.map +1 -1
  62. package/build/cjs/extensions/yfm/YfmCut/const.d.ts +1 -1
  63. package/build/cjs/extensions/yfm/YfmCut/const.js +2 -1
  64. package/build/cjs/extensions/yfm/YfmCut/const.js.map +1 -1
  65. package/build/cjs/extensions/yfm/YfmCut/nodeviews/yfm-cut-title.js +10 -0
  66. package/build/cjs/extensions/yfm/YfmCut/nodeviews/yfm-cut-title.js.map +1 -1
  67. package/build/cjs/extensions/yfm/YfmNote/YfmNoteSpecs/const.d.ts +2 -1
  68. package/build/cjs/extensions/yfm/YfmNote/YfmNoteSpecs/const.js +1 -0
  69. package/build/cjs/extensions/yfm/YfmNote/YfmNoteSpecs/const.js.map +1 -1
  70. package/build/cjs/extensions/yfm/YfmNote/YfmNoteSpecs/parser.js +14 -1
  71. package/build/cjs/extensions/yfm/YfmNote/YfmNoteSpecs/parser.js.map +1 -1
  72. package/build/cjs/extensions/yfm/YfmNote/YfmNoteSpecs/schema.js +3 -2
  73. package/build/cjs/extensions/yfm/YfmNote/YfmNoteSpecs/schema.js.map +1 -1
  74. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.d.ts +2 -1
  75. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.js.map +1 -1
  76. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.d.ts +5 -2
  77. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.js +59 -2
  78. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.js.map +1 -1
  79. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.d.ts +4 -2
  80. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.js +3 -4
  81. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.js.map +1 -1
  82. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.d.ts +3 -1
  83. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.js +36 -1
  84. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.js.map +1 -1
  85. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.d.ts +13 -1
  86. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.js +7 -10
  87. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.js.map +1 -1
  88. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-drop-cursor.d.ts +3 -0
  89. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-drop-cursor.js +39 -1
  90. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-drop-cursor.js.map +1 -1
  91. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-ghost.js +9 -4
  92. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-ghost.js.map +1 -1
  93. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js +1 -1
  94. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js.map +1 -1
  95. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/hooks/use-raf-throttle.d.ts +1 -0
  96. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/hooks/use-raf-throttle.js +25 -0
  97. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/hooks/use-raf-throttle.js.map +1 -0
  98. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.js +4 -2
  99. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.js.map +1 -1
  100. package/build/cjs/i18n/codeblock/en.json +2 -1
  101. package/build/cjs/i18n/codeblock/index.d.ts +2 -1
  102. package/build/cjs/i18n/codeblock/ru.json +2 -1
  103. package/build/cjs/styles/styles.css +289 -0
  104. package/build/cjs/styles/yfm-themes.css +288 -0
  105. package/build/cjs/table-utils/table-desc.d.ts +1 -0
  106. package/build/cjs/table-utils/table-desc.js +3 -0
  107. package/build/cjs/table-utils/table-desc.js.map +1 -1
  108. package/build/cjs/utils/index.d.ts +1 -0
  109. package/build/cjs/utils/index.js +1 -0
  110. package/build/cjs/utils/index.js.map +1 -1
  111. package/build/cjs/utils/node-descedants.d.ts +10 -0
  112. package/build/cjs/utils/node-descedants.js +23 -0
  113. package/build/cjs/utils/node-descedants.js.map +1 -0
  114. package/build/cjs/version.js +1 -1
  115. package/build/cjs/version.js.map +1 -1
  116. package/build/cjs/view/hocs/withYfmHtml/index.d.ts +1 -0
  117. package/build/cjs/view/hocs/withYfmHtml/index.js +3 -0
  118. package/build/cjs/view/hocs/withYfmHtml/index.js.map +1 -1
  119. package/build/cjs/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.d.ts +5 -1
  120. package/build/cjs/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.js +8 -1
  121. package/build/cjs/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.js.map +1 -1
  122. package/build/esm/bundle/Editor.js +56 -23
  123. package/build/esm/bundle/Editor.js.map +1 -1
  124. package/build/esm/extensions/additional/Math/const.d.ts +1 -0
  125. package/build/esm/extensions/additional/Math/const.js +10 -0
  126. package/build/esm/extensions/additional/Math/const.js.map +1 -1
  127. package/build/esm/extensions/additional/Math/index.d.ts +1 -0
  128. package/build/esm/extensions/additional/Math/index.js +3 -0
  129. package/build/esm/extensions/additional/Math/index.js.map +1 -1
  130. package/build/esm/extensions/additional/Math/latex-paste-plugin.d.ts +2 -0
  131. package/build/esm/extensions/additional/Math/latex-paste-plugin.js +50 -0
  132. package/build/esm/extensions/additional/Math/latex-paste-plugin.js.map +1 -0
  133. package/build/esm/extensions/additional/Math/utils.d.ts +7 -0
  134. package/build/esm/extensions/additional/Math/utils.js +39 -0
  135. package/build/esm/extensions/additional/Math/utils.js.map +1 -0
  136. package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.css +8 -0
  137. package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.d.ts +3 -0
  138. package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.js +80 -12
  139. package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/CodeBlockHighlight.js.map +1 -1
  140. package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/TooltipPlugin/TooltipView.css +4 -0
  141. package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/TooltipPlugin/index.d.ts +1 -1
  142. package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/TooltipPlugin/index.js +54 -29
  143. package/build/esm/extensions/markdown/CodeBlock/CodeBlockHighlight/TooltipPlugin/index.js.map +1 -1
  144. package/build/esm/extensions/markdown/CodeBlock/CodeBlockSpecs/index.d.ts +7 -0
  145. package/build/esm/extensions/markdown/CodeBlock/CodeBlockSpecs/index.js +36 -2
  146. package/build/esm/extensions/markdown/CodeBlock/CodeBlockSpecs/index.js.map +1 -1
  147. package/build/esm/extensions/markdown/CodeBlock/index.d.ts +2 -1
  148. package/build/esm/extensions/markdown/CodeBlock/index.js +21 -6
  149. package/build/esm/extensions/markdown/CodeBlock/index.js.map +1 -1
  150. package/build/esm/extensions/markdown/Deflist/DeflistSpecs/const.d.ts +3 -0
  151. package/build/esm/extensions/markdown/Deflist/DeflistSpecs/const.js +3 -0
  152. package/build/esm/extensions/markdown/Deflist/DeflistSpecs/const.js.map +1 -1
  153. package/build/esm/extensions/markdown/Deflist/DeflistSpecs/parser.js +10 -2
  154. package/build/esm/extensions/markdown/Deflist/DeflistSpecs/parser.js.map +1 -1
  155. package/build/esm/extensions/markdown/Deflist/DeflistSpecs/schema.js +4 -3
  156. package/build/esm/extensions/markdown/Deflist/DeflistSpecs/schema.js.map +1 -1
  157. package/build/esm/extensions/markdown/Lists/ListsSpecs/const.d.ts +2 -1
  158. package/build/esm/extensions/markdown/Lists/ListsSpecs/const.js +1 -0
  159. package/build/esm/extensions/markdown/Lists/ListsSpecs/const.js.map +1 -1
  160. package/build/esm/extensions/markdown/Lists/ListsSpecs/parser.js +4 -1
  161. package/build/esm/extensions/markdown/Lists/ListsSpecs/parser.js.map +1 -1
  162. package/build/esm/extensions/markdown/Lists/ListsSpecs/schema.js +3 -2
  163. package/build/esm/extensions/markdown/Lists/ListsSpecs/schema.js.map +1 -1
  164. package/build/esm/extensions/markdown/Table/TableSpecs/const.d.ts +2 -1
  165. package/build/esm/extensions/markdown/Table/TableSpecs/const.js +1 -0
  166. package/build/esm/extensions/markdown/Table/TableSpecs/const.js.map +1 -1
  167. package/build/esm/extensions/markdown/Table/TableSpecs/parser.js +9 -1
  168. package/build/esm/extensions/markdown/Table/TableSpecs/parser.js.map +1 -1
  169. package/build/esm/extensions/markdown/Table/TableSpecs/schema.js +3 -2
  170. package/build/esm/extensions/markdown/Table/TableSpecs/schema.js.map +1 -1
  171. package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/const.d.ts +1 -0
  172. package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/const.js +1 -0
  173. package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/const.js.map +1 -1
  174. package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/schema.js +30 -17
  175. package/build/esm/extensions/yfm/Checkbox/CheckboxSpecs/schema.js.map +1 -1
  176. package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/const.d.ts +1 -0
  177. package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/const.js +1 -0
  178. package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/const.js.map +1 -1
  179. package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/parser.js +14 -1
  180. package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/parser.js.map +1 -1
  181. package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/schema.js +4 -1
  182. package/build/esm/extensions/yfm/YfmCut/YfmCutSpecs/schema.js.map +1 -1
  183. package/build/esm/extensions/yfm/YfmCut/const.d.ts +1 -1
  184. package/build/esm/extensions/yfm/YfmCut/const.js +1 -1
  185. package/build/esm/extensions/yfm/YfmCut/const.js.map +1 -1
  186. package/build/esm/extensions/yfm/YfmCut/nodeviews/yfm-cut-title.js +11 -1
  187. package/build/esm/extensions/yfm/YfmCut/nodeviews/yfm-cut-title.js.map +1 -1
  188. package/build/esm/extensions/yfm/YfmNote/YfmNoteSpecs/const.d.ts +2 -1
  189. package/build/esm/extensions/yfm/YfmNote/YfmNoteSpecs/const.js +1 -0
  190. package/build/esm/extensions/yfm/YfmNote/YfmNoteSpecs/const.js.map +1 -1
  191. package/build/esm/extensions/yfm/YfmNote/YfmNoteSpecs/parser.js +15 -2
  192. package/build/esm/extensions/yfm/YfmNote/YfmNoteSpecs/parser.js.map +1 -1
  193. package/build/esm/extensions/yfm/YfmNote/YfmNoteSpecs/schema.js +3 -2
  194. package/build/esm/extensions/yfm/YfmNote/YfmNoteSpecs/schema.js.map +1 -1
  195. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.d.ts +2 -1
  196. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.js.map +1 -1
  197. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.d.ts +5 -2
  198. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.js +59 -2
  199. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.js.map +1 -1
  200. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.d.ts +4 -2
  201. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.js +4 -4
  202. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.js.map +1 -1
  203. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.d.ts +3 -1
  204. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.js +38 -3
  205. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.js.map +1 -1
  206. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.d.ts +13 -1
  207. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.js +8 -10
  208. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPopup/FloatingPopup.js.map +1 -1
  209. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-drop-cursor.d.ts +3 -0
  210. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-drop-cursor.js +38 -1
  211. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-drop-cursor.js.map +1 -1
  212. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-ghost.js +9 -4
  213. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd-ghost.js.map +1 -1
  214. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js +2 -2
  215. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/dnd/dnd.js.map +1 -1
  216. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/hooks/use-raf-throttle.d.ts +1 -0
  217. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/hooks/use-raf-throttle.js +22 -0
  218. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/hooks/use-raf-throttle.js.map +1 -0
  219. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.js +4 -2
  220. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/nodeviews/yfm-table-cell-view.js.map +1 -1
  221. package/build/esm/i18n/codeblock/en.json +2 -1
  222. package/build/esm/i18n/codeblock/index.d.ts +2 -1
  223. package/build/esm/i18n/codeblock/ru.json +2 -1
  224. package/build/esm/styles/styles.css +289 -0
  225. package/build/esm/styles/yfm-themes.css +288 -0
  226. package/build/esm/table-utils/table-desc.d.ts +1 -0
  227. package/build/esm/table-utils/table-desc.js +3 -0
  228. package/build/esm/table-utils/table-desc.js.map +1 -1
  229. package/build/esm/utils/index.d.ts +1 -0
  230. package/build/esm/utils/index.js +1 -0
  231. package/build/esm/utils/index.js.map +1 -1
  232. package/build/esm/utils/node-descedants.d.ts +10 -0
  233. package/build/esm/utils/node-descedants.js +19 -0
  234. package/build/esm/utils/node-descedants.js.map +1 -0
  235. package/build/esm/version.js +1 -1
  236. package/build/esm/version.js.map +1 -1
  237. package/build/esm/view/hocs/withYfmHtml/index.d.ts +1 -0
  238. package/build/esm/view/hocs/withYfmHtml/index.js +1 -0
  239. package/build/esm/view/hocs/withYfmHtml/index.js.map +1 -1
  240. package/build/esm/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.d.ts +5 -1
  241. package/build/esm/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.js +7 -1
  242. package/build/esm/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.js.map +1 -1
  243. package/build/styles.css +589 -0
  244. package/package.json +10 -9
@@ -1,4 +1,4 @@
1
- export { CutNode, cutType, cutTitleType, cutContentType } from "./YfmCutSpecs/const.js";
1
+ export { CutNode, CutAttr, cutType, cutTitleType, cutContentType } from "./YfmCutSpecs/const.js";
2
2
  export declare const YfmCutClassName: {
3
3
  readonly TitleInner: "g-md-yfm-cut-title-inner";
4
4
  readonly Open: "yfm-cut-open";
@@ -1,5 +1,5 @@
1
1
  import { YfmCutClassName as YfmCutClassNameSpecs } from "./YfmCutSpecs/const.js";
2
- export { CutNode, cutType, cutTitleType, cutContentType } from "./YfmCutSpecs/const.js";
2
+ export { CutNode, CutAttr, cutType, cutTitleType, cutContentType } from "./YfmCutSpecs/const.js";
3
3
  export const YfmCutClassName = {
4
4
  ...YfmCutClassNameSpecs,
5
5
  TitleInner: 'g-md-yfm-cut-title-inner',
@@ -1 +1 @@
1
- {"version":3,"file":"const.js","sourceRoot":"../../../../../src","sources":["extensions/yfm/YfmCut/const.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,IAAI,oBAAoB,EAAC,+BAA4B;AAE5E,OAAO,EAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAC,+BAA4B;AAEnF,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,GAAG,oBAAoB;IACvB,UAAU,EAAE,0BAA0B;IACtC,IAAI,EAAE,cAAc;IACpB,MAAM,EAAE,gBAAgB;CAClB,CAAC","sourcesContent":["import {YfmCutClassName as YfmCutClassNameSpecs} from './YfmCutSpecs/const';\n\nexport {CutNode, cutType, cutTitleType, cutContentType} from './YfmCutSpecs/const';\n\nexport const YfmCutClassName = {\n ...YfmCutClassNameSpecs,\n TitleInner: 'g-md-yfm-cut-title-inner',\n Open: 'yfm-cut-open',\n Active: 'yfm-cut-active',\n} as const;\n"]}
1
+ {"version":3,"file":"const.js","sourceRoot":"../../../../../src","sources":["extensions/yfm/YfmCut/const.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,IAAI,oBAAoB,EAAC,+BAA4B;AAE5E,OAAO,EAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAC,+BAA4B;AAE5F,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,GAAG,oBAAoB;IACvB,UAAU,EAAE,0BAA0B;IACtC,IAAI,EAAE,cAAc;IACpB,MAAM,EAAE,gBAAgB;CAClB,CAAC","sourcesContent":["import {YfmCutClassName as YfmCutClassNameSpecs} from './YfmCutSpecs/const';\n\nexport {CutNode, CutAttr, cutType, cutTitleType, cutContentType} from './YfmCutSpecs/const';\n\nexport const YfmCutClassName = {\n ...YfmCutClassNameSpecs,\n TitleInner: 'g-md-yfm-cut-title-inner',\n Open: 'yfm-cut-open',\n Active: 'yfm-cut-active',\n} as const;\n"]}
@@ -1,4 +1,4 @@
1
- import { YfmCutClassName } from "../const.js";
1
+ import { CutAttr, YfmCutClassName } from "../const.js";
2
2
  import "./yfm-cut-title.css";
3
3
  export class YfmCutTitleNodeView {
4
4
  dom;
@@ -9,6 +9,7 @@ export class YfmCutTitleNodeView {
9
9
  this.dom = document.createElement('div');
10
10
  this.dom.classList.add(YfmCutClassName.Title);
11
11
  this.dom.addEventListener('click', this._onTitleClick);
12
+ updateDomAttribute(this.dom, CutAttr.Line, node.attrs[CutAttr.Line]);
12
13
  this.contentDOM = this.dom.appendChild(document.createElement('div'));
13
14
  this.contentDOM.classList.add(YfmCutClassName.TitleInner);
14
15
  this.contentDOM.addEventListener('click', this._onTitleInnerClick);
@@ -17,6 +18,7 @@ export class YfmCutTitleNodeView {
17
18
  if (this.node.type !== node.type)
18
19
  return false;
19
20
  this.node = node;
21
+ updateDomAttribute(this.dom, CutAttr.Line, node.attrs[CutAttr.Line]);
20
22
  return true;
21
23
  }
22
24
  destroy() {
@@ -40,4 +42,12 @@ export class YfmCutTitleNodeView {
40
42
  e.preventDefault();
41
43
  };
42
44
  }
45
+ function updateDomAttribute(elem, attr, value) {
46
+ if (value) {
47
+ elem.setAttribute(attr, value);
48
+ }
49
+ else {
50
+ elem.removeAttribute(attr);
51
+ }
52
+ }
43
53
  //# sourceMappingURL=yfm-cut-title.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"yfm-cut-title.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmCut/nodeviews/yfm-cut-title.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,eAAe,EAAC,oBAAiB;AAEzC,6BAA8B;AAE9B,MAAM,OAAO,mBAAmB;IACnB,GAAG,CAAc;IACjB,UAAU,CAAc;IAEzB,IAAI,CAAO;IAEnB,YAAY,IAAU;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QA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AM,CAAC,SAAS,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;YAClD,CAAC;QACL,CAAC;IACL,CAAC,CAAC;IAEM,kBAAkB,GAAG,CAAC,CAAa,EAAE,EAAE;QAC3C,uCAAuC;QACvC,2DAA2D;QAC3D,CAAC,CAAC,eAAe,EAAE,CAAC;QACpB,CAAC,CAAC,cAAc,EAAE,CAAC;IACvB,CAAC,CAAC;CACL","sourcesContent":["import type {Node} from '#pm/model';\nimport type {NodeView} from '#pm/view';\n\nimport {YfmCutClassName} from '../const';\n\nimport './yfm-cut-title.scss';\n\nexport class YfmCutTitleNodeView implements NodeView {\n readonly dom: HTMLElement;\n readonly contentDOM: HTMLElement;\n\n private node: Node;\n\n constructor(node: Node) {\n this.node = node;\n\n this.dom = document.createElement('div');\n this.dom.classList.add(YfmCutClassName.Title);\n this.dom.addEventListener('click', this._onTitleClick);\n\n this.contentDOM = this.dom.appendChild(document.createElement('div'));\n this.contentDOM.classList.add(YfmCutClassName.TitleInner);\n this.contentDOM.addEventListener('click', this._onTitleInnerClick);\n }\n\n update(node: Node): boolean {\n if (this.node.type !== node.type) return false;\n this.node = node;\n return true;\n }\n\n destroy() {\n this.dom.removeEventListener('click', this._onTitleClick);\n this.contentDOM.removeEventListener('click', this._onTitleInnerClick);\n }\n\n private _onTitleClick = (e: MouseEvent) => {\n const {currentTarget} = e;\n if (currentTarget instanceof HTMLElement) {\n const parent = currentTarget.parentElement;\n if (parent?.classList.contains(YfmCutClassName.Cut)) {\n // TODO: toggle open classname via prosemirror decoration\n parent.classList.toggle(YfmCutClassName.Open);\n }\n }\n };\n\n private _onTitleInnerClick = (e: MouseEvent) => {\n // ignore clicking on the title content\n // you can open/close yfm-cut by clicking on the arrow icon\n e.stopPropagation();\n e.preventDefault();\n };\n}\n"]}
1
+ {"version":3,"file":"yfm-cut-title.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmCut/nodeviews/yfm-cut-title.ts"],"names":[],"mappings":"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C,GAAG,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAC1D,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAC1E,CAAC;IAEO,aAAa,GAAG,CAAC,CAAa,EAAE,EAAE;QACtC,MAAM,EAAC,aAAa,EAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,aAAa,YAAY,WAAW,EAAE,CAAC;YACvC,MAAM,MAAM,GAAG,aAAa,CAAC,aAAa,CAAC;YAC3C,IAAI,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;gBAClD,yDAAyD;gBACzD,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;YAClD,CAAC;QACL,CAAC;IACL,CAAC,CAAC;IAEM,kBAAkB,GAAG,CAAC,CAAa,EAAE,EAAE;QAC3C,uCAAuC;QACvC,2DAA2D;QAC3D,CAAC,CAAC,eAAe,EAAE,CAAC;QACpB,CAAC,CAAC,cAAc,EAAE,CAAC;IACvB,CAAC,CAAC;CACL;AAED,SAAS,kBAAkB,CAAC,IAAa,EAAE,IAAY,EAAE,KAAgC;IACrF,IAAI,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;SAAM,CAAC;QACJ,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;AACL,CAAC","sourcesContent":["import type {Node} from '#pm/model';\nimport type {NodeView} from '#pm/view';\n\nimport {CutAttr, YfmCutClassName} from '../const';\n\nimport './yfm-cut-title.scss';\n\nexport class YfmCutTitleNodeView implements NodeView {\n readonly dom: HTMLElement;\n readonly contentDOM: HTMLElement;\n\n private node: Node;\n\n constructor(node: Node) {\n this.node = node;\n\n this.dom = document.createElement('div');\n this.dom.classList.add(YfmCutClassName.Title);\n this.dom.addEventListener('click', this._onTitleClick);\n updateDomAttribute(this.dom, CutAttr.Line, node.attrs[CutAttr.Line]);\n\n this.contentDOM = this.dom.appendChild(document.createElement('div'));\n this.contentDOM.classList.add(YfmCutClassName.TitleInner);\n this.contentDOM.addEventListener('click', this._onTitleInnerClick);\n }\n\n update(node: Node): boolean {\n if (this.node.type !== node.type) return false;\n this.node = node;\n updateDomAttribute(this.dom, CutAttr.Line, node.attrs[CutAttr.Line]);\n return true;\n }\n\n destroy() {\n this.dom.removeEventListener('click', this._onTitleClick);\n this.contentDOM.removeEventListener('click', this._onTitleInnerClick);\n }\n\n private _onTitleClick = (e: MouseEvent) => {\n const {currentTarget} = e;\n if (currentTarget instanceof HTMLElement) {\n const parent = currentTarget.parentElement;\n if (parent?.classList.contains(YfmCutClassName.Cut)) {\n // TODO: toggle open classname via prosemirror decoration\n parent.classList.toggle(YfmCutClassName.Open);\n }\n }\n };\n\n private _onTitleInnerClick = (e: MouseEvent) => {\n // ignore clicking on the title content\n // you can open/close yfm-cut by clicking on the arrow icon\n e.stopPropagation();\n e.preventDefault();\n };\n}\n\nfunction updateDomAttribute(elem: Element, attr: string, value: string | null | undefined) {\n if (value) {\n elem.setAttribute(attr, value);\n } else {\n elem.removeAttribute(attr);\n }\n}\n"]}
@@ -5,5 +5,6 @@ export declare enum NoteNode {
5
5
  }
6
6
  export declare enum NoteAttrs {
7
7
  Class = "class",
8
- Type = "note-type"
8
+ Type = "note-type",
9
+ Line = "data-line"
9
10
  }
@@ -8,5 +8,6 @@ export var NoteAttrs;
8
8
  (function (NoteAttrs) {
9
9
  NoteAttrs["Class"] = "class";
10
10
  NoteAttrs["Type"] = "note-type";
11
+ NoteAttrs["Line"] = "data-line";
11
12
  })(NoteAttrs || (NoteAttrs = {}));
12
13
  //# sourceMappingURL=const.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"const.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmNote/YfmNoteSpecs/const.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,QAIX;AAJD,WAAY,QAAQ;IAChB,6BAAiB,CAAA;IACjB,wCAA4B,CAAA;IAC5B,4CAAgC,CAAA;AACpC,CAAC,EAJW,QAAQ,KAAR,QAAQ,QAInB;AAED,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACjB,4BAAe,CAAA;IACf,+BAAkB,CAAA;AACtB,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB","sourcesContent":["export enum NoteNode {\n Note = 'yfm_note',\n NoteTitle = 'yfm_note_title',\n NoteContent = 'yfm_note_content',\n}\n\nexport enum NoteAttrs {\n Class = 'class',\n Type = 'note-type',\n}\n"]}
1
+ {"version":3,"file":"const.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmNote/YfmNoteSpecs/const.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,QAIX;AAJD,WAAY,QAAQ;IAChB,6BAAiB,CAAA;IACjB,wCAA4B,CAAA;IAC5B,4CAAgC,CAAA;AACpC,CAAC,EAJW,QAAQ,KAAR,QAAQ,QAInB;AAED,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACjB,4BAAe,CAAA;IACf,+BAAkB,CAAA;IAClB,+BAAkB,CAAA;AACtB,CAAC,EAJW,SAAS,KAAT,SAAS,QAIpB","sourcesContent":["export enum NoteNode {\n Note = 'yfm_note',\n NoteTitle = 'yfm_note_title',\n NoteContent = 'yfm_note_content',\n}\n\nexport enum NoteAttrs {\n Class = 'class',\n Type = 'note-type',\n Line = 'data-line',\n}\n"]}
@@ -1,11 +1,24 @@
1
- import { NoteNode } from "./const.js";
1
+ import { NoteAttrs, NoteNode } from "./const.js";
2
2
  export const parserTokens = {
3
3
  [NoteNode.Note]: {
4
4
  name: NoteNode.Note,
5
5
  type: 'block',
6
6
  getAttrs: (token) => (token.attrs ? Object.fromEntries(token.attrs) : {}),
7
7
  },
8
- [NoteNode.NoteTitle]: { name: NoteNode.NoteTitle, type: 'block' },
8
+ [NoteNode.NoteTitle]: {
9
+ name: NoteNode.NoteTitle,
10
+ type: 'block',
11
+ getAttrs: (token, tokens, index) => {
12
+ let dataLine = token.attrGet('data-line');
13
+ if (!dataLine) {
14
+ const prevToken = tokens[index - 1];
15
+ if (prevToken?.type === 'yfm_note_open') {
16
+ dataLine = prevToken.attrGet('data-line');
17
+ }
18
+ }
19
+ return { [NoteAttrs.Line]: dataLine };
20
+ },
21
+ },
9
22
  [NoteNode.NoteContent]: { name: NoteNode.NoteContent, type: 'block' },
10
23
  };
11
24
  //# sourceMappingURL=parser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parser.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmNote/YfmNoteSpecs/parser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,EAAC,mBAAgB;AAEjC,MAAM,CAAC,MAAM,YAAY,GAAkC;IACvD,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;QACb,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5E;IACD,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,EAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,EAAC;IAC/D,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,EAAC,IAAI,EAAE,QAAQ,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,EAAC;CACtE,CAAC","sourcesContent":["import type {ParserToken} from '../../../../core';\n\nimport {NoteNode} from './const';\n\nexport const parserTokens: Record<NoteNode, ParserToken> = {\n [NoteNode.Note]: {\n name: NoteNode.Note,\n type: 'block',\n getAttrs: (token) => (token.attrs ? Object.fromEntries(token.attrs) : {}),\n },\n [NoteNode.NoteTitle]: {name: NoteNode.NoteTitle, type: 'block'},\n [NoteNode.NoteContent]: {name: NoteNode.NoteContent, type: 'block'},\n};\n"]}
1
+ {"version":3,"file":"parser.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmNote/YfmNoteSpecs/parser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,mBAAgB;AAE5C,MAAM,CAAC,MAAM,YAAY,GAAkC;IACvD,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;QACb,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5E;IACD,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QAClB,IAAI,EAAE,QAAQ,CAAC,SAAS;QACxB,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE;YAC/B,IAAI,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAC1C,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACZ,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;gBACpC,IAAI,SAAS,EAAE,IAAI,KAAK,eAAe,EAAE,CAAC;oBACtC,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;gBAC9C,CAAC;YACL,CAAC;YACD,OAAO,EAAC,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAC,CAAC;QACxC,CAAC;KACJ;IACD,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,EAAC,IAAI,EAAE,QAAQ,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,EAAC;CACtE,CAAC","sourcesContent":["import type {ParserToken} from '../../../../core';\n\nimport {NoteAttrs, NoteNode} from './const';\n\nexport const parserTokens: Record<NoteNode, ParserToken> = {\n [NoteNode.Note]: {\n name: NoteNode.Note,\n type: 'block',\n getAttrs: (token) => (token.attrs ? Object.fromEntries(token.attrs) : {}),\n },\n [NoteNode.NoteTitle]: {\n name: NoteNode.NoteTitle,\n type: 'block',\n getAttrs: (token, tokens, index) => {\n let dataLine = token.attrGet('data-line');\n if (!dataLine) {\n const prevToken = tokens[index - 1];\n if (prevToken?.type === 'yfm_note_open') {\n dataLine = prevToken.attrGet('data-line');\n }\n }\n return {[NoteAttrs.Line]: dataLine};\n },\n },\n [NoteNode.NoteContent]: {name: NoteNode.NoteContent, type: 'block'},\n};\n"]}
@@ -27,6 +27,7 @@ export const getSchemaSpecs = (opts, placeholder) => ({
27
27
  complex: 'root',
28
28
  },
29
29
  [NoteNode.NoteTitle]: {
30
+ attrs: { [NoteAttrs.Line]: { default: null } },
30
31
  content: 'inline*',
31
32
  group: 'block yfm-note',
32
33
  parseDOM: [
@@ -35,8 +36,8 @@ export const getSchemaSpecs = (opts, placeholder) => ({
35
36
  priority: 100,
36
37
  },
37
38
  ],
38
- toDOM() {
39
- return ['p', { class: 'yfm-note-title' }, 0];
39
+ toDOM(node) {
40
+ return ['p', { class: 'yfm-note-title', ...node.attrs }, 0];
40
41
  },
41
42
  selectable: false,
42
43
  allowSelection: false,
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmNote/YfmNoteSpecs/schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,mBAAgB;AAI5C,MAAM,yBAAyB,GAAG,MAAM,CAAC;AACzC,MAAM,2BAA2B,GAAG,cAAc,CAAC;AAEnD,MAAM,CAAC,MAAM,cAA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K;QACjB,cAAc,EAAE,KAAK;QACrB,WAAW,EAAE;YACT,OAAO,EACH,WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC;gBACjC,IAAI,EAAE,uBAAuB;gBAC7B,yBAAyB;YAC7B,aAAa,EAAE,IAAI;SACtB;QACD,OAAO,EAAE,MAAM;KAClB;IACD,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QACpB,OAAO,EAAE,sBAAsB;QAC/B,KAAK,EAAE,gBAAgB;QACvB,QAAQ,EAAE;YACN;gBACI,GAAG,EAAE,sBAAsB;gBAC3B,QAAQ,EAAE,GAAG;aAChB;SACJ;QACD,KAAK;YACD,OAAO,CAAC,KAAK,EAAE,EAAC,KAAK,EAAE,kBAAkB,EAAC,EAAE,CAAC,CAAC,CAAC;QACnD,CAAC;QACD,UAAU,EAAE,KAAK;QACjB,cAAc,EAAE,KAAK;QACrB,WAAW,EAAE;YACT,OAAO,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,2BAA2B;YAC3E,aAAa,EAAE,IAAI;SACtB;QACD,OAAO,EAAE,MAAM;KAClB;CACJ,CAAC,CAAC","sourcesContent":["import type {NodeSpec} from 'prosemirror-model';\n\nimport type {PlaceholderOptions} from '../../../../utils/placeholder';\n\nimport {NoteAttrs, NoteNode} from './const';\n\nimport type {YfmNoteSpecsOptions} from './index';\n\nconst DEFAULT_TITLE_PLACEHOLDER = 'Note';\nconst DEFAULT_CONTENT_PLACEHOLDER = 'Note content';\n\nexport const getSchemaSpecs = (\n opts?: YfmNoteSpecsOptions,\n placeholder?: PlaceholderOptions,\n): Record<NoteNode, NodeSpec> => ({\n [NoteNode.Note]: {\n attrs: {\n [NoteAttrs.Class]: {default: 'yfm-note yfm-accent-info'},\n [NoteAttrs.Type]: {default: 'info'},\n },\n content: `${NoteNode.NoteTitle} ${NoteNode.NoteContent}`,\n group: 'block yfm-note',\n parseDOM: [\n {\n tag: 'div.yfm-note',\n priority: 100,\n getAttrs: (node) => ({\n [NoteAttrs.Class]: (node as Element).getAttribute(NoteAttrs.Class) || '',\n [NoteAttrs.Type]: (node as Element).getAttribute(NoteAttrs.Type) || 'info',\n }),\n },\n ],\n toDOM(node) {\n return ['div', node.attrs, 0];\n },\n selectable: true,\n allowSelection: true,\n complex: 'root',\n },\n\n [NoteNode.NoteTitle]: {\n content: 'inline*',\n group: 'block yfm-note',\n parseDOM: [\n {\n tag: 'p.yfm-note-title',\n priority: 100,\n },\n ],\n toDOM() {\n return ['p', {class: 'yfm-note-title'}, 0];\n },\n selectable: false,\n allowSelection: false,\n placeholder: {\n content:\n placeholder?.[NoteNode.NoteTitle] ??\n opts?.yfmNoteTitlePlaceholder ??\n DEFAULT_TITLE_PLACEHOLDER,\n alwaysVisible: true,\n },\n complex: 'leaf',\n },\n [NoteNode.NoteContent]: {\n content: '(block | paragraph)+',\n group: 'block yfm-note',\n parseDOM: [\n {\n tag: 'div.yfm-note-content',\n priority: 100,\n },\n ],\n toDOM() {\n return ['div', {class: 'yfm-note-content'}, 0];\n },\n selectable: false,\n allowSelection: false,\n placeholder: {\n content: placeholder?.[NoteNode.NoteContent] ?? DEFAULT_CONTENT_PLACEHOLDER,\n alwaysVisible: true,\n },\n complex: 'leaf',\n },\n});\n"]}
1
+ {"version":3,"file":"schema.js","sourceRoot":"../../../../../../src","sources":["extensions/yfm/YfmNote/YfmNoteSpecs/schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,mBAAgB;AAI5C,MAAM,yBAAyB,GAAG,MAAM,CAAC;AACzC,MAAM,2BAA2B,GAAG,cAAc,CAAC;AAEnD,MAAM,CAAC,MAAM,cAAc,GAAG,CAC1B,IAA0B,EAC1B,WAAgC,EACN,EAAE,CAAC,CAAC;IAC9B,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;QACb,KAAK,EAAE;YACH,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAC,OAAO,EAAE,0BAA0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T,OAAO,EACH,WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC;gBACjC,IAAI,EAAE,uBAAuB;gBAC7B,yBAAyB;YAC7B,aAAa,EAAE,IAAI;SACtB;QACD,OAAO,EAAE,MAAM;KAClB;IACD,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QACpB,OAAO,EAAE,sBAAsB;QAC/B,KAAK,EAAE,gBAAgB;QACvB,QAAQ,EAAE;YACN;gBACI,GAAG,EAAE,sBAAsB;gBAC3B,QAAQ,EAAE,GAAG;aAChB;SACJ;QACD,KAAK;YACD,OAAO,CAAC,KAAK,EAAE,EAAC,KAAK,EAAE,kBAAkB,EAAC,EAAE,CAAC,CAAC,CAAC;QACnD,CAAC;QACD,UAAU,EAAE,KAAK;QACjB,cAAc,EAAE,KAAK;QACrB,WAAW,EAAE;YACT,OAAO,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,2BAA2B;YAC3E,aAAa,EAAE,IAAI;SACtB;QACD,OAAO,EAAE,MAAM;KAClB;CACJ,CAAC,CAAC","sourcesContent":["import type {NodeSpec} from 'prosemirror-model';\n\nimport type {PlaceholderOptions} from '../../../../utils/placeholder';\n\nimport {NoteAttrs, NoteNode} from './const';\n\nimport type {YfmNoteSpecsOptions} from './index';\n\nconst DEFAULT_TITLE_PLACEHOLDER = 'Note';\nconst DEFAULT_CONTENT_PLACEHOLDER = 'Note content';\n\nexport const getSchemaSpecs = (\n opts?: YfmNoteSpecsOptions,\n placeholder?: PlaceholderOptions,\n): Record<NoteNode, NodeSpec> => ({\n [NoteNode.Note]: {\n attrs: {\n [NoteAttrs.Class]: {default: 'yfm-note yfm-accent-info'},\n [NoteAttrs.Type]: {default: 'info'},\n },\n content: `${NoteNode.NoteTitle} ${NoteNode.NoteContent}`,\n group: 'block yfm-note',\n parseDOM: [\n {\n tag: 'div.yfm-note',\n priority: 100,\n getAttrs: (node) => ({\n [NoteAttrs.Class]: (node as Element).getAttribute(NoteAttrs.Class) || '',\n [NoteAttrs.Type]: (node as Element).getAttribute(NoteAttrs.Type) || 'info',\n }),\n },\n ],\n toDOM(node) {\n return ['div', node.attrs, 0];\n },\n selectable: true,\n allowSelection: true,\n complex: 'root',\n },\n\n [NoteNode.NoteTitle]: {\n attrs: {[NoteAttrs.Line]: {default: null}},\n content: 'inline*',\n group: 'block yfm-note',\n parseDOM: [\n {\n tag: 'p.yfm-note-title',\n priority: 100,\n },\n ],\n toDOM(node) {\n return ['p', {class: 'yfm-note-title', ...node.attrs}, 0];\n },\n selectable: false,\n allowSelection: false,\n placeholder: {\n content:\n placeholder?.[NoteNode.NoteTitle] ??\n opts?.yfmNoteTitlePlaceholder ??\n DEFAULT_TITLE_PLACEHOLDER,\n alwaysVisible: true,\n },\n complex: 'leaf',\n },\n [NoteNode.NoteContent]: {\n content: '(block | paragraph)+',\n group: 'block yfm-note',\n parseDOM: [\n {\n tag: 'div.yfm-note-content',\n priority: 100,\n },\n ],\n toDOM() {\n return ['div', {class: 'yfm-note-content'}, 0];\n },\n selectable: false,\n allowSelection: false,\n placeholder: {\n content: placeholder?.[NoteNode.NoteContent] ?? DEFAULT_CONTENT_PLACEHOLDER,\n alwaysVisible: true,\n },\n complex: 'leaf',\n },\n});\n"]}
@@ -1,8 +1,9 @@
1
1
  import { type ButtonButtonProps, type DropdownMenuProps } from '@gravity-ui/uikit';
2
+ import { type ReferenceType } from "../FloatingPopup/index.js";
2
3
  export type FloatingMenuProps = {
3
4
  dirtype: 'row' | 'column';
4
5
  canDrag: boolean;
5
- anchorElement: Element;
6
+ anchorElement: ReferenceType;
6
7
  dropdownItems: DropdownMenuProps<unknown>['items'];
7
8
  switcherMouseProps?: Pick<ButtonButtonProps, 'onMouseDown' | 'onMouseMove' | 'onMouseUp' | 'onMouseLeave'>;
8
9
  onOpenToggle: NonNullable<DropdownMenuProps<unknown>['onOpenToggle']>;
@@ -1 +1 @@
1
- {"version":3,"file":"FloatingMenu.js","sourceRoot":"../../../../../../../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,EAAE;gBACR,MAAM,EAAE,IAAI;gBACZ,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc;aACxD,EACD,SAAS,EAAE,EAAC,EAAE,EAAE,kBAAkB,OAAO,OAAO,EAAC,EACjD,KAAK,EAAE,aAAa,GACtB,GACU,CACnB,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {useState} from 'react';\n\nimport {Ellipsis as DotsColumn, GripHorizontal as GripColumn} from '@gravity-ui/icons';\nimport {\n Button,\n type ButtonButtonProps,\n DropdownMenu,\n type DropdownMenuProps,\n Flex,\n Icon,\n} from '@gravity-ui/uikit';\n\nimport {useBooleanState} from 'src/react-utils';\n\nimport {FloatingPopup, type FloatingPopupProps} from '../FloatingPopup';\n\nconst popupOffset: FloatingPopupProps['offset'] = {\n mainAxis: -9.5,\n};\n\nexport type FloatingMenuProps = {\n dirtype: 'row' | 'column';\n canDrag: boolean;\n anchorElement: Element;\n dropdownItems: DropdownMenuProps<unknown>['items'];\n switcherMouseProps?: Pick<\n ButtonButtonProps,\n 'onMouseDown' | 'onMouseMove' | 'onMouseUp' | 'onMouseLeave'\n >;\n onOpenToggle: NonNullable<DropdownMenuProps<unknown>['onOpenToggle']>;\n};\n\nexport const FloatingMenu: React.FC<FloatingMenuProps> = function YfmTableFloatingMenu(props) {\n const {dirtype, canDrag, anchorElement, dropdownItems, switcherMouseProps, onOpenToggle} =\n props;\n\n const [isMenuOpened, setMenuOpened] = useState(false);\n const [isHovered, setHovered, unsetHovered] = useBooleanState(false);\n\n const showActionView = isMenuOpened || isHovered;\n const isRowType = dirtype === 'row';\n\n return (\n <FloatingPopup\n open\n offset={popupOffset}\n anchorElement={anchorElement}\n placement={isRowType ? 'left' : 'top'}\n floatingStyles={{\n lineHeight: 'initial',\n }}\n style={{\n backgroundColor: 'transparent',\n }}\n >\n <DropdownMenu\n onOpenToggle={(...args) => {\n setMenuOpened(...args);\n onOpenToggle(...args);\n }}\n renderSwitcher={(switcherProps) => (\n <Flex\n centerContent\n width={20} // xs button\n height={20} // xs button\n style={{\n borderRadius: 'var(--g-border-radius-xs)',\n backgroundColor: showActionView\n ? 'var(--g-color-base-background)'\n : undefined,\n }}\n onMouseEnter={setHovered}\n onMouseLeave={unsetHovered}\n >\n <Button\n style={{\n cursor: canDrag ? 'grab' : undefined,\n transform: isRowType ? 'rotate(90deg)' : undefined,\n '--g-button-height': showActionView ? undefined : '5px',\n '--_--background-color': showActionView\n ? undefined\n : 'var(--g-color-base-background)',\n }}\n view={isMenuOpened ? 'outlined-action' : 'outlined'}\n pin={showActionView ? 'round-round' : 'circle-circle'}\n size=\"xs\"\n qa={isRowType ? 'g-md-yfm-table-row-btn' : 'g-md-yfm-table-column-btn'}\n {...switcherProps}\n {...switcherMouseProps}\n >\n {showActionView ? (\n <Icon data={canDrag ? GripColumn : DotsColumn} />\n ) : (\n String.fromCharCode(8194) // en space\n )}\n </Button>\n </Flex>\n )}\n popupProps={{\n zIndex: 1010,\n placement: isRowType ? 'right-start' : 'bottom-start',\n }}\n menuProps={{qa: `g-md-yfm-table-${dirtype}-menu`}}\n items={dropdownItems}\n />\n </FloatingPopup>\n );\n};\n"]}
1
+ {"version":3,"file":"FloatingMenu.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenu/FloatingMenu.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,QAAQ,IAAI,UAAU,EAAE,cAAc,IAAI,UAAU,EAAC,MAAM,mBAAmB,CAAC;AACvF,OAAO,EACH,MAAM,EAEN,YAAY,EAEZ,IAAI,EACJ,IAAI,GACP,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAC,eAAe,EAAC,kDAAwB;AAEhD,OAAO,EAAC,aAAa,EAA8C,kCAAyB;AAE5F,MAAM,WAAW,GAAiC;IAC9C,QAAQ,EAAE,CAAC,GAAG;CAC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AC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;wBACpC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS;wBAClD,mBAAmB,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK;wBACvD,uBAAuB,EAAE,cAAc;4BACnC,CAAC,CAAC,SAAS;4BACX,CAAC,CAAC,gCAAgC;qBACzC,EACD,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,UAAU,EACnD,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,eAAe,EACrD,IAAI,EAAC,IAAI,EACT,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,2BAA2B,KAClE,aAAa,KACb,kBAAkB,YAErB,cAAc,CAAC,CAAC,CAAC,CACd,KAAC,IAAI,IAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,GAAI,CACpD,CAAC,CAAC,CAAC,CACA,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,WAAW;qBACxC,GACI,GACN,CACV,EACD,UAAU,EAAE;gBACR,MAAM,EAAE,IAAI;gBACZ,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc;aACxD,EACD,SAAS,EAAE,EAAC,EAAE,EAAE,kBAAkB,OAAO,OAAO,EAAC,EACjD,KAAK,EAAE,aAAa,GACtB,GACU,CACnB,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {useState} from 'react';\n\nimport {Ellipsis as DotsColumn, GripHorizontal as GripColumn} from '@gravity-ui/icons';\nimport {\n Button,\n type ButtonButtonProps,\n DropdownMenu,\n type DropdownMenuProps,\n Flex,\n Icon,\n} from '@gravity-ui/uikit';\n\nimport {useBooleanState} from 'src/react-utils';\n\nimport {FloatingPopup, type FloatingPopupProps, type ReferenceType} from '../FloatingPopup';\n\nconst popupOffset: FloatingPopupProps['offset'] = {\n mainAxis: -9.5,\n};\n\nexport type FloatingMenuProps = {\n dirtype: 'row' | 'column';\n canDrag: boolean;\n anchorElement: ReferenceType;\n dropdownItems: DropdownMenuProps<unknown>['items'];\n switcherMouseProps?: Pick<\n ButtonButtonProps,\n 'onMouseDown' | 'onMouseMove' | 'onMouseUp' | 'onMouseLeave'\n >;\n onOpenToggle: NonNullable<DropdownMenuProps<unknown>['onOpenToggle']>;\n};\n\nexport const FloatingMenu: React.FC<FloatingMenuProps> = function YfmTableFloatingMenu(props) {\n const {dirtype, canDrag, anchorElement, dropdownItems, switcherMouseProps, onOpenToggle} =\n props;\n\n const [isMenuOpened, setMenuOpened] = useState(false);\n const [isHovered, setHovered, unsetHovered] = useBooleanState(false);\n\n const showActionView = isMenuOpened || isHovered;\n const isRowType = dirtype === 'row';\n\n return (\n <FloatingPopup\n open\n offset={popupOffset}\n anchorElement={anchorElement}\n placement={isRowType ? 'left' : 'top'}\n floatingStyles={{\n lineHeight: 'initial',\n }}\n style={{\n backgroundColor: 'transparent',\n }}\n >\n <DropdownMenu\n onOpenToggle={(...args) => {\n setMenuOpened(...args);\n onOpenToggle(...args);\n }}\n renderSwitcher={(switcherProps) => (\n <Flex\n centerContent\n width={20} // xs button\n height={20} // xs button\n style={{\n borderRadius: 'var(--g-border-radius-xs)',\n backgroundColor: showActionView\n ? 'var(--g-color-base-background)'\n : undefined,\n }}\n onMouseEnter={setHovered}\n onMouseLeave={unsetHovered}\n >\n <Button\n style={{\n cursor: canDrag ? 'grab' : undefined,\n transform: isRowType ? 'rotate(90deg)' : undefined,\n '--g-button-height': showActionView ? undefined : '5px',\n '--_--background-color': showActionView\n ? undefined\n : 'var(--g-color-base-background)',\n }}\n view={isMenuOpened ? 'outlined-action' : 'outlined'}\n pin={showActionView ? 'round-round' : 'circle-circle'}\n size=\"xs\"\n qa={isRowType ? 'g-md-yfm-table-row-btn' : 'g-md-yfm-table-column-btn'}\n {...switcherProps}\n {...switcherMouseProps}\n >\n {showActionView ? (\n <Icon data={canDrag ? GripColumn : DotsColumn} />\n ) : (\n String.fromCharCode(8194) // en space\n )}\n </Button>\n </Flex>\n )}\n popupProps={{\n zIndex: 1010,\n placement: isRowType ? 'right-start' : 'bottom-start',\n }}\n menuProps={{qa: `g-md-yfm-table-${dirtype}-menu`}}\n items={dropdownItems}\n />\n </FloatingPopup>\n );\n};\n"]}
@@ -1,9 +1,11 @@
1
1
  import type { DnDControlHandler } from "../../dnd/dnd.js";
2
2
  import { type FloatingMenuProps } from "../FloatingMenu/FloatingMenu.js";
3
+ type ControlType = FloatingMenuProps['dirtype'];
3
4
  export type FloatingMenuControlProps = {
4
- acnhorElement: Element;
5
+ cellElement: Element;
6
+ tableElement: Element;
5
7
  multiple: boolean;
6
- type: FloatingMenuProps['dirtype'];
8
+ type: ControlType;
7
9
  dndHandler?: DnDControlHandler;
8
10
  onMenuOpenToggle: FloatingMenuProps['onOpenToggle'];
9
11
  onClearCellsClick: () => void;
@@ -13,3 +15,4 @@ export type FloatingMenuControlProps = {
13
15
  onRemoveTableClick: () => void;
14
16
  };
15
17
  export declare const FloatingMenuControl: React.FC<FloatingMenuControlProps>;
18
+ export {};
@@ -4,7 +4,7 @@ import { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, BroomMotion as ClearCells, T
4
4
  import { Icon } from '@gravity-ui/uikit';
5
5
  import { i18n } from "../../../../../../../i18n/yfm-table/index.js";
6
6
  import { FloatingMenu } from "../FloatingMenu/FloatingMenu.js";
7
- export const FloatingMenuControl = function YfmTableFloatingMenuControl({ type, multiple, dndHandler, acnhorElement, onMenuOpenToggle, onClearCellsClick, onInsertBeforeClick, onInsertAfterClick, onRemoveRangeClick, onRemoveTableClick, }) {
7
+ export const FloatingMenuControl = function YfmTableFloatingMenuControl({ type, multiple, dndHandler, cellElement, tableElement, onMenuOpenToggle, onClearCellsClick, onInsertBeforeClick, onInsertAfterClick, onRemoveRangeClick, onRemoveTableClick, }) {
8
8
  const dropdownItems = useMemo(() => [
9
9
  [
10
10
  {
@@ -52,7 +52,8 @@ export const FloatingMenuControl = function YfmTableFloatingMenuControl({ type,
52
52
  onRemoveRangeClick,
53
53
  onRemoveTableClick,
54
54
  ]);
55
- return (_jsx(FloatingMenu, { dirtype: type, canDrag: dndHandler ? dndHandler.canDrag() : false, onOpenToggle: onMenuOpenToggle, anchorElement: acnhorElement, switcherMouseProps: dndHandler
55
+ const anchor = useMemo(() => getVirtualAnchor(type, tableElement, cellElement), [type, tableElement, cellElement]);
56
+ return (_jsx(FloatingMenu, { dirtype: type, canDrag: dndHandler ? dndHandler.canDrag() : false, onOpenToggle: onMenuOpenToggle, anchorElement: anchor, switcherMouseProps: dndHandler
56
57
  ? {
57
58
  onMouseLeave: dndHandler.control_handleMouseLeave,
58
59
  onMouseDown: dndHandler.control_handleMouseDown,
@@ -61,4 +62,60 @@ export const FloatingMenuControl = function YfmTableFloatingMenuControl({ type,
61
62
  }
62
63
  : undefined, dropdownItems: dropdownItems }));
63
64
  };
65
+ function getVirtualAnchor(type, tableElem, cellElem) {
66
+ if (type === 'row') {
67
+ return {
68
+ contextElement: cellElem,
69
+ getBoundingClientRect() {
70
+ const cellRect = cellElem.getBoundingClientRect();
71
+ const tableRect = tableElem.getBoundingClientRect().toJSON();
72
+ {
73
+ // fix table rect
74
+ tableRect.x += 1;
75
+ tableRect.width -= 2;
76
+ tableRect.left += 1;
77
+ tableRect.right -= 1;
78
+ }
79
+ return {
80
+ // from table
81
+ x: tableRect.x,
82
+ width: tableRect.width,
83
+ left: tableRect.left,
84
+ right: tableRect.right,
85
+ // from cell
86
+ y: cellRect.y,
87
+ height: cellRect.height,
88
+ top: cellRect.top,
89
+ bottom: cellRect.top,
90
+ };
91
+ },
92
+ };
93
+ }
94
+ if (type === 'column') {
95
+ return {
96
+ contextElement: cellElem,
97
+ getBoundingClientRect() {
98
+ const cellRect = cellElem.getBoundingClientRect().toJSON();
99
+ const tableRect = tableElem.getBoundingClientRect();
100
+ const EDGE_OFFSET = 16;
101
+ const cellMiddle = cellRect.x + cellRect.width / 2;
102
+ // left border of table
103
+ if (cellMiddle - EDGE_OFFSET <= tableRect.left) {
104
+ const visible = cellRect.right - tableRect.left;
105
+ cellRect.width = (visible - EDGE_OFFSET) * 2;
106
+ cellRect.left = cellRect.right - cellRect.width;
107
+ cellRect.x = cellRect.left;
108
+ }
109
+ // right border of table
110
+ if (cellMiddle + EDGE_OFFSET >= tableRect.right) {
111
+ const visible = tableRect.right - cellRect.left;
112
+ cellRect.width = (visible - EDGE_OFFSET) * 2;
113
+ cellRect.right = cellRect.left + cellRect.width;
114
+ }
115
+ return cellRect;
116
+ },
117
+ };
118
+ }
119
+ throw new Error(`Unknown control type: ${type}`);
120
+ }
64
121
  //# sourceMappingURL=FloatingMenuControl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FloatingMenuControl.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingMenuControl/FloatingMenuControl.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAE9B,OAAO,EACH,SAAS,EACT,SAAS,EACT,UAAU,EACV,OAAO,EACP,WAAW,IAAI,UAAU,EACzB,QAAQ,EACR,KAAK,GACR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,IAAI,EAAC,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAC,IAAI,EAAC,qDAA2B;AAGxC,OAAO,EAAC,YAAY,EAAyB,wCAAqC;AAelF,MAAM,CAAC,MAAM,mBAAmB,GAC5B,SAAS,2BAA2B,CAAC,EACjC,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,GACrB;IACG,MAAM,aAAa,GAAG,OAAO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;QACJ,QAAQ;QACR,iBAAiB;QACjB,kBAAkB;QAClB,mBAAmB;QACnB,kBAAkB;QAClB,kBAAkB;KACrB,CACJ,CAAC;IAEF,OAAO,CACH,KAAC,YAAY,IACT,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,EAClD,YAAY,EAAE,gBAAgB,EAC9B,aAAa,EAAE,aAAa,EAC5B,kBAAkB,EACd,UAAU;YACN,CAAC,CAAC;gBACI,YAAY,EAAE,UAAU,CAAC,wBAAwB;gBACjD,WAAW,EAAE,UAAU,CAAC,uBAAuB;gBAC/C,WAAW,EAAE,UAAU,CAAC,uBAAuB;gBAC/C,SAAS,EAAE,UAAU,CAAC,qBAAqB;aAC9C;YACH,CAAC,CAAC,SAAS,EAEnB,aAAa,EAAE,aAAa,GAC9B,CACL,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {useMemo} from 'react';\n\nimport {\n ArrowDown,\n ArrowLeft,\n ArrowRight,\n ArrowUp,\n BroomMotion as ClearCells,\n TrashBin,\n Xmark,\n} from '@gravity-ui/icons';\nimport {Icon} from '@gravity-ui/uikit';\n\nimport {i18n} from 'src/i18n/yfm-table';\n\nimport type {DnDControlHandler} from '../../dnd/dnd';\nimport {FloatingMenu, type FloatingMenuProps} from '../FloatingMenu/FloatingMenu';\n\nexport type FloatingMenuControlProps = {\n acnhorElement: Element;\n multiple: boolean;\n type: FloatingMenuProps['dirtype'];\n dndHandler?: DnDControlHandler;\n onMenuOpenToggle: FloatingMenuProps['onOpenToggle'];\n onClearCellsClick: () => void;\n onInsertBeforeClick: () => void;\n onInsertAfterClick: () => void;\n onRemoveRangeClick: () => void;\n onRemoveTableClick: () => void;\n};\n\nexport const FloatingMenuControl: React.FC<FloatingMenuControlProps> =\n function YfmTableFloatingMenuControl({\n type,\n multiple,\n dndHandler,\n acnhorElement,\n onMenuOpenToggle,\n onClearCellsClick,\n onInsertBeforeClick,\n onInsertAfterClick,\n onRemoveRangeClick,\n onRemoveTableClick,\n }) {\n const dropdownItems = useMemo<FloatingMenuProps['dropdownItems']>(\n () =>\n [\n [\n {\n text: i18n(`${type}.add.before`),\n qa: `g-md-yfm-table-action-add-${type}-before`,\n action: onInsertBeforeClick,\n iconStart: <Icon data={type === 'row' ? ArrowUp : ArrowLeft} />,\n },\n {\n text: i18n(`${type}.add.after`),\n qa: `g-md-yfm-table-action-add-${type}-after`,\n action: onInsertAfterClick,\n iconStart: <Icon data={type === 'row' ? ArrowDown : ArrowRight} />,\n },\n ],\n [\n {\n text: i18n('cells.clear'),\n qa: `g-md-yfm-table-${type}-clear-cells`,\n action: onClearCellsClick,\n iconStart: <Icon data={ClearCells} />,\n },\n ],\n [\n {\n text: i18n(`${type}.remove${multiple ? '.multiple' : ''}`),\n qa: `g-md-yfm-table-action-remove-${type}`,\n action: onRemoveRangeClick,\n iconStart: <Icon data={Xmark} />,\n },\n {\n theme: 'danger',\n text: i18n('table.remove'),\n qa: 'g-md-yfm-table-action-remove-table',\n action: onRemoveTableClick,\n iconStart: <Icon data={TrashBin} />,\n },\n ],\n ] satisfies FloatingMenuProps['dropdownItems'],\n [\n type,\n multiple,\n onClearCellsClick,\n onInsertAfterClick,\n onInsertBeforeClick,\n onRemoveRangeClick,\n onRemoveTableClick,\n ],\n );\n\n return (\n <FloatingMenu\n dirtype={type}\n canDrag={dndHandler ? dndHandler.canDrag() : false}\n onOpenToggle={onMenuOpenToggle}\n anchorElement={acnhorElement}\n switcherMouseProps={\n dndHandler\n ? {\n onMouseLeave: dndHandler.control_handleMouseLeave,\n onMouseDown: dndHandler.control_handleMouseDown,\n onMouseMove: dndHandler.control_handleMouseMove,\n onMouseUp: dndHandler.control_handleMouseUp,\n }\n : undefined\n }\n dropdownItems={dropdownItems}\n />\n );\n };\n"]}
1
+ {"version":3,"file":"FloatingMenuControl.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/Y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B,EAAE,CAAC;gBAEpD,MAAM,WAAW,GAAG,EAAE,CAAC;gBAEvB,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;gBAEnD,uBAAuB;gBACvB,IAAI,UAAU,GAAG,WAAW,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC;oBAC7C,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC;oBAChD,QAAQ,CAAC,KAAK,GAAG,CAAC,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;oBAC7C,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;oBAChD,QAAQ,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC;gBAC/B,CAAC;gBAED,wBAAwB;gBACxB,IAAI,UAAU,GAAG,WAAW,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC;oBAC9C,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC;oBAChD,QAAQ,CAAC,KAAK,GAAG,CAAC,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;oBAC7C,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC;gBACpD,CAAC;gBAED,OAAO,QAAQ,CAAC;YACpB,CAAC;SACJ,CAAC;IACN,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import {useMemo} from 'react';\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport type {ClientRectObject, VirtualElement} from '@floating-ui/dom';\nimport {\n ArrowDown,\n ArrowLeft,\n ArrowRight,\n ArrowUp,\n BroomMotion as ClearCells,\n TrashBin,\n Xmark,\n} from '@gravity-ui/icons';\nimport {Icon} from '@gravity-ui/uikit';\n\nimport {i18n} from 'src/i18n/yfm-table';\n\nimport type {DnDControlHandler} from '../../dnd/dnd';\nimport {FloatingMenu, type FloatingMenuProps} from '../FloatingMenu/FloatingMenu';\n\ntype ControlType = FloatingMenuProps['dirtype'];\n\nexport type FloatingMenuControlProps = {\n cellElement: Element;\n tableElement: Element;\n multiple: boolean;\n type: ControlType;\n dndHandler?: DnDControlHandler;\n onMenuOpenToggle: FloatingMenuProps['onOpenToggle'];\n onClearCellsClick: () => void;\n onInsertBeforeClick: () => void;\n onInsertAfterClick: () => void;\n onRemoveRangeClick: () => void;\n onRemoveTableClick: () => void;\n};\n\nexport const FloatingMenuControl: React.FC<FloatingMenuControlProps> =\n function YfmTableFloatingMenuControl({\n type,\n multiple,\n dndHandler,\n cellElement,\n tableElement,\n onMenuOpenToggle,\n onClearCellsClick,\n onInsertBeforeClick,\n onInsertAfterClick,\n onRemoveRangeClick,\n onRemoveTableClick,\n }) {\n const dropdownItems = useMemo<FloatingMenuProps['dropdownItems']>(\n () =>\n [\n [\n {\n text: i18n(`${type}.add.before`),\n qa: `g-md-yfm-table-action-add-${type}-before`,\n action: onInsertBeforeClick,\n iconStart: <Icon data={type === 'row' ? ArrowUp : ArrowLeft} />,\n },\n {\n text: i18n(`${type}.add.after`),\n qa: `g-md-yfm-table-action-add-${type}-after`,\n action: onInsertAfterClick,\n iconStart: <Icon data={type === 'row' ? ArrowDown : ArrowRight} />,\n },\n ],\n [\n {\n text: i18n('cells.clear'),\n qa: `g-md-yfm-table-${type}-clear-cells`,\n action: onClearCellsClick,\n iconStart: <Icon data={ClearCells} />,\n },\n ],\n [\n {\n text: i18n(`${type}.remove${multiple ? '.multiple' : ''}`),\n qa: `g-md-yfm-table-action-remove-${type}`,\n action: onRemoveRangeClick,\n iconStart: <Icon data={Xmark} />,\n },\n {\n theme: 'danger',\n text: i18n('table.remove'),\n qa: 'g-md-yfm-table-action-remove-table',\n action: onRemoveTableClick,\n iconStart: <Icon data={TrashBin} />,\n },\n ],\n ] satisfies FloatingMenuProps['dropdownItems'],\n [\n type,\n multiple,\n onClearCellsClick,\n onInsertAfterClick,\n onInsertBeforeClick,\n onRemoveRangeClick,\n onRemoveTableClick,\n ],\n );\n\n const anchor = useMemo(\n () => getVirtualAnchor(type, tableElement, cellElement),\n [type, tableElement, cellElement],\n );\n\n return (\n <FloatingMenu\n dirtype={type}\n canDrag={dndHandler ? dndHandler.canDrag() : false}\n onOpenToggle={onMenuOpenToggle}\n anchorElement={anchor}\n switcherMouseProps={\n dndHandler\n ? {\n onMouseLeave: dndHandler.control_handleMouseLeave,\n onMouseDown: dndHandler.control_handleMouseDown,\n onMouseMove: dndHandler.control_handleMouseMove,\n onMouseUp: dndHandler.control_handleMouseUp,\n }\n : undefined\n }\n dropdownItems={dropdownItems}\n />\n );\n };\n\nfunction getVirtualAnchor(\n type: ControlType,\n tableElem: Element,\n cellElem: Element,\n): VirtualElement {\n if (type === 'row') {\n return {\n contextElement: cellElem,\n getBoundingClientRect() {\n const cellRect = cellElem.getBoundingClientRect();\n const tableRect: ClientRectObject = tableElem.getBoundingClientRect().toJSON();\n\n {\n // fix table rect\n tableRect.x += 1;\n tableRect.width -= 2;\n tableRect.left += 1;\n tableRect.right -= 1;\n }\n\n return {\n // from table\n x: tableRect.x,\n width: tableRect.width,\n left: tableRect.left,\n right: tableRect.right,\n // from cell\n y: cellRect.y,\n height: cellRect.height,\n top: cellRect.top,\n bottom: cellRect.top,\n };\n },\n };\n }\n\n if (type === 'column') {\n return {\n contextElement: cellElem,\n getBoundingClientRect() {\n const cellRect: ClientRectObject = cellElem.getBoundingClientRect().toJSON();\n const tableRect = tableElem.getBoundingClientRect();\n\n const EDGE_OFFSET = 16;\n\n const cellMiddle = cellRect.x + cellRect.width / 2;\n\n // left border of table\n if (cellMiddle - EDGE_OFFSET <= tableRect.left) {\n const visible = cellRect.right - tableRect.left;\n cellRect.width = (visible - EDGE_OFFSET) * 2;\n cellRect.left = cellRect.right - cellRect.width;\n cellRect.x = cellRect.left;\n }\n\n // right border of table\n if (cellMiddle + EDGE_OFFSET >= tableRect.right) {\n const visible = tableRect.right - cellRect.left;\n cellRect.width = (visible - EDGE_OFFSET) * 2;\n cellRect.right = cellRect.left + cellRect.width;\n }\n\n return cellRect;\n },\n };\n }\n\n throw new Error(`Unknown control type: ${type}`);\n}\n"]}
@@ -1,4 +1,6 @@
1
+ import { type FloatingPopupProps, type FloatingPopupRef } from "../FloatingPopup/index.js";
1
2
  import { type InsertCursorProps } from "./InsertCursor.js";
2
3
  import { type PlusButtonProps } from "./PlusButton.js";
3
- export type FloatingPlusButtonProps = Pick<PlusButtonProps, 'onClick'> & Pick<InsertCursorProps, 'type' | 'anchor'>;
4
- export declare const FloatingPlusButton: React.FC<FloatingPlusButtonProps>;
4
+ export type FloatingPlusButtonRef = FloatingPopupRef & {};
5
+ export type FloatingPlusButtonProps = Pick<FloatingPopupProps, 'floatingStyles'> & Pick<PlusButtonProps, 'onClick'> & Pick<InsertCursorProps, 'type' | 'anchor'>;
6
+ export declare const FloatingPlusButton: import("react").ForwardRefExoticComponent<Pick<FloatingPopupProps, "floatingStyles"> & Pick<PlusButtonProps, "onClick"> & Pick<InsertCursorProps, "type" | "anchor"> & import("react").RefAttributes<FloatingPopupRef>>;
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from 'react';
2
+ import { forwardRef, useState } from 'react';
3
3
  import { FloatingPopup } from "../FloatingPopup/index.js";
4
4
  import { InsertCursor } from "./InsertCursor.js";
5
5
  import { PlusButton } from "./PlusButton.js";
@@ -15,8 +15,8 @@ const offsetByType = {
15
15
  row: { alignmentAxis: -10 },
16
16
  column: { alignmentAxis: -10 },
17
17
  };
18
- export const FloatingPlusButton = function YfmTableFloatingPlusButton({ anchor, type, ...btnProps }) {
18
+ export const FloatingPlusButton = forwardRef(function YfmTableFloatingPlusButton({ anchor, type, floatingStyles, ...btnProps }, ref) {
19
19
  const [hovered, setHovered] = useState(false);
20
- return (_jsxs(_Fragment, { children: [_jsx(FloatingPopup, { open: true, anchorElement: anchor, placement: placementByType[type], offset: offsetByType[type], style: styles, children: _jsx(PlusButton, { ...btnProps, onHoverChange: setHovered, qa: `g-md-yfm-table-plus-${type}` }) }), hovered && _jsx(InsertCursor, { anchor: anchor, type: type })] }));
21
- };
20
+ return (_jsxs(_Fragment, { children: [_jsx(FloatingPopup, { open: true, ref: ref, anchorElement: anchor, floatingStyles: floatingStyles, placement: placementByType[type], offset: offsetByType[type], style: styles, children: _jsx(PlusButton, { ...btnProps, onHoverChange: setHovered, qa: `g-md-yfm-table-plus-${type}` }) }), hovered && _jsx(InsertCursor, { anchor: anchor, type: type })] }));
21
+ });
22
22
  //# sourceMappingURL=FloatingPlusButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FloatingPlusButton.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,aAAa,EAA0B,kCAAyB;AAExE,OAAO,EAAC,YAAY,EAAyB,0BAAuB;AACpE,OAAO,EAAC,UAAU,EAAuB,wBAAqB;AAE9D,MAAM,MAAM,GAAwB;IAChC,YAAY,EAAE,OAAO,EAAE,8BAA8B;IACrD,UAAU,EAAE,aAAa;CAC5B,CAAC;AACF,MAAM,eAAe,GAAuE;IACxF,GAAG,EAAE,UAAU;IACf,MAAM,EAAE,SAAS;CACpB,CAAC;AACF,MAAM,YAAY,GAAoE;IAClF,GAAG,EAAE,EAAC,aAAa,EAAE,CAAC,EAAE,EAAC;IACzB,MAAM,EAAE,EAAC,aAAa,EAAE,CAAC,EAAE,EAAC;CAC/B,CAAC;AAKF,MAAM,CAAC,MAAM,kBAAkB,GAC3B,SAAS,0BAA0B,CAAC,EAAC,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,EAAC;IAC3D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9C,OAAO,CACH,8BACI,KAAC,aAAa,IACV,IAAI,QACJ,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,eAAe,CAAC,IAAI,CAAC,EAChC,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,EAC1B,KAAK,EAAE,MAAM,YAEb,KAAC,UAAU,OACH,QAAQ,EACZ,aAAa,EAAE,UAAU,EACzB,EAAE,EAAE,uBAAuB,IAAI,EAAE,GACnC,GACU,EACf,OAAO,IAAI,KAAC,YAAY,IAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAI,IACzD,CACN,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {useState} from 'react';\n\nimport {FloatingPopup, type FloatingPopupProps} from '../FloatingPopup';\n\nimport {InsertCursor, type InsertCursorProps} from './InsertCursor';\nimport {PlusButton, type PlusButtonProps} from './PlusButton';\n\nconst styles: React.CSSProperties = {\n borderRadius: '100px', // button circle border radius\n background: 'transparent',\n};\nconst placementByType: Record<InsertCursorProps['type'], FloatingPopupProps['placement']> = {\n row: 'left-end',\n column: 'top-end',\n};\nconst offsetByType: Record<InsertCursorProps['type'], FloatingPopupProps['offset']> = {\n row: {alignmentAxis: -10},\n column: {alignmentAxis: -10},\n};\n\nexport type FloatingPlusButtonProps = Pick<PlusButtonProps, 'onClick'> &\n Pick<InsertCursorProps, 'type' | 'anchor'>;\n\nexport const FloatingPlusButton: React.FC<FloatingPlusButtonProps> =\n function YfmTableFloatingPlusButton({anchor, type, ...btnProps}) {\n const [hovered, setHovered] = useState(false);\n\n return (\n <>\n <FloatingPopup\n open\n anchorElement={anchor}\n placement={placementByType[type]}\n offset={offsetByType[type]}\n style={styles}\n >\n <PlusButton\n {...btnProps}\n onHoverChange={setHovered}\n qa={`g-md-yfm-table-plus-${type}`}\n />\n </FloatingPopup>\n {hovered && <InsertCursor anchor={anchor} type={type} />}\n </>\n );\n };\n"]}
1
+ {"version":3,"file":"FloatingPlusButton.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusButton/FloatingPlusButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAC,aAAa,EAAiD,kCAAyB;AAE/F,OAAO,EAAC,YAAY,EAAyB,0BAAuB;AACpE,OAAO,EAAC,UAAU,EAAuB,wBAAqB;AAE9D,MAAM,MAAM,GAAwB;IAChC,YAAY,EAAE,OAAO,EAAE,8BAA8B;IACrD,UAAU,EAAE,aAAa;CAC5B,CAAC;AACF,MAAM,eAAe,GAAuE;IACxF,GAAG,EAAE,UAAU;IACf,MAAM,EAAE,SAAS;CACpB,CAAC;AACF,MAAM,YAAY,GAAoE;IAClF,GAAG,EAAE,EAAC,aAAa,EAAE,CAAC,EAAE,EAAC;IACzB,MAAM,EAAE,EAAC,aAAa,EAAE,CAAC,EAAE,EAAC;CAC/B,CAAC;AAQF,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CACxC,SAAS,0BAA0B,CAAC,EAAC,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,QAAQ,EAAC,EAAE,GAAG;IAChF,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9C,OAAO,CACH,8BACI,KAAC,aAAa,IACV,IAAI,QACJ,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,cAAc,EAC9B,SAAS,EAAE,eAAe,CAAC,IAAI,CAAC,EAChC,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,EAC1B,KAAK,EAAE,MAAM,YAEb,KAAC,UAAU,OACH,QAAQ,EACZ,aAAa,EAAE,UAAU,EACzB,EAAE,EAAE,uBAAuB,IAAI,EAAE,GACnC,GACU,EACf,OAAO,IAAI,KAAC,YAAY,IAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAI,IACzD,CACN,CAAC;AACN,CAAC,CACJ,CAAC","sourcesContent":["import {forwardRef, useState} from 'react';\n\nimport {FloatingPopup, type FloatingPopupProps, type FloatingPopupRef} from '../FloatingPopup';\n\nimport {InsertCursor, type InsertCursorProps} from './InsertCursor';\nimport {PlusButton, type PlusButtonProps} from './PlusButton';\n\nconst styles: React.CSSProperties = {\n borderRadius: '100px', // button circle border radius\n background: 'transparent',\n};\nconst placementByType: Record<InsertCursorProps['type'], FloatingPopupProps['placement']> = {\n row: 'left-end',\n column: 'top-end',\n};\nconst offsetByType: Record<InsertCursorProps['type'], FloatingPopupProps['offset']> = {\n row: {alignmentAxis: -10},\n column: {alignmentAxis: -10},\n};\n\nexport type FloatingPlusButtonRef = FloatingPopupRef & {};\n\nexport type FloatingPlusButtonProps = Pick<FloatingPopupProps, 'floatingStyles'> &\n Pick<PlusButtonProps, 'onClick'> &\n Pick<InsertCursorProps, 'type' | 'anchor'>;\n\nexport const FloatingPlusButton = forwardRef<FloatingPlusButtonRef, FloatingPlusButtonProps>(\n function YfmTableFloatingPlusButton({anchor, type, floatingStyles, ...btnProps}, ref) {\n const [hovered, setHovered] = useState(false);\n\n return (\n <>\n <FloatingPopup\n open\n ref={ref}\n anchorElement={anchor}\n floatingStyles={floatingStyles}\n placement={placementByType[type]}\n offset={offsetByType[type]}\n style={styles}\n >\n <PlusButton\n {...btnProps}\n onHoverChange={setHovered}\n qa={`g-md-yfm-table-plus-${type}`}\n />\n </FloatingPopup>\n {hovered && <InsertCursor anchor={anchor} type={type} />}\n </>\n );\n },\n);\n"]}
@@ -1,9 +1,11 @@
1
1
  import { type FloatingPlusButtonProps } from "../FloatingPlusButton/index.js";
2
+ type ControlType = FloatingPlusButtonProps['type'];
2
3
  export type FloatingPlusControlProps = {
3
- type: FloatingPlusButtonProps['type'];
4
+ type: ControlType;
4
5
  index: number;
5
6
  cellElem: Element;
6
7
  tableElem: Element;
7
8
  onClick: (rowIdx: number) => void;
8
9
  };
9
10
  export declare const FloatingPlusControl: import("react").NamedExoticComponent<FloatingPlusControlProps>;
11
+ export {};
@@ -1,6 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { memo, useMemo } from 'react';
3
- import { FloatingPlusButton } from "../FloatingPlusButton/index.js";
2
+ import { memo, useEffect, useMemo, useRef, useState } from 'react';
3
+ import { useEffectOnce } from 'react-use';
4
+ import { useRafThrottle } from "../../hooks/use-raf-throttle.js";
5
+ import { FloatingPlusButton, } from "../FloatingPlusButton/index.js";
4
6
  export const FloatingPlusControl = memo(function YfmTableRowFloatingPlusControl({ type, index, cellElem, tableElem, onClick }) {
5
7
  const anchor = useMemo(() => ({
6
8
  contextElement: tableElem,
@@ -30,6 +32,39 @@ export const FloatingPlusControl = memo(function YfmTableRowFloatingPlusControl(
30
32
  };
31
33
  },
32
34
  }), [cellElem, tableElem, type]);
33
- return _jsx(FloatingPlusButton, { anchor: anchor, type: type, onClick: () => onClick(index) });
35
+ const [visible, setVisible] = useState(() => shouldBeVisible(type, cellElem, tableElem));
36
+ const buttonRef = useRef(null);
37
+ const updateVisibility = () => {
38
+ const newVisible = shouldBeVisible(type, cellElem, tableElem);
39
+ if (visible !== newVisible)
40
+ setVisible(newVisible);
41
+ };
42
+ const onChange = useRafThrottle(() => {
43
+ buttonRef.current?.forceUpdate();
44
+ updateVisibility();
45
+ });
46
+ // Update after first render
47
+ useEffectOnce(updateVisibility);
48
+ useEffect(() => {
49
+ if (type !== 'column')
50
+ return undefined;
51
+ const observer = new ResizeObserver(onChange);
52
+ observer.observe(tableElem);
53
+ tableElem.addEventListener('scroll', onChange);
54
+ return () => {
55
+ observer.unobserve(tableElem);
56
+ tableElem.removeEventListener('scroll', onChange);
57
+ };
58
+ }, [tableElem, onChange, type]);
59
+ return (_jsx(FloatingPlusButton, { ref: buttonRef, anchor: anchor, type: type, onClick: () => onClick(index), floatingStyles: visible ? undefined : { display: 'none' } }));
34
60
  });
61
+ function shouldBeVisible(type, cellElem, tableElem) {
62
+ if (type !== 'column')
63
+ return true;
64
+ const THRESHOLD = 4; // px
65
+ const cellRect = cellElem.getBoundingClientRect();
66
+ const tableRect = tableElem.getBoundingClientRect();
67
+ return (tableRect.left - cellRect.right <= THRESHOLD &&
68
+ cellRect.right - tableRect.right <= THRESHOLD);
69
+ }
35
70
  //# sourceMappingURL=FloatingPlusControl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FloatingPlusControl.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAKpC,OAAO,EAAC,kBAAkB,EAA+B,uCAA8B;AAUvF,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CACnC,SAAS,8BAA8B,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAC;IAC/E,MAAM,MAAM,GAAG,OAAO,CAClB,GAAG,EAAE,CAAC,CAAC;QACH,cAAc,EAAE,SAAS;QACzB,qBAAqB;YACjB,MAAM,QAAQ,GAAG,QAAQ,CAAC,qBAAqB,EAAE,CAAC;YAClD,MAAM,SAAS,GAAG,SAAS,CAAC,qBAAqB,EAAE,CAAC;YAEpD,OAAO,IAAI,KAAK,KAAK;gBACjB,CAAC,CAAC;oBACI,CAAC,EAAE,SAAS,CAAC,CAAC;oBACd,CAAC,EAAE,QAAQ,CAAC,CAAC;oBACb,KAAK,EAAE,SAAS,CAAC,KAAK;oBACtB,MAAM,EAAE,QAAQ,CAAC,MAAM;oBACvB,GAAG,EAAE,QAAQ,CAAC,GAAG;oBACjB,IAAI,EAAE,SAAS,CAAC,IAAI;oBACpB,KAAK,EAAE,SAAS,CAAC,KAAK;oBACtB,MAAM,EAAE,QAAQ,CAAC,GAAG;iBACvB;gBACH,CAAC,CAAC;oBACI,CAAC,EAAE,QAAQ,CAAC,CAAC;oBACb,CAAC,EAAE,SAAS,CAAC,CAAC;oBACd,KAAK,EAAE,QAAQ,CAAC,KAAK;oBACrB,MAAM,EAAE,SAAS,CAAC,MAAM;oBACxB,GAAG,EAAE,SAAS,CAAC,GAAG;oBAClB,IAAI,EAAE,QAAQ,CAAC,IAAI;oBACnB,KAAK,EAAE,QAAQ,CAAC,KAAK;oBACrB,MAAM,EAAE,SAAS,CAAC,GAAG;iBACxB,CAAC;QACZ,CAAC;KACJ,CAAC,EACF,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,CAC9B,CAAC;IAEF,OAAO,KAAC,kBAAkB,IAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAI,CAAC;AAC7F,CAAC,CACJ,CAAC","sourcesContent":["import {memo, useMemo} from 'react';\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport type {VirtualElement} from '@floating-ui/dom';\n\nimport {FloatingPlusButton, type FloatingPlusButtonProps} from '../FloatingPlusButton';\n\nexport type FloatingPlusControlProps = {\n type: FloatingPlusButtonProps['type'];\n index: number;\n cellElem: Element;\n tableElem: Element;\n onClick: (rowIdx: number) => void;\n};\n\nexport const FloatingPlusControl = memo<FloatingPlusControlProps>(\n function YfmTableRowFloatingPlusControl({type, index, cellElem, tableElem, onClick}) {\n const anchor = useMemo<VirtualElement>(\n () => ({\n contextElement: tableElem,\n getBoundingClientRect() {\n const cellRect = cellElem.getBoundingClientRect();\n const tableRect = tableElem.getBoundingClientRect();\n\n return type === 'row'\n ? {\n x: tableRect.x,\n y: cellRect.y,\n width: tableRect.width,\n height: cellRect.height,\n top: cellRect.top,\n left: tableRect.left,\n right: tableRect.right,\n bottom: cellRect.top,\n }\n : {\n x: cellRect.x,\n y: tableRect.y,\n width: cellRect.width,\n height: tableRect.height,\n top: tableRect.top,\n left: cellRect.left,\n right: cellRect.right,\n bottom: tableRect.top,\n };\n },\n }),\n [cellElem, tableElem, type],\n );\n\n return <FloatingPlusButton anchor={anchor} type={type} onClick={() => onClick(index)} />;\n },\n);\n"]}
1
+ {"version":3,"file":"FloatingPlusControl.js","sourceRoot":"../../../../../../../../../src","sources":["extensions/yfm/YfmTable/plugins/YfmTableControls/components/FloatingPlusControl/FloatingPlusControl.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAIjE,OAAO,EAAC,aAAa,EAAC,MAAM,WAAW,CAAC;AAExC,OAAO,EAAC,cAAc,EAAC,wCAAqC;AAC5D,OAAO,EACH,kBAAkB,GAGrB,uCAA8B;AAY/B,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CACnC,SAAS,8BAA8B,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAC;IAC/E,MAAM,MAAM,GAAG,OAAO,CAClB,GAAG,EAAE,CAAC,CAAC;QACH,cAAc,EAAE,SAAS;QACzB,qBAAqB;YACjB,MAAM,QAAQ,GAAG,QAAQ,CAAC,qBAAqB,EAAE,CAAC;YAClD,MAAM,SAAS,GAAG,SAAS,CAAC,qBAAqB,EAAE,CAAC;YAEpD,OAAO,IAAI,KAAK,KAAK;gBACjB,CAAC,CAAC;oBACI,CAAC,EAAE,SAAS,CAAC,CAAC;oBACd,CAAC,EAAE,QAAQ,CAAC,CAAC;oBACb,KAAK,EAAE,SAAS,CAAC,KAAK;oBACtB,MAAM,EAAE,QAAQ,CAAC,MAAM;oBACvB,GAAG,EAAE,QAAQ,CAAC,GAAG;oBACjB,IAAI,EAAE,SAAS,CAAC,IAAI;oBACpB,KAAK,EAAE,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QAC9C,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC5B,SAAS,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAE/C,OAAO,GAAG,EAAE;YACR,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;YAC9B,SAAS,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACtD,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;IAEhC,OAAO,CACH,KAAC,kBAAkB,IACf,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAC7B,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAC,OAAO,EAAE,MAAM,EAAC,GACzD,CACL,CAAC;AACN,CAAC,CACJ,CAAC;AAEF,SAAS,eAAe,CAAC,IAAiB,EAAE,QAAiB,EAAE,SAAkB;IAC7E,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAEnC,MAAM,SAAS,GAAG,CAAC,CAAC,CAAC,KAAK;IAE1B,MAAM,QAAQ,GAAG,QAAQ,CAAC,qBAAqB,EAAE,CAAC;IAClD,MAAM,SAAS,GAAG,SAAS,CAAC,qBAAqB,EAAE,CAAC;IAEpD,OAAO,CACH,SAAS,CAAC,IAAI,GAAG,QAAQ,CAAC,KAAK,IAAI,SAAS;QAC5C,QAAQ,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,IAAI,SAAS,CAChD,CAAC;AACN,CAAC","sourcesContent":["import {memo, useEffect, useMemo, useRef, useState} from 'react';\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport type {VirtualElement} from '@floating-ui/dom';\nimport {useEffectOnce} from 'react-use';\n\nimport {useRafThrottle} from '../../hooks/use-raf-throttle';\nimport {\n FloatingPlusButton,\n type FloatingPlusButtonProps,\n type FloatingPlusButtonRef,\n} from '../FloatingPlusButton';\n\ntype ControlType = FloatingPlusButtonProps['type'];\n\nexport type FloatingPlusControlProps = {\n type: ControlType;\n index: number;\n cellElem: Element;\n tableElem: Element;\n onClick: (rowIdx: number) => void;\n};\n\nexport const FloatingPlusControl = memo<FloatingPlusControlProps>(\n function YfmTableRowFloatingPlusControl({type, index, cellElem, tableElem, onClick}) {\n const anchor = useMemo<VirtualElement>(\n () => ({\n contextElement: tableElem,\n getBoundingClientRect() {\n const cellRect = cellElem.getBoundingClientRect();\n const tableRect = tableElem.getBoundingClientRect();\n\n return type === 'row'\n ? {\n x: tableRect.x,\n y: cellRect.y,\n width: tableRect.width,\n height: cellRect.height,\n top: cellRect.top,\n left: tableRect.left,\n right: tableRect.right,\n bottom: cellRect.top,\n }\n : {\n x: cellRect.x,\n y: tableRect.y,\n width: cellRect.width,\n height: tableRect.height,\n top: tableRect.top,\n left: cellRect.left,\n right: cellRect.right,\n bottom: tableRect.top,\n };\n },\n }),\n [cellElem, tableElem, type],\n );\n\n const [visible, setVisible] = useState(() => shouldBeVisible(type, cellElem, tableElem));\n const buttonRef = useRef<FloatingPlusButtonRef>(null);\n\n const updateVisibility = () => {\n const newVisible = shouldBeVisible(type, cellElem, tableElem);\n if (visible !== newVisible) setVisible(newVisible);\n };\n\n const onChange = useRafThrottle(() => {\n buttonRef.current?.forceUpdate();\n updateVisibility();\n });\n\n // Update after first render\n useEffectOnce(updateVisibility);\n\n useEffect(() => {\n if (type !== 'column') return undefined;\n\n const observer = new ResizeObserver(onChange);\n observer.observe(tableElem);\n tableElem.addEventListener('scroll', onChange);\n\n return () => {\n observer.unobserve(tableElem);\n tableElem.removeEventListener('scroll', onChange);\n };\n }, [tableElem, onChange, type]);\n\n return (\n <FloatingPlusButton\n ref={buttonRef}\n anchor={anchor}\n type={type}\n onClick={() => onClick(index)}\n floatingStyles={visible ? undefined : {display: 'none'}}\n />\n );\n },\n);\n\nfunction shouldBeVisible(type: ControlType, cellElem: Element, tableElem: Element): boolean {\n if (type !== 'column') return true;\n\n const THRESHOLD = 4; // px\n\n const cellRect = cellElem.getBoundingClientRect();\n const tableRect = tableElem.getBoundingClientRect();\n\n return (\n tableRect.left - cellRect.right <= THRESHOLD &&\n cellRect.right - tableRect.right <= THRESHOLD\n );\n}\n"]}
@@ -1,6 +1,10 @@
1
1
  import { type OffsetOptions, type Placement, type ReferenceType } from '@floating-ui/react';
2
2
  import { type DOMProps, type QAProps } from '@gravity-ui/uikit';
3
3
  import "./FloatingPopup.css";
4
+ export type { ReferenceType };
5
+ export type FloatingPopupRef = {
6
+ forceUpdate: () => void;
7
+ };
4
8
  export type FloatingPopupProps = QAProps & DOMProps & {
5
9
  open?: boolean;
6
10
  zIndex?: number;
@@ -10,4 +14,12 @@ export type FloatingPopupProps = QAProps & DOMProps & {
10
14
  children: React.ReactNode;
11
15
  floatingStyles?: React.CSSProperties;
12
16
  };
13
- export declare const FloatingPopup: React.FC<FloatingPopupProps>;
17
+ export declare const FloatingPopup: import("react").ForwardRefExoticComponent<QAProps & DOMProps & {
18
+ open?: boolean;
19
+ zIndex?: number;
20
+ placement: Placement;
21
+ offset?: OffsetOptions;
22
+ anchorElement: ReferenceType | undefined | null;
23
+ children: React.ReactNode;
24
+ floatingStyles?: React.CSSProperties;
25
+ } & import("react").RefAttributes<FloatingPopupRef>>;
@@ -3,36 +3,34 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  /// Fork of Popup component from @gravity-ui/uikit
4
4
  /// This fork does not use floating focus manager
5
5
  ///
6
- import { useEffect, useMemo } from 'react';
6
+ import { forwardRef, useEffect, useImperativeHandle, useMemo } from 'react';
7
7
  // eslint-disable-next-line import/no-extraneous-dependencies
8
8
  import { FloatingNode, FloatingTree, autoUpdate, offset as offsetMiddleware, useFloating, useFloatingNodeId, useFloatingParentNodeId, useInteractions, } from '@floating-ui/react';
9
9
  import { Portal } from '@gravity-ui/uikit';
10
10
  import { cn } from "../../../../../../../classname.js";
11
11
  import "./FloatingPopup.css";
12
12
  const b = cn('yfm-table-floating-popup');
13
- export const FloatingPopup = function YfmTableFloatingPopup(props) {
13
+ export const FloatingPopup = forwardRef(function YfmTableFloatingPopup(props, ref) {
14
14
  const { anchorElement, zIndex = 1000, style, className, qa, children, floatingStyles: floatingStylesFromProps, } = props;
15
15
  const nodeId = useFloatingNodeId();
16
16
  const parentId = useFloatingParentNodeId();
17
17
  const middleware = useMemo(() => [offsetMiddleware(props.offset)], [props.offset]);
18
- const { refs, elements, floatingStyles, placement, context: { open }, update, } = useFloating({
18
+ const { refs, floatingStyles, placement, context: { open }, update, } = useFloating({
19
19
  nodeId,
20
20
  open: props.open,
21
21
  placement: props.placement,
22
22
  middleware,
23
+ whileElementsMounted: autoUpdate,
23
24
  });
25
+ useImperativeHandle(ref, () => ({
26
+ forceUpdate: update,
27
+ }), [update]);
24
28
  const { getFloatingProps } = useInteractions();
25
29
  useEffect(() => {
26
30
  if (anchorElement !== undefined && anchorElement !== refs.reference.current) {
27
31
  refs.setReference(anchorElement);
28
32
  }
29
33
  }, [anchorElement, refs]);
30
- useEffect(() => {
31
- if (elements.reference && elements.floating) {
32
- return autoUpdate(elements.reference, elements.floating, update);
33
- }
34
- return undefined;
35
- }, [elements, update]);
36
34
  function wrapper(node) {
37
35
  if (parentId === null) {
38
36
  return _jsx(FloatingTree, { children: node });
@@ -50,5 +48,5 @@ export const FloatingPopup = function YfmTableFloatingPopup(props) {
50
48
  ...floatingStylesFromProps,
51
49
  ...floatingStyles,
52
50
  }, "data-floating-ui-placement": placement, ...getFloatingProps(), children: _jsx("div", { className: b(null, className), style: style, "data-qa": qa, children: children }) }) })) : null }));
53
- };
51
+ });
54
52
  //# sourceMappingURL=FloatingPopup.js.map