@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
@@ -0,0 +1,84 @@
1
+ import { useEffect, useState } from 'react';
2
+
3
+ type Props = {
4
+ debug?: boolean;
5
+ rect?: DOMRect;
6
+ };
7
+
8
+ export const SafeSpace = (props: Props) => {
9
+ const { rect, debug } = props;
10
+
11
+ const { x = 0, y = 0, height: h = 0, width: w = 0 } = rect || {};
12
+
13
+ const [mouseX, mouseY] = useMousePosition();
14
+
15
+ const isReversed = mouseX > x + w;
16
+ const width = isReversed ? mouseX - x - w : x - mouseX;
17
+ const height = h;
18
+
19
+ const style = {
20
+ width,
21
+ height: h,
22
+ top: y,
23
+ left: isReversed ? x + w : mouseX,
24
+ };
25
+
26
+ const points = isReversed
27
+ ? `0,0 ${width + 10},${mouseY - y} 0,${height}`
28
+ : `0,${mouseY - y} ${width},0 ${width},${height}`;
29
+
30
+ return (
31
+ <svg
32
+ style={{
33
+ ...style,
34
+ pointerEvents: 'none',
35
+ zIndex: 20,
36
+ position: 'fixed',
37
+ }}
38
+ >
39
+ {/* Safe Area */}
40
+ <polygon
41
+ points={points}
42
+ fill={debug ? 'rgba(0,0,0,0.25)' : 'transparent'}
43
+ pointerEvents="all"
44
+ />
45
+ </svg>
46
+ );
47
+ };
48
+
49
+ const useMousePosition = () => {
50
+ const [mousePosition, setMousePosition] = useState([0, 0]);
51
+
52
+ useEffect(() => {
53
+ const updateMousePosition = (ev: MouseEvent) => {
54
+ setMousePosition([ev.clientX, ev.clientY]);
55
+ };
56
+
57
+ const throttledUpdateMousePosition = throttle(updateMousePosition, 500);
58
+
59
+ document.addEventListener('mousemove', updateMousePosition, {
60
+ once: true,
61
+ });
62
+ document.addEventListener('mousemove', throttledUpdateMousePosition);
63
+
64
+ return () => {
65
+ document.removeEventListener('mousemove', updateMousePosition);
66
+ document.removeEventListener('mousemove', throttledUpdateMousePosition);
67
+ };
68
+ }, []);
69
+
70
+ return mousePosition;
71
+ };
72
+
73
+ function throttle(callback: (...args: any[]) => void, delay: number) {
74
+ let previousCall = Date.now();
75
+
76
+ return function (this: any, ...args: any[]) {
77
+ const time = Date.now();
78
+
79
+ if (time - previousCall >= delay) {
80
+ previousCall = time;
81
+ callback.apply(this, args);
82
+ }
83
+ };
84
+ }
@@ -0,0 +1,2 @@
1
+ export { Menu } from './Menu';
2
+ export type { MenuConfig, MenuItem } from './types';
@@ -0,0 +1,143 @@
1
+ .delimiter {
2
+ border-width: 1px 0 0 0;
3
+ border-style: solid;
4
+ border-color: var(--kona-editor-border-color);
5
+ width: 100%;
6
+ height: 1px;
7
+ margin: 0;
8
+ }
9
+
10
+ /* MenuItem styles */
11
+ .menuItemRoot {
12
+ list-style: none;
13
+ cursor: pointer;
14
+ padding: 0 4px;
15
+ margin: 0;
16
+ border-radius: 4px;
17
+ }
18
+
19
+ .menuItemRootNonSelectable {
20
+ cursor: default;
21
+ }
22
+
23
+ .menuItemContent {
24
+ border-radius: 4px;
25
+ padding: 8px 8px;
26
+ display: flex;
27
+ align-items: center;
28
+ gap: 4px;
29
+ user-select: none;
30
+ color: var(--kona-editor-text-color);
31
+ background-color: transparent;
32
+ }
33
+
34
+ .menuItemContentSelected {
35
+ color: #0066cc;
36
+ background-color: #e6f0ff;
37
+ }
38
+
39
+ .menuItemContentDanger {
40
+ color: #cc0000;
41
+ }
42
+
43
+ /* MenuIcon styles */
44
+ .menuIcon {
45
+ display: inline-flex;
46
+ width: 16px;
47
+ height: 16px;
48
+ align-items: center;
49
+ justify-content: center;
50
+ color: inherit;
51
+ }
52
+
53
+ /* MenuTitle styles */
54
+ .menuTitle {
55
+ flex-grow: 1;
56
+ min-width: 70px;
57
+ color: inherit;
58
+ }
59
+
60
+ /* MenuHotkey styles */
61
+ .menuHotkey {
62
+ display: inline-flex;
63
+ align-items: center;
64
+ justify-content: center;
65
+ background-color: rgba(0, 0, 0, 0.05);
66
+ border-radius: 4px;
67
+ padding: 0 4px;
68
+ }
69
+
70
+ /* Menu styles */
71
+ .menu {
72
+ position: absolute;
73
+ z-index: 13;
74
+ margin: 0;
75
+ padding: 4px 0;
76
+ background-color: var(--kona-editor-background-color);
77
+ border: 1px solid var(--kona-editor-border-color);
78
+ border-radius: 8px;
79
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
80
+ overflow: hidden;
81
+ box-sizing: border-box;
82
+ }
83
+
84
+ .menuVisible {
85
+ opacity: 1;
86
+ transform: scale(1);
87
+ }
88
+
89
+ .menuBody {
90
+ display: flex;
91
+ flex-direction: column;
92
+ height: 100%;
93
+ }
94
+
95
+ .menuScrollable {
96
+ overflow-y: auto;
97
+ overflow-x: hidden;
98
+ flex-grow: 1;
99
+ }
100
+
101
+ .menuScrollable::-webkit-scrollbar {
102
+ background: #f5f5f5;
103
+ width: 6px;
104
+ border-radius: 8px;
105
+ }
106
+
107
+ .menuScrollable::-webkit-scrollbar-thumb {
108
+ background: #cccccc;
109
+ border-radius: 8px;
110
+ }
111
+
112
+ .menuBackdrop {
113
+ position: fixed;
114
+ inset: 0;
115
+ z-index: 20;
116
+ background-color: rgba(0, 0, 0, 0.025);
117
+ }
118
+
119
+ .menuEnterAnimation {
120
+ animation: menuEnter 0.2s ease-in forwards;
121
+ }
122
+
123
+ @keyframes menuEnter {
124
+ from {
125
+ opacity: 0;
126
+ transform: scale(0.95);
127
+ }
128
+ to {
129
+ opacity: 1;
130
+ transform: scale(1);
131
+ }
132
+ }
133
+
134
+ @keyframes menuExit {
135
+ from {
136
+ opacity: 1;
137
+ transform: scale(1);
138
+ }
139
+ to {
140
+ opacity: 0;
141
+ transform: scale(0.95);
142
+ }
143
+ }
@@ -0,0 +1,18 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ export type MenuConfig = {
4
+ items?: MenuItem[];
5
+ header?: () => ReactNode;
6
+ footer?: () => ReactNode;
7
+ onOpen?: () => void;
8
+ onFocus?: () => void;
9
+ }
10
+
11
+ export type MenuItem = {
12
+ render: () => ReactNode;
13
+ selectable?: boolean;
14
+ autoClose?: boolean;
15
+ config?: MenuConfig;
16
+ danger?: boolean;
17
+ onSelect?: () => void;
18
+ }
@@ -0,0 +1,72 @@
1
+ import { useCallback, useState } from 'react';
2
+
3
+ export type Coords = [number, number];
4
+
5
+ type Point = {
6
+ x: number;
7
+ y: number;
8
+ };
9
+
10
+ class Context {
11
+ private readonly p: Point;
12
+ private rect: DOMRect;
13
+
14
+ constructor(p: Point, rect: DOMRect) {
15
+ this.p = { x: p.x, y: p.y };
16
+ this.rect = rect;
17
+ }
18
+
19
+ get point() {
20
+ return this.p;
21
+ }
22
+
23
+ helpers = {
24
+ isWithinWindow: (): [boolean, boolean] => {
25
+ const left = this.p.x + this.rect.width;
26
+
27
+ return [
28
+ left < document.documentElement.clientWidth,
29
+ this.p.y + this.rect.height < document.documentElement.clientHeight,
30
+ ];
31
+ },
32
+ };
33
+
34
+ flip = ([horizontal, vertical]: [boolean, boolean]) => {
35
+ if (horizontal) {
36
+ this.p.x -= this.rect.width;
37
+ }
38
+ if (vertical) {
39
+ this.p.y -= this.rect.height;
40
+ }
41
+
42
+ return this;
43
+ };
44
+
45
+ move = (x: number, y: number) => {
46
+ this.p.x += x;
47
+ this.p.y += y;
48
+
49
+ return this;
50
+ };
51
+ }
52
+
53
+ export const useMenuPosition = (point: Point, transform: (context: Context) => Point) => {
54
+ const [coords, setCoords] = useState<Point>(point);
55
+
56
+ const ref = useCallback(
57
+ (element: HTMLElement) => {
58
+ if (!element) {
59
+ return;
60
+ }
61
+
62
+ const rect = element.getBoundingClientRect();
63
+ const newCoords = transform(new Context(point, rect));
64
+ if (coords.x !== newCoords.x || coords.y !== newCoords.y) {
65
+ setCoords(newCoords);
66
+ }
67
+ },
68
+ [point.x, point.y],
69
+ );
70
+
71
+ return [ref, coords] as const;
72
+ };
@@ -0,0 +1,39 @@
1
+ import { useMemo } from 'react';
2
+
3
+ /**
4
+ * Merges multiple React refs into a single ref callback.
5
+ *
6
+ * @template T The type of the ref value
7
+ * @param {React.Ref<T>[]} refs Array of refs to merge (can be both callback refs and object refs)
8
+ * @returns {React.RefCallback<T> | null} A merged ref callback or null if all input refs are null
9
+ *
10
+ * @example
11
+ * function Component() {
12
+ * const firstRef = useRef<HTMLDivElement>(null)
13
+ * const secondRef = useRef<HTMLDivElement>(null)
14
+ * const forwardedRef = useForwardedRef<HTMLDivElement>(null)
15
+ *
16
+ * const mergedRef = useMergeRefs([firstRef, secondRef, forwardedRef])
17
+ *
18
+ * return (
19
+ * <div ref={mergedRef}>
20
+ * This div will be referenced by all three refs
21
+ * </div>
22
+ * )
23
+ * }
24
+ */
25
+ export const useMergeRefs = <T>(refs: React.Ref<T>[]) =>
26
+ useMemo(() => {
27
+ if (refs.every((ref) => ref == null)) {
28
+ return null;
29
+ }
30
+ return (refValue: T) => {
31
+ refs.forEach((ref) => {
32
+ if (typeof ref === 'function') {
33
+ ref(refValue);
34
+ } else if (ref != null) {
35
+ (ref as React.MutableRefObject<T | null>).current = refValue;
36
+ }
37
+ });
38
+ };
39
+ }, []);
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './editor';
2
+ export { ExampleEditor } from './examples/Editor';
@@ -0,0 +1,41 @@
1
+ import type { Editor } from 'slate';
2
+ import type { RenderElementProps } from 'slate-react';
3
+ import type { IPlugin } from '../../types';
4
+ import type { Options } from './types';
5
+
6
+ export class AttachmentsPlugin implements IPlugin {
7
+ constructor(private options: Options) {}
8
+
9
+ static ATTACHMENT_ELEMENT = 'attach';
10
+
11
+ handlers = {
12
+ onPaste: (event: ClipboardEvent, editor: Editor) => {
13
+ const items = Array.from(event.clipboardData?.items || []);
14
+ for (const item of items) {
15
+ if (item?.type.startsWith('image/')) {
16
+ const file = item.getAsFile();
17
+ if (file) {
18
+ this.options.onPaste?.(editor, file);
19
+ }
20
+ }
21
+ }
22
+ },
23
+ };
24
+
25
+ blocks = [
26
+ {
27
+ type: AttachmentsPlugin.ATTACHMENT_ELEMENT,
28
+ isVoid: true,
29
+ render: (props: RenderElementProps) => {
30
+ const { Attachment } = this.options;
31
+
32
+ return (
33
+ <div {...props.attributes} contentEditable={false}>
34
+ {props.children}
35
+ <Attachment {...props} />
36
+ </div>
37
+ );
38
+ },
39
+ },
40
+ ];
41
+ }
@@ -0,0 +1 @@
1
+ export { AttachmentsPlugin } from './AttachmentsPlugin';
@@ -0,0 +1,12 @@
1
+ import { Editor } from 'slate';
2
+ import { RenderElementProps } from 'slate-react';
3
+ import { ReactNode } from 'react';
4
+
5
+ export type Options = {
6
+ onDragEnter?: () => void;
7
+ onDragLeave?: () => void;
8
+ onPaste?: (editor: Editor, file: File) => void;
9
+ onDelete?: (editor: Editor, fileId?: string) => void;
10
+ onDownload?: (fileId: string) => void;
11
+ Attachment: (props: RenderElementProps) => ReactNode;
12
+ };
@@ -0,0 +1,100 @@
1
+ import { Editor } from 'slate';
2
+ import type { CustomElement, CustomText } from '../../../types';
3
+ import type { IPlugin } from '../../types';
4
+
5
+ type CustomLeaf = CustomText & {
6
+ bold?: boolean;
7
+ italic?: boolean;
8
+ underline?: boolean;
9
+ strikethrough?: boolean;
10
+ };
11
+
12
+ export class BasicFormattingPlugin
13
+ implements IPlugin<Editor, CustomElement, CustomLeaf>
14
+ {
15
+ hotkeys = [
16
+ ['cmd+b', (_, editor) => BasicFormattingPlugin.toggleBold(editor)] as const,
17
+ [
18
+ 'ctrl+b',
19
+ (_, editor) => BasicFormattingPlugin.toggleBold(editor),
20
+ ] as const,
21
+
22
+ [
23
+ 'cmd+i',
24
+ (_, editor) => BasicFormattingPlugin.toggleItalic(editor),
25
+ ] as const,
26
+ [
27
+ 'ctrl+i',
28
+ (_, editor) => BasicFormattingPlugin.toggleItalic(editor),
29
+ ] as const,
30
+
31
+ [
32
+ 'cmd+u',
33
+ (_, editor) => BasicFormattingPlugin.toggleUnderline(editor),
34
+ ] as const,
35
+ [
36
+ 'ctrl+u',
37
+ (_, editor) => BasicFormattingPlugin.toggleUnderline(editor),
38
+ ] as const,
39
+ ];
40
+
41
+ leafs: IPlugin<Editor, CustomElement, CustomLeaf>['leafs'] = [
42
+ {
43
+ render: (props) => {
44
+ const { leaf, attributes, children } = props;
45
+
46
+ let content = children;
47
+
48
+ if (leaf.bold) {
49
+ content = <strong>{content}</strong>;
50
+ }
51
+
52
+ if (leaf.italic) {
53
+ content = <em>{content}</em>;
54
+ }
55
+
56
+ if (leaf.underline) {
57
+ content = <u>{content}</u>;
58
+ }
59
+
60
+ if (leaf.strikethrough) {
61
+ content = <s>{content}</s>;
62
+ }
63
+
64
+ return <span {...attributes}>{content}</span>;
65
+ },
66
+ },
67
+ ];
68
+
69
+ static isMarkActive(editor: Editor, mark: keyof CustomLeaf) {
70
+ const marks: Record<string, boolean> | null = Editor.marks(editor);
71
+
72
+ return marks ? marks[mark] === true : false;
73
+ }
74
+
75
+ static toggleMark(editor: Editor, mark: keyof CustomLeaf) {
76
+ const isActive = BasicFormattingPlugin.isMarkActive(editor, mark);
77
+
78
+ if (isActive) {
79
+ editor.removeMark(mark);
80
+ } else {
81
+ editor.addMark(mark, true);
82
+ }
83
+ }
84
+
85
+ static toggleBold(editor: Editor) {
86
+ BasicFormattingPlugin.toggleMark(editor, 'bold');
87
+ }
88
+
89
+ static toggleItalic(editor: Editor) {
90
+ BasicFormattingPlugin.toggleMark(editor, 'italic');
91
+ }
92
+
93
+ static toggleUnderline(editor: Editor) {
94
+ BasicFormattingPlugin.toggleMark(editor, 'underline');
95
+ }
96
+
97
+ static toggleStrikethrough(editor: Editor) {
98
+ BasicFormattingPlugin.toggleMark(editor, 'strikethrough');
99
+ }
100
+ }
@@ -0,0 +1 @@
1
+ export { BasicFormattingPlugin } from './BasicFormattingPlugin';
@@ -0,0 +1,70 @@
1
+ import type { KeyboardEvent } from 'react';
2
+ import { Editor, Transforms } from 'slate';
3
+ import type { CustomElement } from '../../../types';
4
+ import type { IPlugin } from '../../types';
5
+
6
+ type Options = {
7
+ breakNodes: string[];
8
+ };
9
+
10
+ export class BreaksPlugin implements IPlugin {
11
+ constructor(private options: Options) {}
12
+
13
+ init(editor: Editor) {
14
+ const { insertBreak } = editor;
15
+
16
+ editor.insertBreak = () => {
17
+ const node = Editor.above<CustomElement>(editor, {
18
+ match: (n) => Editor.isBlock(editor, n as CustomElement),
19
+ mode: 'lowest',
20
+ });
21
+
22
+ if (!node) {
23
+ insertBreak();
24
+ return;
25
+ }
26
+
27
+ const [element, path] = node;
28
+
29
+ const { selection } = editor;
30
+ if (!selection) {
31
+ insertBreak();
32
+ return;
33
+ }
34
+
35
+ if (this.options.breakNodes.includes(element.type)) {
36
+ const { anchor } = selection;
37
+
38
+ const isStart = Editor.isStart(editor, anchor, path);
39
+
40
+ if (isStart) {
41
+ Transforms.insertNodes(editor, {
42
+ type: 'paragraph',
43
+ children: [{ text: '' }],
44
+ });
45
+ Transforms.move(editor);
46
+ return;
47
+ } else {
48
+ insertBreak();
49
+
50
+ Transforms.setNodes(editor, {
51
+ type: 'paragraph',
52
+ });
53
+ }
54
+ } else {
55
+ insertBreak();
56
+ }
57
+ };
58
+
59
+ return editor;
60
+ }
61
+
62
+ handlers = {
63
+ onKeyDown: (event: KeyboardEvent, editor: Editor) => {
64
+ if (event.key === 'Enter' && event.shiftKey) {
65
+ event.preventDefault();
66
+ editor.insertText('\n');
67
+ }
68
+ },
69
+ };
70
+ }
@@ -0,0 +1 @@
1
+ export { BreaksPlugin } from './BreaksPlugin';
@@ -0,0 +1,20 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { RenderElementProps } from 'slate-react';
3
+ import styles from './styles.module.css';
4
+ import type { CodeElement } from './types';
5
+
6
+ type Props = RenderElementProps & {
7
+ element: CodeElement;
8
+ renderLanguageSelector: (element: CodeElement) => ReactNode;
9
+ };
10
+
11
+ export const CodeBlock = (props: Props) => {
12
+ return (
13
+ <div {...props.attributes} className={styles.code} spellCheck={false}>
14
+ <div contentEditable={false}>
15
+ {props.renderLanguageSelector(props.element)}
16
+ </div>
17
+ <div className={styles.content}>{props.children}</div>
18
+ </div>
19
+ );
20
+ };
@@ -0,0 +1,7 @@
1
+ import { RenderElementProps } from 'slate-react';
2
+
3
+ export const CodeBlockLine = (props: RenderElementProps) => (
4
+ <div {...props.attributes} style={{ position: 'relative' }}>
5
+ {props.children}
6
+ </div>
7
+ );