@aquera/nile-elements 0.1.64-beta-1.1 → 0.1.64-beta-1.2

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 (230) hide show
  1. package/demo/index.html +70 -53
  2. package/dist/index.cjs.js +1 -1
  3. package/dist/index.esm.js +1 -1
  4. package/dist/index.js +590 -545
  5. package/dist/nile-avatar/nile-avatar.test.cjs.js +1 -1
  6. package/dist/nile-avatar/nile-avatar.test.cjs.js.map +1 -1
  7. package/dist/nile-avatar/nile-avatar.test.esm.js +1 -1
  8. package/dist/nile-badge/index.cjs.js +1 -1
  9. package/dist/nile-badge/index.esm.js +1 -1
  10. package/dist/nile-badge/nile-badge.cjs.js +1 -1
  11. package/dist/nile-badge/nile-badge.cjs.js.map +1 -1
  12. package/dist/nile-badge/nile-badge.esm.js +1 -1
  13. package/dist/nile-badge/nile-badge.test.cjs.js +1 -1
  14. package/dist/nile-badge/nile-badge.test.cjs.js.map +1 -1
  15. package/dist/nile-badge/nile-badge.test.esm.js +1 -1
  16. package/dist/nile-button/index.cjs.js +1 -1
  17. package/dist/nile-button/index.esm.js +1 -1
  18. package/dist/nile-button/nile-button.cjs.js +1 -1
  19. package/dist/nile-button/nile-button.cjs.js.map +1 -1
  20. package/dist/nile-button/nile-button.esm.js +2 -2
  21. package/dist/nile-button/nile-button.test.cjs.js +1 -1
  22. package/dist/nile-button/nile-button.test.cjs.js.map +1 -1
  23. package/dist/nile-button/nile-button.test.esm.js +1 -1
  24. package/dist/nile-calendar/nile-calendar.test.cjs.js +1 -1
  25. package/dist/nile-calendar/nile-calendar.test.cjs.js.map +1 -1
  26. package/dist/nile-calendar/nile-calendar.test.esm.js +5 -5
  27. package/dist/nile-chip/nile-chip.test.cjs.js +1 -1
  28. package/dist/nile-chip/nile-chip.test.cjs.js.map +1 -1
  29. package/dist/nile-chip/nile-chip.test.esm.js +1 -1
  30. package/dist/nile-dialog/index.cjs.js +1 -1
  31. package/dist/nile-dialog/index.esm.js +1 -1
  32. package/dist/nile-dialog/nile-dialog.cjs.js +1 -1
  33. package/dist/nile-dialog/nile-dialog.cjs.js.map +1 -1
  34. package/dist/nile-dialog/nile-dialog.esm.js +1 -1
  35. package/dist/nile-dialog/nile-dialog.test.cjs.js +1 -1
  36. package/dist/nile-dialog/nile-dialog.test.cjs.js.map +1 -1
  37. package/dist/nile-dialog/nile-dialog.test.esm.js +1 -1
  38. package/dist/nile-drawer/index.cjs.js +1 -1
  39. package/dist/nile-drawer/index.esm.js +1 -1
  40. package/dist/nile-drawer/nile-drawer.cjs.js +1 -1
  41. package/dist/nile-drawer/nile-drawer.cjs.js.map +1 -1
  42. package/dist/nile-drawer/nile-drawer.esm.js +2 -2
  43. package/dist/nile-drawer/nile-drawer.test.cjs.js +1 -1
  44. package/dist/nile-drawer/nile-drawer.test.cjs.js.map +1 -1
  45. package/dist/nile-drawer/nile-drawer.test.esm.js +1 -1
  46. package/dist/nile-icon/icons/svg/bold-try.cjs.js +2 -0
  47. package/dist/nile-icon/icons/svg/bold-try.cjs.js.map +1 -0
  48. package/dist/nile-icon/icons/svg/bold-try.esm.js +1 -0
  49. package/dist/nile-icon/icons/svg/index.cjs.js +1 -1
  50. package/dist/nile-icon/icons/svg/index.esm.js +1 -1
  51. package/dist/nile-icon/icons/svg/nile-bold.cjs.js +2 -0
  52. package/dist/nile-icon/icons/svg/nile-bold.cjs.js.map +1 -0
  53. package/dist/nile-icon/icons/svg/nile-bold.esm.js +1 -0
  54. package/dist/nile-icon/icons/svg/nile-centeralign.cjs.js +2 -0
  55. package/dist/nile-icon/icons/svg/nile-centeralign.cjs.js.map +1 -0
  56. package/dist/nile-icon/icons/svg/nile-centeralign.esm.js +1 -0
  57. package/dist/nile-icon/icons/svg/nile-italic.cjs.js +2 -0
  58. package/dist/nile-icon/icons/svg/nile-italic.cjs.js.map +1 -0
  59. package/dist/nile-icon/icons/svg/nile-italic.esm.js +1 -0
  60. package/dist/nile-icon/icons/svg/nile-justify.cjs.js +2 -0
  61. package/dist/nile-icon/icons/svg/nile-justify.cjs.js.map +1 -0
  62. package/dist/nile-icon/icons/svg/nile-justify.esm.js +1 -0
  63. package/dist/nile-icon/icons/svg/nile-leftalign.cjs.js +2 -0
  64. package/dist/nile-icon/icons/svg/nile-leftalign.cjs.js.map +1 -0
  65. package/dist/nile-icon/icons/svg/nile-leftalign.esm.js +1 -0
  66. package/dist/nile-icon/icons/svg/nile-ol.cjs.js +2 -0
  67. package/dist/nile-icon/icons/svg/nile-ol.cjs.js.map +1 -0
  68. package/dist/nile-icon/icons/svg/nile-ol.esm.js +1 -0
  69. package/dist/nile-icon/icons/svg/nile-rightalign.cjs.js +2 -0
  70. package/dist/nile-icon/icons/svg/nile-rightalign.cjs.js.map +1 -0
  71. package/dist/nile-icon/icons/svg/nile-rightalign.esm.js +1 -0
  72. package/dist/nile-icon/icons/svg/nile-ul.cjs.js +2 -0
  73. package/dist/nile-icon/icons/svg/nile-ul.cjs.js.map +1 -0
  74. package/dist/nile-icon/icons/svg/nile-ul.esm.js +1 -0
  75. package/dist/nile-icon/icons/svg/nile-underline.cjs.js +2 -0
  76. package/dist/nile-icon/icons/svg/nile-underline.cjs.js.map +1 -0
  77. package/dist/nile-icon/icons/svg/nile-underline.esm.js +1 -0
  78. package/dist/nile-icon/index.cjs.js +1 -1
  79. package/dist/nile-icon/index.cjs.js.map +1 -1
  80. package/dist/nile-icon/index.esm.js +1 -1
  81. package/dist/nile-icon/nile-icon.test.cjs.js +1 -1
  82. package/dist/nile-icon/nile-icon.test.cjs.js.map +1 -1
  83. package/dist/nile-icon/nile-icon.test.esm.js +1 -1
  84. package/dist/nile-icon-button/index.cjs.js +1 -1
  85. package/dist/nile-icon-button/index.esm.js +1 -1
  86. package/dist/nile-icon-button/nile-icon-button.cjs.js +1 -1
  87. package/dist/nile-icon-button/nile-icon-button.cjs.js.map +1 -1
  88. package/dist/nile-icon-button/nile-icon-button.esm.js +1 -1
  89. package/dist/nile-input/index.cjs.js +1 -1
  90. package/dist/nile-input/index.esm.js +1 -1
  91. package/dist/nile-input/nile-input.cjs.js +1 -1
  92. package/dist/nile-input/nile-input.cjs.js.map +1 -1
  93. package/dist/nile-input/nile-input.esm.js +1 -1
  94. package/dist/nile-input/nile-input.test.cjs.js +1 -1
  95. package/dist/nile-input/nile-input.test.cjs.js.map +1 -1
  96. package/dist/nile-input/nile-input.test.esm.js +1 -1
  97. package/dist/nile-menu-item/index.cjs.js +1 -1
  98. package/dist/nile-menu-item/index.esm.js +1 -1
  99. package/dist/nile-menu-item/nile-menu-item.cjs.js +1 -1
  100. package/dist/nile-menu-item/nile-menu-item.cjs.js.map +1 -1
  101. package/dist/nile-menu-item/nile-menu-item.esm.js +1 -1
  102. package/dist/nile-option/index.cjs.js +1 -1
  103. package/dist/nile-option/index.esm.js +1 -1
  104. package/dist/nile-option/nile-option.cjs.js +1 -1
  105. package/dist/nile-option/nile-option.cjs.js.map +1 -1
  106. package/dist/nile-option/nile-option.esm.js +1 -1
  107. package/dist/nile-rich-text-editor/index.cjs.js +1 -1
  108. package/dist/nile-rich-text-editor/index.esm.js +1 -1
  109. package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js +1 -1
  110. package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js.map +1 -1
  111. package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js +1 -1
  112. package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js.map +1 -1
  113. package/dist/nile-rich-text-editor/nile-rich-text-editor.css.esm.js +41 -4
  114. package/dist/nile-rich-text-editor/nile-rich-text-editor.esm.js +1 -1
  115. package/dist/nile-rich-text-editor/nile-rte-mentions-item.cjs.js +1 -1
  116. package/dist/nile-rich-text-editor/nile-rte-mentions-item.cjs.js.map +1 -1
  117. package/dist/nile-rich-text-editor/nile-rte-mentions-item.esm.js +1 -1
  118. package/dist/nile-rich-text-editor/nile-rte-mentions.cjs.js +2 -2
  119. package/dist/nile-rich-text-editor/nile-rte-mentions.cjs.js.map +1 -1
  120. package/dist/nile-rich-text-editor/nile-rte-mentions.esm.js +1 -1
  121. package/dist/nile-rich-text-editor/nile-rte-select.cjs.js +1 -1
  122. package/dist/nile-rich-text-editor/nile-rte-select.cjs.js.map +1 -1
  123. package/dist/nile-rich-text-editor/nile-rte-select.esm.js +14 -12
  124. package/dist/nile-select/index.cjs.js +1 -1
  125. package/dist/nile-select/index.esm.js +1 -1
  126. package/dist/nile-select/nile-select.cjs.js +1 -1
  127. package/dist/nile-select/nile-select.cjs.js.map +1 -1
  128. package/dist/nile-select/nile-select.esm.js +1 -1
  129. package/dist/nile-select/nile-select.test.cjs.js +1 -1
  130. package/dist/nile-select/nile-select.test.cjs.js.map +1 -1
  131. package/dist/nile-select/nile-select.test.esm.js +1 -1
  132. package/dist/nile-tab/index.cjs.js +1 -1
  133. package/dist/nile-tab/index.esm.js +1 -1
  134. package/dist/nile-tab/nile-tab.cjs.js +1 -1
  135. package/dist/nile-tab/nile-tab.cjs.js.map +1 -1
  136. package/dist/nile-tab/nile-tab.esm.js +1 -1
  137. package/dist/nile-tab-group/index.cjs.js +1 -1
  138. package/dist/nile-tab-group/index.esm.js +1 -1
  139. package/dist/nile-tab-group/nile-tab-group.cjs.js +1 -1
  140. package/dist/nile-tab-group/nile-tab-group.cjs.js.map +1 -1
  141. package/dist/nile-tab-group/nile-tab-group.esm.js +2 -2
  142. package/dist/nile-tab-group/nile-tab-group.test.cjs.js +1 -1
  143. package/dist/nile-tab-group/nile-tab-group.test.cjs.js.map +1 -1
  144. package/dist/nile-tab-group/nile-tab-group.test.esm.js +1 -1
  145. package/dist/nile-tag/index.cjs.js +1 -1
  146. package/dist/nile-tag/index.esm.js +1 -1
  147. package/dist/nile-tag/nile-tag.cjs.js +1 -1
  148. package/dist/nile-tag/nile-tag.cjs.js.map +1 -1
  149. package/dist/nile-tag/nile-tag.esm.js +1 -1
  150. package/dist/nile-toast/index.cjs.js +1 -1
  151. package/dist/nile-toast/index.esm.js +1 -1
  152. package/dist/nile-toast/nile-toast.cjs.js +1 -1
  153. package/dist/nile-toast/nile-toast.cjs.js.map +1 -1
  154. package/dist/nile-toast/nile-toast.esm.js +1 -1
  155. package/dist/nile-tree/index.cjs.js +1 -1
  156. package/dist/nile-tree/index.esm.js +1 -1
  157. package/dist/nile-tree/nile-tree.cjs.js +1 -1
  158. package/dist/nile-tree/nile-tree.cjs.js.map +1 -1
  159. package/dist/nile-tree/nile-tree.esm.js +1 -1
  160. package/dist/nile-tree-item/index.cjs.js +1 -1
  161. package/dist/nile-tree-item/index.esm.js +1 -1
  162. package/dist/nile-tree-item/nile-tree-item.cjs.js +1 -1
  163. package/dist/nile-tree-item/nile-tree-item.cjs.js.map +1 -1
  164. package/dist/nile-tree-item/nile-tree-item.esm.js +1 -1
  165. package/dist/src/nile-icon/icons/svg/bold-try.d.ts +5 -0
  166. package/dist/src/nile-icon/icons/svg/bold-try.js +5 -0
  167. package/dist/src/nile-icon/icons/svg/bold-try.js.map +1 -0
  168. package/dist/src/nile-icon/icons/svg/index.d.ts +10 -0
  169. package/dist/src/nile-icon/icons/svg/index.js +10 -0
  170. package/dist/src/nile-icon/icons/svg/index.js.map +1 -1
  171. package/dist/src/nile-icon/icons/svg/nile-bold.d.ts +5 -0
  172. package/dist/src/nile-icon/icons/svg/nile-bold.js +5 -0
  173. package/dist/src/nile-icon/icons/svg/nile-bold.js.map +1 -0
  174. package/dist/src/nile-icon/icons/svg/nile-centeralign.d.ts +5 -0
  175. package/dist/src/nile-icon/icons/svg/nile-centeralign.js +5 -0
  176. package/dist/src/nile-icon/icons/svg/nile-centeralign.js.map +1 -0
  177. package/dist/src/nile-icon/icons/svg/nile-italic.d.ts +5 -0
  178. package/dist/src/nile-icon/icons/svg/nile-italic.js +5 -0
  179. package/dist/src/nile-icon/icons/svg/nile-italic.js.map +1 -0
  180. package/dist/src/nile-icon/icons/svg/nile-justify.d.ts +5 -0
  181. package/dist/src/nile-icon/icons/svg/nile-justify.js +5 -0
  182. package/dist/src/nile-icon/icons/svg/nile-justify.js.map +1 -0
  183. package/dist/src/nile-icon/icons/svg/nile-leftalign.d.ts +5 -0
  184. package/dist/src/nile-icon/icons/svg/nile-leftalign.js +5 -0
  185. package/dist/src/nile-icon/icons/svg/nile-leftalign.js.map +1 -0
  186. package/dist/src/nile-icon/icons/svg/nile-ol.d.ts +5 -0
  187. package/dist/src/nile-icon/icons/svg/nile-ol.js +5 -0
  188. package/dist/src/nile-icon/icons/svg/nile-ol.js.map +1 -0
  189. package/dist/src/nile-icon/icons/svg/nile-rightalign.d.ts +5 -0
  190. package/dist/src/nile-icon/icons/svg/nile-rightalign.js +5 -0
  191. package/dist/src/nile-icon/icons/svg/nile-rightalign.js.map +1 -0
  192. package/dist/src/nile-icon/icons/svg/nile-ul.d.ts +5 -0
  193. package/dist/src/nile-icon/icons/svg/nile-ul.js +5 -0
  194. package/dist/src/nile-icon/icons/svg/nile-ul.js.map +1 -0
  195. package/dist/src/nile-icon/icons/svg/nile-underline.d.ts +5 -0
  196. package/dist/src/nile-icon/icons/svg/nile-underline.js +5 -0
  197. package/dist/src/nile-icon/icons/svg/nile-underline.js.map +1 -0
  198. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.d.ts +0 -9
  199. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js +40 -11
  200. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js.map +1 -1
  201. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.d.ts +1 -1
  202. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js +23 -70
  203. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js.map +1 -1
  204. package/dist/src/nile-rich-text-editor/nile-rte-mentions-item.d.ts +1 -0
  205. package/dist/src/nile-rich-text-editor/nile-rte-mentions-item.js +5 -0
  206. package/dist/src/nile-rich-text-editor/nile-rte-mentions-item.js.map +1 -1
  207. package/dist/src/nile-rich-text-editor/nile-rte-mentions.d.ts +3 -0
  208. package/dist/src/nile-rich-text-editor/nile-rte-mentions.js +39 -2
  209. package/dist/src/nile-rich-text-editor/nile-rte-mentions.js.map +1 -1
  210. package/dist/src/nile-rich-text-editor/nile-rte-select.js +26 -3
  211. package/dist/src/nile-rich-text-editor/nile-rte-select.js.map +1 -1
  212. package/dist/tsconfig.tsbuildinfo +1 -1
  213. package/package.json +1 -1
  214. package/src/nile-icon/icons/svg/bold-try.ts +5 -0
  215. package/src/nile-icon/icons/svg/index.ts +10 -0
  216. package/src/nile-icon/icons/svg/nile-bold.ts +5 -0
  217. package/src/nile-icon/icons/svg/nile-centeralign.ts +5 -0
  218. package/src/nile-icon/icons/svg/nile-italic.ts +5 -0
  219. package/src/nile-icon/icons/svg/nile-justify.ts +5 -0
  220. package/src/nile-icon/icons/svg/nile-leftalign.ts +5 -0
  221. package/src/nile-icon/icons/svg/nile-ol.ts +5 -0
  222. package/src/nile-icon/icons/svg/nile-rightalign.ts +5 -0
  223. package/src/nile-icon/icons/svg/nile-ul.ts +5 -0
  224. package/src/nile-icon/icons/svg/nile-underline.ts +5 -0
  225. package/src/nile-rich-text-editor/nile-rich-text-editor.css.ts +42 -14
  226. package/src/nile-rich-text-editor/nile-rich-text-editor.ts +29 -67
  227. package/src/nile-rich-text-editor/nile-rte-mentions-item.ts +5 -0
  228. package/src/nile-rich-text-editor/nile-rte-mentions.ts +38 -4
  229. package/src/nile-rich-text-editor/nile-rte-select.ts +26 -4
  230. package/vscode-html-custom-data.json +10 -2
@@ -1 +1 @@
1
- import{__decorate as t}from"tslib";import{LitElement as e}from"lit";import{property as i,state as s,customElement as n}from"lit/decorators.js";import"./nile-rte-toolbar.esm.js";import"./nile-rte-toolbar-item.esm.js";import"./nile-rte-select.esm.js";import"./nile-rte-color.esm.js";import"./nile-rte-divider.esm.js";import"./nile-rte-preview.esm.js";import"./nile-rte-mentions.esm.js";import{s as r,a as o,b as h,c as l,i as c,t as a,n as d,d as u,r as p}from"./utils.esm.js";const f={bold:"bold",italic:"itallic",underline:"underline",link:"user",left:"user",center:"user",right:"user",justify:"user",ul:"ul",ol:"ol",clear:"close"};let b=class extends e{constructor(){super(...arguments),this.value="",this.mentions={},this.content="",this.previewEl=null,this.toolbarEl=null,this.lastRange=null,this.buttonMap=new Map,this.headingSelect=null,this.fontSelect=null,this.colorInput=null,this.mentionsEl=null,this.onSelectionChange=()=>{if(!this.editorEl)return;const t=document.getSelection();if(!t||0===t.rangeCount)return;const e=t.getRangeAt(0);this.editorEl.contains(e.commonAncestorContainer)&&(this.lastRange=e.cloneRange(),this.updateToolbarState())}}createRenderRoot(){return this}shouldUpdate(){return!1}connectedCallback(){super.connectedCallback(),this.injectStyles(),this.toolbarEl=this.querySelector("nile-rte-toolbar"),this.previewEl=this.querySelector("nile-rte-preview"),this.ensureEditor(),this.value&&!this.editorEl.innerHTML.trim()&&(this.editorEl.innerHTML=this.value),this.content=this.editorEl.innerHTML,this.toolbarEl&&this.wireAuthoredToolbar(this.toolbarEl),this.mentionsEl=this.querySelector("nile-rte-mentions"),this.mentionsEl&&(this.mentionsEl.attach?.(this.editorEl,this),this.mentionsEl.setExternalConfig?.(this.mentions)),this.wireEditor(),this.updateToolbarState(),this.syncPreview(),document.addEventListener("selectionchange",this.onSelectionChange,!0)}disconnectedCallback(){document.removeEventListener("selectionchange",this.onSelectionChange,!0),this.mentionsEl&&this.mentionsEl.detach&&this.mentionsEl.detach(),super.disconnectedCallback()}injectStyles(){if(this.querySelector("style[data-rte-style]"))return;const t=document.createElement("style");t.setAttribute("data-rte-style","true"),t.textContent='\n /* Host positioning for overlays */\n nile-rich-text-editor { position: relative; display: block; }\n\n \nnile-rte-toolbar-item > nile-button::part(base) {\n \n width:32px; height:32px; padding:0px 6px;\n}\n \n \n\n\n .toolbar, nile-rte-toolbar {\n display:flex; align-items:center; gap:8px; padding-top:8px; padding-left: 8px; padding-right: 8px;\n border:1px solid #e5e7eb; border-bottom:none; border-radius:8px 8px 0 0; background:#fff;\n }\n\n nile-rte-toolbar-item > button, .toolbar button, nile-rte-toolbar button {\n border:1px solid #e5e7eb; background:#fff; border-radius:6px;\n cursor:pointer;\n }\n\n \n /* Ensure clicks hit the button (not nested icon internals) */\n nile-rte-toolbar-item > button nile-icon { pointer-events:none; }\n\n nile-rte-toolbar-item > button.active { border-color:#2563eb; background:#eff6ff; }\n nile-rte-select select { height:32px; border:1px solid #e5e7eb; border-radius:6px; background:#fff; }\n nile-rte-color input[type="color"] { height:32px; width:36px; border:1px solid #e5e7eb; padding:0; border-radius:6px; background:#fff; }\n nile-rte-divider { width:1px; height:20px; background:#e5e7eb; display:inline-block; margin:0 4px; }\n\n .editor p { margin:1em 0; }\n .editor h1 { font-size:2em }\n .editor h2 { font-size:1.5em }\n .editor h3 { font-size:1.17em }\n .editor h4 { font-size:1em }\n .editor h5 { font-size:0.83em }\n .editor h6 { font-size:0.67em }\n\n .editor { min-height:160px; padding:12px; border:1px solid #e5e7eb; border-radius:0 0 8px 8px; background:#fff; outline:none; }\n nile-rte-preview { display:block; margin-top:10px; padding:10px; border:1px dashed #cbd5e1; border-radius:8px; background:#fafafa; }\n ',this.insertBefore(t,this.firstChild)}ensureEditor(){if(this.editorEl=this.querySelector(".editor"),!this.editorEl){const t=document.createElement("div");t.className="editor",t.setAttribute("contenteditable","true"),this.toolbarEl?.nextSibling?this.insertBefore(t,this.toolbarEl.nextSibling):this.previewEl?this.insertBefore(t,this.previewEl):this.appendChild(t),this.editorEl=t}this.editorEl.innerHTML.trim()||(this.editorEl.innerHTML="<p><br></p>"),this.ensureAtLeastOneParagraph()}wireEditor(){this.editorEl.addEventListener("input",(()=>{this.ensureAtLeastOneParagraph(),this.updateContent()})),this.editorEl.addEventListener("mouseup",(()=>this.saveSelection())),this.editorEl.addEventListener("keyup",(()=>this.saveSelection()))}wireAuthoredToolbar(t){this.buttonMap.clear(),this.headingSelect=null,this.fontSelect=null,this.colorInput=null,Array.from(t.children).forEach((t=>{const e=t.tagName.toLowerCase();if("nile-rte-select"!==e||"align"!==t.getAttribute("type")){if("nile-rte-toolbar-item"===e){let e=t.querySelector(":scope > nile-button");const i=t.getAttribute("name")||"",s=t.getAttribute("label")||i,n=t.getAttribute("icon"),r=t.innerHTML.trim().length>0;if(e||(e=document.createElement("nile-button"),e.variant="tertiary",e.size="small"),n)e.innerHTML=`<nile-icon name="${n}" aria-label="${s}"></nile-icon>`,t.innerHTML="";else if(r)e.innerHTML=t.innerHTML,t.innerHTML="";else{const n=f[i];n?e.innerHTML=`<nile-icon name="${n}" size="26" aria-label="${s}"></nile-icon>`:e.textContent=s||i,t.innerHTML=""}e.isConnected||t.appendChild(e),e.setAttribute("aria-label",s),e.addEventListener("mousedown",(t=>t.preventDefault())),e.addEventListener("click",(()=>this.onToolbarCommand(i)));const o=this.buttonMap.get(i)??[];return o.push(e),void this.buttonMap.set(i,o)}if("nile-rte-select"!==e){if("nile-rte-color"===e){const e=t.getAttribute("label")??"Text color",i=t.getAttribute("value")??"#000000";let s=t.querySelector(':scope > input[type="color"]');s||(s=document.createElement("input"),s.type="color",t.appendChild(s)),s.title=e,s.value=i,s.addEventListener("mousedown",(t=>t.preventDefault())),s.addEventListener("input",(()=>{this.focusAndRestore(),l(this.editorEl,s.value),this.updateContent(),this.updateToolbarState()})),this.colorInput=s}}else{const e=t.getAttribute("type")||"";t.addEventListener("change",(t=>{this.focusAndRestore();const i=t.detail;"heading"===e?o(this.editorEl,i):"font"===e&&h(this.editorEl,i),this.updateContent(),this.updateToolbarState()}))}}else t.addEventListener("change",(t=>{this.focusAndRestore();const e=t.detail;r(this.editorEl,e),this.updateContent(),this.updateToolbarState()}))}))}saveSelection(){const t=window.getSelection();t&&t.rangeCount&&(this.lastRange=t.getRangeAt(0).cloneRange())}restoreSelection(){if(!this.lastRange)return;const t=document.getSelection();t&&(t.removeAllRanges(),t.addRange(this.lastRange))}focusAndRestore(){this.editorEl?.focus(),this.restoreSelection()}insertList(t){if(this.restoreSelection(),!this.lastRange)return;const e=document.createElement(t),i=this.lastRange.extractContents(),s=document.createElement("div");s.appendChild(i),Array.from(s.childNodes).forEach((t=>{if(t.nodeType===Node.TEXT_NODE&&!t.textContent?.trim())return;const i=document.createElement("li");i.appendChild(t),e.appendChild(i)})),this.lastRange.insertNode(e),this.afterListEdit(e)}afterListEdit(t){const e=document.createRange();e.setStartAfter(t),e.collapse(!0);const i=window.getSelection();i?.removeAllRanges(),i?.addRange(e),this.saveSelection(),this.updateContent(),this.updateToolbarState()}ensureAtLeastOneParagraph(){const t=this.editorEl;if(!t)return;const e=""===(t.textContent??"").replace(/\u200B/g,"").trim();if(0===t.childNodes.length||e)return void(t.innerHTML="<p><br></p>");if(!t.querySelector("p,h1,h2,h3,h4,h5,h6,ul,ol,table,blockquote,pre")){const e=document.createElement("p");for(;t.firstChild;)e.appendChild(t.firstChild);return e.hasChildNodes()||e.appendChild(document.createElement("br")),void t.appendChild(e)}t.querySelectorAll("p").forEach((t=>{""===(t.textContent??"").replace(/\u200B/g,"")&&(t.innerHTML.toLowerCase().includes("<br")||(t.innerHTML="<br>"))}))}onToolbarCommand(t){switch(this.focusAndRestore(),t){case"bold":a(this.editorEl,"strong");break;case"italic":a(this.editorEl,"em");break;case"underline":a(this.editorEl,"u");break;case"left":r(this.editorEl,"left");break;case"center":r(this.editorEl,"center");break;case"right":r(this.editorEl,"right");break;case"justify":r(this.editorEl,"justify");break;case"ul":this.insertList("ul");break;case"ol":this.insertList("ol");break;case"link":c(this.editorEl);break;case"clear":const t=document.createTreeWalker(this.editorEl,NodeFilter.SHOW_ELEMENT),e=[];for(;t.nextNode();){const i=t.currentNode;i.removeAttribute("style"),["B","STRONG","I","EM","U","SPAN","FONT"].includes(i.tagName)&&e.push(i)}for(const t of e){for(;t.firstChild;)t.parentNode?.insertBefore(t.firstChild,t);t.remove()}this.ensureAtLeastOneParagraph()}this.updateContent(),this.updateToolbarState()}setBtnActive(t,e){const i=this.buttonMap.get(t);if(i)for(const t of i)t.toggleAttribute("data-active",!!e)}updateToolbarState(){if(!this.editorEl)return;const t=document.getSelection();if(!t||0===t.rangeCount)return;const e=t.getRangeAt(0);if(!this.editorEl.contains(e.commonAncestorContainer))return;const i=d(e.startContainer)||this.editorEl,s=getComputedStyle(i),n=u(e.startContainer,this.editorEl)||this.editorEl,r=(()=>{let t=i;for(;t&&t!==this.editorEl;){if(t instanceof HTMLElement){const e=t.tagName.toLowerCase();if("strong"===e||"b"===e)return!0;const i=getComputedStyle(t).fontWeight;if(parseInt(i,10)>=600)return!0}t=t.parentNode}return!1})(),o=(()=>{let t=i;for(;t&&t!==this.editorEl;){if(t instanceof HTMLElement){const e=t.tagName.toLowerCase();if("em"===e||"i"===e)return!0;if("italic"===getComputedStyle(t).fontStyle)return!0}t=t.parentNode}return!1})(),h=(()=>{let t=i;for(;t&&t!==this.editorEl;){if(t instanceof HTMLElement){const e=getComputedStyle(t).textDecorationLine;if(e&&e.includes("underline"))return!0;if("u"===t.tagName.toLowerCase())return!0}t=t.parentNode}return!1})(),l=!!i.closest("a"),c=n.style.textAlign||getComputedStyle(n).textAlign||"start",a="start"===c?"left":c,f=!!i.closest("li")&&i.closest("ul,ol")?.tagName.toLowerCase()||"";if(this.setBtnActive("bold",r),this.setBtnActive("italic",o),this.setBtnActive("underline",h),this.setBtnActive("link",l),this.setBtnActive("left","left"===a&&!["center","right","justify"].includes(a)),this.setBtnActive("center","center"===a),this.setBtnActive("right","right"===a),this.setBtnActive("justify","justify"===a),this.setBtnActive("ul","ul"===f),this.setBtnActive("ol","ol"===f),this.headingSelect){const t=n.tagName.toLowerCase(),e=["h1","h2","h3"].includes(t)?t:"p";this.headingSelect.value!==e&&(this.headingSelect.value=e)}if(this.fontSelect){const t=(s.fontFamily||"").replace(/["']/g,"").split(",")[0].trim().toLowerCase();if(t)for(const e of Array.from(this.fontSelect.options))if(e.value.toLowerCase()===t){this.fontSelect.value=e.value;break}}if(this.colorInput){const t=p(s.color);t&&this.colorInput.value.toLowerCase()!==t.toLowerCase()&&(this.colorInput.value=t)}}syncPreview(){this.updateContent()}updateContent(){this.editorEl&&(this.ensureAtLeastOneParagraph(),this.content=this.editorEl.innerHTML,this.previewEl&&(this.previewEl.innerHTML=this.content),this.dispatchEvent(new CustomEvent("content-changed",{detail:{content:this.content},bubbles:!0,composed:!0})))}};t([i({type:String})],b.prototype,"value",void 0),t([i({attribute:"mentions",converter:{fromAttribute:t=>{try{const e=JSON.parse(t),i={};for(const t of Object.keys(e)){const s=e[t];Array.isArray(s)&&(i[t]=s.filter((t=>t&&"string"==typeof t.key&&"string"==typeof t.label)).map((t=>({key:t.key,label:t.label}))))}return i}catch{return{}}},toAttribute:t=>JSON.stringify(t)}})],b.prototype,"mentions",void 0),t([s()],b.prototype,"content",void 0),b=t([n("nile-rich-text-editor")],b);export{b as N};
1
+ import{__decorate as t}from"tslib";import{LitElement as i}from"lit";import{property as e,state as s,customElement as n}from"lit/decorators.js";import"./nile-rte-toolbar.esm.js";import"./nile-rte-toolbar-item.esm.js";import"./nile-rte-select.esm.js";import"./nile-rte-color.esm.js";import"./nile-rte-divider.esm.js";import"./nile-rte-preview.esm.js";import"./nile-rte-mentions.esm.js";import{s as r,a as o,b as h,c as l,i as c,t as a,n as u,d as f,r as d}from"./utils.esm.js";import{s as m}from"./nile-rich-text-editor.css.esm.js";const p={bold:"nile-bold",italic:"nile-italic",underline:"nile-underline",link:"user",left:"nile-leftalign",center:"nile-centeralign",right:"nile-rightalign",justify:"nile-justify",ul:"nile-ul",ol:"nile-ol",clear:"error"};let b=class extends i{constructor(){super(...arguments),this.value="",this.mentions={},this.content="",this.previewEl=null,this.toolbarEl=null,this.lastRange=null,this.buttonMap=new Map,this.headingSelect=null,this.fontSelect=null,this.colorInput=null,this.mentionsEl=null,this.onSelectionChange=()=>{if(!this.editorEl)return;const t=document.getSelection();if(!t||0===t.rangeCount)return;const i=t.getRangeAt(0);this.editorEl.contains(i.commonAncestorContainer)&&(this.lastRange=i.cloneRange(),this.updateToolbarState())}}createRenderRoot(){return this}shouldUpdate(){return!1}injectCss(t){if(this.querySelector("style[data-rte-style]"))return;const i=document.createElement("style");i.setAttribute("data-rte-style","true"),i.textContent=t,this.insertBefore(i,this.firstChild)}connectedCallback(){super.connectedCallback(),this.injectCss(m.cssText),this.toolbarEl=this.querySelector("nile-rte-toolbar"),this.previewEl=this.querySelector("nile-rte-preview"),this.ensureEditor(),this.value&&!this.editorEl.innerHTML.trim()&&(this.editorEl.innerHTML=this.value),this.content=this.editorEl.innerHTML,this.toolbarEl&&this.wireAuthoredToolbar(this.toolbarEl),this.mentionsEl=this.querySelector("nile-rte-mentions"),this.mentionsEl&&(this.mentionsEl.attach?.(this.editorEl,this),this.mentionsEl.setExternalConfig?.(this.mentions)),this.wireEditor(),this.updateToolbarState(),this.syncPreview(),document.addEventListener("selectionchange",this.onSelectionChange,!0)}disconnectedCallback(){document.removeEventListener("selectionchange",this.onSelectionChange,!0),this.mentionsEl&&this.mentionsEl.detach&&this.mentionsEl.detach(),super.disconnectedCallback()}ensureEditor(){if(this.editorEl=this.querySelector(".editor"),!this.editorEl){const t=document.createElement("div");t.className="editor",t.setAttribute("contenteditable","true"),this.toolbarEl?.nextSibling?this.insertBefore(t,this.toolbarEl.nextSibling):this.previewEl?this.insertBefore(t,this.previewEl):this.appendChild(t),this.editorEl=t}this.editorEl.innerHTML.trim()||(this.editorEl.innerHTML="<p><br></p>"),this.ensureAtLeastOneParagraph()}wireEditor(){this.editorEl.addEventListener("input",(()=>{this.ensureAtLeastOneParagraph(),this.updateContent()})),this.editorEl.addEventListener("mouseup",(()=>this.saveSelection())),this.editorEl.addEventListener("keyup",(()=>this.saveSelection()))}wireAuthoredToolbar(t){this.buttonMap.clear(),this.headingSelect=null,this.fontSelect=null,this.colorInput=null,Array.from(t.children).forEach((t=>{const i=t.tagName.toLowerCase();if("nile-rte-select"!==i||"align"!==t.getAttribute("type")){if("nile-rte-toolbar-item"===i){let i=t.querySelector(":scope > nile-button");const e=t.getAttribute("name")||"",s=t.getAttribute("label")||e,n=t.getAttribute("icon"),r=t.innerHTML.trim().length>0;if(i||(i=document.createElement("nile-button"),i.variant="tertiary",i.size="small"),n)i.innerHTML=`<nile-icon name="${n}" aria-label="${s}"></nile-icon>`,t.innerHTML="";else if(r)i.innerHTML=t.innerHTML,t.innerHTML="";else{const n=p[e];n?i.innerHTML=`<nile-icon name="${n}" size="20" color="black" aria-label="${s}"></nile-icon>`:i.textContent=s||e,t.innerHTML=""}i.isConnected||t.appendChild(i),i.setAttribute("aria-label",s),i.addEventListener("mousedown",(t=>t.preventDefault())),i.addEventListener("click",(()=>this.onToolbarCommand(e)));const o=this.buttonMap.get(e)??[];return o.push(i),void this.buttonMap.set(e,o)}if("nile-rte-select"!==i){if("nile-rte-color"===i){const i=t.getAttribute("label")??"Text color",e=t.getAttribute("value")??"#000000";let s=t.querySelector(':scope > input[type="color"]');s||(s=document.createElement("input"),s.type="color",t.appendChild(s)),s.title=i,s.value=e,s.addEventListener("mousedown",(t=>t.preventDefault())),s.addEventListener("input",(()=>{this.focusAndRestore(),l(this.editorEl,s.value),this.updateContent(),this.updateToolbarState()})),this.colorInput=s}}else{const i=t.getAttribute("type")||"";t.addEventListener("change",(t=>{this.focusAndRestore();const e=t.detail;"heading"===i?o(this.editorEl,e):"font"===i&&h(this.editorEl,e),this.updateContent(),this.updateToolbarState()}))}}else t.addEventListener("change",(t=>{this.focusAndRestore();const i=t.detail;r(this.editorEl,i),this.updateContent(),this.updateToolbarState()}))}))}saveSelection(){const t=window.getSelection();t&&t.rangeCount&&(this.lastRange=t.getRangeAt(0).cloneRange())}restoreSelection(){if(!this.lastRange)return;const t=document.getSelection();t&&(t.removeAllRanges(),t.addRange(this.lastRange))}focusAndRestore(){this.editorEl?.focus(),this.restoreSelection()}insertList(t){if(this.restoreSelection(),!this.lastRange)return;const i=document.createElement(t),e=this.lastRange.extractContents(),s=document.createElement("div");s.appendChild(e),Array.from(s.childNodes).forEach((t=>{if(t.nodeType===Node.TEXT_NODE&&!t.textContent?.trim())return;const e=document.createElement("li");e.appendChild(t),i.appendChild(e)})),this.lastRange.insertNode(i),this.afterListEdit(i)}afterListEdit(t){const i=document.createRange();i.setStartAfter(t),i.collapse(!0);const e=window.getSelection();e?.removeAllRanges(),e?.addRange(i),this.saveSelection(),this.updateContent(),this.updateToolbarState()}ensureAtLeastOneParagraph(){const t=this.editorEl;if(!t)return;const i=""===(t.textContent??"").replace(/\u200B/g,"").trim();if(0===t.childNodes.length||i)return void(t.innerHTML="<p><br></p>");if(!t.querySelector("p,h1,h2,h3,h4,h5,h6,ul,ol,table,blockquote,pre")){const i=document.createElement("p");for(;t.firstChild;)i.appendChild(t.firstChild);return i.hasChildNodes()||i.appendChild(document.createElement("br")),void t.appendChild(i)}t.querySelectorAll("p").forEach((t=>{""===(t.textContent??"").replace(/\u200B/g,"")&&(t.innerHTML.toLowerCase().includes("<br")||(t.innerHTML="<br>"))}))}onToolbarCommand(t){switch(this.focusAndRestore(),t){case"bold":a(this.editorEl,"strong");break;case"italic":a(this.editorEl,"em");break;case"underline":a(this.editorEl,"u");break;case"left":r(this.editorEl,"left");break;case"center":r(this.editorEl,"center");break;case"right":r(this.editorEl,"right");break;case"justify":r(this.editorEl,"justify");break;case"ul":this.insertList("ul");break;case"ol":this.insertList("ol");break;case"link":c(this.editorEl);break;case"clear":const t=document.createTreeWalker(this.editorEl,NodeFilter.SHOW_ELEMENT),i=[];for(;t.nextNode();){const e=t.currentNode;e.removeAttribute("style"),["B","STRONG","I","EM","U","SPAN","FONT"].includes(e.tagName)&&i.push(e)}for(const t of i){for(;t.firstChild;)t.parentNode?.insertBefore(t.firstChild,t);t.remove()}this.ensureAtLeastOneParagraph()}this.updateContent(),this.updateToolbarState()}setBtnActive(t,i){const e=this.buttonMap.get(t);if(e)for(const t of e)t.toggleAttribute("data-active",!!i)}updateToolbarState(){if(!this.editorEl)return;const t=document.getSelection();if(!t||0===t.rangeCount)return;const i=t.getRangeAt(0);if(!this.editorEl.contains(i.commonAncestorContainer))return;const e=u(i.startContainer)||this.editorEl,s=getComputedStyle(e),n=f(i.startContainer,this.editorEl)||this.editorEl,r=(()=>{let t=e;for(;t&&t!==this.editorEl;){if(t instanceof HTMLElement){const i=t.tagName.toLowerCase();if("strong"===i||"b"===i)return!0;const e=getComputedStyle(t).fontWeight;if(parseInt(e,10)>=600)return!0}t=t.parentNode}return!1})(),o=(()=>{let t=e;for(;t&&t!==this.editorEl;){if(t instanceof HTMLElement){const i=t.tagName.toLowerCase();if("em"===i||"i"===i)return!0;if("italic"===getComputedStyle(t).fontStyle)return!0}t=t.parentNode}return!1})(),h=(()=>{let t=e;for(;t&&t!==this.editorEl;){if(t instanceof HTMLElement){const i=getComputedStyle(t).textDecorationLine;if(i&&i.includes("underline"))return!0;if("u"===t.tagName.toLowerCase())return!0}t=t.parentNode}return!1})(),l=!!e.closest("a"),c=n.style.textAlign||getComputedStyle(n).textAlign||"start",a="start"===c?"left":c,m=!!e.closest("li")&&e.closest("ul,ol")?.tagName.toLowerCase()||"";if(this.setBtnActive("bold",r),this.setBtnActive("italic",o),this.setBtnActive("underline",h),this.setBtnActive("link",l),this.setBtnActive("left","left"===a&&!["center","right","justify"].includes(a)),this.setBtnActive("center","center"===a),this.setBtnActive("right","right"===a),this.setBtnActive("justify","justify"===a),this.setBtnActive("ul","ul"===m),this.setBtnActive("ol","ol"===m),this.headingSelect){const t=n.tagName.toLowerCase(),i=["h1","h2","h3"].includes(t)?t:"p";this.headingSelect.value!==i&&(this.headingSelect.value=i)}if(this.fontSelect){const t=(s.fontFamily||"").replace(/["']/g,"").split(",")[0].trim().toLowerCase();if(t)for(const i of Array.from(this.fontSelect.options))if(i.value.toLowerCase()===t){this.fontSelect.value=i.value;break}}if(this.colorInput){const t=d(s.color);t&&this.colorInput.value.toLowerCase()!==t.toLowerCase()&&(this.colorInput.value=t)}}syncPreview(){this.updateContent()}updateContent(){this.editorEl&&(this.ensureAtLeastOneParagraph(),this.content=this.editorEl.innerHTML,this.previewEl&&(this.previewEl.innerHTML=this.content),this.dispatchEvent(new CustomEvent("content-changed",{detail:{content:this.content},bubbles:!0,composed:!0})))}};t([e({type:String})],b.prototype,"value",void 0),t([e({attribute:"mentions",converter:{fromAttribute:t=>{try{const i=JSON.parse(t),e={};for(const t of Object.keys(i)){const s=i[t];Array.isArray(s)&&(e[t]=s.filter((t=>t&&"string"==typeof t.key&&"string"==typeof t.label)).map((t=>({key:t.key,label:t.label}))))}return e}catch{return{}}},toAttribute:t=>JSON.stringify(t)}})],b.prototype,"mentions",void 0),t([s()],b.prototype,"content",void 0),b=t([n("nile-rich-text-editor")],b);export{b as N};
@@ -1,2 +1,2 @@
1
- function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}System.register(["tslib","lit","lit/decorators.js"],function(_export,_context){"use strict";var t,r,e,i,o;function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_lit){r=_lit.LitElement;},function(_litDecoratorsJs){e=_litDecoratorsJs.property;i=_litDecoratorsJs.customElement;}],execute:function execute(){o=/*#__PURE__*/function(_r){function o(){var _this;_classCallCheck(this,o);_this=_callSuper(this,o,arguments),_this.mentionsCharacter="",_this.mentionsData=[];return _this;}_inherits(o,_r);return _createClass(o,[{key:"createRenderRoot",value:function createRenderRoot(){return this;}}]);}(r);t([e({attribute:"mentionscharacter"})],o.prototype,"mentionsCharacter",void 0),t([e({attribute:"mentionsdata",converter:{fromAttribute:function fromAttribute(t){if(!t)return[];try{var _r2=JSON.parse(t);return Array.isArray(_r2)?_r2.filter(function(t){return t&&"string"==typeof t.key&&"string"==typeof t.label;}):[];}catch(_unused){return[];}},toAttribute:function toAttribute(t){return JSON.stringify(t!==null&&t!==void 0?t:[]);}}})],o.prototype,"mentionsData",void 0),o=t([i("nile-rte-mentions-item")],o);}};});
1
+ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}System.register(["tslib","lit","lit/decorators.js"],function(_export,_context){"use strict";var t,r,e,o,i;function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_lit){r=_lit.LitElement;},function(_litDecoratorsJs){e=_litDecoratorsJs.property;o=_litDecoratorsJs.customElement;}],execute:function execute(){i=/*#__PURE__*/function(_r){function i(){var _this;_classCallCheck(this,i);_this=_callSuper(this,i,arguments),_this.mentionsCharacter="",_this.mentionsColor="",_this.mentionsData=[];return _this;}_inherits(i,_r);return _createClass(i,[{key:"createRenderRoot",value:function createRenderRoot(){return this;}}]);}(r);t([e({attribute:"mentionscharacter"})],i.prototype,"mentionsCharacter",void 0),t([e({attribute:"mentionscolor"})],i.prototype,"mentionsColor",void 0),t([e({attribute:"mentionsdata",converter:{fromAttribute:function fromAttribute(t){if(!t)return[];try{var _r2=JSON.parse(t);return Array.isArray(_r2)?_r2.filter(function(t){return t&&"string"==typeof t.key&&"string"==typeof t.label;}):[];}catch(_unused){return[];}},toAttribute:function toAttribute(t){return JSON.stringify(t!==null&&t!==void 0?t:[]);}}})],i.prototype,"mentionsData",void 0),i=t([o("nile-rte-mentions-item")],i);}};});
2
2
  //# sourceMappingURL=nile-rte-mentions-item.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nile-rte-mentions-item.cjs.js","sources":["../../../src/nile-rich-text-editor/nile-rte-mentions-item.ts"],"sourcesContent":["import { LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nexport type MentionItem = { key: string; label: string };\n\n@customElement('nile-rte-mentions-item')\nexport class NileRteMentionsItem extends LitElement {\n protected createRenderRoot() { return this; } // Light DOM\n\n /** Single-character trigger, e.g., '@' or '#' */\n @property({ attribute: 'mentionscharacter' })\n mentionsCharacter: string = '';\n\n /** JSON array of { key, label } */\n @property({\n attribute: 'mentionsdata',\n converter: {\n fromAttribute: (value: string | null): MentionItem[] => {\n if (!value) return [];\n try {\n const parsed = JSON.parse(value);\n return Array.isArray(parsed)\n ? parsed.filter(i => i && typeof i.key === 'string' && typeof i.label === 'string')\n : [];\n } catch { return []; }\n },\n toAttribute: (v: MentionItem[]) => JSON.stringify(v ?? []),\n }\n })\n mentionsData: MentionItem[] = [];\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-rte-mentions-item': NileRteMentionsItem;\n }\n}\n"],"names":["NileRteMentionsItem","_r","o","constructor","this","mentionsCharacter","mentionsData","_this","_inherits","_createClass","key","value","createRenderRoot","__decorate","LitElement","property","attribute","prototype","converter","fromAttribute","parsed","JSON","parse","Array","isArray","filter","i","label","_unused","toAttribute","v","stringify","customElement"],"mappings":"gyFAMaA,CAAN,uBAAAC,EAAA,EAAA,SAAAC,EAAA,CAAAC,KAAAA,KAAAA,CAAAA,eAAAA,MAAAA,CAAAA,mCAKLC,EAAAA,KAAAA,CAAiBC,kBAAW,EAkB5BD,CAAAA,KAAAA,CAAYE,aAAkB,EAC/B,QAAAC,KAAA,EAvBWC,SAAA,CAAAN,CAAA,CAAAD,EAAA,SAAAQ,YAAA,CAAAP,CAAA,GAAAQ,GAAA,oBAAAC,KAAA,UAAAC,gBAAAA,CAAAA,CAAqB,CAAA,MAAOR,KAAO,EAI7CS,MALuCC,GAKvCD,CAAAA,CAAA,CADCE,CAAS,CAAA,CAAEC,UAAW,mBACQhB,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAiB,UAAA,mBAAA,CAAA,IAAA,EAAA,CAAA,CAkB/BJ,EAAA,CAfCE,CAAAA,CAAS,CACRC,SAAW,CAAA,cAAA,CACXE,UAAW,CACTC,aAAAA,CAAgBR,QAAhBQ,CAAAA,aAAAA,CAAgBR,CACd,CAAA,CAAA,GAAA,CAAKA,EAAO,MAAO,EAAA,CACnB,IACE,GAAMS,CAAAA,GAAAA,CAASC,KAAKC,KAAMX,CAAAA,CAAAA,CAAAA,CAC1B,MAAOY,CAAAA,KAAMC,CAAAA,OAAAA,CAAQJ,KACjBA,GAAOK,CAAAA,MAAAA,CAAOC,SAAAA,SAAKA,CAAAA,CAAsB,EAAA,QAAA,EAAA,MAAVA,CAAAA,EAAEhB,GAAuC,EAAA,QAAA,EAAA,MAAZgB,CAAAA,EAAEC,KAC9D,EAAA,CAAA,CAAA,EACL,EAAC,MAAAC,OAAA,CAAQ,CAAA,MAAO,EAAK,EAExBC,CAAAA,CAAAA,WAAAA,CAAcC,QAAdD,CAAAA,WAAAA,CAAcC,SAAqBT,CAAAA,IAAKU,CAAAA,SAAAA,CAAUD,UAAAA,WAAAA,EAAK,EAG1B9B,CAAAA,GAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAiB,UAAA,cAAA,CAAA,IAAA,EAAA,CAAA,CAvBtBjB,EAAmBa,CAAA,CAAA,CAD/BmB,EAAc,wBACFhC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA"}
1
+ {"version":3,"file":"nile-rte-mentions-item.cjs.js","sources":["../../../src/nile-rich-text-editor/nile-rte-mentions-item.ts"],"sourcesContent":["// nile-rte-mentions-item.ts\nimport { LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nexport type MentionItem = { key: string; label: string };\n\n@customElement('nile-rte-mentions-item')\nexport class NileRteMentionsItem extends LitElement {\n protected createRenderRoot() { return this; } // Light DOM\n\n /** Single-character trigger, e.g., '@' or '#' */\n @property({ attribute: 'mentionscharacter' })\n mentionsCharacter: string = '';\n\n \n @property({ attribute: 'mentionscolor' })\n mentionsColor: string = ''; // NEW\n\n /** JSON array of { key, label } */\n @property({\n attribute: 'mentionsdata',\n converter: {\n fromAttribute: (value: string | null): MentionItem[] => {\n if (!value) return [];\n try {\n const parsed = JSON.parse(value);\n return Array.isArray(parsed)\n ? parsed.filter(i => i && typeof i.key === 'string' && typeof i.label === 'string')\n : [];\n } catch { return []; }\n },\n toAttribute: (v: MentionItem[]) => JSON.stringify(v ?? []),\n }\n })\n mentionsData: MentionItem[] = [];\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-rte-mentions-item': NileRteMentionsItem;\n }\n}\n"],"names":["NileRteMentionsItem","_r","i","this","mentionsCharacter","mentionsColor","mentionsData","_this","_inherits","_createClass","key","value","createRenderRoot","__decorate","LitElement","property","attribute","prototype","converter","fromAttribute","parsed","JSON","parse","Array","isArray","filter","label","_unused","toAttribute","v","stringify","customElement"],"mappings":"gyFAOaA,CAAN,uBAAAC,EAAA,EAAA,SAAAC,EAAA,uEAKLC,KAAAA,CAAiBC,iBAAW,CAAA,EAAA,CAI5BD,KAAAA,CAAAE,aAAwB,CAAA,EAAA,CAkBxBF,KAAAA,CAAYG,YAAAA,CAAkB,EAC/B,QAAAC,KAAA,EA3BWC,SAAA,CAAAN,CAAA,CAAAD,EAAA,SAAAQ,YAAA,CAAAP,CAAA,GAAAQ,GAAA,oBAAAC,KAAA,UAAAC,gBAAAA,CAAAA,CAAqB,CAAA,MAAOT,KAAO,EAI7CU,MALuCC,CAAlC,EAKLD,CAAAA,CAAA,CADCE,CAAS,CAAA,CAAEC,SAAW,CAAA,mBAAA,CAAA,CAAA,CAAA,CACQhB,CAAAiB,CAAAA,SAAAA,CAAA,wBAAA,EAI/BJ,CAAAA,CAAAA,CAAAA,CAAA,CADCE,CAAAA,CAAS,CAAEC,SAAAA,CAAW,mBACIhB,CAAAiB,CAAAA,SAAAA,CAAA,eAAA,CAAA,IAAA,EAAA,CAAA,CAkB3BJ,CAAA,CAAA,CAfCE,EAAS,CACRC,SAAAA,CAAW,eACXE,SAAW,CAAA,CACTC,cAAgBR,QAAhBQ,CAAAA,cAAgBR,CACd,CAAA,CAAA,GAAA,CAAKA,CAAO,CAAA,MAAO,EACnB,CAAA,GAAA,CACE,GAAMS,CAAAA,GAASC,CAAAA,IAAAA,CAAKC,KAAMX,CAAAA,CAAAA,CAAAA,CAC1B,MAAOY,CAAAA,KAAAA,CAAMC,QAAQJ,GACjBA,CAAAA,CAAAA,GAAAA,CAAOK,MAAOvB,CAAAA,SAAAA,CAAAA,QAAKA,CAAAA,CAAsB,EAAA,QAAA,EAAA,MAAVA,CAAAA,EAAEQ,GAAuC,EAAA,QAAA,EAAA,MAAZR,CAAAA,EAAEwB,KAC9D,EAAA,CAAA,CAAA,EACL,EAAC,MAAAC,OAAA,CAAQ,CAAA,MAAO,EAAK,EAAA,CAAA,CAExBC,WAAcC,CAAAA,QAAdD,CAAAA,WAAcC,CAAAA,CAAAA,QAAqBR,CAAAA,KAAKS,SAAUD,CAAAA,CAAAA,SAAAA,CAAAA,UAAAA,CAAAA,CAAK,EAG1B7B,CAAAA,GAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAiB,SAAA,CAAA,cAAA,CAAA,IAAA,IA3BtBjB,CAAmBa,CAAAA,CAAAA,CAAA,CAD/BkB,CAAAA,CAAc,wBACF/B,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA"}
@@ -1 +1 @@
1
- import{__decorate as t}from"tslib";import{LitElement as r}from"lit";import{property as e,customElement as i}from"lit/decorators.js";let o=class extends r{constructor(){super(...arguments),this.mentionsCharacter="",this.mentionsData=[]}createRenderRoot(){return this}};t([e({attribute:"mentionscharacter"})],o.prototype,"mentionsCharacter",void 0),t([e({attribute:"mentionsdata",converter:{fromAttribute:t=>{if(!t)return[];try{const r=JSON.parse(t);return Array.isArray(r)?r.filter((t=>t&&"string"==typeof t.key&&"string"==typeof t.label)):[]}catch{return[]}},toAttribute:t=>JSON.stringify(t??[])}})],o.prototype,"mentionsData",void 0),o=t([i("nile-rte-mentions-item")],o);
1
+ import{__decorate as t}from"tslib";import{LitElement as r}from"lit";import{property as e,customElement as o}from"lit/decorators.js";let i=class extends r{constructor(){super(...arguments),this.mentionsCharacter="",this.mentionsColor="",this.mentionsData=[]}createRenderRoot(){return this}};t([e({attribute:"mentionscharacter"})],i.prototype,"mentionsCharacter",void 0),t([e({attribute:"mentionscolor"})],i.prototype,"mentionsColor",void 0),t([e({attribute:"mentionsdata",converter:{fromAttribute:t=>{if(!t)return[];try{const r=JSON.parse(t);return Array.isArray(r)?r.filter((t=>t&&"string"==typeof t.key&&"string"==typeof t.label)):[]}catch{return[]}},toAttribute:t=>JSON.stringify(t??[])}})],i.prototype,"mentionsData",void 0),i=t([o("nile-rte-mentions-item")],i);
@@ -1,3 +1,3 @@
1
- function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}System.register(["tslib","lit","lit/decorators.js"],function(_export,_context){"use strict";var t,i,s,n,e,h;function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0,F=function F(){};return{s:F,n:function(_n2){function n(){return _n2.apply(this,arguments);}n.toString=function(){return _n2.toString();};return n;}(function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]};}),e:function e(r){throw r;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e;}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t);}:p;}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value;}},_get.apply(null,arguments);}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t;}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_lit){i=_lit.LitElement;},function(_litDecoratorsJs){s=_litDecoratorsJs.property;n=_litDecoratorsJs.state;e=_litDecoratorsJs.customElement;}],execute:function execute(){h=/*#__PURE__*/function(_i){function h(){var _this;_classCallCheck(this,h);_this=_callSuper(this,h,arguments),_this.mentions={},_this.externalConfig={},_this.itemsConfig={},_this.editorEl=null,_this.hostEl=null,_this.dropdownEl=null,_this.menuEl=null,_this.lastRange=null,_this.mentionOpen=!1,_this.mentionTrigger=null,_this.mentionQuery="",_this.mentionSuggestions=[],_this.mentionFiltered=[],_this.mentionX=0,_this.mentionY=0,_this.triggerBtn=null,_this.mo=null,_this.onSelectionChange=function(){if(!_this.editorEl)return;var t=document.getSelection();if(!t||0===t.rangeCount)return;var i=t.getRangeAt(0);_this.editorEl.contains(i.commonAncestorContainer)&&(_this.lastRange=i.cloneRange());},_this.saveSelection=function(){var t=window.getSelection();t&&t.rangeCount&&(_this.lastRange=t.getRangeAt(0).cloneRange());},_this.onEditorInput=function(){_this.mentionOpen&&_this.handleMention();},_this.onEditorKeyUp=function(t){_this.saveSelection();var i=t.key,s=_this.config;!_this.mentionOpen&&i&&s[i]?_this.openMention(i):_this.mentionOpen&&_this.handleMention();},_this.onEditorKeyDown=function(t){if(!_this.mentionOpen)return;var i=t.key;"ArrowDown"===i||"ArrowUp"===i||"Enter"===i?(t.preventDefault(),"Enter"===i&&_this.mentionFiltered.length&&_this.selectMention(_this.mentionFiltered[0])):"Escape"===i&&(t.preventDefault(),_this.closeMention());},_this.repositionMention=function(){if(!_this.mentionOpen||!_this.hostEl||!_this.triggerBtn)return;var t=_this.getCaretClientRect();if(!t)return;var i=_this.hostEl.getBoundingClientRect();_this.mentionX=t.left-i.left,_this.mentionY=t.bottom-i.top,_this.triggerBtn.style.left="".concat(_this.mentionX,"px"),_this.triggerBtn.style.top="".concat(_this.mentionY,"px");};return _this;}_inherits(h,_i);return _createClass(h,[{key:"createRenderRoot",value:function createRenderRoot(){return this;}},{key:"config",get:function get(){return _objectSpread(_objectSpread(_objectSpread({},this.externalConfig),this.mentions),this.itemsConfig);}},{key:"attach",value:function attach(t,i){var _this2=this;this.editorEl=t,this.hostEl=i,this.injectStyles(),this.ensureMentionDropdown(),this.rebuildConfigFromChildren(),this.mo=new MutationObserver(function(){return _this2.rebuildConfigFromChildren();}),this.mo.observe(this,{childList:!0,subtree:!0,attributes:!0}),this.editorEl.addEventListener("input",this.onEditorInput),this.editorEl.addEventListener("mouseup",this.saveSelection),this.editorEl.addEventListener("keyup",this.onEditorKeyUp),this.editorEl.addEventListener("keydown",this.onEditorKeyDown),this.editorEl.addEventListener("scroll",this.repositionMention),document.addEventListener("selectionchange",this.onSelectionChange,!0);}},{key:"detach",value:function detach(){this.mo&&(this.mo.disconnect(),this.mo=null),this.editorEl&&(this.editorEl.removeEventListener("input",this.onEditorInput),this.editorEl.removeEventListener("mouseup",this.saveSelection),this.editorEl.removeEventListener("keyup",this.onEditorKeyUp),this.editorEl.removeEventListener("keydown",this.onEditorKeyDown),this.editorEl.removeEventListener("scroll",this.repositionMention)),document.removeEventListener("selectionchange",this.onSelectionChange,!0);}},{key:"setExternalConfig",value:function setExternalConfig(t){this.externalConfig=t||{};}},{key:"disconnectedCallback",value:function disconnectedCallback(){this.detach(),_superPropGet(h,"disconnectedCallback",this,3)([]);}},{key:"rebuildConfigFromChildren",value:function rebuildConfigFromChildren(){var t={},i=Array.from(this.querySelectorAll("nile-rte-mentions-item"));var _loop=function _loop(){var _ref,_s$mentionsCharacter,_s$mentionsData;var s=_i2[_i3];var i=(_ref=(_s$mentionsCharacter=s.mentionsCharacter)!==null&&_s$mentionsCharacter!==void 0?_s$mentionsCharacter:s.getAttribute("mentionscharacter"))!==null&&_ref!==void 0?_ref:"";if(!i||"string"!=typeof i)return 1;// continue
2
- var n=(_s$mentionsData=s.mentionsData)!==null&&_s$mentionsData!==void 0?_s$mentionsData:function(){var t=s.getAttribute("mentionsdata");if(!t)return null;try{var _i4=JSON.parse(t);return Array.isArray(_i4)?_i4.filter(function(t){return t&&"string"==typeof t.key&&"string"==typeof t.label;}):[];}catch(_unused){return[];}}();Array.isArray(n)||(n=[]),t[i]=n;};for(var _i3=0,_i2=i;_i3<_i2.length;_i3++){if(_loop())continue;}this.itemsConfig=t;}},{key:"injectStyles",value:function injectStyles(){if(this.querySelector("style[data-mentions-style]"))return;var t=document.createElement("style");t.setAttribute("data-mentions-style","true"),t.textContent="\n .mention-dropdown {\n position: absolute; z-index: 1000; list-style: none; margin: 0; padding: 4px;\n border: 1px solid #e5e7eb; border-radius: 6px; background: #fff;\n box-shadow: 0 4px 10px rgba(0,0,0,.08); max-height: 180px; overflow: auto; font-size: 14px;\n }\n .mention-dropdown li { padding: 6px 8px; cursor: pointer; border-radius: 4px; }\n .mention-dropdown li:hover { background: #f1f5f9; }\n .mention { background: #eef2ff; padding: 0 3px; border-radius: 3px; }\n ",this.insertBefore(t,this.firstChild);}},{key:"ensureMentionDropdown",value:function ensureMentionDropdown(){if(this.dropdownEl||!this.hostEl)return;var t=document.createElement("nile-dropdown");t.style.zIndex="1000";var i=document.createElement("nile-button");i.setAttribute("slot","trigger"),i.style.position="absolute",i.style.width="1px",i.style.height="1px",i.style.border="0",i.style.padding="0",i.style.opacity="0",i.style.pointerEvents="none",t.appendChild(i),this.triggerBtn=i;var s=document.createElement("nile-menu");t.appendChild(s),this.hostEl.appendChild(t),this.dropdownEl=t,this.menuEl=s;}},{key:"restoreSelection",value:function restoreSelection(){if(!this.lastRange)return;var t=document.getSelection();t&&(t.removeAllRanges(),t.addRange(this.lastRange));}},{key:"focusAndRestore",value:function focusAndRestore(){var _this$editorEl;(_this$editorEl=this.editorEl)!==null&&_this$editorEl!==void 0&&_this$editorEl.focus(),this.restoreSelection();}},{key:"getCaretClientRect",value:function getCaretClientRect(){var t=document.getSelection();if(!t||0===t.rangeCount)return null;var i=t.getRangeAt(0).cloneRange();i.collapse(!1);var s=i.getClientRects();if(s&&s.length>0)return s[0];var n=document.createElement("span");n.setAttribute("data-caret-marker","1"),n.textContent="​",i.insertNode(n);var e=n.getBoundingClientRect(),_h=document.createRange();return _h.setStartAfter(n),_h.collapse(!0),t.removeAllRanges(),t.addRange(_h),n.remove(),e||null;}},{key:"openMention",value:function openMention(t){if(this.saveSelection(),!this.editorEl||!this.dropdownEl||!this.hostEl)return;var i=this.getCaretClientRect();if(!i)return;var s=this.hostEl.getBoundingClientRect();this.mentionX=i.left-s.left,this.mentionY=i.bottom-s.top,this.mentionTrigger=t,this.mentionSuggestions=this.config[t]||[],this.mentionQuery="",this.updateMentionFiltered(),this.mentionOpen=!0,this.renderMentionList();}},{key:"closeMention",value:function closeMention(){var _this$dropdownEl;this.mentionOpen=!1,this.mentionTrigger=null,this.mentionQuery="",this.mentionFiltered=[],(_this$dropdownEl=this.dropdownEl)===null||_this$dropdownEl===void 0?void 0:_this$dropdownEl.removeAttribute("open");}},{key:"handleMention",value:function handleMention(){if(!this.mentionOpen||!this.mentionTrigger)return;var t=window.getSelection();if(!t||!t.anchorNode)return;var i=t.anchorNode;if(i.nodeType!==Node.TEXT_NODE){var _i$childNodes;var _s=((_i$childNodes=i.childNodes)===null||_i$childNodes===void 0?void 0:_i$childNodes[t.anchorOffset])||i.firstChild;(_s===null||_s===void 0?void 0:_s.nodeType)===Node.TEXT_NODE&&(i=_s);}var s=i&&i.nodeType===Node.TEXT_NODE&&i.textContent||"",n=s.lastIndexOf(this.mentionTrigger);n>=0?(this.mentionQuery=s.substring(n+1),this.updateMentionFiltered(),this.renderMentionList()):this.closeMention();}},{key:"updateMentionFiltered",value:function updateMentionFiltered(){var t=this.mentionQuery.toLowerCase();this.mentionFiltered=(this.mentionSuggestions||[]).filter(function(i){return i.label.toLowerCase().startsWith(t);});}},{key:"renderMentionList",value:function renderMentionList(){var _this3=this;if(this.dropdownEl&&this.menuEl&&this.triggerBtn)if(this.triggerBtn.style.position="absolute",this.triggerBtn.style.left="".concat(this.mentionX,"px"),this.triggerBtn.style.top="".concat(this.mentionY,"px"),this.menuEl.innerHTML="",this.mentionOpen&&this.mentionFiltered.length){var _iterator=_createForOfIteratorHelper(this.mentionFiltered),_step;try{var _loop2=function _loop2(){var t=_step.value;var i=document.createElement("nile-menu-item");i.textContent=t.label,i.addEventListener("mousedown",function(i){i.preventDefault(),_this3.selectMention(t);}),_this3.menuEl.appendChild(i);};for(_iterator.s();!(_step=_iterator.n()).done;){_loop2();}}catch(err){_iterator.e(err);}finally{_iterator.f();}this.dropdownEl.setAttribute("open","");}else this.dropdownEl.removeAttribute("open");}},{key:"selectMention",value:function selectMention(t){if(this.restoreSelection(),!this.lastRange||!this.mentionTrigger||!this.editorEl)return;var i=this.lastRange.startContainer,s=this.lastRange.startOffset;if(i.nodeType!==Node.TEXT_NODE){var _t=i.childNodes[s];if((_t===null||_t===void 0?void 0:_t.nodeType)!==Node.TEXT_NODE)return;i=_t,s=0;}var n=i,e=(n.textContent||"").lastIndexOf(this.mentionTrigger,s);if(e<0)return;var _h2=e+1+this.mentionQuery.length,o=document.createRange();o.setStart(n,e),o.setEnd(n,_h2),o.deleteContents();var r=document.createElement("span");r.classList.add("mention"),r.textContent="".concat(this.mentionTrigger).concat(t.label),o.insertNode(r);var u=document.createTextNode(" ");r.after(u);var c=window.getSelection(),l=document.createRange();l.setStartAfter(u),l.collapse(!0),c!==null&&c!==void 0&&c.removeAllRanges(),c!==null&&c!==void 0&&c.addRange(l),this.lastRange=l.cloneRange(),this.closeMention(),this.editorEl.dispatchEvent(new InputEvent("input",{bubbles:!0}));}}]);}(i);t([s({attribute:"mentions",converter:{fromAttribute:function fromAttribute(t){try{var _i5=JSON.parse(t),_s2={};for(var _i6=0,_Object$keys=Object.keys(_i5);_i6<_Object$keys.length;_i6++){var _t2=_Object$keys[_i6];var _n=_i5[_t2];Array.isArray(_n)&&(_s2[_t2]=_n.filter(function(t){return t&&"string"==typeof t.key&&"string"==typeof t.label;}).map(function(t){return{key:t.key,label:t.label};}));}return _s2;}catch(_unused2){return{};}},toAttribute:function toAttribute(t){return JSON.stringify(t);}}})],h.prototype,"mentions",void 0),t([n()],h.prototype,"externalConfig",void 0),t([n()],h.prototype,"itemsConfig",void 0),h=t([e("nile-rte-mentions")],h);}};});
1
+ System.register(["tslib","lit","lit/decorators.js"],function(_export,_context){"use strict";var t,i,s,n,e,o;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0,F=function F(){};return{s:F,n:function(_n2){function n(){return _n2.apply(this,arguments);}n.toString=function(){return _n2.toString();};return n;}(function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]};}),e:function e(r){throw r;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e;}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t);}:p;}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value;}},_get.apply(null,arguments);}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t;}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_lit){i=_lit.LitElement;},function(_litDecoratorsJs){s=_litDecoratorsJs.property;n=_litDecoratorsJs.state;e=_litDecoratorsJs.customElement;}],execute:function execute(){o=/*#__PURE__*/function(_i){function o(){var _this;_classCallCheck(this,o);_this=_callSuper(this,o,arguments),_this.mentions={},_this.mentionColors={},_this.externalConfig={},_this.itemsConfig={},_this.itemsColors={},_this.editorEl=null,_this.hostEl=null,_this.dropdownEl=null,_this.menuEl=null,_this.lastRange=null,_this.mentionOpen=!1,_this.mentionTrigger=null,_this.mentionQuery="",_this.mentionSuggestions=[],_this.mentionFiltered=[],_this.mentionX=0,_this.mentionY=0,_this.triggerBtn=null,_this.mo=null,_this.onSelectionChange=function(){if(!_this.editorEl)return;var t=document.getSelection();if(!t||0===t.rangeCount)return;var i=t.getRangeAt(0);_this.editorEl.contains(i.commonAncestorContainer)&&(_this.lastRange=i.cloneRange());},_this.saveSelection=function(){var t=window.getSelection();t&&t.rangeCount&&(_this.lastRange=t.getRangeAt(0).cloneRange());},_this.onEditorInput=function(){_this.mentionOpen&&_this.handleMention();},_this.onEditorKeyUp=function(t){_this.saveSelection();var i=t.key,s=_this.config;!_this.mentionOpen&&i&&s[i]?_this.openMention(i):_this.mentionOpen&&_this.handleMention();},_this.onEditorKeyDown=function(t){if(!_this.mentionOpen)return;var i=t.key;"ArrowDown"===i||"ArrowUp"===i||"Enter"===i?(t.preventDefault(),"Enter"===i&&_this.mentionFiltered.length&&_this.selectMention(_this.mentionFiltered[0])):"Escape"===i&&(t.preventDefault(),_this.closeMention());},_this.repositionMention=function(){if(!_this.mentionOpen||!_this.hostEl||!_this.triggerBtn)return;var t=_this.getCaretClientRect();if(!t)return;var i=_this.hostEl.getBoundingClientRect();_this.mentionX=t.left-i.left,_this.mentionY=t.bottom-i.top,_this.triggerBtn.style.left="".concat(_this.mentionX,"px"),_this.triggerBtn.style.top="".concat(_this.mentionY,"px");};return _this;}_inherits(o,_i);return _createClass(o,[{key:"createRenderRoot",value:function createRenderRoot(){return this;}},{key:"config",get:function get(){return _objectSpread(_objectSpread(_objectSpread({},this.externalConfig),this.mentions),this.itemsConfig);}},{key:"attach",value:function attach(t,i){var _this2=this;this.editorEl=t,this.hostEl=i,this.injectStyles(),this.ensureMentionDropdown(),this.rebuildConfigFromChildren(),this.mo=new MutationObserver(function(){return _this2.rebuildConfigFromChildren();}),this.mo.observe(this,{childList:!0,subtree:!0,attributes:!0}),this.editorEl.addEventListener("input",this.onEditorInput),this.editorEl.addEventListener("mouseup",this.saveSelection),this.editorEl.addEventListener("keyup",this.onEditorKeyUp),this.editorEl.addEventListener("keydown",this.onEditorKeyDown),this.editorEl.addEventListener("scroll",this.repositionMention),document.addEventListener("selectionchange",this.onSelectionChange,!0);}},{key:"detach",value:function detach(){this.mo&&(this.mo.disconnect(),this.mo=null),this.editorEl&&(this.editorEl.removeEventListener("input",this.onEditorInput),this.editorEl.removeEventListener("mouseup",this.saveSelection),this.editorEl.removeEventListener("keyup",this.onEditorKeyUp),this.editorEl.removeEventListener("keydown",this.onEditorKeyDown),this.editorEl.removeEventListener("scroll",this.repositionMention)),document.removeEventListener("selectionchange",this.onSelectionChange,!0);}},{key:"setExternalConfig",value:function setExternalConfig(t){this.externalConfig=t||{};}},{key:"disconnectedCallback",value:function disconnectedCallback(){this.detach(),_superPropGet(o,"disconnectedCallback",this,3)([]);}},{key:"rebuildConfigFromChildren",value:function rebuildConfigFromChildren(){var t={},i={},s=Array.from(this.querySelectorAll("nile-rte-mentions-item"));var _loop=function _loop(){var _ref,_n$mentionsCharacter,_n$mentionsData,_ref2,_n$mentionsColor;var n=_s[_i2];var s=(_ref=(_n$mentionsCharacter=n.mentionsCharacter)!==null&&_n$mentionsCharacter!==void 0?_n$mentionsCharacter:n.getAttribute("mentionscharacter"))!==null&&_ref!==void 0?_ref:"";if(!s||"string"!=typeof s)return 1;// continue
2
+ var e=(_n$mentionsData=n.mentionsData)!==null&&_n$mentionsData!==void 0?_n$mentionsData:function(){var t=n.getAttribute("mentionsdata");if(!t)return null;try{var _i3=JSON.parse(t);return Array.isArray(_i3)?_i3.filter(function(t){return t&&"string"==typeof t.key&&"string"==typeof t.label;}):[];}catch(_unused){return[];}}();var _o=(_ref2=(_n$mentionsColor=n.mentionsColor)!==null&&_n$mentionsColor!==void 0?_n$mentionsColor:n.getAttribute("mentionscolor"))!==null&&_ref2!==void 0?_ref2:"";Array.isArray(e)||(e=[]),t[s]=e,_o&&(i[s]=String(_o));};for(var _i2=0,_s=s;_i2<_s.length;_i2++){if(_loop())continue;}this.itemsConfig=t,this.itemsColors=i;}},{key:"injectStyles",value:function injectStyles(){if(this.querySelector("style[data-mentions-style]"))return;var t=document.createElement("style");t.setAttribute("data-mentions-style","true"),t.textContent="\n .mention-dropdown {\n position: absolute; z-index: 1000; list-style: none; margin: 0; padding: 4px;\n border: 1px solid #e5e7eb; border-radius: 6px; background: #fff;\n box-shadow: 0 4px 10px rgba(0,0,0,.08); max-height: 180px; overflow: auto; font-size: 14px;\n }\n .mention-dropdown li { padding: 6px 8px; cursor: pointer; border-radius: 4px; }\n .mention-dropdown li:hover { background: #f1f5f9; }\n .mention { background: #eef2ff; padding: 0 3px; border-radius: 3px; }\n ",this.insertBefore(t,this.firstChild);}},{key:"getTriggerColor",value:function getTriggerColor(t){var _this$itemsColors$t;return(_this$itemsColors$t=this.itemsColors[t])!==null&&_this$itemsColors$t!==void 0?_this$itemsColors$t:this.mentionColors[t];}},{key:"ensureMentionDropdown",value:function ensureMentionDropdown(){if(this.dropdownEl||!this.hostEl)return;var t=document.createElement("nile-dropdown");t.style.zIndex="1000";var i=document.createElement("nile-button");i.setAttribute("slot","trigger"),i.style.position="absolute",i.style.width="1px",i.style.height="1px",i.style.border="0",i.style.padding="0",i.style.opacity="0",i.style.pointerEvents="none",t.appendChild(i),this.triggerBtn=i;var s=document.createElement("nile-menu");t.appendChild(s),this.hostEl.appendChild(t),this.dropdownEl=t,this.menuEl=s;}},{key:"restoreSelection",value:function restoreSelection(){if(!this.lastRange)return;var t=document.getSelection();t&&(t.removeAllRanges(),t.addRange(this.lastRange));}},{key:"focusAndRestore",value:function focusAndRestore(){var _this$editorEl;(_this$editorEl=this.editorEl)!==null&&_this$editorEl!==void 0&&_this$editorEl.focus(),this.restoreSelection();}},{key:"getCaretClientRect",value:function getCaretClientRect(){var t=document.getSelection();if(!t||0===t.rangeCount)return null;var i=t.getRangeAt(0).cloneRange();i.collapse(!1);var s=i.getClientRects();if(s&&s.length>0)return s[0];var n=document.createElement("span");n.setAttribute("data-caret-marker","1"),n.textContent="​",i.insertNode(n);var e=n.getBoundingClientRect(),_o2=document.createRange();return _o2.setStartAfter(n),_o2.collapse(!0),t.removeAllRanges(),t.addRange(_o2),n.remove(),e||null;}},{key:"openMention",value:function openMention(t){if(this.saveSelection(),!this.editorEl||!this.dropdownEl||!this.hostEl)return;var i=this.getCaretClientRect();if(!i)return;var s=this.hostEl.getBoundingClientRect();this.mentionX=i.left-s.left,this.mentionY=i.bottom-s.top,this.mentionTrigger=t,this.mentionSuggestions=this.config[t]||[],this.mentionQuery="",this.updateMentionFiltered(),this.mentionOpen=!0,this.renderMentionList();}},{key:"closeMention",value:function closeMention(){var _this$dropdownEl;this.mentionOpen=!1,this.mentionTrigger=null,this.mentionQuery="",this.mentionFiltered=[],(_this$dropdownEl=this.dropdownEl)===null||_this$dropdownEl===void 0?void 0:_this$dropdownEl.removeAttribute("open");}},{key:"handleMention",value:function handleMention(){if(!this.mentionOpen||!this.mentionTrigger)return;var t=window.getSelection();if(!t||!t.anchorNode)return;var i=t.anchorNode;if(i.nodeType!==Node.TEXT_NODE){var _i$childNodes;var _s2=((_i$childNodes=i.childNodes)===null||_i$childNodes===void 0?void 0:_i$childNodes[t.anchorOffset])||i.firstChild;(_s2===null||_s2===void 0?void 0:_s2.nodeType)===Node.TEXT_NODE&&(i=_s2);}var s=i&&i.nodeType===Node.TEXT_NODE&&i.textContent||"",n=s.lastIndexOf(this.mentionTrigger);n>=0?(this.mentionQuery=s.substring(n+1),this.updateMentionFiltered(),this.renderMentionList()):this.closeMention();}},{key:"updateMentionFiltered",value:function updateMentionFiltered(){var t=this.mentionQuery.toLowerCase();this.mentionFiltered=(this.mentionSuggestions||[]).filter(function(i){return i.label.toLowerCase().startsWith(t);});}},{key:"renderMentionList",value:function renderMentionList(){var _this3=this;if(this.dropdownEl&&this.menuEl&&this.triggerBtn)if(this.triggerBtn.style.position="absolute",this.triggerBtn.style.left="".concat(this.mentionX,"px"),this.triggerBtn.style.top="".concat(this.mentionY,"px"),this.menuEl.innerHTML="",this.mentionOpen&&this.mentionFiltered.length){var _iterator=_createForOfIteratorHelper(this.mentionFiltered),_step;try{var _loop2=function _loop2(){var t=_step.value;var i=document.createElement("nile-menu-item");i.textContent=t.label,i.addEventListener("mousedown",function(i){i.preventDefault(),_this3.selectMention(t);}),_this3.menuEl.appendChild(i);};for(_iterator.s();!(_step=_iterator.n()).done;){_loop2();}}catch(err){_iterator.e(err);}finally{_iterator.f();}this.dropdownEl.setAttribute("open","");}else this.dropdownEl.removeAttribute("open");}},{key:"selectMention",value:function selectMention(t){if(this.restoreSelection(),!this.lastRange||!this.mentionTrigger||!this.editorEl)return;var i=this.lastRange.startContainer,s=this.lastRange.startOffset;if(i.nodeType!==Node.TEXT_NODE){var _t=i.childNodes[s];if((_t===null||_t===void 0?void 0:_t.nodeType)!==Node.TEXT_NODE)return;i=_t,s=0;}var n=i,e=(n.textContent||"").lastIndexOf(this.mentionTrigger,s);if(e<0)return;var _o3=e+1+this.mentionQuery.length,h=document.createRange();h.setStart(n,e),h.setEnd(n,_o3),h.deleteContents();var r=document.createElement("span");r.classList.add("mention"),r.textContent="".concat(this.mentionTrigger).concat(t.label);var c=this.getTriggerColor(this.mentionTrigger);c&&(r.style.backgroundColor=c),h.insertNode(r);var u=document.createTextNode(" ");r.after(u);var l=window.getSelection(),d=document.createRange();d.setStartAfter(u),d.collapse(!0),l!==null&&l!==void 0&&l.removeAllRanges(),l!==null&&l!==void 0&&l.addRange(d),this.lastRange=d.cloneRange(),this.closeMention(),this.editorEl.dispatchEvent(new InputEvent("input",{bubbles:!0}));}}]);}(i);t([s({attribute:"mentions",converter:{fromAttribute:function fromAttribute(t){try{var _i4=JSON.parse(t),_s3={};for(var _i5=0,_Object$keys=Object.keys(_i4);_i5<_Object$keys.length;_i5++){var _t2=_Object$keys[_i5];var _n=_i4[_t2];Array.isArray(_n)&&(_s3[_t2]=_n.filter(function(t){return t&&"string"==typeof t.key&&"string"==typeof t.label;}).map(function(t){return{key:t.key,label:t.label};}));}return _s3;}catch(_unused2){return{};}},toAttribute:function toAttribute(t){return JSON.stringify(t);}}})],o.prototype,"mentions",void 0),t([s({attribute:"mentioncolors",converter:{fromAttribute:function fromAttribute(t){try{var _i6=JSON.parse(t);return _i6&&"object"==_typeof(_i6)?_i6:{};}catch(_unused3){return{};}},toAttribute:function toAttribute(t){return JSON.stringify(t!==null&&t!==void 0?t:{});}}})],o.prototype,"mentionColors",void 0),t([n()],o.prototype,"externalConfig",void 0),t([n()],o.prototype,"itemsConfig",void 0),t([n()],o.prototype,"itemsColors",void 0),o=t([e("nile-rte-mentions")],o);}};});
3
3
  //# sourceMappingURL=nile-rte-mentions.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nile-rte-mentions.cjs.js","sources":["../../../src/nile-rich-text-editor/nile-rte-mentions.ts"],"sourcesContent":["import { LitElement } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport type { MentionItem } from './nile-rte-mentions-item';\n\ntype MentionsConfig = Record<string, MentionItem[]>;\n\n@customElement('nile-rte-mentions')\nexport class NileRteMentions extends LitElement {\n protected createRenderRoot() { return this; } \n\n \n @property({\n attribute: 'mentions',\n converter: {\n fromAttribute: (value: string): MentionsConfig => {\n try {\n const parsed = JSON.parse(value);\n const out: MentionsConfig = {};\n for (const trig of Object.keys(parsed)) {\n const arr = parsed[trig];\n if (Array.isArray(arr)) {\n out[trig] = arr\n .filter(i => i && typeof i.key === 'string' && typeof i.label === 'string')\n .map(i => ({ key: i.key, label: i.label }));\n }\n }\n return out;\n } catch { return {}; }\n },\n toAttribute: (v: MentionsConfig) => JSON.stringify(v),\n }\n })\n mentions: MentionsConfig = {};\n\n /** External config from the editor (lowest priority) */\n @state() private externalConfig: MentionsConfig = {};\n\n /** Config gathered from child <nile-rte-mentions-item> (highest priority) */\n @state() private itemsConfig: MentionsConfig = {};\n\n private get config(): MentionsConfig {\n // Priority: external < attribute < child-items\n return { ...this.externalConfig, ...this.mentions, ...this.itemsConfig };\n }\n\n // wired from editor\n private editorEl: HTMLElement | null = null;\n private hostEl: HTMLElement | null = null;\n\n // dropdown & menu elements we’ll create once and reuse\nprivate dropdownEl: HTMLElement | null = null; // <nile-dropdown>\nprivate menuEl: HTMLElement | null = null; // <nile-menu>\n\n\n // selection caret\n private lastRange: Range | null = null;\n\n // dropdown state\n private mentionOpen = false;\n private mentionTrigger: string | null = null;\n private mentionQuery = '';\n private mentionSuggestions: MentionItem[] = [];\n private mentionFiltered: MentionItem[] = [];\n private mentionX = 0;\n private mentionY = 0;\nprivate triggerBtn: HTMLElement | null = null;\n\n \n\n // Observe child items & their attributes\n private mo: MutationObserver | null = null;\n\n // Public API used by <nile-rich-text-editor>\n attach(editorEl: HTMLElement, hostEl: HTMLElement) {\n this.editorEl = editorEl;\n this.hostEl = hostEl;\n\n this.injectStyles();\n this.ensureMentionDropdown();\n this.rebuildConfigFromChildren();\n\n // Watch for <nile-rte-mentions-item> add/remove/attr changes\n this.mo = new MutationObserver(() => this.rebuildConfigFromChildren());\n this.mo.observe(this, { childList: true, subtree: true, attributes: true });\n\n // listeners on editor\n this.editorEl.addEventListener('input', this.onEditorInput);\n this.editorEl.addEventListener('mouseup', this.saveSelection);\n this.editorEl.addEventListener('keyup', this.onEditorKeyUp);\n this.editorEl.addEventListener('keydown', this.onEditorKeyDown);\n this.editorEl.addEventListener('scroll', this.repositionMention);\n\n // keep range fresh\n document.addEventListener('selectionchange', this.onSelectionChange, true);\n }\n\n detach() {\n if (this.mo) { this.mo.disconnect(); this.mo = null; }\n if (this.editorEl) {\n this.editorEl.removeEventListener('input', this.onEditorInput);\n this.editorEl.removeEventListener('mouseup', this.saveSelection);\n this.editorEl.removeEventListener('keyup', this.onEditorKeyUp);\n this.editorEl.removeEventListener('keydown', this.onEditorKeyDown);\n this.editorEl.removeEventListener('scroll', this.repositionMention);\n }\n document.removeEventListener('selectionchange', this.onSelectionChange, true);\n }\n\n setExternalConfig(cfg: MentionsConfig) {\n this.externalConfig = cfg || {};\n }\n\n disconnectedCallback(): void {\n this.detach();\n super.disconnectedCallback();\n }\n\n // ---------- gather child items ----------\n private rebuildConfigFromChildren() {\n const cfg: MentionsConfig = {};\n const items = Array.from(this.querySelectorAll('nile-rte-mentions-item')) as Array<\n HTMLElement & { mentionsCharacter?: string; mentionsData?: MentionItem[] }\n >;\n\n for (const item of items) {\n // read live properties first (if Lit already upgraded), else read attributes\n const trig =\n (item as any).mentionsCharacter ??\n item.getAttribute('mentionscharacter') ??\n '';\n\n if (!trig || typeof trig !== 'string') continue;\n\n let data: MentionItem[] | null =\n (item as any).mentionsData ??\n (() => {\n const raw = item.getAttribute('mentionsdata');\n if (!raw) return null;\n try {\n const parsed = JSON.parse(raw);\n return Array.isArray(parsed)\n ? parsed.filter(i => i && typeof i.key === 'string' && typeof i.label === 'string')\n : [];\n } catch { return []; }\n })();\n\n if (!Array.isArray(data)) data = [];\n cfg[trig] = data;\n }\n this.itemsConfig = cfg;\n }\n\n // ---------- styles ----------\n private injectStyles() {\n if (this.querySelector('style[data-mentions-style]')) return;\n const style = document.createElement('style');\n style.setAttribute('data-mentions-style', 'true');\n style.textContent = `\n .mention-dropdown {\n position: absolute; z-index: 1000; list-style: none; margin: 0; padding: 4px;\n border: 1px solid #e5e7eb; border-radius: 6px; background: #fff;\n box-shadow: 0 4px 10px rgba(0,0,0,.08); max-height: 180px; overflow: auto; font-size: 14px;\n }\n .mention-dropdown li { padding: 6px 8px; cursor: pointer; border-radius: 4px; }\n .mention-dropdown li:hover { background: #f1f5f9; }\n .mention { background: #eef2ff; padding: 0 3px; border-radius: 3px; }\n `;\n this.insertBefore(style, this.firstChild);\n }\n\n \nprivate ensureMentionDropdown() {\n if (this.dropdownEl || !this.hostEl) return;\n\n const dd = document.createElement('nile-dropdown');\n dd.style.zIndex = '1000';\n\n const btn = document.createElement('nile-button'); // invisible trigger\n btn.setAttribute('slot', 'trigger');\n btn.style.position = 'absolute'; \n btn.style.width = '1px';\n btn.style.height = '1px';\n btn.style.border = '0';\n btn.style.padding = '0';\n btn.style.opacity = '0'; \n btn.style.pointerEvents = 'none'; \n dd.appendChild(btn);\n this.triggerBtn = btn; \n const menu = document.createElement('nile-menu');\n dd.appendChild(menu);\n\n this.hostEl.appendChild(dd);\n this.dropdownEl = dd;\n this.menuEl = menu;\n}\n\n // ---------- selection helpers ----------\n private onSelectionChange = () => {\n if (!this.editorEl) return;\n const sel = document.getSelection();\n if (!sel || sel.rangeCount === 0) return;\n const range = sel.getRangeAt(0);\n if (this.editorEl.contains(range.commonAncestorContainer)) {\n this.lastRange = range.cloneRange();\n }\n };\n private saveSelection = () => {\n const sel = window.getSelection();\n if (sel && sel.rangeCount) this.lastRange = sel.getRangeAt(0).cloneRange();\n };\n private restoreSelection() {\n if (!this.lastRange) return;\n const sel = document.getSelection(); if (!sel) return;\n sel.removeAllRanges(); sel.addRange(this.lastRange);\n }\n private focusAndRestore() { this.editorEl?.focus(); this.restoreSelection(); }\n\n private getCaretClientRect(): DOMRect | null {\n const sel = document.getSelection();\n if (!sel || sel.rangeCount === 0) return null;\n\n const range = sel.getRangeAt(0).cloneRange();\n range.collapse(false);\n\n const rects = range.getClientRects();\n if (rects && rects.length > 0) return rects[0];\n\n const marker = document.createElement('span');\n marker.setAttribute('data-caret-marker', '1');\n marker.textContent = '\\u200B';\n range.insertNode(marker);\n\n const rect = marker.getBoundingClientRect();\n\n const after = document.createRange();\n after.setStartAfter(marker);\n after.collapse(true);\n sel.removeAllRanges();\n sel.addRange(after);\n marker.remove();\n\n return rect || null;\n }\n\n // ---------- editor events ----------\n private onEditorInput = () => {\n if (this.mentionOpen) this.handleMention();\n };\n\n private onEditorKeyUp = (e: KeyboardEvent) => {\n this.saveSelection();\n const key = e.key;\n const cfg = this.config;\n if (!this.mentionOpen && key && cfg[key]) {\n this.openMention(key);\n return;\n }\n if (this.mentionOpen) this.handleMention();\n };\n\n private onEditorKeyDown = (e: KeyboardEvent) => {\n if (!this.mentionOpen) return;\n const key = e.key;\n if (key === 'ArrowDown' || key === 'ArrowUp' || key === 'Enter') {\n e.preventDefault();\n if (key === 'Enter' && this.mentionFiltered.length) {\n this.selectMention(this.mentionFiltered[0]);\n }\n } else if (key === 'Escape') {\n e.preventDefault();\n this.closeMention();\n }\n };\n\n // ---------- mentions flow ----------\n private openMention(trigger: string) {\n this.saveSelection();\n if (!this.editorEl || !this.dropdownEl || !this.hostEl) return;\n\n const caretRect = this.getCaretClientRect();\n if (!caretRect) return;\n\n const hostRect = this.hostEl.getBoundingClientRect();\n\n this.mentionX = caretRect.left - hostRect.left;\n this.mentionY = caretRect.bottom - hostRect.top;\n\n this.mentionTrigger = trigger;\n this.mentionSuggestions = this.config[trigger] || [];\n this.mentionQuery = '';\n this.updateMentionFiltered();\n\n this.mentionOpen = true;\n this.renderMentionList();\n }\n\n private closeMention() {\n this.mentionOpen = false;\n this.mentionTrigger = null;\n this.mentionQuery = '';\n this.mentionFiltered = [];\n // hide dropdown\n this.dropdownEl?.removeAttribute('open');\n }\n\n private handleMention() {\n if (!this.mentionOpen || !this.mentionTrigger) return;\n const sel = window.getSelection(); if (!sel || !sel.anchorNode) return;\n\n let node: Node | null = sel.anchorNode;\n if (node.nodeType !== Node.TEXT_NODE) {\n const c = (node as HTMLElement).childNodes?.[sel.anchorOffset] || node.firstChild;\n if (c?.nodeType === Node.TEXT_NODE) node = c;\n }\n const text = (node && node.nodeType === Node.TEXT_NODE) ? (node.textContent || '') : '';\n const idx = text.lastIndexOf(this.mentionTrigger);\n if (idx >= 0) {\n this.mentionQuery = text.substring(idx + 1);\n this.updateMentionFiltered();\n this.renderMentionList();\n } else {\n this.closeMention();\n }\n }\n\n private updateMentionFiltered() {\n const q = this.mentionQuery.toLowerCase();\n this.mentionFiltered = (this.mentionSuggestions || []).filter(item =>\n item.label.toLowerCase().startsWith(q)\n );\n }\n\n private renderMentionList() {\n if (!this.dropdownEl || !this.menuEl) return;\n \n if (!this.triggerBtn) return;\n this.triggerBtn.style.position = 'absolute';\n this.triggerBtn.style.left = `${this.mentionX}px`;\n this.triggerBtn.style.top = `${this.mentionY}px`;\n \n \n // clear old items\n this.menuEl.innerHTML = '';\n \n if (!this.mentionOpen || !this.mentionFiltered.length) {\n this.dropdownEl.removeAttribute('open');\n return;\n }\n \n // build menu items\n for (const item of this.mentionFiltered) {\n const mi = document.createElement('nile-menu-item');\n mi.textContent = item.label;\n mi.addEventListener('mousedown', (e) => {\n e.preventDefault();\n this.selectMention(item);\n });\n this.menuEl.appendChild(mi);\n }\n \n // show dropdown\n this.dropdownEl.setAttribute('open', '');\n }\n \n\n private repositionMention = () => {\n if (!this.mentionOpen || !this.hostEl || !this.triggerBtn) return;\n\n const caretRect = this.getCaretClientRect();\n if (!caretRect) return;\n\n const hostRect = this.hostEl.getBoundingClientRect();\n\n this.mentionX = caretRect.left - hostRect.left;\n this.mentionY = caretRect.bottom - hostRect.top;\n\n this.triggerBtn.style.left = `${this.mentionX}px`;\n this.triggerBtn.style.top = `${this.mentionY}px`;\n };\n\n private selectMention(item: MentionItem) {\n this.restoreSelection(); if (!this.lastRange || !this.mentionTrigger || !this.editorEl) return;\n\n let node: Node = this.lastRange.startContainer;\n let offset = this.lastRange.startOffset;\n if (node.nodeType !== Node.TEXT_NODE) {\n const child = node.childNodes[offset];\n if (child?.nodeType === Node.TEXT_NODE) { node = child; offset = 0; } else return;\n }\n const textNode = node as Text;\n const text = textNode.textContent || '';\n const atIndex = text.lastIndexOf(this.mentionTrigger, offset);\n if (atIndex < 0) return;\n\n const endIndex = atIndex + 1 + this.mentionQuery.length;\n const mentionRange = document.createRange();\n mentionRange.setStart(textNode, atIndex);\n mentionRange.setEnd(textNode, endIndex);\n mentionRange.deleteContents();\n\n const span = document.createElement('span');\n span.classList.add('mention');\n span.textContent = `${this.mentionTrigger}${item.label}`;\n mentionRange.insertNode(span);\n\n const spaceNode = document.createTextNode('\\u00A0');\n span.after(spaceNode);\n\n const sel = window.getSelection();\n const afterRange = document.createRange();\n afterRange.setStartAfter(spaceNode); afterRange.collapse(true);\n sel?.removeAllRanges(); sel?.addRange(afterRange);\n this.lastRange = afterRange.cloneRange();\n\n this.closeMention();\n\n // bubble an input event so the editor updates preview/state\n this.editorEl.dispatchEvent(new InputEvent('input', { bubbles: true }));\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-rte-mentions': NileRteMentions;\n }\n}\n"],"names":["NileRteMentions","h","constructor","this","mentions","externalConfig","itemsConfig","editorEl","hostEl","dropdownEl","menuEl","lastRange","mentionOpen","mentionTrigger","mentionQuery","mentionSuggestions","mentionFiltered","mentionX","mentionY","triggerBtn","mo","onSelectionChange","sel","document","getSelection","rangeCount","range","getRangeAt","contains","commonAncestorContainer","cloneRange","saveSelection","window","onEditorInput","handleMention","onEditorKeyUp","e","key","cfg","config","openMention","onEditorKeyDown","preventDefault","length","selectMention","closeMention","repositionMention","caretRect","getCaretClientRect","hostRect","getBoundingClientRect","left","bottom","top","style","_this","_inherits","_i","_createClass","value","createRenderRoot","get","_objectSpread","attach","injectStyles","ensureMentionDropdown","rebuildConfigFromChildren","MutationObserver","observe","childList","subtree","attributes","addEventListener","detach","disconnect","removeEventListener","setExternalConfig","disconnectedCallback","items","Array","from","querySelectorAll","_loop","_ref","_s$mentionsCharacter","_s$mentionsData","item","trig","mentionsCharacter","getAttribute","data","mentionsData","raw","parsed","JSON","parse","isArray","filter","i","label","_unused","_i3","_i2","querySelector","createElement","setAttribute","textContent","insertBefore","firstChild","dd","zIndex","btn","position","width","height","border","padding","opacity","pointerEvents","appendChild","menu","restoreSelection","removeAllRanges","addRange","focusAndRestore","focus","collapse","rects","getClientRects","marker","insertNode","rect","after","createRange","setStartAfter","remove","trigger","updateMentionFiltered","renderMentionList","removeAttribute","anchorNode","node","nodeType","Node","TEXT_NODE","_i$childNodes","c","childNodes","anchorOffset","text","idx","lastIndexOf","substring","q","toLowerCase","startsWith","_this3","innerHTML","_iterator","_createForOfIteratorHelper","mi","s","_step","n","done","_loop2","startContainer","offset","startOffset","child","textNode","atIndex","endIndex","mentionRange","setStart","setEnd","deleteContents","span","classList","add","concat","spaceNode","createTextNode","afterRange","dispatchEvent","InputEvent","bubbles","__decorate","LitElement","property","attribute","converter","fromAttribute","out","_i6","_Object$keys","Object","keys","arr","map","_unused2","toAttribute","v","stringify","prototype","state","customElement"],"mappings":"u1KAOaA,CAAAA,uBAAAA,EAAAA,EAAN,SAAAC,EAAA,CAAAC,KAAAA,KAAAA,CAAAA,eAAAA,MAAAA,CAAAA,mCAyBLC,EAAAA,KAAAA,CAAQC,QAAmB,CAAA,EAGVD,CAAAA,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,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA"}
1
+ {"version":3,"file":"nile-rte-mentions.cjs.js","sources":["../../../src/nile-rich-text-editor/nile-rte-mentions.ts"],"sourcesContent":["import { LitElement } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport type { MentionItem } from './nile-rte-mentions-item';\n\ntype MentionsConfig = Record<string, MentionItem[]>;\n\n@customElement('nile-rte-mentions')\nexport class NileRteMentions extends LitElement {\n protected createRenderRoot() { return this; } \n\n \n @property({\n attribute: 'mentions',\n converter: {\n fromAttribute: (value: string): MentionsConfig => {\n try {\n const parsed = JSON.parse(value);\n const out: MentionsConfig = {};\n for (const trig of Object.keys(parsed)) {\n const arr = parsed[trig];\n if (Array.isArray(arr)) {\n out[trig] = arr\n .filter(i => i && typeof i.key === 'string' && typeof i.label === 'string')\n .map(i => ({ key: i.key, label: i.label }));\n }\n }\n return out;\n } catch { return {}; }\n },\n toAttribute: (v: MentionsConfig) => JSON.stringify(v),\n }\n })\n mentions: MentionsConfig = {};\n\n @property({\n attribute: 'mentioncolors',\n converter: {\n fromAttribute: (value: string): Record<string,string> => {\n try { const o = JSON.parse(value); return (o && typeof o === 'object') ? o : {}; }\n catch { return {}; }\n },\n toAttribute: (v: Record<string,string>) => JSON.stringify(v ?? {})\n }\n })\n mentionColors: Record<string, string> = {}; // NEW\n\n /** External config from the editor (lowest priority) */\n @state() private externalConfig: MentionsConfig = {};\n\n /** Config gathered from child <nile-rte-mentions-item> (highest priority) */\n @state() private itemsConfig: MentionsConfig = {};\n\n @state() private itemsColors: Record<string,string> = {}; // NEW\n\n private get config(): MentionsConfig {\n // Priority: external < attribute < child-items\n return { ...this.externalConfig, ...this.mentions, ...this.itemsConfig };\n }\n\n // wired from editor\n private editorEl: HTMLElement | null = null;\n private hostEl: HTMLElement | null = null;\n\n \nprivate dropdownEl: HTMLElement | null = null; // <nile-dropdown>\nprivate menuEl: HTMLElement | null = null; // <nile-menu>\n\n\n // selection caret\n private lastRange: Range | null = null;\n\n // dropdown state\n private mentionOpen = false;\n private mentionTrigger: string | null = null;\n private mentionQuery = '';\n private mentionSuggestions: MentionItem[] = [];\n private mentionFiltered: MentionItem[] = [];\n private mentionX = 0;\n private mentionY = 0;\nprivate triggerBtn: HTMLElement | null = null;\n\n \n\n // Observe child items & their attributes\n private mo: MutationObserver | null = null;\n\n // Public API used by <nile-rich-text-editor>\n attach(editorEl: HTMLElement, hostEl: HTMLElement) {\n this.editorEl = editorEl;\n this.hostEl = hostEl;\n\n this.injectStyles();\n this.ensureMentionDropdown();\n this.rebuildConfigFromChildren();\n\n // Watch for <nile-rte-mentions-item> add/remove/attr changes\n this.mo = new MutationObserver(() => this.rebuildConfigFromChildren());\n this.mo.observe(this, { childList: true, subtree: true, attributes: true });\n\n // listeners on editor\n this.editorEl.addEventListener('input', this.onEditorInput);\n this.editorEl.addEventListener('mouseup', this.saveSelection);\n this.editorEl.addEventListener('keyup', this.onEditorKeyUp);\n this.editorEl.addEventListener('keydown', this.onEditorKeyDown);\n this.editorEl.addEventListener('scroll', this.repositionMention);\n\n // keep range fresh\n document.addEventListener('selectionchange', this.onSelectionChange, true);\n }\n\n detach() {\n if (this.mo) { this.mo.disconnect(); this.mo = null; }\n if (this.editorEl) {\n this.editorEl.removeEventListener('input', this.onEditorInput);\n this.editorEl.removeEventListener('mouseup', this.saveSelection);\n this.editorEl.removeEventListener('keyup', this.onEditorKeyUp);\n this.editorEl.removeEventListener('keydown', this.onEditorKeyDown);\n this.editorEl.removeEventListener('scroll', this.repositionMention);\n }\n document.removeEventListener('selectionchange', this.onSelectionChange, true);\n }\n\n setExternalConfig(cfg: MentionsConfig) {\n this.externalConfig = cfg || {};\n }\n\n disconnectedCallback(): void {\n this.detach();\n super.disconnectedCallback();\n }\n\n // ---------- gather child items ----------\n private rebuildConfigFromChildren() {\n const cfg: MentionsConfig = {};\n const colors: Record<string,string> = {}; // NEW\n\n const items = Array.from(this.querySelectorAll('nile-rte-mentions-item')) as Array<\n HTMLElement & { mentionsCharacter?: string; mentionsData?: MentionItem[]; mentionsColor?: string }\n >;\n\n for (const item of items) {\n const trig =\n (item as any).mentionsCharacter ??\n item.getAttribute('mentionscharacter') ??\n '';\n\n if (!trig || typeof trig !== 'string') continue;\n\n let data: MentionItem[] | null =\n (item as any).mentionsData ??\n (() => {\n const raw = item.getAttribute('mentionsdata');\n if (!raw) return null;\n try {\n const parsed = JSON.parse(raw);\n return Array.isArray(parsed)\n ? parsed.filter(i => i && typeof i.key === 'string' && typeof i.label === 'string')\n : [];\n } catch { return []; }\n })();\n\n const color =\n (item as any).mentionsColor ??\n item.getAttribute('mentionscolor') ??\n '';\n\n if (!Array.isArray(data)) data = [];\n cfg[trig] = data;\n if (color) colors[trig] = String(color); // record color if provided\n }\n\n this.itemsConfig = cfg;\n this.itemsColors = colors; // NEW\n }\n // ---------- styles ----------\n private injectStyles() {\n if (this.querySelector('style[data-mentions-style]')) return;\n const style = document.createElement('style');\n style.setAttribute('data-mentions-style', 'true');\n style.textContent = `\n .mention-dropdown {\n position: absolute; z-index: 1000; list-style: none; margin: 0; padding: 4px;\n border: 1px solid #e5e7eb; border-radius: 6px; background: #fff;\n box-shadow: 0 4px 10px rgba(0,0,0,.08); max-height: 180px; overflow: auto; font-size: 14px;\n }\n .mention-dropdown li { padding: 6px 8px; cursor: pointer; border-radius: 4px; }\n .mention-dropdown li:hover { background: #f1f5f9; }\n .mention { background: #eef2ff; padding: 0 3px; border-radius: 3px; }\n `;\n this.insertBefore(style, this.firstChild);\n }\n\n private getTriggerColor(trigger: string): string | undefined {\n // Priority: child item color > attribute JSON color\n return this.itemsColors[trigger] ?? this.mentionColors[trigger];\n }\n\n \nprivate ensureMentionDropdown() {\n if (this.dropdownEl || !this.hostEl) return;\n\n const dd = document.createElement('nile-dropdown');\n dd.style.zIndex = '1000';\n\n const btn = document.createElement('nile-button'); // invisible trigger\n btn.setAttribute('slot', 'trigger');\n btn.style.position = 'absolute'; \n btn.style.width = '1px';\n btn.style.height = '1px';\n btn.style.border = '0';\n btn.style.padding = '0';\n btn.style.opacity = '0'; \n btn.style.pointerEvents = 'none'; \n dd.appendChild(btn);\n this.triggerBtn = btn; \n const menu = document.createElement('nile-menu');\n dd.appendChild(menu);\n\n this.hostEl.appendChild(dd);\n this.dropdownEl = dd;\n this.menuEl = menu;\n}\n\n // ---------- selection helpers ----------\n private onSelectionChange = () => {\n if (!this.editorEl) return;\n const sel = document.getSelection();\n if (!sel || sel.rangeCount === 0) return;\n const range = sel.getRangeAt(0);\n if (this.editorEl.contains(range.commonAncestorContainer)) {\n this.lastRange = range.cloneRange();\n }\n };\n private saveSelection = () => {\n const sel = window.getSelection();\n if (sel && sel.rangeCount) this.lastRange = sel.getRangeAt(0).cloneRange();\n };\n private restoreSelection() {\n if (!this.lastRange) return;\n const sel = document.getSelection(); if (!sel) return;\n sel.removeAllRanges(); sel.addRange(this.lastRange);\n }\n private focusAndRestore() { this.editorEl?.focus(); this.restoreSelection(); }\n\n private getCaretClientRect(): DOMRect | null {\n const sel = document.getSelection();\n if (!sel || sel.rangeCount === 0) return null;\n\n const range = sel.getRangeAt(0).cloneRange();\n range.collapse(false);\n\n const rects = range.getClientRects();\n if (rects && rects.length > 0) return rects[0];\n\n const marker = document.createElement('span');\n marker.setAttribute('data-caret-marker', '1');\n marker.textContent = '\\u200B';\n range.insertNode(marker);\n\n const rect = marker.getBoundingClientRect();\n\n const after = document.createRange();\n after.setStartAfter(marker);\n after.collapse(true);\n sel.removeAllRanges();\n sel.addRange(after);\n marker.remove();\n\n return rect || null;\n }\n\n // ---------- editor events ----------\n private onEditorInput = () => {\n if (this.mentionOpen) this.handleMention();\n };\n\n private onEditorKeyUp = (e: KeyboardEvent) => {\n this.saveSelection();\n const key = e.key;\n const cfg = this.config;\n if (!this.mentionOpen && key && cfg[key]) {\n this.openMention(key);\n return;\n }\n if (this.mentionOpen) this.handleMention();\n };\n\n private onEditorKeyDown = (e: KeyboardEvent) => {\n if (!this.mentionOpen) return;\n const key = e.key;\n if (key === 'ArrowDown' || key === 'ArrowUp' || key === 'Enter') {\n e.preventDefault();\n if (key === 'Enter' && this.mentionFiltered.length) {\n this.selectMention(this.mentionFiltered[0]);\n }\n } else if (key === 'Escape') {\n e.preventDefault();\n this.closeMention();\n }\n };\n\n // ---------- mentions flow ----------\n private openMention(trigger: string) {\n this.saveSelection();\n if (!this.editorEl || !this.dropdownEl || !this.hostEl) return;\n\n const caretRect = this.getCaretClientRect();\n if (!caretRect) return;\n\n const hostRect = this.hostEl.getBoundingClientRect();\n\n this.mentionX = caretRect.left - hostRect.left;\n this.mentionY = caretRect.bottom - hostRect.top;\n\n this.mentionTrigger = trigger;\n this.mentionSuggestions = this.config[trigger] || [];\n this.mentionQuery = '';\n this.updateMentionFiltered();\n\n this.mentionOpen = true;\n this.renderMentionList();\n }\n\n private closeMention() {\n this.mentionOpen = false;\n this.mentionTrigger = null;\n this.mentionQuery = '';\n this.mentionFiltered = [];\n // hide dropdown\n this.dropdownEl?.removeAttribute('open');\n }\n\n private handleMention() {\n if (!this.mentionOpen || !this.mentionTrigger) return;\n const sel = window.getSelection(); if (!sel || !sel.anchorNode) return;\n\n let node: Node | null = sel.anchorNode;\n if (node.nodeType !== Node.TEXT_NODE) {\n const c = (node as HTMLElement).childNodes?.[sel.anchorOffset] || node.firstChild;\n if (c?.nodeType === Node.TEXT_NODE) node = c;\n }\n const text = (node && node.nodeType === Node.TEXT_NODE) ? (node.textContent || '') : '';\n const idx = text.lastIndexOf(this.mentionTrigger);\n if (idx >= 0) {\n this.mentionQuery = text.substring(idx + 1);\n this.updateMentionFiltered();\n this.renderMentionList();\n } else {\n this.closeMention();\n }\n }\n\n private updateMentionFiltered() {\n const q = this.mentionQuery.toLowerCase();\n this.mentionFiltered = (this.mentionSuggestions || []).filter(item =>\n item.label.toLowerCase().startsWith(q)\n );\n }\n\n private renderMentionList() {\n if (!this.dropdownEl || !this.menuEl) return;\n \n if (!this.triggerBtn) return;\n this.triggerBtn.style.position = 'absolute';\n this.triggerBtn.style.left = `${this.mentionX}px`;\n this.triggerBtn.style.top = `${this.mentionY}px`;\n \n \n // clear old items\n this.menuEl.innerHTML = '';\n \n if (!this.mentionOpen || !this.mentionFiltered.length) {\n this.dropdownEl.removeAttribute('open');\n return;\n }\n \n // build menu items\n for (const item of this.mentionFiltered) {\n const mi = document.createElement('nile-menu-item');\n mi.textContent = item.label;\n mi.addEventListener('mousedown', (e) => {\n e.preventDefault();\n this.selectMention(item);\n });\n this.menuEl.appendChild(mi);\n }\n \n // show dropdown\n this.dropdownEl.setAttribute('open', '');\n }\n \n\n private repositionMention = () => {\n if (!this.mentionOpen || !this.hostEl || !this.triggerBtn) return;\n\n const caretRect = this.getCaretClientRect();\n if (!caretRect) return;\n\n const hostRect = this.hostEl.getBoundingClientRect();\n\n this.mentionX = caretRect.left - hostRect.left;\n this.mentionY = caretRect.bottom - hostRect.top;\n\n this.triggerBtn.style.left = `${this.mentionX}px`;\n this.triggerBtn.style.top = `${this.mentionY}px`;\n };\n\n private selectMention(item: MentionItem) {\n this.restoreSelection(); if (!this.lastRange || !this.mentionTrigger || !this.editorEl) return;\n\n let node: Node = this.lastRange.startContainer;\n let offset = this.lastRange.startOffset;\n if (node.nodeType !== Node.TEXT_NODE) {\n const child = node.childNodes[offset];\n if (child?.nodeType === Node.TEXT_NODE) { node = child; offset = 0; } else return;\n }\n const textNode = node as Text;\n const text = textNode.textContent || '';\n const atIndex = text.lastIndexOf(this.mentionTrigger, offset);\n if (atIndex < 0) return;\n\n const endIndex = atIndex + 1 + this.mentionQuery.length;\n const mentionRange = document.createRange();\n mentionRange.setStart(textNode, atIndex);\n mentionRange.setEnd(textNode, endIndex);\n mentionRange.deleteContents();\n\n const span = document.createElement('span');\n span.classList.add('mention');\n span.textContent = `${this.mentionTrigger}${item.label}`;\n const bg = this.getTriggerColor(this.mentionTrigger);\n if (bg) {\n span.style.backgroundColor = bg;\n // Optional: if you prefer colored text instead of bg\n // span.style.color = bg;\n }\n\n mentionRange.insertNode(span);\n\n const spaceNode = document.createTextNode('\\u00A0');\n span.after(spaceNode);\n\n const sel = window.getSelection();\n const afterRange = document.createRange();\n afterRange.setStartAfter(spaceNode); afterRange.collapse(true);\n sel?.removeAllRanges(); sel?.addRange(afterRange);\n this.lastRange = afterRange.cloneRange();\n\n this.closeMention();\n\n // bubble an input event so the editor updates preview/state\n this.editorEl.dispatchEvent(new InputEvent('input', { bubbles: true }));\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-rte-mentions': NileRteMentions;\n }\n}\n"],"names":["NileRteMentions","o","this","mentions","mentionColors","externalConfig","itemsConfig","itemsColors","editorEl","hostEl","dropdownEl","menuEl","lastRange","mentionOpen","mentionTrigger","mentionQuery","mentionSuggestions","mentionFiltered","mentionX","mentionY","triggerBtn","mo","onSelectionChange","sel","document","getSelection","rangeCount","range","getRangeAt","contains","commonAncestorContainer","cloneRange","saveSelection","window","onEditorInput","handleMention","onEditorKeyUp","e","key","cfg","config","openMention","onEditorKeyDown","preventDefault","length","selectMention","closeMention","repositionMention","caretRect","getCaretClientRect","hostRect","getBoundingClientRect","left","bottom","top","style","concat","_this","_inherits","_i","_createClass","value","createRenderRoot","get","_objectSpread","attach","injectStyles","ensureMentionDropdown","rebuildConfigFromChildren","MutationObserver","observe","childList","subtree","attributes","addEventListener","detach","disconnect","removeEventListener","setExternalConfig","disconnectedCallback","super","colors","items","Array","from","querySelectorAll","_loop","_ref","_n$mentionsCharacter","_n$mentionsData","_ref2","_n$mentionsColor","item","trig","mentionsCharacter","getAttribute","data","mentionsData","raw","parsed","JSON","parse","isArray","filter","i","label","_unused","color","mentionsColor","String","_i2","_s","querySelector","createElement","setAttribute","textContent","insertBefore","firstChild","getTriggerColor","trigger","_this$itemsColors$t","dd","zIndex","btn","position","width","height","border","padding","opacity","pointerEvents","appendChild","menu","restoreSelection","removeAllRanges","addRange","focusAndRestore","focus","collapse","rects","getClientRects","marker","insertNode","rect","after","createRange","setStartAfter","remove","updateMentionFiltered","renderMentionList","_this$dropdownEl","removeAttribute","anchorNode","node","nodeType","Node","TEXT_NODE","_i$childNodes","c","childNodes","anchorOffset","text","idx","lastIndexOf","substring","q","toLowerCase","startsWith","_this3","innerHTML","_iterator","_createForOfIteratorHelper","mi","s","_step","n","done","_loop2","startContainer","offset","startOffset","child","textNode","atIndex","endIndex","mentionRange","setStart","setEnd","deleteContents","span","classList","add","bg","backgroundColor","spaceNode","createTextNode","afterRange","dispatchEvent","InputEvent","bubbles","__decorate","LitElement","property","attribute","converter","fromAttribute","out","_i5","_Object$keys","Object","keys","arr","map","_unused2","toAttribute","v","stringify","prototype","_typeof","_unused3","state","customElement"],"mappings":"u1KAOaA,CAAAA,uBAAAA,EAAAA,EAAN,SAAAC,EAAA,uEAyBLC,KAAAA,CAAQC,QAAAA,CAAmB,GAY3BD,KAAAA,CAAAE,aAAwC,CAAA,EAGvBF,CAAAA,KAAAA,CAAcG,eAAmB,GAGjCH,KAAAA,CAAWI,WAAAA,CAAmB,EAE9BJ,CAAAA,KAAAA,CAAAK,WAAqC,CAAA,GAQ9CL,KAAAA,CAAQM,QAAAA,CAAuB,IAC/BN,CAAAA,KAAAA,CAAMO,MAAuB,CAAA,IAAA,CAG/BP,KAAAA,CAAAQ,UAAAA,CAAiC,KACjCR,KAAAA,CAAAS,MAAAA,CAAkC,IAIhCT,CAAAA,KAAAA,CAASU,UAAiB,IAG1BV,CAAAA,KAAAA,CAAWW,WAAG,CAAA,CAAA,CAAA,CACdX,KAAAA,CAAcY,cAAkB,CAAA,IAAA,CAChCZ,KAAAA,CAAYa,YAAAA,CAAG,GACfb,KAAAA,CAAkBc,kBAAAA,CAAkB,EACpCd,CAAAA,KAAAA,CAAee,gBAAkB,EACjCf,CAAAA,KAAAA,CAAQgB,QAAG,CAAA,CAAA,CACXhB,KAAAA,CAAQiB,QAAG,CAAA,CAAA,CACbjB,KAAAA,CAAUkB,UAAAA,CAAuB,KAK/BlB,KAAAA,CAAEmB,EAAAA,C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,CAAAA,SAAAA,CAAA,aAAA,CAAA,IAAA,EAAA,CAAA,CAEjCjB,EAAA,CAAhBoB,CAAAA,CAAAA,CAAAA,CAAAA,CAAwD5N,CAAAyN,CAAAA,SAAAA,CAAA,kBAAA,EA7C9CzN,CAAAA,CAAAA,CAAAA,CAAewM,CAAA,CAAA,CAD3BqB,EAAc,mBACF7N,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA"}
@@ -1 +1 @@
1
- import{__decorate as t}from"tslib";import{LitElement as i}from"lit";import{property as s,state as n,customElement as e}from"lit/decorators.js";let h=class extends i{constructor(){super(...arguments),this.mentions={},this.externalConfig={},this.itemsConfig={},this.editorEl=null,this.hostEl=null,this.dropdownEl=null,this.menuEl=null,this.lastRange=null,this.mentionOpen=!1,this.mentionTrigger=null,this.mentionQuery="",this.mentionSuggestions=[],this.mentionFiltered=[],this.mentionX=0,this.mentionY=0,this.triggerBtn=null,this.mo=null,this.onSelectionChange=()=>{if(!this.editorEl)return;const t=document.getSelection();if(!t||0===t.rangeCount)return;const i=t.getRangeAt(0);this.editorEl.contains(i.commonAncestorContainer)&&(this.lastRange=i.cloneRange())},this.saveSelection=()=>{const t=window.getSelection();t&&t.rangeCount&&(this.lastRange=t.getRangeAt(0).cloneRange())},this.onEditorInput=()=>{this.mentionOpen&&this.handleMention()},this.onEditorKeyUp=t=>{this.saveSelection();const i=t.key,s=this.config;!this.mentionOpen&&i&&s[i]?this.openMention(i):this.mentionOpen&&this.handleMention()},this.onEditorKeyDown=t=>{if(!this.mentionOpen)return;const i=t.key;"ArrowDown"===i||"ArrowUp"===i||"Enter"===i?(t.preventDefault(),"Enter"===i&&this.mentionFiltered.length&&this.selectMention(this.mentionFiltered[0])):"Escape"===i&&(t.preventDefault(),this.closeMention())},this.repositionMention=()=>{if(!this.mentionOpen||!this.hostEl||!this.triggerBtn)return;const t=this.getCaretClientRect();if(!t)return;const i=this.hostEl.getBoundingClientRect();this.mentionX=t.left-i.left,this.mentionY=t.bottom-i.top,this.triggerBtn.style.left=`${this.mentionX}px`,this.triggerBtn.style.top=`${this.mentionY}px`}}createRenderRoot(){return this}get config(){return{...this.externalConfig,...this.mentions,...this.itemsConfig}}attach(t,i){this.editorEl=t,this.hostEl=i,this.injectStyles(),this.ensureMentionDropdown(),this.rebuildConfigFromChildren(),this.mo=new MutationObserver((()=>this.rebuildConfigFromChildren())),this.mo.observe(this,{childList:!0,subtree:!0,attributes:!0}),this.editorEl.addEventListener("input",this.onEditorInput),this.editorEl.addEventListener("mouseup",this.saveSelection),this.editorEl.addEventListener("keyup",this.onEditorKeyUp),this.editorEl.addEventListener("keydown",this.onEditorKeyDown),this.editorEl.addEventListener("scroll",this.repositionMention),document.addEventListener("selectionchange",this.onSelectionChange,!0)}detach(){this.mo&&(this.mo.disconnect(),this.mo=null),this.editorEl&&(this.editorEl.removeEventListener("input",this.onEditorInput),this.editorEl.removeEventListener("mouseup",this.saveSelection),this.editorEl.removeEventListener("keyup",this.onEditorKeyUp),this.editorEl.removeEventListener("keydown",this.onEditorKeyDown),this.editorEl.removeEventListener("scroll",this.repositionMention)),document.removeEventListener("selectionchange",this.onSelectionChange,!0)}setExternalConfig(t){this.externalConfig=t||{}}disconnectedCallback(){this.detach(),super.disconnectedCallback()}rebuildConfigFromChildren(){const t={},i=Array.from(this.querySelectorAll("nile-rte-mentions-item"));for(const s of i){const i=s.mentionsCharacter??s.getAttribute("mentionscharacter")??"";if(!i||"string"!=typeof i)continue;let n=s.mentionsData??(()=>{const t=s.getAttribute("mentionsdata");if(!t)return null;try{const i=JSON.parse(t);return Array.isArray(i)?i.filter((t=>t&&"string"==typeof t.key&&"string"==typeof t.label)):[]}catch{return[]}})();Array.isArray(n)||(n=[]),t[i]=n}this.itemsConfig=t}injectStyles(){if(this.querySelector("style[data-mentions-style]"))return;const t=document.createElement("style");t.setAttribute("data-mentions-style","true"),t.textContent="\n .mention-dropdown {\n position: absolute; z-index: 1000; list-style: none; margin: 0; padding: 4px;\n border: 1px solid #e5e7eb; border-radius: 6px; background: #fff;\n box-shadow: 0 4px 10px rgba(0,0,0,.08); max-height: 180px; overflow: auto; font-size: 14px;\n }\n .mention-dropdown li { padding: 6px 8px; cursor: pointer; border-radius: 4px; }\n .mention-dropdown li:hover { background: #f1f5f9; }\n .mention { background: #eef2ff; padding: 0 3px; border-radius: 3px; }\n ",this.insertBefore(t,this.firstChild)}ensureMentionDropdown(){if(this.dropdownEl||!this.hostEl)return;const t=document.createElement("nile-dropdown");t.style.zIndex="1000";const i=document.createElement("nile-button");i.setAttribute("slot","trigger"),i.style.position="absolute",i.style.width="1px",i.style.height="1px",i.style.border="0",i.style.padding="0",i.style.opacity="0",i.style.pointerEvents="none",t.appendChild(i),this.triggerBtn=i;const s=document.createElement("nile-menu");t.appendChild(s),this.hostEl.appendChild(t),this.dropdownEl=t,this.menuEl=s}restoreSelection(){if(!this.lastRange)return;const t=document.getSelection();t&&(t.removeAllRanges(),t.addRange(this.lastRange))}focusAndRestore(){this.editorEl?.focus(),this.restoreSelection()}getCaretClientRect(){const t=document.getSelection();if(!t||0===t.rangeCount)return null;const i=t.getRangeAt(0).cloneRange();i.collapse(!1);const s=i.getClientRects();if(s&&s.length>0)return s[0];const n=document.createElement("span");n.setAttribute("data-caret-marker","1"),n.textContent="​",i.insertNode(n);const e=n.getBoundingClientRect(),h=document.createRange();return h.setStartAfter(n),h.collapse(!0),t.removeAllRanges(),t.addRange(h),n.remove(),e||null}openMention(t){if(this.saveSelection(),!this.editorEl||!this.dropdownEl||!this.hostEl)return;const i=this.getCaretClientRect();if(!i)return;const s=this.hostEl.getBoundingClientRect();this.mentionX=i.left-s.left,this.mentionY=i.bottom-s.top,this.mentionTrigger=t,this.mentionSuggestions=this.config[t]||[],this.mentionQuery="",this.updateMentionFiltered(),this.mentionOpen=!0,this.renderMentionList()}closeMention(){this.mentionOpen=!1,this.mentionTrigger=null,this.mentionQuery="",this.mentionFiltered=[],this.dropdownEl?.removeAttribute("open")}handleMention(){if(!this.mentionOpen||!this.mentionTrigger)return;const t=window.getSelection();if(!t||!t.anchorNode)return;let i=t.anchorNode;if(i.nodeType!==Node.TEXT_NODE){const s=i.childNodes?.[t.anchorOffset]||i.firstChild;s?.nodeType===Node.TEXT_NODE&&(i=s)}const s=i&&i.nodeType===Node.TEXT_NODE&&i.textContent||"",n=s.lastIndexOf(this.mentionTrigger);n>=0?(this.mentionQuery=s.substring(n+1),this.updateMentionFiltered(),this.renderMentionList()):this.closeMention()}updateMentionFiltered(){const t=this.mentionQuery.toLowerCase();this.mentionFiltered=(this.mentionSuggestions||[]).filter((i=>i.label.toLowerCase().startsWith(t)))}renderMentionList(){if(this.dropdownEl&&this.menuEl&&this.triggerBtn)if(this.triggerBtn.style.position="absolute",this.triggerBtn.style.left=`${this.mentionX}px`,this.triggerBtn.style.top=`${this.mentionY}px`,this.menuEl.innerHTML="",this.mentionOpen&&this.mentionFiltered.length){for(const t of this.mentionFiltered){const i=document.createElement("nile-menu-item");i.textContent=t.label,i.addEventListener("mousedown",(i=>{i.preventDefault(),this.selectMention(t)})),this.menuEl.appendChild(i)}this.dropdownEl.setAttribute("open","")}else this.dropdownEl.removeAttribute("open")}selectMention(t){if(this.restoreSelection(),!this.lastRange||!this.mentionTrigger||!this.editorEl)return;let i=this.lastRange.startContainer,s=this.lastRange.startOffset;if(i.nodeType!==Node.TEXT_NODE){const t=i.childNodes[s];if(t?.nodeType!==Node.TEXT_NODE)return;i=t,s=0}const n=i,e=(n.textContent||"").lastIndexOf(this.mentionTrigger,s);if(e<0)return;const h=e+1+this.mentionQuery.length,o=document.createRange();o.setStart(n,e),o.setEnd(n,h),o.deleteContents();const r=document.createElement("span");r.classList.add("mention"),r.textContent=`${this.mentionTrigger}${t.label}`,o.insertNode(r);const u=document.createTextNode(" ");r.after(u);const c=window.getSelection(),l=document.createRange();l.setStartAfter(u),l.collapse(!0),c?.removeAllRanges(),c?.addRange(l),this.lastRange=l.cloneRange(),this.closeMention(),this.editorEl.dispatchEvent(new InputEvent("input",{bubbles:!0}))}};t([s({attribute:"mentions",converter:{fromAttribute:t=>{try{const i=JSON.parse(t),s={};for(const t of Object.keys(i)){const n=i[t];Array.isArray(n)&&(s[t]=n.filter((t=>t&&"string"==typeof t.key&&"string"==typeof t.label)).map((t=>({key:t.key,label:t.label}))))}return s}catch{return{}}},toAttribute:t=>JSON.stringify(t)}})],h.prototype,"mentions",void 0),t([n()],h.prototype,"externalConfig",void 0),t([n()],h.prototype,"itemsConfig",void 0),h=t([e("nile-rte-mentions")],h);
1
+ import{__decorate as t}from"tslib";import{LitElement as i}from"lit";import{property as s,state as n,customElement as e}from"lit/decorators.js";let o=class extends i{constructor(){super(...arguments),this.mentions={},this.mentionColors={},this.externalConfig={},this.itemsConfig={},this.itemsColors={},this.editorEl=null,this.hostEl=null,this.dropdownEl=null,this.menuEl=null,this.lastRange=null,this.mentionOpen=!1,this.mentionTrigger=null,this.mentionQuery="",this.mentionSuggestions=[],this.mentionFiltered=[],this.mentionX=0,this.mentionY=0,this.triggerBtn=null,this.mo=null,this.onSelectionChange=()=>{if(!this.editorEl)return;const t=document.getSelection();if(!t||0===t.rangeCount)return;const i=t.getRangeAt(0);this.editorEl.contains(i.commonAncestorContainer)&&(this.lastRange=i.cloneRange())},this.saveSelection=()=>{const t=window.getSelection();t&&t.rangeCount&&(this.lastRange=t.getRangeAt(0).cloneRange())},this.onEditorInput=()=>{this.mentionOpen&&this.handleMention()},this.onEditorKeyUp=t=>{this.saveSelection();const i=t.key,s=this.config;!this.mentionOpen&&i&&s[i]?this.openMention(i):this.mentionOpen&&this.handleMention()},this.onEditorKeyDown=t=>{if(!this.mentionOpen)return;const i=t.key;"ArrowDown"===i||"ArrowUp"===i||"Enter"===i?(t.preventDefault(),"Enter"===i&&this.mentionFiltered.length&&this.selectMention(this.mentionFiltered[0])):"Escape"===i&&(t.preventDefault(),this.closeMention())},this.repositionMention=()=>{if(!this.mentionOpen||!this.hostEl||!this.triggerBtn)return;const t=this.getCaretClientRect();if(!t)return;const i=this.hostEl.getBoundingClientRect();this.mentionX=t.left-i.left,this.mentionY=t.bottom-i.top,this.triggerBtn.style.left=`${this.mentionX}px`,this.triggerBtn.style.top=`${this.mentionY}px`}}createRenderRoot(){return this}get config(){return{...this.externalConfig,...this.mentions,...this.itemsConfig}}attach(t,i){this.editorEl=t,this.hostEl=i,this.injectStyles(),this.ensureMentionDropdown(),this.rebuildConfigFromChildren(),this.mo=new MutationObserver((()=>this.rebuildConfigFromChildren())),this.mo.observe(this,{childList:!0,subtree:!0,attributes:!0}),this.editorEl.addEventListener("input",this.onEditorInput),this.editorEl.addEventListener("mouseup",this.saveSelection),this.editorEl.addEventListener("keyup",this.onEditorKeyUp),this.editorEl.addEventListener("keydown",this.onEditorKeyDown),this.editorEl.addEventListener("scroll",this.repositionMention),document.addEventListener("selectionchange",this.onSelectionChange,!0)}detach(){this.mo&&(this.mo.disconnect(),this.mo=null),this.editorEl&&(this.editorEl.removeEventListener("input",this.onEditorInput),this.editorEl.removeEventListener("mouseup",this.saveSelection),this.editorEl.removeEventListener("keyup",this.onEditorKeyUp),this.editorEl.removeEventListener("keydown",this.onEditorKeyDown),this.editorEl.removeEventListener("scroll",this.repositionMention)),document.removeEventListener("selectionchange",this.onSelectionChange,!0)}setExternalConfig(t){this.externalConfig=t||{}}disconnectedCallback(){this.detach(),super.disconnectedCallback()}rebuildConfigFromChildren(){const t={},i={},s=Array.from(this.querySelectorAll("nile-rte-mentions-item"));for(const n of s){const s=n.mentionsCharacter??n.getAttribute("mentionscharacter")??"";if(!s||"string"!=typeof s)continue;let e=n.mentionsData??(()=>{const t=n.getAttribute("mentionsdata");if(!t)return null;try{const i=JSON.parse(t);return Array.isArray(i)?i.filter((t=>t&&"string"==typeof t.key&&"string"==typeof t.label)):[]}catch{return[]}})();const o=n.mentionsColor??n.getAttribute("mentionscolor")??"";Array.isArray(e)||(e=[]),t[s]=e,o&&(i[s]=String(o))}this.itemsConfig=t,this.itemsColors=i}injectStyles(){if(this.querySelector("style[data-mentions-style]"))return;const t=document.createElement("style");t.setAttribute("data-mentions-style","true"),t.textContent="\n .mention-dropdown {\n position: absolute; z-index: 1000; list-style: none; margin: 0; padding: 4px;\n border: 1px solid #e5e7eb; border-radius: 6px; background: #fff;\n box-shadow: 0 4px 10px rgba(0,0,0,.08); max-height: 180px; overflow: auto; font-size: 14px;\n }\n .mention-dropdown li { padding: 6px 8px; cursor: pointer; border-radius: 4px; }\n .mention-dropdown li:hover { background: #f1f5f9; }\n .mention { background: #eef2ff; padding: 0 3px; border-radius: 3px; }\n ",this.insertBefore(t,this.firstChild)}getTriggerColor(t){return this.itemsColors[t]??this.mentionColors[t]}ensureMentionDropdown(){if(this.dropdownEl||!this.hostEl)return;const t=document.createElement("nile-dropdown");t.style.zIndex="1000";const i=document.createElement("nile-button");i.setAttribute("slot","trigger"),i.style.position="absolute",i.style.width="1px",i.style.height="1px",i.style.border="0",i.style.padding="0",i.style.opacity="0",i.style.pointerEvents="none",t.appendChild(i),this.triggerBtn=i;const s=document.createElement("nile-menu");t.appendChild(s),this.hostEl.appendChild(t),this.dropdownEl=t,this.menuEl=s}restoreSelection(){if(!this.lastRange)return;const t=document.getSelection();t&&(t.removeAllRanges(),t.addRange(this.lastRange))}focusAndRestore(){this.editorEl?.focus(),this.restoreSelection()}getCaretClientRect(){const t=document.getSelection();if(!t||0===t.rangeCount)return null;const i=t.getRangeAt(0).cloneRange();i.collapse(!1);const s=i.getClientRects();if(s&&s.length>0)return s[0];const n=document.createElement("span");n.setAttribute("data-caret-marker","1"),n.textContent="​",i.insertNode(n);const e=n.getBoundingClientRect(),o=document.createRange();return o.setStartAfter(n),o.collapse(!0),t.removeAllRanges(),t.addRange(o),n.remove(),e||null}openMention(t){if(this.saveSelection(),!this.editorEl||!this.dropdownEl||!this.hostEl)return;const i=this.getCaretClientRect();if(!i)return;const s=this.hostEl.getBoundingClientRect();this.mentionX=i.left-s.left,this.mentionY=i.bottom-s.top,this.mentionTrigger=t,this.mentionSuggestions=this.config[t]||[],this.mentionQuery="",this.updateMentionFiltered(),this.mentionOpen=!0,this.renderMentionList()}closeMention(){this.mentionOpen=!1,this.mentionTrigger=null,this.mentionQuery="",this.mentionFiltered=[],this.dropdownEl?.removeAttribute("open")}handleMention(){if(!this.mentionOpen||!this.mentionTrigger)return;const t=window.getSelection();if(!t||!t.anchorNode)return;let i=t.anchorNode;if(i.nodeType!==Node.TEXT_NODE){const s=i.childNodes?.[t.anchorOffset]||i.firstChild;s?.nodeType===Node.TEXT_NODE&&(i=s)}const s=i&&i.nodeType===Node.TEXT_NODE&&i.textContent||"",n=s.lastIndexOf(this.mentionTrigger);n>=0?(this.mentionQuery=s.substring(n+1),this.updateMentionFiltered(),this.renderMentionList()):this.closeMention()}updateMentionFiltered(){const t=this.mentionQuery.toLowerCase();this.mentionFiltered=(this.mentionSuggestions||[]).filter((i=>i.label.toLowerCase().startsWith(t)))}renderMentionList(){if(this.dropdownEl&&this.menuEl&&this.triggerBtn)if(this.triggerBtn.style.position="absolute",this.triggerBtn.style.left=`${this.mentionX}px`,this.triggerBtn.style.top=`${this.mentionY}px`,this.menuEl.innerHTML="",this.mentionOpen&&this.mentionFiltered.length){for(const t of this.mentionFiltered){const i=document.createElement("nile-menu-item");i.textContent=t.label,i.addEventListener("mousedown",(i=>{i.preventDefault(),this.selectMention(t)})),this.menuEl.appendChild(i)}this.dropdownEl.setAttribute("open","")}else this.dropdownEl.removeAttribute("open")}selectMention(t){if(this.restoreSelection(),!this.lastRange||!this.mentionTrigger||!this.editorEl)return;let i=this.lastRange.startContainer,s=this.lastRange.startOffset;if(i.nodeType!==Node.TEXT_NODE){const t=i.childNodes[s];if(t?.nodeType!==Node.TEXT_NODE)return;i=t,s=0}const n=i,e=(n.textContent||"").lastIndexOf(this.mentionTrigger,s);if(e<0)return;const o=e+1+this.mentionQuery.length,h=document.createRange();h.setStart(n,e),h.setEnd(n,o),h.deleteContents();const r=document.createElement("span");r.classList.add("mention"),r.textContent=`${this.mentionTrigger}${t.label}`;const c=this.getTriggerColor(this.mentionTrigger);c&&(r.style.backgroundColor=c),h.insertNode(r);const u=document.createTextNode(" ");r.after(u);const l=window.getSelection(),d=document.createRange();d.setStartAfter(u),d.collapse(!0),l?.removeAllRanges(),l?.addRange(d),this.lastRange=d.cloneRange(),this.closeMention(),this.editorEl.dispatchEvent(new InputEvent("input",{bubbles:!0}))}};t([s({attribute:"mentions",converter:{fromAttribute:t=>{try{const i=JSON.parse(t),s={};for(const t of Object.keys(i)){const n=i[t];Array.isArray(n)&&(s[t]=n.filter((t=>t&&"string"==typeof t.key&&"string"==typeof t.label)).map((t=>({key:t.key,label:t.label}))))}return s}catch{return{}}},toAttribute:t=>JSON.stringify(t)}})],o.prototype,"mentions",void 0),t([s({attribute:"mentioncolors",converter:{fromAttribute:t=>{try{const i=JSON.parse(t);return i&&"object"==typeof i?i:{}}catch{return{}}},toAttribute:t=>JSON.stringify(t??{})}})],o.prototype,"mentionColors",void 0),t([n()],o.prototype,"externalConfig",void 0),t([n()],o.prototype,"itemsConfig",void 0),t([n()],o.prototype,"itemsColors",void 0),o=t([e("nile-rte-mentions")],o);
@@ -1,2 +1,2 @@
1
- function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}System.register(["tslib","lit","lit/decorators.js"],function(_export,_context){"use strict";var t,e,n,i,l,r,_templateObject,_templateObject2,_templateObject3,_templateObject4,_templateObject5,s;function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}));}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t);}:p;}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value;}},_get.apply(null,arguments);}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t;}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_lit){e=_lit.LitElement;n=_lit.html;},function(_litDecoratorsJs){i=_litDecoratorsJs.property;l=_litDecoratorsJs.state;r=_litDecoratorsJs.customElement;}],execute:function execute(){s=/*#__PURE__*/function(_e){function s(){var _this;_classCallCheck(this,s);_this=_callSuper(this,s,arguments),_this.type="",_this.options="[]",_this.label="",_this.selectedValue="";return _this;}_inherits(s,_e);return _createClass(s,[{key:"createRenderRoot",value:function createRenderRoot(){return this;}},{key:"mapAlignIcon",value:function mapAlignIcon(t){return{left:"align-left",center:"align-center",right:"align-right",justify:"align-justify"}[t]||"align-left";}},{key:"parsedOptions",get:function get(){var _this2=this;try{return JSON.parse(this.options).map(function(t){var _t$value,_ref,_t$label,_t$icon;var e=(_t$value=t.value)!==null&&_t$value!==void 0?_t$value:t;return{value:e,label:(_ref=(_t$label=t.label)!==null&&_t$label!==void 0?_t$label:t.value)!==null&&_ref!==void 0?_ref:t,icon:(_t$icon=t.icon)!==null&&_t$icon!==void 0?_t$icon:"align"===_this2.type?_this2.mapAlignIcon(String(e)):void 0};});}catch(_unused){return[];}}},{key:"ensureDefault",value:function ensureDefault(){if(!this.selectedValue){var _t=this.parsedOptions[0];_t&&(this.selectedValue=_t.value);}}},{key:"onSelect",value:function onSelect(t){this.selectedValue=t,this.dispatchEvent(new CustomEvent("change",{detail:t,bubbles:!0,composed:!0}));}},{key:"connectedCallback",value:function connectedCallback(){_superPropGet(s,"connectedCallback",this,3)([]),this.injectLocalStyles();}},{key:"injectLocalStyles",value:function injectLocalStyles(){if(this.querySelector("style[data-rte-select-style]"))return;var t=document.createElement("style");t.setAttribute("data-rte-select-style","true"),t.textContent="\n\n nile-menu.rte-align-menu::part(menu__items-wrapper) {\n display: flex;\n }\n nile-menu.rte-align-menu,nile-menu.rte-default-menu{\n margin-bottom: 1px;\n }\n\n nile-button.rte-align-trigger::part(base),nile-button.rte-default-trigger::part(base){\n min-width: 32px;\n height: 32px;\n padding: 0px 6px;\n box-shadow: none;\n }\n \n ",this.insertBefore(t,this.firstChild);}},{key:"render",value:function render(){var _this3=this;var t=this.parsedOptions;this.ensureDefault();var e=t.find(function(t){return t.value===_this3.selectedValue;});if("align"===this.type){var _i=e!==null&&e!==void 0&&e.icon?n(_templateObject||(_templateObject=_taggedTemplateLiteral(["<nile-icon name=\"","\"></nile-icon>"])),e.icon):this.label||"Align";return n(_templateObject2||(_templateObject2=_taggedTemplateLiteral(["\n <nile-dropdown class=\"rte-align-dd\">\n <nile-button slot=\"trigger\" variant=\"tertiary\" class=\"rte-align-trigger\">\n ","\n </nile-button>\n <nile-menu class=\"rte-align-menu\">\n ","\n </nile-menu>\n </nile-dropdown>\n "])),_i,t.map(function(t){return n(_templateObject3||(_templateObject3=_taggedTemplateLiteral(["\n <nile-menu-item\n class=\"rte-align-item\"\n ?active=","\n @click=",">\n <nile-icon name=\"","\"></nile-icon>\n </nile-menu-item>\n "])),t.value===_this3.selectedValue,function(){return _this3.onSelect(t.value);},t.icon);}));}var i=(e===null||e===void 0?void 0:e.label)||this.label||"Select";return n(_templateObject4||(_templateObject4=_taggedTemplateLiteral(["\n <nile-dropdown class=\"rte-default-dd\">\n <nile-button slot=\"trigger\" variant=\"tertiary\" class=\"rte-default-trigger\">\n ","\n </nile-button>\n <nile-menu class=\"rte-default-menu\">\n ","\n </nile-menu>\n </nile-dropdown>\n "])),i,t.map(function(t){return n(_templateObject5||(_templateObject5=_taggedTemplateLiteral(["\n <nile-menu-item\n ?active=","\n @click=",">\n ","\n </nile-menu-item>\n "])),t.value===_this3.selectedValue,function(){return _this3.onSelect(t.value);},t.label);}));}}]);}(e);t([i({type:String})],s.prototype,"type",void 0),t([i({type:String})],s.prototype,"options",void 0),t([i({type:String})],s.prototype,"label",void 0),t([l()],s.prototype,"selectedValue",void 0),s=t([r("nile-rte-select")],s);}};});
1
+ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}System.register(["tslib","lit","lit/decorators.js"],function(_export,_context){"use strict";var e,t,n,i,l,r,_templateObject,_templateObject2,_templateObject3,_templateObject4,_templateObject5,s;function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}));}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t);}:p;}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value;}},_get.apply(null,arguments);}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t;}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}return{setters:[function(_tslib){e=_tslib.__decorate;},function(_lit){t=_lit.LitElement;n=_lit.html;},function(_litDecoratorsJs){i=_litDecoratorsJs.property;l=_litDecoratorsJs.state;r=_litDecoratorsJs.customElement;}],execute:function execute(){s=/*#__PURE__*/function(_t){function s(){var _this;_classCallCheck(this,s);_this=_callSuper(this,s,arguments),_this.type="",_this.options="[]",_this.label="",_this.selectedValue="";return _this;}_inherits(s,_t);return _createClass(s,[{key:"createRenderRoot",value:function createRenderRoot(){return this;}},{key:"mapAlignIcon",value:function mapAlignIcon(e){return{left:"align-left",center:"align-center",right:"align-right",justify:"nile-justify"}[e]||"align-left";}},{key:"parsedOptions",get:function get(){var _this2=this;try{return JSON.parse(this.options).map(function(e){var _e$value,_ref,_e$label,_e$icon;var t=(_e$value=e.value)!==null&&_e$value!==void 0?_e$value:e;return{value:t,label:(_ref=(_e$label=e.label)!==null&&_e$label!==void 0?_e$label:e.value)!==null&&_ref!==void 0?_ref:e,icon:(_e$icon=e.icon)!==null&&_e$icon!==void 0?_e$icon:"align"===_this2.type?_this2.mapAlignIcon(String(t)):void 0};});}catch(_unused){return[];}}},{key:"ensureDefault",value:function ensureDefault(){if(!this.selectedValue){var _e=this.parsedOptions[0];_e&&(this.selectedValue=_e.value);}}},{key:"onSelect",value:function onSelect(e){this.selectedValue=e,this.dispatchEvent(new CustomEvent("change",{detail:e,bubbles:!0,composed:!0}));}},{key:"connectedCallback",value:function connectedCallback(){_superPropGet(s,"connectedCallback",this,3)([]),this.injectLocalStyles();}},{key:"injectLocalStyles",value:function injectLocalStyles(){if(this.querySelector("style[data-rte-select-style]"))return;var e=document.createElement("style");e.setAttribute("data-rte-select-style","true"),e.textContent="\n\n nile-menu.rte-align-menu::part(menu__items-wrapper) {\n display: flex;\n }\n nile-menu.rte-align-menu,nile-menu.rte-default-menu{\n margin-top: 0px;\n }\n\n nile-button.rte-align-trigger::part(base),nile-button.rte-default-trigger::part(base){\n min-width: 32px;\n height: 32px;\n padding: 0px 6px;\n box-shadow: none;\n }\n \n ",this.insertBefore(e,this.firstChild);}},{key:"render",value:function render(){var _this3=this;var e=this.parsedOptions;this.ensureDefault();var t=e.find(function(e){return e.value===_this3.selectedValue;});if("align"===this.type){var _i=t!==null&&t!==void 0&&t.icon?n(_templateObject||(_templateObject=_taggedTemplateLiteral(["<nile-icon name=\"","\"></nile-icon>"])),t.icon):this.label||"Align";return n(_templateObject2||(_templateObject2=_taggedTemplateLiteral(["\n <nile-dropdown class=\"rte-align-dd\">\n <nile-button slot=\"trigger\" variant=\"tertiary\" class=\"rte-align-trigger\">\n ","\n </nile-button>\n <nile-menu class=\"rte-align-menu\">\n ","\n </nile-menu>\n </nile-dropdown>\n\n \n "])),_i,e.map(function(e){return n(_templateObject3||(_templateObject3=_taggedTemplateLiteral(["\n <nile-menu-item\n class=\"rte-align-item\"\n ?active=","\n @click=",">\n <nile-icon name=\"","\"></nile-icon>\n </nile-menu-item>\n "])),e.value===_this3.selectedValue,function(){return _this3.onSelect(e.value);},e.icon);}));}var i=(t===null||t===void 0?void 0:t.label)||this.label||"Select";return n(_templateObject4||(_templateObject4=_taggedTemplateLiteral(["\n <nile-dropdown class=\"rte-default-dd\">\n <nile-button slot=\"trigger\" variant=\"tertiary\" class=\"rte-default-trigger\">\n "," <nile-icon name=\"arrowdown\"></nile-icon>\n </nile-button>\n <nile-menu class=\"rte-default-menu\">\n ","\n </nile-menu>\n </nile-dropdown>\n "])),i,e.map(function(e){return n(_templateObject5||(_templateObject5=_taggedTemplateLiteral(["\n <nile-menu-item\n ?active=","\n @click=",">\n ","\n </nile-menu-item>\n "])),e.value===_this3.selectedValue,function(){return _this3.onSelect(e.value);},e.label);}));}}]);}(t);e([i({type:String})],s.prototype,"type",void 0),e([i({type:String})],s.prototype,"options",void 0),e([i({type:String})],s.prototype,"label",void 0),e([l()],s.prototype,"selectedValue",void 0),s=e([r("nile-rte-select")],s);}};});
2
2
  //# sourceMappingURL=nile-rte-select.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nile-rte-select.cjs.js","sources":["../../../src/nile-rich-text-editor/nile-rte-select.ts"],"sourcesContent":["// nile-rte-select.ts\nimport { LitElement, html } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\n\n\n@customElement('nile-rte-select')\nexport class NileRteSelect extends LitElement {\n protected createRenderRoot() { return this; }\n\n /** 'heading' | 'font' | 'align' */\n @property({ type: String }) type = '';\n /** JSON: [{ value, label?, icon? }, ...] */\n @property({ type: String }) options = '[]';\n /** Fallback label for trigger (e.g., \"Align\") */\n @property({ type: String }) label = '';\n\n @state() private selectedValue = '';\n\n private mapAlignIcon(v: string) {\n const map: Record<string,string> = {\n left: 'align-left',\n center: 'align-center',\n right: 'align-right',\n justify: 'align-justify'\n };\n return map[v] || 'align-left';\n }\n\n private get parsedOptions(): Array<{ value: string; label: string; icon?: string }> {\n try {\n const raw = JSON.parse(this.options);\n return raw.map((o: any) => {\n const value = o.value ?? o;\n const label = o.label ?? o.value ?? o;\n const icon = o.icon ?? (this.type === 'align' ? this.mapAlignIcon(String(value)) : undefined);\n return { value, label, icon };\n });\n } catch {\n return [];\n }\n }\n\n private ensureDefault() {\n if (!this.selectedValue) {\n const first = this.parsedOptions[0];\n if (first) this.selectedValue = first.value;\n }\n }\n\n private onSelect(value: string) {\n this.selectedValue = value;\n this.dispatchEvent(new CustomEvent('change', {\n detail: value, bubbles: true, composed: true\n }));\n }\n\n \n\n connectedCallback(): void {\n super.connectedCallback();\n this.injectLocalStyles(); \n }\n\n private injectLocalStyles() {\n \n if (this.querySelector('style[data-rte-select-style]')) return;\n\n const style = document.createElement('style');\n style.setAttribute('data-rte-select-style', 'true');\n style.textContent = `\n\n nile-menu.rte-align-menu::part(menu__items-wrapper) {\n display: flex;\n }\n nile-menu.rte-align-menu,nile-menu.rte-default-menu{\n margin-bottom: 1px;\n }\n\n nile-button.rte-align-trigger::part(base),nile-button.rte-default-trigger::part(base){\n min-width: 32px;\n height: 32px;\n padding: 0px 6px;\n box-shadow: none;\n }\n \n `;\n \n this.insertBefore(style, this.firstChild);\n }\n\n\n render() {\n const opts = this.parsedOptions;\n this.ensureDefault();\n const current = opts.find(o => o.value === this.selectedValue);\n\n if (this.type === 'align') {\n // ► Align: separate dropdown instance + icon-only items + icon trigger\n const trigger = current?.icon\n ? html`<nile-icon name=\"${current.icon}\"></nile-icon>`\n : (this.label || 'Align');\n\n return html`\n <nile-dropdown class=\"rte-align-dd\">\n <nile-button slot=\"trigger\" variant=\"tertiary\" class=\"rte-align-trigger\">\n ${trigger}\n </nile-button>\n <nile-menu class=\"rte-align-menu\">\n ${opts.map(o => html`\n <nile-menu-item\n class=\"rte-align-item\"\n ?active=${o.value === this.selectedValue}\n @click=${() => this.onSelect(o.value)}>\n <nile-icon name=\"${o.icon}\"></nile-icon>\n </nile-menu-item>\n `)}\n </nile-menu>\n </nile-dropdown>\n `;\n }\n\n // ► Everything else: default (text) dropdown\n const triggerText = current?.label || this.label || 'Select';\n return html`\n <nile-dropdown class=\"rte-default-dd\">\n <nile-button slot=\"trigger\" variant=\"tertiary\" class=\"rte-default-trigger\">\n ${triggerText}\n </nile-button>\n <nile-menu class=\"rte-default-menu\">\n ${opts.map(o => html`\n <nile-menu-item\n ?active=${o.value === this.selectedValue}\n @click=${() => this.onSelect(o.value)}>\n ${o.label}\n </nile-menu-item>\n `)}\n </nile-menu>\n </nile-dropdown>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-rte-select': NileRteSelect;\n }\n}\n"],"names":["NileRteSelect","s","this","type","options","label","selectedValue","_this","_inherits","_e","_createClass","key","value","createRenderRoot","mapAlignIcon","v","left","center","right","justify","get","_this2","JSON","parse","map","o","icon","_t$icon","String","undefined","_unused","ensureDefault","first","parsedOptions","onSelect","dispatchEvent","CustomEvent","detail","bubbles","composed","connectedCallback","super","injectLocalStyles","querySelector","style","document","createElement","setAttribute","textContent","insertBefore","firstChild","render","opts","current","find","trigger","html","_templateObject","_taggedTemplateLiteral","_templateObject2","_templateObject3","triggerText","_templateObject4","_templateObject5","LitElement","__decorate","property","prototype","state","customElement"],"mappings":"kjHAMaA,CAAAA,uBAAAA,EAAAA,EAAN,SAAAC,EAAA,uEAIuBC,KAAAA,CAAIC,IAAG,CAAA,EAAA,CAEPD,KAAAA,CAAOE,OAAG,CAAA,IAAA,CAEVF,KAAAA,CAAKG,KAAG,CAAA,EAAA,CAEnBH,KAAAA,CAAaI,aAAG,CAAA,EA4HlC,QAAAC,KAAA,EArIWC,SAAA,CAAAP,CAAA,CAAAQ,EAAA,SAAAC,YAAA,CAAAT,CAAA,GAAAU,GAAA,oBAAAC,KAAA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A,CAAA,CAA3BC,EAAS,CAAE/D,IAAAA,CAAMyB,UAAqB5B,CAAAmE,CAAAA,SAAAA,CAAA,YAAA,EAEtBF,CAAAA,CAAAA,CAAAA,CAAA,CAAhBG,CAAmCpE,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAmE,UAAA,eAAA,CAAA,IAAA,EAAA,CAAA,CAVzBnE,EAAaiE,CAAA,CAAA,CADzBI,EAAc,iBACFrE,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA"}
1
+ {"version":3,"file":"nile-rte-select.cjs.js","sources":["../../../src/nile-rich-text-editor/nile-rte-select.ts"],"sourcesContent":["// nile-rte-select.ts\nimport { LitElement, html } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\n\n\n@customElement('nile-rte-select')\nexport class NileRteSelect extends LitElement {\n protected createRenderRoot() { return this; }\n\n /** 'heading' | 'font' | 'align' */\n @property({ type: String }) type = '';\n /** JSON: [{ value, label?, icon? }, ...] */\n @property({ type: String }) options = '[]';\n /** Fallback label for trigger (e.g., \"Align\") */\n @property({ type: String }) label = '';\n\n @state() private selectedValue = '';\n\n private mapAlignIcon(v: string) {\n const map: Record<string,string> = {\n left: 'align-left',\n center: 'align-center',\n right: 'align-right',\n justify: 'nile-justify'\n };\n return map[v] || 'align-left';\n }\n\n private get parsedOptions(): Array<{ value: string; label: string; icon?: string }> {\n try {\n const raw = JSON.parse(this.options);\n return raw.map((o: any) => {\n const value = o.value ?? o;\n const label = o.label ?? o.value ?? o;\n const icon = o.icon ?? (this.type === 'align' ? this.mapAlignIcon(String(value)) : undefined);\n return { value, label, icon };\n });\n } catch {\n return [];\n }\n }\n\n private ensureDefault() {\n if (!this.selectedValue) {\n const first = this.parsedOptions[0];\n if (first) this.selectedValue = first.value;\n }\n }\n\n private onSelect(value: string) {\n this.selectedValue = value;\n this.dispatchEvent(new CustomEvent('change', {\n detail: value, bubbles: true, composed: true\n }));\n }\n\n \n\n connectedCallback(): void {\n super.connectedCallback();\n this.injectLocalStyles(); \n }\n\n private injectLocalStyles() {\n \n if (this.querySelector('style[data-rte-select-style]')) return;\n\n const style = document.createElement('style');\n style.setAttribute('data-rte-select-style', 'true');\n style.textContent = `\n\n nile-menu.rte-align-menu::part(menu__items-wrapper) {\n display: flex;\n }\n nile-menu.rte-align-menu,nile-menu.rte-default-menu{\n margin-top: 0px;\n }\n\n nile-button.rte-align-trigger::part(base),nile-button.rte-default-trigger::part(base){\n min-width: 32px;\n height: 32px;\n padding: 0px 6px;\n box-shadow: none;\n }\n \n `;\n \n this.insertBefore(style, this.firstChild);\n }\n\n\n render() {\n const opts = this.parsedOptions;\n this.ensureDefault();\n const current = opts.find(o => o.value === this.selectedValue);\n\n if (this.type === 'align') {\n // ► Align: separate dropdown instance + icon-only items + icon trigger\n const trigger = current?.icon\n ? html`<nile-icon name=\"${current.icon}\"></nile-icon>`\n : (this.label || 'Align');\n return html`\n <nile-dropdown class=\"rte-align-dd\">\n <nile-button slot=\"trigger\" variant=\"tertiary\" class=\"rte-align-trigger\">\n ${trigger}\n </nile-button>\n <nile-menu class=\"rte-align-menu\">\n ${opts.map(o => html`\n <nile-menu-item\n class=\"rte-align-item\"\n ?active=${o.value === this.selectedValue}\n @click=${() => this.onSelect(o.value)}>\n <nile-icon name=\"${o.icon}\"></nile-icon>\n </nile-menu-item>\n `)}\n </nile-menu>\n </nile-dropdown>\n\n \n `;\n if (this.type === 'font') {\n const triggerText = current?.label || this.label || 'Font';\n return html`\n <nile-dropdown class=\"rte-default-dd\">\n <nile-button slot=\"trigger\" variant=\"tertiary\" class=\"rte-default-trigger\"\n style=\"font-family: ${current?.value || 'inherit'}\">\n ${triggerText} <nile-icon name=\"arrowdown\"></nile-icon>\n </nile-button>\n <nile-menu class=\"rte-default-menu\">\n ${opts.map(o => html`\n <nile-menu-item\n style=\"font-family: ${o.value}\"\n ?active=${o.value === this.selectedValue}\n @click=${() => this.onSelect(o.value)}>\n ${o.label}\n </nile-menu-item>\n `)}\n </nile-menu>\n </nile-dropdown>\n `;\n }\n }\n\n // ► Everything else: default (text) dropdown\n const triggerText = current?.label || this.label || 'Select';\n return html`\n <nile-dropdown class=\"rte-default-dd\">\n <nile-button slot=\"trigger\" variant=\"tertiary\" class=\"rte-default-trigger\">\n ${triggerText} <nile-icon name=\"arrowdown\"></nile-icon>\n </nile-button>\n <nile-menu class=\"rte-default-menu\">\n ${opts.map(o => html`\n <nile-menu-item\n ?active=${o.value === this.selectedValue}\n @click=${() => this.onSelect(o.value)}>\n ${o.label}\n </nile-menu-item>\n `)}\n </nile-menu>\n </nile-dropdown>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-rte-select': NileRteSelect;\n }\n}\n"],"names":["NileRteSelect","s","this","type","options","label","selectedValue","_this","_inherits","_t","_createClass","key","value","createRenderRoot","mapAlignIcon","v","left","center","right","justify","get","_this2","JSON","parse","map","o","icon","_e$icon","String","undefined","_unused","ensureDefault","first","parsedOptions","onSelect","dispatchEvent","CustomEvent","detail","bubbles","composed","connectedCallback","super","injectLocalStyles","querySelector","style","document","createElement","setAttribute","textContent","insertBefore","firstChild","render","opts","current","find","trigger","html","_templateObject","_taggedTemplateLiteral","_templateObject2","_templateObject3","triggerText","_templateObject4","_templateObject5","LitElement","__decorate","property","prototype","state","customElement"],"mappings":"kjHAMaA,CAAAA,uBAAAA,EAAAA,EAAN,SAAAC,EAAA,uEAIuBC,KAAAA,CAAIC,IAAG,CAAA,EAAA,CAEPD,KAAAA,CAAOE,OAAG,CAAA,IAAA,CAEVF,KAAAA,CAAKG,KAAG,CAAA,EAAA,CAEnBH,KAAAA,CAAaI,aAAG,CAAA,EAkJlC,QAAAC,KAAA,EA3JWC,SAAA,CAAAP,CAAA,CAAAQ,EAAA,SAAAC,YAAA,CAAAT,CAAA,GAAAU,GAAA,oBAAAC,KAAA,UAAAC,gBAAAA,CAAAA,CAAAA,CAAqB,MAAOX,KAAO,EAWrC,GAAAS,GAAA,gBAAAC,KAAA,U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