@aquera/nile-elements 1.9.7 → 1.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/README.md +6 -0
  2. package/dist/{index-249de90a.esm.js → index-289706c7.esm.js} +1 -1
  3. package/dist/{index-df196058.cjs.js → index-d7e6f1c6.cjs.js} +2 -2
  4. package/dist/index-d7e6f1c6.cjs.js.map +1 -0
  5. package/dist/index.cjs.js +1 -1
  6. package/dist/index.esm.js +1 -1
  7. package/dist/index.js +1587 -1276
  8. package/dist/katex-44476ab4.esm.js +1 -0
  9. package/dist/katex-f4186f87.cjs.js +2 -0
  10. package/dist/katex-f4186f87.cjs.js.map +1 -0
  11. package/dist/nile-color-picker/index.cjs.js +1 -1
  12. package/dist/nile-color-picker/index.esm.js +1 -1
  13. package/dist/nile-color-picker/nile-color-picker.cjs.js +1 -1
  14. package/dist/nile-color-picker/nile-color-picker.cjs.js.map +1 -1
  15. package/dist/nile-color-picker/nile-color-picker.esm.js +1 -1
  16. package/dist/nile-select/virtual-scroll-helper.cjs.js +1 -1
  17. package/dist/nile-select/virtual-scroll-helper.cjs.js.map +1 -1
  18. package/dist/nile-select/virtual-scroll-helper.esm.js +52 -44
  19. package/dist/nile-virtual-select/renderer.cjs.js +1 -1
  20. package/dist/nile-virtual-select/renderer.cjs.js.map +1 -1
  21. package/dist/nile-virtual-select/renderer.esm.js +23 -22
  22. package/dist/nile-wysiwyg-editor/engine/commands.cjs.js +1 -1
  23. package/dist/nile-wysiwyg-editor/engine/commands.cjs.js.map +1 -1
  24. package/dist/nile-wysiwyg-editor/engine/commands.esm.js +1 -1
  25. package/dist/nile-wysiwyg-editor/engine/create-state.cjs.js +1 -1
  26. package/dist/nile-wysiwyg-editor/engine/create-state.cjs.js.map +1 -1
  27. package/dist/nile-wysiwyg-editor/engine/create-state.esm.js +1 -1
  28. package/dist/nile-wysiwyg-editor/engine/index.cjs.js +1 -1
  29. package/dist/nile-wysiwyg-editor/engine/index.esm.js +1 -1
  30. package/dist/nile-wysiwyg-editor/engine/inputrules.cjs.js +1 -1
  31. package/dist/nile-wysiwyg-editor/engine/keymap.cjs.js +1 -1
  32. package/dist/nile-wysiwyg-editor/engine/keymap.esm.js +1 -1
  33. package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.cjs.js +1 -1
  34. package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.cjs.js.map +1 -1
  35. package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.esm.js +1 -1
  36. package/dist/nile-wysiwyg-editor/engine/plugins/embed-view.cjs.js +1 -1
  37. package/dist/nile-wysiwyg-editor/engine/plugins/embed-view.cjs.js.map +1 -1
  38. package/dist/nile-wysiwyg-editor/engine/plugins/embed-view.esm.js +1 -1
  39. package/dist/nile-wysiwyg-editor/engine/plugins/embeds.cjs.js +1 -1
  40. package/dist/nile-wysiwyg-editor/engine/plugins/embeds.cjs.js.map +1 -1
  41. package/dist/nile-wysiwyg-editor/engine/plugins/embeds.esm.js +1 -1
  42. package/dist/nile-wysiwyg-editor/engine/plugins/math-view.cjs.js +1 -1
  43. package/dist/nile-wysiwyg-editor/engine/plugins/math-view.cjs.js.map +1 -1
  44. package/dist/nile-wysiwyg-editor/engine/plugins/math-view.esm.js +1 -1
  45. package/dist/nile-wysiwyg-editor/engine/plugins/style-block-view.cjs.js +2 -0
  46. package/dist/nile-wysiwyg-editor/engine/plugins/style-block-view.cjs.js.map +1 -0
  47. package/dist/nile-wysiwyg-editor/engine/plugins/style-block-view.esm.js +1 -0
  48. package/dist/nile-wysiwyg-editor/engine/plugins/tables.cjs.js +1 -1
  49. package/dist/nile-wysiwyg-editor/engine/plugins/tables.cjs.js.map +1 -1
  50. package/dist/nile-wysiwyg-editor/engine/plugins/tables.esm.js +1 -1
  51. package/dist/nile-wysiwyg-editor/engine/sanitize.cjs.js +1 -1
  52. package/dist/nile-wysiwyg-editor/engine/sanitize.cjs.js.map +1 -1
  53. package/dist/nile-wysiwyg-editor/engine/sanitize.esm.js +1 -1
  54. package/dist/nile-wysiwyg-editor/engine/schema.cjs.js +1 -1
  55. package/dist/nile-wysiwyg-editor/engine/schema.cjs.js.map +1 -1
  56. package/dist/nile-wysiwyg-editor/engine/schema.esm.js +1 -1
  57. package/dist/nile-wysiwyg-editor/engine/selection-state.cjs.js +1 -1
  58. package/dist/nile-wysiwyg-editor/engine/selection-state.cjs.js.map +1 -1
  59. package/dist/nile-wysiwyg-editor/engine/selection-state.esm.js +1 -1
  60. package/dist/nile-wysiwyg-editor/index.cjs.js +1 -1
  61. package/dist/nile-wysiwyg-editor/index.esm.js +1 -1
  62. package/dist/nile-wysiwyg-editor/math/katex-renderer.cjs.js +2 -0
  63. package/dist/nile-wysiwyg-editor/math/katex-renderer.cjs.js.map +1 -0
  64. package/dist/nile-wysiwyg-editor/math/katex-renderer.esm.js +1 -0
  65. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js +1 -1
  66. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js.map +1 -1
  67. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.cjs.js +1 -1
  68. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.cjs.js.map +1 -1
  69. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.esm.js +22 -3
  70. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.esm.js +7 -6
  71. package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.cjs.js +1 -1
  72. package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.esm.js +1 -1
  73. package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.cjs.js +2 -0
  74. package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.cjs.js.map +1 -0
  75. package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.esm.js +1 -0
  76. package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.cjs.js +1 -1
  77. package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.cjs.js.map +1 -1
  78. package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.cjs.js +1 -1
  79. package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.cjs.js.map +1 -1
  80. package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.esm.js +33 -54
  81. package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.esm.js +83 -95
  82. package/dist/nile-wysiwyg-editor/types.cjs.js +1 -1
  83. package/dist/nile-wysiwyg-editor/types.cjs.js.map +1 -1
  84. package/dist/nile-wysiwyg-editor/types.esm.js +1 -1
  85. package/dist/nile-wysiwyg-editor/ui/bubble-item.cjs.js +2 -0
  86. package/dist/nile-wysiwyg-editor/ui/bubble-item.cjs.js.map +1 -0
  87. package/dist/nile-wysiwyg-editor/ui/bubble-item.esm.js +1 -0
  88. package/dist/nile-wysiwyg-editor/ui/bubble-menu.cjs.js +1 -1
  89. package/dist/nile-wysiwyg-editor/ui/bubble-menu.cjs.js.map +1 -1
  90. package/dist/nile-wysiwyg-editor/ui/bubble-menu.esm.js +23 -15
  91. package/dist/nile-wysiwyg-editor/ui/code-block-menu.cjs.js +1 -1
  92. package/dist/nile-wysiwyg-editor/ui/code-block-menu.cjs.js.map +1 -1
  93. package/dist/nile-wysiwyg-editor/ui/code-block-menu.esm.js +3 -3
  94. package/dist/nile-wysiwyg-editor/ui/embed-panel.cjs.js +1 -1
  95. package/dist/nile-wysiwyg-editor/ui/embed-panel.cjs.js.map +1 -1
  96. package/dist/nile-wysiwyg-editor/ui/embed-panel.esm.js +2 -2
  97. package/dist/nile-wysiwyg-editor/ui/math-panel.cjs.js +1 -1
  98. package/dist/nile-wysiwyg-editor/ui/math-panel.cjs.js.map +1 -1
  99. package/dist/nile-wysiwyg-editor/ui/math-panel.esm.js +0 -3
  100. package/dist/nile-wysiwyg-editor/ui/preview.cjs.js +2 -0
  101. package/dist/nile-wysiwyg-editor/ui/preview.cjs.js.map +1 -0
  102. package/dist/nile-wysiwyg-editor/ui/preview.esm.js +8 -0
  103. package/dist/nile-wysiwyg-editor/ui/source-view.cjs.js +1 -1
  104. package/dist/nile-wysiwyg-editor/ui/source-view.cjs.js.map +1 -1
  105. package/dist/nile-wysiwyg-editor/ui/source-view.esm.js +225 -24
  106. package/dist/nile-wysiwyg-editor/ui/suggest-list.cjs.js +1 -1
  107. package/dist/nile-wysiwyg-editor/ui/suggest-list.cjs.js.map +1 -1
  108. package/dist/nile-wysiwyg-editor/ui/suggest-list.esm.js +9 -9
  109. package/dist/nile-wysiwyg-editor/ui/table-grid-picker.cjs.js +1 -1
  110. package/dist/nile-wysiwyg-editor/ui/table-grid-picker.cjs.js.map +1 -1
  111. package/dist/nile-wysiwyg-editor/ui/table-grid-picker.esm.js +115 -13
  112. package/dist/nile-wysiwyg-editor/ui/table-menu.cjs.js +1 -1
  113. package/dist/nile-wysiwyg-editor/ui/table-menu.cjs.js.map +1 -1
  114. package/dist/nile-wysiwyg-editor/ui/table-menu.esm.js +13 -12
  115. package/dist/src/index.d.ts +5 -0
  116. package/dist/src/index.js +3 -0
  117. package/dist/src/index.js.map +1 -1
  118. package/dist/src/nile-color-picker/nile-color-picker.d.ts +1 -0
  119. package/dist/src/nile-color-picker/nile-color-picker.js +1 -0
  120. package/dist/src/nile-color-picker/nile-color-picker.js.map +1 -1
  121. package/dist/src/nile-select/virtual-scroll-helper.js +9 -1
  122. package/dist/src/nile-select/virtual-scroll-helper.js.map +1 -1
  123. package/dist/src/nile-virtual-select/renderer.js +1 -0
  124. package/dist/src/nile-virtual-select/renderer.js.map +1 -1
  125. package/dist/src/nile-wysiwyg-editor/engine/index.d.ts +1 -0
  126. package/dist/src/nile-wysiwyg-editor/engine/index.js +1 -0
  127. package/dist/src/nile-wysiwyg-editor/engine/index.js.map +1 -1
  128. package/dist/src/nile-wysiwyg-editor/engine/plugins/embed-view.js +3 -0
  129. package/dist/src/nile-wysiwyg-editor/engine/plugins/embed-view.js.map +1 -1
  130. package/dist/src/nile-wysiwyg-editor/engine/plugins/embeds.d.ts +19 -4
  131. package/dist/src/nile-wysiwyg-editor/engine/plugins/embeds.js +23 -18
  132. package/dist/src/nile-wysiwyg-editor/engine/plugins/embeds.js.map +1 -1
  133. package/dist/src/nile-wysiwyg-editor/engine/plugins/math-view.d.ts +8 -3
  134. package/dist/src/nile-wysiwyg-editor/engine/plugins/math-view.js +41 -4
  135. package/dist/src/nile-wysiwyg-editor/engine/plugins/math-view.js.map +1 -1
  136. package/dist/src/nile-wysiwyg-editor/engine/plugins/style-block-view.d.ts +17 -0
  137. package/dist/src/nile-wysiwyg-editor/engine/plugins/style-block-view.js +174 -0
  138. package/dist/src/nile-wysiwyg-editor/engine/plugins/style-block-view.js.map +1 -0
  139. package/dist/src/nile-wysiwyg-editor/engine/plugins/tables.js +33 -2
  140. package/dist/src/nile-wysiwyg-editor/engine/plugins/tables.js.map +1 -1
  141. package/dist/src/nile-wysiwyg-editor/engine/pm.test.js +49 -8
  142. package/dist/src/nile-wysiwyg-editor/engine/pm.test.js.map +1 -1
  143. package/dist/src/nile-wysiwyg-editor/engine/sanitize.d.ts +12 -0
  144. package/dist/src/nile-wysiwyg-editor/engine/sanitize.js +76 -8
  145. package/dist/src/nile-wysiwyg-editor/engine/sanitize.js.map +1 -1
  146. package/dist/src/nile-wysiwyg-editor/engine/schema.d.ts +2 -0
  147. package/dist/src/nile-wysiwyg-editor/engine/schema.js +154 -2
  148. package/dist/src/nile-wysiwyg-editor/engine/schema.js.map +1 -1
  149. package/dist/src/nile-wysiwyg-editor/index.d.ts +5 -0
  150. package/dist/src/nile-wysiwyg-editor/index.js +3 -0
  151. package/dist/src/nile-wysiwyg-editor/index.js.map +1 -1
  152. package/dist/src/nile-wysiwyg-editor/math/katex-renderer.d.ts +38 -0
  153. package/dist/src/nile-wysiwyg-editor/math/katex-renderer.js +40 -0
  154. package/dist/src/nile-wysiwyg-editor/math/katex-renderer.js.map +1 -0
  155. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.js +22 -3
  156. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.js.map +1 -1
  157. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.d.ts +36 -0
  158. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.js +125 -8
  159. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.js.map +1 -1
  160. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.test.js +5 -2
  161. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.test.js.map +1 -1
  162. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.d.ts +2 -0
  163. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.js +1 -0
  164. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.js.map +1 -1
  165. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.d.ts +55 -0
  166. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.js +79 -0
  167. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.js.map +1 -0
  168. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.js +33 -54
  169. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.js.map +1 -1
  170. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.d.ts +50 -2
  171. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.js +158 -102
  172. package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.js.map +1 -1
  173. package/dist/src/nile-wysiwyg-editor/types.d.ts +4 -2
  174. package/dist/src/nile-wysiwyg-editor/types.js +2 -2
  175. package/dist/src/nile-wysiwyg-editor/types.js.map +1 -1
  176. package/dist/src/nile-wysiwyg-editor/ui/bubble-item.d.ts +48 -0
  177. package/dist/src/nile-wysiwyg-editor/ui/bubble-item.js +69 -0
  178. package/dist/src/nile-wysiwyg-editor/ui/bubble-item.js.map +1 -0
  179. package/dist/src/nile-wysiwyg-editor/ui/bubble-menu.d.ts +17 -2
  180. package/dist/src/nile-wysiwyg-editor/ui/bubble-menu.js +128 -35
  181. package/dist/src/nile-wysiwyg-editor/ui/bubble-menu.js.map +1 -1
  182. package/dist/src/nile-wysiwyg-editor/ui/embed-panel.d.ts +2 -1
  183. package/dist/src/nile-wysiwyg-editor/ui/embed-panel.js +4 -3
  184. package/dist/src/nile-wysiwyg-editor/ui/embed-panel.js.map +1 -1
  185. package/dist/src/nile-wysiwyg-editor/ui/math-panel.js +0 -3
  186. package/dist/src/nile-wysiwyg-editor/ui/math-panel.js.map +1 -1
  187. package/dist/src/nile-wysiwyg-editor/ui/preview.d.ts +20 -0
  188. package/dist/src/nile-wysiwyg-editor/ui/preview.js +44 -0
  189. package/dist/src/nile-wysiwyg-editor/ui/preview.js.map +1 -0
  190. package/dist/src/nile-wysiwyg-editor/ui/source-view.d.ts +35 -3
  191. package/dist/src/nile-wysiwyg-editor/ui/source-view.js +337 -24
  192. package/dist/src/nile-wysiwyg-editor/ui/source-view.js.map +1 -1
  193. package/dist/src/nile-wysiwyg-editor/ui/suggest-list.d.ts +1 -0
  194. package/dist/src/nile-wysiwyg-editor/ui/suggest-list.js +9 -0
  195. package/dist/src/nile-wysiwyg-editor/ui/suggest-list.js.map +1 -1
  196. package/dist/src/nile-wysiwyg-editor/ui/table-grid-picker.d.ts +13 -2
  197. package/dist/src/nile-wysiwyg-editor/ui/table-grid-picker.js +166 -10
  198. package/dist/src/nile-wysiwyg-editor/ui/table-grid-picker.js.map +1 -1
  199. package/dist/src/nile-wysiwyg-editor/ui/table-menu.d.ts +1 -0
  200. package/dist/src/nile-wysiwyg-editor/ui/table-menu.js +10 -8
  201. package/dist/src/nile-wysiwyg-editor/ui/table-menu.js.map +1 -1
  202. package/dist/src/version.js +1 -1
  203. package/dist/src/version.js.map +1 -1
  204. package/dist/tsconfig.tsbuildinfo +1 -1
  205. package/dist/xml-25c4108a.esm.js +1 -0
  206. package/dist/xml-90fd974e.cjs.js +2 -0
  207. package/dist/xml-90fd974e.cjs.js.map +1 -0
  208. package/package.json +2 -1
  209. package/rollup.config.js +1 -0
  210. package/src/index.ts +8 -0
  211. package/src/nile-color-picker/nile-color-picker.ts +1 -0
  212. package/src/nile-select/virtual-scroll-helper.ts +9 -1
  213. package/src/nile-virtual-select/renderer.ts +1 -1
  214. package/src/nile-wysiwyg-editor/engine/index.ts +1 -0
  215. package/src/nile-wysiwyg-editor/engine/plugins/embed-view.ts +3 -0
  216. package/src/nile-wysiwyg-editor/engine/plugins/embeds.ts +26 -20
  217. package/src/nile-wysiwyg-editor/engine/plugins/math-view.ts +45 -4
  218. package/src/nile-wysiwyg-editor/engine/plugins/style-block-view.ts +178 -0
  219. package/src/nile-wysiwyg-editor/engine/plugins/tables.ts +34 -2
  220. package/src/nile-wysiwyg-editor/engine/pm.test.ts +58 -8
  221. package/src/nile-wysiwyg-editor/engine/sanitize.ts +71 -8
  222. package/src/nile-wysiwyg-editor/engine/schema.ts +158 -7
  223. package/src/nile-wysiwyg-editor/index.ts +5 -0
  224. package/src/nile-wysiwyg-editor/math/katex-renderer.ts +59 -0
  225. package/src/nile-wysiwyg-editor/math/katex.d.ts +17 -0
  226. package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.ts +22 -3
  227. package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.test.ts +5 -2
  228. package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.ts +142 -7
  229. package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.ts +2 -0
  230. package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.ts +68 -0
  231. package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.ts +33 -54
  232. package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.ts +202 -108
  233. package/src/nile-wysiwyg-editor/types.ts +6 -4
  234. package/src/nile-wysiwyg-editor/ui/bubble-item.ts +60 -0
  235. package/src/nile-wysiwyg-editor/ui/bubble-menu.ts +147 -40
  236. package/src/nile-wysiwyg-editor/ui/embed-panel.ts +4 -3
  237. package/src/nile-wysiwyg-editor/ui/math-panel.ts +0 -3
  238. package/src/nile-wysiwyg-editor/ui/preview.ts +42 -0
  239. package/src/nile-wysiwyg-editor/ui/source-view.ts +339 -31
  240. package/src/nile-wysiwyg-editor/ui/suggest-list.ts +10 -0
  241. package/src/nile-wysiwyg-editor/ui/table-grid-picker.ts +160 -10
  242. package/src/nile-wysiwyg-editor/ui/table-menu.ts +10 -8
  243. package/vscode-html-custom-data.json +75 -6
  244. package/dist/index-df196058.cjs.js.map +0 -1
@@ -1,30 +1,101 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { html, css } from 'lit';
3
- import { customElement, property, query } from 'lit/decorators.js';
3
+ import { customElement, property, query, state } from 'lit/decorators.js';
4
+ import { classMap } from 'lit/directives/class-map.js';
5
+ import { unsafeHTML } from 'lit/directives/unsafe-html.js';
6
+ import hljs from 'highlight.js/lib/core';
7
+ import xml from 'highlight.js/lib/languages/xml';
4
8
  import NileElement from '../../internal/nile-element';
9
+ import { sanitizeHtml } from '../engine/sanitize';
10
+ import './preview';
11
+ // HTML highlighting only — reuses the same lib the code-block feature already
12
+ // bundles, so this adds no new dependency. Registration is idempotent.
13
+ hljs.registerLanguage('xml', xml);
5
14
  /**
6
- * Raw HTML source editing mode. Replaces the rich surface while open; the
7
- * host re-parses (and re-sanitizes) the HTML on apply. Emits
15
+ * Raw HTML source editing mode. A split view: the raw HTML on the left, a
16
+ * live rendered preview on the right, with a draggable divider between them
17
+ * and a resizable body. The preview runs the same sanitizer the host applies
18
+ * on the way back, so what you see is what the document becomes. Emits
8
19
  * `wysiwyg-source-apply` detail: { html } and `wysiwyg-source-cancel`.
20
+ *
21
+ * The code pane is a lightweight editor: a real `<textarea>` for input, with a
22
+ * highlight.js-coloured layer painted behind it and a synced line-number
23
+ * gutter. No heavyweight code-editor dependency.
9
24
  */
10
25
  let NileWysiwygSourceView = class NileWysiwygSourceView extends NileElement {
11
26
  constructor() {
12
27
  super(...arguments);
13
28
  this.value = '';
29
+ /** Current source text, drives the live preview, highlight and gutter. */
30
+ this.draft = '';
31
+ /**
32
+ * Fraction of the body width given to the code pane (the rest is preview).
33
+ * Clamped while dragging the divider.
34
+ */
35
+ this.splitRatio = 0.5;
36
+ /** Whether the divider is currently being dragged. */
37
+ this.splitDragging = false;
38
+ /** Begins a pointer-driven resize of the split divider. */
39
+ this.startSplitDrag = (e) => {
40
+ const body = this.bodyEl;
41
+ if (!body)
42
+ return;
43
+ e.preventDefault();
44
+ this.splitDragging = true;
45
+ const rect = body.getBoundingClientRect();
46
+ const MIN = 0.15;
47
+ const MAX = 0.85;
48
+ const onMove = (ev) => {
49
+ if (rect.width === 0)
50
+ return;
51
+ const ratio = (ev.clientX - rect.left) / rect.width;
52
+ this.splitRatio = Math.min(MAX, Math.max(MIN, ratio));
53
+ };
54
+ const onUp = () => {
55
+ this.splitDragging = false;
56
+ window.removeEventListener('pointermove', onMove);
57
+ window.removeEventListener('pointerup', onUp);
58
+ };
59
+ window.addEventListener('pointermove', onMove);
60
+ window.addEventListener('pointerup', onUp);
61
+ };
62
+ /** Resets the divider to a 50/50 layout (double-click affordance). */
63
+ this.resetSplit = () => {
64
+ this.splitRatio = 0.5;
65
+ };
66
+ this.onInput = (e) => {
67
+ this.draft = e.target.value;
68
+ };
69
+ /** Keeps the highlight layer and line-number gutter aligned with scroll. */
70
+ this.onScroll = (e) => {
71
+ const ta = e.target;
72
+ if (this.highlightEl) {
73
+ this.highlightEl.style.transform = `translate(${-ta.scrollLeft}px, ${-ta.scrollTop}px)`;
74
+ }
75
+ if (this.linenosEl) {
76
+ this.linenosEl.style.transform = `translateY(${-ta.scrollTop}px)`;
77
+ }
78
+ };
14
79
  }
15
80
  static get styles() {
16
81
  return [
17
82
  css `
18
83
  :host {
19
- font-family: var(
20
- --nile-font-family-sans-serif,
21
- var(--ng-font-family-body, system-ui, -apple-system, sans-serif)
22
- );
23
84
  display: flex;
24
85
  flex-direction: column;
86
+ box-sizing: border-box;
87
+ overflow: hidden;
88
+ min-height: var(--nile-wysiwyg-min-height, 200px);
89
+ height: var(--nile-wysiwyg-source-height, 340px);
90
+ max-height: var(
91
+ --nile-wysiwyg-source-max-height,
92
+ var(--nile-wysiwyg-max-height, 70vh)
93
+ );
94
+ resize: vertical;
25
95
  }
26
96
 
27
97
  .bar {
98
+ flex: 0 0 auto;
28
99
  display: flex;
29
100
  align-items: center;
30
101
  justify-content: space-between;
@@ -56,30 +127,224 @@ let NileWysiwygSourceView = class NileWysiwygSourceView extends NileElement {
56
127
  color: #ffffff;
57
128
  }
58
129
 
59
- textarea {
60
- flex: 1;
61
- min-height: var(--nile-wysiwyg-min-height, 160px);
62
- padding: 12px 16px;
63
- border: none;
64
- outline: none;
65
- resize: vertical;
130
+ .body {
131
+ flex: 1 1 auto;
132
+ display: flex;
133
+ align-items: stretch;
134
+ overflow: hidden;
135
+ min-height: 0;
136
+ box-sizing: border-box;
137
+ }
138
+
139
+ .body--dragging {
140
+ cursor: col-resize;
141
+ user-select: none;
142
+ -webkit-user-select: none;
143
+ }
144
+
145
+ .body--dragging .pane {
146
+ pointer-events: none;
147
+ }
148
+
149
+ .pane {
150
+ min-width: 0;
151
+ min-height: 0;
152
+ box-sizing: border-box;
153
+ }
154
+
155
+ /* --- Lightweight code editor: gutter + highlighted textarea --- */
156
+ .pane--code {
157
+ display: flex;
158
+ background: var(--nile-colors-white-base, #ffffff);
159
+ /* Shared code metrics, inherited by the gutter, highlight and textarea
160
+ so every line lines up to the pixel. */
66
161
  font-family: var(--nile-wysiwyg-code-font, ui-monospace, SFMono-Regular, Menlo, monospace);
67
162
  font-size: 12px;
68
- line-height: 1.5;
163
+ line-height: 18px;
164
+ tab-size: 2;
165
+ -moz-tab-size: 2;
166
+ }
167
+
168
+ .linenos {
169
+ flex: 0 0 auto;
170
+ overflow: hidden;
171
+ box-sizing: border-box;
172
+ padding: 12px 8px 0;
173
+ text-align: right;
174
+ color: var(--nile-colors-neutral-400, #98a2b3);
175
+ background: var(--nile-colors-neutral-50, #f9fafb);
176
+ border-right: 1px solid var(--nile-colors-neutral-200, #eaecf0);
177
+ user-select: none;
178
+ }
179
+
180
+ .linenos-inner {
181
+ will-change: transform;
182
+ }
183
+
184
+ .linenos-inner > div {
185
+ height: 18px;
186
+ }
187
+
188
+ .input-wrap {
189
+ position: relative;
190
+ flex: 1 1 0;
191
+ min-width: 0;
192
+ overflow: hidden;
193
+ }
194
+
195
+ /* Highlight layer and textarea share the exact same box (offset for
196
+ padding via top/left, extending to the edges for horizontal scroll),
197
+ so the coloured text sits directly under the caret. */
198
+ .hl,
199
+ textarea {
200
+ position: absolute;
201
+ top: 12px;
202
+ left: 16px;
203
+ right: 0;
204
+ bottom: 0;
205
+ margin: 0;
206
+ border: 0;
207
+ padding: 0;
208
+ font: inherit;
209
+ line-height: inherit;
210
+ tab-size: inherit;
211
+ white-space: pre;
212
+ word-wrap: normal;
213
+ overflow-wrap: normal;
214
+ box-sizing: border-box;
215
+ }
216
+
217
+ .hl {
218
+ overflow: hidden;
219
+ pointer-events: none;
69
220
  color: var(--nile-colors-neutral-900, #101828);
221
+ }
222
+
223
+ .hl > code {
224
+ display: block;
225
+ will-change: transform;
226
+ }
227
+
228
+ textarea {
229
+ width: auto;
230
+ resize: none;
231
+ outline: none;
232
+ overflow: auto;
70
233
  background: transparent;
71
- box-sizing: border-box;
234
+ color: transparent;
235
+ caret-color: var(--nile-colors-neutral-900, #101828);
236
+ }
237
+
238
+ /* Must be translucent: the textarea's text is transparent and the
239
+ coloured code sits BEHIND it, so an opaque selection would hide the
240
+ text. A tint lets the highlighted code show through the selection. */
241
+ textarea::selection {
242
+ background: rgba(41, 112, 255, 0.3);
243
+ }
244
+ textarea::-moz-selection {
245
+ background: rgba(41, 112, 255, 0.3);
246
+ }
247
+
248
+ /* highlight.js token palette (Atom One Light), matching code blocks. */
249
+ .hl .hljs-comment,
250
+ .hl .hljs-quote { color: #a0a1a7; font-style: italic; }
251
+ .hl .hljs-keyword,
252
+ .hl .hljs-selector-tag,
253
+ .hl .hljs-doctag { color: #a626a4; }
254
+ .hl .hljs-name,
255
+ .hl .hljs-selector-id,
256
+ .hl .hljs-selector-class,
257
+ .hl .hljs-tag { color: #e45649; }
258
+ .hl .hljs-literal,
259
+ .hl .hljs-built_in { color: #0184bb; }
260
+ .hl .hljs-string,
261
+ .hl .hljs-attribute,
262
+ .hl .hljs-meta .hljs-string { color: #50a14f; }
263
+ .hl .hljs-attr,
264
+ .hl .hljs-variable,
265
+ .hl .hljs-type,
266
+ .hl .hljs-number { color: #986801; }
267
+ .hl .hljs-symbol,
268
+ .hl .hljs-meta,
269
+ .hl .hljs-title { color: #4078f2; }
270
+
271
+ /* Draggable divider between the code and preview panes. */
272
+ .gutter {
273
+ flex: 0 0 auto;
274
+ position: relative;
275
+ width: 1px;
276
+ align-self: stretch;
277
+ background: var(--nile-colors-neutral-300, #e4e7ec);
278
+ cursor: col-resize;
279
+ touch-action: none;
280
+ }
281
+
282
+ .gutter::before {
283
+ content: '';
284
+ position: absolute;
285
+ inset: 0 -4px;
286
+ }
287
+
288
+ .gutter:hover,
289
+ .body--dragging .gutter {
290
+ background: var(--ng-colors-bg-brand-primary, #2970ff);
291
+ }
292
+
293
+ .pane--preview {
294
+ flex: 1 1 0;
295
+ overflow: auto;
296
+ border-left: 1px solid var(--nile-colors-neutral-200, #eaecf0);
297
+ background: var(--nile-colors-white-base, #ffffff);
298
+ }
299
+
300
+ nile-wysiwyg-preview {
301
+ display: block;
302
+ }
303
+
304
+ .preview-empty {
305
+ display: block;
306
+ padding: 12px 16px;
307
+ color: var(--nile-colors-neutral-500, #98a2b3);
308
+ font-size: 12px;
309
+ opacity: 0.7;
72
310
  }
73
311
  `,
74
312
  ];
75
313
  }
314
+ willUpdate(changed) {
315
+ // Sync the draft (and thus preview/highlight) whenever the host sets value.
316
+ if (changed.has('value'))
317
+ this.draft = this.value;
318
+ }
319
+ /** The current (possibly edited) source text — what "Done" would apply. */
320
+ get currentValue() {
321
+ return this.draft;
322
+ }
76
323
  focusInput() {
77
324
  this.updateComplete.then(() => this.textarea?.focus());
78
325
  }
326
+ /** highlight.js-coloured HTML for the current draft (falls back to escaped). */
327
+ get highlighted() {
328
+ if (!this.draft)
329
+ return '';
330
+ try {
331
+ return hljs.highlight(this.draft, { language: 'xml' }).value;
332
+ }
333
+ catch {
334
+ return this.draft.replace(/[&<>]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;' }[c]));
335
+ }
336
+ }
337
+ get lineCount() {
338
+ return this.draft ? this.draft.split('\n').length : 1;
339
+ }
79
340
  render() {
341
+ const preview = sanitizeHtml(this.draft);
342
+ const lines = [];
343
+ for (let i = 1; i <= this.lineCount; i += 1)
344
+ lines.push(html `<div>${i}</div>`);
80
345
  return html `
81
346
  <div class="bar" part="source-bar">
82
- <span>HTML source</span>
347
+ <span>HTML</span>
83
348
  <span class="actions">
84
349
  <button type="button" @click=${() => this.emit('wysiwyg-source-cancel')}>
85
350
  Cancel
@@ -87,23 +352,53 @@ let NileWysiwygSourceView = class NileWysiwygSourceView extends NileElement {
87
352
  <button
88
353
  type="button"
89
354
  class="primary"
90
- @click=${() => this.emit('wysiwyg-source-apply', { html: this.textarea?.value ?? '' })}
355
+ @click=${() => this.emit('wysiwyg-source-apply', { html: this.draft })}
91
356
  >
92
357
  Done
93
358
  </button>
94
359
  </span>
95
360
  </div>
96
- <textarea
97
- part="source-textarea"
98
- spellcheck="false"
99
- .value=${this.value}
100
- @keydown=${(e) => {
361
+ <div class=${classMap({ body: true, 'body--dragging': this.splitDragging })}>
362
+ <div class="pane pane--code" style="flex: 0 0 ${this.splitRatio * 100}%">
363
+ <div class="linenos" part="line-numbers" aria-hidden="true">
364
+ <div class="linenos-inner">${lines}</div>
365
+ </div>
366
+ <div class="input-wrap">
367
+ <pre class="hl" aria-hidden="true"><code>${unsafeHTML(this.highlighted)}</code></pre>
368
+ <textarea
369
+ part="source-textarea"
370
+ spellcheck="false"
371
+ autocapitalize="off"
372
+ autocomplete="off"
373
+ wrap="off"
374
+ .value=${this.value}
375
+ @input=${this.onInput}
376
+ @scroll=${this.onScroll}
377
+ @keydown=${(e) => {
101
378
  if (e.key === 'Escape') {
102
379
  e.stopPropagation();
103
380
  this.emit('wysiwyg-source-cancel');
104
381
  }
105
382
  }}
106
- ></textarea>
383
+ ></textarea>
384
+ </div>
385
+ </div>
386
+ <div
387
+ class="gutter"
388
+ part="gutter"
389
+ role="separator"
390
+ aria-orientation="vertical"
391
+ aria-label="Resize source and preview"
392
+ title="Drag to resize · double-click to reset"
393
+ @pointerdown=${this.startSplitDrag}
394
+ @dblclick=${this.resetSplit}
395
+ ></div>
396
+ <div class="pane pane--preview" part="preview">
397
+ ${this.draft.trim()
398
+ ? html `<nile-wysiwyg-preview .content=${preview}></nile-wysiwyg-preview>`
399
+ : html `<span class="preview-empty">Nothing to preview</span>`}
400
+ </div>
401
+ </div>
107
402
  `;
108
403
  }
109
404
  };
@@ -113,6 +408,24 @@ __decorate([
113
408
  __decorate([
114
409
  query('textarea')
115
410
  ], NileWysiwygSourceView.prototype, "textarea", void 0);
411
+ __decorate([
412
+ query('.hl > code')
413
+ ], NileWysiwygSourceView.prototype, "highlightEl", void 0);
414
+ __decorate([
415
+ query('.linenos-inner')
416
+ ], NileWysiwygSourceView.prototype, "linenosEl", void 0);
417
+ __decorate([
418
+ query('.body')
419
+ ], NileWysiwygSourceView.prototype, "bodyEl", void 0);
420
+ __decorate([
421
+ state()
422
+ ], NileWysiwygSourceView.prototype, "draft", void 0);
423
+ __decorate([
424
+ state()
425
+ ], NileWysiwygSourceView.prototype, "splitRatio", void 0);
426
+ __decorate([
427
+ state()
428
+ ], NileWysiwygSourceView.prototype, "splitDragging", void 0);
116
429
  NileWysiwygSourceView = __decorate([
117
430
  customElement('nile-wysiwyg-source-view')
118
431
  ], NileWysiwygSourceView);
@@ -1 +1 @@
1
- {"version":3,"file":"source-view.js","sourceRoot":"","sources":["../../../../src/nile-wysiwyg-editor/ui/source-view.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAkC,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,WAAW,MAAM,6BAA6B,CAAC;AAEtD;;;;GAIG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,WAAW;IAA/C;;QACuB,UAAK,GAAG,EAAE,CAAC;IAqGzC,CAAC;IAjGQ,MAAM,KAAK,MAAM;QACtB,OAAO;YACL,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwDF;SACF,CAAC;IACJ,CAAC;IAEM,UAAU;QACf,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IACzD,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAA;;;;yCAI0B,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC;;;;;;qBAM5D,GAAG,EAAE,CACZ,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE,EAAE,CAAC;;;;;;;;;iBASpE,IAAI,CAAC,KAAK;mBACR,CAAC,CAAgB,EAAE,EAAE;YAC9B,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;gBACvB,CAAC,CAAC,eAAe,EAAE,CAAC;gBACpB,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;;KAEJ,CAAC;IACJ,CAAC;CACF,CAAA;AArG6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAAY;AAEpB;IAAlB,KAAK,CAAC,UAAU,CAAC;uDAAgC;AAHvC,qBAAqB;IADjC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,qBAAqB,CAsGjC","sourcesContent":["import { html, css, TemplateResult, CSSResultArray } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport NileElement from '../../internal/nile-element';\n\n/**\n * Raw HTML source editing mode. Replaces the rich surface while open; the\n * host re-parses (and re-sanitizes) the HTML on apply. Emits\n * `wysiwyg-source-apply` detail: { html } and `wysiwyg-source-cancel`.\n */\n@customElement('nile-wysiwyg-source-view')\nexport class NileWysiwygSourceView extends NileElement {\n @property({ type: String }) value = '';\n\n @query('textarea') textarea?: HTMLTextAreaElement;\n\n public static get styles(): CSSResultArray {\n return [\n css`\n :host {\n font-family: var(\n --nile-font-family-sans-serif,\n var(--ng-font-family-body, system-ui, -apple-system, sans-serif)\n );\n display: flex;\n flex-direction: column;\n }\n\n .bar {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 6px 12px;\n font-size: 12px;\n color: var(--nile-colors-neutral-600, #475467);\n border-bottom: 1px solid var(--nile-colors-neutral-300, #e4e7ec);\n background: var(--nile-wysiwyg-toolbar-bg, var(--nile-colors-neutral-50, #f9fafb));\n }\n\n .actions {\n display: flex;\n gap: 8px;\n }\n\n button {\n font: inherit;\n font-size: 12px;\n padding: 4px 12px;\n border-radius: 6px;\n border: 1px solid transparent;\n cursor: pointer;\n background: transparent;\n color: var(--nile-colors-neutral-700, #344054);\n }\n\n button.primary {\n background: var(--nile-colors-primary-600, var(--ng-componentcolors-utility-blue-600, #2563eb));\n color: #ffffff;\n }\n\n textarea {\n flex: 1;\n min-height: var(--nile-wysiwyg-min-height, 160px);\n padding: 12px 16px;\n border: none;\n outline: none;\n resize: vertical;\n font-family: var(--nile-wysiwyg-code-font, ui-monospace, SFMono-Regular, Menlo, monospace);\n font-size: 12px;\n line-height: 1.5;\n color: var(--nile-colors-neutral-900, #101828);\n background: transparent;\n box-sizing: border-box;\n }\n `,\n ];\n }\n\n public focusInput(): void {\n this.updateComplete.then(() => this.textarea?.focus());\n }\n\n public render(): TemplateResult {\n return html`\n <div class=\"bar\" part=\"source-bar\">\n <span>HTML source</span>\n <span class=\"actions\">\n <button type=\"button\" @click=${() => this.emit('wysiwyg-source-cancel')}>\n Cancel\n </button>\n <button\n type=\"button\"\n class=\"primary\"\n @click=${() =>\n this.emit('wysiwyg-source-apply', { html: this.textarea?.value ?? '' })}\n >\n Done\n </button>\n </span>\n </div>\n <textarea\n part=\"source-textarea\"\n spellcheck=\"false\"\n .value=${this.value}\n @keydown=${(e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n e.stopPropagation();\n this.emit('wysiwyg-source-cancel');\n }\n }}\n ></textarea>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-wysiwyg-source-view': NileWysiwygSourceView;\n }\n}\n"]}
1
+ {"version":3,"file":"source-view.js","sourceRoot":"","sources":["../../../../src/nile-wysiwyg-editor/ui/source-view.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAkC,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AA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IAAI,CAAA,kCAAkC,OAAO,0BAA0B;YACzE,CAAC,CAAC,IAAI,CAAA,uDAAuD;;;KAGpE,CAAC;IACJ,CAAC;CACF,CAAA;AAzY6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAAY;AAEZ;IAA1B,KAAK,CAAC,UAAU,CAAC;uDAAwC;AAE7B;IAA5B,KAAK,CAAC,YAAY,CAAC;0DAAmC;AAEtB;IAAhC,KAAK,CAAC,gBAAgB,CAAC;wDAAiC;AAEjC;IAAvB,KAAK,CAAC,OAAO,CAAC;qDAA8B;AAG5B;IAAhB,KAAK,EAAE;oDAAoB;AAMX;IAAhB,KAAK,EAAE;yDAA0B;AAGjB;IAAhB,KAAK,EAAE;4DAA+B;AArB5B,qBAAqB;IADjC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,qBAAqB,CA0YjC","sourcesContent":["import { html, css, TemplateResult, CSSResultArray } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\nimport hljs from 'highlight.js/lib/core';\nimport xml from 'highlight.js/lib/languages/xml';\nimport NileElement from '../../internal/nile-element';\nimport { sanitizeHtml } from '../engine/sanitize';\nimport './preview';\n\n// HTML highlighting only — reuses the same lib the code-block feature already\n// bundles, so this adds no new dependency. Registration is idempotent.\nhljs.registerLanguage('xml', xml);\n\n/**\n * Raw HTML source editing mode. A split view: the raw HTML on the left, a\n * live rendered preview on the right, with a draggable divider between them\n * and a resizable body. The preview runs the same sanitizer the host applies\n * on the way back, so what you see is what the document becomes. Emits\n * `wysiwyg-source-apply` detail: { html } and `wysiwyg-source-cancel`.\n *\n * The code pane is a lightweight editor: a real `<textarea>` for input, with a\n * highlight.js-coloured layer painted behind it and a synced line-number\n * gutter. No heavyweight code-editor dependency.\n */\n@customElement('nile-wysiwyg-source-view')\nexport class NileWysiwygSourceView extends NileElement {\n @property({ type: String }) value = '';\n\n @query('textarea') private textarea?: HTMLTextAreaElement;\n\n @query('.hl > code') private highlightEl?: HTMLElement;\n\n @query('.linenos-inner') private linenosEl?: HTMLElement;\n\n @query('.body') private bodyEl?: HTMLElement;\n\n /** Current source text, drives the live preview, highlight and gutter. */\n @state() private draft = '';\n\n /**\n * Fraction of the body width given to the code pane (the rest is preview).\n * Clamped while dragging the divider.\n */\n @state() private splitRatio = 0.5;\n\n /** Whether the divider is currently being dragged. */\n @state() private splitDragging = false;\n\n public static get styles(): CSSResultArray {\n return [\n css`\n :host {\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n overflow: hidden;\n min-height: var(--nile-wysiwyg-min-height, 200px);\n height: var(--nile-wysiwyg-source-height, 340px);\n max-height: var(\n --nile-wysiwyg-source-max-height,\n var(--nile-wysiwyg-max-height, 70vh)\n );\n resize: vertical;\n }\n\n .bar {\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 6px 12px;\n font-size: 12px;\n color: var(--nile-colors-neutral-600, #475467);\n border-bottom: 1px solid var(--nile-colors-neutral-300, #e4e7ec);\n background: var(--nile-wysiwyg-toolbar-bg, var(--nile-colors-neutral-50, #f9fafb));\n }\n\n .actions {\n display: flex;\n gap: 8px;\n }\n\n button {\n font: inherit;\n font-size: 12px;\n padding: 4px 12px;\n border-radius: 6px;\n border: 1px solid transparent;\n cursor: pointer;\n background: transparent;\n color: var(--nile-colors-neutral-700, #344054);\n }\n\n button.primary {\n background: var(--nile-colors-primary-600, var(--ng-componentcolors-utility-blue-600, #2563eb));\n color: #ffffff;\n }\n\n .body {\n flex: 1 1 auto;\n display: flex;\n align-items: stretch;\n overflow: hidden;\n min-height: 0;\n box-sizing: border-box;\n }\n\n .body--dragging {\n cursor: col-resize;\n user-select: none;\n -webkit-user-select: none;\n }\n\n .body--dragging .pane {\n pointer-events: none;\n }\n\n .pane {\n min-width: 0;\n min-height: 0;\n box-sizing: border-box;\n }\n\n /* --- Lightweight code editor: gutter + highlighted textarea --- */\n .pane--code {\n display: flex;\n background: var(--nile-colors-white-base, #ffffff);\n /* Shared code metrics, inherited by the gutter, highlight and textarea\n so every line lines up to the pixel. */\n font-family: var(--nile-wysiwyg-code-font, ui-monospace, SFMono-Regular, Menlo, monospace);\n font-size: 12px;\n line-height: 18px;\n tab-size: 2;\n -moz-tab-size: 2;\n }\n\n .linenos {\n flex: 0 0 auto;\n overflow: hidden;\n box-sizing: border-box;\n padding: 12px 8px 0;\n text-align: right;\n color: var(--nile-colors-neutral-400, #98a2b3);\n background: var(--nile-colors-neutral-50, #f9fafb);\n border-right: 1px solid var(--nile-colors-neutral-200, #eaecf0);\n user-select: none;\n }\n\n .linenos-inner {\n will-change: transform;\n }\n\n .linenos-inner > div {\n height: 18px;\n }\n\n .input-wrap {\n position: relative;\n flex: 1 1 0;\n min-width: 0;\n overflow: hidden;\n }\n\n /* Highlight layer and textarea share the exact same box (offset for\n padding via top/left, extending to the edges for horizontal scroll),\n so the coloured text sits directly under the caret. */\n .hl,\n textarea {\n position: absolute;\n top: 12px;\n left: 16px;\n right: 0;\n bottom: 0;\n margin: 0;\n border: 0;\n padding: 0;\n font: inherit;\n line-height: inherit;\n tab-size: inherit;\n white-space: pre;\n word-wrap: normal;\n overflow-wrap: normal;\n box-sizing: border-box;\n }\n\n .hl {\n overflow: hidden;\n pointer-events: none;\n color: var(--nile-colors-neutral-900, #101828);\n }\n\n .hl > code {\n display: block;\n will-change: transform;\n }\n\n textarea {\n width: auto;\n resize: none;\n outline: none;\n overflow: auto;\n background: transparent;\n color: transparent;\n caret-color: var(--nile-colors-neutral-900, #101828);\n }\n\n /* Must be translucent: the textarea's text is transparent and the\n coloured code sits BEHIND it, so an opaque selection would hide the\n text. A tint lets the highlighted code show through the selection. */\n textarea::selection {\n background: rgba(41, 112, 255, 0.3);\n }\n textarea::-moz-selection {\n background: rgba(41, 112, 255, 0.3);\n }\n\n /* highlight.js token palette (Atom One Light), matching code blocks. */\n .hl .hljs-comment,\n .hl .hljs-quote { color: #a0a1a7; font-style: italic; }\n .hl .hljs-keyword,\n .hl .hljs-selector-tag,\n .hl .hljs-doctag { color: #a626a4; }\n .hl .hljs-name,\n .hl .hljs-selector-id,\n .hl .hljs-selector-class,\n .hl .hljs-tag { color: #e45649; }\n .hl .hljs-literal,\n .hl .hljs-built_in { color: #0184bb; }\n .hl .hljs-string,\n .hl .hljs-attribute,\n .hl .hljs-meta .hljs-string { color: #50a14f; }\n .hl .hljs-attr,\n .hl .hljs-variable,\n .hl .hljs-type,\n .hl .hljs-number { color: #986801; }\n .hl .hljs-symbol,\n .hl .hljs-meta,\n .hl .hljs-title { color: #4078f2; }\n\n /* Draggable divider between the code and preview panes. */\n .gutter {\n flex: 0 0 auto;\n position: relative;\n width: 1px;\n align-self: stretch;\n background: var(--nile-colors-neutral-300, #e4e7ec);\n cursor: col-resize;\n touch-action: none;\n }\n\n .gutter::before {\n content: '';\n position: absolute;\n inset: 0 -4px;\n }\n\n .gutter:hover,\n .body--dragging .gutter {\n background: var(--ng-colors-bg-brand-primary, #2970ff);\n }\n\n .pane--preview {\n flex: 1 1 0;\n overflow: auto;\n border-left: 1px solid var(--nile-colors-neutral-200, #eaecf0);\n background: var(--nile-colors-white-base, #ffffff);\n }\n\n nile-wysiwyg-preview {\n display: block;\n }\n\n .preview-empty {\n display: block;\n padding: 12px 16px;\n color: var(--nile-colors-neutral-500, #98a2b3);\n font-size: 12px;\n opacity: 0.7;\n }\n `,\n ];\n }\n\n protected willUpdate(changed: Map<string, unknown>): void {\n // Sync the draft (and thus preview/highlight) whenever the host sets value.\n if (changed.has('value')) this.draft = this.value;\n }\n\n /** The current (possibly edited) source text — what \"Done\" would apply. */\n public get currentValue(): string {\n return this.draft;\n }\n\n public focusInput(): void {\n this.updateComplete.then(() => this.textarea?.focus());\n }\n\n /** highlight.js-coloured HTML for the current draft (falls back to escaped). */\n private get highlighted(): string {\n if (!this.draft) return '';\n try {\n return hljs.highlight(this.draft, { language: 'xml' }).value;\n } catch {\n return this.draft.replace(/[&<>]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;' }[c]!));\n }\n }\n\n private get lineCount(): number {\n return this.draft ? this.draft.split('\\n').length : 1;\n }\n\n /** Begins a pointer-driven resize of the split divider. */\n private startSplitDrag = (e: PointerEvent) => {\n const body = this.bodyEl;\n if (!body) return;\n e.preventDefault();\n this.splitDragging = true;\n\n const rect = body.getBoundingClientRect();\n const MIN = 0.15;\n const MAX = 0.85;\n\n const onMove = (ev: PointerEvent) => {\n if (rect.width === 0) return;\n const ratio = (ev.clientX - rect.left) / rect.width;\n this.splitRatio = Math.min(MAX, Math.max(MIN, ratio));\n };\n const onUp = () => {\n this.splitDragging = false;\n window.removeEventListener('pointermove', onMove);\n window.removeEventListener('pointerup', onUp);\n };\n window.addEventListener('pointermove', onMove);\n window.addEventListener('pointerup', onUp);\n };\n\n /** Resets the divider to a 50/50 layout (double-click affordance). */\n private resetSplit = () => {\n this.splitRatio = 0.5;\n };\n\n private onInput = (e: Event) => {\n this.draft = (e.target as HTMLTextAreaElement).value;\n };\n\n /** Keeps the highlight layer and line-number gutter aligned with scroll. */\n private onScroll = (e: Event) => {\n const ta = e.target as HTMLTextAreaElement;\n if (this.highlightEl) {\n this.highlightEl.style.transform = `translate(${-ta.scrollLeft}px, ${-ta.scrollTop}px)`;\n }\n if (this.linenosEl) {\n this.linenosEl.style.transform = `translateY(${-ta.scrollTop}px)`;\n }\n };\n\n public render(): TemplateResult {\n const preview = sanitizeHtml(this.draft);\n const lines: TemplateResult[] = [];\n for (let i = 1; i <= this.lineCount; i += 1) lines.push(html`<div>${i}</div>`);\n return html`\n <div class=\"bar\" part=\"source-bar\">\n <span>HTML</span>\n <span class=\"actions\">\n <button type=\"button\" @click=${() => this.emit('wysiwyg-source-cancel')}>\n Cancel\n </button>\n <button\n type=\"button\"\n class=\"primary\"\n @click=${() => this.emit('wysiwyg-source-apply', { html: this.draft })}\n >\n Done\n </button>\n </span>\n </div>\n <div class=${classMap({ body: true, 'body--dragging': this.splitDragging })}>\n <div class=\"pane pane--code\" style=\"flex: 0 0 ${this.splitRatio * 100}%\">\n <div class=\"linenos\" part=\"line-numbers\" aria-hidden=\"true\">\n <div class=\"linenos-inner\">${lines}</div>\n </div>\n <div class=\"input-wrap\">\n <pre class=\"hl\" aria-hidden=\"true\"><code>${unsafeHTML(this.highlighted)}</code></pre>\n <textarea\n part=\"source-textarea\"\n spellcheck=\"false\"\n autocapitalize=\"off\"\n autocomplete=\"off\"\n wrap=\"off\"\n .value=${this.value}\n @input=${this.onInput}\n @scroll=${this.onScroll}\n @keydown=${(e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n e.stopPropagation();\n this.emit('wysiwyg-source-cancel');\n }\n }}\n ></textarea>\n </div>\n </div>\n <div\n class=\"gutter\"\n part=\"gutter\"\n role=\"separator\"\n aria-orientation=\"vertical\"\n aria-label=\"Resize source and preview\"\n title=\"Drag to resize · double-click to reset\"\n @pointerdown=${this.startSplitDrag}\n @dblclick=${this.resetSplit}\n ></div>\n <div class=\"pane pane--preview\" part=\"preview\">\n ${this.draft.trim()\n ? html`<nile-wysiwyg-preview .content=${preview}></nile-wysiwyg-preview>`\n : html`<span class=\"preview-empty\">Nothing to preview</span>`}\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-wysiwyg-source-view': NileWysiwygSourceView;\n }\n}\n"]}
@@ -18,6 +18,7 @@ export declare class NileWysiwygSuggestList extends NileElement {
18
18
  private activeIndex;
19
19
  static get styles(): CSSResultArray;
20
20
  protected willUpdate(): void;
21
+ protected updated(changed: Map<string, unknown>): void;
21
22
  next(): void;
22
23
  prev(): void;
23
24
  resetActive(): void;
@@ -77,6 +77,15 @@ let NileWysiwygSuggestList = class NileWysiwygSuggestList extends NileElement {
77
77
  if (this.activeIndex >= this.items.length)
78
78
  this.activeIndex = 0;
79
79
  }
80
+ updated(changed) {
81
+ // Keep the highlighted item visible as the user arrows through a list
82
+ // that overflows the popup's max-height. `nearest` is a no-op when the
83
+ // item is already visible (e.g. after a hover), so it never fights the mouse.
84
+ if (changed.has('activeIndex') || changed.has('items')) {
85
+ const active = this.renderRoot.querySelector('.item.active');
86
+ active?.scrollIntoView({ block: 'nearest' });
87
+ }
88
+ }
80
89
  next() {
81
90
  if (this.items.length)
82
91
  this.activeIndex = (this.activeIndex + 1) % this.items.length;
@@ -1 +1 @@
1
- {"version":3,"file":"suggest-list.js","sourceRoot":"","sources":["../../../../src/nile-wysiwyg-editor/ui/suggest-list.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAkC,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,WAAW,MAAM,6BAA6B,CAAC;AAStD;;;;;GAKG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,WAAW;IAAhD;;QACuC,SAAI,GAAG,KAAK,CAAC;QAEzB,UAAK,GAAkB,EAAE,CAAC;QAEzC,gBAAW,GAAG,CAAC,CAAC;IA4GnC,CAAC;IA1GQ,MAAM,KAAK,MAAM;QACtB,OAAO;YACL,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqDF;SACF,CAAC;IACJ,CAAC;IAES,UAAU;QAClB,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM;YAAE,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;IAClE,CAAC;IAEM,IAAI;QACT,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM;YAAE,IAAI,CAAC,WAAW,GAAG,CAAC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IACvF,CAAC;IAEM,IAAI;QACT,IAAI,IAAI,CAAC,KAAK,CAAC,MAA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AE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDAAc;AAEzB;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;qDAA2B;AAEzC;IAAhB,KAAK,EAAE;2DAAyB;AALtB,sBAAsB;IADlC,aAAa,CAAC,2BAA2B,CAAC;GAC9B,sBAAsB,CAiHlC","sourcesContent":["import { html, css, TemplateResult, CSSResultArray } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport NileElement from '../../internal/nile-element';\n\nexport interface SuggestItem {\n key: string;\n label: string;\n /** Secondary text shown right-aligned (e.g. slash-command hint). */\n hint?: string;\n}\n\n/**\n * Keyboard-navigable suggestion popup shared by mentions and slash commands.\n * The host positions it, feeds `items`, and drives navigation through\n * next()/prev()/selectCurrent(); picking an item emits\n * `wysiwyg-suggest-select` with the item.\n */\n@customElement('nile-wysiwyg-suggest-list')\nexport class NileWysiwygSuggestList extends NileElement {\n @property({ type: Boolean, reflect: true }) open = false;\n\n @property({ attribute: false }) items: SuggestItem[] = [];\n\n @state() private activeIndex = 0;\n\n public static get styles(): CSSResultArray {\n return [\n css`\n :host {\n font-family: var(\n --nile-font-family-sans-serif,\n var(--ng-font-family-body, system-ui, -apple-system, sans-serif)\n );\n position: absolute;\n z-index: 25;\n display: none;\n }\n\n :host([open]) {\n display: block;\n }\n\n .list {\n min-width: 200px;\n max-width: 320px;\n max-height: 240px;\n overflow-y: auto;\n padding: 4px;\n background: var(--nile-wysiwyg-popover-bg, #ffffff);\n border: 1px solid var(--nile-colors-neutral-400, #d0d5dd);\n border-radius: 8px;\n box-shadow: var(--nile-wysiwyg-popover-shadow, 0 4px 12px rgba(16, 24, 40, 0.12));\n font-size: 13px;\n }\n\n .item {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n padding: 6px 8px;\n border-radius: 5px;\n cursor: pointer;\n color: var(--nile-colors-neutral-700, #344054);\n }\n\n .item.active {\n background: var(--nile-colors-primary-50, var(--ng-componentcolors-utility-blue-50, #eff4ff));\n color: var(--nile-colors-primary-700, var(--ng-componentcolors-utility-blue-700, #1d4ed8));\n }\n\n .hint {\n font-size: 11px;\n color: var(--nile-colors-neutral-500, #98a2b3);\n }\n\n .empty {\n padding: 6px 8px;\n color: var(--nile-colors-neutral-500, #98a2b3);\n }\n `,\n ];\n }\n\n protected willUpdate(): void {\n if (this.activeIndex >= this.items.length) this.activeIndex = 0;\n }\n\n public next(): void {\n if (this.items.length) this.activeIndex = (this.activeIndex + 1) % this.items.length;\n }\n\n public prev(): void {\n if (this.items.length) {\n this.activeIndex = (this.activeIndex - 1 + this.items.length) % this.items.length;\n }\n }\n\n public resetActive(): void {\n this.activeIndex = 0;\n }\n\n public selectCurrent(): boolean {\n const item = this.items[this.activeIndex];\n if (!item) return false;\n this.emit('wysiwyg-suggest-select', { item });\n return true;\n }\n\n public render(): TemplateResult {\n return html`\n <div class=\"list\" part=\"suggest-list\" @mousedown=${(e: Event) => e.preventDefault()}>\n ${this.items.length\n ? this.items.map(\n (item, index) => html`\n <div\n class=\"item ${index === this.activeIndex ? 'active' : ''}\"\n @mouseenter=${() => {\n this.activeIndex = index;\n }}\n @click=${() => this.selectCurrent()}\n >\n <span>${item.label}</span>\n ${item.hint ? html`<span class=\"hint\">${item.hint}</span>` : ''}\n </div>\n `\n )\n : html`<div class=\"empty\">No results</div>`}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-wysiwyg-suggest-list': NileWysiwygSuggestList;\n }\n}\n"]}
1
+ {"version":3,"file":"suggest-list.js","sourceRoot":"","sources":["../../../../src/nile-wysiwyg-editor/ui/suggest-list.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAkC,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,WAAW,MAAM,6BAA6B,CAAC;AAStD;;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BAA2B,CAAC;GAC9B,sBAAsB,CA2HlC","sourcesContent":["import { html, css, TemplateResult, CSSResultArray } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport NileElement from '../../internal/nile-element';\n\nexport interface SuggestItem {\n key: string;\n label: string;\n /** Secondary text shown right-aligned (e.g. slash-command hint). */\n hint?: string;\n}\n\n/**\n * Keyboard-navigable suggestion popup shared by mentions and slash commands.\n * The host positions it, feeds `items`, and drives navigation through\n * next()/prev()/selectCurrent(); picking an item emits\n * `wysiwyg-suggest-select` with the item.\n */\n@customElement('nile-wysiwyg-suggest-list')\nexport class NileWysiwygSuggestList extends NileElement {\n @property({ type: Boolean, reflect: true }) open = false;\n\n @property({ attribute: false }) items: SuggestItem[] = [];\n\n @state() private activeIndex = 0;\n\n public static get styles(): CSSResultArray {\n return [\n css`\n :host {\n font-family: var(\n --nile-font-family-sans-serif,\n var(--ng-font-family-body, system-ui, -apple-system, sans-serif)\n );\n position: absolute;\n z-index: 25;\n display: none;\n }\n\n :host([open]) {\n display: block;\n }\n\n .list {\n min-width: 200px;\n max-width: 320px;\n max-height: 240px;\n overflow-y: auto;\n padding: 4px;\n background: var(--nile-wysiwyg-popover-bg, #ffffff);\n border: 1px solid var(--nile-colors-neutral-400, #d0d5dd);\n border-radius: 8px;\n box-shadow: var(--nile-wysiwyg-popover-shadow, 0 4px 12px rgba(16, 24, 40, 0.12));\n font-size: 13px;\n }\n\n .item {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n padding: 6px 8px;\n border-radius: 5px;\n cursor: pointer;\n color: var(--nile-colors-neutral-700, #344054);\n }\n\n .item.active {\n background: var(--nile-colors-primary-50, var(--ng-componentcolors-utility-blue-50, #eff4ff));\n color: var(--nile-colors-primary-700, var(--ng-componentcolors-utility-blue-700, #1d4ed8));\n }\n\n .hint {\n font-size: 11px;\n color: var(--nile-colors-neutral-500, #98a2b3);\n }\n\n .empty {\n padding: 6px 8px;\n color: var(--nile-colors-neutral-500, #98a2b3);\n }\n `,\n ];\n }\n\n protected willUpdate(): void {\n if (this.activeIndex >= this.items.length) this.activeIndex = 0;\n }\n\n protected updated(changed: Map<string, unknown>): void {\n // Keep the highlighted item visible as the user arrows through a list\n // that overflows the popup's max-height. `nearest` is a no-op when the\n // item is already visible (e.g. after a hover), so it never fights the mouse.\n if (changed.has('activeIndex') || changed.has('items')) {\n const active = this.renderRoot.querySelector('.item.active');\n (active as HTMLElement | null)?.scrollIntoView({ block: 'nearest' });\n }\n }\n\n public next(): void {\n if (this.items.length) this.activeIndex = (this.activeIndex + 1) % this.items.length;\n }\n\n public prev(): void {\n if (this.items.length) {\n this.activeIndex = (this.activeIndex - 1 + this.items.length) % this.items.length;\n }\n }\n\n public resetActive(): void {\n this.activeIndex = 0;\n }\n\n public selectCurrent(): boolean {\n const item = this.items[this.activeIndex];\n if (!item) return false;\n this.emit('wysiwyg-suggest-select', { item });\n return true;\n }\n\n public render(): TemplateResult {\n return html`\n <div class=\"list\" part=\"suggest-list\" @mousedown=${(e: Event) => e.preventDefault()}>\n ${this.items.length\n ? this.items.map(\n (item, index) => html`\n <div\n class=\"item ${index === this.activeIndex ? 'active' : ''}\"\n @mouseenter=${() => {\n this.activeIndex = index;\n }}\n @click=${() => this.selectCurrent()}\n >\n <span>${item.label}</span>\n ${item.hint ? html`<span class=\"hint\">${item.hint}</span>` : ''}\n </div>\n `\n )\n : html`<div class=\"empty\">No results</div>`}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-wysiwyg-suggest-list': NileWysiwygSuggestList;\n }\n}\n"]}
@@ -1,19 +1,30 @@
1
1
  import { TemplateResult, CSSResultArray } from 'lit';
2
2
  import NileElement from '../../internal/nile-element';
3
3
  /**
4
- * Toolbar item: a table button that opens an N×M hover grid. Picking a cell
5
- * emits `wysiwyg-command` with `insertTable { rows, cols }`.
4
+ * Toolbar item: a table button that opens a hover grid which auto-expands as
5
+ * the pointer reaches the last row/column (up to `maxRows`×`maxCols`), plus a
6
+ * "Custom" rows×cols input for larger tables. Picking a cell or confirming the
7
+ * custom size emits `wysiwyg-command` with `insertTable { rows, cols }`.
6
8
  */
7
9
  export declare class NileWysiwygTablePicker extends NileElement {
8
10
  disabled: boolean;
11
+ /** Hard cap on the number of rows selectable via grid or custom input. */
12
+ maxRows: number;
13
+ /** Hard cap on the number of columns selectable via grid or custom input. */
14
+ maxCols: number;
9
15
  private open;
10
16
  private hoverRows;
11
17
  private hoverCols;
18
+ private customRows;
19
+ private customCols;
12
20
  static get styles(): CSSResultArray;
13
21
  connectedCallback(): void;
14
22
  disconnectedCallback(): void;
15
23
  private handleOutside;
16
24
  private pick;
25
+ /** Clamp raw input to 1..max; returns 0 when empty/invalid. */
26
+ private clamp;
27
+ private insertCustom;
17
28
  render(): TemplateResult;
18
29
  }
19
30
  declare global {