@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,29 @@
1
+ import { Transforms } from "slate";
2
+ const removeCommand = (editor, selection, filter)=>()=>{
3
+ Transforms["delete"](editor, {
4
+ at: selection?.focus,
5
+ distance: 'string' == typeof filter ? filter.length + 1 : 1,
6
+ reverse: true,
7
+ unit: 'character'
8
+ });
9
+ };
10
+ const set = (editor, selection, filter)=>(params, options = {})=>{
11
+ removeCommand(editor, selection, filter)();
12
+ Transforms.setNodes(editor, params, {
13
+ ...options
14
+ });
15
+ };
16
+ const insert = (editor, selection, filter)=>(params)=>{
17
+ removeCommand(editor, selection, filter)();
18
+ Transforms.insertNodes(editor, params);
19
+ };
20
+ const wrap = (editor, selection, filter)=>(params, options = {})=>{
21
+ removeCommand(editor, selection, filter)();
22
+ Transforms.wrapNodes(editor, params, {
23
+ ...options
24
+ });
25
+ };
26
+ const insertText = (editor)=>(text)=>{
27
+ Transforms.insertText(editor, text);
28
+ };
29
+ export { insert, insertText, removeCommand, set, wrap };
@@ -0,0 +1,2 @@
1
+ export { CommandsPlugin } from './CommandsPlugin';
2
+ export type { Command } from './types';
@@ -0,0 +1,2 @@
1
+ import { CommandsPlugin } from "./CommandsPlugin.js";
2
+ export { CommandsPlugin };
@@ -0,0 +1,9 @@
1
+ import "./styles_module.css";
2
+ const styles_module = {
3
+ menu: "menu-ZXHiGS",
4
+ button: "button-yrhMLR",
5
+ active: "active-Is5D6b",
6
+ icon: "icon-Xca6dM",
7
+ backdrop: "backdrop-lw7AjW"
8
+ };
9
+ export { styles_module as default };
@@ -0,0 +1,66 @@
1
+ :root {
2
+ --menu-background-color: #fff;
3
+ --menu-background-color-hover: #f9f9f9;
4
+ --menu-text-color: #444;
5
+ --menu-border-color: #ddd;
6
+ }
7
+
8
+ .menu-ZXHiGS {
9
+ color: var(--menu-text-color, #444);
10
+ z-index: 31;
11
+ opacity: 0;
12
+ background-color: var(--menu-background-color, #fff);
13
+ border: 1px solid var(--menu-border-color, #ddd);
14
+ border-radius: 4px;
15
+ flex-direction: column;
16
+ max-height: 200px;
17
+ margin-top: -6px;
18
+ font-size: 12px;
19
+ transition: transform .25s;
20
+ display: flex;
21
+ position: absolute;
22
+ top: -100000px;
23
+ left: -100000px;
24
+ overflow-y: auto;
25
+ transform: scale(.9);
26
+ box-shadow: 0 1px 3px #00000006;
27
+ }
28
+
29
+ .button-yrhMLR {
30
+ box-sizing: border-box;
31
+ cursor: pointer;
32
+ height: 40px;
33
+ color: var(--menu-text-color, #444);
34
+ background: none;
35
+ border: none;
36
+ align-items: center;
37
+ column-gap: 8px;
38
+ padding: 8px;
39
+ display: inline-flex;
40
+ }
41
+
42
+ .button-yrhMLR:hover, .active-Is5D6b {
43
+ background-color: var(--menu-background-color-hover, #f9f9f9);
44
+ }
45
+
46
+ .icon-Xca6dM {
47
+ opacity: .5;
48
+ background: var(--menu-background-color-hover, #f9f9f9);
49
+ width: 24px;
50
+ height: 24px;
51
+ color: var(--menu-text-color, #444);
52
+ border-radius: 4px;
53
+ justify-content: center;
54
+ align-items: center;
55
+ padding: 2px;
56
+ font-size: 12px;
57
+ display: inline-flex;
58
+ }
59
+
60
+ .backdrop-lw7AjW {
61
+ z-index: 30;
62
+ background-color: #0000;
63
+ position: fixed;
64
+ inset: 0;
65
+ }
66
+
@@ -0,0 +1,27 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { Editor } from 'slate';
3
+ import type { CustomElement } from '../../../types';
4
+ export type Options = {
5
+ commands: Command[];
6
+ renderMenu: (children: ReactNode) => ReactNode;
7
+ ignoreNodes?: string[];
8
+ };
9
+ export type CommandsStore = {
10
+ isOpen: boolean;
11
+ filter: boolean | string;
12
+ commands: Command[];
13
+ };
14
+ export type Command = {
15
+ name: string;
16
+ title: string;
17
+ commandName: string;
18
+ icon: ReactNode;
19
+ action: (actions: Actions, editor: Editor) => void;
20
+ };
21
+ export type Actions = {
22
+ removeCommand: () => void;
23
+ set: (params: Partial<CustomElement>, options?: any) => void;
24
+ insert: (params: CustomElement) => void;
25
+ wrap: (params: CustomElement, options?: any) => void;
26
+ insertText: (text: string) => void;
27
+ };
File without changes
@@ -0,0 +1,33 @@
1
+ import type React from 'react';
2
+ import { type ConnectDragPreview, type ConnectDragSource, type ConnectDropTarget } from 'react-dnd';
3
+ import { Editor, Path } from 'slate';
4
+ import { type RenderElementProps } from 'slate-react';
5
+ import type { CustomElement } from '../../../types';
6
+ import type { IPlugin } from '../../types';
7
+ type Options = {
8
+ onDropFiles: (editor: Editor, files: File[], path: Path) => void;
9
+ renderBlock?: (params: {
10
+ props: RenderElementProps;
11
+ dragRef: ConnectDragSource;
12
+ dropRef: ConnectDropTarget;
13
+ previewRef: ConnectDragPreview;
14
+ position: 'top' | 'bottom' | null;
15
+ }) => React.ReactNode;
16
+ ignoreNodes?: string[];
17
+ customTypes?: {
18
+ [type: string]: {
19
+ type: string | symbol;
20
+ getData?: (element: CustomElement) => Record<string, unknown>;
21
+ };
22
+ };
23
+ };
24
+ export declare class DnDPlugin implements IPlugin {
25
+ private options;
26
+ constructor(options: Options);
27
+ static DND_BLOCK_ELEMENT: string;
28
+ handlers: {
29
+ onDrop: (event: DragEvent) => void;
30
+ };
31
+ renderBlock: (props: RenderElementProps) => any;
32
+ }
33
+ export {};
@@ -0,0 +1,110 @@
1
+ import { useEffect, useState } from "react";
2
+ import { useDrag, useDrop } from "react-dnd";
3
+ import { NativeTypes } from "react-dnd-html5-backend";
4
+ import { Editor, Path, Transforms } from "slate";
5
+ import { ReactEditor, useReadOnly, useSlate } from "slate-react";
6
+ class DnDPlugin {
7
+ options;
8
+ constructor(options){
9
+ this.options = options;
10
+ }
11
+ static DND_BLOCK_ELEMENT = 'block';
12
+ handlers = {
13
+ onDrop: (event)=>{
14
+ event.preventDefault();
15
+ }
16
+ };
17
+ renderBlock = (props)=>{
18
+ const editor = useSlate();
19
+ const options = this.options;
20
+ const isReadOnly = useReadOnly();
21
+ const [dropPosition, setDropPosition] = useState(null);
22
+ const customType = options.customTypes?.[props.element.type];
23
+ const [, drag, preview] = useDrag({
24
+ type: customType?.type || DnDPlugin.DND_BLOCK_ELEMENT,
25
+ item: {
26
+ ...customType?.getData?.(props.element) || {},
27
+ element: props.element
28
+ },
29
+ canDrag: !isReadOnly
30
+ });
31
+ const allCustomTypes = Object.values(options.customTypes || {}).map((customType)=>customType.type);
32
+ const [{ isOver }, drop] = useDrop({
33
+ accept: [
34
+ DnDPlugin.DND_BLOCK_ELEMENT,
35
+ NativeTypes.FILE,
36
+ ...allCustomTypes
37
+ ],
38
+ collect (monitor) {
39
+ return {
40
+ item: monitor.getItem(),
41
+ isOver: monitor.isOver(),
42
+ position: monitor.isOver() ? monitor.getClientOffset() : null
43
+ };
44
+ },
45
+ hover (_, monitor) {
46
+ const element = ReactEditor.toDOMNode(editor, props.element);
47
+ if (!element) return;
48
+ const hoverBoundingRect = element.getBoundingClientRect();
49
+ const hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;
50
+ const clientOffset = monitor.getClientOffset();
51
+ if (!clientOffset) return;
52
+ const hoverClientY = clientOffset.y - hoverBoundingRect.top;
53
+ hoverClientY < hoverMiddleY ? setDropPosition('top') : setDropPosition('bottom');
54
+ },
55
+ drop (item, monitor) {
56
+ const itemType = monitor.getItemType();
57
+ const sourceTo = ReactEditor.findPath(editor, props.element);
58
+ if (!sourceTo) return;
59
+ const dropPath = getDropPath(editor, sourceTo, dropPosition);
60
+ if (!dropPath) return;
61
+ switch(itemType){
62
+ case NativeTypes.FILE:
63
+ options.onDropFiles(editor, item.files, dropPath);
64
+ break;
65
+ default:
66
+ {
67
+ const targetTo = ReactEditor.findPath(editor, item.element);
68
+ if (!dropPosition) return;
69
+ moveNode(editor, sourceTo, targetTo, dropPosition);
70
+ break;
71
+ }
72
+ }
73
+ setDropPosition(null);
74
+ }
75
+ });
76
+ useEffect(()=>{
77
+ setDropPosition(null);
78
+ }, [
79
+ isOver
80
+ ]);
81
+ if (this.options.ignoreNodes?.includes(props.element.type)) return props.children;
82
+ if (editor.isInline(props.element)) return props.children;
83
+ return options.renderBlock?.({
84
+ props,
85
+ dragRef: drag,
86
+ dropRef: drop,
87
+ previewRef: preview,
88
+ position: dropPosition
89
+ });
90
+ };
91
+ }
92
+ const getDropPath = (editor, targetNodePath, position)=>{
93
+ const target = Editor.node(editor, targetNodePath);
94
+ switch(position){
95
+ case 'top':
96
+ return target[1];
97
+ case 'bottom':
98
+ return Path.next(target[1]);
99
+ }
100
+ };
101
+ const moveNode = (editor, targetNodePath, sourceNodePath, position)=>{
102
+ const dropPath = getDropPath(editor, targetNodePath, position);
103
+ if (!dropPath) return;
104
+ Transforms.moveNodes(editor, {
105
+ at: sourceNodePath,
106
+ to: dropPath,
107
+ mode: 'highest'
108
+ });
109
+ };
110
+ export { DnDPlugin };
@@ -0,0 +1 @@
1
+ export { DnDPlugin } from './DnDPlugin';
@@ -0,0 +1,2 @@
1
+ import { DnDPlugin } from "./DnDPlugin.js";
2
+ export { DnDPlugin };
@@ -0,0 +1,9 @@
1
+ import "./styles_module.css";
2
+ const styles_module = {
3
+ root: "root-mImbWh",
4
+ block: "block-Zksas5",
5
+ drag: "drag-ONjCpH",
6
+ top: "top-aH68un",
7
+ bottom: "bottom-RubLVC"
8
+ };
9
+ export { styles_module as default };
@@ -0,0 +1,43 @@
1
+ .root-mImbWh {
2
+ border-top: 2px solid #0000;
3
+ border-bottom: 2px solid #0000;
4
+ position: relative;
5
+ }
6
+
7
+ .block-Zksas5 {
8
+ border-radius: 4px;
9
+ grid-template-columns: 16px 1fr;
10
+ align-items: start;
11
+ column-gap: 8px;
12
+ padding: 4px 8px;
13
+ transition: background-color .25s;
14
+ display: grid;
15
+ position: relative;
16
+ }
17
+
18
+ .block-Zksas5:hover {
19
+ background-color: #00000006;
20
+ }
21
+
22
+ .block-Zksas5:hover .drag-ONjCpH {
23
+ opacity: 1;
24
+ }
25
+
26
+ .drag-ONjCpH {
27
+ vertical-align: baseline;
28
+ cursor: move;
29
+ opacity: 0;
30
+ width: 16px;
31
+ line-height: 1.2;
32
+ transition: opacity .25s;
33
+ display: inline-block;
34
+ }
35
+
36
+ .top-aH68un {
37
+ border-top: 2px solid #3498db;
38
+ }
39
+
40
+ .bottom-RubLVC {
41
+ border-bottom: 2px solid #3498db;
42
+ }
43
+
@@ -0,0 +1,9 @@
1
+ import type { Options } from './types';
2
+ type Props = {
3
+ focused?: HTMLElement | null;
4
+ options: Options;
5
+ isVisible?: boolean;
6
+ onVisibilityChange?: (isVisible: boolean) => void;
7
+ };
8
+ export declare const FloatingMenu: (props: Props) => import("react").ReactPortal | null;
9
+ export {};
@@ -0,0 +1,89 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useLayoutEffect, useRef, useState } from "react";
3
+ import { createPortal } from "react-dom";
4
+ import { Editor, Range } from "slate";
5
+ import { useFocused, useSlate, useSlateSelection } from "slate-react";
6
+ import styles_module from "./styles.module.js";
7
+ const FloatingMenu = (props)=>{
8
+ const { options, focused, isVisible, onVisibilityChange } = props;
9
+ const [style, setStyle] = useState(void 0);
10
+ const ref = useRef(null);
11
+ const selection = useSlateSelection();
12
+ const editor = useSlate();
13
+ const isFocused = useFocused();
14
+ const onClose = ()=>{
15
+ setStyle(void 0);
16
+ options.onHide();
17
+ };
18
+ useLayoutEffect(()=>{
19
+ if (!selection) return;
20
+ const entry = Editor.above(editor, {
21
+ at: selection,
22
+ match: (n)=>!Editor.isEditor(n),
23
+ mode: 'highest'
24
+ });
25
+ if (!selection || !isFocused || Range.isCollapsed(selection) || '' === Editor.string(editor, selection) || !entry || options.ignoreNodes?.includes(entry[0].type)) return void onVisibilityChange?.(options.onHide());
26
+ onVisibilityChange?.(options.onShow());
27
+ }, [
28
+ selection
29
+ ]);
30
+ useLayoutEffect(()=>{
31
+ if (!selection) return;
32
+ const entry = Editor.above(editor, {
33
+ at: selection,
34
+ match: (n)=>!Editor.isEditor(n),
35
+ mode: 'highest'
36
+ });
37
+ if (!selection || !isFocused || Range.isCollapsed(selection) || '' === Editor.string(editor, selection) || !entry || options.ignoreNodes?.includes(entry?.[0].type)) return;
38
+ handleUpdate();
39
+ }, [
40
+ selection
41
+ ]);
42
+ const handleUpdate = ()=>{
43
+ const element = ref.current;
44
+ let rect;
45
+ if (focused) rect = focused.getBoundingClientRect();
46
+ else {
47
+ const domSelection = window.getSelection();
48
+ if (!domSelection || domSelection.isCollapsed) return;
49
+ const domRange = domSelection?.getRangeAt(0);
50
+ rect = domRange?.getBoundingClientRect();
51
+ }
52
+ setStyle({
53
+ opacity: 1,
54
+ transform: 'scale(1)',
55
+ top: `${(rect?.top || 0) + window.scrollY - (element?.offsetHeight || 0)}px`,
56
+ left: `${(rect?.left || 0) + window.scrollX - (element?.offsetWidth || 0) / 2 + (rect?.width || 0) / 2}px`
57
+ });
58
+ };
59
+ if (!isVisible) return null;
60
+ return /*#__PURE__*/ createPortal(/*#__PURE__*/ jsxs(Fragment, {
61
+ children: [
62
+ /*#__PURE__*/ jsx("div", {
63
+ onMouseDown: ()=>{
64
+ setStyle(void 0);
65
+ },
66
+ children: options.renderBackdrop?.({
67
+ onClose,
68
+ onUpdate: handleUpdate
69
+ })
70
+ }),
71
+ /*#__PURE__*/ jsx("div", {
72
+ ref: ref,
73
+ style: {
74
+ ...style,
75
+ display: 'block'
76
+ },
77
+ className: styles_module.root,
78
+ onMouseDown: (event)=>{
79
+ event.preventDefault();
80
+ },
81
+ children: options.renderMenu(editor, {
82
+ onClose,
83
+ onUpdate: handleUpdate
84
+ })
85
+ })
86
+ ]
87
+ }), document.body);
88
+ };
89
+ export { FloatingMenu };
@@ -0,0 +1,15 @@
1
+ import { type MapStore } from 'nanostores';
2
+ import type { IPlugin } from '../../types';
3
+ import type { Options } from './types';
4
+ export declare class FloatingMenuPlugin implements IPlugin {
5
+ private options;
6
+ $store: MapStore<{
7
+ isVisible: boolean;
8
+ focused: HTMLElement | null;
9
+ }>;
10
+ constructor(options: Options);
11
+ openOnElement: (element: HTMLElement) => void;
12
+ ui({ readOnly }: {
13
+ readOnly: any;
14
+ }): import("react/jsx-runtime").JSX.Element | null;
15
+ }
@@ -0,0 +1,36 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useStore } from "@nanostores/react";
3
+ import { map } from "nanostores";
4
+ import { FloatingMenu } from "./FloatingMenu.js";
5
+ class FloatingMenuPlugin {
6
+ options;
7
+ $store;
8
+ constructor(options){
9
+ this.options = options;
10
+ this.$store = map({
11
+ focused: null
12
+ });
13
+ }
14
+ openOnElement = (element)=>{
15
+ this.$store.setKey('focused', element);
16
+ this.$store.setKey('isVisible', true);
17
+ };
18
+ ui({ readOnly }) {
19
+ const { focused, isVisible } = useStore(this.$store);
20
+ return readOnly ? null : /*#__PURE__*/ jsx(FloatingMenu, {
21
+ focused: focused,
22
+ isVisible: isVisible,
23
+ onVisibilityChange: (isVisible)=>{
24
+ this.$store.setKey('isVisible', isVisible);
25
+ },
26
+ options: {
27
+ ...this.options,
28
+ onHide: ()=>{
29
+ this.$store.setKey('focused', null);
30
+ return this.options.onHide();
31
+ }
32
+ }
33
+ });
34
+ }
35
+ }
36
+ export { FloatingMenuPlugin };
@@ -0,0 +1,2 @@
1
+ export { FloatingMenuPlugin } from './FloatingMenuPlugin';
2
+ export type { Commands } from './types';
@@ -0,0 +1,2 @@
1
+ import { FloatingMenuPlugin } from "./FloatingMenuPlugin.js";
2
+ export { FloatingMenuPlugin };
@@ -0,0 +1,7 @@
1
+ import "./styles_module.css";
2
+ const styles_module = {
3
+ root: "root-j2ULfe",
4
+ button: "button-Ava9ko",
5
+ active: "active-GxBDgg"
6
+ };
7
+ export { styles_module as default };
@@ -0,0 +1,23 @@
1
+ .root-j2ULfe {
2
+ z-index: 20;
3
+ opacity: 0;
4
+ margin-top: -6px;
5
+ transition: transform .25s;
6
+ position: absolute;
7
+ top: -100000px;
8
+ left: -100000px;
9
+ transform: scale(.8);
10
+ }
11
+
12
+ .button-Ava9ko {
13
+ cursor: pointer;
14
+ opacity: .4;
15
+ align-items: center;
16
+ padding: 4px;
17
+ display: inline-flex;
18
+ }
19
+
20
+ .active-GxBDgg {
21
+ opacity: .7;
22
+ }
23
+
@@ -0,0 +1,16 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { Editor } from 'slate';
3
+ export type Options = {
4
+ ignoreNodes?: string[];
5
+ renderMenu: (editor: Editor, commands: Commands) => ReactNode;
6
+ renderBackdrop: (commands: {
7
+ onClose: () => void;
8
+ onUpdate: () => void;
9
+ }) => ReactNode;
10
+ onShow: () => boolean;
11
+ onHide: () => boolean;
12
+ };
13
+ export type Commands = {
14
+ onClose: () => void;
15
+ onUpdate: () => void;
16
+ };
File without changes
@@ -0,0 +1,19 @@
1
+ import { Editor } from 'slate';
2
+ import { RenderElementProps } from 'slate-react';
3
+ import { IPlugin } from '../../types';
4
+ export declare class HeadingsPlugin implements IPlugin {
5
+ static HeadingLevel1: string;
6
+ static HeadingLevel2: string;
7
+ static HeadingLevel3: string;
8
+ blocks: {
9
+ type: string;
10
+ render: (props: RenderElementProps) => import("react/jsx-runtime").JSX.Element;
11
+ }[];
12
+ static isHeading1Active(editor: Editor): boolean;
13
+ static isHeading2Active(editor: Editor): boolean;
14
+ static isHeading3Active(editor: Editor): boolean;
15
+ private static toggleHeading;
16
+ static toggleHeading1(editor: Editor): void;
17
+ static toggleHeading2(editor: Editor): void;
18
+ static toggleHeading3(editor: Editor): void;
19
+ }
@@ -0,0 +1,64 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Editor, Element, Transforms } from "slate";
3
+ class HeadingsPlugin {
4
+ static HeadingLevel1 = 'h1';
5
+ static HeadingLevel2 = 'h2';
6
+ static HeadingLevel3 = 'h3';
7
+ blocks = [
8
+ {
9
+ type: HeadingsPlugin.HeadingLevel1,
10
+ render: (props)=>/*#__PURE__*/ jsx("h1", {
11
+ ...props.attributes,
12
+ children: props.children
13
+ })
14
+ },
15
+ {
16
+ type: HeadingsPlugin.HeadingLevel2,
17
+ render: (props)=>/*#__PURE__*/ jsx("h2", {
18
+ ...props.attributes,
19
+ children: props.children
20
+ })
21
+ },
22
+ {
23
+ type: HeadingsPlugin.HeadingLevel3,
24
+ render: (props)=>/*#__PURE__*/ jsx("h3", {
25
+ ...props.attributes,
26
+ children: props.children
27
+ })
28
+ }
29
+ ];
30
+ static isHeading1Active(editor) {
31
+ return isBlockActive(editor, HeadingsPlugin.HeadingLevel1);
32
+ }
33
+ static isHeading2Active(editor) {
34
+ return isBlockActive(editor, HeadingsPlugin.HeadingLevel2);
35
+ }
36
+ static isHeading3Active(editor) {
37
+ return isBlockActive(editor, HeadingsPlugin.HeadingLevel3);
38
+ }
39
+ static toggleHeading(editor, type) {
40
+ const isActive = isBlockActive(editor, type);
41
+ Transforms.setNodes(editor, {
42
+ type: isActive ? 'paragraph' : type
43
+ });
44
+ }
45
+ static toggleHeading1(editor) {
46
+ HeadingsPlugin.toggleHeading(editor, HeadingsPlugin.HeadingLevel1);
47
+ }
48
+ static toggleHeading2(editor) {
49
+ HeadingsPlugin.toggleHeading(editor, HeadingsPlugin.HeadingLevel2);
50
+ }
51
+ static toggleHeading3(editor) {
52
+ HeadingsPlugin.toggleHeading(editor, HeadingsPlugin.HeadingLevel3);
53
+ }
54
+ }
55
+ const isBlockActive = (editor, type)=>{
56
+ const { selection } = editor;
57
+ if (!selection) return false;
58
+ const [match] = Array.from(Editor.nodes(editor, {
59
+ at: Editor.unhangRange(editor, selection),
60
+ match: (node)=>!Editor.isEditor(node) && Element.isElement(node) && node.type === type
61
+ }));
62
+ return !!match;
63
+ };
64
+ export { HeadingsPlugin };
@@ -0,0 +1 @@
1
+ export { HeadingsPlugin } from './HeadingsPlugin';
@@ -0,0 +1,2 @@
1
+ import { HeadingsPlugin } from "./HeadingsPlugin.js";
2
+ export { HeadingsPlugin };
@@ -0,0 +1,16 @@
1
+ import { Editor } from 'slate';
2
+ import type { RenderLeafProps } from 'slate-react';
3
+ import type { IPlugin } from '../../types';
4
+ type Options = {
5
+ colors: Record<string, string>;
6
+ };
7
+ export declare class HighlightsPlugin implements IPlugin {
8
+ private options;
9
+ constructor(options: Options);
10
+ static toggleHighlight(editor: Editor, color: string): void;
11
+ static isHighlightActive(editor: Editor, color: string): boolean;
12
+ leafs: {
13
+ render: (props: RenderLeafProps) => import("react/jsx-runtime").JSX.Element;
14
+ }[];
15
+ }
16
+ export {};