@esportsplus/ui 0.59.1 → 0.62.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 (851) hide show
  1. package/.audit/audit.json +2770 -0
  2. package/.audit/check-scss.mjs +20 -0
  3. package/.audit/rules-audit.md +531 -0
  4. package/README.md +52 -40
  5. package/RULES.md +145 -0
  6. package/build/components/accordion/index.d.ts +15 -2174
  7. package/build/components/accordion/index.js +32 -31
  8. package/build/components/accordion/scss/index.scss +1 -1
  9. package/build/components/announcement/index.d.ts +720 -2164
  10. package/build/components/announcement/index.js +12 -9
  11. package/build/components/announcement/scss/index.scss +1 -1
  12. package/build/components/breadcrumb/index.d.ts +4 -1
  13. package/build/components/breadcrumb/index.js +57 -69
  14. package/build/components/breadcrumb/scss/index.scss +1 -1
  15. package/build/components/button/copy.d.ts +4 -11
  16. package/build/components/button/copy.js +32 -25
  17. package/build/components/button/faces.d.ts +2 -2
  18. package/build/components/button/faces.js +9 -11
  19. package/build/components/button/index.d.ts +3 -7
  20. package/build/components/button/index.js +3 -5
  21. package/build/components/button/kbd.d.ts +3 -7
  22. package/build/components/button/kbd.js +63 -76
  23. package/build/components/button/morph/index.d.ts +1447 -0
  24. package/build/components/button/morph/index.js +4 -0
  25. package/build/components/button/morph/save.d.ts +10 -0
  26. package/build/components/button/morph/save.js +57 -0
  27. package/build/components/button/morph/template.d.ts +23 -0
  28. package/build/components/button/morph/template.js +110 -0
  29. package/build/components/button/scss/index.scss +1 -1
  30. package/build/components/button/sidebar.d.ts +1 -10
  31. package/build/components/button/sidebar.js +14 -12
  32. package/build/components/button/split.d.ts +7 -2
  33. package/build/components/button/split.js +20 -19
  34. package/build/components/capslock/index.d.ts +1 -10
  35. package/build/components/capslock/index.js +18 -14
  36. package/build/components/capslock/scss/index.scss +1 -1
  37. package/build/components/card/scss/index.scss +1 -1
  38. package/build/components/cc/index.d.ts +4 -1
  39. package/build/components/cc/index.js +209 -175
  40. package/build/components/cc/scss/index.scss +1 -1
  41. package/build/components/chat/index.d.ts +6 -0
  42. package/build/components/chat/index.js +3 -0
  43. package/build/components/chat/minimap/index.d.ts +63 -0
  44. package/build/components/chat/minimap/index.js +272 -0
  45. package/build/components/{chat-minimap/range.js → chat/minimap/model.js} +1 -1
  46. package/build/components/{chat-minimap → chat/minimap}/spy.d.ts +1 -1
  47. package/build/components/{chat-minimap → chat/minimap}/spy.js +1 -1
  48. package/build/components/checkbox/group.d.ts +2 -10
  49. package/build/components/checkbox/group.js +39 -29
  50. package/build/components/checkbox/index.d.ts +1 -0
  51. package/build/components/checkbox/index.js +1 -0
  52. package/build/components/checkbox/options.d.ts +5005 -6441
  53. package/build/components/checkbox/options.js +72 -45
  54. package/build/components/checkbox/scss/index.scss +1 -1
  55. package/build/components/clipboard/index.d.ts +3 -2181
  56. package/build/components/clipboard/index.js +2 -3
  57. package/build/components/color-picker/index.d.ts +31 -1
  58. package/build/components/color-picker/index.js +200 -168
  59. package/build/components/color-picker/scss/index.scss +1 -1
  60. package/build/components/command/index.d.ts +6 -93
  61. package/build/components/command/index.js +4 -601
  62. package/build/components/command/palette.d.ts +111 -0
  63. package/build/components/command/palette.js +606 -0
  64. package/build/components/command/scss/index.scss +1 -1
  65. package/build/components/command/search.d.ts +19 -0
  66. package/build/components/command/search.js +68 -0
  67. package/build/components/container/scss/index.scss +1 -1
  68. package/build/components/counter/index.d.ts +6 -4
  69. package/build/components/counter/index.js +36 -32
  70. package/build/components/counter/scss/index.scss +1 -1
  71. package/build/components/dock/index.d.ts +28 -6
  72. package/build/components/dock/index.js +433 -55
  73. package/build/components/dock/scss/index.scss +1 -1
  74. package/build/components/editor/code/editor.d.ts +1 -10
  75. package/build/components/editor/code/features.d.ts +3 -3
  76. package/build/components/editor/code/features.js +65 -52
  77. package/build/components/editor/code/field.d.ts +1 -1
  78. package/build/components/editor/code/find.d.ts +4 -4
  79. package/build/components/editor/code/find.js +39 -37
  80. package/build/components/editor/code/folding.d.ts +1 -1
  81. package/build/components/editor/code/goto.d.ts +2 -1
  82. package/build/components/editor/code/goto.js +7 -7
  83. package/build/components/editor/code/gutter.js +12 -12
  84. package/build/components/editor/code/html.d.ts +4 -0
  85. package/build/components/editor/code/html.js +8 -0
  86. package/build/components/editor/code/minimap.d.ts +4 -10
  87. package/build/components/editor/code/minimap.js +18 -13
  88. package/build/components/editor/code/rows.js +6 -12
  89. package/build/components/editor/code/search.d.ts +1 -2
  90. package/build/components/editor/code/search.js +1 -1
  91. package/build/components/editor/code/services/index.d.ts +1 -1
  92. package/build/components/editor/code/services/index.js +27 -23
  93. package/build/components/editor/code/services/model.d.ts +1 -5
  94. package/build/components/editor/code/services/model.js +1 -1
  95. package/build/components/editor/code/services/session.d.ts +3 -2
  96. package/build/components/editor/code/services/session.js +1 -4
  97. package/build/components/editor/code/syntax.d.ts +1 -1
  98. package/build/components/editor/code/view.d.ts +2 -1
  99. package/build/components/editor/code/view.js +50 -39
  100. package/build/components/editor/diffs/merge.d.ts +1 -10
  101. package/build/components/editor/diffs/merge.js +126 -102
  102. package/build/components/editor/diffs/render.d.ts +1 -2
  103. package/build/components/editor/diffs/render.js +2 -8
  104. package/build/components/editor/diffs/view.d.ts +1 -10
  105. package/build/components/editor/diffs/view.js +112 -105
  106. package/build/components/editor/markdown/editing.d.ts +1 -1
  107. package/build/components/editor/markdown/erase.js +1 -1
  108. package/build/components/editor/markdown/format.d.ts +23 -0
  109. package/build/components/editor/markdown/format.js +319 -0
  110. package/build/components/editor/markdown/html.d.ts +1 -1
  111. package/build/components/editor/markdown/index.d.ts +3 -22
  112. package/build/components/editor/markdown/index.js +3 -30
  113. package/build/components/editor/markdown/inline.d.ts +1 -1
  114. package/build/components/editor/markdown/inline.js +6 -5
  115. package/build/components/editor/markdown/layout.d.ts +1 -3
  116. package/build/components/editor/markdown/layout.js +1 -1
  117. package/build/components/editor/markdown/model.d.ts +3 -9
  118. package/build/components/editor/markdown/model.js +1 -8
  119. package/build/components/editor/markdown/render.d.ts +2 -1
  120. package/build/components/editor/markdown/render.js +281 -252
  121. package/build/components/editor/markdown/template.d.ts +13 -0
  122. package/build/components/editor/markdown/template.js +30 -0
  123. package/build/components/editor/markdown/toolbar.d.ts +32 -0
  124. package/build/components/editor/markdown/toolbar.js +556 -0
  125. package/build/components/editor/markdown/view.d.ts +12 -1
  126. package/build/components/editor/markdown/view.js +154 -60
  127. package/build/components/editor/tree/compact.d.ts +2 -1
  128. package/build/components/editor/tree/compact.js +12 -11
  129. package/build/components/editor/tree/drag.d.ts +3 -2
  130. package/build/components/editor/tree/drag.js +29 -26
  131. package/build/components/editor/tree/edit.d.ts +1 -1
  132. package/build/components/editor/tree/edit.js +10 -9
  133. package/build/components/editor/tree/find.d.ts +1 -1
  134. package/build/components/editor/tree/find.js +13 -9
  135. package/build/components/editor/tree/icons.d.ts +1 -1
  136. package/build/components/editor/tree/icons.js +1 -1
  137. package/build/components/editor/tree/index.d.ts +3 -116
  138. package/build/components/editor/tree/index.js +3 -2225
  139. package/build/components/editor/tree/lazy.d.ts +2 -1
  140. package/build/components/editor/tree/lazy.js +17 -16
  141. package/build/components/editor/tree/sticky.d.ts +3 -2
  142. package/build/components/editor/tree/sticky.js +7 -6
  143. package/build/components/editor/tree/template.d.ts +117 -0
  144. package/build/components/editor/tree/template.js +2212 -0
  145. package/build/components/editor/viewer/index.d.ts +3 -26
  146. package/build/components/editor/viewer/index.js +3 -249
  147. package/build/components/editor/viewer/model.js +1 -7
  148. package/build/components/editor/viewer/template.d.ts +17 -0
  149. package/build/components/editor/viewer/template.js +258 -0
  150. package/build/components/editor/workspace/index.d.ts +4 -65
  151. package/build/components/editor/workspace/index.js +4 -1228
  152. package/build/components/editor/workspace/model.d.ts +29 -37
  153. package/build/components/editor/workspace/model.js +186 -155
  154. package/build/components/editor/workspace/navigate.d.ts +2 -1
  155. package/build/components/editor/workspace/navigate.js +2 -4
  156. package/build/components/editor/workspace/session.d.ts +5 -1
  157. package/build/components/editor/workspace/session.js +71 -39
  158. package/build/components/editor/workspace/shortcuts.d.ts +0 -2
  159. package/build/components/editor/workspace/shortcuts.js +39 -35
  160. package/build/components/editor/workspace/status.d.ts +4 -5
  161. package/build/components/editor/workspace/status.js +79 -61
  162. package/build/components/editor/workspace/statusbar.d.ts +7 -4
  163. package/build/components/editor/workspace/statusbar.js +73 -86
  164. package/build/components/editor/workspace/strip.d.ts +1 -2
  165. package/build/components/editor/workspace/strip.js +10 -8
  166. package/build/components/editor/workspace/tabs.d.ts +35 -3
  167. package/build/components/editor/workspace/tabs.js +75 -13
  168. package/build/components/editor/workspace/template.d.ts +57 -0
  169. package/build/components/editor/workspace/template.js +1150 -0
  170. package/build/components/error/index.d.ts +1 -10
  171. package/build/components/error/index.js +64 -32
  172. package/build/components/error/scss/index.scss +1 -1
  173. package/build/components/filter/index.js +138 -77
  174. package/build/components/filter/scss/index.scss +1 -1
  175. package/build/components/form/action.d.ts +2 -2
  176. package/build/components/form/action.js +12 -9
  177. package/build/components/form/index.d.ts +6 -32
  178. package/build/components/form/index.js +2 -1
  179. package/build/components/frame/scss/index.scss +1 -1
  180. package/build/components/grid/scss/index.scss +1 -1
  181. package/build/components/group/index.d.ts +14 -0
  182. package/build/components/group/index.js +18 -0
  183. package/build/components/group/scss/index.scss +2 -0
  184. package/build/components/heatmap/index.d.ts +5 -2
  185. package/build/components/heatmap/index.js +79 -88
  186. package/build/components/heatmap/scss/index.scss +1 -1
  187. package/build/components/highlight/index.d.ts +3 -13
  188. package/build/components/highlight/index.js +95 -92
  189. package/build/components/highlight/scss/index.scss +1 -1
  190. package/build/components/icon/index.d.ts +2 -10
  191. package/build/components/icon/index.js +12 -10
  192. package/build/components/icon/scss/index.scss +1 -1
  193. package/build/components/image/index.d.ts +3 -16
  194. package/build/components/image/index.js +2 -2
  195. package/build/components/image/lazyload.d.ts +2 -1
  196. package/build/components/image/lazyload.js +29 -26
  197. package/build/components/image/scss/index.scss +1 -1
  198. package/build/components/index.d.ts +6 -7
  199. package/build/components/index.js +6 -7
  200. package/build/components/inline-edit/index.d.ts +5 -1
  201. package/build/components/inline-edit/index.js +35 -27
  202. package/build/components/inline-edit/rich.d.ts +10 -15
  203. package/build/components/inline-edit/rich.js +82 -1197
  204. package/build/components/inline-edit/scss/index.scss +1 -1
  205. package/build/components/inline-edit/status.d.ts +3 -2
  206. package/build/components/inline-edit/status.js +23 -18
  207. package/build/components/input/field.d.ts +2 -1
  208. package/build/components/input/field.js +12 -9
  209. package/build/components/input/scrub.d.ts +4 -1
  210. package/build/components/input/scrub.js +25 -20
  211. package/build/components/input/scss/index.scss +1 -1
  212. package/build/components/input/tag.d.ts +4 -2
  213. package/build/components/input/tag.js +105 -83
  214. package/build/components/json/index.d.ts +4 -3
  215. package/build/components/json/index.js +2 -1
  216. package/build/components/link/scss/index.scss +1 -1
  217. package/build/components/loading/index.d.ts +2 -1
  218. package/build/components/loading/index.js +6 -3
  219. package/build/components/loading/scss/index.scss +1 -1
  220. package/build/components/marquee/index.d.ts +2 -1
  221. package/build/components/marquee/index.js +92 -84
  222. package/build/components/marquee/scss/index.scss +1 -1
  223. package/build/components/marquee/velocity.js +4 -3
  224. package/build/components/metric/flash.d.ts +2 -1
  225. package/build/components/metric/flash.js +26 -25
  226. package/build/components/metric/index.d.ts +13 -2
  227. package/build/components/metric/index.js +60 -56
  228. package/build/components/metric/scss/index.scss +1 -1
  229. package/build/components/nav/index.d.ts +1 -1
  230. package/build/components/nav/scss/index.scss +1 -1
  231. package/build/components/nav/spy.js +9 -6
  232. package/build/components/nav/toc.d.ts +4 -18
  233. package/build/components/nav/toc.js +9 -21
  234. package/build/components/nav/tree.d.ts +14 -13
  235. package/build/components/nav/tree.js +80 -65
  236. package/build/components/notification/index.d.ts +5 -3
  237. package/build/components/notification/index.js +30 -39
  238. package/build/components/notification/scss/index.scss +1 -1
  239. package/build/components/overlay/index.d.ts +4 -5
  240. package/build/components/overlay/index.js +399 -196
  241. package/build/components/overlay/popup.d.ts +5 -6
  242. package/build/components/overlay/popup.js +80 -39
  243. package/build/components/overlay/scss/index.scss +1 -1
  244. package/build/components/page/scss/index.scss +1 -1
  245. package/build/components/pagination/arrows.d.ts +2 -1
  246. package/build/components/pagination/arrows.js +48 -45
  247. package/build/components/pagination/cards.d.ts +5 -1
  248. package/build/components/pagination/cards.js +70 -47
  249. package/build/components/pagination/dots.d.ts +3 -1
  250. package/build/components/pagination/dots.js +29 -24
  251. package/build/components/pagination/index.d.ts +2 -1
  252. package/build/components/pagination/index.js +27 -28
  253. package/build/components/pagination/scss/index.scss +1 -1
  254. package/build/components/panels/dnd.d.ts +47 -0
  255. package/build/components/panels/dnd.js +114 -0
  256. package/build/components/panels/group.d.ts +36 -0
  257. package/build/components/panels/group.js +322 -0
  258. package/build/components/panels/index.d.ts +17 -0
  259. package/build/components/panels/index.js +524 -0
  260. package/build/components/panels/model.d.ts +64 -0
  261. package/build/components/panels/model.js +446 -0
  262. package/build/components/panels/resize.d.ts +9 -0
  263. package/build/components/panels/resize.js +123 -0
  264. package/build/components/panels/scss/index.scss +2 -0
  265. package/build/components/panels/subtree.d.ts +4 -0
  266. package/build/components/panels/subtree.js +44 -0
  267. package/build/components/preview/buttons.d.ts +12 -0
  268. package/build/components/preview/buttons.js +26 -0
  269. package/build/components/preview/code.d.ts +8 -0
  270. package/build/components/preview/code.js +18 -0
  271. package/build/components/preview/header.d.ts +8 -0
  272. package/build/components/preview/header.js +21 -0
  273. package/build/components/preview/index.d.ts +37 -0
  274. package/build/components/preview/index.js +123 -0
  275. package/build/components/preview/scss/index.scss +2 -0
  276. package/build/components/preview/source.d.ts +12 -0
  277. package/build/components/preview/source.js +79 -0
  278. package/build/components/preview/stage.d.ts +8 -0
  279. package/build/components/preview/stage.js +28 -0
  280. package/build/components/progress/index.d.ts +2 -1
  281. package/build/components/progress/index.js +30 -26
  282. package/build/components/progress/scss/index.scss +1 -1
  283. package/build/components/progress/text.d.ts +2 -1
  284. package/build/components/progress/text.js +30 -30
  285. package/build/components/radio/index.d.ts +3 -2
  286. package/build/components/radio/index.js +2 -2
  287. package/build/components/range/filter.d.ts +2 -1
  288. package/build/components/range/filter.js +130 -132
  289. package/build/components/range/index.d.ts +2 -1
  290. package/build/components/range/index.js +17 -22
  291. package/build/components/range/scss/index.scss +1 -1
  292. package/build/components/relative-time/index.d.ts +3 -1
  293. package/build/components/relative-time/index.js +60 -48
  294. package/build/components/relative-time/scss/index.scss +1 -1
  295. package/build/components/root/scss/index.scss +1 -1
  296. package/build/components/select/expand.d.ts +44 -0
  297. package/build/components/select/expand.js +215 -0
  298. package/build/components/select/index.d.ts +19 -10
  299. package/build/components/select/index.js +130 -90
  300. package/build/components/select/scss/index.scss +1 -1
  301. package/build/components/shell/index.d.ts +23 -0
  302. package/build/components/shell/index.js +290 -0
  303. package/build/components/shell/scss/index.scss +2 -0
  304. package/build/components/shortcut-recorder/index.d.ts +2 -3
  305. package/build/components/shortcut-recorder/index.js +49 -44
  306. package/build/components/shortcut-recorder/scss/index.scss +1 -1
  307. package/build/components/sortable/index.d.ts +2 -714
  308. package/build/components/sortable/index.js +75 -64
  309. package/build/components/sortable/scss/index.scss +1 -1
  310. package/build/components/story/index.d.ts +3 -5
  311. package/build/components/story/index.js +122 -84
  312. package/build/components/story/scss/index.scss +1 -1
  313. package/build/components/surface-field/engine.js +51 -53
  314. package/build/components/surface-field/index.d.ts +2180 -2921
  315. package/build/components/surface-field/index.js +52 -51
  316. package/build/components/surface-field/scss/index.scss +1 -1
  317. package/build/components/surface-field/surface.d.ts +1 -10
  318. package/build/components/surface-field/surface.js +42 -36
  319. package/build/components/switch/index.d.ts +3 -2
  320. package/build/components/switch/index.js +2 -2
  321. package/build/components/tasklist/index.d.ts +8 -1
  322. package/build/components/tasklist/index.js +66 -47
  323. package/build/components/tasklist/scss/index.scss +1 -1
  324. package/build/components/textarea/index.d.ts +722 -2170
  325. package/build/components/textarea/index.js +67 -91
  326. package/build/components/textarea/scss/index.scss +1 -1
  327. package/build/components/theme/cards.d.ts +4 -0
  328. package/build/components/theme/cards.js +21 -0
  329. package/build/components/theme/index.d.ts +17 -4
  330. package/build/components/theme/index.js +40 -15
  331. package/build/components/theme/reveal.d.ts +6 -0
  332. package/build/components/theme/reveal.js +100 -0
  333. package/build/components/theme/scss/index.scss +1 -1
  334. package/build/components/theme/shared.d.ts +26 -0
  335. package/build/components/theme/shared.js +26 -0
  336. package/build/components/theme/swatches.d.ts +4 -0
  337. package/build/components/theme/swatches.js +21 -0
  338. package/build/components/theme/toggle.d.ts +15 -0
  339. package/build/components/theme/toggle.js +33 -0
  340. package/build/components/toast/index.d.ts +6 -2
  341. package/build/components/toast/index.js +68 -56
  342. package/build/components/toast/scss/index.scss +1 -1
  343. package/build/components/tooltip/menu.d.ts +12 -2
  344. package/build/components/tooltip/menu.js +234 -176
  345. package/build/components/tooltip/onclick.d.ts +1 -10
  346. package/build/components/tooltip/onclick.js +25 -27
  347. package/build/components/tooltip/onhover.d.ts +8 -709
  348. package/build/components/tooltip/onhover.js +60 -60
  349. package/build/components/tooltip/scss/index.scss +1 -1
  350. package/build/components/tooltip/shared.d.ts +5 -3
  351. package/build/components/tooltip/shared.js +201 -91
  352. package/build/components/tooltip/utilities.d.ts +10 -4
  353. package/build/components/tooltip/utilities.js +95 -18
  354. package/build/components/typewriter/index.d.ts +2855 -1413
  355. package/build/components/typewriter/index.js +17 -18
  356. package/build/components/typewriter/retype.d.ts +2 -1
  357. package/build/components/typewriter/retype.js +21 -18
  358. package/build/components/typewriter/rotate.d.ts +2 -1
  359. package/build/components/typewriter/rotate.js +41 -45
  360. package/build/components/typewriter/scss/index.scss +1 -1
  361. package/build/components/uptime/index.d.ts +2 -1
  362. package/build/components/uptime/index.js +51 -54
  363. package/build/components/uptime/scss/index.scss +1 -1
  364. package/build/components/usage-meter/index.d.ts +719 -2161
  365. package/build/components/usage-meter/index.js +23 -20
  366. package/build/components/usage-meter/scss/index.scss +1 -1
  367. package/build/modifiers/background/scss/index.scss +2 -0
  368. package/build/modifiers/border/scss/index.scss +2 -0
  369. package/build/modifiers/box-shadow/scss/index.scss +2 -0
  370. package/build/modifiers/color/scss/index.scss +2 -0
  371. package/build/modifiers/disabled/scss/index.scss +2 -0
  372. package/build/modifiers/glass/index.d.ts +3 -2
  373. package/build/modifiers/glass/index.js +7 -7
  374. package/build/modifiers/glass/scss/index.scss +1 -1
  375. package/build/modifiers/scrollbar/index.d.ts +13 -13
  376. package/build/modifiers/scrollbar/index.js +74 -90
  377. package/build/modifiers/scrollbar/scss/index.scss +1 -1
  378. package/build/shared/animation.d.ts +1 -1
  379. package/build/shared/animation.js +6 -4
  380. package/build/shared/dispatch.d.ts +7 -0
  381. package/build/shared/dispatch.js +25 -0
  382. package/build/shared/drag.d.ts +4 -5
  383. package/build/shared/drag.js +4 -3
  384. package/build/shared/press.d.ts +1 -1
  385. package/build/shared/press.js +5 -3
  386. package/build/shared/resize.js +2 -25
  387. package/build/shared/transition.d.ts +1 -1
  388. package/build/shared/transition.js +2 -2
  389. package/build/shared/visible.js +1 -24
  390. package/package.json +10 -11
  391. package/scripts/code-editor-services.test.mjs +1 -1
  392. package/scripts/code-editor-workspace.test.mjs +28 -18
  393. package/scripts/panels.test.mjs +262 -0
  394. package/scripts/workspace-keybindings.test.mjs +1 -1
  395. package/scripts/workspace-session.test.mjs +8 -6
  396. package/scripts/workspace-status.test.mjs +9 -1
  397. package/scripts/workspace-tabs.test.mjs +5 -5
  398. package/src/components/accordion/index.ts +13 -12
  399. package/src/components/accordion/scss/index.scss +16 -13
  400. package/src/components/accordion/scss/variables.scss +13 -10
  401. package/src/components/announcement/scss/index.scss +16 -24
  402. package/src/components/announcement/scss/variables.scss +20 -10
  403. package/src/components/breadcrumb/index.ts +11 -13
  404. package/src/components/breadcrumb/scss/index.scss +52 -126
  405. package/src/components/breadcrumb/scss/variables.scss +64 -53
  406. package/src/components/button/copy.ts +35 -28
  407. package/src/components/button/faces.ts +2 -4
  408. package/src/components/button/index.ts +3 -7
  409. package/src/components/button/kbd.ts +42 -99
  410. package/src/components/button/morph/index.ts +6 -0
  411. package/src/components/button/morph/save.ts +55 -0
  412. package/src/components/button/morph/template.ts +133 -0
  413. package/src/components/button/scss/index.scss +263 -119
  414. package/src/components/button/scss/variables.scss +180 -120
  415. package/src/components/button/sidebar.ts +7 -7
  416. package/src/components/button/split.ts +11 -13
  417. package/src/components/capslock/index.ts +11 -10
  418. package/src/components/capslock/scss/index.scss +24 -26
  419. package/src/components/capslock/scss/variables.scss +32 -14
  420. package/src/components/card/scss/index.scss +12 -36
  421. package/src/components/card/scss/variables.scss +33 -76
  422. package/src/components/cc/index.ts +46 -42
  423. package/src/components/cc/scss/index.scss +142 -155
  424. package/src/components/cc/scss/variables.scss +234 -44
  425. package/src/components/chat/index.ts +10 -0
  426. package/src/components/{chat-minimap → chat/minimap}/index.ts +74 -28
  427. package/src/components/chat/minimap/scss/index.scss +111 -0
  428. package/src/components/chat/minimap/scss/variables.scss +182 -0
  429. package/src/components/{chat-minimap → chat/minimap}/spy.ts +1 -1
  430. package/src/components/checkbox/group.ts +5 -5
  431. package/src/components/checkbox/index.ts +1 -0
  432. package/src/components/checkbox/options.ts +2 -3
  433. package/src/components/checkbox/scss/index.scss +33 -35
  434. package/src/components/checkbox/scss/variables.scss +102 -56
  435. package/src/components/clipboard/index.ts +4 -3
  436. package/src/components/clipboard/write.ts +2 -1
  437. package/src/components/color-picker/index.ts +131 -69
  438. package/src/components/color-picker/scss/index.scss +138 -221
  439. package/src/components/color-picker/scss/variables.scss +205 -73
  440. package/src/components/command/index.ts +5 -860
  441. package/src/components/command/palette.ts +865 -0
  442. package/src/components/command/scss/index.scss +77 -99
  443. package/src/components/command/scss/variables.scss +129 -50
  444. package/src/components/command/search.ts +62 -0
  445. package/src/components/container/scss/index.scss +2 -4
  446. package/src/components/container/scss/variables.scss +0 -2
  447. package/src/components/counter/index.ts +91 -85
  448. package/src/components/counter/scss/index.scss +33 -41
  449. package/src/components/counter/scss/variables.scss +41 -19
  450. package/src/components/dock/index.ts +514 -42
  451. package/src/components/dock/scss/index.scss +288 -73
  452. package/src/components/dock/scss/variables.scss +301 -39
  453. package/src/components/editor/code/features.ts +4 -6
  454. package/src/components/editor/code/field.ts +1 -1
  455. package/src/components/editor/code/find.ts +1 -2
  456. package/src/components/editor/code/folding.ts +1 -1
  457. package/src/components/editor/code/html.ts +17 -0
  458. package/src/components/editor/code/keymap.ts +0 -1
  459. package/src/components/editor/code/minimap.ts +7 -5
  460. package/src/components/editor/code/rows.ts +1 -14
  461. package/src/components/editor/code/scss/_editor.scss +22 -54
  462. package/src/components/editor/code/scss/_features.scss +28 -70
  463. package/src/components/editor/code/scss/_minimap.scss +29 -0
  464. package/src/components/editor/code/scss/_services.scss +19 -30
  465. package/src/components/editor/code/scss/index.scss +1 -2
  466. package/src/components/editor/code/scss/variables.scss +217 -56
  467. package/src/components/editor/code/search.ts +1 -1
  468. package/src/components/editor/code/services/completion.ts +1 -0
  469. package/src/components/editor/code/services/hover.ts +1 -0
  470. package/src/components/editor/code/services/index.ts +1 -1
  471. package/src/components/editor/code/services/model.ts +1 -1
  472. package/src/components/editor/code/services/session.ts +1 -4
  473. package/src/components/editor/code/syntax.ts +1 -1
  474. package/src/components/editor/code/view.ts +0 -1
  475. package/src/components/editor/diffs/merge.ts +3 -3
  476. package/src/components/editor/diffs/render.ts +2 -17
  477. package/src/components/editor/diffs/scss/_diffs.scss +41 -129
  478. package/src/components/editor/diffs/scss/_merge.scss +9 -41
  479. package/src/components/editor/diffs/scss/index.scss +1 -1
  480. package/src/components/editor/diffs/scss/variables.scss +141 -13
  481. package/src/components/editor/diffs/view.ts +4 -5
  482. package/src/components/editor/markdown/editing.ts +1 -1
  483. package/src/components/editor/markdown/erase.ts +3 -3
  484. package/src/components/editor/markdown/format.ts +517 -0
  485. package/src/components/editor/markdown/html.ts +1 -1
  486. package/src/components/editor/markdown/index.ts +3 -67
  487. package/src/components/editor/markdown/inline.ts +9 -6
  488. package/src/components/editor/markdown/layout.ts +1 -1
  489. package/src/components/editor/markdown/model.ts +2 -17
  490. package/src/components/editor/markdown/render.ts +6 -8
  491. package/src/components/editor/markdown/scss/index.scss +157 -100
  492. package/src/components/editor/markdown/scss/variables.scss +241 -36
  493. package/src/components/editor/markdown/template.ts +69 -0
  494. package/src/components/editor/markdown/toolbar.ts +628 -0
  495. package/src/components/editor/markdown/view.ts +121 -10
  496. package/src/components/editor/tree/drag.ts +19 -15
  497. package/src/components/editor/tree/find.ts +5 -4
  498. package/src/components/editor/tree/icons.ts +1 -1
  499. package/src/components/editor/tree/index.ts +3 -3434
  500. package/src/components/editor/tree/scss/index.scss +261 -294
  501. package/src/components/editor/tree/scss/variables.scss +263 -65
  502. package/src/components/editor/tree/sticky.ts +1 -1
  503. package/src/components/editor/tree/template.ts +3436 -0
  504. package/src/components/editor/viewer/index.ts +3 -318
  505. package/src/components/editor/viewer/model.ts +1 -14
  506. package/src/components/editor/viewer/scss/_viewer.scss +31 -97
  507. package/src/components/editor/viewer/scss/variables.scss +56 -16
  508. package/src/components/editor/viewer/template.ts +323 -0
  509. package/src/components/editor/workspace/index.ts +4 -1480
  510. package/src/components/editor/workspace/model.ts +225 -185
  511. package/src/components/editor/workspace/navigate.ts +3 -6
  512. package/src/components/editor/workspace/scss/_keybindings.scss +165 -0
  513. package/src/components/editor/workspace/scss/_status.scss +65 -0
  514. package/src/components/editor/workspace/scss/_tabs.scss +60 -0
  515. package/src/components/editor/workspace/scss/index.scss +105 -330
  516. package/src/components/editor/workspace/scss/variables.scss +431 -0
  517. package/src/components/editor/workspace/session.ts +96 -53
  518. package/src/components/editor/workspace/shortcuts.ts +0 -2
  519. package/src/components/editor/workspace/status.ts +110 -80
  520. package/src/components/editor/workspace/statusbar.ts +38 -35
  521. package/src/components/editor/workspace/strip.ts +6 -5
  522. package/src/components/editor/workspace/tabs.ts +115 -15
  523. package/src/components/editor/workspace/template.ts +1477 -0
  524. package/src/components/error/index.ts +36 -15
  525. package/src/components/error/scss/index.scss +35 -64
  526. package/src/components/error/scss/variables.scss +29 -9
  527. package/src/components/filter/index.ts +147 -104
  528. package/src/components/filter/scss/index.scss +9 -2
  529. package/src/components/filter/scss/variables.scss +6 -6
  530. package/src/components/form/action.ts +1 -1
  531. package/src/components/form/index.ts +4 -1
  532. package/src/components/frame/scss/index.scss +37 -44
  533. package/src/components/frame/scss/variables.scss +31 -19
  534. package/src/components/grid/scss/index.scss +3 -2
  535. package/src/components/grid/scss/variables.scss +1 -1
  536. package/src/components/group/index.ts +24 -0
  537. package/src/components/group/scss/index.scss +6 -0
  538. package/src/components/group/scss/variables.scss +4 -0
  539. package/src/components/heatmap/index.ts +16 -46
  540. package/src/components/heatmap/scss/index.scss +48 -49
  541. package/src/components/heatmap/scss/variables.scss +74 -51
  542. package/src/components/highlight/index.ts +133 -120
  543. package/src/components/highlight/scss/index.scss +43 -45
  544. package/src/components/highlight/scss/variables.scss +70 -31
  545. package/src/components/icon/index.ts +7 -9
  546. package/src/components/icon/scss/index.scss +9 -2
  547. package/src/components/icon/scss/variables.scss +2 -0
  548. package/src/components/image/index.ts +4 -2
  549. package/src/components/image/lazyload.ts +1 -1
  550. package/src/components/image/scss/index.scss +18 -25
  551. package/src/components/image/scss/variables.scss +31 -12
  552. package/src/components/index.ts +6 -7
  553. package/src/components/inline-edit/index.ts +9 -7
  554. package/src/components/inline-edit/rich.ts +88 -1401
  555. package/src/components/inline-edit/scss/index.scss +125 -381
  556. package/src/components/inline-edit/scss/variables.scss +153 -92
  557. package/src/components/inline-edit/status.ts +8 -4
  558. package/src/components/input/field.ts +2 -2
  559. package/src/components/input/scrub.ts +1 -5
  560. package/src/components/input/scss/_field.scss +1 -1
  561. package/src/components/input/scss/_scrub.scss +21 -25
  562. package/src/components/input/scss/_tag.scss +28 -46
  563. package/src/components/input/scss/index.scss +1 -2
  564. package/src/components/input/scss/variables.scss +160 -77
  565. package/src/components/input/tag.ts +65 -56
  566. package/src/components/json/download.ts +2 -1
  567. package/src/components/json/index.ts +4 -1
  568. package/src/components/link/scss/index.scss +1 -5
  569. package/src/components/link/scss/variables.scss +5 -1
  570. package/src/components/loading/index.ts +1 -1
  571. package/src/components/loading/scss/index.scss +7 -27
  572. package/src/components/loading/scss/variables.scss +7 -10
  573. package/src/components/marquee/index.ts +36 -31
  574. package/src/components/marquee/scss/index.scss +37 -29
  575. package/src/components/marquee/scss/variables.scss +35 -24
  576. package/src/components/marquee/velocity.ts +7 -3
  577. package/src/components/metric/flash.ts +3 -2
  578. package/src/components/metric/index.ts +5 -13
  579. package/src/components/metric/scss/_flash.scss +129 -144
  580. package/src/components/metric/scss/index.scss +38 -48
  581. package/src/components/metric/scss/variables.scss +196 -102
  582. package/src/components/nav/index.ts +1 -1
  583. package/src/components/nav/scss/index.scss +47 -49
  584. package/src/components/nav/scss/variables.scss +59 -64
  585. package/src/components/nav/spy.ts +15 -6
  586. package/src/components/nav/toc.ts +11 -31
  587. package/src/components/nav/tree.ts +77 -47
  588. package/src/components/notification/index.ts +115 -89
  589. package/src/components/notification/scss/index.scss +91 -75
  590. package/src/components/notification/scss/variables.scss +55 -38
  591. package/src/components/overlay/index.ts +211 -139
  592. package/src/components/overlay/popup.ts +89 -52
  593. package/src/components/overlay/scss/index.scss +152 -189
  594. package/src/components/overlay/scss/variables.scss +54 -23
  595. package/src/components/page/scss/variables.scss +1 -1
  596. package/src/components/pagination/cards.ts +1 -1
  597. package/src/components/pagination/index.ts +1 -7
  598. package/src/components/pagination/scss/index.scss +191 -7
  599. package/src/components/pagination/scss/variables.scss +128 -40
  600. package/src/components/panels/dnd.ts +190 -0
  601. package/src/components/panels/group.ts +429 -0
  602. package/src/components/panels/index.ts +676 -0
  603. package/src/components/panels/model.ts +675 -0
  604. package/src/components/panels/resize.ts +157 -0
  605. package/src/components/panels/scss/index.scss +379 -0
  606. package/src/components/panels/scss/variables.scss +197 -0
  607. package/src/components/panels/subtree.ts +65 -0
  608. package/src/components/preview/buttons.ts +48 -0
  609. package/src/components/preview/code.ts +28 -0
  610. package/src/components/preview/header.ts +23 -0
  611. package/src/components/preview/index.ts +149 -0
  612. package/src/components/preview/scss/index.scss +158 -0
  613. package/src/components/preview/scss/variables.scss +149 -0
  614. package/src/components/preview/source.ts +73 -0
  615. package/src/components/preview/stage.ts +33 -0
  616. package/src/components/progress/scss/index.scss +120 -15
  617. package/src/components/progress/scss/variables.scss +144 -41
  618. package/src/components/progress/text.ts +11 -9
  619. package/src/components/radio/index.ts +2 -4
  620. package/src/components/range/filter.ts +16 -22
  621. package/src/components/range/index.ts +2 -9
  622. package/src/components/range/scss/_filter.scss +300 -325
  623. package/src/components/range/scss/_slider.scss +32 -110
  624. package/src/components/range/scss/_vertical.scss +8 -20
  625. package/src/components/range/scss/index.scss +1 -4
  626. package/src/components/range/scss/variables.scss +361 -71
  627. package/src/components/relative-time/index.ts +22 -28
  628. package/src/components/relative-time/scss/index.scss +17 -21
  629. package/src/components/relative-time/scss/variables.scss +51 -30
  630. package/src/components/root/scss/index.scss +14 -20
  631. package/src/components/root/scss/variables.scss +24 -22
  632. package/src/components/select/expand.ts +272 -0
  633. package/src/components/select/index.ts +155 -110
  634. package/src/components/select/scss/index.scss +99 -54
  635. package/src/components/select/scss/variables.scss +141 -19
  636. package/src/components/shell/index.ts +344 -0
  637. package/src/components/shell/scss/index.scss +201 -0
  638. package/src/components/shell/scss/variables.scss +89 -0
  639. package/src/components/shortcut-recorder/index.ts +20 -20
  640. package/src/components/shortcut-recorder/scss/index.scss +78 -58
  641. package/src/components/shortcut-recorder/scss/variables.scss +48 -25
  642. package/src/components/sortable/index.ts +25 -27
  643. package/src/components/sortable/scss/index.scss +59 -63
  644. package/src/components/sortable/scss/variables.scss +81 -52
  645. package/src/components/story/index.ts +111 -83
  646. package/src/components/story/scss/index.scss +26 -107
  647. package/src/components/story/scss/variables.scss +52 -22
  648. package/src/components/surface-field/engine.ts +71 -72
  649. package/src/components/surface-field/index.ts +32 -37
  650. package/src/components/surface-field/scss/index.scss +36 -52
  651. package/src/components/surface-field/scss/variables.scss +89 -23
  652. package/src/components/surface-field/surface.ts +4 -3
  653. package/src/components/switch/index.ts +2 -4
  654. package/src/components/tasklist/index.ts +9 -8
  655. package/src/components/tasklist/scss/index.scss +28 -32
  656. package/src/components/tasklist/scss/variables.scss +31 -32
  657. package/src/components/textarea/index.ts +50 -91
  658. package/src/components/textarea/scss/index.scss +28 -21
  659. package/src/components/textarea/scss/variables.scss +17 -2
  660. package/src/components/theme/cards.ts +19 -0
  661. package/src/components/theme/index.ts +68 -19
  662. package/src/components/theme/reveal.ts +190 -0
  663. package/src/components/theme/scss/index.scss +122 -0
  664. package/src/components/theme/scss/variables.scss +155 -16
  665. package/src/components/theme/shared.ts +57 -0
  666. package/src/components/theme/swatches.ts +15 -0
  667. package/src/components/theme/toggle.ts +47 -0
  668. package/src/components/toast/index.ts +16 -17
  669. package/src/components/toast/scss/index.scss +193 -155
  670. package/src/components/toast/scss/variables.scss +195 -53
  671. package/src/components/tooltip/menu.ts +194 -117
  672. package/src/components/tooltip/onclick.ts +16 -21
  673. package/src/components/tooltip/onhover.ts +5 -8
  674. package/src/components/tooltip/scss/index.scss +561 -85
  675. package/src/components/tooltip/scss/variables.scss +243 -72
  676. package/src/components/tooltip/shared.ts +129 -85
  677. package/src/components/tooltip/utilities.ts +75 -24
  678. package/src/components/typewriter/index.ts +7 -10
  679. package/src/components/typewriter/rotate.ts +26 -31
  680. package/src/components/typewriter/scss/index.scss +133 -3
  681. package/src/components/typewriter/scss/variables.scss +56 -44
  682. package/src/components/uptime/index.ts +13 -19
  683. package/src/components/uptime/scss/index.scss +99 -126
  684. package/src/components/uptime/scss/variables.scss +101 -55
  685. package/src/components/usage-meter/index.ts +1 -1
  686. package/src/components/usage-meter/scss/index.scss +19 -22
  687. package/src/components/usage-meter/scss/variables.scss +80 -36
  688. package/src/css-utilities/absolute.scss +54 -52
  689. package/src/css-utilities/background.scss +29 -23
  690. package/src/css-utilities/border.scss +24 -21
  691. package/src/css-utilities/box-shadow.scss +33 -21
  692. package/src/css-utilities/color.scss +34 -22
  693. package/src/css-utilities/disabled.scss +12 -0
  694. package/src/css-utilities/flex.scss +55 -53
  695. package/src/css-utilities/font/geist/index.scss +2 -1
  696. package/src/css-utilities/font/montserrat/index.scss +1 -1
  697. package/src/css-utilities/group.scss +6 -0
  698. package/src/css-utilities/hidden.scss +22 -20
  699. package/src/css-utilities/icon.scss +33 -30
  700. package/src/css-utilities/layer.scss +12 -11
  701. package/src/css-utilities/reset.scss +27 -16
  702. package/src/css-utilities/skeleton.scss +4 -1
  703. package/src/css-utilities/surface.scss +217 -150
  704. package/src/css-utilities/text.scss +115 -115
  705. package/src/modifiers/background/scss/index.scss +1 -0
  706. package/src/modifiers/background/scss/variables.scss +22 -0
  707. package/src/modifiers/border/scss/index.scss +1 -0
  708. package/src/modifiers/border/scss/variables.scss +19 -0
  709. package/src/modifiers/box-shadow/scss/index.scss +1 -0
  710. package/src/modifiers/box-shadow/scss/variables.scss +12 -0
  711. package/src/modifiers/color/scss/index.scss +1 -0
  712. package/src/modifiers/color/scss/variables.scss +10 -0
  713. package/src/modifiers/disabled/scss/index.scss +5 -0
  714. package/src/modifiers/glass/index.ts +2 -1
  715. package/src/modifiers/glass/scss/index.scss +8 -11
  716. package/src/modifiers/glass/scss/variables.scss +1 -0
  717. package/src/modifiers/scrollbar/index.ts +94 -113
  718. package/src/modifiers/scrollbar/scss/index.scss +23 -4
  719. package/src/modifiers/scrollbar/scss/variables.scss +6 -5
  720. package/src/normalize/scss/index.scss +1 -0
  721. package/src/shared/anchor.ts +1 -1
  722. package/src/shared/animation.ts +9 -7
  723. package/src/shared/dispatch.ts +42 -0
  724. package/src/shared/drag.ts +10 -4
  725. package/src/shared/press.ts +7 -5
  726. package/src/shared/resize.ts +4 -35
  727. package/src/shared/scss/list.scss +1 -2
  728. package/src/shared/transition.ts +2 -2
  729. package/src/shared/visible.ts +3 -35
  730. package/src/tokens/scss/color.scss +50 -38
  731. package/src/tokens/scss/focus.scss +5 -0
  732. package/src/tokens/scss/font-size.scss +1 -2
  733. package/src/tokens/scss/index.scss +1 -1
  734. package/src/tokens/scss/scale.scss +4 -8
  735. package/src/tokens/scss/size.scss +3 -3
  736. package/src/tokens/scss/spacer.scss +1 -1
  737. package/src/tokens/scss/state.scss +25 -29
  738. package/storage/svg/code.svg +1 -1
  739. package/storage/svg/collapse.svg +1 -0
  740. package/storage/svg/grid.svg +1 -0
  741. package/storage/svg/stack.svg +1 -0
  742. package/vite-env.d.ts +1 -1
  743. package/vite.config.ts +10 -8
  744. package/build/components/banner/scss/index.scss +0 -2
  745. package/build/components/button/fan.d.ts +0 -24
  746. package/build/components/button/fan.js +0 -118
  747. package/build/components/button/hold.d.ts +0 -31
  748. package/build/components/button/hold.js +0 -115
  749. package/build/components/button/icons.d.ts +0 -6
  750. package/build/components/button/icons.js +0 -35
  751. package/build/components/button/loading.d.ts +0 -22
  752. package/build/components/button/loading.js +0 -60
  753. package/build/components/button/morph.d.ts +0 -22
  754. package/build/components/button/morph.js +0 -115
  755. package/build/components/card/expand.d.ts +0 -22
  756. package/build/components/card/expand.js +0 -118
  757. package/build/components/card/index.d.ts +0 -6
  758. package/build/components/card/index.js +0 -4
  759. package/build/components/chat-minimap/index.d.ts +0 -28
  760. package/build/components/chat-minimap/index.js +0 -223
  761. package/build/components/chat-minimap/scss/index.scss +0 -2
  762. package/build/components/clipboard/copy.d.ts +0 -27
  763. package/build/components/clipboard/copy.js +0 -48
  764. package/build/components/copy/index.d.ts +0 -23
  765. package/build/components/copy/index.js +0 -61
  766. package/build/components/copy/scss/index.scss +0 -2
  767. package/build/components/datalist/index.d.ts +0 -42
  768. package/build/components/datalist/index.js +0 -186
  769. package/build/components/datalist/scss/index.scss +0 -2
  770. package/build/components/highlight/easing.d.ts +0 -2
  771. package/build/components/highlight/easing.js +0 -19
  772. package/build/components/inline-edit/format.d.ts +0 -29
  773. package/build/components/inline-edit/format.js +0 -112
  774. package/build/components/inline-edit/history.d.ts +0 -14
  775. package/build/components/inline-edit/history.js +0 -40
  776. package/build/components/inline-edit/markdown.d.ts +0 -7
  777. package/build/components/inline-edit/markdown.js +0 -314
  778. package/build/components/inline-edit/model.d.ts +0 -61
  779. package/build/components/inline-edit/model.js +0 -192
  780. package/build/components/inline-edit/selection.d.ts +0 -7
  781. package/build/components/inline-edit/selection.js +0 -114
  782. package/build/components/inline-edit/utilities.d.ts +0 -4
  783. package/build/components/inline-edit/utilities.js +0 -12
  784. package/build/components/pull-to-refresh/index.d.ts +0 -18
  785. package/build/components/pull-to-refresh/index.js +0 -222
  786. package/build/components/pull-to-refresh/scss/index.scss +0 -2
  787. package/build/components/sticky-header/index.d.ts +0 -2166
  788. package/build/components/sticky-header/index.js +0 -58
  789. package/build/components/sticky-header/scss/index.scss +0 -2
  790. package/build/components/theme-picker/index.d.ts +0 -52
  791. package/build/components/theme-picker/index.js +0 -167
  792. package/build/components/theme-picker/scss/index.scss +0 -2
  793. package/src/components/banner/scss/index.scss +0 -37
  794. package/src/components/banner/scss/variables.scss +0 -16
  795. package/src/components/button/fan.ts +0 -170
  796. package/src/components/button/hold.ts +0 -154
  797. package/src/components/button/icons.ts +0 -21
  798. package/src/components/button/loading.ts +0 -77
  799. package/src/components/button/morph.ts +0 -153
  800. package/src/components/button/scss/_fan.scss +0 -121
  801. package/src/components/button/scss/_kbd.scss +0 -11
  802. package/src/components/button/scss/_morph.scss +0 -107
  803. package/src/components/button/scss/_sidebar.scss +0 -61
  804. package/src/components/button/scss/_split.scss +0 -53
  805. package/src/components/card/expand.ts +0 -141
  806. package/src/components/card/index.ts +0 -8
  807. package/src/components/card/scss/_expand.scss +0 -234
  808. package/src/components/chat-minimap/scss/index.scss +0 -148
  809. package/src/components/chat-minimap/scss/variables.scss +0 -97
  810. package/src/components/clipboard/copy.ts +0 -49
  811. package/src/components/copy/index.ts +0 -69
  812. package/src/components/copy/scss/index.scss +0 -52
  813. package/src/components/copy/scss/variables.scss +0 -19
  814. package/src/components/datalist/index.ts +0 -256
  815. package/src/components/datalist/scss/index.scss +0 -104
  816. package/src/components/datalist/scss/variables.scss +0 -33
  817. package/src/components/editor/workspace/scss/keybindings.scss +0 -190
  818. package/src/components/editor/workspace/scss/status.scss +0 -122
  819. package/src/components/editor/workspace/scss/tabs.scss +0 -56
  820. package/src/components/highlight/easing.ts +0 -33
  821. package/src/components/inline-edit/format.ts +0 -183
  822. package/src/components/inline-edit/history.ts +0 -71
  823. package/src/components/inline-edit/markdown.ts +0 -485
  824. package/src/components/inline-edit/model.ts +0 -366
  825. package/src/components/inline-edit/selection.ts +0 -188
  826. package/src/components/inline-edit/utilities.ts +0 -18
  827. package/src/components/pagination/scss/_arrows.scss +0 -69
  828. package/src/components/pagination/scss/_cards.scss +0 -121
  829. package/src/components/pagination/scss/_dots.scss +0 -64
  830. package/src/components/progress/scss/_text.scss +0 -135
  831. package/src/components/pull-to-refresh/index.ts +0 -316
  832. package/src/components/pull-to-refresh/scss/index.scss +0 -128
  833. package/src/components/pull-to-refresh/scss/variables.scss +0 -38
  834. package/src/components/sticky-header/index.ts +0 -78
  835. package/src/components/sticky-header/scss/index.scss +0 -140
  836. package/src/components/sticky-header/scss/variables.scss +0 -46
  837. package/src/components/theme-picker/index.ts +0 -231
  838. package/src/components/theme-picker/scss/index.scss +0 -264
  839. package/src/components/tooltip/scss/_center.scss +0 -9
  840. package/src/components/tooltip/scss/_east.scss +0 -33
  841. package/src/components/tooltip/scss/_menu.scss +0 -367
  842. package/src/components/tooltip/scss/_north.scss +0 -33
  843. package/src/components/tooltip/scss/_shared.scss +0 -109
  844. package/src/components/tooltip/scss/_south.scss +0 -33
  845. package/src/components/tooltip/scss/_west.scss +0 -33
  846. package/src/components/typewriter/scss/_caret.scss +0 -34
  847. package/src/components/typewriter/scss/_retype.scss +0 -68
  848. package/src/components/typewriter/scss/_rotate.scss +0 -29
  849. package/src/tokens/scss/transition.scss +0 -21
  850. /package/build/components/{chat-minimap/range.d.ts → chat/minimap/model.d.ts} +0 -0
  851. /package/src/components/{chat-minimap/range.ts → chat/minimap/model.ts} +0 -0
@@ -1,53 +1,26 @@
1
- import { component, html, type Attributes, type Renderable } from '@esportsplus/template';
2
- import { effect, flush, reactive, ReactiveArray, read, signal, untrack, write, type Signal } from '@esportsplus/reactivity';
3
- import faces from '~/components/button/faces';
4
- import { check as checked, copy as copied, cross } from '~/components/button/icons';
5
- import checkbox from '~/components/checkbox';
6
- import clipboard from '~/components/clipboard/write';
7
- import input from '~/components/input';
8
- import selectInput from '~/components/select';
9
- import tooltip from '~/components/tooltip';
1
+ import { effect, reactive, read, signal, write } from '@esportsplus/reactivity';
2
+ import { component, html, type Attributes } from '@esportsplus/template';
3
+ import markdown, { type MarkdownController, type MarkdownOptions } from '~/components/editor/markdown';
4
+ import icon from '~/components/icon';
10
5
  import { mac } from '~/shared/platform';
11
- import { observe } from '~/shared/resize';
12
- import { viewport } from '~/shared/viewport';
13
- import { active, check, clear, extent, kindAt, link, setKind, toggle, unformat } from './format';
14
- import history, { type Entry, type Kind as Step } from './history';
15
- import { parse, serialize, type Feature, type Group } from './markdown';
16
- import { caret, empty, insert, length, list, nest, order, paste, remove, slice, sort, split, styleAt, text, type Block, type Doc, type Edit, type Kind, type Mark, type Pos, type Selection, type Span, type Tree } from './model';
17
- import { capture, elements, restore, target, written } from './selection';
18
6
  import status, { INLINE_EDIT_STATUS, type Status } from './status';
19
- import { INLINE_LINE_BREAKS, safe } from './utilities';
20
- import boldSvg from '@esportsplus/ui/svg/bold.svg';
7
+ import type { Tool } from '~/components/editor/markdown/toolbar';
21
8
  import checkSvg from '@esportsplus/ui/svg/check.svg';
22
- import clearSvg from '@esportsplus/ui/svg/clear-format.svg';
23
- import codeSvg from '@esportsplus/ui/svg/code.svg';
24
- import highlightSvg from '@esportsplus/ui/svg/highlight.svg';
25
- import italicSvg from '@esportsplus/ui/svg/italic.svg';
26
- import linkSvg from '@esportsplus/ui/svg/link.svg';
27
- import openSvg from '@esportsplus/ui/svg/external-link.svg';
28
9
  import pencilSvg from '@esportsplus/ui/svg/pencil.svg';
29
- import strikeSvg from '@esportsplus/ui/svg/strikethrough.svg';
30
- import unlinkSvg from '@esportsplus/ui/svg/unlink.svg';
31
- import '~/components/button/scss/index.scss';
32
- import '~/components/select/scss/index.scss';
33
10
  import './scss/index.scss';
34
11
 
35
12
 
36
13
  type A = Attributes & {
37
14
  [INLINE_EDIT_RICH_EDITOR]?: Attributes;
38
- [INLINE_EDIT_RICH_TOOLBAR]?: Attributes;
39
15
  [INLINE_EDIT_STATUS]?: Attributes;
40
- // The whitelist: only these become formatting, in the toolbar, the shortcuts, pastes and the saved markdown.
41
- features?: Feature[];
16
+ // The toolbar's tools; markdown typed or pasted outside them still formats.
17
+ features?: Tool[];
42
18
  label: string;
43
19
  multiline?: boolean;
20
+ onconnect?: never;
44
21
  ondisconnect?: never;
45
- ondocumentselectionchange?: never;
46
- onfocusout?: never;
47
22
  // A returned promise holds the status at saving until it settles.
48
23
  onsave?: (value: string) => unknown;
49
- onwindowpointercancel?: never;
50
- onwindowpointerup?: never;
51
24
  placeholder?: string;
52
25
  state?: State;
53
26
  // Shows the save status under the field; pass a Status to read or drive it from outside.
@@ -55,287 +28,30 @@ type A = Attributes & {
55
28
  value?: string;
56
29
  };
57
30
 
58
- type Action = Exclude<Mark, 'link'> | 'clear' | 'copy' | 'link';
59
-
60
- // Consecutive blocks rendered together: the items of one list, or a run of other blocks.
61
- type Section = {
62
- items: ReactiveArray<View>;
63
- kind: 'block' | 'bullet' | 'ordered' | 'task';
64
- slot?: { flush(): void };
65
- };
66
-
67
31
  type State = {
68
32
  editing: boolean;
69
33
  saved: boolean;
70
34
  value: string;
71
35
  };
72
36
 
73
- type Tool = HTMLElement & { [HINT]: Renderable<unknown> };
74
-
75
- // A rendered block. A checklist box only toggles 'checked', so its own animation plays instead of a new box.
76
- type View = {
77
- block: Block;
78
- checked: Signal<boolean>;
79
- };
80
-
81
-
82
- const URL_SCHEME = /^[a-z][a-z\d+.-]*:/i;
83
37
 
84
- const RELATIVE_URL = /^[/#?]/;
85
-
86
- const EMAIL = /^[^\s/@]+@[^\s/@]+\.[^\s/@]+$/;
87
-
88
- const MAC_SHORTCUT = /(⇧?)(\w)$/;
89
-
90
-
91
- const ACTIONS: { action: Action, label: string, shortcut?: string }[] = [
92
- { action: 'bold', label: 'Bold', shortcut: 'B' },
93
- { action: 'italic', label: 'Italic', shortcut: 'I' },
94
- { action: 'strike', label: 'Strikethrough', shortcut: 'Shift+X' },
95
- { action: 'code', label: 'Code', shortcut: 'E' },
96
- { action: 'highlight', label: 'Highlight', shortcut: 'Shift+H' },
97
- { action: 'link', label: 'Link', shortcut: 'K' },
98
- { action: 'clear', label: 'Clear formatting' },
99
- { action: 'copy', label: 'Copy as markdown' }
100
- ];
101
-
102
- const BASE: Feature[] = ['bold', 'italic', 'link', 'copy'];
103
-
104
- // Long enough to read the check, short enough to copy again right away.
105
- const COPIED_FOR = 1400;
106
-
107
- // The browser's own formatting commands (a menu, a touch bar), as marks.
108
- const FORMATS: Partial<Record<string, Exclude<Mark, 'link'>>> = {
109
- formatBold: 'bold',
110
- formatItalic: 'italic',
111
- formatStrikeThrough: 'strike'
112
- };
113
-
114
- // Space between the selection and the toolbar, and between the toolbar and the viewport edge.
115
- const GAP = 8;
116
-
117
- const HINT = Symbol();
118
-
119
- const ICONS: Record<Exclude<Action, 'copy'> | 'apply' | 'open' | 'unlink', string> = {
120
- apply: checkSvg,
121
- bold: boldSvg,
122
- clear: clearSvg,
123
- code: codeSvg,
124
- highlight: highlightSvg,
125
- italic: italicSvg,
126
- link: linkSvg,
127
- open: openSvg,
128
- strike: strikeSvg,
129
- unlink: unlinkSvg
130
- };
38
+ const BASE: Tool[] = ['bold', 'italic', 'link', 'copy'];
131
39
 
132
40
  const INLINE_EDIT_RICH_EDITOR = Symbol.for('@esportsplus/ui/inline-edit.rich.editor');
133
41
 
134
- const INLINE_EDIT_RICH_TOOLBAR = Symbol.for('@esportsplus/ui/inline-edit.rich.toolbar');
135
-
136
- const KINDS: { feature?: Group, label: string, value: Kind }[] = [
137
- { label: 'Text', value: 'paragraph' },
138
- { feature: 'heading', label: 'Heading 1', value: 'h1' },
139
- { feature: 'heading', label: 'Heading 2', value: 'h2' },
140
- { feature: 'heading', label: 'Heading 3', value: 'h3' },
141
- { feature: 'quote', label: 'Quote', value: 'quote' },
142
- { feature: 'codeblock', label: 'Code block', value: 'codeblock' },
143
- { feature: 'bullet', label: 'Bulleted list', value: 'bullet' },
144
- { feature: 'ordered', label: 'Numbered list', value: 'ordered' },
145
- { feature: 'task', label: 'Checklist', value: 'task' }
146
- ];
147
-
148
- // Long enough that labels only show once the pointer rests, so passing across the toolbar stays quiet.
149
- const TOOLTIP_DELAY = 700;
150
-
151
-
152
- // What was typed into the link field, as an address: a bare domain gets https, a bare email mailto.
153
- function address(value: string) {
154
- let href = value.trim();
155
-
156
- if (href && !URL_SCHEME.test(href) && !RELATIVE_URL.test(href)) {
157
- href = (EMAIL.test(href) ? 'mailto:' : 'https://') + href;
158
- }
159
-
160
- return href && safe(href) ? href : '';
161
- }
162
-
163
- // Where the browser didn't say what a delete covers: a character, a word or a line from the caret, or the break to
164
- // the next block at the edge of one.
165
- function around(doc: Doc, pos: Pos, type: string): Span | null {
166
- let backward = type.includes('Backward'),
167
- value = text(doc[pos.block].runs),
168
- to: number;
169
-
170
- if (backward && pos.offset === 0) {
171
- return pos.block > 0 ? { end: pos, start: { block: pos.block - 1, offset: length(doc[pos.block - 1].runs) } } : null;
172
- }
173
-
174
- if (!backward && pos.offset === value.length) {
175
- return pos.block < doc.length - 1 ? { end: { block: pos.block + 1, offset: 0 }, start: pos } : null;
176
- }
177
-
178
- if (type.includes('Line')) {
179
- let edge = backward ? value.lastIndexOf('\n', pos.offset - 1) + 1 : value.indexOf('\n', pos.offset);
180
-
181
- if (edge < 0) {
182
- edge = value.length;
183
- }
184
-
185
- to = edge === pos.offset ? pos.offset + (backward ? -1 : 1) : edge;
186
- }
187
- else {
188
- to = boundary(value, pos.offset, backward, type.includes('Word') ? 'word' : 'grapheme');
189
- }
190
-
191
- let other = { block: pos.block, offset: to };
192
-
193
- return backward ? { end: pos, start: other } : { end: other, start: pos };
194
- }
195
-
196
- function boundary(value: string, offset: number, backward: boolean, granularity: 'grapheme' | 'word') {
197
- let edge = backward ? 0 : value.length;
198
-
199
- for (let { index, isWordLike, segment } of new Intl.Segmenter(undefined, { granularity }).segment(value)) {
200
- let counts = granularity === 'grapheme' || isWordLike;
201
-
202
- if (backward && index < offset && counts) {
203
- edge = index;
204
- }
205
- else if (!backward && index + segment.length > offset && counts) {
206
- return Math.max(index + segment.length, offset + 1);
207
- }
208
- }
209
-
210
- return edge;
211
- }
212
-
213
- function collapsed(span: Span) {
214
- return span.start.block === span.end.block && span.start.offset === span.end.offset;
215
- }
216
-
217
- // Whether 'view' still renders 'next': the same block with the same content. A changed checkbox it takes on itself.
218
- function follows(view: View, next: Block) {
219
- if (view.block === next) {
220
- return true;
221
- }
222
-
223
- if (view.block.key !== next.key || view.block.kind !== next.kind || view.block.runs !== next.runs) {
224
- return false;
225
- }
226
-
227
- view.block = next;
228
- write(view.checked, next.checked);
229
-
230
- return true;
231
- }
232
-
233
- function hint(label: string, shortcut?: string) {
234
- if (!shortcut) {
235
- return label;
236
- }
237
-
238
- return mac()
239
- ? `${label} ${shortcut.replace('Shift+', '⇧')}`.replace(MAC_SHORTCUT, '$1⌘$2')
240
- : `${label} Ctrl+${shortcut}`;
241
- }
242
-
243
- function icon(action: Exclude<Action, 'copy'> | 'apply' | 'open' | 'unlink') {
244
- return html`<svg aria-hidden='true' class='inline-edit-toolbar-icon'><use href='#${ICONS[action]}' /></svg>`;
245
- }
246
-
247
- // Runs as elements; a line break is a <br>.
248
- function inline(trees: Tree[]): Renderable<unknown>[] {
249
- return trees.map((tree) => {
250
- if ('text' in tree) {
251
- return lines(tree.text);
252
- }
253
-
254
- let children = inline(tree.children);
255
-
256
- switch (tree.mark) {
257
- case 'bold':
258
- return html`<strong>${children}</strong>`;
259
- case 'code':
260
- return html`<code>${children}</code>`;
261
- case 'highlight':
262
- return html`<mark>${children}</mark>`;
263
- case 'italic':
264
- return html`<em>${children}</em>`;
265
- case 'link':
266
- return html`<a href='${tree.href}'>${children}</a>`;
267
- default:
268
- return html`<s>${children}</s>`;
269
- }
270
- });
271
- }
272
-
273
- function lines(value: string) {
274
- let out: Renderable<unknown>[] = [],
275
- parts = value.split('\n');
276
-
277
- for (let i = 0, n = parts.length; i < n; i++) {
278
- if (i > 0) {
279
- out.push(html`<br>`);
280
- }
281
-
282
- if (parts[i]) {
283
- out.push(parts[i]);
284
- }
285
- }
286
-
287
- return out;
288
- }
289
-
290
- function partition(doc: Doc) {
291
- let out: { blocks: Block[], kind: Section['kind'] }[] = [];
292
-
293
- for (let i = 0, n = doc.length; i < n; i++) {
294
- let kind = (list(doc[i].kind) ? doc[i].kind : 'block') as Section['kind'],
295
- last = out[out.length - 1];
296
-
297
- if (last && last.kind === kind) {
298
- last.blocks.push(doc[i]);
299
- }
300
- else {
301
- out.push({ blocks: [doc[i]], kind });
302
- }
303
- }
304
-
305
- return out;
306
- }
307
-
308
- // Where 'pos' lands once 'span' is deleted; 'pos' is outside it.
309
- function shift(pos: Pos, { end, start }: Span): Pos {
310
- if (pos.block < end.block || (pos.block === end.block && pos.offset <= end.offset)) {
311
- return pos;
312
- }
313
-
314
- if (pos.block === end.block) {
315
- return { block: start.block, offset: start.offset + pos.offset - end.offset };
316
- }
42
+ // Mod+Enter saves here, so the editor's own binding for it (a blank line) is off.
43
+ const KEYBINDINGS = { 'Mod+Enter': null };
317
44
 
318
- return { block: pos.block - (end.block - start.block), offset: pos.offset };
319
- }
320
-
321
- function spans(a: Span | null, b: Span) {
322
- return !!a
323
- && a.start.block === b.start.block
324
- && a.start.offset === b.start.offset
325
- && a.end.block === b.end.block
326
- && a.end.offset === b.end.offset;
327
- }
328
-
329
- function view(block: Block): View {
330
- return { block, checked: signal(block.checked) };
331
- }
45
+ const SPACES = /\s+/g;
332
46
 
333
47
 
48
+ // The markdown editor in its inline mode: it rests as text, edits in place with the formatting toolbar over a
49
+ // selection, and saves when focus leaves, on Enter for one line or Mod+Enter for several; Escape puts the text back.
334
50
  export default component(
335
51
  function(
336
- this: { attributes?: Pick<A, typeof INLINE_EDIT_RICH_EDITOR | typeof INLINE_EDIT_RICH_TOOLBAR | typeof INLINE_EDIT_STATUS> } | void,
52
+ this: { attributes?: Pick<A, typeof INLINE_EDIT_RICH_EDITOR | typeof INLINE_EDIT_STATUS> } | void,
337
53
  {
338
- features: whitelist = BASE,
54
+ features = BASE,
339
55
  label,
340
56
  multiline = false,
341
57
  onsave,
@@ -346,1173 +62,144 @@ export default component(
346
62
  ...attributes
347
63
  }: A
348
64
  ) {
349
- let features = new Set(multiline ? whitelist : whitelist.filter((feature) => !KINDS.some((k) => k.feature === feature))),
350
- actions = ACTIONS.filter(({ action }) => features.has(action)),
351
- block = reactive({ active: false, error: '', selected: 'paragraph' }),
352
- doc = signal<Doc>(parse(state.value, features, multiline)),
353
- hyperlink = reactive({ existing: false, invalid: false, url: '' }),
354
- // Declared so page-wide shortcuts (a command palette on Mod+K) leave these to the text.
355
- keyshortcuts = actions
356
- .flatMap(({ shortcut }) => shortcut ? ['Control', 'Meta'].map((mod) => `${mod}+${shortcut}`) : [])
357
- .concat(multiline ? ['Control+Enter', 'Meta+Enter'] : [])
358
- .join(' '),
359
- kinds = KINDS.filter((k) => !k.feature || features.has(k.feature)),
360
- // 'focus' is the format control the arrow keys rove to, the toolbar's one tab stop.
361
- local = reactive({ copied: 'idle' as 'error' | 'idle' | 'success', focus: 0, live: '' }),
362
- marks = actions.filter(({ action }) => action !== 'clear' && action !== 'copy'),
363
- // The toolbar: 'link' swaps its buttons for the link field, 'instant' holds its moves still, 'origin' and
364
- // 'x'/'y' place it over the selection.
365
- panel = reactive({ instant: false, link: false, open: false, origin: '', x: 0, y: 0 }),
366
- // Mark buttons by their mark, pressed while the selection carries it.
367
- pressed = reactive(Object.fromEntries(marks.map(({ action }) => [action, false])) as Record<string, boolean>),
368
- // The saved value as this field writes it, which a value from outside may not be: what an edit differs from.
369
- pristine = signal(serialize(read(doc), features, multiline)),
370
- saving = status.saver(state, indicator, () => serialize(read(doc), features, multiline) !== read(pristine), onsave),
371
- sections = new ReactiveArray<Section>(partition(read(doc)).map(section)),
372
- slot = html.reactive(sections, group),
373
- steps = history(),
374
- tip = tooltip.shared({ delay: { open: TOOLTIP_DELAY } });
375
-
376
- let composing: { block: number, element: HTMLElement } | null = null,
377
- copyTimer: ReturnType<typeof setTimeout> | undefined,
378
- dismissed = false,
379
- // A drag from inside the text: what it moves, until the drop lands it.
380
- dragged: Span | null = null,
381
- editor: HTMLElement | undefined,
382
- frame = 0,
383
- items: HTMLElement[] = [],
384
- keys: AbortController | undefined,
385
- pressing = false,
65
+ let apple = mac(),
66
+ controller: MarkdownController | undefined,
67
+ current = signal(state.value),
68
+ // The saved value as this field holds it: what an edit differs from.
69
+ pristine = signal(state.value),
386
70
  root: HTMLElement | undefined,
387
- saved: Span | null = null,
388
- selection: Selection | null = null,
389
- settling: ReturnType<typeof setTimeout> | undefined,
390
- shown: Kind = 'paragraph',
391
- toolbar: HTMLElement | undefined,
392
- unobserve: VoidFunction | undefined,
393
- url: HTMLInputElement | undefined;
394
-
395
- // The select only reports a value; one that differs from the block under the selection is a choice.
396
- effect(() => {
397
- let next = block.selected as Kind;
398
-
399
- if (next !== shown) {
400
- untrack(() => turn(next));
401
- }
402
- });
71
+ saving = status.saver(state, indicator, () => clean(read(current)) !== read(pristine), onsave),
72
+ defaults = this?.attributes?.[INLINE_EDIT_RICH_EDITOR],
73
+ own = attributes[INLINE_EDIT_RICH_EDITOR],
74
+ options: MarkdownOptions = {
75
+ inline: true,
76
+ keybindings: KEYBINDINGS,
77
+ label,
78
+ placeholder,
79
+ singleLine: !multiline,
80
+ toolbar: features
81
+ };
403
82
 
404
83
  // A value set from outside while the field rests shows at once.
405
84
  effect(() => state.value, (next, previous) => {
406
85
  if (previous !== undefined && !state.editing && next !== read(pristine)) {
407
- load(next);
86
+ write(pristine, next);
87
+ controller?.setValue(next);
408
88
  }
409
89
  });
410
90
 
411
- function apply(href: string | null) {
412
- let span = current();
413
-
414
- if (!editor || !span) {
415
- return;
416
- }
417
-
418
- if (href !== null) {
419
- href = address(href);
420
-
421
- if (!href) {
422
- hyperlink.invalid = true;
423
- return;
424
- }
425
- }
426
-
427
- back();
428
- change(link(read(doc), span, href), 'other');
429
- local.live = href ? 'Link set' : 'Link removed';
430
- }
431
-
432
- // Leaves the link field for the buttons, handing focus and the selection back to the text.
433
- function back() {
434
- panel.link = false;
435
- editor?.focus({ preventScroll: true });
436
-
437
- let span = current();
438
-
439
- if (span) {
440
- select({ anchor: span.start, focus: span.end });
441
-
442
- let range = live();
443
-
444
- if (range) {
445
- place(range);
446
- }
447
- }
448
- }
449
-
450
- // Records the change for undo, renders it and puts the selection where it leaves off.
451
- function change(edit: Edit, kind: Step) {
452
- steps.push({ doc: read(doc), selection }, edit.selection, kind);
453
- commit(edit.doc);
454
- select(edit.selection);
455
- }
456
-
457
- // Copies carry markdown, so a paste back in keeps the formatting.
458
- function clip(e: ClipboardEvent, cut: boolean) {
459
- let range = live(),
460
- now = editor ? capture(editor) : null;
461
-
462
- if (!range || range.collapsed || !now || !e.clipboardData) {
463
- return;
464
- }
465
-
466
- let holder = document.createElement('div'),
467
- span = order(now);
468
-
469
- holder.append(range.cloneContents());
470
- e.preventDefault();
471
- e.clipboardData.setData('text/html', holder.innerHTML);
472
- e.clipboardData.setData('text/plain', serialize(excerpt(span), features, multiline));
473
-
474
- if (cut) {
475
- change(remove(read(doc), span), 'other');
476
- }
477
- }
478
-
479
- // The DOM follows the model: each section's items are patched by block identity, so only blocks that changed
480
- // render again, and the slots land it before the selection is placed.
481
- function commit(next: Doc) {
482
- write(doc, next);
483
-
484
- let parts = partition(next),
485
- end = 0,
486
- m = parts.length,
487
- n = sections.length,
488
- start = 0;
489
-
490
- while (start < n && start < m && sections[start].kind === parts[start].kind) {
491
- patch(sections[start].items, parts[start].blocks);
492
- start++;
493
- }
494
-
495
- while (end < n - start && end < m - start && sections[n - 1 - end].kind === parts[m - 1 - end].kind) {
496
- patch(sections[n - 1 - end].items, parts[m - 1 - end].blocks);
497
- end++;
498
- }
499
-
500
- if (start + end < n || start + end < m) {
501
- sections.splice(start, n - start - end, ...parts.slice(start, m - end).map(section));
502
- }
503
-
504
- slot.flush();
505
-
506
- for (let i = 0, o = sections.length; i < o; i++) {
507
- sections[i].slot?.flush();
508
- }
509
-
510
- flush();
511
- }
512
-
513
- async function copy() {
514
- let span = current();
515
-
516
- if (!span) {
517
- return;
518
- }
519
-
520
- // Confirms on press; waiting for the write makes the click feel ignored.
521
- clearTimeout(copyTimer);
522
- local.copied = 'success';
523
- local.live = 'Copied';
524
- copyTimer = setTimeout(() => {
525
- local.copied = 'idle';
526
- }, COPIED_FOR);
527
-
528
- if (!(await clipboard(serialize(excerpt(span), features, multiline)))) {
529
- local.copied = 'error';
530
- local.live = 'Couldn\'t copy';
531
- }
532
- }
533
-
534
- function current() {
535
- let blocks = read(doc);
536
-
537
- if (!saved || collapsed(saved) || !blocks[saved.end.block]) {
538
- return null;
539
- }
540
-
541
- return saved;
542
- }
543
-
544
- function dismiss() {
545
- dismissed = true;
546
- show(false);
547
- }
548
-
549
- // A drop from inside the text moves what was dragged; one from elsewhere pastes.
550
- function drop(e: InputEvent, at: Span) {
551
- let from = dragged;
552
-
553
- dragged = null;
554
-
555
- if (!from) {
556
- land(at, e.dataTransfer?.getData('text/plain') ?? '');
557
- return;
558
- }
559
-
560
- let pos = at.start,
561
- inside = (pos.block > from.start.block || (pos.block === from.start.block && pos.offset >= from.start.offset))
562
- && (pos.block < from.end.block || (pos.block === from.end.block && pos.offset <= from.end.offset));
563
-
564
- if (inside) {
565
- return;
566
- }
567
-
568
- let moved = excerpt(from),
569
- rest = remove(read(doc), from).doc,
570
- to = shift(pos, from);
571
-
572
- change(paste(rest, { end: to, start: to }, moved), 'other');
573
- }
574
-
575
- // Turns each kind of input into a change to the model. The browser never edits the DOM itself; an input
576
- // method does, and composition ends by reading back what it wrote.
577
- function edit(e: InputEvent) {
578
- let type = e.inputType;
579
-
580
- if (e.isComposing || type === 'insertCompositionText' || type === 'deleteCompositionText' || type === 'insertFromComposition') {
581
- return;
582
- }
583
-
584
- e.preventDefault();
585
- resolve();
586
-
587
- if (!editor) {
588
- return;
589
- }
590
-
591
- let now = capture(editor),
592
- range = e.getTargetRanges()[0],
593
- span = (range && target(editor, range)) || (now && order(now));
594
-
595
- if (!span) {
596
- return;
597
- }
598
-
599
- let format = FORMATS[type];
600
-
601
- if (format) {
602
- if (features.has(format) && !collapsed(span)) {
603
- change(toggle(read(doc), span, format), 'other');
604
- }
605
-
606
- return;
607
- }
608
-
609
- switch (type) {
610
- case 'deleteByDrag':
611
- dragged = span;
612
- return;
613
- case 'formatRemove':
614
- if (features.has('clear') && !collapsed(span)) {
615
- change(clear(read(doc), span), 'other');
616
- }
617
-
618
- return;
619
- case 'historyRedo':
620
- redo();
621
- return;
622
- case 'historyUndo':
623
- undo();
624
- return;
625
- case 'insertFromDrop':
626
- drop(e, span);
627
- return;
628
- case 'insertFromPaste':
629
- land(span, e.dataTransfer?.getData('text/plain') ?? '');
630
- return;
631
- case 'insertLineBreak':
632
- case 'insertParagraph':
633
- if (!multiline) {
634
- finish(true, true);
635
- }
636
- else if (type === 'insertParagraph') {
637
- change(split(read(doc), span), 'other');
638
- }
639
- else {
640
- typed(span, '\n');
641
- }
642
-
643
- return;
644
- case 'insertOrderedList':
645
- case 'insertUnorderedList': {
646
- let kind: Kind = type === 'insertOrderedList' ? 'ordered' : 'bullet';
647
-
648
- if (features.has(kind as Group)) {
649
- change(setKind(read(doc), span, kind), 'other');
650
- }
651
-
652
- return;
653
- }
654
- }
655
-
656
- if (type.startsWith('insert')) {
657
- typed(span, e.data ?? e.dataTransfer?.getData('text/plain') ?? '');
658
- }
659
- else if (type.startsWith('delete')) {
660
- erase(type, span, now);
661
- }
662
- }
663
-
664
- function erase(type: string, span: Span, now: Selection | null) {
665
- let blocks = read(doc),
666
- at = now && now.anchor.block === now.focus.block && now.anchor.offset === now.focus.offset ? now.focus : null;
667
-
668
- if (type === 'deleteContentBackward' && at?.offset === 0) {
669
- let next = unformat(blocks, at.block);
670
-
671
- if (next) {
672
- change(next, 'other');
673
- return;
674
- }
675
- }
676
-
677
- let reach = collapsed(span) && at ? around(blocks, at, type) : span;
678
-
679
- if (reach && !collapsed(reach)) {
680
- change(remove(blocks, reach), type === 'deleteByCut' ? 'other' : 'delete');
681
- }
682
- }
683
-
684
- // What a copy takes: within one block just its text, across several the blocks as they are.
685
- function excerpt(span: Span) {
686
- let part = slice(read(doc), span);
687
-
688
- if (part.length === 1) {
689
- part[0] = { ...part[0], checked: false, kind: 'paragraph' };
690
- }
691
-
692
- return part;
91
+ function clean(text: string) {
92
+ return multiline ? text.trim() : text.replace(SPACES, ' ').trim();
693
93
  }
694
94
 
695
95
  function finish(commit: boolean, keyboard: boolean) {
696
- if (!editor || !state.editing) {
96
+ if (!state.editing || !controller) {
697
97
  return;
698
98
  }
699
99
 
700
- resolve();
701
100
  state.editing = false;
702
- panel.link = false;
703
- show(false);
704
101
 
705
102
  if (commit) {
706
103
  save();
707
104
  }
708
-
709
- // Rebuilt from the markdown either way: a save drops anything outside the whitelist, a cancel reverts.
710
- load(state.value);
711
-
712
- if (keyboard) {
713
- editor.blur();
714
- }
715
- }
716
-
717
- function focus(index: number) {
718
- local.focus = (index + items.length) % items.length;
719
- items[local.focus]?.focus();
720
- }
721
-
722
- function group(section: Section) {
723
- let slot = html.reactive(section.items, item);
724
-
725
- section.slot = slot;
726
-
727
- switch (section.kind) {
728
- case 'bullet':
729
- return html`<ul>${slot}</ul>`;
730
- case 'ordered':
731
- return html`<ol>${slot}</ol>`;
732
- case 'task':
733
- return html`<ul data-task>${slot}</ul>`;
734
- default:
735
- return html`${slot}`;
736
- }
737
- }
738
-
739
- // Inspects the selection for the toolbar: which marks it carries, and the kind of block it starts in.
740
- function inspect(span: Span) {
741
- let blocks = read(doc);
742
-
743
- for (let i = 0, n = marks.length; i < n; i++) {
744
- let mark = marks[i].action as Mark;
745
-
746
- pressed[mark] = active(blocks, span, mark);
747
- }
748
-
749
- shown = kindAt(blocks, span);
750
- block.selected = shown;
751
- }
752
-
753
- function item(view: View) {
754
- let { kind, runs } = view.block,
755
- characters = text(runs),
756
- body = [inline(nest(runs)), (!characters || characters.endsWith('\n')) && html`<br data-filler>`];
757
-
758
- switch (kind) {
759
- case 'bullet':
760
- case 'ordered':
761
- return html`<li data-block>${body}</li>`;
762
- case 'codeblock':
763
- return html`<pre data-block>${body}</pre>`;
764
- case 'h1':
765
- return html`<h1 data-block>${body}</h1>`;
766
- case 'h2':
767
- return html`<h2 data-block>${body}</h2>`;
768
- case 'h3':
769
- return html`<h3 data-block>${body}</h3>`;
770
- case 'quote':
771
- return html`<blockquote data-block>${body}</blockquote>`;
772
- case 'task':
773
- return html`
774
- <li data-block ${{ 'data-checked': () => read(view.checked) ? 'true' : 'false' }}>
775
- <span class='inline-edit-task' contenteditable='false'>
776
- ${checkbox({
777
- [checkbox.input]: {
778
- 'aria-label': 'Done',
779
- checked: () => read(view.checked),
780
- onchange: (e: Event) => tick(view, (e.currentTarget as HTMLInputElement).checked)
781
- }
782
- })}
783
- </span>
784
- ${body}
785
- </li>
786
- `;
787
- default:
788
- return html`<p data-block>${body}</p>`;
789
- }
790
- }
791
-
792
- // Markdown lands as formatting, taking on the style at the caret; inside code it stays as typed.
793
- function land(span: Span, value: string) {
794
- if (!value) {
795
- return;
796
- }
797
-
798
- let blocks = read(doc),
799
- host = blocks[span.start.block],
800
- style = styleAt(host.runs, span.start.offset);
801
-
802
- if (host.kind === 'codeblock' || style.marks.includes('code')) {
803
- change(insert(blocks, span, [{ ...style, text: host.kind === 'codeblock' ? value : value.replace(INLINE_LINE_BREAKS, ' ') }]), 'other');
804
- return;
805
- }
806
-
807
- let pasted = parse(value, features, multiline && value.includes('\n'));
808
-
809
- if (pasted.length === 1 && pasted[0].kind === 'paragraph') {
810
- if (!pasted[0].runs.length) {
811
- return;
812
- }
813
-
814
- pasted[0] = {
815
- ...pasted[0],
816
- runs: pasted[0].runs.map((run) => ({ href: run.href || style.href, marks: sort([...style.marks, ...run.marks]), text: run.text }))
817
- };
818
- }
819
-
820
- change(paste(blocks, span, pasted), 'other');
821
- }
822
-
823
- function leave(e: FocusEvent) {
824
- // Focus moving between the text and the toolbar stays in the edit.
825
- if (!root?.contains(e.relatedTarget as Node | null)) {
826
- finish(true, false);
827
- }
828
- }
829
-
830
- // Swaps the buttons for the link field, prefilled when the selection sits in a link.
831
- function linker() {
832
- let span = current();
833
-
834
- if (!editor || !span || !toolbar || !url) {
835
- return;
105
+ else {
106
+ controller.setValue(read(pristine));
836
107
  }
837
108
 
838
- let found = extent(read(doc), span);
839
-
840
- if (found) {
841
- saved = found.span;
842
- select({ anchor: found.span.start, focus: found.span.end });
843
- }
844
-
845
- panel.link = true;
846
- hyperlink.existing = !!found;
847
- hyperlink.invalid = false;
848
- hyperlink.url = found?.href ?? '';
849
-
850
- let range = live();
851
-
852
- if (range) {
853
- place(range);
854
- }
855
-
856
- // The field shows, and takes its value, once the link mode lands.
857
- flush();
858
- url.focus({ preventScroll: true });
859
- url.select();
860
- }
861
-
862
- function live() {
863
- let native = window.getSelection();
864
-
865
- return native && native.rangeCount > 0 ? native.getRangeAt(0) : null;
866
- }
867
-
868
- // A fresh document from markdown, with nothing to undo.
869
- function load(markdown: string) {
870
- let next = parse(markdown, features, multiline);
871
-
872
- steps.clear();
873
- write(pristine, serialize(next, features, multiline));
874
- commit(next);
875
- }
876
-
877
- function navigate(e: KeyboardEvent) {
878
- if (e.target === url) {
879
- if (e.key === 'Enter') {
880
- e.preventDefault();
881
- apply(url.value);
882
- }
883
- else if (e.key === 'Escape') {
884
- e.preventDefault();
885
- back();
886
- }
887
-
888
- return;
889
- }
890
-
891
- if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
892
- e.preventDefault();
893
- focus(local.focus + (e.key === 'ArrowRight' ? 1 : -1));
894
- }
895
- else if (e.key === 'Home' || e.key === 'End') {
896
- e.preventDefault();
897
- focus(e.key === 'Home' ? 0 : -1);
898
- }
899
- else if (e.key === 'Escape' && !block.active) {
900
- e.preventDefault();
901
- dismiss();
902
- editor?.focus({ preventScroll: true });
903
-
904
- let span = current();
109
+ if (keyboard) {
110
+ let active = root?.ownerDocument.activeElement;
905
111
 
906
- if (span) {
907
- select({ anchor: span.start, focus: span.end });
112
+ if (active instanceof HTMLElement && root?.contains(active)) {
113
+ active.blur();
908
114
  }
909
115
  }
910
116
  }
911
117
 
912
- // Only the blocks that differ from what is rendered render again; a box ticked or unticked just follows.
913
- function patch(items: ReactiveArray<View>, next: Block[]) {
914
- let end = 0,
915
- m = next.length,
916
- n = items.length,
917
- start = 0;
918
-
919
- while (start < n && start < m && follows(items[start], next[start])) {
920
- start++;
921
- }
922
-
923
- while (end < n - start && end < m - start && follows(items[n - 1 - end], next[m - 1 - end])) {
924
- end++;
925
- }
926
-
927
- if (start + end < n || start + end < m) {
928
- items.splice(start, n - start - end, ...next.slice(start, m - end).map(view));
929
- }
930
- }
931
-
932
- function place(range: Range) {
933
- if (!root || !toolbar) {
934
- return;
935
- }
936
-
937
- let bounds = range.getBoundingClientRect(),
938
- box = root.getBoundingClientRect(),
939
- h = toolbar.offsetHeight,
940
- lines = [...range.getClientRects()].filter((rect) => rect.width > 0),
941
- w = toolbar.offsetWidth;
942
-
943
- let first = lines[0] ?? bounds,
944
- last = lines[lines.length - 1] ?? bounds;
945
-
946
- // Floats outside the field, so only the viewport limits it: flips below when there's no room above.
947
- let below = first.top < h + GAP,
948
- center = bounds.left + bounds.width / 2,
949
- x = Math.min(Math.max(center - w / 2, GAP), viewport().width - w - GAP);
950
-
951
- // Scales out of the selection itself, even when clamped to the edge.
952
- panel.origin = `${center - x}px ${below ? 0 : h}px`;
953
- panel.x = x - box.left;
954
- panel.y = below ? last.bottom - box.top + GAP : first.top - box.top - h - GAP;
955
-
956
- // Shown afresh it jumps there, committed before its moves glide again; once open it glides along.
957
- if (!panel.open) {
958
- panel.instant = true;
959
- flush();
960
- void toolbar.offsetWidth;
961
- panel.instant = false;
962
- }
963
- }
964
-
965
- function redo() {
966
- let entry = steps.redo({ doc: read(doc), selection });
967
-
968
- if (entry) {
969
- revert(entry);
970
- }
971
- }
972
-
973
- // Ends a composition: the text the input method wrote replaces the model's, and the block renders again so
974
- // none of the nodes it made stay behind.
975
- function resolve() {
976
- clearTimeout(settling);
977
-
978
- if (!composing || !editor) {
979
- return;
980
- }
981
-
982
- let { block: i, element } = composing,
983
- blocks = read(doc);
984
-
985
- composing = null;
986
-
987
- if (!blocks[i] || !element.isConnected) {
988
- sections.splice(0, sections.length, ...partition(blocks).map(section));
989
- commit(blocks);
990
- return;
991
- }
992
-
993
- let after = written(element),
994
- before = text(blocks[i].runs),
995
- end = 0,
996
- now = capture(editor),
997
- start = 0;
998
-
999
- while (start < before.length && start < after.length && before[start] === after[start]) {
1000
- start++;
1001
- }
1002
-
1003
- while (end < before.length - start && end < after.length - start && before[before.length - 1 - end] === after[after.length - 1 - end]) {
1004
- end++;
1005
- }
1006
-
1007
- let next = insert(
1008
- blocks,
1009
- { end: { block: i, offset: before.length - end }, start: { block: i, offset: start } },
1010
- [{ ...styleAt(blocks[i].runs, start), text: after.slice(start, after.length - end) }]
1011
- ),
1012
- at = now && now.focus.block === i ? now.focus : next.selection.focus;
1013
-
1014
- next.doc[i] = { ...next.doc[i], runs: next.doc[i].runs.slice() };
1015
-
1016
- if (before === after) {
1017
- commit(next.doc);
1018
- select(caret(at));
1019
- return;
1020
- }
1021
-
1022
- change({ doc: next.doc, selection: caret(at) }, 'type');
1023
- }
1024
-
1025
- function revert(entry: Entry) {
1026
- commit(entry.doc);
1027
-
1028
- if (entry.selection) {
1029
- select(entry.selection);
1030
- }
1031
- }
1032
-
1033
118
  function save() {
1034
- let next = serialize(read(doc), features, multiline);
119
+ let next = clean(read(current));
1035
120
 
1036
121
  if (next === read(pristine)) {
1037
122
  return;
1038
123
  }
1039
124
 
1040
125
  write(pristine, next);
1041
- saving.save(next);
1042
- }
1043
-
1044
- function section({ blocks, kind }: { blocks: Block[], kind: Section['kind'] }): Section {
1045
- return { items: new ReactiveArray<View>(blocks.map(view)), kind };
1046
- }
1047
-
1048
- function select(next: Selection) {
1049
- selection = next;
1050
-
1051
- if (editor && document.activeElement === editor) {
1052
- restore(editor, next);
1053
- }
1054
- }
1055
-
1056
- // The selection finalises after pointerup, so it is read a frame later.
1057
- function settle() {
1058
- if (!pressing) {
1059
- return;
1060
- }
1061
-
1062
- pressing = false;
1063
- cancelAnimationFrame(frame);
1064
- frame = requestAnimationFrame(sync);
1065
- }
1066
-
1067
- function show(next: boolean, instant = false) {
1068
- panel.open = next;
1069
-
1070
- if (instant) {
1071
- panel.instant = true;
1072
- }
1073
- }
1074
-
1075
- function sync() {
1076
- if (!editor || !toolbar) {
1077
- return;
1078
- }
1079
126
 
1080
- let now = capture(editor);
1081
-
1082
- if (now) {
1083
- selection = now;
1084
- }
1085
-
1086
- if (composing || (!actions.length && kinds.length < 2)) {
1087
- return;
1088
- }
1089
-
1090
- let range = live();
1091
-
1092
- // Focus in the toolbar (its buttons, the select, the link field) keeps it where it is.
1093
- if (toolbar.contains(document.activeElement) || panel.link) {
1094
- return;
1095
- }
1096
-
1097
- if (!now || !range || range.collapsed || !editor.contains(range.commonAncestorContainer)) {
1098
- if (panel.open) {
1099
- show(false);
1100
- }
1101
-
1102
- return;
1103
- }
1104
-
1105
- // A drag in progress settles on release, so the toolbar doesn't chase every pixel.
1106
- if (pressing) {
1107
- return;
1108
- }
1109
-
1110
- let span = order(now);
1111
-
1112
- if (dismissed) {
1113
- if (spans(saved, span)) {
1114
- return;
1115
- }
1116
-
1117
- dismissed = false;
1118
- }
1119
-
1120
- saved = span;
1121
- place(range);
1122
- inspect(span);
1123
-
1124
- if (!panel.open) {
1125
- local.focus = 0;
1126
- show(true);
1127
- }
1128
- }
1129
-
1130
- // Ticked without editing, it saves at once; mid-edit it goes with the rest.
1131
- function tick(view: View, value: boolean) {
1132
- let blocks = read(doc),
1133
- index = blocks.findIndex((b) => b.key === view.block.key);
1134
-
1135
- if (index < 0) {
1136
- return;
1137
- }
1138
-
1139
- change({ doc: check(blocks, index, value), selection: selection ?? caret({ block: index, offset: 0 }) }, 'other');
1140
-
1141
- if (!state.editing) {
1142
- save();
1143
- }
1144
- }
1145
-
1146
- function trigger(action: Action) {
1147
- let span = current();
1148
-
1149
- if (!span) {
1150
- return;
1151
- }
1152
-
1153
- switch (action) {
1154
- case 'clear':
1155
- change(clear(read(doc), span), 'other');
1156
- local.live = 'Formatting cleared';
1157
- break;
1158
- case 'copy':
1159
- void copy();
1160
- return;
1161
- case 'link':
1162
- linker();
1163
- return;
1164
- default:
1165
- change(toggle(read(doc), span, action), 'other');
1166
- }
1167
-
1168
- inspect(span);
1169
- }
1170
-
1171
- function turn(kind: Kind) {
1172
- let span = current();
1173
-
1174
- if (!editor || !span) {
1175
- return;
1176
- }
1177
-
1178
- shown = kind;
1179
- editor.focus({ preventScroll: true });
1180
- change(setKind(read(doc), span, kind), 'other');
1181
- }
1182
-
1183
- // Typing takes on the style of the text it follows; a one line field has no line breaks to take.
1184
- function typed(span: Span, value: string) {
1185
- if (!multiline) {
1186
- value = value.replace(INLINE_LINE_BREAKS, ' ');
1187
- }
1188
-
1189
- if (!value) {
1190
- return;
127
+ if (controller && controller.document.value !== next) {
128
+ controller.setValue(next);
1191
129
  }
1192
130
 
1193
- let blocks = read(doc),
1194
- style = styleAt(blocks[span.start.block].runs, span.start.offset + (collapsed(span) ? 0 : 1));
1195
-
1196
- change(insert(blocks, span, [{ ...style, text: value }]), 'type');
1197
- }
1198
-
1199
- function undo() {
1200
- let entry = steps.undo({ doc: read(doc), selection });
1201
-
1202
- if (entry) {
1203
- revert(entry);
1204
- }
131
+ saving.save(next);
1205
132
  }
1206
133
 
1207
- // 'index' is the button's place among the format controls the arrow keys rove.
1208
- let button = ({ action, label, shortcut }: (typeof ACTIONS)[number], content: Renderable<unknown>, index: number) => html`
1209
- <button
1210
- aria-label='${label}'
1211
- class='button button--feedback inline-edit-toolbar-button'
1212
- tabindex='${() => local.focus === index ? '0' : '-1'}'
1213
- type='button'
1214
- ${action === 'clear' || action === 'copy' ? {} : { 'aria-pressed': () => pressed[action] ? 'true' : 'false' }}
1215
- ${{
1216
- onclick: () => trigger(action),
1217
- onconnect: (element: Tool) => {
1218
- element[HINT] = action === 'copy' ? () => local.copied === 'success' ? 'Copied' : label : hint(label, shortcut);
1219
- items[index] = element;
1220
- }
1221
- }}
1222
- >
1223
- ${content}
1224
- </button>
1225
- `;
1226
-
1227
- // The text style select leads the format controls when there is one.
1228
- let lead = kinds.length > 1 ? 1 : 0,
1229
- tools = actions.filter(({ action }) => action === 'clear' || action === 'copy');
1230
-
1231
134
  return html`
1232
135
  <div
1233
- class='inline-edit'
136
+ class='inline-edit inline-edit--rich'
1234
137
  ${this?.attributes}
1235
138
  ${attributes}
1236
139
  ${{
1237
140
  class: [
1238
141
  multiline && 'inline-edit--multiline',
1239
142
  () => state.editing && '--active',
1240
- () => state.saved && 'inline-edit--saved',
1241
- () => empty(read(doc)) && 'inline-edit--empty'
143
+ () => state.saved && 'inline-edit--saved'
1242
144
  ],
1243
- onconnect: (element: HTMLElement) => {
145
+ // Direct: delegation only runs the nearest bound handler, and the editor binds these itself.
146
+ onconnect: (element: HTMLElement, on) => {
1244
147
  root = element;
1245
- unobserve?.();
1246
- unobserve = observe(element, sync);
1247
- },
1248
- ondisconnect: () => {
1249
- cancelAnimationFrame(frame);
1250
- clearTimeout(copyTimer);
1251
- clearTimeout(settling);
1252
- keys?.abort();
1253
- unobserve?.();
1254
- unobserve = undefined;
1255
- saving.dispose();
1256
- },
1257
- ondocumentselectionchange: sync,
1258
- onfocusout: leave,
1259
- onwindowpointercancel: settle,
1260
- onwindowpointerup: settle
1261
- }}
1262
- >
1263
- <div
1264
- aria-label='${label}'
1265
- aria-multiline='${multiline ? 'true' : 'false'}'
1266
- aria-keyshortcuts='${keyshortcuts}'
1267
- aria-placeholder='${placeholder}'
1268
- class='inline-edit-editor'
1269
- contenteditable='true'
1270
- data-placeholder='${placeholder}'
1271
- role='textbox'
1272
- ${this?.attributes?.[INLINE_EDIT_RICH_EDITOR]}
1273
- ${attributes[INLINE_EDIT_RICH_EDITOR]}
1274
- ${{
1275
- onbeforeinput: edit,
1276
- oncompositionend: () => {
1277
- clearTimeout(settling);
1278
- // Some engines write the composed text after this event, so it is read once they have.
1279
- settling = setTimeout(resolve, 0);
1280
- },
1281
- oncompositionstart: () => {
1282
- resolve();
1283
-
1284
- let now = editor ? capture(editor) : null;
1285
-
1286
- if (!editor || !now) {
1287
- return;
1288
- }
1289
-
1290
- let span = order(now);
1291
-
1292
- // The input method replaces a selection within one block itself; across blocks it would
1293
- // merge elements, so that part is deleted first.
1294
- if (span.start.block !== span.end.block) {
1295
- change(remove(read(doc), span), 'delete');
1296
- }
1297
-
1298
- composing = { block: span.start.block, element: elements(editor)[span.start.block] };
1299
- show(false, true);
1300
- },
1301
- onconnect: (element: HTMLElement) => {
1302
- editor = element;
1303
- },
1304
- oncopy: (e: ClipboardEvent) => clip(e, false),
1305
- oncut: (e: ClipboardEvent) => clip(e, true),
1306
- onfocus: () => {
148
+ on(element, 'focusin', () => {
1307
149
  state.editing = true;
1308
-
1309
- // Clicking back into the text leaves the link field.
1310
- panel.link = false;
1311
- },
1312
- onkeydown: (e: KeyboardEvent) => {
1313
- if (e.isComposing) {
1314
- return;
150
+ }, { direct: true });
151
+ // Focus moving between the text and its toolbar stays in the edit.
152
+ on(element, 'focusout', (e: FocusEvent) => {
153
+ if (!root?.contains(e.relatedTarget as Node | null)) {
154
+ finish(true, false);
1315
155
  }
1316
-
1317
- resolve();
1318
-
1319
- let key = e.key.toLowerCase(),
1320
- mod = e.metaKey || e.ctrlKey;
1321
-
1322
- if (mod && !e.altKey && (key === 'y' || key === 'z')) {
1323
- e.preventDefault();
1324
-
1325
- if (key === 'y' || e.shiftKey) {
1326
- redo();
1327
- }
1328
- else {
1329
- undo();
1330
- }
1331
-
1332
- return;
1333
- }
1334
-
1335
- if (mod && !e.altKey && key !== 'enter') {
1336
- let action = ACTIONS.find(({ shortcut }) => shortcut?.toLowerCase() === (e.shiftKey ? 'shift+' : '') + key)?.action;
1337
-
1338
- // Same path as the buttons, so the shortcut updates the toolbar like a click.
1339
- if (action && features.has(action)) {
1340
- e.preventDefault();
1341
- trigger(action);
1342
- }
1343
-
156
+ }, { direct: true });
157
+ // Bubbled from the text: the editor and its toolbar keep the keys they handle.
158
+ on(element, 'keydown', (e: KeyboardEvent) => {
159
+ if (e.defaultPrevented || e.isComposing) {
1344
160
  return;
1345
161
  }
1346
162
 
1347
163
  if (e.key === 'Escape') {
1348
164
  e.preventDefault();
1349
-
1350
- if (panel.open) {
1351
- dismiss();
1352
- }
1353
- else {
1354
- finish(false, true);
1355
- }
1356
-
1357
- return;
165
+ finish(false, true);
1358
166
  }
1359
-
1360
- // One line saves on Enter; a multiline field keeps Enter for new blocks and saves on Mod+Enter.
1361
- if (e.key === 'Enter' && (mod || !multiline)) {
167
+ else if (e.key === 'Enter' && (!multiline || (apple ? e.metaKey : e.ctrlKey))) {
1362
168
  e.preventDefault();
1363
169
  finish(true, true);
1364
- return;
1365
- }
1366
-
1367
- if (panel.open && !mod && (e.key.length === 1 || e.key === 'Backspace' || e.key === 'Delete' || e.key === 'Enter')) {
1368
- show(false, true);
1369
170
  }
1370
- },
1371
- onpaste: (e: ClipboardEvent) => {
1372
- e.preventDefault();
1373
- resolve();
1374
-
1375
- let now = editor ? capture(editor) : null;
171
+ }, { direct: true });
172
+ },
173
+ ondisconnect: saving.dispose
174
+ }}
175
+ >
176
+ ${markdown({
177
+ ...defaults,
178
+ ...own,
179
+ class: ['inline-edit-editor', defaults?.class ?? [], own?.class ?? []].flat(),
180
+ controller: (next: MarkdownController) => {
181
+ controller = next;
182
+ },
183
+ // A box ticked while the field rests saves at once; mid-edit it goes with the rest.
184
+ onChange: (next: string) => {
185
+ write(current, next);
1376
186
 
1377
- if (now) {
1378
- land(order(now), e.clipboardData?.getData('text/plain') ?? '');
1379
- }
1380
- },
1381
- onpointerdown: (e: PointerEvent) => {
1382
- if (e.button === 0) {
1383
- pressing = true;
1384
- }
187
+ if (!state.editing) {
188
+ save();
1385
189
  }
1386
- }}
1387
- >
1388
- ${slot}
1389
- </div>
1390
- <div class='tooltip tooltip--context inline-edit-anchor' ${{ class: () => panel.open && '--active' }}>
1391
- <div
1392
- aria-label='Formatting'
1393
- class='tooltip-content tooltip-content--context inline-edit-toolbar'
1394
- role='toolbar'
1395
- ${this?.attributes?.[INLINE_EDIT_RICH_TOOLBAR]}
1396
- ${attributes[INLINE_EDIT_RICH_TOOLBAR]}
1397
- ${{
1398
- 'aria-hidden': () => panel.open ? 'false' : 'true',
1399
- class: [
1400
- () => panel.instant && 'inline-edit-toolbar--instant',
1401
- () => panel.link && 'inline-edit-toolbar--link'
1402
- ],
1403
- inert: () => !panel.open,
1404
- onconnect: (element: HTMLElement) => {
1405
- toolbar = element;
1406
- // Bound directly: delegation only runs the nearest bound handler, which for the text
1407
- // style select is its own.
1408
- keys = new AbortController();
1409
- element.addEventListener('keydown', navigate, { signal: keys.signal });
1410
- },
1411
- // Keeps the text selected and focused when a control is pressed; the link field takes focus.
1412
- onmousedown: (e: MouseEvent) => {
1413
- if ((e.target as Element).tagName !== 'INPUT') {
1414
- e.preventDefault();
1415
- }
1416
- },
1417
- style: () => `--toolbar-origin: ${panel.origin}; --toolbar-x: ${panel.x}px; --toolbar-y: ${panel.y}px;`
1418
- }}
1419
- >
1420
- <div class='inline-edit-toolbar-format' ${tip.delegate({ content: (trigger) => (trigger as Tool)[HINT], edge: true, selector: '.inline-edit-toolbar-button' })}>
1421
- ${kinds.length > 1 && html`
1422
- ${selectInput({
1423
- [selectInput.trigger]: {
1424
- onconnect: (element: HTMLElement) => {
1425
- items[0] = element;
1426
- },
1427
- tabindex: () => local.focus === 0 ? '0' : '-1'
1428
- },
1429
- class: 'inline-edit-toolbar-block',
1430
- label: 'Text style',
1431
- options: kinds,
1432
- state: block
1433
- })}
1434
- ${(marks.length > 0 || tools.length > 0) && html`<span aria-hidden='true' class='inline-edit-toolbar-divider'></span>`}
1435
- `}
1436
- ${marks.map((item, i) => button(item, icon(item.action as Exclude<Action, 'copy'>), lead + i))}
1437
- ${marks.length > 0 && tools.length > 0 && html`<span aria-hidden='true' class='inline-edit-toolbar-divider'></span>`}
1438
- ${tools.map((item, i) => button(
1439
- item,
1440
- item.action === 'copy'
1441
- ? faces(() => local.copied, [
1442
- { content: '', icon: copied, key: 'idle' },
1443
- { content: '', icon: checked, key: 'success', tone: 'success' },
1444
- { content: '', icon: cross, key: 'error', tone: 'error' }
1445
- ])
1446
- : icon(item.action as Exclude<Action, 'copy'>),
1447
- lead + marks.length + i
1448
- ))}
1449
- ${tip.render()}
1450
- </div>
1451
- ${features.has('link') && html`
1452
- <div class='inline-edit-toolbar-link'>
1453
- ${input({
1454
- 'aria-invalid': () => hyperlink.invalid && 'true',
1455
- 'aria-label': 'Link address',
1456
- class: 'inline-edit-toolbar-url',
1457
- onconnect: (element: HTMLInputElement) => {
1458
- url = element;
1459
- },
1460
- oninput: (e: Event) => {
1461
- hyperlink.url = (e.currentTarget as HTMLInputElement).value;
1462
- },
1463
- placeholder: 'Paste or type a link',
1464
- type: 'url',
1465
- value: () => hyperlink.url
1466
- })}
1467
- <button
1468
- aria-label='Apply link'
1469
- class='button button--feedback inline-edit-toolbar-button'
1470
- type='button'
1471
- ${{ onclick: () => apply(hyperlink.url) }}
1472
- >
1473
- ${icon('apply')}
1474
- </button>
1475
- <button
1476
- aria-label='Open link in a new tab'
1477
- class='button button--feedback inline-edit-toolbar-button'
1478
- type='button'
1479
- ${{
1480
- onclick: () => {
1481
- let href = address(hyperlink.url);
1482
-
1483
- if (href) {
1484
- window.open(href, '_blank', 'noopener');
1485
- }
1486
- }
1487
- }}
1488
- >
1489
- ${icon('open')}
1490
- </button>
1491
- <button
1492
- aria-label='Remove link'
1493
- class='button button--feedback inline-edit-toolbar-button inline-edit-toolbar-unlink'
1494
- type='button'
1495
- ${{
1496
- hidden: () => !hyperlink.existing,
1497
- onclick: () => apply(null)
1498
- }}
1499
- >
1500
- ${icon('unlink')}
1501
- </button>
1502
- </div>
1503
- `}
1504
- </div>
1505
- </div>
190
+ },
191
+ options,
192
+ value: state.value
193
+ })}
1506
194
  <span aria-hidden='true' class='inline-edit-icon'>
1507
- <svg class='inline-edit-icon-pencil'><use href='#${pencilSvg}' /></svg>
1508
- <svg class='inline-edit-icon-check'><use href='#${checkSvg}' /></svg>
195
+ ${icon({ class: 'inline-edit-icon-pencil' }, pencilSvg)}
196
+ ${icon({ class: 'inline-edit-icon-check' }, checkSvg)}
1509
197
  </span>
1510
- <span aria-live='polite' class='inline-edit-label'>${() => local.live}</span>
1511
198
  ${saving.status && status.render(saving.status, this?.attributes?.[INLINE_EDIT_STATUS], attributes[INLINE_EDIT_STATUS])}
1512
199
  </div>
1513
200
  `;
1514
201
  },
1515
- { editor: INLINE_EDIT_RICH_EDITOR, status: INLINE_EDIT_STATUS, toolbar: INLINE_EDIT_RICH_TOOLBAR }
202
+ { editor: INLINE_EDIT_RICH_EDITOR, status: INLINE_EDIT_STATUS }
1516
203
  );
1517
204
 
1518
- export type { Feature, Status };
205
+ export type { Status, Tool as Feature };