@use-kona/editor 0.1.0-rc.0

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 (401) hide show
  1. package/README.md +23 -0
  2. package/dist/constants.d.ts +1 -0
  3. package/dist/constants.js +2 -0
  4. package/dist/core/createEditable.d.ts +7 -0
  5. package/dist/core/createEditable.js +110 -0
  6. package/dist/core/createEditor.d.ts +2 -0
  7. package/dist/core/createEditor.js +167 -0
  8. package/dist/core/deserialize.d.ts +3 -0
  9. package/dist/core/deserialize.js +33 -0
  10. package/dist/core/queries.d.ts +2 -0
  11. package/dist/core/queries.js +10 -0
  12. package/dist/core/serialize.d.ts +3 -0
  13. package/dist/core/serialize.js +13 -0
  14. package/dist/core/styles.module.js +6 -0
  15. package/dist/core/styles_module.css +29 -0
  16. package/dist/defaultValue.d.ts +4 -0
  17. package/dist/defaultValue.js +13 -0
  18. package/dist/editor.d.ts +10 -0
  19. package/dist/editor.js +43 -0
  20. package/dist/elements/BaseElement.d.ts +2 -0
  21. package/dist/elements/BaseElement.js +6 -0
  22. package/dist/examples/Backdrop.d.ts +5 -0
  23. package/dist/examples/Backdrop.js +13 -0
  24. package/dist/examples/Backdrop.module.js +5 -0
  25. package/dist/examples/Backdrop_module.css +6 -0
  26. package/dist/examples/DragBlock.d.ts +11 -0
  27. package/dist/examples/DragBlock.js +38 -0
  28. package/dist/examples/DragBlock.module.js +9 -0
  29. package/dist/examples/DragBlock_module.css +43 -0
  30. package/dist/examples/DragHandler.d.ts +2 -0
  31. package/dist/examples/DragHandler.js +44 -0
  32. package/dist/examples/DragHandler.module.js +8 -0
  33. package/dist/examples/DragHandler_module.css +18 -0
  34. package/dist/examples/Editor.d.ts +2 -0
  35. package/dist/examples/Editor.js +23 -0
  36. package/dist/examples/Editor.module.js +12 -0
  37. package/dist/examples/Editor_module.css +128 -0
  38. package/dist/examples/FloatingMenu.d.ts +17 -0
  39. package/dist/examples/FloatingMenu.js +244 -0
  40. package/dist/examples/FloatingMenu.module.js +9 -0
  41. package/dist/examples/FloatingMenu_module.css +75 -0
  42. package/dist/examples/LanguageSelector.d.ts +10 -0
  43. package/dist/examples/LanguageSelector.js +154 -0
  44. package/dist/examples/LanguageSelector.module.js +7 -0
  45. package/dist/examples/LanguageSelector_module.css +52 -0
  46. package/dist/examples/LinksHint.d.ts +7 -0
  47. package/dist/examples/LinksHint.js +50 -0
  48. package/dist/examples/LinksHint.module.js +6 -0
  49. package/dist/examples/LinksHint_module.css +28 -0
  50. package/dist/examples/Menu.d.ts +6 -0
  51. package/dist/examples/Menu.js +79 -0
  52. package/dist/examples/Menu.module.js +8 -0
  53. package/dist/examples/Menu_module.css +38 -0
  54. package/dist/examples/colors.d.ts +10 -0
  55. package/dist/examples/colors.js +12 -0
  56. package/dist/examples/getCommands.d.ts +2 -0
  57. package/dist/examples/getCommands.js +87 -0
  58. package/dist/examples/getPlugins.d.ts +2 -0
  59. package/dist/examples/getPlugins.js +127 -0
  60. package/dist/examples/getShortcuts.d.ts +2 -0
  61. package/dist/examples/getShortcuts.js +90 -0
  62. package/dist/examples/icons/bold.d.ts +2 -0
  63. package/dist/examples/icons/bold.js +27 -0
  64. package/dist/examples/icons/check.d.ts +2 -0
  65. package/dist/examples/icons/check.js +24 -0
  66. package/dist/examples/icons/chevronRight.d.ts +2 -0
  67. package/dist/examples/icons/chevronRight.js +24 -0
  68. package/dist/examples/icons/color.d.ts +2 -0
  69. package/dist/examples/icons/color.js +30 -0
  70. package/dist/examples/icons/copy.d.ts +2 -0
  71. package/dist/examples/icons/copy.js +27 -0
  72. package/dist/examples/icons/cross.d.ts +2 -0
  73. package/dist/examples/icons/cross.js +27 -0
  74. package/dist/examples/icons/drag.d.ts +2 -0
  75. package/dist/examples/icons/drag.js +39 -0
  76. package/dist/examples/icons/edit.d.ts +2 -0
  77. package/dist/examples/icons/edit.js +30 -0
  78. package/dist/examples/icons/external.d.ts +2 -0
  79. package/dist/examples/icons/external.js +30 -0
  80. package/dist/examples/icons/heading1.d.ts +2 -0
  81. package/dist/examples/icons/heading1.js +45 -0
  82. package/dist/examples/icons/heading2.d.ts +2 -0
  83. package/dist/examples/icons/heading2.js +45 -0
  84. package/dist/examples/icons/heading3.d.ts +2 -0
  85. package/dist/examples/icons/heading3.js +48 -0
  86. package/dist/examples/icons/italic.d.ts +2 -0
  87. package/dist/examples/icons/italic.js +30 -0
  88. package/dist/examples/icons/link.d.ts +2 -0
  89. package/dist/examples/icons/link.js +30 -0
  90. package/dist/examples/icons/ol.d.ts +2 -0
  91. package/dist/examples/icons/ol.js +36 -0
  92. package/dist/examples/icons/strikethrough.d.ts +2 -0
  93. package/dist/examples/icons/strikethrough.js +27 -0
  94. package/dist/examples/icons/text.d.ts +2 -0
  95. package/dist/examples/icons/text.js +22 -0
  96. package/dist/examples/icons/types.d.ts +3 -0
  97. package/dist/examples/icons/types.js +0 -0
  98. package/dist/examples/icons/ul.d.ts +2 -0
  99. package/dist/examples/icons/ul.js +39 -0
  100. package/dist/examples/icons/underline.d.ts +2 -0
  101. package/dist/examples/icons/underline.js +27 -0
  102. package/dist/examples/store.d.ts +8 -0
  103. package/dist/examples/store.js +6 -0
  104. package/dist/examples/styles.module.js +11 -0
  105. package/dist/examples/styles_module.css +78 -0
  106. package/dist/examples/text.d.ts +3 -0
  107. package/dist/examples/text.js +60 -0
  108. package/dist/examples/ui/Button/Button.d.ts +8 -0
  109. package/dist/examples/ui/Button/Button.js +15 -0
  110. package/dist/examples/ui/Button/ButtonWrapper.d.ts +4 -0
  111. package/dist/examples/ui/Button/ButtonWrapper.js +14 -0
  112. package/dist/examples/ui/Button/index.d.ts +2 -0
  113. package/dist/examples/ui/Button/index.js +3 -0
  114. package/dist/examples/ui/Button/styles.module.js +10 -0
  115. package/dist/examples/ui/Button/styles_module.css +72 -0
  116. package/dist/examples/ui/Button/types.d.ts +1 -0
  117. package/dist/examples/ui/Button/types.js +0 -0
  118. package/dist/examples/ui/Dropdown/Dropdown.d.ts +16 -0
  119. package/dist/examples/ui/Dropdown/Dropdown.js +75 -0
  120. package/dist/examples/ui/Dropdown/index.d.ts +1 -0
  121. package/dist/examples/ui/Dropdown/index.js +2 -0
  122. package/dist/examples/ui/Menu/Menu.d.ts +41 -0
  123. package/dist/examples/ui/Menu/Menu.js +404 -0
  124. package/dist/examples/ui/Menu/MenuDelimiter.d.ts +1 -0
  125. package/dist/examples/ui/Menu/MenuDelimiter.js +6 -0
  126. package/dist/examples/ui/Menu/MenuHotkey.d.ts +6 -0
  127. package/dist/examples/ui/Menu/MenuHotkey.js +12 -0
  128. package/dist/examples/ui/Menu/MenuIcon.d.ts +6 -0
  129. package/dist/examples/ui/Menu/MenuIcon.js +12 -0
  130. package/dist/examples/ui/Menu/MenuItem.d.ts +6 -0
  131. package/dist/examples/ui/Menu/MenuItem.js +17 -0
  132. package/dist/examples/ui/Menu/MenuTitle.d.ts +6 -0
  133. package/dist/examples/ui/Menu/MenuTitle.js +12 -0
  134. package/dist/examples/ui/Menu/SafeSpace.d.ts +6 -0
  135. package/dist/examples/ui/Menu/SafeSpace.js +65 -0
  136. package/dist/examples/ui/Menu/index.d.ts +2 -0
  137. package/dist/examples/ui/Menu/index.js +2 -0
  138. package/dist/examples/ui/Menu/styles.module.js +21 -0
  139. package/dist/examples/ui/Menu/styles_module.css +140 -0
  140. package/dist/examples/ui/Menu/types.d.ts +16 -0
  141. package/dist/examples/ui/Menu/types.js +0 -0
  142. package/dist/examples/ui/useMenuPosition.d.ts +18 -0
  143. package/dist/examples/ui/useMenuPosition.js +51 -0
  144. package/dist/examples/ui/useMergeRefs.d.ts +23 -0
  145. package/dist/examples/ui/useMergeRefs.js +11 -0
  146. package/dist/index.d.ts +2 -0
  147. package/dist/index.js +3 -0
  148. package/dist/plugins/AttachmentsPlugin/AttachmentsPlugin.d.ts +17 -0
  149. package/dist/plugins/AttachmentsPlugin/AttachmentsPlugin.js +37 -0
  150. package/dist/plugins/AttachmentsPlugin/index.d.ts +1 -0
  151. package/dist/plugins/AttachmentsPlugin/index.js +2 -0
  152. package/dist/plugins/AttachmentsPlugin/types.d.ts +11 -0
  153. package/dist/plugins/AttachmentsPlugin/types.js +0 -0
  154. package/dist/plugins/BasicFormattingPlugin/BasicFormattingPlugin.d.ts +20 -0
  155. package/dist/plugins/BasicFormattingPlugin/BasicFormattingPlugin.js +76 -0
  156. package/dist/plugins/BasicFormattingPlugin/index.d.ts +1 -0
  157. package/dist/plugins/BasicFormattingPlugin/index.js +2 -0
  158. package/dist/plugins/BreaksPlugin/BreaksPlugin.d.ts +15 -0
  159. package/dist/plugins/BreaksPlugin/BreaksPlugin.js +50 -0
  160. package/dist/plugins/BreaksPlugin/index.d.ts +1 -0
  161. package/dist/plugins/BreaksPlugin/index.js +2 -0
  162. package/dist/plugins/CodeBlockPlugin/CodeBlock.d.ts +9 -0
  163. package/dist/plugins/CodeBlockPlugin/CodeBlock.js +18 -0
  164. package/dist/plugins/CodeBlockPlugin/CodeBlockLine.d.ts +2 -0
  165. package/dist/plugins/CodeBlockPlugin/CodeBlockLine.js +9 -0
  166. package/dist/plugins/CodeBlockPlugin/CodeBlockPlugin.d.ts +55 -0
  167. package/dist/plugins/CodeBlockPlugin/CodeBlockPlugin.js +224 -0
  168. package/dist/plugins/CodeBlockPlugin/index.d.ts +1 -0
  169. package/dist/plugins/CodeBlockPlugin/index.js +2 -0
  170. package/dist/plugins/CodeBlockPlugin/styles.module.js +6 -0
  171. package/dist/plugins/CodeBlockPlugin/styles_module.css +12 -0
  172. package/dist/plugins/CodeBlockPlugin/types.d.ts +8 -0
  173. package/dist/plugins/CodeBlockPlugin/types.js +0 -0
  174. package/dist/plugins/CodeBlockPlugin/utils.d.ts +13 -0
  175. package/dist/plugins/CodeBlockPlugin/utils.js +87 -0
  176. package/dist/plugins/CommandsPlugin/CommandsPlugin.d.ts +11 -0
  177. package/dist/plugins/CommandsPlugin/CommandsPlugin.js +65 -0
  178. package/dist/plugins/CommandsPlugin/Menu.d.ts +11 -0
  179. package/dist/plugins/CommandsPlugin/Menu.js +153 -0
  180. package/dist/plugins/CommandsPlugin/actions.d.ts +7 -0
  181. package/dist/plugins/CommandsPlugin/actions.js +29 -0
  182. package/dist/plugins/CommandsPlugin/index.d.ts +2 -0
  183. package/dist/plugins/CommandsPlugin/index.js +2 -0
  184. package/dist/plugins/CommandsPlugin/styles.module.js +9 -0
  185. package/dist/plugins/CommandsPlugin/styles_module.css +66 -0
  186. package/dist/plugins/CommandsPlugin/types.d.ts +27 -0
  187. package/dist/plugins/CommandsPlugin/types.js +0 -0
  188. package/dist/plugins/DnDPlugin/DnDPlugin.d.ts +33 -0
  189. package/dist/plugins/DnDPlugin/DnDPlugin.js +110 -0
  190. package/dist/plugins/DnDPlugin/index.d.ts +1 -0
  191. package/dist/plugins/DnDPlugin/index.js +2 -0
  192. package/dist/plugins/DnDPlugin/styles.module.js +9 -0
  193. package/dist/plugins/DnDPlugin/styles_module.css +43 -0
  194. package/dist/plugins/FloatingMenuPlugin/FloatingMenu.d.ts +9 -0
  195. package/dist/plugins/FloatingMenuPlugin/FloatingMenu.js +89 -0
  196. package/dist/plugins/FloatingMenuPlugin/FloatingMenuPlugin.d.ts +15 -0
  197. package/dist/plugins/FloatingMenuPlugin/FloatingMenuPlugin.js +36 -0
  198. package/dist/plugins/FloatingMenuPlugin/index.d.ts +2 -0
  199. package/dist/plugins/FloatingMenuPlugin/index.js +2 -0
  200. package/dist/plugins/FloatingMenuPlugin/styles.module.js +7 -0
  201. package/dist/plugins/FloatingMenuPlugin/styles_module.css +23 -0
  202. package/dist/plugins/FloatingMenuPlugin/types.d.ts +16 -0
  203. package/dist/plugins/FloatingMenuPlugin/types.js +0 -0
  204. package/dist/plugins/HeadingsPlugin/HeadingsPlugin.d.ts +19 -0
  205. package/dist/plugins/HeadingsPlugin/HeadingsPlugin.js +64 -0
  206. package/dist/plugins/HeadingsPlugin/index.d.ts +1 -0
  207. package/dist/plugins/HeadingsPlugin/index.js +2 -0
  208. package/dist/plugins/HighlightsPlugin/HighlightsPlugin.d.ts +16 -0
  209. package/dist/plugins/HighlightsPlugin/HighlightsPlugin.js +36 -0
  210. package/dist/plugins/HighlightsPlugin/index.d.ts +1 -0
  211. package/dist/plugins/HighlightsPlugin/index.js +2 -0
  212. package/dist/plugins/LinksPlugin/Link.d.ts +11 -0
  213. package/dist/plugins/LinksPlugin/Link.js +89 -0
  214. package/dist/plugins/LinksPlugin/LinksPlugin.d.ts +17 -0
  215. package/dist/plugins/LinksPlugin/LinksPlugin.js +102 -0
  216. package/dist/plugins/LinksPlugin/constants.d.ts +1 -0
  217. package/dist/plugins/LinksPlugin/constants.js +2 -0
  218. package/dist/plugins/LinksPlugin/index.d.ts +2 -0
  219. package/dist/plugins/LinksPlugin/index.js +2 -0
  220. package/dist/plugins/LinksPlugin/styles.module.js +11 -0
  221. package/dist/plugins/LinksPlugin/styles_module.css +71 -0
  222. package/dist/plugins/LinksPlugin/types.d.ts +18 -0
  223. package/dist/plugins/LinksPlugin/types.js +0 -0
  224. package/dist/plugins/ListsPlugin/ListsPlugin.d.ts +32 -0
  225. package/dist/plugins/ListsPlugin/ListsPlugin.js +218 -0
  226. package/dist/plugins/ListsPlugin/index.d.ts +1 -0
  227. package/dist/plugins/ListsPlugin/index.js +2 -0
  228. package/dist/plugins/ListsPlugin/styles.module.js +6 -0
  229. package/dist/plugins/ListsPlugin/styles_module.css +8 -0
  230. package/dist/plugins/MenuPlugin/Menu.d.ts +2 -0
  231. package/dist/plugins/MenuPlugin/Menu.js +14 -0
  232. package/dist/plugins/MenuPlugin/MenuPlugin.d.ts +7 -0
  233. package/dist/plugins/MenuPlugin/MenuPlugin.js +19 -0
  234. package/dist/plugins/MenuPlugin/index.d.ts +1 -0
  235. package/dist/plugins/MenuPlugin/index.js +2 -0
  236. package/dist/plugins/MenuPlugin/styles.module.js +6 -0
  237. package/dist/plugins/MenuPlugin/styles_module.css +33 -0
  238. package/dist/plugins/MenuPlugin/types.d.ts +4 -0
  239. package/dist/plugins/MenuPlugin/types.js +0 -0
  240. package/dist/plugins/NodeIdPlugin/NodeIdPlugin.d.ts +15 -0
  241. package/dist/plugins/NodeIdPlugin/NodeIdPlugin.js +36 -0
  242. package/dist/plugins/NodeIdPlugin/index.d.ts +1 -0
  243. package/dist/plugins/NodeIdPlugin/index.js +2 -0
  244. package/dist/plugins/PlaceholderPlugin/PlaceholderPlugin.d.ts +16 -0
  245. package/dist/plugins/PlaceholderPlugin/PlaceholderPlugin.js +44 -0
  246. package/dist/plugins/PlaceholderPlugin/index.d.ts +1 -0
  247. package/dist/plugins/PlaceholderPlugin/index.js +2 -0
  248. package/dist/plugins/PlaceholderPlugin/styles.module.js +5 -0
  249. package/dist/plugins/PlaceholderPlugin/styles_module.css +14 -0
  250. package/dist/plugins/ShortcutsPlugin/ShortcutsPlugin.d.ts +24 -0
  251. package/dist/plugins/ShortcutsPlugin/ShortcutsPlugin.js +55 -0
  252. package/dist/plugins/ShortcutsPlugin/index.d.ts +2 -0
  253. package/dist/plugins/ShortcutsPlugin/index.js +2 -0
  254. package/dist/plugins/TableOfContentsPlugin/TableOfContentsPlugin.d.ts +18 -0
  255. package/dist/plugins/TableOfContentsPlugin/TableOfContentsPlugin.js +76 -0
  256. package/dist/plugins/TableOfContentsPlugin/index.d.ts +1 -0
  257. package/dist/plugins/TableOfContentsPlugin/index.js +2 -0
  258. package/dist/plugins/TableOfContentsPlugin/styles.module.js +10 -0
  259. package/dist/plugins/TableOfContentsPlugin/styles_module.css +114 -0
  260. package/dist/plugins/index.d.ts +16 -0
  261. package/dist/plugins/index.js +17 -0
  262. package/dist/queries/getMatchedGroups.d.ts +0 -0
  263. package/dist/queries/getMatchedGroups.js +0 -0
  264. package/dist/types.d.ts +50 -0
  265. package/dist/types.js +0 -0
  266. package/dist/utils.d.ts +2 -0
  267. package/dist/utils.js +8 -0
  268. package/package.json +71 -0
  269. package/src/constants.ts +1 -0
  270. package/src/core/createEditable.tsx +159 -0
  271. package/src/core/createEditor.ts +244 -0
  272. package/src/core/deserialize.ts +57 -0
  273. package/src/core/queries.ts +10 -0
  274. package/src/core/serialize.ts +38 -0
  275. package/src/core/styles.module.css +28 -0
  276. package/src/defaultValue.ts +10 -0
  277. package/src/editor.tsx +55 -0
  278. package/src/elements/BaseElement.tsx +5 -0
  279. package/src/examples/Backdrop.module.css +8 -0
  280. package/src/examples/Backdrop.tsx +16 -0
  281. package/src/examples/DragBlock.module.css +42 -0
  282. package/src/examples/DragBlock.tsx +57 -0
  283. package/src/examples/DragHandler.module.css +17 -0
  284. package/src/examples/DragHandler.tsx +39 -0
  285. package/src/examples/Editor.module.css +130 -0
  286. package/src/examples/Editor.tsx +26 -0
  287. package/src/examples/FloatingMenu.module.css +74 -0
  288. package/src/examples/FloatingMenu.tsx +274 -0
  289. package/src/examples/LanguageSelector.module.css +51 -0
  290. package/src/examples/LanguageSelector.tsx +99 -0
  291. package/src/examples/LinksHint.module.css +27 -0
  292. package/src/examples/LinksHint.tsx +58 -0
  293. package/src/examples/Menu.module.css +37 -0
  294. package/src/examples/Menu.tsx +80 -0
  295. package/src/examples/colors.ts +11 -0
  296. package/src/examples/getCommands.tsx +76 -0
  297. package/src/examples/getPlugins.tsx +143 -0
  298. package/src/examples/getShortcuts.ts +107 -0
  299. package/src/examples/icons/bold.tsx +20 -0
  300. package/src/examples/icons/check.tsx +19 -0
  301. package/src/examples/icons/chevronRight.tsx +19 -0
  302. package/src/examples/icons/color.tsx +23 -0
  303. package/src/examples/icons/copy.tsx +20 -0
  304. package/src/examples/icons/cross.tsx +20 -0
  305. package/src/examples/icons/drag.tsx +24 -0
  306. package/src/examples/icons/edit.tsx +21 -0
  307. package/src/examples/icons/external.tsx +21 -0
  308. package/src/examples/icons/heading1.tsx +26 -0
  309. package/src/examples/icons/heading2.tsx +26 -0
  310. package/src/examples/icons/heading3.tsx +27 -0
  311. package/src/examples/icons/italic.tsx +21 -0
  312. package/src/examples/icons/link.tsx +21 -0
  313. package/src/examples/icons/ol.tsx +23 -0
  314. package/src/examples/icons/strikethrough.tsx +20 -0
  315. package/src/examples/icons/text.tsx +18 -0
  316. package/src/examples/icons/types.ts +3 -0
  317. package/src/examples/icons/ul.tsx +24 -0
  318. package/src/examples/icons/underline.tsx +20 -0
  319. package/src/examples/store.ts +14 -0
  320. package/src/examples/styles.module.css +77 -0
  321. package/src/examples/text.tsx +133 -0
  322. package/src/examples/ui/Button/Button.tsx +34 -0
  323. package/src/examples/ui/Button/ButtonWrapper.tsx +22 -0
  324. package/src/examples/ui/Button/index.ts +2 -0
  325. package/src/examples/ui/Button/styles.module.css +75 -0
  326. package/src/examples/ui/Button/types.ts +1 -0
  327. package/src/examples/ui/Dropdown/Dropdown.tsx +101 -0
  328. package/src/examples/ui/Dropdown/index.ts +1 -0
  329. package/src/examples/ui/Menu/Menu.tsx +576 -0
  330. package/src/examples/ui/Menu/MenuDelimiter.tsx +3 -0
  331. package/src/examples/ui/Menu/MenuHotkey.tsx +17 -0
  332. package/src/examples/ui/Menu/MenuIcon.tsx +17 -0
  333. package/src/examples/ui/Menu/MenuItem.tsx +45 -0
  334. package/src/examples/ui/Menu/MenuTitle.tsx +17 -0
  335. package/src/examples/ui/Menu/SafeSpace.tsx +84 -0
  336. package/src/examples/ui/Menu/index.ts +2 -0
  337. package/src/examples/ui/Menu/styles.module.css +143 -0
  338. package/src/examples/ui/Menu/types.ts +18 -0
  339. package/src/examples/ui/useMenuPosition.ts +72 -0
  340. package/src/examples/ui/useMergeRefs.ts +39 -0
  341. package/src/index.ts +2 -0
  342. package/src/plugins/AttachmentsPlugin/AttachmentsPlugin.tsx +41 -0
  343. package/src/plugins/AttachmentsPlugin/index.ts +1 -0
  344. package/src/plugins/AttachmentsPlugin/types.ts +12 -0
  345. package/src/plugins/BasicFormattingPlugin/BasicFormattingPlugin.tsx +100 -0
  346. package/src/plugins/BasicFormattingPlugin/index.ts +1 -0
  347. package/src/plugins/BreaksPlugin/BreaksPlugin.tsx +70 -0
  348. package/src/plugins/BreaksPlugin/index.ts +1 -0
  349. package/src/plugins/CodeBlockPlugin/CodeBlock.tsx +20 -0
  350. package/src/plugins/CodeBlockPlugin/CodeBlockLine.tsx +7 -0
  351. package/src/plugins/CodeBlockPlugin/CodeBlockPlugin.tsx +304 -0
  352. package/src/plugins/CodeBlockPlugin/index.ts +1 -0
  353. package/src/plugins/CodeBlockPlugin/styles.module.css +11 -0
  354. package/src/plugins/CodeBlockPlugin/types.ts +10 -0
  355. package/src/plugins/CodeBlockPlugin/utils.ts +117 -0
  356. package/src/plugins/CommandsPlugin/CommandsPlugin.tsx +99 -0
  357. package/src/plugins/CommandsPlugin/Menu.tsx +205 -0
  358. package/src/plugins/CommandsPlugin/actions.ts +41 -0
  359. package/src/plugins/CommandsPlugin/index.ts +2 -0
  360. package/src/plugins/CommandsPlugin/styles.module.css +69 -0
  361. package/src/plugins/CommandsPlugin/types.ts +32 -0
  362. package/src/plugins/DnDPlugin/DnDPlugin.tsx +200 -0
  363. package/src/plugins/DnDPlugin/index.ts +1 -0
  364. package/src/plugins/DnDPlugin/styles.module.css +42 -0
  365. package/src/plugins/FloatingMenuPlugin/FloatingMenu.tsx +144 -0
  366. package/src/plugins/FloatingMenuPlugin/FloatingMenuPlugin.tsx +44 -0
  367. package/src/plugins/FloatingMenuPlugin/index.ts +2 -0
  368. package/src/plugins/FloatingMenuPlugin/styles.module.css +22 -0
  369. package/src/plugins/FloatingMenuPlugin/types.ts +18 -0
  370. package/src/plugins/HeadingsPlugin/HeadingsPlugin.tsx +75 -0
  371. package/src/plugins/HeadingsPlugin/index.ts +1 -0
  372. package/src/plugins/HighlightsPlugin/HighlightsPlugin.tsx +56 -0
  373. package/src/plugins/HighlightsPlugin/index.ts +1 -0
  374. package/src/plugins/LinksPlugin/Link.tsx +90 -0
  375. package/src/plugins/LinksPlugin/LinksPlugin.tsx +128 -0
  376. package/src/plugins/LinksPlugin/constants.ts +1 -0
  377. package/src/plugins/LinksPlugin/index.ts +2 -0
  378. package/src/plugins/LinksPlugin/styles.module.css +73 -0
  379. package/src/plugins/LinksPlugin/types.ts +19 -0
  380. package/src/plugins/ListsPlugin/ListsPlugin.tsx +355 -0
  381. package/src/plugins/ListsPlugin/index.ts +1 -0
  382. package/src/plugins/ListsPlugin/styles.module.css +7 -0
  383. package/src/plugins/MenuPlugin/Menu.tsx +9 -0
  384. package/src/plugins/MenuPlugin/MenuPlugin.tsx +20 -0
  385. package/src/plugins/MenuPlugin/index.ts +1 -0
  386. package/src/plugins/MenuPlugin/styles.module.css +33 -0
  387. package/src/plugins/MenuPlugin/types.ts +5 -0
  388. package/src/plugins/NodeIdPlugin/NodeIdPlugin.ts +62 -0
  389. package/src/plugins/NodeIdPlugin/index.ts +1 -0
  390. package/src/plugins/PlaceholderPlugin/PlaceholderPlugin.tsx +66 -0
  391. package/src/plugins/PlaceholderPlugin/index.ts +1 -0
  392. package/src/plugins/PlaceholderPlugin/styles.module.css +17 -0
  393. package/src/plugins/ShortcutsPlugin/ShortcutsPlugin.tsx +133 -0
  394. package/src/plugins/ShortcutsPlugin/index.ts +2 -0
  395. package/src/plugins/TableOfContentsPlugin/TableOfContentsPlugin.tsx +102 -0
  396. package/src/plugins/TableOfContentsPlugin/index.ts +1 -0
  397. package/src/plugins/TableOfContentsPlugin/styles.module.css +113 -0
  398. package/src/plugins/index.ts +20 -0
  399. package/src/queries/getMatchedGroups.ts +0 -0
  400. package/src/types.ts +87 -0
  401. package/src/utils.ts +15 -0
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # Rslib project
2
+
3
+ ## Setup
4
+
5
+ Install the dependencies:
6
+
7
+ ```bash
8
+ pnpm install
9
+ ```
10
+
11
+ ## Get started
12
+
13
+ Build the library:
14
+
15
+ ```bash
16
+ pnpm build
17
+ ```
18
+
19
+ Build the library in watch mode:
20
+
21
+ ```bash
22
+ pnpm dev
23
+ ```
@@ -0,0 +1 @@
1
+ export declare const ELEMENT_PARAGRAPH = "paragraph";
@@ -0,0 +1,2 @@
1
+ const ELEMENT_PARAGRAPH = 'paragraph';
2
+ export { ELEMENT_PARAGRAPH };
@@ -0,0 +1,7 @@
1
+ import type { Editor } from 'slate';
2
+ import type { IPlugin } from '../types';
3
+ type Props = {
4
+ readOnly?: boolean;
5
+ };
6
+ export declare const createEditable: (editor: Editor, plugins: IPlugin[]) => ({ readOnly }: Props) => import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,110 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import is_hotkey from "is-hotkey";
3
+ import react, { isValidElement, useCallback } from "react";
4
+ import { Editable, useReadOnly } from "slate-react";
5
+ import { BaseElement } from "../elements/BaseElement.js";
6
+ import styles_module from "./styles.module.js";
7
+ const SUPPORTED_HANDLERS = [
8
+ 'onDrop',
9
+ 'onKeyDown',
10
+ 'onPaste'
11
+ ];
12
+ const createEditable = (editor, plugins)=>({ readOnly })=>{
13
+ const renderElement = (props)=>{
14
+ let result = null;
15
+ for (const plugin of plugins)for (const element of plugin.blocks || []){
16
+ if (element.type !== props.element.type) continue;
17
+ const newElement = element.render(props, editor);
18
+ result = newElement || result;
19
+ }
20
+ for (const plugin of plugins)if (plugin.renderBlock) result = plugin.renderBlock({
21
+ ...props,
22
+ children: result || props.children
23
+ });
24
+ return result || /*#__PURE__*/ jsx(BaseElement, {
25
+ ...props
26
+ });
27
+ };
28
+ const renderLeaf = (props)=>{
29
+ let result;
30
+ for (const plugin of plugins)plugin.leafs?.map((element)=>{
31
+ const newElement = element.render({
32
+ ...props,
33
+ children: result || props.children
34
+ }, editor);
35
+ if (newElement && /*#__PURE__*/ isValidElement(newElement)) result = newElement;
36
+ });
37
+ return result;
38
+ };
39
+ const handleHotkey = (event)=>{
40
+ for (const plugin of plugins)if (plugin.hotkeys) {
41
+ for (const hotkey of plugin.hotkeys)if (is_hotkey(hotkey[0], event) && hotkey[1]) {
42
+ event.preventDefault();
43
+ hotkey[1](event, editor);
44
+ }
45
+ }
46
+ };
47
+ const decorate = (entry)=>{
48
+ const decorators = plugins.filter((plugin)=>!!plugin.decorate);
49
+ return decorators.reduce((decorations, plugin)=>{
50
+ const pluginDecorators = plugin.decorate?.(entry) || [];
51
+ return decorations.concat(pluginDecorators);
52
+ }, []);
53
+ };
54
+ const handlers = plugins.reduce((handlers, plugin)=>{
55
+ SUPPORTED_HANDLERS.forEach((handlerName)=>{
56
+ if (plugin.handlers?.[handlerName]) {
57
+ const lastHandler = handlers[handlerName];
58
+ if (lastHandler) handlers[handlerName] = (event)=>{
59
+ lastHandler(event, editor);
60
+ plugin.handlers?.[handlerName](event, editor);
61
+ };
62
+ else handlers[handlerName] = (event)=>{
63
+ plugin.handlers?.[handlerName](event, editor);
64
+ };
65
+ }
66
+ });
67
+ return handlers;
68
+ }, {
69
+ onKeyDown: handleHotkey
70
+ });
71
+ const Ui = useCallback(({ children })=>{
72
+ const ui = plugins.filter((p)=>Boolean(p.ui));
73
+ const readOnly = useReadOnly();
74
+ if (!ui.length) return /*#__PURE__*/ jsx("div", {
75
+ className: styles_module.editor,
76
+ children: children
77
+ });
78
+ return /*#__PURE__*/ jsxs(Fragment, {
79
+ children: [
80
+ ui.map((p, index)=>/*#__PURE__*/ jsx(react.Fragment, {
81
+ children: p.ui({
82
+ readOnly,
83
+ children,
84
+ editor
85
+ })
86
+ }, index)),
87
+ /*#__PURE__*/ jsx("div", {
88
+ className: styles_module.editor,
89
+ children: children
90
+ })
91
+ ]
92
+ });
93
+ }, [
94
+ editor,
95
+ plugins.filter
96
+ ]);
97
+ return /*#__PURE__*/ jsx("div", {
98
+ className: styles_module.root,
99
+ children: /*#__PURE__*/ jsx(Ui, {
100
+ children: /*#__PURE__*/ jsx(Editable, {
101
+ decorate: decorate,
102
+ renderElement: renderElement,
103
+ renderLeaf: renderLeaf,
104
+ readOnly: readOnly,
105
+ ...handlers
106
+ })
107
+ })
108
+ });
109
+ };
110
+ export { createEditable };
@@ -0,0 +1,2 @@
1
+ import type { IPlugin } from '../types';
2
+ export declare const createEditor: (plugins: IPlugin[]) => () => import("slate").BaseEditor & import("slate-react").ReactEditor;
@@ -0,0 +1,167 @@
1
+ import { Editor, Path, Range, Transforms, createEditor } from "slate";
2
+ import { withHistory } from "slate-history";
3
+ import { withReact } from "slate-react";
4
+ const createEditor_createEditor = (plugins)=>()=>{
5
+ const baseEditor = withHistory(withReact(createEditor()));
6
+ const editorWithPlugins = plugins.reduce((editor, plugin)=>{
7
+ if (plugin.init) return plugin.init(editor);
8
+ return editor;
9
+ }, baseEditor);
10
+ const { isInline, isVoid, normalizeNode, deleteFragment, deleteBackward, deleteForward } = editorWithPlugins;
11
+ editorWithPlugins.normalizeNode = (entry)=>{
12
+ const [node, path] = entry;
13
+ const lastElement = editorWithPlugins.children[editorWithPlugins.children.length - 1];
14
+ if (!lastElement || 'paragraph' !== lastElement.type) {
15
+ const paragraph = {
16
+ type: 'paragraph',
17
+ children: [
18
+ {
19
+ text: ''
20
+ }
21
+ ]
22
+ };
23
+ Transforms.insertNodes(editorWithPlugins, paragraph, {
24
+ at: [
25
+ editorWithPlugins.children.length
26
+ ]
27
+ });
28
+ }
29
+ return normalizeNode([
30
+ node,
31
+ path
32
+ ]);
33
+ };
34
+ editorWithPlugins.isVoid = (element)=>{
35
+ const result = plugins.reduce((result, plugin)=>{
36
+ const match = plugin.blocks?.find((el)=>element?.type === el.type);
37
+ if (match && 'isVoid' in match) return match.isVoid;
38
+ return result;
39
+ }, void 0);
40
+ return result ?? isVoid(element);
41
+ };
42
+ editorWithPlugins.isInline = (element)=>{
43
+ const result = plugins.reduce((result, plugin)=>{
44
+ const match = plugin.blocks?.find((el)=>element?.type === el.type);
45
+ if (match && 'isInline' in match) return match.isInline;
46
+ return result;
47
+ }, void 0);
48
+ return result ?? isInline(element);
49
+ };
50
+ editorWithPlugins.deleteForward = async (unit)=>{
51
+ const { selection } = editorWithPlugins;
52
+ if (!selection) return;
53
+ if (Range.isCollapsed(selection)) {
54
+ const firstEntry = Editor.above(editorWithPlugins, {
55
+ at: selection.anchor,
56
+ match: (n)=>Editor.isBlock(editorWithPlugins, n),
57
+ mode: 'lowest'
58
+ });
59
+ if (!firstEntry) return;
60
+ const [, currentPath] = firstEntry;
61
+ const secondEntry = Editor.above(editorWithPlugins, {
62
+ at: Editor.after(editorWithPlugins, selection.anchor),
63
+ match: (n)=>Editor.isBlock(editorWithPlugins, n),
64
+ mode: 'lowest'
65
+ });
66
+ if (!secondEntry) return;
67
+ const [node, path] = secondEntry;
68
+ if (node && Editor.isStart(editorWithPlugins, selection.anchor, currentPath)) {
69
+ const matchedBlock = plugins.reduce((block, plugin)=>{
70
+ const match = plugin.blocks?.find((b)=>b.type === node.type);
71
+ return block || match || null;
72
+ }, null);
73
+ if (matchedBlock) {
74
+ const result = matchedBlock.onBeforeDelete ? await matchedBlock?.onBeforeDelete?.([
75
+ node
76
+ ]) : true;
77
+ if (result) {
78
+ Transforms.removeNodes(editorWithPlugins, {
79
+ at: path
80
+ });
81
+ matchedBlock.onDelete?.([
82
+ node
83
+ ]);
84
+ }
85
+ return;
86
+ }
87
+ }
88
+ }
89
+ deleteForward(unit);
90
+ };
91
+ editorWithPlugins.deleteBackward = async (unit)=>{
92
+ const { selection } = editorWithPlugins;
93
+ if (!selection) return;
94
+ if (Range.isCollapsed(selection)) {
95
+ const firstEntry = Editor.above(editorWithPlugins, {
96
+ at: selection.anchor,
97
+ match: (n)=>Editor.isBlock(editorWithPlugins, n),
98
+ mode: 'lowest'
99
+ });
100
+ const secondEntry = Editor.above(editorWithPlugins, {
101
+ at: Editor.before(editorWithPlugins, selection.anchor),
102
+ match: (n)=>Editor.isBlock(editorWithPlugins, n),
103
+ mode: 'lowest'
104
+ });
105
+ if (!firstEntry || !secondEntry) return;
106
+ const [_, currentPath] = firstEntry;
107
+ const [node, path] = secondEntry;
108
+ if (node && Editor.isStart(editorWithPlugins, selection.anchor, currentPath)) {
109
+ const matchedBlock = plugins.reduce((block, plugin)=>{
110
+ const match = plugin.blocks?.find((b)=>b.type === node.type);
111
+ return block || match || null;
112
+ }, null);
113
+ if (matchedBlock) {
114
+ const result = matchedBlock.onBeforeDelete ? await matchedBlock.onBeforeDelete([
115
+ node
116
+ ]) : true;
117
+ if (result) {
118
+ Transforms.removeNodes(editorWithPlugins, {
119
+ at: path
120
+ });
121
+ matchedBlock.onDelete?.([
122
+ node
123
+ ]);
124
+ }
125
+ return;
126
+ }
127
+ }
128
+ }
129
+ deleteBackward(unit);
130
+ };
131
+ editorWithPlugins.deleteFragment = async (options)=>{
132
+ const { selection } = editorWithPlugins;
133
+ if (!selection) return;
134
+ const [start, end] = Range.edges(selection);
135
+ const isSingleText = Path.equals(start.path, end.path);
136
+ if (isSingleText) return void deleteFragment(options);
137
+ const nodes = Array.from(Editor.nodes(editorWithPlugins, {
138
+ at: selection,
139
+ match: (n)=>!Editor.isEditor(n) && Editor.isBlock(editorWithPlugins, n)
140
+ })).reverse();
141
+ for (const entry of nodes){
142
+ const [node, path] = entry;
143
+ const plugin = plugins.find((plugin)=>plugin.blocks?.find((b)=>b.type === node.type));
144
+ if (plugin) {
145
+ const match = plugin.blocks?.find((b)=>b.type === node.type);
146
+ const result = match?.onBeforeDelete ? await match.onBeforeDelete([
147
+ node
148
+ ]) : true;
149
+ if (!result) return;
150
+ Transforms.removeNodes(editorWithPlugins, {
151
+ at: path,
152
+ match: (n)=>n.type === node.type
153
+ });
154
+ match?.onDelete?.([
155
+ node
156
+ ]);
157
+ } else Transforms.removeNodes(editorWithPlugins, {
158
+ at: path,
159
+ match: (n)=>n.type === node.type
160
+ });
161
+ }
162
+ if (nodes.length > 0) return;
163
+ deleteFragment(options);
164
+ };
165
+ return editorWithPlugins;
166
+ };
167
+ export { createEditor_createEditor as createEditor };
@@ -0,0 +1,3 @@
1
+ import { type Descendant } from 'slate';
2
+ import type { IPlugin } from '../types';
3
+ export declare const deserialize: (plugins: IPlugin[]) => (element: HTMLElement) => (Descendant | string)[] | string | Descendant | null;
@@ -0,0 +1,33 @@
1
+ import { Element } from "slate";
2
+ import { jsx } from "slate-hyperscript";
3
+ const deserialize = (plugins)=>(element)=>{
4
+ if (3 === element.nodeType) return element.textContent;
5
+ if (1 !== element.nodeType) return null;
6
+ if ('BR' === element.nodeName) return '\n';
7
+ let children = Array.from(element.childNodes).flatMap((node)=>deserialize(plugins)(node));
8
+ if (0 === children.length) children = [
9
+ {
10
+ text: ''
11
+ }
12
+ ];
13
+ if ('BODY' === element.nodeName) if (children.some((c)=>Element.isElement(c))) return jsx('fragment', {}, children);
14
+ else return jsx('element', {
15
+ type: 'paragraph'
16
+ }, children);
17
+ if ('P' === element.nodeName) return jsx('element', {
18
+ type: 'paragraph'
19
+ }, children);
20
+ let result = null;
21
+ for (const plugin of plugins){
22
+ if (plugin.blocks?.some((b)=>b.deserialize)) plugin.blocks.forEach((e)=>{
23
+ if (e.deserialize) {
24
+ const childrenAsDescendants = children;
25
+ const newResult = e.deserialize(element, childrenAsDescendants);
26
+ if (newResult) result = newResult;
27
+ }
28
+ });
29
+ if (result) return result;
30
+ }
31
+ return children.filter((child)=>null !== child);
32
+ };
33
+ export { deserialize };
@@ -0,0 +1,2 @@
1
+ import { Editor, NodeEntry, Node } from 'slate';
2
+ export declare const getPrev: (editor: Editor, node: NodeEntry) => Node | null;
@@ -0,0 +1,10 @@
1
+ import { Node, Path } from "slate";
2
+ const getPrev = (editor, node)=>{
3
+ try {
4
+ const [, path] = node;
5
+ return Node.get(editor, Path.previous(path));
6
+ } catch (e) {
7
+ return null;
8
+ }
9
+ };
10
+ export { getPrev };
@@ -0,0 +1,3 @@
1
+ import type { CustomElement, CustomText } from '../../types';
2
+ import type { IPlugin } from '../types';
3
+ export declare const serialize: (plugins: IPlugin[]) => (node: CustomElement | CustomElement[] | CustomText | CustomText[]) => string;
@@ -0,0 +1,13 @@
1
+ import escape_html from "escape-html";
2
+ import { Text } from "slate";
3
+ const serialize = (plugins)=>(node)=>{
4
+ const serializers = plugins.flatMap((plugin)=>plugin.blocks?.map((element)=>element.serialize)).filter(Boolean);
5
+ if (Array.isArray(node)) return node.map(serialize(plugins)).join('');
6
+ if (Text.isText(node)) return serializers.reduce((prev, current)=>current?.(node) || prev, escape_html(node.text));
7
+ {
8
+ const children = node.children?.map((n)=>serialize(plugins)(n)).join('');
9
+ if ('paragraph' === node.type) return `<p>${children}</p>`;
10
+ return serializers.reduce((prev, current)=>current?.(node, children) || prev, '') || children;
11
+ }
12
+ };
13
+ export { serialize };
@@ -0,0 +1,6 @@
1
+ import "./styles_module.css";
2
+ const styles_module = {
3
+ root: "root-e1gdll",
4
+ editor: "editor-K2itFp"
5
+ };
6
+ export { styles_module as default };
@@ -0,0 +1,29 @@
1
+ .root-e1gdll {
2
+ height: 100%;
3
+ color: var(--kona-editor-text-color, #444);
4
+ background-color: var(--kona-editor-background-color, #fff);
5
+ flex-direction: column;
6
+ display: flex;
7
+ position: relative;
8
+ }
9
+
10
+ .editor-K2itFp {
11
+ outline: none;
12
+ overflow: auto;
13
+
14
+ &::-webkit-scrollbar {
15
+ background: #00000006;
16
+ border-radius: 8px;
17
+ width: 4px;
18
+ }
19
+
20
+ &::-webkit-scrollbar-thumb {
21
+ background: #00000013;
22
+ border-radius: 8px;
23
+ }
24
+
25
+ & > [role="textbox"] {
26
+ outline: none;
27
+ }
28
+ }
29
+
@@ -0,0 +1,4 @@
1
+ import type { Descendant } from 'slate';
2
+ export declare const defaultValue: {
3
+ children: Descendant[];
4
+ };
@@ -0,0 +1,13 @@
1
+ const defaultValue = {
2
+ children: [
3
+ {
4
+ type: 'paragraph',
5
+ children: [
6
+ {
7
+ text: ''
8
+ }
9
+ ]
10
+ }
11
+ ]
12
+ };
13
+ export { defaultValue };
@@ -0,0 +1,10 @@
1
+ import { type Descendant } from 'slate';
2
+ import type { EditorRef, IPlugin } from './types';
3
+ type KonaEditorProps = {
4
+ readOnly?: boolean;
5
+ plugins?: IPlugin[];
6
+ initialValue: Descendant[];
7
+ onChange: (value: Descendant[]) => void;
8
+ };
9
+ export declare const KonaEditor: import("react").ForwardRefExoticComponent<KonaEditorProps & import("react").RefAttributes<EditorRef>>;
10
+ export {};
package/dist/editor.js ADDED
@@ -0,0 +1,43 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useCallback, useImperativeHandle, useState } from "react";
3
+ import { Transforms } from "slate";
4
+ import { ReactEditor, Slate } from "slate-react";
5
+ import { createEditable } from "./core/createEditable.js";
6
+ import { createEditor } from "./core/createEditor.js";
7
+ import { deserialize } from "./core/deserialize.js";
8
+ import { serialize } from "./core/serialize.js";
9
+ import { isEmpty } from "./utils.js";
10
+ const KonaEditor = /*#__PURE__*/ forwardRef((props, ref)=>{
11
+ const { initialValue, plugins = [], readOnly = false, onChange } = props;
12
+ const [editor] = useState(createEditor(plugins));
13
+ const SlateEditable = useCallback(createEditable(editor, plugins), []);
14
+ useImperativeHandle(ref, ()=>{
15
+ const deleteNode = (match)=>{
16
+ Transforms.removeNodes(editor, {
17
+ at: [],
18
+ match
19
+ });
20
+ };
21
+ return {
22
+ serialize: serialize(plugins),
23
+ deserialize: deserialize(plugins),
24
+ deleteNode,
25
+ isEmpty: ()=>isEmpty(editor.children),
26
+ focus: ()=>{
27
+ ReactEditor.focus(editor);
28
+ }
29
+ };
30
+ }, [
31
+ editor,
32
+ plugins
33
+ ]);
34
+ return /*#__PURE__*/ jsx(Slate, {
35
+ editor: editor,
36
+ initialValue: initialValue,
37
+ onValueChange: onChange,
38
+ children: /*#__PURE__*/ jsx(SlateEditable, {
39
+ readOnly: readOnly
40
+ })
41
+ });
42
+ });
43
+ export { KonaEditor };
@@ -0,0 +1,2 @@
1
+ import { RenderElementProps } from 'slate-react';
2
+ export declare const BaseElement: (props: RenderElementProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ const BaseElement = (props)=>/*#__PURE__*/ jsx("p", {
3
+ ...props.attributes,
4
+ children: props.children
5
+ });
6
+ export { BaseElement };
@@ -0,0 +1,5 @@
1
+ type Props = {
2
+ onClose: () => void;
3
+ };
4
+ export declare const Backdrop: (props: Props) => import("react/jsx-runtime").JSX.Element | null;
5
+ export {};
@@ -0,0 +1,13 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useStore } from "@nanostores/react";
3
+ import Backdrop_module from "./Backdrop.module.js";
4
+ import { $store } from "./store.js";
5
+ const Backdrop = (props)=>{
6
+ const { isFloatingMenuOpen } = useStore($store);
7
+ const { onClose } = props;
8
+ return isFloatingMenuOpen ? /*#__PURE__*/ jsx("div", {
9
+ className: Backdrop_module.root,
10
+ onClick: onClose
11
+ }) : null;
12
+ };
13
+ export { Backdrop };
@@ -0,0 +1,5 @@
1
+ import "./Backdrop_module.css";
2
+ const Backdrop_module = {
3
+ root: "root-f5Zwn7"
4
+ };
5
+ export { Backdrop_module as default };
@@ -0,0 +1,6 @@
1
+ .root-f5Zwn7 {
2
+ z-index: 1;
3
+ position: fixed;
4
+ inset: 0;
5
+ }
6
+
@@ -0,0 +1,11 @@
1
+ import type { ConnectDragPreview, ConnectDragSource, ConnectDropTarget } from 'react-dnd';
2
+ import type { RenderElementProps } from 'slate-react';
3
+ type Props = {
4
+ props: RenderElementProps;
5
+ dragRef: ConnectDragSource;
6
+ dropRef: ConnectDropTarget;
7
+ previewRef: ConnectDragPreview;
8
+ position: 'top' | 'bottom' | null;
9
+ };
10
+ export declare const DragBlock: (props: Props) => import("react/jsx-runtime").JSX.Element;
11
+ export {};
@@ -0,0 +1,38 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import clsx from "clsx";
3
+ import DragBlock_module from "./DragBlock.module.js";
4
+ import { DragHandler } from "./DragHandler.js";
5
+ const DragBlock = (props)=>{
6
+ const { props: { attributes, element, children }, dragRef: drag, dropRef: drop, previewRef: preview, position } = props;
7
+ return /*#__PURE__*/ jsx("div", {
8
+ className: clsx(DragBlock_module.root, {
9
+ [DragBlock_module.top]: 'top' === position,
10
+ [DragBlock_module.bottom]: 'bottom' === position
11
+ }),
12
+ ...attributes,
13
+ children: /*#__PURE__*/ jsxs("div", {
14
+ className: DragBlock_module.block,
15
+ ref: (e)=>{
16
+ drop(preview(e));
17
+ },
18
+ children: [
19
+ /*#__PURE__*/ jsx("div", {
20
+ className: DragBlock_module.drag,
21
+ ref: (element)=>{
22
+ drag(element);
23
+ },
24
+ contentEditable: false,
25
+ children: /*#__PURE__*/ jsx(DragHandler, {
26
+ attributes: attributes,
27
+ element: element,
28
+ children: children
29
+ })
30
+ }),
31
+ /*#__PURE__*/ jsx("div", {
32
+ children: children
33
+ })
34
+ ]
35
+ })
36
+ });
37
+ };
38
+ export { DragBlock };
@@ -0,0 +1,9 @@
1
+ import "./DragBlock_module.css";
2
+ const DragBlock_module = {
3
+ root: "root-QYAUnT",
4
+ top: "top-qIwygJ",
5
+ bottom: "bottom-K22AI8",
6
+ drag: "drag-v0MSZ1",
7
+ block: "block-y_k_tl"
8
+ };
9
+ export { DragBlock_module as default };
@@ -0,0 +1,43 @@
1
+ .root-QYAUnT {
2
+ border-top: 2px solid #0000;
3
+ border-bottom: 2px solid #0000;
4
+ position: relative;
5
+ }
6
+
7
+ .top-qIwygJ {
8
+ border-top: 2px solid #3498db;
9
+ }
10
+
11
+ .bottom-K22AI8 {
12
+ border-bottom: 2px solid #3498db;
13
+ }
14
+
15
+ .drag-v0MSZ1 {
16
+ vertical-align: baseline;
17
+ cursor: move;
18
+ opacity: 0;
19
+ width: 16px;
20
+ line-height: 1.2;
21
+ transition: opacity .25s;
22
+ display: inline-block;
23
+ }
24
+
25
+ .block-y_k_tl {
26
+ border-radius: 4px;
27
+ grid-template-columns: 16px 1fr;
28
+ align-items: start;
29
+ column-gap: 8px;
30
+ padding: 4px 8px;
31
+ transition: background-color .25s;
32
+ display: grid;
33
+ position: relative;
34
+
35
+ &:hover {
36
+ background-color: #00000004;
37
+ }
38
+
39
+ &:hover .drag-v0MSZ1 {
40
+ opacity: 1;
41
+ }
42
+ }
43
+
@@ -0,0 +1,2 @@
1
+ import type { RenderElementProps } from 'slate-react';
2
+ export declare const DragHandler: (props: RenderElementProps) => import("react/jsx-runtime").JSX.Element;