create-nextjs-cms 0.5.55 → 0.5.58

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 (341) hide show
  1. package/package.json +4 -4
  2. package/templates/default/CHANGELOG.md +140 -140
  3. package/templates/default/_gitignore +1 -0
  4. package/templates/default/app/(auth)/auth/login/LoginPage.tsx +14 -11
  5. package/templates/default/app/(rootLayout)/admins/page.tsx +7 -2
  6. package/templates/default/app/(rootLayout)/advanced/page.tsx +8 -2
  7. package/templates/default/app/(rootLayout)/browse/[section]/[page]/page.tsx +17 -3
  8. package/templates/default/app/(rootLayout)/categorized/[section]/page.tsx +9 -1
  9. package/templates/default/app/(rootLayout)/dashboard-new/page.tsx +7 -0
  10. package/templates/default/app/(rootLayout)/edit/[section]/[itemId]/page.tsx +11 -1
  11. package/templates/default/app/(rootLayout)/layout.tsx +8 -1
  12. package/templates/default/app/(rootLayout)/new/[section]/page.tsx +9 -1
  13. package/templates/default/app/(rootLayout)/section/[section]/page.tsx +10 -1
  14. package/templates/default/app/(rootLayout)/settings/page.tsx +7 -1
  15. package/templates/default/app/api/trpc/[trpc]/route.ts +1 -1
  16. package/templates/default/app/api/video/route.ts +1 -1
  17. package/templates/default/app/layout.tsx +5 -3
  18. package/templates/default/app/providers.tsx +10 -9
  19. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/LICENSE +191 -0
  20. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/README.md +118 -0
  21. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/install/build.js +38 -0
  22. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/install/check.js +14 -0
  23. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/channel.js +177 -0
  24. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/colour.js +195 -0
  25. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/composite.js +212 -0
  26. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/constructor.js +499 -0
  27. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/index.d.ts +1971 -0
  28. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/index.js +16 -0
  29. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/input.js +809 -0
  30. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/is.js +143 -0
  31. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/libvips.js +207 -0
  32. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/operation.js +1016 -0
  33. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/output.js +1666 -0
  34. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/resize.js +595 -0
  35. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/sharp.js +121 -0
  36. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/lib/utility.js +291 -0
  37. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/package.json +202 -0
  38. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/binding.gyp +298 -0
  39. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/common.cc +1130 -0
  40. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/common.h +402 -0
  41. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/metadata.cc +346 -0
  42. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/metadata.h +90 -0
  43. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/operations.cc +499 -0
  44. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/operations.h +137 -0
  45. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/pipeline.cc +1814 -0
  46. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/pipeline.h +408 -0
  47. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/sharp.cc +43 -0
  48. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/stats.cc +186 -0
  49. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/stats.h +62 -0
  50. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/utilities.cc +288 -0
  51. package/templates/default/apps/cms/node_modules/next/node_modules/_tmp_40516_de1b9f7e36eccb968b79dbd2b8c388ea/src/utilities.h +22 -0
  52. package/templates/default/components/BrowsePage.tsx +4 -4
  53. package/templates/default/components/DashboardNewPage.tsx +252 -0
  54. package/templates/default/components/Layout.tsx +2 -2
  55. package/templates/default/components/LogPage.tsx +2 -3
  56. package/templates/default/components/NavbarAlt.tsx +5 -5
  57. package/templates/default/components/SettingsPage.tsx +1 -1
  58. package/templates/default/components/Sidebar.tsx +7 -7
  59. package/templates/default/components/form/Form.tsx +5 -5
  60. package/templates/default/components/form/helpers/util.ts +5 -5
  61. package/templates/default/dynamic-schemas/schema.ts +381 -381
  62. package/templates/default/next-env.d.ts +1 -1
  63. package/templates/default/next.config.ts +24 -0
  64. package/templates/default/package.json +23 -17
  65. package/templates/default/{middleware.ts → proxy.ts} +3 -4
  66. package/templates/default/test/prize.section.ts +58 -0
  67. package/templates/default/tsconfig.json +6 -3
  68. package/templates/default/app/api/placeholder/route.ts +0 -7
  69. package/templates/default/components/form/helpers/_section-hot-reload.js +0 -11
  70. package/templates/default/public/tinymce/CHANGELOG.md +0 -3940
  71. package/templates/default/public/tinymce/README.md +0 -77
  72. package/templates/default/public/tinymce/bower.json +0 -27
  73. package/templates/default/public/tinymce/composer.json +0 -52
  74. package/templates/default/public/tinymce/icons/default/icons.js +0 -239
  75. package/templates/default/public/tinymce/icons/default/icons.min.js +0 -1
  76. package/templates/default/public/tinymce/icons/default/index.js +0 -7
  77. package/templates/default/public/tinymce/license.md +0 -9
  78. package/templates/default/public/tinymce/models/dom/index.js +0 -7
  79. package/templates/default/public/tinymce/models/dom/model.js +0 -8980
  80. package/templates/default/public/tinymce/models/dom/model.min.js +0 -1
  81. package/templates/default/public/tinymce/notices.txt +0 -21
  82. package/templates/default/public/tinymce/package.json +0 -32
  83. package/templates/default/public/tinymce/plugins/accordion/index.js +0 -7
  84. package/templates/default/public/tinymce/plugins/accordion/plugin.js +0 -1373
  85. package/templates/default/public/tinymce/plugins/accordion/plugin.min.js +0 -1
  86. package/templates/default/public/tinymce/plugins/advlist/index.js +0 -7
  87. package/templates/default/public/tinymce/plugins/advlist/plugin.js +0 -473
  88. package/templates/default/public/tinymce/plugins/advlist/plugin.min.js +0 -1
  89. package/templates/default/public/tinymce/plugins/anchor/index.js +0 -7
  90. package/templates/default/public/tinymce/plugins/anchor/plugin.js +0 -237
  91. package/templates/default/public/tinymce/plugins/anchor/plugin.min.js +0 -1
  92. package/templates/default/public/tinymce/plugins/autolink/index.js +0 -7
  93. package/templates/default/public/tinymce/plugins/autolink/plugin.js +0 -315
  94. package/templates/default/public/tinymce/plugins/autolink/plugin.min.js +0 -1
  95. package/templates/default/public/tinymce/plugins/autoresize/index.js +0 -7
  96. package/templates/default/public/tinymce/plugins/autoresize/plugin.js +0 -221
  97. package/templates/default/public/tinymce/plugins/autoresize/plugin.min.js +0 -1
  98. package/templates/default/public/tinymce/plugins/autosave/index.js +0 -7
  99. package/templates/default/public/tinymce/plugins/autosave/plugin.js +0 -249
  100. package/templates/default/public/tinymce/plugins/autosave/plugin.min.js +0 -1
  101. package/templates/default/public/tinymce/plugins/charmap/index.js +0 -7
  102. package/templates/default/public/tinymce/plugins/charmap/plugin.js +0 -997
  103. package/templates/default/public/tinymce/plugins/charmap/plugin.min.js +0 -1
  104. package/templates/default/public/tinymce/plugins/code/index.js +0 -7
  105. package/templates/default/public/tinymce/plugins/code/plugin.js +0 -98
  106. package/templates/default/public/tinymce/plugins/code/plugin.min.js +0 -1
  107. package/templates/default/public/tinymce/plugins/codesample/index.js +0 -7
  108. package/templates/default/public/tinymce/plugins/codesample/plugin.js +0 -3655
  109. package/templates/default/public/tinymce/plugins/codesample/plugin.min.js +0 -9
  110. package/templates/default/public/tinymce/plugins/directionality/index.js +0 -7
  111. package/templates/default/public/tinymce/plugins/directionality/plugin.js +0 -634
  112. package/templates/default/public/tinymce/plugins/directionality/plugin.min.js +0 -1
  113. package/templates/default/public/tinymce/plugins/emoticons/index.js +0 -7
  114. package/templates/default/public/tinymce/plugins/emoticons/js/emojiimages.js +0 -1
  115. package/templates/default/public/tinymce/plugins/emoticons/js/emojiimages.min.js +0 -1
  116. package/templates/default/public/tinymce/plugins/emoticons/js/emojis.js +0 -1
  117. package/templates/default/public/tinymce/plugins/emoticons/js/emojis.min.js +0 -1
  118. package/templates/default/public/tinymce/plugins/emoticons/plugin.js +0 -809
  119. package/templates/default/public/tinymce/plugins/emoticons/plugin.min.js +0 -1
  120. package/templates/default/public/tinymce/plugins/fullscreen/index.js +0 -7
  121. package/templates/default/public/tinymce/plugins/fullscreen/plugin.js +0 -1607
  122. package/templates/default/public/tinymce/plugins/fullscreen/plugin.min.js +0 -1
  123. package/templates/default/public/tinymce/plugins/help/index.js +0 -7
  124. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ar.js +0 -93
  125. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/bg-BG.js +0 -93
  126. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/bg_BG.js +0 -93
  127. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ca.js +0 -93
  128. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/cs.js +0 -93
  129. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/da.js +0 -93
  130. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/de.js +0 -93
  131. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/el.js +0 -93
  132. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/en.js +0 -93
  133. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/es.js +0 -93
  134. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/eu.js +0 -93
  135. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/fa.js +0 -93
  136. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/fi.js +0 -93
  137. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/fr-FR.js +0 -93
  138. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/fr_FR.js +0 -93
  139. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/he-IL.js +0 -93
  140. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/he_IL.js +0 -93
  141. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/hi.js +0 -93
  142. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/hr.js +0 -93
  143. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/hu-HU.js +0 -93
  144. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/hu_HU.js +0 -93
  145. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/id.js +0 -93
  146. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/it.js +0 -93
  147. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ja.js +0 -93
  148. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/kk.js +0 -93
  149. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ko-KR.js +0 -93
  150. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ko_KR.js +0 -93
  151. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ms.js +0 -93
  152. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/nb-NO.js +0 -93
  153. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/nb_NO.js +0 -93
  154. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/nl.js +0 -93
  155. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/pl.js +0 -93
  156. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/pt-BR.js +0 -93
  157. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/pt-PT.js +0 -93
  158. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/pt_BR.js +0 -93
  159. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/pt_PT.js +0 -93
  160. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ro.js +0 -93
  161. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/ru.js +0 -93
  162. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/sk.js +0 -93
  163. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/sl-SI.js +0 -93
  164. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/sl_SI.js +0 -93
  165. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/sv-SE.js +0 -93
  166. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/sv_SE.js +0 -93
  167. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/th-TH.js +0 -93
  168. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/th_TH.js +0 -93
  169. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/tr.js +0 -93
  170. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/uk.js +0 -93
  171. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/vi.js +0 -93
  172. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/zh-CN.js +0 -87
  173. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/zh-TW.js +0 -93
  174. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/zh_CN.js +0 -87
  175. package/templates/default/public/tinymce/plugins/help/js/i18n/keynav/zh_TW.js +0 -93
  176. package/templates/default/public/tinymce/plugins/help/plugin.js +0 -826
  177. package/templates/default/public/tinymce/plugins/help/plugin.min.js +0 -1
  178. package/templates/default/public/tinymce/plugins/image/index.js +0 -7
  179. package/templates/default/public/tinymce/plugins/image/plugin.js +0 -1691
  180. package/templates/default/public/tinymce/plugins/image/plugin.min.js +0 -1
  181. package/templates/default/public/tinymce/plugins/importcss/index.js +0 -7
  182. package/templates/default/public/tinymce/plugins/importcss/plugin.js +0 -401
  183. package/templates/default/public/tinymce/plugins/importcss/plugin.min.js +0 -1
  184. package/templates/default/public/tinymce/plugins/insertdatetime/index.js +0 -7
  185. package/templates/default/public/tinymce/plugins/insertdatetime/plugin.js +0 -187
  186. package/templates/default/public/tinymce/plugins/insertdatetime/plugin.min.js +0 -1
  187. package/templates/default/public/tinymce/plugins/link/index.js +0 -7
  188. package/templates/default/public/tinymce/plugins/link/plugin.js +0 -1709
  189. package/templates/default/public/tinymce/plugins/link/plugin.min.js +0 -1
  190. package/templates/default/public/tinymce/plugins/lists/index.js +0 -7
  191. package/templates/default/public/tinymce/plugins/lists/plugin.js +0 -602
  192. package/templates/default/public/tinymce/plugins/lists/plugin.min.js +0 -1
  193. package/templates/default/public/tinymce/plugins/media/index.js +0 -7
  194. package/templates/default/public/tinymce/plugins/media/plugin.js +0 -1442
  195. package/templates/default/public/tinymce/plugins/media/plugin.min.js +0 -1
  196. package/templates/default/public/tinymce/plugins/nonbreaking/index.js +0 -7
  197. package/templates/default/public/tinymce/plugins/nonbreaking/plugin.js +0 -128
  198. package/templates/default/public/tinymce/plugins/nonbreaking/plugin.min.js +0 -1
  199. package/templates/default/public/tinymce/plugins/pagebreak/index.js +0 -7
  200. package/templates/default/public/tinymce/plugins/pagebreak/plugin.js +0 -123
  201. package/templates/default/public/tinymce/plugins/pagebreak/plugin.min.js +0 -1
  202. package/templates/default/public/tinymce/plugins/preview/index.js +0 -7
  203. package/templates/default/public/tinymce/plugins/preview/plugin.js +0 -843
  204. package/templates/default/public/tinymce/plugins/preview/plugin.min.js +0 -1
  205. package/templates/default/public/tinymce/plugins/quickbars/index.js +0 -7
  206. package/templates/default/public/tinymce/plugins/quickbars/plugin.js +0 -654
  207. package/templates/default/public/tinymce/plugins/quickbars/plugin.min.js +0 -1
  208. package/templates/default/public/tinymce/plugins/save/index.js +0 -7
  209. package/templates/default/public/tinymce/plugins/save/plugin.js +0 -136
  210. package/templates/default/public/tinymce/plugins/save/plugin.min.js +0 -1
  211. package/templates/default/public/tinymce/plugins/searchreplace/index.js +0 -7
  212. package/templates/default/public/tinymce/plugins/searchreplace/plugin.js +0 -1367
  213. package/templates/default/public/tinymce/plugins/searchreplace/plugin.min.js +0 -1
  214. package/templates/default/public/tinymce/plugins/table/index.js +0 -7
  215. package/templates/default/public/tinymce/plugins/table/plugin.js +0 -4008
  216. package/templates/default/public/tinymce/plugins/table/plugin.min.js +0 -1
  217. package/templates/default/public/tinymce/plugins/visualblocks/index.js +0 -7
  218. package/templates/default/public/tinymce/plugins/visualblocks/plugin.js +0 -106
  219. package/templates/default/public/tinymce/plugins/visualblocks/plugin.min.js +0 -1
  220. package/templates/default/public/tinymce/plugins/visualchars/index.js +0 -7
  221. package/templates/default/public/tinymce/plugins/visualchars/plugin.js +0 -808
  222. package/templates/default/public/tinymce/plugins/visualchars/plugin.min.js +0 -1
  223. package/templates/default/public/tinymce/plugins/wordcount/index.js +0 -7
  224. package/templates/default/public/tinymce/plugins/wordcount/plugin.js +0 -480
  225. package/templates/default/public/tinymce/plugins/wordcount/plugin.min.js +0 -1
  226. package/templates/default/public/tinymce/skins/content/dark/content.css +0 -75
  227. package/templates/default/public/tinymce/skins/content/dark/content.js +0 -10
  228. package/templates/default/public/tinymce/skins/content/dark/content.min.css +0 -10
  229. package/templates/default/public/tinymce/skins/content/dark/content.min.ts +0 -3
  230. package/templates/default/public/tinymce/skins/content/dark/content.ts +0 -3
  231. package/templates/default/public/tinymce/skins/content/default/content.css +0 -70
  232. package/templates/default/public/tinymce/skins/content/default/content.js +0 -10
  233. package/templates/default/public/tinymce/skins/content/default/content.min.css +0 -10
  234. package/templates/default/public/tinymce/skins/content/default/content.min.ts +0 -3
  235. package/templates/default/public/tinymce/skins/content/default/content.ts +0 -3
  236. package/templates/default/public/tinymce/skins/content/document/content.css +0 -75
  237. package/templates/default/public/tinymce/skins/content/document/content.js +0 -10
  238. package/templates/default/public/tinymce/skins/content/document/content.min.css +0 -10
  239. package/templates/default/public/tinymce/skins/content/document/content.min.ts +0 -3
  240. package/templates/default/public/tinymce/skins/content/document/content.ts +0 -3
  241. package/templates/default/public/tinymce/skins/content/tinymce-5/content.css +0 -70
  242. package/templates/default/public/tinymce/skins/content/tinymce-5/content.js +0 -10
  243. package/templates/default/public/tinymce/skins/content/tinymce-5/content.min.css +0 -10
  244. package/templates/default/public/tinymce/skins/content/tinymce-5/content.min.ts +0 -3
  245. package/templates/default/public/tinymce/skins/content/tinymce-5/content.ts +0 -3
  246. package/templates/default/public/tinymce/skins/content/tinymce-5-dark/content.css +0 -75
  247. package/templates/default/public/tinymce/skins/content/tinymce-5-dark/content.js +0 -10
  248. package/templates/default/public/tinymce/skins/content/tinymce-5-dark/content.min.css +0 -10
  249. package/templates/default/public/tinymce/skins/content/tinymce-5-dark/content.min.ts +0 -3
  250. package/templates/default/public/tinymce/skins/content/tinymce-5-dark/content.ts +0 -3
  251. package/templates/default/public/tinymce/skins/content/writer/content.css +0 -71
  252. package/templates/default/public/tinymce/skins/content/writer/content.js +0 -10
  253. package/templates/default/public/tinymce/skins/content/writer/content.min.css +0 -10
  254. package/templates/default/public/tinymce/skins/content/writer/content.min.ts +0 -3
  255. package/templates/default/public/tinymce/skins/content/writer/content.ts +0 -3
  256. package/templates/default/public/tinymce/skins/ui/oxide/content.css +0 -1037
  257. package/templates/default/public/tinymce/skins/ui/oxide/content.inline.css +0 -1031
  258. package/templates/default/public/tinymce/skins/ui/oxide/content.inline.js +0 -10
  259. package/templates/default/public/tinymce/skins/ui/oxide/content.inline.min.css +0 -10
  260. package/templates/default/public/tinymce/skins/ui/oxide/content.inline.min.ts +0 -116
  261. package/templates/default/public/tinymce/skins/ui/oxide/content.inline.ts +0 -116
  262. package/templates/default/public/tinymce/skins/ui/oxide/content.js +0 -10
  263. package/templates/default/public/tinymce/skins/ui/oxide/content.min.css +0 -10
  264. package/templates/default/public/tinymce/skins/ui/oxide/content.min.ts +0 -116
  265. package/templates/default/public/tinymce/skins/ui/oxide/content.ts +0 -116
  266. package/templates/default/public/tinymce/skins/ui/oxide/skin.css +0 -5615
  267. package/templates/default/public/tinymce/skins/ui/oxide/skin.js +0 -1
  268. package/templates/default/public/tinymce/skins/ui/oxide/skin.min.css +0 -1
  269. package/templates/default/public/tinymce/skins/ui/oxide/skin.min.ts +0 -507
  270. package/templates/default/public/tinymce/skins/ui/oxide/skin.shadowdom.css +0 -30
  271. package/templates/default/public/tinymce/skins/ui/oxide/skin.shadowdom.js +0 -1
  272. package/templates/default/public/tinymce/skins/ui/oxide/skin.shadowdom.min.css +0 -1
  273. package/templates/default/public/tinymce/skins/ui/oxide/skin.shadowdom.min.ts +0 -9
  274. package/templates/default/public/tinymce/skins/ui/oxide/skin.shadowdom.ts +0 -9
  275. package/templates/default/public/tinymce/skins/ui/oxide/skin.ts +0 -507
  276. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.css +0 -1025
  277. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.inline.css +0 -1031
  278. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.inline.js +0 -10
  279. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.inline.min.css +0 -10
  280. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.inline.min.ts +0 -116
  281. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.inline.ts +0 -116
  282. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.js +0 -10
  283. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.min.css +0 -10
  284. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.min.ts +0 -116
  285. package/templates/default/public/tinymce/skins/ui/oxide-dark/content.ts +0 -116
  286. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.css +0 -5618
  287. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.js +0 -1
  288. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.min.css +0 -1
  289. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.min.ts +0 -507
  290. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.css +0 -30
  291. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.js +0 -1
  292. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.css +0 -1
  293. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.ts +0 -9
  294. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.shadowdom.ts +0 -9
  295. package/templates/default/public/tinymce/skins/ui/oxide-dark/skin.ts +0 -507
  296. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.css +0 -1037
  297. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.inline.css +0 -1031
  298. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.inline.js +0 -10
  299. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.inline.min.css +0 -10
  300. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.inline.min.ts +0 -116
  301. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.inline.ts +0 -116
  302. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.js +0 -10
  303. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.min.css +0 -10
  304. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.min.ts +0 -116
  305. package/templates/default/public/tinymce/skins/ui/tinymce-5/content.ts +0 -116
  306. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.css +0 -5734
  307. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.js +0 -1
  308. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.min.css +0 -1
  309. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.min.ts +0 -508
  310. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.shadowdom.css +0 -30
  311. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.shadowdom.js +0 -1
  312. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.shadowdom.min.css +0 -1
  313. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.shadowdom.min.ts +0 -9
  314. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.shadowdom.ts +0 -9
  315. package/templates/default/public/tinymce/skins/ui/tinymce-5/skin.ts +0 -508
  316. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.css +0 -1025
  317. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.inline.css +0 -1031
  318. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.inline.js +0 -10
  319. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.inline.min.css +0 -10
  320. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.inline.min.ts +0 -116
  321. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.inline.ts +0 -116
  322. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.js +0 -10
  323. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.min.css +0 -10
  324. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.min.ts +0 -116
  325. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/content.ts +0 -116
  326. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.css +0 -5734
  327. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.js +0 -1
  328. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.min.css +0 -1
  329. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.min.ts +0 -508
  330. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.css +0 -30
  331. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.js +0 -1
  332. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.min.css +0 -1
  333. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.min.ts +0 -9
  334. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.ts +0 -9
  335. package/templates/default/public/tinymce/skins/ui/tinymce-5-dark/skin.ts +0 -508
  336. package/templates/default/public/tinymce/themes/silver/index.js +0 -7
  337. package/templates/default/public/tinymce/themes/silver/theme.js +0 -34748
  338. package/templates/default/public/tinymce/themes/silver/theme.min.js +0 -1
  339. package/templates/default/public/tinymce/tinymce.d.ts +0 -3413
  340. package/templates/default/public/tinymce/tinymce.js +0 -41518
  341. package/templates/default/public/tinymce/tinymce.min.js +0 -10
@@ -1,4008 +0,0 @@
1
- /**
2
- * TinyMCE version 8.3.1 (2025-12-17)
3
- */
4
-
5
- (function () {
6
- 'use strict';
7
-
8
- var global$3 = tinymce.util.Tools.resolve('tinymce.PluginManager');
9
-
10
- /* eslint-disable @typescript-eslint/no-wrapper-object-types */
11
- const hasProto = (v, constructor, predicate) => {
12
- if (predicate(v, constructor.prototype)) {
13
- return true;
14
- }
15
- else {
16
- // String-based fallback time
17
- return v.constructor?.name === constructor.name;
18
- }
19
- };
20
- const typeOf = (x) => {
21
- const t = typeof x;
22
- if (x === null) {
23
- return 'null';
24
- }
25
- else if (t === 'object' && Array.isArray(x)) {
26
- return 'array';
27
- }
28
- else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
29
- return 'string';
30
- }
31
- else {
32
- return t;
33
- }
34
- };
35
- const isType$1 = (type) => (value) => typeOf(value) === type;
36
- const isSimpleType = (type) => (value) => typeof value === type;
37
- const eq$1 = (t) => (a) => t === a;
38
- const isString = isType$1('string');
39
- const isArray = isType$1('array');
40
- const isBoolean = isSimpleType('boolean');
41
- const isUndefined = eq$1(undefined);
42
- const isNullable = (a) => a === null || a === undefined;
43
- const isNonNullable = (a) => !isNullable(a);
44
- const isFunction = isSimpleType('function');
45
- const isNumber = isSimpleType('number');
46
-
47
- const noop = () => { };
48
- /** Compose two unary functions. Similar to compose, but avoids using Function.prototype.apply. */
49
- const compose1 = (fbc, fab) => (a) => fbc(fab(a));
50
- const constant = (value) => {
51
- return () => {
52
- return value;
53
- };
54
- };
55
- const identity = (x) => {
56
- return x;
57
- };
58
- const tripleEquals = (a, b) => {
59
- return a === b;
60
- };
61
- function curry(fn, ...initialArgs) {
62
- return (...restArgs) => {
63
- const all = initialArgs.concat(restArgs);
64
- return fn.apply(null, all);
65
- };
66
- }
67
- const call = (f) => {
68
- f();
69
- };
70
- const never = constant(false);
71
- const always = constant(true);
72
-
73
- /**
74
- * The `Optional` type represents a value (of any type) that potentially does
75
- * not exist. Any `Optional<T>` can either be a `Some<T>` (in which case the
76
- * value does exist) or a `None` (in which case the value does not exist). This
77
- * module defines a whole lot of FP-inspired utility functions for dealing with
78
- * `Optional` objects.
79
- *
80
- * Comparison with null or undefined:
81
- * - We don't get fancy null coalescing operators with `Optional`
82
- * - We do get fancy helper functions with `Optional`
83
- * - `Optional` support nesting, and allow for the type to still be nullable (or
84
- * another `Optional`)
85
- * - There is no option to turn off strict-optional-checks like there is for
86
- * strict-null-checks
87
- */
88
- class Optional {
89
- tag;
90
- value;
91
- // Sneaky optimisation: every instance of Optional.none is identical, so just
92
- // reuse the same object
93
- static singletonNone = new Optional(false);
94
- // The internal representation has a `tag` and a `value`, but both are
95
- // private: able to be console.logged, but not able to be accessed by code
96
- constructor(tag, value) {
97
- this.tag = tag;
98
- this.value = value;
99
- }
100
- // --- Identities ---
101
- /**
102
- * Creates a new `Optional<T>` that **does** contain a value.
103
- */
104
- static some(value) {
105
- return new Optional(true, value);
106
- }
107
- /**
108
- * Create a new `Optional<T>` that **does not** contain a value. `T` can be
109
- * any type because we don't actually have a `T`.
110
- */
111
- static none() {
112
- return Optional.singletonNone;
113
- }
114
- /**
115
- * Perform a transform on an `Optional` type. Regardless of whether this
116
- * `Optional` contains a value or not, `fold` will return a value of type `U`.
117
- * If this `Optional` does not contain a value, the `U` will be created by
118
- * calling `onNone`. If this `Optional` does contain a value, the `U` will be
119
- * created by calling `onSome`.
120
- *
121
- * For the FP enthusiasts in the room, this function:
122
- * 1. Could be used to implement all of the functions below
123
- * 2. Forms a catamorphism
124
- */
125
- fold(onNone, onSome) {
126
- if (this.tag) {
127
- return onSome(this.value);
128
- }
129
- else {
130
- return onNone();
131
- }
132
- }
133
- /**
134
- * Determine if this `Optional` object contains a value.
135
- */
136
- isSome() {
137
- return this.tag;
138
- }
139
- /**
140
- * Determine if this `Optional` object **does not** contain a value.
141
- */
142
- isNone() {
143
- return !this.tag;
144
- }
145
- // --- Functor (name stolen from Haskell / maths) ---
146
- /**
147
- * Perform a transform on an `Optional` object, **if** there is a value. If
148
- * you provide a function to turn a T into a U, this is the function you use
149
- * to turn an `Optional<T>` into an `Optional<U>`. If this **does** contain
150
- * a value then the output will also contain a value (that value being the
151
- * output of `mapper(this.value)`), and if this **does not** contain a value
152
- * then neither will the output.
153
- */
154
- map(mapper) {
155
- if (this.tag) {
156
- return Optional.some(mapper(this.value));
157
- }
158
- else {
159
- return Optional.none();
160
- }
161
- }
162
- // --- Monad (name stolen from Haskell / maths) ---
163
- /**
164
- * Perform a transform on an `Optional` object, **if** there is a value.
165
- * Unlike `map`, here the transform itself also returns an `Optional`.
166
- */
167
- bind(binder) {
168
- if (this.tag) {
169
- return binder(this.value);
170
- }
171
- else {
172
- return Optional.none();
173
- }
174
- }
175
- // --- Traversable (name stolen from Haskell / maths) ---
176
- /**
177
- * For a given predicate, this function finds out if there **exists** a value
178
- * inside this `Optional` object that meets the predicate. In practice, this
179
- * means that for `Optional`s that do not contain a value it returns false (as
180
- * no predicate-meeting value exists).
181
- */
182
- exists(predicate) {
183
- return this.tag && predicate(this.value);
184
- }
185
- /**
186
- * For a given predicate, this function finds out if **all** the values inside
187
- * this `Optional` object meet the predicate. In practice, this means that
188
- * for `Optional`s that do not contain a value it returns true (as all 0
189
- * objects do meet the predicate).
190
- */
191
- forall(predicate) {
192
- return !this.tag || predicate(this.value);
193
- }
194
- filter(predicate) {
195
- if (!this.tag || predicate(this.value)) {
196
- return this;
197
- }
198
- else {
199
- return Optional.none();
200
- }
201
- }
202
- // --- Getters ---
203
- /**
204
- * Get the value out of the inside of the `Optional` object, using a default
205
- * `replacement` value if the provided `Optional` object does not contain a
206
- * value.
207
- */
208
- getOr(replacement) {
209
- return this.tag ? this.value : replacement;
210
- }
211
- /**
212
- * Get the value out of the inside of the `Optional` object, using a default
213
- * `replacement` value if the provided `Optional` object does not contain a
214
- * value. Unlike `getOr`, in this method the `replacement` object is also
215
- * `Optional` - meaning that this method will always return an `Optional`.
216
- */
217
- or(replacement) {
218
- return this.tag ? this : replacement;
219
- }
220
- /**
221
- * Get the value out of the inside of the `Optional` object, using a default
222
- * `replacement` value if the provided `Optional` object does not contain a
223
- * value. Unlike `getOr`, in this method the `replacement` value is
224
- * "thunked" - that is to say that you don't pass a value to `getOrThunk`, you
225
- * pass a function which (if called) will **return** the `value` you want to
226
- * use.
227
- */
228
- getOrThunk(thunk) {
229
- return this.tag ? this.value : thunk();
230
- }
231
- /**
232
- * Get the value out of the inside of the `Optional` object, using a default
233
- * `replacement` value if the provided Optional object does not contain a
234
- * value.
235
- *
236
- * Unlike `or`, in this method the `replacement` value is "thunked" - that is
237
- * to say that you don't pass a value to `orThunk`, you pass a function which
238
- * (if called) will **return** the `value` you want to use.
239
- *
240
- * Unlike `getOrThunk`, in this method the `replacement` value is also
241
- * `Optional`, meaning that this method will always return an `Optional`.
242
- */
243
- orThunk(thunk) {
244
- return this.tag ? this : thunk();
245
- }
246
- /**
247
- * Get the value out of the inside of the `Optional` object, throwing an
248
- * exception if the provided `Optional` object does not contain a value.
249
- *
250
- * WARNING:
251
- * You should only be using this function if you know that the `Optional`
252
- * object **is not** empty (otherwise you're throwing exceptions in production
253
- * code, which is bad).
254
- *
255
- * In tests this is more acceptable.
256
- *
257
- * Prefer other methods to this, such as `.each`.
258
- */
259
- getOrDie(message) {
260
- if (!this.tag) {
261
- throw new Error(message ?? 'Called getOrDie on None');
262
- }
263
- else {
264
- return this.value;
265
- }
266
- }
267
- // --- Interop with null and undefined ---
268
- /**
269
- * Creates an `Optional` value from a nullable (or undefined-able) input.
270
- * Null, or undefined, is converted to `None`, and anything else is converted
271
- * to `Some`.
272
- */
273
- static from(value) {
274
- return isNonNullable(value) ? Optional.some(value) : Optional.none();
275
- }
276
- /**
277
- * Converts an `Optional` to a nullable type, by getting the value if it
278
- * exists, or returning `null` if it does not.
279
- */
280
- getOrNull() {
281
- return this.tag ? this.value : null;
282
- }
283
- /**
284
- * Converts an `Optional` to an undefined-able type, by getting the value if
285
- * it exists, or returning `undefined` if it does not.
286
- */
287
- getOrUndefined() {
288
- return this.value;
289
- }
290
- // --- Utilities ---
291
- /**
292
- * If the `Optional` contains a value, perform an action on that value.
293
- * Unlike the rest of the methods on this type, `.each` has side-effects. If
294
- * you want to transform an `Optional<T>` **into** something, then this is not
295
- * the method for you. If you want to use an `Optional<T>` to **do**
296
- * something, then this is the method for you - provided you're okay with not
297
- * doing anything in the case where the `Optional` doesn't have a value inside
298
- * it. If you're not sure whether your use-case fits into transforming
299
- * **into** something or **doing** something, check whether it has a return
300
- * value. If it does, you should be performing a transform.
301
- */
302
- each(worker) {
303
- if (this.tag) {
304
- worker(this.value);
305
- }
306
- }
307
- /**
308
- * Turn the `Optional` object into an array that contains all of the values
309
- * stored inside the `Optional`. In practice, this means the output will have
310
- * either 0 or 1 elements.
311
- */
312
- toArray() {
313
- return this.tag ? [this.value] : [];
314
- }
315
- /**
316
- * Turn the `Optional` object into a string for debugging or printing. Not
317
- * recommended for production code, but good for debugging. Also note that
318
- * these days an `Optional` object can be logged to the console directly, and
319
- * its inner value (if it exists) will be visible.
320
- */
321
- toString() {
322
- return this.tag ? `some(${this.value})` : 'none()';
323
- }
324
- }
325
-
326
- const nativeSlice = Array.prototype.slice;
327
- const nativeIndexOf = Array.prototype.indexOf;
328
- const nativePush = Array.prototype.push;
329
- const rawIndexOf = (ts, t) => nativeIndexOf.call(ts, t);
330
- const contains = (xs, x) => rawIndexOf(xs, x) > -1;
331
- const exists = (xs, pred) => {
332
- for (let i = 0, len = xs.length; i < len; i++) {
333
- const x = xs[i];
334
- if (pred(x, i)) {
335
- return true;
336
- }
337
- }
338
- return false;
339
- };
340
- const range = (num, f) => {
341
- const r = [];
342
- for (let i = 0; i < num; i++) {
343
- r.push(f(i));
344
- }
345
- return r;
346
- };
347
- const map = (xs, f) => {
348
- // pre-allocating array size when it's guaranteed to be known
349
- // http://jsperf.com/push-allocated-vs-dynamic/22
350
- const len = xs.length;
351
- const r = new Array(len);
352
- for (let i = 0; i < len; i++) {
353
- const x = xs[i];
354
- r[i] = f(x, i);
355
- }
356
- return r;
357
- };
358
- // Unwound implementing other functions in terms of each.
359
- // The code size is roughly the same, and it should allow for better optimisation.
360
- // const each = function<T, U>(xs: T[], f: (x: T, i?: number, xs?: T[]) => void): void {
361
- const each$1 = (xs, f) => {
362
- for (let i = 0, len = xs.length; i < len; i++) {
363
- const x = xs[i];
364
- f(x, i);
365
- }
366
- };
367
- const eachr = (xs, f) => {
368
- for (let i = xs.length - 1; i >= 0; i--) {
369
- const x = xs[i];
370
- f(x, i);
371
- }
372
- };
373
- const partition = (xs, pred) => {
374
- const pass = [];
375
- const fail = [];
376
- for (let i = 0, len = xs.length; i < len; i++) {
377
- const x = xs[i];
378
- const arr = pred(x, i) ? pass : fail;
379
- arr.push(x);
380
- }
381
- return { pass, fail };
382
- };
383
- const filter$1 = (xs, pred) => {
384
- const r = [];
385
- for (let i = 0, len = xs.length; i < len; i++) {
386
- const x = xs[i];
387
- if (pred(x, i)) {
388
- r.push(x);
389
- }
390
- }
391
- return r;
392
- };
393
- const foldr = (xs, f, acc) => {
394
- eachr(xs, (x, i) => {
395
- acc = f(acc, x, i);
396
- });
397
- return acc;
398
- };
399
- const foldl = (xs, f, acc) => {
400
- each$1(xs, (x, i) => {
401
- acc = f(acc, x, i);
402
- });
403
- return acc;
404
- };
405
- const findUntil = (xs, pred, until) => {
406
- for (let i = 0, len = xs.length; i < len; i++) {
407
- const x = xs[i];
408
- if (pred(x, i)) {
409
- return Optional.some(x);
410
- }
411
- else if (until(x, i)) {
412
- break;
413
- }
414
- }
415
- return Optional.none();
416
- };
417
- const find = (xs, pred) => {
418
- return findUntil(xs, pred, never);
419
- };
420
- const findIndex = (xs, pred) => {
421
- for (let i = 0, len = xs.length; i < len; i++) {
422
- const x = xs[i];
423
- if (pred(x, i)) {
424
- return Optional.some(i);
425
- }
426
- }
427
- return Optional.none();
428
- };
429
- const flatten$1 = (xs) => {
430
- // Note, this is possible because push supports multiple arguments:
431
- // http://jsperf.com/concat-push/6
432
- // Note that in the past, concat() would silently work (very slowly) for array-like objects.
433
- // With this change it will throw an error.
434
- const r = [];
435
- for (let i = 0, len = xs.length; i < len; ++i) {
436
- // Ensure that each value is an array itself
437
- if (!isArray(xs[i])) {
438
- throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
439
- }
440
- nativePush.apply(r, xs[i]);
441
- }
442
- return r;
443
- };
444
- const bind = (xs, f) => flatten$1(map(xs, f));
445
- const forall = (xs, pred) => {
446
- for (let i = 0, len = xs.length; i < len; ++i) {
447
- const x = xs[i];
448
- if (pred(x, i) !== true) {
449
- return false;
450
- }
451
- }
452
- return true;
453
- };
454
- const mapToObject = (xs, f) => {
455
- const r = {};
456
- for (let i = 0, len = xs.length; i < len; i++) {
457
- const x = xs[i];
458
- r[String(x)] = f(x, i);
459
- }
460
- return r;
461
- };
462
- const get$4 = (xs, i) => i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
463
- const head = (xs) => get$4(xs, 0);
464
- const last = (xs) => get$4(xs, xs.length - 1);
465
- isFunction(Array.from) ? Array.from : (x) => nativeSlice.call(x);
466
- const findMap = (arr, f) => {
467
- for (let i = 0; i < arr.length; i++) {
468
- const r = f(arr[i], i);
469
- if (r.isSome()) {
470
- return r;
471
- }
472
- }
473
- return Optional.none();
474
- };
475
-
476
- // There are many variations of Object iteration that are faster than the 'for-in' style:
477
- // http://jsperf.com/object-keys-iteration/107
478
- //
479
- // Use the native keys if it is available (IE9+), otherwise fall back to manually filtering
480
- const keys = Object.keys;
481
- const hasOwnProperty = Object.hasOwnProperty;
482
- const each = (obj, f) => {
483
- const props = keys(obj);
484
- for (let k = 0, len = props.length; k < len; k++) {
485
- const i = props[k];
486
- const x = obj[i];
487
- f(x, i);
488
- }
489
- };
490
- const objAcc = (r) => (x, i) => {
491
- r[i] = x;
492
- };
493
- const internalFilter = (obj, pred, onTrue, onFalse) => {
494
- each(obj, (x, i) => {
495
- (pred(x, i) ? onTrue : onFalse)(x, i);
496
- });
497
- };
498
- const filter = (obj, pred) => {
499
- const t = {};
500
- internalFilter(obj, pred, objAcc(t), noop);
501
- return t;
502
- };
503
- const mapToArray = (obj, f) => {
504
- const r = [];
505
- each(obj, (value, name) => {
506
- r.push(f(value, name));
507
- });
508
- return r;
509
- };
510
- const values = (obj) => {
511
- return mapToArray(obj, identity);
512
- };
513
- const size = (obj) => {
514
- return keys(obj).length;
515
- };
516
- const get$3 = (obj, key) => {
517
- return has(obj, key) ? Optional.from(obj[key]) : Optional.none();
518
- };
519
- const has = (obj, key) => hasOwnProperty.call(obj, key);
520
- const hasNonNullableKey = (obj, key) => has(obj, key) && obj[key] !== undefined && obj[key] !== null;
521
- const isEmpty$1 = (r) => {
522
- for (const x in r) {
523
- if (hasOwnProperty.call(r, x)) {
524
- return false;
525
- }
526
- }
527
- return true;
528
- };
529
-
530
- const Cell = (initial) => {
531
- let value = initial;
532
- const get = () => {
533
- return value;
534
- };
535
- const set = (v) => {
536
- value = v;
537
- };
538
- return {
539
- get,
540
- set
541
- };
542
- };
543
-
544
- /**
545
- * **Is** the value stored inside this Optional object equal to `rhs`?
546
- */
547
- const is$2 = (lhs, rhs, comparator = tripleEquals) => lhs.exists((left) => comparator(left, rhs));
548
- const cat = (arr) => {
549
- const r = [];
550
- const push = (x) => {
551
- r.push(x);
552
- };
553
- for (let i = 0; i < arr.length; i++) {
554
- arr[i].each(push);
555
- }
556
- return r;
557
- };
558
- /*
559
- Notes on the lift functions:
560
- - We used to have a generic liftN, but we were concerned about its type-safety, and the below variants were faster in microbenchmarks.
561
- - The getOrDie calls are partial functions, but are checked beforehand. This is faster and more convenient (but less safe) than folds.
562
- - && is used instead of a loop for simplicity and performance.
563
- */
564
- const lift2 = (oa, ob, f) => oa.isSome() && ob.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie())) : Optional.none();
565
- const flatten = (oot) => oot.bind(identity);
566
- // This can help with type inference, by specifying the type param on the none case, so the caller doesn't have to.
567
- const someIf = (b, a) => b ? Optional.some(a) : Optional.none();
568
-
569
- const singleton = (doRevoke) => {
570
- const subject = Cell(Optional.none());
571
- const revoke = () => subject.get().each(doRevoke);
572
- const clear = () => {
573
- revoke();
574
- subject.set(Optional.none());
575
- };
576
- const isSet = () => subject.get().isSome();
577
- const get = () => subject.get();
578
- const set = (s) => {
579
- revoke();
580
- subject.set(Optional.some(s));
581
- };
582
- return {
583
- clear,
584
- isSet,
585
- get,
586
- set
587
- };
588
- };
589
- const unbindable = () => singleton((s) => s.unbind());
590
-
591
- const removeFromStart = (str, numChars) => {
592
- return str.substring(numChars);
593
- };
594
-
595
- const checkRange = (str, substr, start) => substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
596
- const removeLeading = (str, prefix) => {
597
- return startsWith(str, prefix) ? removeFromStart(str, prefix.length) : str;
598
- };
599
- /** Does 'str' start with 'prefix'?
600
- * Note: all strings start with the empty string.
601
- * More formally, for all strings x, startsWith(x, "").
602
- * This is so that for all strings x and y, startsWith(y + x, y)
603
- */
604
- const startsWith = (str, prefix) => {
605
- return checkRange(str, prefix, 0);
606
- };
607
- const blank = (r) => (s) => s.replace(r, '');
608
- /** removes all leading and trailing spaces */
609
- const trim = blank(/^\s+|\s+$/g);
610
- const isNotEmpty = (s) => s.length > 0;
611
- const isEmpty = (s) => !isNotEmpty(s);
612
- const toInt = (value, radix = 10) => {
613
- const num = parseInt(value, radix);
614
- return isNaN(num) ? Optional.none() : Optional.some(num);
615
- };
616
- const toFloat = (value) => {
617
- const num = parseFloat(value);
618
- return isNaN(num) ? Optional.none() : Optional.some(num);
619
- };
620
-
621
- const cached = (f) => {
622
- let called = false;
623
- let r;
624
- return (...args) => {
625
- if (!called) {
626
- called = true;
627
- r = f.apply(null, args);
628
- }
629
- return r;
630
- };
631
- };
632
-
633
- const fromHtml = (html, scope) => {
634
- const doc = scope || document;
635
- const div = doc.createElement('div');
636
- div.innerHTML = html;
637
- if (!div.hasChildNodes() || div.childNodes.length > 1) {
638
- const message = 'HTML does not have a single root node';
639
- // eslint-disable-next-line no-console
640
- console.error(message, html);
641
- throw new Error(message);
642
- }
643
- return fromDom$1(div.childNodes[0]);
644
- };
645
- const fromTag = (tag, scope) => {
646
- const doc = scope || document;
647
- const node = doc.createElement(tag);
648
- return fromDom$1(node);
649
- };
650
- const fromText = (text, scope) => {
651
- const doc = scope || document;
652
- const node = doc.createTextNode(text);
653
- return fromDom$1(node);
654
- };
655
- const fromDom$1 = (node) => {
656
- // TODO: Consider removing this check, but left atm for safety
657
- if (node === null || node === undefined) {
658
- throw new Error('Node cannot be null or undefined');
659
- }
660
- return {
661
- dom: node
662
- };
663
- };
664
- const fromPoint = (docElm, x, y) => Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom$1);
665
- // tslint:disable-next-line:variable-name
666
- const SugarElement = {
667
- fromHtml,
668
- fromTag,
669
- fromText,
670
- fromDom: fromDom$1,
671
- fromPoint
672
- };
673
-
674
- const COMMENT = 8;
675
- const DOCUMENT = 9;
676
- const DOCUMENT_FRAGMENT = 11;
677
- const ELEMENT = 1;
678
- const TEXT = 3;
679
-
680
- const is$1 = (element, selector) => {
681
- const dom = element.dom;
682
- if (dom.nodeType !== ELEMENT) {
683
- return false;
684
- }
685
- else {
686
- const elem = dom;
687
- if (elem.matches !== undefined) {
688
- return elem.matches(selector);
689
- }
690
- else if (elem.msMatchesSelector !== undefined) {
691
- return elem.msMatchesSelector(selector);
692
- }
693
- else if (elem.webkitMatchesSelector !== undefined) {
694
- return elem.webkitMatchesSelector(selector);
695
- }
696
- else if (elem.mozMatchesSelector !== undefined) {
697
- // cast to any as mozMatchesSelector doesn't exist in TS DOM lib
698
- return elem.mozMatchesSelector(selector);
699
- }
700
- else {
701
- throw new Error('Browser lacks native selectors');
702
- } // unfortunately we can't throw this on startup :(
703
- }
704
- };
705
- const bypassSelector = (dom) =>
706
- // Only elements, documents and shadow roots support querySelector
707
- // shadow root element type is DOCUMENT_FRAGMENT
708
- dom.nodeType !== ELEMENT && dom.nodeType !== DOCUMENT && dom.nodeType !== DOCUMENT_FRAGMENT ||
709
- // IE fix for complex queries on empty nodes: http://jsfiddle.net/spyder/fv9ptr5L/
710
- dom.childElementCount === 0;
711
- const all$1 = (selector, scope) => {
712
- const base = scope === undefined ? document : scope.dom;
713
- return bypassSelector(base) ? [] : map(base.querySelectorAll(selector), SugarElement.fromDom);
714
- };
715
- const one = (selector, scope) => {
716
- const base = scope === undefined ? document : scope.dom;
717
- return bypassSelector(base) ? Optional.none() : Optional.from(base.querySelector(selector)).map(SugarElement.fromDom);
718
- };
719
-
720
- const eq = (e1, e2) => e1.dom === e2.dom;
721
- const is = is$1;
722
-
723
- const name = (element) => {
724
- const r = element.dom.nodeName;
725
- return r.toLowerCase();
726
- };
727
- const type = (element) => element.dom.nodeType;
728
- const isType = (t) => (element) => type(element) === t;
729
- const isComment = (element) => type(element) === COMMENT || name(element) === '#comment';
730
- const isElement = isType(ELEMENT);
731
- const isText = isType(TEXT);
732
- const isDocument = isType(DOCUMENT);
733
- const isDocumentFragment = isType(DOCUMENT_FRAGMENT);
734
- const isTag = (tag) => (e) => isElement(e) && name(e) === tag;
735
-
736
- /**
737
- * The document associated with the current element
738
- * NOTE: this will throw if the owner is null.
739
- */
740
- const owner = (element) => SugarElement.fromDom(element.dom.ownerDocument);
741
- /**
742
- * If the element is a document, return it. Otherwise, return its ownerDocument.
743
- * @param dos
744
- */
745
- const documentOrOwner = (dos) => isDocument(dos) ? dos : owner(dos);
746
- const parent = (element) => Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
747
- const parents = (element, isRoot) => {
748
- const stop = isFunction(isRoot) ? isRoot : never;
749
- // This is used a *lot* so it needs to be performant, not recursive
750
- let dom = element.dom;
751
- const ret = [];
752
- while (dom.parentNode !== null && dom.parentNode !== undefined) {
753
- const rawParent = dom.parentNode;
754
- const p = SugarElement.fromDom(rawParent);
755
- ret.push(p);
756
- if (stop(p) === true) {
757
- break;
758
- }
759
- else {
760
- dom = rawParent;
761
- }
762
- }
763
- return ret;
764
- };
765
- const prevSibling = (element) => Optional.from(element.dom.previousSibling).map(SugarElement.fromDom);
766
- const nextSibling = (element) => Optional.from(element.dom.nextSibling).map(SugarElement.fromDom);
767
- const children$3 = (element) => map(element.dom.childNodes, SugarElement.fromDom);
768
- const child$3 = (element, index) => {
769
- const cs = element.dom.childNodes;
770
- return Optional.from(cs[index]).map(SugarElement.fromDom);
771
- };
772
- const firstChild = (element) => child$3(element, 0);
773
-
774
- /**
775
- * Is the element a ShadowRoot?
776
- *
777
- * Note: this is insufficient to test if any element is a shadow root, but it is sufficient to differentiate between
778
- * a Document and a ShadowRoot.
779
- */
780
- const isShadowRoot = (dos) => isDocumentFragment(dos) && isNonNullable(dos.dom.host);
781
- const getRootNode = (e) => SugarElement.fromDom(e.dom.getRootNode());
782
- /** If this element is in a ShadowRoot, return it. */
783
- const getShadowRoot = (e) => {
784
- const r = getRootNode(e);
785
- return isShadowRoot(r) ? Optional.some(r) : Optional.none();
786
- };
787
- /** Return the host of a ShadowRoot.
788
- *
789
- * This function will throw if Shadow DOM is unsupported in the browser, or if the host is null.
790
- * If you actually have a ShadowRoot, this shouldn't happen.
791
- */
792
- const getShadowHost = (e) => SugarElement.fromDom(e.dom.host);
793
-
794
- const before = (marker, element) => {
795
- const parent$1 = parent(marker);
796
- parent$1.each((v) => {
797
- v.dom.insertBefore(element.dom, marker.dom);
798
- });
799
- };
800
- const after$1 = (marker, element) => {
801
- const sibling = nextSibling(marker);
802
- sibling.fold(() => {
803
- const parent$1 = parent(marker);
804
- parent$1.each((v) => {
805
- append$1(v, element);
806
- });
807
- }, (v) => {
808
- before(v, element);
809
- });
810
- };
811
- const prepend = (parent, element) => {
812
- const firstChild$1 = firstChild(parent);
813
- firstChild$1.fold(() => {
814
- append$1(parent, element);
815
- }, (v) => {
816
- parent.dom.insertBefore(element.dom, v.dom);
817
- });
818
- };
819
- const append$1 = (parent, element) => {
820
- parent.dom.appendChild(element.dom);
821
- };
822
- const wrap = (element, wrapper) => {
823
- before(element, wrapper);
824
- append$1(wrapper, element);
825
- };
826
-
827
- const after = (marker, elements) => {
828
- each$1(elements, (x, i) => {
829
- const e = i === 0 ? marker : elements[i - 1];
830
- after$1(e, x);
831
- });
832
- };
833
- const append = (parent, elements) => {
834
- each$1(elements, (x) => {
835
- append$1(parent, x);
836
- });
837
- };
838
-
839
- const rawSet = (dom, key, value) => {
840
- /*
841
- * JQuery coerced everything to a string, and silently did nothing on text node/null/undefined.
842
- *
843
- * We fail on those invalid cases, only allowing numbers and booleans.
844
- */
845
- if (isString(value) || isBoolean(value) || isNumber(value)) {
846
- dom.setAttribute(key, value + '');
847
- }
848
- else {
849
- // eslint-disable-next-line no-console
850
- console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
851
- throw new Error('Attribute value was not simple');
852
- }
853
- };
854
- const set$2 = (element, key, value) => {
855
- rawSet(element.dom, key, value);
856
- };
857
- const setAll = (element, attrs) => {
858
- const dom = element.dom;
859
- each(attrs, (v, k) => {
860
- rawSet(dom, k, v);
861
- });
862
- };
863
- const get$2 = (element, key) => {
864
- const v = element.dom.getAttribute(key);
865
- // undefined is the more appropriate value for JS, and this matches JQuery
866
- return v === null ? undefined : v;
867
- };
868
- const getOpt = (element, key) => Optional.from(get$2(element, key));
869
- const remove$2 = (element, key) => {
870
- element.dom.removeAttribute(key);
871
- };
872
- const clone = (element) => foldl(element.dom.attributes, (acc, attr) => {
873
- acc[attr.name] = attr.value;
874
- return acc;
875
- }, {});
876
-
877
- const remove$1 = (element) => {
878
- const dom = element.dom;
879
- if (dom.parentNode !== null) {
880
- dom.parentNode.removeChild(dom);
881
- }
882
- };
883
- const unwrap = (wrapper) => {
884
- const children = children$3(wrapper);
885
- if (children.length > 0) {
886
- after(wrapper, children);
887
- }
888
- remove$1(wrapper);
889
- };
890
-
891
- const fromDom = (nodes) => map(nodes, SugarElement.fromDom);
892
-
893
- // some elements, such as mathml, don't have style attributes
894
- // others, such as angular elements, have style attributes that aren't a CSSStyleDeclaration
895
- const isSupported = (dom) => dom.style !== undefined && isFunction(dom.style.getPropertyValue);
896
-
897
- // Node.contains() is very, very, very good performance
898
- // http://jsperf.com/closest-vs-contains/5
899
- const inBody = (element) => {
900
- // Technically this is only required on IE, where contains() returns false for text nodes.
901
- // But it's cheap enough to run everywhere and Sugar doesn't have platform detection (yet).
902
- const dom = isText(element) ? element.dom.parentNode : element.dom;
903
- // use ownerDocument.body to ensure this works inside iframes.
904
- // Normally contains is bad because an element "contains" itself, but here we want that.
905
- if (dom === undefined || dom === null || dom.ownerDocument === null) {
906
- return false;
907
- }
908
- const doc = dom.ownerDocument;
909
- return getShadowRoot(SugarElement.fromDom(dom)).fold(() => doc.body.contains(dom), compose1(inBody, getShadowHost));
910
- };
911
-
912
- const internalSet = (dom, property, value) => {
913
- // This is going to hurt. Apologies.
914
- // JQuery coerces numbers to pixels for certain property names, and other times lets numbers through.
915
- // we're going to be explicit; strings only.
916
- if (!isString(value)) {
917
- // eslint-disable-next-line no-console
918
- console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);
919
- throw new Error('CSS value must be a string: ' + value);
920
- }
921
- // removed: support for dom().style[property] where prop is camel case instead of normal property name
922
- if (isSupported(dom)) {
923
- dom.style.setProperty(property, value);
924
- }
925
- };
926
- const internalRemove = (dom, property) => {
927
- /*
928
- * IE9 and above - MDN doesn't have details, but here's a couple of random internet claims
929
- *
930
- * http://help.dottoro.com/ljopsjck.php
931
- * http://stackoverflow.com/a/7901886/7546
932
- */
933
- if (isSupported(dom)) {
934
- dom.style.removeProperty(property);
935
- }
936
- };
937
- const set$1 = (element, property, value) => {
938
- const dom = element.dom;
939
- internalSet(dom, property, value);
940
- };
941
- /*
942
- * NOTE: For certain properties, this returns the "used value" which is subtly different to the "computed value" (despite calling getComputedStyle).
943
- * Blame CSS 2.0.
944
- *
945
- * https://developer.mozilla.org/en-US/docs/Web/CSS/used_value
946
- */
947
- const get$1 = (element, property) => {
948
- const dom = element.dom;
949
- /*
950
- * IE9 and above per
951
- * https://developer.mozilla.org/en/docs/Web/API/window.getComputedStyle
952
- *
953
- * Not in numerosity, because it doesn't memoize and looking this up dynamically in performance critical code would be horrendous.
954
- *
955
- * JQuery has some magic here for IE popups, but we don't really need that.
956
- * It also uses element.ownerDocument.defaultView to handle iframes but that hasn't been required since FF 3.6.
957
- */
958
- const styles = window.getComputedStyle(dom);
959
- const r = styles.getPropertyValue(property);
960
- // jquery-ism: If r is an empty string, check that the element is not in a document. If it isn't, return the raw value.
961
- // Turns out we do this a lot.
962
- return (r === '' && !inBody(element)) ? getUnsafeProperty(dom, property) : r;
963
- };
964
- // removed: support for dom().style[property] where prop is camel case instead of normal property name
965
- // empty string is what the browsers (IE11 and Chrome) return when the propertyValue doesn't exists.
966
- const getUnsafeProperty = (dom, property) => isSupported(dom) ? dom.style.getPropertyValue(property) : '';
967
- /*
968
- * Gets the raw value from the style attribute. Useful for retrieving "used values" from the DOM:
969
- * https://developer.mozilla.org/en-US/docs/Web/CSS/used_value
970
- *
971
- * Returns NONE if the property isn't set, or the value is an empty string.
972
- */
973
- const getRaw$1 = (element, property) => {
974
- const dom = element.dom;
975
- const raw = getUnsafeProperty(dom, property);
976
- return Optional.from(raw).filter((r) => r.length > 0);
977
- };
978
- const remove = (element, property) => {
979
- const dom = element.dom;
980
- internalRemove(dom, property);
981
- if (is$2(getOpt(element, 'style').map(trim), '')) {
982
- // No more styles left, remove the style attribute as well
983
- remove$2(element, 'style');
984
- }
985
- };
986
-
987
- const Dimension = (name, getOffset) => {
988
- const set = (element, h) => {
989
- if (!isNumber(h) && !h.match(/^[0-9]+$/)) {
990
- throw new Error(name + '.set accepts only positive integer values. Value was ' + h);
991
- }
992
- const dom = element.dom;
993
- if (isSupported(dom)) {
994
- dom.style[name] = h + 'px';
995
- }
996
- };
997
- /*
998
- * jQuery supports querying width and height on the document and window objects.
999
- *
1000
- * TBIO doesn't do this, so the code is removed to save space, but left here just in case.
1001
- */
1002
- /*
1003
- var getDocumentWidth = (element) => {
1004
- var dom = element.dom;
1005
- if (Node.isDocument(element)) {
1006
- var body = dom.body;
1007
- var doc = dom.documentElement;
1008
- return Math.max(
1009
- body.scrollHeight,
1010
- doc.scrollHeight,
1011
- body.offsetHeight,
1012
- doc.offsetHeight,
1013
- doc.clientHeight
1014
- );
1015
- }
1016
- };
1017
-
1018
- var getWindowWidth = (element) => {
1019
- var dom = element.dom;
1020
- if (dom.window === dom) {
1021
- // There is no offsetHeight on a window, so use the clientHeight of the document
1022
- return dom.document.documentElement.clientHeight;
1023
- }
1024
- };
1025
- */
1026
- const get = (element) => {
1027
- const r = getOffset(element);
1028
- // zero or null means non-standard or disconnected, fall back to CSS
1029
- if (r <= 0 || r === null) {
1030
- const css = get$1(element, name);
1031
- // ugh this feels dirty, but it saves cycles
1032
- return parseFloat(css) || 0;
1033
- }
1034
- return r;
1035
- };
1036
- // in jQuery, getOuter replicates (or uses) box-sizing: border-box calculations
1037
- // although these calculations only seem relevant for quirks mode, and edge cases TBIO doesn't rely on
1038
- const getOuter = get;
1039
- const aggregate = (element, properties) => foldl(properties, (acc, property) => {
1040
- const val = get$1(element, property);
1041
- const value = val === undefined ? 0 : parseInt(val, 10);
1042
- return isNaN(value) ? acc : acc + value;
1043
- }, 0);
1044
- const max = (element, value, properties) => {
1045
- const cumulativeInclusions = aggregate(element, properties);
1046
- // if max-height is 100px and your cumulativeInclusions is 150px, there is no way max-height can be 100px, so we return 0.
1047
- const absoluteMax = value > cumulativeInclusions ? value - cumulativeInclusions : 0;
1048
- return absoluteMax;
1049
- };
1050
- return {
1051
- set,
1052
- get,
1053
- getOuter,
1054
- aggregate,
1055
- max
1056
- };
1057
- };
1058
-
1059
- const toNumber = (px, fallback) => toFloat(px).getOr(fallback);
1060
- const getProp = (element, name, fallback) => toNumber(get$1(element, name), fallback);
1061
- const calcContentBoxSize = (element, size, upper, lower) => {
1062
- const paddingUpper = getProp(element, `padding-${upper}`, 0);
1063
- const paddingLower = getProp(element, `padding-${lower}`, 0);
1064
- const borderUpper = getProp(element, `border-${upper}-width`, 0);
1065
- const borderLower = getProp(element, `border-${lower}-width`, 0);
1066
- return size - paddingUpper - paddingLower - borderUpper - borderLower;
1067
- };
1068
- const getCalculatedWidth = (element, boxSizing) => {
1069
- const dom = element.dom;
1070
- const width = dom.getBoundingClientRect().width || dom.offsetWidth;
1071
- return boxSizing === 'border-box' ? width : calcContentBoxSize(element, width, 'left', 'right');
1072
- };
1073
- const getInnerWidth = (element) => getCalculatedWidth(element, 'content-box');
1074
-
1075
- Dimension('width', (element) => {
1076
- const dom = element.dom;
1077
- return inBody(element) ? dom.getBoundingClientRect().width : dom.offsetWidth;
1078
- });
1079
- const getInner = getInnerWidth;
1080
-
1081
- const NodeValue = (is, name) => {
1082
- const get = (element) => {
1083
- if (!is(element)) {
1084
- throw new Error('Can only get ' + name + ' value of a ' + name + ' node');
1085
- }
1086
- return getOption(element).getOr('');
1087
- };
1088
- const getOption = (element) => is(element) ? Optional.from(element.dom.nodeValue) : Optional.none();
1089
- const set = (element, value) => {
1090
- if (!is(element)) {
1091
- throw new Error('Can only set raw ' + name + ' value of a ' + name + ' node');
1092
- }
1093
- element.dom.nodeValue = value;
1094
- };
1095
- return {
1096
- get,
1097
- getOption,
1098
- set
1099
- };
1100
- };
1101
-
1102
- const api = NodeValue(isText, 'text');
1103
- const get = (element) => api.get(element);
1104
- const set = (element, value) => api.set(element, value);
1105
-
1106
- var ClosestOrAncestor = (is, ancestor, scope, a, isRoot) => {
1107
- if (is(scope, a)) {
1108
- return Optional.some(scope);
1109
- }
1110
- else if (isFunction(isRoot) && isRoot(scope)) {
1111
- return Optional.none();
1112
- }
1113
- else {
1114
- return ancestor(scope, a, isRoot);
1115
- }
1116
- };
1117
-
1118
- const ancestor$1 = (scope, predicate, isRoot) => {
1119
- let element = scope.dom;
1120
- const stop = isFunction(isRoot) ? isRoot : never;
1121
- while (element.parentNode) {
1122
- element = element.parentNode;
1123
- const el = SugarElement.fromDom(element);
1124
- if (predicate(el)) {
1125
- return Optional.some(el);
1126
- }
1127
- else if (stop(el)) {
1128
- break;
1129
- }
1130
- }
1131
- return Optional.none();
1132
- };
1133
- const closest$2 = (scope, predicate, isRoot) => {
1134
- // This is required to avoid ClosestOrAncestor passing the predicate to itself
1135
- const is = (s, test) => test(s);
1136
- return ClosestOrAncestor(is, ancestor$1, scope, predicate, isRoot);
1137
- };
1138
- const child$2 = (scope, predicate) => {
1139
- const pred = (node) => predicate(SugarElement.fromDom(node));
1140
- const result = find(scope.dom.childNodes, pred);
1141
- return result.map(SugarElement.fromDom);
1142
- };
1143
-
1144
- const ancestor = (scope, selector, isRoot) => ancestor$1(scope, (e) => is$1(e, selector), isRoot);
1145
- const child$1 = (scope, selector) => child$2(scope, (e) => is$1(e, selector));
1146
- const descendant = (scope, selector) => one(selector, scope);
1147
- // Returns Some(closest ancestor element (sugared)) matching 'selector' up to isRoot, or None() otherwise
1148
- const closest$1 = (scope, selector, isRoot) => {
1149
- const is = (element, selector) => is$1(element, selector);
1150
- return ClosestOrAncestor(is, ancestor, scope, selector, isRoot);
1151
- };
1152
-
1153
- const closest = (target) => closest$1(target, '[contenteditable]');
1154
- const isEditable = (element, assumeEditable = false) => {
1155
- if (inBody(element)) {
1156
- return element.dom.isContentEditable;
1157
- }
1158
- else {
1159
- // Find the closest contenteditable element and check if it's editable
1160
- return closest(element).fold(constant(assumeEditable), (editable) => getRaw(editable) === 'true');
1161
- }
1162
- };
1163
- const getRaw = (element) => element.dom.contentEditable;
1164
-
1165
- const children$2 = (scope, predicate) => filter$1(children$3(scope), predicate);
1166
- const descendants$1 = (scope, predicate) => {
1167
- let result = [];
1168
- // Recurse.toArray() might help here
1169
- each$1(children$3(scope), (x) => {
1170
- if (predicate(x)) {
1171
- result = result.concat([x]);
1172
- }
1173
- result = result.concat(descendants$1(x, predicate));
1174
- });
1175
- return result;
1176
- };
1177
-
1178
- const children$1 = (scope, selector) =>
1179
- // It may surprise you to learn this is exactly what JQuery does
1180
- // TODO: Avoid all the wrapping and unwrapping
1181
- children$2(scope, (e) => is$1(e, selector));
1182
- const descendants = (scope, selector) => all$1(selector, scope);
1183
-
1184
- const child = (scope, selector) => child$1(scope, selector).isSome();
1185
-
1186
- /*
1187
- NOTE: This file is partially duplicated in the following locations:
1188
- - models/dom/table/core/TableUtils.ts
1189
- - advtable
1190
- Make sure that if making changes to this file, the other files are updated as well
1191
- */
1192
- const getNodeName = (elm) => elm.nodeName.toLowerCase();
1193
- const getBody = (editor) => SugarElement.fromDom(editor.getBody());
1194
- const getIsRoot = (editor) => (element) => eq(element, getBody(editor));
1195
- const removePxSuffix = (size) => size ? size.replace(/px$/, '') : '';
1196
- const addPxSuffix = (size) => /^\d+(\.\d+)?$/.test(size) ? size + 'px' : size;
1197
- const getSelectionStart = (editor) => SugarElement.fromDom(editor.selection.getStart());
1198
- const getSelectionEnd = (editor) => SugarElement.fromDom(editor.selection.getEnd());
1199
- const isInEditableContext = (cell) => closest$2(cell, isTag('table')).forall(isEditable);
1200
-
1201
- const validSectionList = ['tfoot', 'thead', 'tbody', 'colgroup'];
1202
- const isValidSection = (parentName) => contains(validSectionList, parentName);
1203
- const grid = (rows, columns) => ({
1204
- rows,
1205
- columns
1206
- });
1207
- const detail = (element, rowspan, colspan) => ({
1208
- element,
1209
- rowspan,
1210
- colspan
1211
- });
1212
- const extended = (element, rowspan, colspan, row, column, isLocked) => ({
1213
- element,
1214
- rowspan,
1215
- colspan,
1216
- row,
1217
- column,
1218
- isLocked
1219
- });
1220
- const rowdetail = (element, cells, section) => ({
1221
- element,
1222
- cells,
1223
- section
1224
- });
1225
- const bounds = (startRow, startCol, finishRow, finishCol) => ({
1226
- startRow,
1227
- startCol,
1228
- finishRow,
1229
- finishCol
1230
- });
1231
- const columnext = (element, colspan, column) => ({
1232
- element,
1233
- colspan,
1234
- column
1235
- });
1236
- const colgroup = (element, columns) => ({
1237
- element,
1238
- columns
1239
- });
1240
-
1241
- const getAttrValue = (cell, name, fallback = 0) => getOpt(cell, name).map((value) => parseInt(value, 10)).getOr(fallback);
1242
-
1243
- const firstLayer = (scope, selector) => {
1244
- return filterFirstLayer(scope, selector, always);
1245
- };
1246
- const filterFirstLayer = (scope, selector, predicate) => {
1247
- return bind(children$3(scope), (x) => {
1248
- if (is$1(x, selector)) {
1249
- return predicate(x) ? [x] : [];
1250
- }
1251
- else {
1252
- return filterFirstLayer(x, selector, predicate);
1253
- }
1254
- });
1255
- };
1256
-
1257
- // lookup inside this table
1258
- const lookup = (tags, element, isRoot = never) => {
1259
- // If the element we're inspecting is the root, we definitely don't want it.
1260
- if (isRoot(element)) {
1261
- return Optional.none();
1262
- }
1263
- // This looks a lot like SelectorFind.closest, with one big exception - the isRoot check.
1264
- // The code here will look for parents if passed a table, SelectorFind.closest with that specific isRoot check won't.
1265
- if (contains(tags, name(element))) {
1266
- return Optional.some(element);
1267
- }
1268
- const isRootOrUpperTable = (elm) => is$1(elm, 'table') || isRoot(elm);
1269
- return ancestor(element, tags.join(','), isRootOrUpperTable);
1270
- };
1271
- /*
1272
- * Identify the optional cell that element represents.
1273
- */
1274
- const cell = (element, isRoot) => lookup(['td', 'th'], element, isRoot);
1275
- const cells = (ancestor) => firstLayer(ancestor, 'th,td');
1276
- const columns = (ancestor) => {
1277
- if (is$1(ancestor, 'colgroup')) {
1278
- return children$1(ancestor, 'col');
1279
- }
1280
- else {
1281
- return bind(columnGroups(ancestor), (columnGroup) => children$1(columnGroup, 'col'));
1282
- }
1283
- };
1284
- const table = (element, isRoot) => closest$1(element, 'table', isRoot);
1285
- const rows = (ancestor) => firstLayer(ancestor, 'tr');
1286
- const columnGroups = (ancestor) => table(ancestor).fold(constant([]), (table) => children$1(table, 'colgroup'));
1287
-
1288
- const isHeaderCell = isTag('th');
1289
- const getRowHeaderType = (isHeaderRow, isHeaderCells) => {
1290
- if (isHeaderRow && isHeaderCells) {
1291
- return 'sectionCells';
1292
- }
1293
- else if (isHeaderRow) {
1294
- return 'section';
1295
- }
1296
- else {
1297
- return 'cells';
1298
- }
1299
- };
1300
- const getRowType$1 = (row) => {
1301
- // Header rows can use a combination of theads and ths - want to detect the different combinations
1302
- const isHeaderRow = row.section === 'thead';
1303
- const isHeaderCells = is$2(findCommonCellType(row.cells), 'th');
1304
- if (row.section === 'tfoot') {
1305
- return { type: 'footer' };
1306
- }
1307
- else if (isHeaderRow || isHeaderCells) {
1308
- return { type: 'header', subType: getRowHeaderType(isHeaderRow, isHeaderCells) };
1309
- }
1310
- else {
1311
- return { type: 'body' };
1312
- }
1313
- };
1314
- const findCommonCellType = (cells) => {
1315
- const headerCells = filter$1(cells, (cell) => isHeaderCell(cell.element));
1316
- if (headerCells.length === 0) {
1317
- return Optional.some('td');
1318
- }
1319
- else if (headerCells.length === cells.length) {
1320
- return Optional.some('th');
1321
- }
1322
- else {
1323
- return Optional.none();
1324
- }
1325
- };
1326
- const findCommonRowType = (rows) => {
1327
- const rowTypes = map(rows, (row) => getRowType$1(row).type);
1328
- const hasHeader = contains(rowTypes, 'header');
1329
- const hasFooter = contains(rowTypes, 'footer');
1330
- if (!hasHeader && !hasFooter) {
1331
- return Optional.some('body');
1332
- }
1333
- else {
1334
- const hasBody = contains(rowTypes, 'body');
1335
- if (hasHeader && !hasBody && !hasFooter) {
1336
- return Optional.some('header');
1337
- }
1338
- else if (!hasHeader && !hasBody && hasFooter) {
1339
- return Optional.some('footer');
1340
- }
1341
- else {
1342
- return Optional.none();
1343
- }
1344
- }
1345
- };
1346
-
1347
- const fromRowsOrColGroups = (elems, getSection) => map(elems, (row) => {
1348
- if (name(row) === 'colgroup') {
1349
- const cells = map(columns(row), (column) => {
1350
- const colspan = getAttrValue(column, 'span', 1);
1351
- return detail(column, 1, colspan);
1352
- });
1353
- return rowdetail(row, cells, 'colgroup');
1354
- }
1355
- else {
1356
- const cells$1 = map(cells(row), (cell) => {
1357
- const rowspan = getAttrValue(cell, 'rowspan', 1);
1358
- const colspan = getAttrValue(cell, 'colspan', 1);
1359
- return detail(cell, rowspan, colspan);
1360
- });
1361
- return rowdetail(row, cells$1, getSection(row));
1362
- }
1363
- });
1364
- const getParentSection = (group) => parent(group).map((parent) => {
1365
- const parentName = name(parent);
1366
- return isValidSection(parentName) ? parentName : 'tbody';
1367
- }).getOr('tbody');
1368
- /*
1369
- * Takes a DOM table and returns a list of list of:
1370
- element: row element
1371
- cells: (id, rowspan, colspan) structs
1372
- */
1373
- const fromTable$1 = (table) => {
1374
- const rows$1 = rows(table);
1375
- const columnGroups$1 = columnGroups(table);
1376
- const elems = [...columnGroups$1, ...rows$1];
1377
- return fromRowsOrColGroups(elems, getParentSection);
1378
- };
1379
-
1380
- const LOCKED_COL_ATTR = 'data-snooker-locked-cols';
1381
- const getLockedColumnsFromTable = (table) => getOpt(table, LOCKED_COL_ATTR)
1382
- .bind((lockedColStr) => Optional.from(lockedColStr.match(/\d+/g)))
1383
- .map((lockedCols) => mapToObject(lockedCols, always));
1384
-
1385
- const key = (row, column) => {
1386
- return row + ',' + column;
1387
- };
1388
- const getAt = (warehouse, row, column) => Optional.from(warehouse.access[key(row, column)]);
1389
- const findItem = (warehouse, item, comparator) => {
1390
- const filtered = filterItems(warehouse, (detail) => {
1391
- return comparator(item, detail.element);
1392
- });
1393
- return filtered.length > 0 ? Optional.some(filtered[0]) : Optional.none();
1394
- };
1395
- const filterItems = (warehouse, predicate) => {
1396
- const all = bind(warehouse.all, (r) => {
1397
- return r.cells;
1398
- });
1399
- return filter$1(all, predicate);
1400
- };
1401
- const generateColumns = (rowData) => {
1402
- const columnsGroup = {};
1403
- let index = 0;
1404
- each$1(rowData.cells, (column) => {
1405
- const colspan = column.colspan;
1406
- range(colspan, (columnIndex) => {
1407
- const colIndex = index + columnIndex;
1408
- columnsGroup[colIndex] = columnext(column.element, colspan, colIndex);
1409
- });
1410
- index += colspan;
1411
- });
1412
- return columnsGroup;
1413
- };
1414
- /*
1415
- * From a list of list of Detail, generate three pieces of information:
1416
- * 1. the grid size
1417
- * 2. a data structure which can efficiently identify which cell is in which row,column position
1418
- * 3. a list of all cells in order left-to-right, top-to-bottom
1419
- */
1420
- const generate = (list) => {
1421
- // list is an array of objects, made by cells and elements
1422
- // elements: is the TR
1423
- // cells: is an array of objects representing the cells in the row.
1424
- // It is made of:
1425
- // colspan (merge cell)
1426
- // element
1427
- // rowspan (merge cols)
1428
- const access = {};
1429
- const cells = [];
1430
- const tableOpt = head(list).map((rowData) => rowData.element).bind(table);
1431
- const lockedColumns = tableOpt.bind(getLockedColumnsFromTable).getOr({});
1432
- let maxRows = 0;
1433
- let maxColumns = 0;
1434
- let rowCount = 0;
1435
- const { pass: colgroupRows, fail: rows } = partition(list, (rowData) => rowData.section === 'colgroup');
1436
- // Handle rows first
1437
- each$1(rows, (rowData) => {
1438
- const currentRow = [];
1439
- each$1(rowData.cells, (rowCell) => {
1440
- let start = 0;
1441
- // If this spot has been taken by a previous rowspan, skip it.
1442
- while (access[key(rowCount, start)] !== undefined) {
1443
- start++;
1444
- }
1445
- const isLocked = hasNonNullableKey(lockedColumns, start.toString());
1446
- const current = extended(rowCell.element, rowCell.rowspan, rowCell.colspan, rowCount, start, isLocked);
1447
- // Occupy all the (row, column) positions that this cell spans for.
1448
- for (let occupiedColumnPosition = 0; occupiedColumnPosition < rowCell.colspan; occupiedColumnPosition++) {
1449
- for (let occupiedRowPosition = 0; occupiedRowPosition < rowCell.rowspan; occupiedRowPosition++) {
1450
- const rowPosition = rowCount + occupiedRowPosition;
1451
- const columnPosition = start + occupiedColumnPosition;
1452
- const newpos = key(rowPosition, columnPosition);
1453
- access[newpos] = current;
1454
- maxColumns = Math.max(maxColumns, columnPosition + 1);
1455
- }
1456
- }
1457
- currentRow.push(current);
1458
- });
1459
- maxRows++;
1460
- cells.push(rowdetail(rowData.element, currentRow, rowData.section));
1461
- rowCount++;
1462
- });
1463
- // Handle colgroups
1464
- // Note: Currently only a single colgroup is supported so just use the last one
1465
- const { columns, colgroups } = last(colgroupRows).map((rowData) => {
1466
- const columns = generateColumns(rowData);
1467
- const colgroup$1 = colgroup(rowData.element, values(columns));
1468
- return {
1469
- colgroups: [colgroup$1],
1470
- columns
1471
- };
1472
- }).getOrThunk(() => ({
1473
- colgroups: [],
1474
- columns: {}
1475
- }));
1476
- const grid$1 = grid(maxRows, maxColumns);
1477
- return {
1478
- grid: grid$1,
1479
- access,
1480
- all: cells,
1481
- columns,
1482
- colgroups
1483
- };
1484
- };
1485
- const fromTable = (table) => {
1486
- const list = fromTable$1(table);
1487
- return generate(list);
1488
- };
1489
- const justCells = (warehouse) => bind(warehouse.all, (w) => w.cells);
1490
- const justColumns = (warehouse) => values(warehouse.columns);
1491
- const hasColumns = (warehouse) => keys(warehouse.columns).length > 0;
1492
- const getColumnAt = (warehouse, columnIndex) => Optional.from(warehouse.columns[columnIndex]);
1493
- const Warehouse = {
1494
- fromTable,
1495
- generate,
1496
- getAt,
1497
- findItem,
1498
- filterItems,
1499
- justCells,
1500
- justColumns,
1501
- hasColumns,
1502
- getColumnAt
1503
- };
1504
-
1505
- const findInWarehouse = (warehouse, element) => findMap(warehouse.all, (r) => find(r.cells, (e) => eq(element, e.element)));
1506
- const extractCells = (warehouse, target, predicate) => {
1507
- const details = map(target.selection, (cell$1) => {
1508
- return cell(cell$1)
1509
- .bind((lc) => findInWarehouse(warehouse, lc))
1510
- .filter(predicate);
1511
- });
1512
- const cells = cat(details);
1513
- return someIf(cells.length > 0, cells);
1514
- };
1515
- const onMergable = (_warehouse, target) => target.mergable;
1516
- const onUnmergable = (_warehouse, target) => target.unmergable;
1517
- const onCells = (warehouse, target) => extractCells(warehouse, target, always);
1518
- const isUnlockedTableCell = (warehouse, cell) => findInWarehouse(warehouse, cell).exists((detail) => !detail.isLocked);
1519
- const allUnlocked = (warehouse, cells) => forall(cells, (cell) => isUnlockedTableCell(warehouse, cell));
1520
- // If any locked columns are present in the selection, then don't want to be able to merge
1521
- const onUnlockedMergable = (warehouse, target) => onMergable(warehouse, target).filter((mergeable) => allUnlocked(warehouse, mergeable.cells));
1522
- // If any locked columns are present in the selection, then don't want to be able to unmerge
1523
- const onUnlockedUnmergable = (warehouse, target) => onUnmergable(warehouse, target).filter((cells) => allUnlocked(warehouse, cells));
1524
-
1525
- const isCol = isTag('col');
1526
- const isColgroup = isTag('colgroup');
1527
- const isRow = (element) => name(element) === 'tr' || isColgroup(element);
1528
- const elementToData = (element) => {
1529
- const colspan = getAttrValue(element, 'colspan', 1);
1530
- const rowspan = getAttrValue(element, 'rowspan', 1);
1531
- return {
1532
- element,
1533
- colspan,
1534
- rowspan
1535
- };
1536
- };
1537
- // note that `toData` seems to be only for testing
1538
- const modification = (generators, toData = elementToData) => {
1539
- const nuCell = (data) => isCol(data.element) ? generators.col(data) : generators.cell(data);
1540
- const nuRow = (data) => isColgroup(data.element) ? generators.colgroup(data) : generators.row(data);
1541
- const add = (element) => {
1542
- if (isRow(element)) {
1543
- return nuRow({ element });
1544
- }
1545
- else {
1546
- const cell = element;
1547
- const replacement = nuCell(toData(cell));
1548
- recent = Optional.some({ item: cell, replacement });
1549
- return replacement;
1550
- }
1551
- };
1552
- let recent = Optional.none();
1553
- const getOrInit = (element, comparator) => {
1554
- return recent.fold(() => {
1555
- return add(element);
1556
- }, (p) => {
1557
- return comparator(element, p.item) ? p.replacement : add(element);
1558
- });
1559
- };
1560
- return {
1561
- getOrInit
1562
- };
1563
- };
1564
- const transform = (tag) => {
1565
- return (generators) => {
1566
- const list = [];
1567
- const find$1 = (element, comparator) => {
1568
- return find(list, (x) => {
1569
- return comparator(x.item, element);
1570
- });
1571
- };
1572
- const makeNew = (element) => {
1573
- // Ensure scope is never set on a td element as it's a deprecated attribute
1574
- const attrs = tag === 'td' ? { scope: null } : {};
1575
- const cell = generators.replace(element, tag, attrs);
1576
- list.push({
1577
- item: element,
1578
- sub: cell
1579
- });
1580
- return cell;
1581
- };
1582
- const replaceOrInit = (element, comparator) => {
1583
- if (isRow(element) || isCol(element)) {
1584
- return element;
1585
- }
1586
- else {
1587
- const cell = element;
1588
- return find$1(cell, comparator).fold(() => {
1589
- return makeNew(cell);
1590
- }, (p) => {
1591
- return comparator(element, p.item) ? p.sub : makeNew(cell);
1592
- });
1593
- }
1594
- };
1595
- return {
1596
- replaceOrInit
1597
- };
1598
- };
1599
- };
1600
- const getScopeAttribute = (cell) => getOpt(cell, 'scope').map(
1601
- // Attribute can be col, colgroup, row, and rowgroup.
1602
- // As col and colgroup are to be treated as if they are the same, lob off everything after the first three characters and there is no difference.
1603
- (attribute) => attribute.substr(0, 3));
1604
- const merging = (generators) => {
1605
- const unmerge = (cell) => {
1606
- const scope = getScopeAttribute(cell);
1607
- scope.each((attribute) => set$2(cell, 'scope', attribute));
1608
- return () => {
1609
- const raw = generators.cell({
1610
- element: cell,
1611
- colspan: 1,
1612
- rowspan: 1
1613
- });
1614
- // Remove any width calculations because they are no longer relevant.
1615
- remove(raw, 'width');
1616
- remove(cell, 'width');
1617
- scope.each((attribute) => set$2(raw, 'scope', attribute));
1618
- return raw;
1619
- };
1620
- };
1621
- const merge = (cells) => {
1622
- const getScopeProperty = () => {
1623
- const stringAttributes = cat(map(cells, getScopeAttribute));
1624
- if (stringAttributes.length === 0) {
1625
- return Optional.none();
1626
- }
1627
- else {
1628
- const baseScope = stringAttributes[0];
1629
- const scopes = ['row', 'col'];
1630
- const isMixed = exists(stringAttributes, (attribute) => {
1631
- return attribute !== baseScope && contains(scopes, attribute);
1632
- });
1633
- return isMixed ? Optional.none() : Optional.from(baseScope);
1634
- }
1635
- };
1636
- remove(cells[0], 'width');
1637
- getScopeProperty().fold(() => remove$2(cells[0], 'scope'), (attribute) => set$2(cells[0], 'scope', attribute + 'group'));
1638
- return constant(cells[0]);
1639
- };
1640
- return {
1641
- unmerge,
1642
- merge
1643
- };
1644
- };
1645
- const Generators = {
1646
- modification,
1647
- transform,
1648
- merging
1649
- };
1650
-
1651
- var TagBoundaries = [
1652
- 'body',
1653
- 'p',
1654
- 'div',
1655
- 'article',
1656
- 'aside',
1657
- 'figcaption',
1658
- 'figure',
1659
- 'footer',
1660
- 'header',
1661
- 'nav',
1662
- 'section',
1663
- 'ol',
1664
- 'ul',
1665
- 'li',
1666
- 'table',
1667
- 'thead',
1668
- 'tbody',
1669
- 'tfoot',
1670
- 'caption',
1671
- 'tr',
1672
- 'td',
1673
- 'th',
1674
- 'h1',
1675
- 'h2',
1676
- 'h3',
1677
- 'h4',
1678
- 'h5',
1679
- 'h6',
1680
- 'blockquote',
1681
- 'pre',
1682
- 'address'
1683
- ];
1684
-
1685
- var DomUniverse = () => {
1686
- const clone$1 = (element) => {
1687
- return SugarElement.fromDom(element.dom.cloneNode(false));
1688
- };
1689
- const document = (element) => documentOrOwner(element).dom;
1690
- const isBoundary = (element) => {
1691
- if (!isElement(element)) {
1692
- return false;
1693
- }
1694
- if (name(element) === 'body') {
1695
- return true;
1696
- }
1697
- return contains(TagBoundaries, name(element));
1698
- };
1699
- const isEmptyTag = (element) => {
1700
- if (!isElement(element)) {
1701
- return false;
1702
- }
1703
- return contains(['br', 'img', 'hr', 'input'], name(element));
1704
- };
1705
- const isNonEditable = (element) => isElement(element) && get$2(element, 'contenteditable') === 'false';
1706
- const comparePosition = (element, other) => {
1707
- return element.dom.compareDocumentPosition(other.dom);
1708
- };
1709
- const copyAttributesTo = (source, destination) => {
1710
- const as = clone(source);
1711
- setAll(destination, as);
1712
- };
1713
- const isSpecial = (element) => {
1714
- const tag = name(element);
1715
- return contains([
1716
- 'script', 'noscript', 'iframe', 'noframes', 'noembed', 'title', 'style', 'textarea', 'xmp'
1717
- ], tag);
1718
- };
1719
- const getLanguage = (element) => isElement(element) ? getOpt(element, 'lang') : Optional.none();
1720
- return {
1721
- up: constant({
1722
- selector: ancestor,
1723
- closest: closest$1,
1724
- predicate: ancestor$1,
1725
- all: parents
1726
- }),
1727
- down: constant({
1728
- selector: descendants,
1729
- predicate: descendants$1
1730
- }),
1731
- styles: constant({
1732
- get: get$1,
1733
- getRaw: getRaw$1,
1734
- set: set$1,
1735
- remove: remove
1736
- }),
1737
- attrs: constant({
1738
- get: get$2,
1739
- set: set$2,
1740
- remove: remove$2,
1741
- copyTo: copyAttributesTo
1742
- }),
1743
- insert: constant({
1744
- before: before,
1745
- after: after$1,
1746
- afterAll: after,
1747
- append: append$1,
1748
- appendAll: append,
1749
- prepend: prepend,
1750
- wrap: wrap
1751
- }),
1752
- remove: constant({
1753
- unwrap: unwrap,
1754
- remove: remove$1
1755
- }),
1756
- create: constant({
1757
- nu: SugarElement.fromTag,
1758
- clone: clone$1,
1759
- text: SugarElement.fromText
1760
- }),
1761
- query: constant({
1762
- comparePosition,
1763
- prevSibling: prevSibling,
1764
- nextSibling: nextSibling
1765
- }),
1766
- property: constant({
1767
- children: children$3,
1768
- name: name,
1769
- parent: parent,
1770
- document,
1771
- isText: isText,
1772
- isComment: isComment,
1773
- isElement: isElement,
1774
- isSpecial,
1775
- getLanguage,
1776
- getText: get,
1777
- setText: set,
1778
- isBoundary,
1779
- isEmptyTag,
1780
- isNonEditable
1781
- }),
1782
- eq: eq,
1783
- is: is
1784
- };
1785
- };
1786
-
1787
- const leftRight = (left, right) => ({
1788
- left,
1789
- right
1790
- });
1791
- const brokenPath = (first, second, splits) => ({
1792
- first,
1793
- second,
1794
- splits
1795
- });
1796
- const bisect = (universe, parent, child) => {
1797
- const children = universe.property().children(parent);
1798
- const index = findIndex(children, curry(universe.eq, child));
1799
- return index.map((ind) => {
1800
- return {
1801
- before: children.slice(0, ind),
1802
- after: children.slice(ind + 1)
1803
- };
1804
- });
1805
- };
1806
- /**
1807
- * Clone parent to the RIGHT and move everything after child in the parent element into
1808
- * a clone of the parent (placed after parent).
1809
- */
1810
- const breakToRight = (universe, parent, child) => {
1811
- return bisect(universe, parent, child).map((parts) => {
1812
- const second = universe.create().clone(parent);
1813
- universe.insert().appendAll(second, parts.after);
1814
- universe.insert().after(parent, second);
1815
- return leftRight(parent, second);
1816
- });
1817
- };
1818
- /**
1819
- * Clone parent to the LEFT and move everything before and including child into
1820
- * the a clone of the parent (placed before parent)
1821
- */
1822
- const breakToLeft = (universe, parent, child) => {
1823
- return bisect(universe, parent, child).map((parts) => {
1824
- const prior = universe.create().clone(parent);
1825
- universe.insert().appendAll(prior, parts.before.concat([child]));
1826
- universe.insert().appendAll(parent, parts.after);
1827
- universe.insert().before(parent, prior);
1828
- return leftRight(prior, parent);
1829
- });
1830
- };
1831
- /*
1832
- * Using the breaker, break from the child up to the top element defined by the predicate.
1833
- * It returns three values:
1834
- * first: the top level element that completed the break
1835
- * second: the optional element representing second part of the top-level split if the breaking completed successfully to the top
1836
- * splits: a list of (Element, Element) pairs that represent the splits that have occurred on the way to the top.
1837
- */
1838
- const breakPath = (universe, item, isTop, breaker) => {
1839
- const next = (child, group, splits) => {
1840
- const fallback = brokenPath(child, Optional.none(), splits);
1841
- // Found the top, so stop.
1842
- if (isTop(child)) {
1843
- return brokenPath(child, group, splits);
1844
- }
1845
- else {
1846
- // Split the child at parent, and keep going
1847
- return universe.property().parent(child).bind((parent) => {
1848
- return breaker(universe, parent, child).map((breakage) => {
1849
- const extra = [{ first: breakage.left, second: breakage.right }];
1850
- // Our isTop is based on the left-side parent, so keep it regardless of split.
1851
- const nextChild = isTop(parent) ? parent : breakage.left;
1852
- return next(nextChild, Optional.some(breakage.right), splits.concat(extra));
1853
- });
1854
- }).getOr(fallback);
1855
- }
1856
- };
1857
- return next(item, Optional.none(), []);
1858
- };
1859
-
1860
- const all = (universe, look, elements, f) => {
1861
- const head = elements[0];
1862
- const tail = elements.slice(1);
1863
- return f(universe, look, head, tail);
1864
- };
1865
- /**
1866
- * Check if look returns the same element for all elements, and return it if it exists.
1867
- */
1868
- const oneAll = (universe, look, elements) => {
1869
- return elements.length > 0 ?
1870
- all(universe, look, elements, unsafeOne) :
1871
- Optional.none();
1872
- };
1873
- const unsafeOne = (universe, look, head, tail) => {
1874
- const start = look(universe, head);
1875
- return foldr(tail, (b, a) => {
1876
- const current = look(universe, a);
1877
- return commonElement(universe, b, current);
1878
- }, start);
1879
- };
1880
- const commonElement = (universe, start, end) => {
1881
- return start.bind((s) => {
1882
- return end.filter(curry(universe.eq, s));
1883
- });
1884
- };
1885
-
1886
- const sharedOne$1 = oneAll;
1887
- breakToLeft;
1888
- breakToRight;
1889
- breakPath;
1890
-
1891
- const universe = DomUniverse();
1892
- const sharedOne = (look, elements) => {
1893
- return sharedOne$1(universe, (_universe, element) => {
1894
- return look(element);
1895
- }, elements);
1896
- };
1897
-
1898
- const opGetRowsType = (table, target) => {
1899
- const house = Warehouse.fromTable(table);
1900
- const details = onCells(house, target);
1901
- return details.bind((selectedCells) => {
1902
- const lastSelectedCell = selectedCells[selectedCells.length - 1];
1903
- const minRowRange = selectedCells[0].row;
1904
- const maxRowRange = lastSelectedCell.row + lastSelectedCell.rowspan;
1905
- const selectedRows = house.all.slice(minRowRange, maxRowRange);
1906
- return findCommonRowType(selectedRows);
1907
- }).getOr('');
1908
- };
1909
- Generators.transform('th');
1910
- Generators.transform('td');
1911
- const getRowsType = opGetRowsType;
1912
-
1913
- // Note, something is *within* if it is completely contained within the bounds.
1914
- const isWithin = (bounds, detail) => {
1915
- return (detail.column >= bounds.startCol &&
1916
- (detail.column + detail.colspan - 1) <= bounds.finishCol &&
1917
- detail.row >= bounds.startRow &&
1918
- (detail.row + detail.rowspan - 1) <= bounds.finishRow);
1919
- };
1920
- const isRectangular = (warehouse, bounds) => {
1921
- let isRect = true;
1922
- const detailIsWithin = curry(isWithin, bounds);
1923
- for (let i = bounds.startRow; i <= bounds.finishRow; i++) {
1924
- for (let j = bounds.startCol; j <= bounds.finishCol; j++) {
1925
- isRect = isRect && Warehouse.getAt(warehouse, i, j).exists(detailIsWithin);
1926
- }
1927
- }
1928
- return isRect ? Optional.some(bounds) : Optional.none();
1929
- };
1930
-
1931
- const getBounds = (detailA, detailB) => {
1932
- return bounds(Math.min(detailA.row, detailB.row), Math.min(detailA.column, detailB.column), Math.max(detailA.row + detailA.rowspan - 1, detailB.row + detailB.rowspan - 1), Math.max(detailA.column + detailA.colspan - 1, detailB.column + detailB.colspan - 1));
1933
- };
1934
- const getAnyBox = (warehouse, startCell, finishCell) => {
1935
- const startCoords = Warehouse.findItem(warehouse, startCell, eq);
1936
- const finishCoords = Warehouse.findItem(warehouse, finishCell, eq);
1937
- return startCoords.bind((sc) => {
1938
- return finishCoords.map((fc) => {
1939
- return getBounds(sc, fc);
1940
- });
1941
- });
1942
- };
1943
- const getBox$1 = (warehouse, startCell, finishCell) => {
1944
- return getAnyBox(warehouse, startCell, finishCell).bind((bounds) => {
1945
- return isRectangular(warehouse, bounds);
1946
- });
1947
- };
1948
-
1949
- const getBox = (table, first, last) => {
1950
- const warehouse = getWarehouse(table);
1951
- return getBox$1(warehouse, first, last);
1952
- };
1953
- // Private method ... keep warehouse in snooker, please.
1954
- const getWarehouse = Warehouse.fromTable;
1955
-
1956
- var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools');
1957
-
1958
- const getTDTHOverallStyle = (dom, elm, name) => {
1959
- const cells = dom.select('td,th', elm);
1960
- let firstChildStyle;
1961
- for (let i = 0; i < cells.length; i++) {
1962
- const currentStyle = dom.getStyle(cells[i], name);
1963
- if (isUndefined(firstChildStyle)) {
1964
- firstChildStyle = currentStyle;
1965
- }
1966
- if (firstChildStyle !== currentStyle) {
1967
- return '';
1968
- }
1969
- }
1970
- return firstChildStyle;
1971
- };
1972
- const setAlign = (editor, elm, name) => {
1973
- // Alignment formats may not use the same styles so ensure to remove any existing horizontal alignment format first
1974
- global$2.each('left center right'.split(' '), (align) => {
1975
- if (align !== name) {
1976
- editor.formatter.remove('align' + align, {}, elm);
1977
- }
1978
- });
1979
- if (name) {
1980
- editor.formatter.apply('align' + name, {}, elm);
1981
- }
1982
- };
1983
- const setVAlign = (editor, elm, name) => {
1984
- // Alignment formats may not use the same styles so ensure to remove any existing vertical alignment format first
1985
- global$2.each('top middle bottom'.split(' '), (align) => {
1986
- if (align !== name) {
1987
- editor.formatter.remove('valign' + align, {}, elm);
1988
- }
1989
- });
1990
- if (name) {
1991
- editor.formatter.apply('valign' + name, {}, elm);
1992
- }
1993
- };
1994
-
1995
- /*
1996
- NOTE: This file is duplicated in the following locations:
1997
- - core/api/TableEvents.ts
1998
- - models/dom/table/api/Events.ts
1999
- - advtable
2000
- Make sure that if making changes to this file, the other files are updated as well
2001
- */
2002
- const fireTableModified = (editor, table, data) => {
2003
- editor.dispatch('TableModified', { ...data, table });
2004
- };
2005
-
2006
- var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
2007
-
2008
- const defaultTableToolbar = 'tableprops tabledelete | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol';
2009
- const defaultCellBorderWidths = range(5, (i) => {
2010
- const size = `${i + 1}px`;
2011
- return { title: size, value: size };
2012
- });
2013
- const defaultCellBorderStyles = map(['Solid', 'Dotted', 'Dashed', 'Double', 'Groove', 'Ridge', 'Inset', 'Outset', 'None', 'Hidden'], (type) => {
2014
- return { title: type, value: type.toLowerCase() };
2015
- });
2016
- // Note: This is also contained in the core Options.ts file
2017
- const defaultWidth = '100%';
2018
- const getPixelForcedWidth = (editor) => {
2019
- // Determine the inner size of the parent block element where the table will be inserted
2020
- const dom = editor.dom;
2021
- const parentBlock = dom.getParent(editor.selection.getStart(), dom.isBlock) ?? editor.getBody();
2022
- return getInner(SugarElement.fromDom(parentBlock)) + 'px';
2023
- };
2024
- // Note: This is also contained in the core Options.ts file
2025
- const determineDefaultStyles = (editor, defaultStyles) => {
2026
- if (isResponsiveForced(editor) || !shouldStyleWithCss(editor)) {
2027
- return defaultStyles;
2028
- }
2029
- else if (isPixelsForced(editor)) {
2030
- return { ...defaultStyles, width: getPixelForcedWidth(editor) };
2031
- }
2032
- else {
2033
- return { ...defaultStyles, width: defaultWidth };
2034
- }
2035
- };
2036
- // Note: This is also contained in the core Options.ts file
2037
- const determineDefaultAttributes = (editor, defaultAttributes) => {
2038
- if (isResponsiveForced(editor) || shouldStyleWithCss(editor)) {
2039
- return defaultAttributes;
2040
- }
2041
- else if (isPixelsForced(editor)) {
2042
- return { ...defaultAttributes, width: getPixelForcedWidth(editor) };
2043
- }
2044
- else {
2045
- return { ...defaultAttributes, width: defaultWidth };
2046
- }
2047
- };
2048
- const option = (name) => (editor) => editor.options.get(name);
2049
- const register = (editor) => {
2050
- const registerOption = editor.options.register;
2051
- registerOption('table_border_widths', {
2052
- processor: 'object[]',
2053
- default: defaultCellBorderWidths
2054
- });
2055
- registerOption('table_border_styles', {
2056
- processor: 'object[]',
2057
- default: defaultCellBorderStyles
2058
- });
2059
- registerOption('table_cell_advtab', {
2060
- processor: 'boolean',
2061
- default: true
2062
- });
2063
- registerOption('table_row_advtab', {
2064
- processor: 'boolean',
2065
- default: true
2066
- });
2067
- registerOption('table_advtab', {
2068
- processor: 'boolean',
2069
- default: true
2070
- });
2071
- registerOption('table_appearance_options', {
2072
- processor: 'boolean',
2073
- default: true
2074
- });
2075
- registerOption('table_grid', {
2076
- processor: 'boolean',
2077
- // Table grid relies on hover, which isn't available on touch devices so use the dialog instead
2078
- default: !global$1.deviceType.isTouch()
2079
- });
2080
- registerOption('table_cell_class_list', {
2081
- processor: 'object[]',
2082
- default: []
2083
- });
2084
- registerOption('table_row_class_list', {
2085
- processor: 'object[]',
2086
- default: []
2087
- });
2088
- registerOption('table_class_list', {
2089
- processor: 'object[]',
2090
- default: []
2091
- });
2092
- registerOption('table_toolbar', {
2093
- processor: 'string',
2094
- default: defaultTableToolbar
2095
- });
2096
- registerOption('table_background_color_map', {
2097
- processor: 'object[]',
2098
- default: []
2099
- });
2100
- registerOption('table_border_color_map', {
2101
- processor: 'object[]',
2102
- default: []
2103
- });
2104
- };
2105
- const getTableSizingMode = option('table_sizing_mode');
2106
- const getTableBorderWidths = option('table_border_widths');
2107
- const getTableBorderStyles = option('table_border_styles');
2108
- const hasAdvancedCellTab = option('table_cell_advtab');
2109
- const hasAdvancedRowTab = option('table_row_advtab');
2110
- const hasAdvancedTableTab = option('table_advtab');
2111
- const hasAppearanceOptions = option('table_appearance_options');
2112
- const hasTableGrid = option('table_grid');
2113
- const shouldStyleWithCss = option('table_style_by_css');
2114
- const getCellClassList = option('table_cell_class_list');
2115
- const getRowClassList = option('table_row_class_list');
2116
- const getTableClassList = option('table_class_list');
2117
- const getToolbar = option('table_toolbar');
2118
- const getTableBackgroundColorMap = option('table_background_color_map');
2119
- const getTableBorderColorMap = option('table_border_color_map');
2120
- const isPixelsForced = (editor) => getTableSizingMode(editor) === 'fixed';
2121
- const isResponsiveForced = (editor) => getTableSizingMode(editor) === 'responsive';
2122
- const getDefaultStyles = (editor) => {
2123
- // Note: The we don't rely on the default here as we need to dynamically lookup the widths based on the current editor state
2124
- const options = editor.options;
2125
- const defaultStyles = options.get('table_default_styles');
2126
- return options.isSet('table_default_styles') ? defaultStyles : determineDefaultStyles(editor, defaultStyles);
2127
- };
2128
- const getDefaultAttributes = (editor) => {
2129
- // Note: The we don't rely on the default here as we need to dynamically lookup the widths based on the current editor state
2130
- const options = editor.options;
2131
- const defaultAttributes = options.get('table_default_attributes');
2132
- return options.isSet('table_default_attributes') ? defaultAttributes : determineDefaultAttributes(editor, defaultAttributes);
2133
- };
2134
-
2135
- const lookupTable = (container) => {
2136
- return ancestor(container, 'table');
2137
- };
2138
- const retrieve$1 = (container, selector) => {
2139
- const sels = descendants(container, selector);
2140
- return sels.length > 0 ? Optional.some(sels) : Optional.none();
2141
- };
2142
- const getEdges = (container, firstSelectedSelector, lastSelectedSelector) => {
2143
- return descendant(container, firstSelectedSelector).bind((first) => {
2144
- return descendant(container, lastSelectedSelector).bind((last) => {
2145
- return sharedOne(lookupTable, [first, last]).map((table) => {
2146
- return {
2147
- first,
2148
- last,
2149
- table
2150
- };
2151
- });
2152
- });
2153
- });
2154
- };
2155
-
2156
- // Explicitly calling CellSelection.retrieve so that we can see the API signature.
2157
- const retrieve = (container, selector) => {
2158
- return retrieve$1(container, selector);
2159
- };
2160
- const retrieveBox = (container, firstSelectedSelector, lastSelectedSelector) => {
2161
- return getEdges(container, firstSelectedSelector, lastSelectedSelector).bind((edges) => {
2162
- const isRoot = (ancestor) => {
2163
- return eq(container, ancestor);
2164
- };
2165
- const sectionSelector = 'thead,tfoot,tbody,table';
2166
- const firstAncestor = ancestor(edges.first, sectionSelector, isRoot);
2167
- const lastAncestor = ancestor(edges.last, sectionSelector, isRoot);
2168
- return firstAncestor.bind((fA) => {
2169
- return lastAncestor.bind((lA) => {
2170
- return eq(fA, lA) ? getBox(edges.table, edges.first, edges.last) : Optional.none();
2171
- });
2172
- });
2173
- });
2174
- };
2175
-
2176
- const selection = identity;
2177
- const unmergable = (selectedCells) => {
2178
- const hasSpan = (elem, type) => getOpt(elem, type).exists((span) => parseInt(span, 10) > 1);
2179
- const hasRowOrColSpan = (elem) => hasSpan(elem, 'rowspan') || hasSpan(elem, 'colspan');
2180
- return selectedCells.length > 0 && forall(selectedCells, hasRowOrColSpan) ? Optional.some(selectedCells) : Optional.none();
2181
- };
2182
- const mergable = (table, selectedCells, ephemera) => {
2183
- if (selectedCells.length <= 1) {
2184
- return Optional.none();
2185
- }
2186
- else {
2187
- return retrieveBox(table, ephemera.firstSelectedSelector, ephemera.lastSelectedSelector)
2188
- .map((bounds) => ({ bounds, cells: selectedCells }));
2189
- }
2190
- };
2191
-
2192
- /*
2193
- NOTE: This file is duplicated in the following locations:
2194
- - models/dom/table/selection/Ephemera.ts
2195
- - advtable
2196
- Make sure that if making changes to this file, the other files are updated as well
2197
- */
2198
- const strSelected = 'data-mce-selected';
2199
- const strSelectedSelector = 'td[' + strSelected + '],th[' + strSelected + ']';
2200
- const strFirstSelected = 'data-mce-first-selected';
2201
- const strFirstSelectedSelector = 'td[' + strFirstSelected + '],th[' + strFirstSelected + ']';
2202
- const strLastSelected = 'data-mce-last-selected';
2203
- const strLastSelectedSelector = 'td[' + strLastSelected + '],th[' + strLastSelected + ']';
2204
- const ephemera = {
2205
- selected: strSelected,
2206
- selectedSelector: strSelectedSelector,
2207
- firstSelected: strFirstSelected,
2208
- firstSelectedSelector: strFirstSelectedSelector,
2209
- lastSelected: strLastSelected,
2210
- lastSelectedSelector: strLastSelectedSelector
2211
- };
2212
-
2213
- /*
2214
- NOTE: This file is partially duplicated in the following locations:
2215
- - models/dom/table/selection/TableSelection.ts
2216
- - advtable
2217
- Make sure that if making changes to this file, the other files are updated as well
2218
- */
2219
- const getSelectionCellFallback = (element) => table(element).bind((table) => retrieve(table, ephemera.firstSelectedSelector)).fold(constant(element), (cells) => cells[0]);
2220
- const getSelectionFromSelector = (selector) => (initCell, isRoot) => {
2221
- const cellName = name(initCell);
2222
- const cell = cellName === 'col' || cellName === 'colgroup' ? getSelectionCellFallback(initCell) : initCell;
2223
- return closest$1(cell, selector, isRoot);
2224
- };
2225
- const getSelectionCellOrCaption = getSelectionFromSelector('th,td,caption');
2226
- const getSelectionCell = getSelectionFromSelector('th,td');
2227
- const getCellsFromSelection = (editor) => fromDom(editor.model.table.getSelectedCells());
2228
- const getRowsFromSelection = (selected, selector) => {
2229
- const cellOpt = getSelectionCell(selected);
2230
- const rowsOpt = cellOpt.bind((cell) => table(cell))
2231
- .map((table) => rows(table));
2232
- return lift2(cellOpt, rowsOpt, (cell, rows) => filter$1(rows, (row) => exists(fromDom(row.dom.cells), (rowCell) => get$2(rowCell, selector) === '1' || eq(rowCell, cell)))).getOr([]);
2233
- };
2234
-
2235
- const verticalAlignValues = [
2236
- {
2237
- text: 'None',
2238
- value: ''
2239
- },
2240
- {
2241
- text: 'Top',
2242
- value: 'top'
2243
- },
2244
- {
2245
- text: 'Middle',
2246
- value: 'middle'
2247
- },
2248
- {
2249
- text: 'Bottom',
2250
- value: 'bottom'
2251
- }
2252
- ];
2253
-
2254
- const hexColour = (value) => ({
2255
- value: normalizeHex(value)
2256
- });
2257
- const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
2258
- const longformRegex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;
2259
- const isHexString = (hex) => shorthandRegex.test(hex) || longformRegex.test(hex);
2260
- const normalizeHex = (hex) => removeLeading(hex, '#').toUpperCase();
2261
- const fromString$1 = (hex) => isHexString(hex) ? Optional.some({ value: normalizeHex(hex) }) : Optional.none();
2262
- const toHex = (component) => {
2263
- const hex = component.toString(16);
2264
- return (hex.length === 1 ? '0' + hex : hex).toUpperCase();
2265
- };
2266
- const fromRgba = (rgbaColour) => {
2267
- const value = toHex(rgbaColour.red) + toHex(rgbaColour.green) + toHex(rgbaColour.blue);
2268
- return hexColour(value);
2269
- };
2270
-
2271
- const rgbRegex = /^\s*rgb\s*\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)\s*\)\s*$/i;
2272
- // This regex will match rgba(0, 0, 0, 0.5) or rgba(0, 0, 0, 50%) , or without commas
2273
- const rgbaRegex = /^\s*rgba\s*\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*((?:\d?\.\d+|\d+)%?)\s*\)\s*$/i;
2274
- const rgbaColour = (red, green, blue, alpha) => ({
2275
- red,
2276
- green,
2277
- blue,
2278
- alpha
2279
- });
2280
- const fromStringValues = (red, green, blue, alpha) => {
2281
- const r = parseInt(red, 10);
2282
- const g = parseInt(green, 10);
2283
- const b = parseInt(blue, 10);
2284
- const a = parseFloat(alpha);
2285
- return rgbaColour(r, g, b, a);
2286
- };
2287
- const fromString = (rgbaString) => {
2288
- const rgbMatch = rgbRegex.exec(rgbaString);
2289
- if (rgbMatch !== null) {
2290
- return Optional.some(fromStringValues(rgbMatch[1], rgbMatch[2], rgbMatch[3], '1'));
2291
- }
2292
- const rgbaMatch = rgbaRegex.exec(rgbaString);
2293
- if (rgbaMatch !== null) {
2294
- return Optional.some(fromStringValues(rgbaMatch[1], rgbaMatch[2], rgbaMatch[3], rgbaMatch[4]));
2295
- }
2296
- return Optional.none();
2297
- };
2298
-
2299
- const anyToHex = (color) => fromString$1(color)
2300
- .orThunk(() => fromString(color).map(fromRgba))
2301
- .getOrThunk(() => {
2302
- // Not dealing with Hex or RGBA so use a canvas to parse the color
2303
- const canvas = document.createElement('canvas');
2304
- canvas.height = 1;
2305
- canvas.width = 1;
2306
- const canvasContext = canvas.getContext('2d');
2307
- // all valid colors after this point
2308
- canvasContext.clearRect(0, 0, canvas.width, canvas.height);
2309
- // invalid colors will be shown as white - the first assignment will pass and the second may be ignored
2310
- canvasContext.fillStyle = '#FFFFFF';
2311
- canvasContext.fillStyle = color;
2312
- canvasContext.fillRect(0, 0, 1, 1);
2313
- const rgba = canvasContext.getImageData(0, 0, 1, 1).data;
2314
- const r = rgba[0];
2315
- const g = rgba[1];
2316
- const b = rgba[2];
2317
- const a = rgba[3];
2318
- return fromRgba(rgbaColour(r, g, b, a));
2319
- });
2320
- const rgbaToHexString = (color) => fromString(color)
2321
- .map(fromRgba)
2322
- .map((h) => '#' + h.value)
2323
- .getOr(color);
2324
-
2325
- const onSetupToggle = (editor, formatName, formatValue) => {
2326
- return (api) => {
2327
- const boundCallback = unbindable();
2328
- const isNone = isEmpty(formatValue);
2329
- const init = () => {
2330
- const selectedCells = getCellsFromSelection(editor);
2331
- const checkNode = (cell) => editor.formatter.match(formatName, { value: formatValue }, cell.dom, isNone);
2332
- // If value is empty (A None-entry in the list), check if the format is not set at all. Otherwise, check if the format is set to the correct value.
2333
- if (isNone) {
2334
- api.setActive(!exists(selectedCells, checkNode));
2335
- boundCallback.set(editor.formatter.formatChanged(formatName, (match) => api.setActive(!match), true));
2336
- }
2337
- else {
2338
- api.setActive(forall(selectedCells, checkNode));
2339
- boundCallback.set(editor.formatter.formatChanged(formatName, api.setActive, false, { value: formatValue }));
2340
- }
2341
- };
2342
- // The editor may or may not have been setup yet, so check for that
2343
- editor.initialized ? init() : editor.on('init', init);
2344
- return boundCallback.clear;
2345
- };
2346
- };
2347
- const isListGroup = (item) => hasNonNullableKey(item, 'menu');
2348
- const buildListItems = (items) => map(items, (item) => {
2349
- // item.text is not documented - maybe deprecated option we can delete??
2350
- const text = item.text || item.title || '';
2351
- if (isListGroup(item)) {
2352
- return {
2353
- text,
2354
- items: buildListItems(item.menu)
2355
- };
2356
- }
2357
- else {
2358
- return {
2359
- text,
2360
- value: item.value
2361
- };
2362
- }
2363
- });
2364
- const buildClassList = (classList) => {
2365
- if (!classList.length) {
2366
- return Optional.none();
2367
- }
2368
- return Optional.some(buildListItems([{ text: 'Select...', value: 'mce-no-match' }, ...classList]));
2369
- };
2370
- const buildMenuItems = (editor, items, format, onAction) => map(items, (item) => {
2371
- // item.text is not documented - maybe deprecated option we can delete??
2372
- const text = item.text || item.title;
2373
- if (isListGroup(item)) {
2374
- return {
2375
- type: 'nestedmenuitem',
2376
- text,
2377
- getSubmenuItems: () => buildMenuItems(editor, item.menu, format, onAction)
2378
- };
2379
- }
2380
- else {
2381
- return {
2382
- text,
2383
- type: 'togglemenuitem',
2384
- onAction: () => onAction(item.value),
2385
- onSetup: onSetupToggle(editor, format, item.value)
2386
- };
2387
- }
2388
- });
2389
- const applyTableCellStyle = (editor, style) => (value) => {
2390
- editor.execCommand('mceTableApplyCellStyle', false, { [style]: value });
2391
- };
2392
- const filterNoneItem = (list) => bind(list, (item) => {
2393
- if (isListGroup(item)) {
2394
- return [{ ...item, menu: filterNoneItem(item.menu) }];
2395
- }
2396
- else {
2397
- return isNotEmpty(item.value) ? [item] : [];
2398
- }
2399
- });
2400
- const generateMenuItemsCallback = (editor, items, format, onAction) => (callback) => callback(buildMenuItems(editor, items, format, onAction));
2401
- const buildColorMenu = (editor, colorList, style) => {
2402
- const colorMap = map(colorList, (entry) => ({
2403
- text: entry.title,
2404
- value: '#' + anyToHex(entry.value).value,
2405
- type: 'choiceitem'
2406
- }));
2407
- return [{
2408
- type: 'fancymenuitem',
2409
- fancytype: 'colorswatch',
2410
- initData: {
2411
- colors: colorMap.length > 0 ? colorMap : undefined,
2412
- allowCustomColors: false
2413
- },
2414
- onAction: (data) => {
2415
- const value = data.value === 'remove' ? '' : data.value;
2416
- editor.execCommand('mceTableApplyCellStyle', false, { [style]: value });
2417
- }
2418
- }];
2419
- };
2420
- const changeRowHeader = (editor) => () => {
2421
- const currentType = editor.queryCommandValue('mceTableRowType');
2422
- const newType = currentType === 'header' ? 'body' : 'header';
2423
- editor.execCommand('mceTableRowType', false, { type: newType });
2424
- };
2425
- const changeColumnHeader = (editor) => () => {
2426
- const currentType = editor.queryCommandValue('mceTableColType');
2427
- const newType = currentType === 'th' ? 'td' : 'th';
2428
- editor.execCommand('mceTableColType', false, { type: newType });
2429
- };
2430
-
2431
- const getClassList$1 = (editor) => buildClassList(getCellClassList(editor))
2432
- .map((items) => ({
2433
- name: 'class',
2434
- type: 'listbox',
2435
- label: 'Class',
2436
- items
2437
- }));
2438
- const children = [
2439
- {
2440
- name: 'width',
2441
- type: 'input',
2442
- label: 'Width'
2443
- },
2444
- {
2445
- name: 'celltype',
2446
- type: 'listbox',
2447
- label: 'Cell type',
2448
- items: [
2449
- { text: 'Cell', value: 'td' },
2450
- { text: 'Header cell', value: 'th' }
2451
- ]
2452
- },
2453
- {
2454
- name: 'scope',
2455
- type: 'listbox',
2456
- label: 'Scope',
2457
- items: [
2458
- { text: 'None', value: '' },
2459
- { text: 'Row', value: 'row' },
2460
- { text: 'Column', value: 'col' },
2461
- { text: 'Row group', value: 'rowgroup' },
2462
- { text: 'Column group', value: 'colgroup' }
2463
- ]
2464
- },
2465
- {
2466
- name: 'halign',
2467
- type: 'listbox',
2468
- label: 'Horizontal align',
2469
- items: [
2470
- { text: 'None', value: '' },
2471
- { text: 'Left', value: 'left' },
2472
- { text: 'Center', value: 'center' },
2473
- { text: 'Right', value: 'right' }
2474
- ]
2475
- },
2476
- {
2477
- name: 'valign',
2478
- type: 'listbox',
2479
- label: 'Vertical align',
2480
- items: verticalAlignValues
2481
- }
2482
- ];
2483
- const getItems$2 = (editor) => children.concat(getClassList$1(editor).toArray());
2484
-
2485
- const getAdvancedTab = (editor, dialogName) => {
2486
- const emptyBorderStyle = [{ text: 'Select...', value: '' }];
2487
- const advTabItems = [
2488
- {
2489
- name: 'borderstyle',
2490
- type: 'listbox',
2491
- label: 'Border style',
2492
- items: emptyBorderStyle.concat(buildListItems(getTableBorderStyles(editor)))
2493
- },
2494
- {
2495
- name: 'bordercolor',
2496
- type: 'colorinput',
2497
- label: 'Border color'
2498
- },
2499
- {
2500
- name: 'backgroundcolor',
2501
- type: 'colorinput',
2502
- label: 'Background color'
2503
- }
2504
- ];
2505
- const borderWidth = {
2506
- name: 'borderwidth',
2507
- type: 'input',
2508
- label: 'Border width'
2509
- };
2510
- const items = dialogName === 'cell' ? [borderWidth].concat(advTabItems) : advTabItems;
2511
- return {
2512
- title: 'Advanced',
2513
- name: 'advanced',
2514
- items
2515
- };
2516
- };
2517
-
2518
- // The get node is required here because it can be transformed
2519
- // when switching between tags (e.g. th and td)
2520
- const normal = (editor, element) => {
2521
- const dom = editor.dom;
2522
- const setAttrib = (attr, value) => {
2523
- dom.setAttrib(element, attr, value);
2524
- };
2525
- const setStyle = (prop, value) => {
2526
- dom.setStyle(element, prop, value);
2527
- };
2528
- const setFormat = (formatName, value) => {
2529
- // Remove format if given an empty string
2530
- if (value === '') {
2531
- editor.formatter.remove(formatName, { value: null }, element, true);
2532
- }
2533
- else {
2534
- editor.formatter.apply(formatName, { value }, element);
2535
- }
2536
- };
2537
- return {
2538
- setAttrib,
2539
- setStyle,
2540
- setFormat
2541
- };
2542
- };
2543
- const DomModifier = {
2544
- normal
2545
- };
2546
-
2547
- const rgbToHex = (value) => startsWith(value, 'rgb') ? rgbaToHexString(value) : value;
2548
- const extractAdvancedStyles = (elm) => {
2549
- const element = SugarElement.fromDom(elm);
2550
- return {
2551
- borderwidth: getRaw$1(element, 'border-width').getOr(''),
2552
- borderstyle: getRaw$1(element, 'border-style').getOr(''),
2553
- bordercolor: getRaw$1(element, 'border-color').map(rgbToHex).getOr(''),
2554
- backgroundcolor: getRaw$1(element, 'background-color').map(rgbToHex).getOr('')
2555
- };
2556
- };
2557
- const getSharedValues = (data) => {
2558
- // TODO surely there's a better way to do this??
2559
- // Mutates baseData to return an object that contains only the values
2560
- // that were the same across all objects in data
2561
- const baseData = data[0];
2562
- const comparisonData = data.slice(1);
2563
- each$1(comparisonData, (items) => {
2564
- each$1(keys(baseData), (key) => {
2565
- each(items, (itemValue, itemKey) => {
2566
- const comparisonValue = baseData[key];
2567
- if (comparisonValue !== '' && key === itemKey) {
2568
- if (comparisonValue !== itemValue) {
2569
- baseData[key] = key === 'class' ? 'mce-no-match' : '';
2570
- }
2571
- }
2572
- });
2573
- });
2574
- });
2575
- return baseData;
2576
- };
2577
- // The extractDataFrom... functions are in this file partly for code reuse and partly so we can test them,
2578
- // because some of these are crazy complicated
2579
- const getAlignment = (formats, formatName, editor, elm) => find(formats, (name) => !isUndefined(editor.formatter.matchNode(elm, formatName + name))).getOr('');
2580
- const getHAlignment = curry(getAlignment, ['left', 'center', 'right'], 'align');
2581
- const getVAlignment = curry(getAlignment, ['top', 'middle', 'bottom'], 'valign');
2582
- const extractDataFromSettings = (editor, hasAdvTableTab) => {
2583
- const style = getDefaultStyles(editor);
2584
- const attrs = getDefaultAttributes(editor);
2585
- const extractAdvancedStyleData = () => ({
2586
- borderstyle: get$3(style, 'border-style').getOr(''),
2587
- bordercolor: rgbToHex(get$3(style, 'border-color').getOr('')),
2588
- backgroundcolor: rgbToHex(get$3(style, 'background-color').getOr(''))
2589
- });
2590
- const defaultData = {
2591
- height: '',
2592
- width: '100%',
2593
- cellspacing: '',
2594
- cellpadding: '',
2595
- caption: false,
2596
- class: '',
2597
- align: '',
2598
- border: ''
2599
- };
2600
- const getBorder = () => {
2601
- const borderWidth = style['border-width'];
2602
- if (shouldStyleWithCss(editor) && borderWidth) {
2603
- return { border: borderWidth };
2604
- }
2605
- return get$3(attrs, 'border').fold(() => ({}), (border) => ({ border }));
2606
- };
2607
- const advStyle = (hasAdvTableTab ? extractAdvancedStyleData() : {});
2608
- const getCellPaddingCellSpacing = () => {
2609
- const spacing = get$3(style, 'border-spacing').or(get$3(attrs, 'cellspacing')).fold(() => ({}), (cellspacing) => ({ cellspacing }));
2610
- const padding = get$3(style, 'border-padding').or(get$3(attrs, 'cellpadding')).fold(() => ({}), (cellpadding) => ({ cellpadding }));
2611
- return {
2612
- ...spacing,
2613
- ...padding
2614
- };
2615
- };
2616
- const data = {
2617
- ...defaultData,
2618
- ...style,
2619
- ...attrs,
2620
- ...advStyle,
2621
- ...getBorder(),
2622
- ...getCellPaddingCellSpacing()
2623
- };
2624
- return data;
2625
- };
2626
- const getRowType = (elm) => table(SugarElement.fromDom(elm)).map((table) => {
2627
- const target = { selection: fromDom(elm.cells) };
2628
- return getRowsType(table, target);
2629
- }).getOr('');
2630
- const extractDataFromTableElement = (editor, elm, hasAdvTableTab) => {
2631
- const getBorder = (dom, elm) => {
2632
- // Cases (in order to check):
2633
- // 1. shouldStyleWithCss - extract border-width style if it exists
2634
- // 2. !shouldStyleWithCss && border attribute - set border attribute as value
2635
- // 3. !shouldStyleWithCss && nothing on the table - grab styles from the first th or td
2636
- const optBorderWidth = getRaw$1(SugarElement.fromDom(elm), 'border-width');
2637
- if (shouldStyleWithCss(editor) && optBorderWidth.isSome()) {
2638
- return optBorderWidth.getOr('');
2639
- }
2640
- return dom.getAttrib(elm, 'border') || getTDTHOverallStyle(editor.dom, elm, 'border-width')
2641
- || getTDTHOverallStyle(editor.dom, elm, 'border') || '';
2642
- };
2643
- const dom = editor.dom;
2644
- const cellspacing = shouldStyleWithCss(editor) ?
2645
- dom.getStyle(elm, 'border-spacing') || dom.getAttrib(elm, 'cellspacing') :
2646
- dom.getAttrib(elm, 'cellspacing') || dom.getStyle(elm, 'border-spacing');
2647
- const cellpadding = shouldStyleWithCss(editor) ?
2648
- getTDTHOverallStyle(dom, elm, 'padding') || dom.getAttrib(elm, 'cellpadding') :
2649
- dom.getAttrib(elm, 'cellpadding') || getTDTHOverallStyle(dom, elm, 'padding');
2650
- return {
2651
- width: dom.getStyle(elm, 'width') || dom.getAttrib(elm, 'width'),
2652
- height: dom.getStyle(elm, 'height') || dom.getAttrib(elm, 'height'),
2653
- cellspacing: cellspacing ?? '',
2654
- cellpadding: cellpadding ?? '',
2655
- border: getBorder(dom, elm),
2656
- caption: !!dom.select('caption', elm)[0],
2657
- class: dom.getAttrib(elm, 'class', ''),
2658
- align: getHAlignment(editor, elm),
2659
- ...(hasAdvTableTab ? extractAdvancedStyles(elm) : {})
2660
- };
2661
- };
2662
- const extractDataFromRowElement = (editor, elm, hasAdvancedRowTab) => {
2663
- const dom = editor.dom;
2664
- return {
2665
- height: dom.getStyle(elm, 'height') || dom.getAttrib(elm, 'height'),
2666
- class: dom.getAttrib(elm, 'class', ''),
2667
- type: getRowType(elm),
2668
- align: getHAlignment(editor, elm),
2669
- ...(hasAdvancedRowTab ? extractAdvancedStyles(elm) : {})
2670
- };
2671
- };
2672
- const extractDataFromCellElement = (editor, cell, hasAdvancedCellTab, column) => {
2673
- const dom = editor.dom;
2674
- const colElm = column.getOr(cell);
2675
- const getStyle = (element, style) => dom.getStyle(element, style) || dom.getAttrib(element, style);
2676
- return {
2677
- width: getStyle(colElm, 'width'),
2678
- scope: dom.getAttrib(cell, 'scope'),
2679
- celltype: getNodeName(cell),
2680
- class: dom.getAttrib(cell, 'class', ''),
2681
- halign: getHAlignment(editor, cell),
2682
- valign: getVAlignment(editor, cell),
2683
- ...(hasAdvancedCellTab ? extractAdvancedStyles(cell) : {})
2684
- };
2685
- };
2686
-
2687
- const getSelectedCells = (table, cells) => {
2688
- const warehouse = Warehouse.fromTable(table);
2689
- const allCells = Warehouse.justCells(warehouse);
2690
- const filtered = filter$1(allCells, (cellA) => exists(cells, (cellB) => eq(cellA.element, cellB)));
2691
- return map(filtered, (cell) => ({
2692
- element: cell.element.dom,
2693
- column: Warehouse.getColumnAt(warehouse, cell.column).map((col) => col.element.dom)
2694
- }));
2695
- };
2696
- const updateSimpleProps$1 = (modifier, colModifier, data, shouldUpdate) => {
2697
- if (shouldUpdate('scope')) {
2698
- modifier.setAttrib('scope', data.scope);
2699
- }
2700
- if (shouldUpdate('class') && data.class !== 'mce-no-match') {
2701
- modifier.setAttrib('class', data.class);
2702
- }
2703
- if (shouldUpdate('width')) {
2704
- colModifier.setStyle('width', addPxSuffix(data.width));
2705
- }
2706
- };
2707
- const updateAdvancedProps$1 = (modifier, data, shouldUpdate) => {
2708
- if (shouldUpdate('backgroundcolor')) {
2709
- modifier.setFormat('tablecellbackgroundcolor', data.backgroundcolor);
2710
- }
2711
- if (shouldUpdate('bordercolor')) {
2712
- modifier.setFormat('tablecellbordercolor', data.bordercolor);
2713
- }
2714
- if (shouldUpdate('borderstyle')) {
2715
- modifier.setFormat('tablecellborderstyle', data.borderstyle);
2716
- }
2717
- if (shouldUpdate('borderwidth')) {
2718
- modifier.setFormat('tablecellborderwidth', addPxSuffix(data.borderwidth));
2719
- }
2720
- };
2721
- const applyStyleData$1 = (editor, cells, data, wasChanged) => {
2722
- const isSingleCell = cells.length === 1;
2723
- each$1(cells, (item) => {
2724
- const cellElm = item.element;
2725
- const shouldOverrideCurrentValue = isSingleCell ? always : wasChanged;
2726
- const modifier = DomModifier.normal(editor, cellElm);
2727
- const colModifier = item.column.map((col) => DomModifier.normal(editor, col)).getOr(modifier);
2728
- updateSimpleProps$1(modifier, colModifier, data, shouldOverrideCurrentValue);
2729
- if (hasAdvancedCellTab(editor)) {
2730
- updateAdvancedProps$1(modifier, data, shouldOverrideCurrentValue);
2731
- }
2732
- // Apply alignment
2733
- if (wasChanged('halign')) {
2734
- setAlign(editor, cellElm, data.halign);
2735
- }
2736
- // Apply vertical alignment
2737
- if (wasChanged('valign')) {
2738
- setVAlign(editor, cellElm, data.valign);
2739
- }
2740
- });
2741
- };
2742
- const applyStructureData$1 = (editor, data) => {
2743
- // Switch cell type if applicable. Note that we specifically tell the command to not fire events
2744
- // as we'll batch the events and fire a `TableModified` event at the end of the updates.
2745
- editor.execCommand('mceTableCellType', false, { type: data.celltype, no_events: true });
2746
- };
2747
- const applyCellData = (editor, cells, oldData, data) => {
2748
- const modifiedData = filter(data, (value, key) => oldData[key] !== value);
2749
- if (size(modifiedData) > 0 && cells.length >= 1) {
2750
- // Retrieve the table before the cells are modified as there is a case where cells
2751
- // are replaced and the reference will be lost when trying to fire events.
2752
- table(cells[0]).each((table) => {
2753
- const selectedCells = getSelectedCells(table, cells);
2754
- // style modified if there's at least one other change apart from 'celltype' and 'scope'
2755
- const styleModified = size(filter(modifiedData, (_value, key) => key !== 'scope' && key !== 'celltype')) > 0;
2756
- const structureModified = has(modifiedData, 'celltype');
2757
- // Update the cells styling using the dialog data
2758
- if (styleModified || has(modifiedData, 'scope')) {
2759
- applyStyleData$1(editor, selectedCells, data, curry(has, modifiedData));
2760
- }
2761
- // Update the cells structure using the dialog data
2762
- if (structureModified) {
2763
- applyStructureData$1(editor, data);
2764
- }
2765
- fireTableModified(editor, table.dom, {
2766
- structure: structureModified,
2767
- style: styleModified,
2768
- });
2769
- });
2770
- }
2771
- };
2772
- const onSubmitCellForm = (editor, cells, oldData, api) => {
2773
- const data = api.getData();
2774
- api.close();
2775
- editor.undoManager.transact(() => {
2776
- applyCellData(editor, cells, oldData, data);
2777
- editor.focus();
2778
- });
2779
- };
2780
- const getData$1 = (editor, cells) => {
2781
- const cellsData = table(cells[0]).map((table) => map(getSelectedCells(table, cells), (item) => extractDataFromCellElement(editor, item.element, hasAdvancedCellTab(editor), item.column)));
2782
- return getSharedValues(cellsData.getOrDie());
2783
- };
2784
- const open$2 = (editor) => {
2785
- const cells = getCellsFromSelection(editor);
2786
- // Check if there are any cells to operate on
2787
- if (cells.length === 0) {
2788
- return;
2789
- }
2790
- const data = getData$1(editor, cells);
2791
- const dialogTabPanel = {
2792
- type: 'tabpanel',
2793
- tabs: [
2794
- {
2795
- title: 'General',
2796
- name: 'general',
2797
- items: getItems$2(editor)
2798
- },
2799
- getAdvancedTab(editor, 'cell')
2800
- ]
2801
- };
2802
- const dialogPanel = {
2803
- type: 'panel',
2804
- items: [
2805
- {
2806
- type: 'grid',
2807
- columns: 2,
2808
- items: getItems$2(editor)
2809
- }
2810
- ]
2811
- };
2812
- editor.windowManager.open({
2813
- title: 'Cell Properties',
2814
- size: 'normal',
2815
- body: hasAdvancedCellTab(editor) ? dialogTabPanel : dialogPanel,
2816
- buttons: [
2817
- {
2818
- type: 'cancel',
2819
- name: 'cancel',
2820
- text: 'Cancel'
2821
- },
2822
- {
2823
- type: 'submit',
2824
- name: 'save',
2825
- text: 'Save',
2826
- primary: true
2827
- }
2828
- ],
2829
- initialData: data,
2830
- onSubmit: curry(onSubmitCellForm, editor, cells, data)
2831
- });
2832
- };
2833
-
2834
- const getClassList = (editor) => buildClassList(getRowClassList(editor))
2835
- .map((items) => ({
2836
- name: 'class',
2837
- type: 'listbox',
2838
- label: 'Class',
2839
- items
2840
- }));
2841
- const formChildren = [
2842
- {
2843
- type: 'listbox',
2844
- name: 'type',
2845
- label: 'Row type',
2846
- items: [
2847
- { text: 'Header', value: 'header' },
2848
- { text: 'Body', value: 'body' },
2849
- { text: 'Footer', value: 'footer' }
2850
- ]
2851
- },
2852
- {
2853
- type: 'listbox',
2854
- name: 'align',
2855
- label: 'Alignment',
2856
- items: [
2857
- { text: 'None', value: '' },
2858
- { text: 'Left', value: 'left' },
2859
- { text: 'Center', value: 'center' },
2860
- { text: 'Right', value: 'right' }
2861
- ]
2862
- },
2863
- {
2864
- label: 'Height',
2865
- name: 'height',
2866
- type: 'input'
2867
- }
2868
- ];
2869
- const getItems$1 = (editor) => formChildren.concat(getClassList(editor).toArray());
2870
-
2871
- const updateSimpleProps = (modifier, data, shouldUpdate) => {
2872
- if (shouldUpdate('class') && data.class !== 'mce-no-match') {
2873
- modifier.setAttrib('class', data.class);
2874
- }
2875
- if (shouldUpdate('height')) {
2876
- modifier.setStyle('height', addPxSuffix(data.height));
2877
- }
2878
- };
2879
- const updateAdvancedProps = (modifier, data, shouldUpdate) => {
2880
- if (shouldUpdate('backgroundcolor')) {
2881
- modifier.setStyle('background-color', data.backgroundcolor);
2882
- }
2883
- if (shouldUpdate('bordercolor')) {
2884
- modifier.setStyle('border-color', data.bordercolor);
2885
- }
2886
- if (shouldUpdate('borderstyle')) {
2887
- modifier.setStyle('border-style', data.borderstyle);
2888
- }
2889
- };
2890
- const applyStyleData = (editor, rows, data, wasChanged) => {
2891
- const isSingleRow = rows.length === 1;
2892
- const shouldOverrideCurrentValue = isSingleRow ? always : wasChanged;
2893
- each$1(rows, (rowElm) => {
2894
- const rowCells = children$1(SugarElement.fromDom(rowElm), 'td,th');
2895
- const modifier = DomModifier.normal(editor, rowElm);
2896
- updateSimpleProps(modifier, data, shouldOverrideCurrentValue);
2897
- if (hasAdvancedRowTab(editor)) {
2898
- updateAdvancedProps(modifier, data, shouldOverrideCurrentValue);
2899
- }
2900
- // TINY-10617: Simplify number of height styles when applying height on tr
2901
- if (wasChanged('height')) {
2902
- each$1(rowCells, (cell) => {
2903
- editor.dom.setStyle(cell.dom, 'height', null);
2904
- });
2905
- }
2906
- if (wasChanged('align')) {
2907
- setAlign(editor, rowElm, data.align);
2908
- }
2909
- });
2910
- };
2911
- const applyStructureData = (editor, data) => {
2912
- // Switch cell type if applicable. Note that we specifically tell the command to not fire events
2913
- // as we'll batch the events and fire a `TableModified` event at the end of the updates.
2914
- editor.execCommand('mceTableRowType', false, { type: data.type, no_events: true });
2915
- };
2916
- const applyRowData = (editor, rows, oldData, data) => {
2917
- const modifiedData = filter(data, (value, key) => oldData[key] !== value);
2918
- if (size(modifiedData) > 0) {
2919
- const typeModified = has(modifiedData, 'type');
2920
- // style modified if there's at least one other change apart from 'type'
2921
- const styleModified = typeModified ? size(modifiedData) > 1 : true;
2922
- // Update the rows styling using the dialog data
2923
- if (styleModified) {
2924
- applyStyleData(editor, rows, data, curry(has, modifiedData));
2925
- }
2926
- // Update the rows structure using the dialog data
2927
- if (typeModified) {
2928
- applyStructureData(editor, data);
2929
- }
2930
- table(SugarElement.fromDom(rows[0])).each((table) => fireTableModified(editor, table.dom, {
2931
- structure: typeModified,
2932
- style: styleModified
2933
- }));
2934
- }
2935
- };
2936
- const onSubmitRowForm = (editor, rows, oldData, api) => {
2937
- const data = api.getData();
2938
- api.close();
2939
- editor.undoManager.transact(() => {
2940
- applyRowData(editor, rows, oldData, data);
2941
- editor.focus();
2942
- });
2943
- };
2944
- const open$1 = (editor) => {
2945
- const rows = getRowsFromSelection(getSelectionStart(editor), ephemera.selected);
2946
- // Check if there are any rows to operate on
2947
- if (rows.length === 0) {
2948
- return;
2949
- }
2950
- // Get current data and find shared values between rows
2951
- const rowsData = map(rows, (rowElm) => extractDataFromRowElement(editor, rowElm.dom, hasAdvancedRowTab(editor)));
2952
- const data = getSharedValues(rowsData);
2953
- const dialogTabPanel = {
2954
- type: 'tabpanel',
2955
- tabs: [
2956
- {
2957
- title: 'General',
2958
- name: 'general',
2959
- items: getItems$1(editor)
2960
- },
2961
- getAdvancedTab(editor, 'row')
2962
- ]
2963
- };
2964
- const dialogPanel = {
2965
- type: 'panel',
2966
- items: [
2967
- {
2968
- type: 'grid',
2969
- columns: 2,
2970
- items: getItems$1(editor)
2971
- }
2972
- ]
2973
- };
2974
- editor.windowManager.open({
2975
- title: 'Row Properties',
2976
- size: 'normal',
2977
- body: hasAdvancedRowTab(editor) ? dialogTabPanel : dialogPanel,
2978
- buttons: [
2979
- {
2980
- type: 'cancel',
2981
- name: 'cancel',
2982
- text: 'Cancel'
2983
- },
2984
- {
2985
- type: 'submit',
2986
- name: 'save',
2987
- text: 'Save',
2988
- primary: true
2989
- }
2990
- ],
2991
- initialData: data,
2992
- onSubmit: curry(onSubmitRowForm, editor, map(rows, (r) => r.dom), data)
2993
- });
2994
- };
2995
-
2996
- const getItems = (editor, classes, insertNewTable) => {
2997
- const rowColCountItems = !insertNewTable ? [] : [
2998
- {
2999
- type: 'input',
3000
- name: 'cols',
3001
- label: 'Cols',
3002
- inputMode: 'numeric'
3003
- },
3004
- {
3005
- type: 'input',
3006
- name: 'rows',
3007
- label: 'Rows',
3008
- inputMode: 'numeric'
3009
- }
3010
- ];
3011
- const alwaysItems = [
3012
- {
3013
- type: 'input',
3014
- name: 'width',
3015
- label: 'Width'
3016
- },
3017
- {
3018
- type: 'input',
3019
- name: 'height',
3020
- label: 'Height'
3021
- }
3022
- ];
3023
- const appearanceItems = hasAppearanceOptions(editor) ? [
3024
- {
3025
- type: 'input',
3026
- name: 'cellspacing',
3027
- label: 'Cell spacing',
3028
- inputMode: 'numeric'
3029
- },
3030
- {
3031
- type: 'input',
3032
- name: 'cellpadding',
3033
- label: 'Cell padding',
3034
- inputMode: 'numeric'
3035
- },
3036
- {
3037
- type: 'input',
3038
- name: 'border',
3039
- label: 'Border width'
3040
- },
3041
- {
3042
- type: 'label',
3043
- label: 'Caption',
3044
- items: [
3045
- {
3046
- type: 'checkbox',
3047
- name: 'caption',
3048
- label: 'Show caption'
3049
- }
3050
- ]
3051
- }
3052
- ] : [];
3053
- const alignmentItem = [
3054
- {
3055
- type: 'listbox',
3056
- name: 'align',
3057
- label: 'Alignment',
3058
- items: [
3059
- { text: 'None', value: '' },
3060
- { text: 'Left', value: 'left' },
3061
- { text: 'Center', value: 'center' },
3062
- { text: 'Right', value: 'right' }
3063
- ]
3064
- }
3065
- ];
3066
- const classListItem = classes.length > 0 ? [
3067
- {
3068
- name: 'class',
3069
- type: 'listbox',
3070
- label: 'Class',
3071
- items: classes
3072
- }
3073
- ] : [];
3074
- return rowColCountItems.concat(alwaysItems).concat(appearanceItems).concat(alignmentItem).concat(classListItem);
3075
- };
3076
-
3077
- // Explore the layers of the table till we find the first layer of tds or ths
3078
- const styleTDTH = (dom, elm, name, value) => {
3079
- if (elm.tagName === 'TD' || elm.tagName === 'TH') {
3080
- if (isString(name) && isNonNullable(value)) {
3081
- dom.setStyle(elm, name, value);
3082
- }
3083
- else {
3084
- dom.setStyles(elm, name);
3085
- }
3086
- }
3087
- else {
3088
- if (elm.children) {
3089
- for (let i = 0; i < elm.children.length; i++) {
3090
- styleTDTH(dom, elm.children[i], name, value);
3091
- }
3092
- }
3093
- }
3094
- };
3095
- const applyDataToElement = (editor, tableElm, data, shouldApplyOnCell) => {
3096
- const dom = editor.dom;
3097
- const attrs = {};
3098
- const styles = {};
3099
- const shouldStyleWithCss$1 = shouldStyleWithCss(editor);
3100
- const hasAdvancedTableTab$1 = hasAdvancedTableTab(editor);
3101
- const borderIsZero = parseFloat(data.border) === 0;
3102
- if (!isUndefined(data.class) && data.class !== 'mce-no-match') {
3103
- attrs.class = data.class;
3104
- }
3105
- styles.height = addPxSuffix(data.height);
3106
- if (shouldStyleWithCss$1) {
3107
- styles.width = addPxSuffix(data.width);
3108
- }
3109
- else if (dom.getAttrib(tableElm, 'width')) {
3110
- attrs.width = removePxSuffix(data.width);
3111
- }
3112
- if (shouldStyleWithCss$1) {
3113
- if (borderIsZero) {
3114
- attrs.border = 0;
3115
- styles['border-width'] = '';
3116
- }
3117
- else {
3118
- styles['border-width'] = addPxSuffix(data.border);
3119
- attrs.border = 1;
3120
- }
3121
- styles['border-spacing'] = addPxSuffix(data.cellspacing);
3122
- }
3123
- else {
3124
- attrs.border = borderIsZero ? 0 : data.border;
3125
- attrs.cellpadding = data.cellpadding;
3126
- attrs.cellspacing = data.cellspacing;
3127
- }
3128
- // TINY-9837: Relevant data are applied on child TD/THs only if they have been modified since the previous dialog submission
3129
- if (shouldStyleWithCss$1 && tableElm.children) {
3130
- const cellStyles = {};
3131
- if (borderIsZero) {
3132
- cellStyles['border-width'] = '';
3133
- }
3134
- else if (shouldApplyOnCell.border) {
3135
- cellStyles['border-width'] = addPxSuffix(data.border);
3136
- }
3137
- if (shouldApplyOnCell.cellpadding) {
3138
- cellStyles.padding = addPxSuffix(data.cellpadding);
3139
- }
3140
- if (hasAdvancedTableTab$1 && shouldApplyOnCell.bordercolor) {
3141
- cellStyles['border-color'] = data.bordercolor;
3142
- }
3143
- if (!isEmpty$1(cellStyles)) {
3144
- for (let i = 0; i < tableElm.children.length; i++) {
3145
- styleTDTH(dom, tableElm.children[i], cellStyles);
3146
- }
3147
- }
3148
- }
3149
- if (hasAdvancedTableTab$1) {
3150
- const advData = data;
3151
- styles['background-color'] = advData.backgroundcolor;
3152
- styles['border-color'] = advData.bordercolor;
3153
- styles['border-style'] = advData.borderstyle;
3154
- }
3155
- dom.setStyles(tableElm, { ...getDefaultStyles(editor), ...styles });
3156
- dom.setAttribs(tableElm, { ...getDefaultAttributes(editor), ...attrs });
3157
- };
3158
- const onSubmitTableForm = (editor, tableElm, oldData, api) => {
3159
- const dom = editor.dom;
3160
- const data = api.getData();
3161
- const modifiedData = filter(data, (value, key) => oldData[key] !== value);
3162
- api.close();
3163
- editor.undoManager.transact(() => {
3164
- if (!tableElm) {
3165
- const cols = toInt(data.cols).getOr(1);
3166
- const rows = toInt(data.rows).getOr(1);
3167
- // Cases 1 & 3 - inserting a table
3168
- editor.execCommand('mceInsertTable', false, { rows, columns: cols });
3169
- tableElm = getSelectionCell(getSelectionStart(editor), getIsRoot(editor))
3170
- .bind((cell) => table(cell, getIsRoot(editor)))
3171
- .map((table) => table.dom)
3172
- .getOrDie();
3173
- }
3174
- if (size(modifiedData) > 0) {
3175
- const applicableCellProperties = {
3176
- border: has(modifiedData, 'border'),
3177
- bordercolor: has(modifiedData, 'bordercolor'),
3178
- cellpadding: has(modifiedData, 'cellpadding')
3179
- };
3180
- applyDataToElement(editor, tableElm, data, applicableCellProperties);
3181
- // Toggle caption on/off
3182
- const captionElm = dom.select('caption', tableElm)[0];
3183
- if (captionElm && !data.caption || !captionElm && data.caption) {
3184
- editor.execCommand('mceTableToggleCaption');
3185
- }
3186
- setAlign(editor, tableElm, data.align);
3187
- }
3188
- editor.focus();
3189
- editor.addVisual();
3190
- if (size(modifiedData) > 0) {
3191
- const captionModified = has(modifiedData, 'caption');
3192
- // style modified if there's at least one other change apart from 'caption'
3193
- const styleModified = captionModified ? size(modifiedData) > 1 : true;
3194
- fireTableModified(editor, tableElm, { structure: captionModified, style: styleModified });
3195
- }
3196
- });
3197
- };
3198
- const open = (editor, insertNewTable) => {
3199
- const dom = editor.dom;
3200
- let tableElm;
3201
- let data = extractDataFromSettings(editor, hasAdvancedTableTab(editor));
3202
- // Cases for creation/update of tables:
3203
- // 1. isNew == true - called by mceInsertTable - we are inserting a new table so we don't care what the selection's parent is,
3204
- // and we need to add cols and rows input fields to the dialog
3205
- // 2. isNew == false && selection parent is a table - update the table
3206
- // 3. isNew == false && selection parent isn't a table - open dialog with default values and insert a table
3207
- if (insertNewTable) {
3208
- // Case 1 - isNew == true. We're inserting a new table so use defaults and add cols and rows + adv properties.
3209
- data.cols = '1';
3210
- data.rows = '1';
3211
- if (hasAdvancedTableTab(editor)) {
3212
- data.borderstyle = '';
3213
- data.bordercolor = '';
3214
- data.backgroundcolor = '';
3215
- }
3216
- }
3217
- else {
3218
- tableElm = dom.getParent(editor.selection.getStart(), 'table', editor.getBody());
3219
- if (tableElm) {
3220
- // Case 2 - isNew == false && table parent
3221
- data = extractDataFromTableElement(editor, tableElm, hasAdvancedTableTab(editor));
3222
- }
3223
- else {
3224
- // Case 3 - isNew == false && non-table parent. data is set to basic defaults so just add the adv properties if needed
3225
- if (hasAdvancedTableTab(editor)) {
3226
- data.borderstyle = '';
3227
- data.bordercolor = '';
3228
- data.backgroundcolor = '';
3229
- }
3230
- }
3231
- }
3232
- const classes = buildClassList(getTableClassList(editor));
3233
- if (classes.isSome()) {
3234
- if (data.class) {
3235
- data.class = data.class.replace(/\s*mce\-item\-table\s*/g, '');
3236
- }
3237
- }
3238
- const generalPanel = {
3239
- type: 'grid',
3240
- columns: 2,
3241
- items: getItems(editor, classes.getOr([]), insertNewTable)
3242
- };
3243
- const nonAdvancedForm = () => ({
3244
- type: 'panel',
3245
- items: [generalPanel]
3246
- });
3247
- const advancedForm = () => ({
3248
- type: 'tabpanel',
3249
- tabs: [
3250
- {
3251
- title: 'General',
3252
- name: 'general',
3253
- items: [generalPanel]
3254
- },
3255
- getAdvancedTab(editor, 'table')
3256
- ]
3257
- });
3258
- const dialogBody = hasAdvancedTableTab(editor) ? advancedForm() : nonAdvancedForm();
3259
- editor.windowManager.open({
3260
- title: 'Table Properties',
3261
- size: 'normal',
3262
- body: dialogBody,
3263
- onSubmit: curry(onSubmitTableForm, editor, tableElm, data),
3264
- buttons: [
3265
- {
3266
- type: 'cancel',
3267
- name: 'cancel',
3268
- text: 'Cancel'
3269
- },
3270
- {
3271
- type: 'submit',
3272
- name: 'save',
3273
- text: 'Save',
3274
- primary: true
3275
- }
3276
- ],
3277
- initialData: data
3278
- });
3279
- };
3280
-
3281
- const registerCommands = (editor) => {
3282
- const runAction = (f) => {
3283
- if (isInEditableContext(getSelectionStart(editor))) {
3284
- f();
3285
- }
3286
- };
3287
- // Register dialog commands
3288
- each({
3289
- // AP-101 TableDialog.open renders a slightly different dialog if isNew is true
3290
- mceTableProps: curry(open, editor, false),
3291
- mceTableRowProps: curry(open$1, editor),
3292
- mceTableCellProps: curry(open$2, editor),
3293
- mceInsertTableDialog: curry(open, editor, true),
3294
- }, (func, name) => editor.addCommand(name, () => runAction(func)));
3295
- };
3296
-
3297
- /*
3298
- NOTE: This file is partially duplicated in the following locations:
3299
- - models/dom/table/queries/TableTargets.ts
3300
- - advtable
3301
- Make sure that if making changes to this file, the other files are updated as well
3302
- */
3303
- const noMenu = (cell) => ({
3304
- element: cell,
3305
- mergable: Optional.none(),
3306
- unmergable: Optional.none(),
3307
- selection: [cell]
3308
- });
3309
- const forMenu = (selectedCells, table, cell) => ({
3310
- element: cell,
3311
- mergable: mergable(table, selectedCells, ephemera),
3312
- unmergable: unmergable(selectedCells),
3313
- selection: selection(selectedCells)
3314
- });
3315
-
3316
- const getSelectionTargets = (editor) => {
3317
- const targets = Cell(Optional.none());
3318
- const changeHandlers = Cell([]);
3319
- let selectionDetails = Optional.none();
3320
- const isCaption = isTag('caption');
3321
- const isDisabledForSelection = (key) => selectionDetails.forall((details) => !details[key]);
3322
- const getStart = () => getSelectionCellOrCaption(getSelectionStart(editor), getIsRoot(editor));
3323
- const getEnd = () => getSelectionCellOrCaption(getSelectionEnd(editor), getIsRoot(editor));
3324
- const findTargets = () => getStart().bind((startCellOrCaption) => flatten(lift2(table(startCellOrCaption), getEnd().bind(table), (startTable, endTable) => {
3325
- if (eq(startTable, endTable)) {
3326
- if (isCaption(startCellOrCaption)) {
3327
- return Optional.some(noMenu(startCellOrCaption));
3328
- }
3329
- else {
3330
- return Optional.some(forMenu(getCellsFromSelection(editor), startTable, startCellOrCaption));
3331
- }
3332
- }
3333
- return Optional.none();
3334
- })));
3335
- const getExtractedDetails = (targets) => {
3336
- const tableOpt = table(targets.element);
3337
- return tableOpt.map((table) => {
3338
- const warehouse = Warehouse.fromTable(table);
3339
- const selectedCells = onCells(warehouse, targets).getOr([]);
3340
- const locked = foldl(selectedCells, (acc, cell) => {
3341
- if (cell.isLocked) {
3342
- acc.onAny = true;
3343
- if (cell.column === 0) {
3344
- acc.onFirst = true;
3345
- }
3346
- else if (cell.column + cell.colspan >= warehouse.grid.columns) {
3347
- acc.onLast = true;
3348
- }
3349
- }
3350
- return acc;
3351
- }, { onAny: false, onFirst: false, onLast: false });
3352
- return {
3353
- mergeable: onUnlockedMergable(warehouse, targets).isSome(),
3354
- unmergeable: onUnlockedUnmergable(warehouse, targets).isSome(),
3355
- locked
3356
- };
3357
- });
3358
- };
3359
- const resetTargets = () => {
3360
- // Reset the targets
3361
- targets.set(cached(findTargets)());
3362
- // Reset the selection details
3363
- selectionDetails = targets.get().bind(getExtractedDetails);
3364
- // Trigger change handlers
3365
- each$1(changeHandlers.get(), call);
3366
- };
3367
- const setupHandler = (handler) => {
3368
- // Execute the handler to set the initial state
3369
- handler();
3370
- // Register the handler so we can update the state when resetting targets
3371
- changeHandlers.set(changeHandlers.get().concat([handler]));
3372
- return () => {
3373
- changeHandlers.set(filter$1(changeHandlers.get(), (h) => h !== handler));
3374
- };
3375
- };
3376
- const onSetup = (api, isDisabled) => setupHandler(() => targets.get().fold(() => {
3377
- api.setEnabled(false);
3378
- }, (targets) => {
3379
- api.setEnabled(!isDisabled(targets) && editor.selection.isEditable());
3380
- }));
3381
- const onSetupWithToggle = (api, isDisabled, isActive) => setupHandler(() => targets.get().fold(() => {
3382
- api.setEnabled(false);
3383
- api.setActive(false);
3384
- }, (targets) => {
3385
- api.setEnabled(!isDisabled(targets) && editor.selection.isEditable());
3386
- api.setActive(isActive(targets));
3387
- }));
3388
- const isDisabledFromLocked = (lockedDisable) => selectionDetails.exists((details) => details.locked[lockedDisable]);
3389
- const onSetupTable = (api) => onSetup(api, (_) => false);
3390
- const onSetupCellOrRow = (api) => onSetup(api, (targets) => isCaption(targets.element));
3391
- const onSetupColumn = (lockedDisable) => (api) => onSetup(api, (targets) => isCaption(targets.element) || isDisabledFromLocked(lockedDisable));
3392
- const onSetupPasteable = (getClipboardData) => (api) => onSetup(api, (targets) => isCaption(targets.element) || getClipboardData().isNone());
3393
- const onSetupPasteableColumn = (getClipboardData, lockedDisable) => (api) => onSetup(api, (targets) => isCaption(targets.element) || getClipboardData().isNone() || isDisabledFromLocked(lockedDisable));
3394
- const onSetupMergeable = (api) => onSetup(api, (_targets) => isDisabledForSelection('mergeable'));
3395
- const onSetupUnmergeable = (api) => onSetup(api, (_targets) => isDisabledForSelection('unmergeable'));
3396
- const onSetupTableWithCaption = (api) => {
3397
- return onSetupWithToggle(api, never, (targets) => {
3398
- const tableOpt = table(targets.element, getIsRoot(editor));
3399
- return tableOpt.exists((table) => child(table, 'caption'));
3400
- });
3401
- };
3402
- const onSetupTableHeaders = (command, headerType) => (api) => {
3403
- return onSetupWithToggle(api, (targets) => isCaption(targets.element), () => editor.queryCommandValue(command) === headerType);
3404
- };
3405
- const onSetupTableRowHeaders = onSetupTableHeaders('mceTableRowType', 'header');
3406
- const onSetupTableColumnHeaders = onSetupTableHeaders('mceTableColType', 'th');
3407
- editor.on('NodeChange ExecCommand TableSelectorChange', resetTargets);
3408
- return {
3409
- onSetupTable,
3410
- onSetupCellOrRow,
3411
- onSetupColumn,
3412
- onSetupPasteable,
3413
- onSetupPasteableColumn,
3414
- onSetupMergeable,
3415
- onSetupUnmergeable,
3416
- resetTargets,
3417
- onSetupTableWithCaption,
3418
- onSetupTableRowHeaders,
3419
- onSetupTableColumnHeaders,
3420
- targets: targets.get
3421
- };
3422
- };
3423
-
3424
- var global = tinymce.util.Tools.resolve('tinymce.FakeClipboard');
3425
-
3426
- /*
3427
- NOTE: This file is duplicated in the following locations:
3428
- - models/dom/table/api/Clipboard.ts
3429
- Make sure that if making changes to this file, the other files are updated as well
3430
- */
3431
- const tableTypeBase = 'x-tinymce/dom-table-';
3432
- const tableTypeRow = tableTypeBase + 'rows';
3433
- const tableTypeColumn = tableTypeBase + 'columns';
3434
- const getData = (type) => {
3435
- const items = global.read() ?? [];
3436
- return findMap(items, (item) => Optional.from(item.getType(type)));
3437
- };
3438
- const getRows = () => getData(tableTypeRow);
3439
- const getColumns = () => getData(tableTypeColumn);
3440
-
3441
- const onSetupEditable$1 = (editor) => (api) => {
3442
- const nodeChanged = () => {
3443
- api.setEnabled(editor.selection.isEditable());
3444
- };
3445
- editor.on('NodeChange', nodeChanged);
3446
- nodeChanged();
3447
- return () => {
3448
- editor.off('NodeChange', nodeChanged);
3449
- };
3450
- };
3451
- const addButtons = (editor, selectionTargets) => {
3452
- editor.ui.registry.addMenuButton('table', {
3453
- tooltip: 'Table',
3454
- icon: 'table',
3455
- onSetup: onSetupEditable$1(editor),
3456
- fetch: (callback) => callback('inserttable | cell row column | advtablesort | tableprops deletetable')
3457
- });
3458
- const cmd = (command) => () => editor.execCommand(command);
3459
- // TODO: TINY-8172 Unwind this when an alternative solution is found
3460
- const addButtonIfRegistered = (name, spec) => {
3461
- if (editor.queryCommandSupported(spec.command)) {
3462
- editor.ui.registry.addButton(name, {
3463
- ...spec,
3464
- onAction: isFunction(spec.onAction) ? spec.onAction : cmd(spec.command)
3465
- });
3466
- }
3467
- };
3468
- // TODO: TINY-8172 Unwind this when an alternative solution is found
3469
- const addToggleButtonIfRegistered = (name, spec) => {
3470
- if (editor.queryCommandSupported(spec.command)) {
3471
- editor.ui.registry.addToggleButton(name, {
3472
- ...spec,
3473
- onAction: isFunction(spec.onAction) ? spec.onAction : cmd(spec.command)
3474
- });
3475
- }
3476
- };
3477
- addButtonIfRegistered('tableprops', {
3478
- tooltip: 'Table properties',
3479
- command: 'mceTableProps',
3480
- icon: 'table',
3481
- onSetup: selectionTargets.onSetupTable
3482
- });
3483
- addButtonIfRegistered('tabledelete', {
3484
- tooltip: 'Delete table',
3485
- command: 'mceTableDelete',
3486
- icon: 'table-delete-table',
3487
- onSetup: selectionTargets.onSetupTable
3488
- });
3489
- addButtonIfRegistered('tablecellprops', {
3490
- tooltip: 'Cell properties',
3491
- command: 'mceTableCellProps',
3492
- icon: 'table-cell-properties',
3493
- onSetup: selectionTargets.onSetupCellOrRow
3494
- });
3495
- addButtonIfRegistered('tablemergecells', {
3496
- tooltip: 'Merge cells',
3497
- command: 'mceTableMergeCells',
3498
- icon: 'table-merge-cells',
3499
- onSetup: selectionTargets.onSetupMergeable
3500
- });
3501
- addButtonIfRegistered('tablesplitcells', {
3502
- tooltip: 'Split cell',
3503
- command: 'mceTableSplitCells',
3504
- icon: 'table-split-cells',
3505
- onSetup: selectionTargets.onSetupUnmergeable
3506
- });
3507
- addButtonIfRegistered('tableinsertrowbefore', {
3508
- tooltip: 'Insert row before',
3509
- command: 'mceTableInsertRowBefore',
3510
- icon: 'table-insert-row-above',
3511
- onSetup: selectionTargets.onSetupCellOrRow
3512
- });
3513
- addButtonIfRegistered('tableinsertrowafter', {
3514
- tooltip: 'Insert row after',
3515
- command: 'mceTableInsertRowAfter',
3516
- icon: 'table-insert-row-after',
3517
- onSetup: selectionTargets.onSetupCellOrRow
3518
- });
3519
- addButtonIfRegistered('tabledeleterow', {
3520
- tooltip: 'Delete row',
3521
- command: 'mceTableDeleteRow',
3522
- icon: 'table-delete-row',
3523
- onSetup: selectionTargets.onSetupCellOrRow
3524
- });
3525
- addButtonIfRegistered('tablerowprops', {
3526
- tooltip: 'Row properties',
3527
- command: 'mceTableRowProps',
3528
- icon: 'table-row-properties',
3529
- onSetup: selectionTargets.onSetupCellOrRow
3530
- });
3531
- addButtonIfRegistered('tableinsertcolbefore', {
3532
- tooltip: 'Insert column before',
3533
- command: 'mceTableInsertColBefore',
3534
- icon: 'table-insert-column-before',
3535
- onSetup: selectionTargets.onSetupColumn("onFirst" /* LockedDisable.onFirst */)
3536
- });
3537
- addButtonIfRegistered('tableinsertcolafter', {
3538
- tooltip: 'Insert column after',
3539
- command: 'mceTableInsertColAfter',
3540
- icon: 'table-insert-column-after',
3541
- onSetup: selectionTargets.onSetupColumn("onLast" /* LockedDisable.onLast */)
3542
- });
3543
- addButtonIfRegistered('tabledeletecol', {
3544
- tooltip: 'Delete column',
3545
- command: 'mceTableDeleteCol',
3546
- icon: 'table-delete-column',
3547
- onSetup: selectionTargets.onSetupColumn("onAny" /* LockedDisable.onAny */)
3548
- });
3549
- addButtonIfRegistered('tablecutrow', {
3550
- tooltip: 'Cut row',
3551
- command: 'mceTableCutRow',
3552
- icon: 'cut-row',
3553
- onSetup: selectionTargets.onSetupCellOrRow
3554
- });
3555
- addButtonIfRegistered('tablecopyrow', {
3556
- tooltip: 'Copy row',
3557
- command: 'mceTableCopyRow',
3558
- icon: 'duplicate-row',
3559
- onSetup: selectionTargets.onSetupCellOrRow
3560
- });
3561
- addButtonIfRegistered('tablepasterowbefore', {
3562
- tooltip: 'Paste row before',
3563
- command: 'mceTablePasteRowBefore',
3564
- icon: 'paste-row-before',
3565
- onSetup: selectionTargets.onSetupPasteable(getRows)
3566
- });
3567
- addButtonIfRegistered('tablepasterowafter', {
3568
- tooltip: 'Paste row after',
3569
- command: 'mceTablePasteRowAfter',
3570
- icon: 'paste-row-after',
3571
- onSetup: selectionTargets.onSetupPasteable(getRows)
3572
- });
3573
- addButtonIfRegistered('tablecutcol', {
3574
- tooltip: 'Cut column',
3575
- command: 'mceTableCutCol',
3576
- icon: 'cut-column',
3577
- onSetup: selectionTargets.onSetupColumn("onAny" /* LockedDisable.onAny */)
3578
- });
3579
- addButtonIfRegistered('tablecopycol', {
3580
- tooltip: 'Copy column',
3581
- command: 'mceTableCopyCol',
3582
- icon: 'duplicate-column',
3583
- onSetup: selectionTargets.onSetupColumn("onAny" /* LockedDisable.onAny */)
3584
- });
3585
- addButtonIfRegistered('tablepastecolbefore', {
3586
- tooltip: 'Paste column before',
3587
- command: 'mceTablePasteColBefore',
3588
- icon: 'paste-column-before',
3589
- onSetup: selectionTargets.onSetupPasteableColumn(getColumns, "onFirst" /* LockedDisable.onFirst */)
3590
- });
3591
- addButtonIfRegistered('tablepastecolafter', {
3592
- tooltip: 'Paste column after',
3593
- command: 'mceTablePasteColAfter',
3594
- icon: 'paste-column-after',
3595
- onSetup: selectionTargets.onSetupPasteableColumn(getColumns, "onLast" /* LockedDisable.onLast */)
3596
- });
3597
- addButtonIfRegistered('tableinsertdialog', {
3598
- tooltip: 'Insert table',
3599
- command: 'mceInsertTableDialog',
3600
- icon: 'table',
3601
- onSetup: onSetupEditable$1(editor)
3602
- });
3603
- const tableClassList = filterNoneItem(getTableClassList(editor));
3604
- if (tableClassList.length !== 0 && editor.queryCommandSupported('mceTableToggleClass')) {
3605
- editor.ui.registry.addMenuButton('tableclass', {
3606
- icon: 'table-classes',
3607
- tooltip: 'Table styles',
3608
- fetch: generateMenuItemsCallback(editor, tableClassList, 'tableclass', (value) => editor.execCommand('mceTableToggleClass', false, value)),
3609
- onSetup: selectionTargets.onSetupTable
3610
- });
3611
- }
3612
- const tableCellClassList = filterNoneItem(getCellClassList(editor));
3613
- if (tableCellClassList.length !== 0 && editor.queryCommandSupported('mceTableCellToggleClass')) {
3614
- editor.ui.registry.addMenuButton('tablecellclass', {
3615
- icon: 'table-cell-classes',
3616
- tooltip: 'Cell styles',
3617
- fetch: generateMenuItemsCallback(editor, tableCellClassList, 'tablecellclass', (value) => editor.execCommand('mceTableCellToggleClass', false, value)),
3618
- onSetup: selectionTargets.onSetupCellOrRow
3619
- });
3620
- }
3621
- // TODO: TINY-8172 Unwind this when an alternative solution is found
3622
- if (editor.queryCommandSupported('mceTableApplyCellStyle')) {
3623
- editor.ui.registry.addMenuButton('tablecellvalign', {
3624
- icon: 'vertical-align',
3625
- tooltip: 'Vertical align',
3626
- fetch: generateMenuItemsCallback(editor, verticalAlignValues, 'tablecellverticalalign', applyTableCellStyle(editor, 'vertical-align')),
3627
- onSetup: selectionTargets.onSetupCellOrRow
3628
- });
3629
- editor.ui.registry.addMenuButton('tablecellborderwidth', {
3630
- icon: 'border-width',
3631
- tooltip: 'Border width',
3632
- fetch: generateMenuItemsCallback(editor, getTableBorderWidths(editor), 'tablecellborderwidth', applyTableCellStyle(editor, 'border-width')),
3633
- onSetup: selectionTargets.onSetupCellOrRow
3634
- });
3635
- editor.ui.registry.addMenuButton('tablecellborderstyle', {
3636
- icon: 'border-style',
3637
- tooltip: 'Border style',
3638
- fetch: generateMenuItemsCallback(editor, getTableBorderStyles(editor), 'tablecellborderstyle', applyTableCellStyle(editor, 'border-style')),
3639
- onSetup: selectionTargets.onSetupCellOrRow
3640
- });
3641
- editor.ui.registry.addMenuButton('tablecellbackgroundcolor', {
3642
- icon: 'cell-background-color',
3643
- tooltip: 'Background color',
3644
- fetch: (callback) => callback(buildColorMenu(editor, getTableBackgroundColorMap(editor), 'background-color')),
3645
- onSetup: selectionTargets.onSetupCellOrRow
3646
- });
3647
- editor.ui.registry.addMenuButton('tablecellbordercolor', {
3648
- icon: 'cell-border-color',
3649
- tooltip: 'Border color',
3650
- fetch: (callback) => callback(buildColorMenu(editor, getTableBorderColorMap(editor), 'border-color')),
3651
- onSetup: selectionTargets.onSetupCellOrRow
3652
- });
3653
- }
3654
- addToggleButtonIfRegistered('tablecaption', {
3655
- tooltip: 'Table caption',
3656
- icon: 'table-caption',
3657
- command: 'mceTableToggleCaption',
3658
- onSetup: selectionTargets.onSetupTableWithCaption
3659
- });
3660
- addToggleButtonIfRegistered('tablerowheader', {
3661
- tooltip: 'Row header',
3662
- icon: 'table-top-header',
3663
- command: 'mceTableRowType',
3664
- onAction: changeRowHeader(editor),
3665
- onSetup: selectionTargets.onSetupTableRowHeaders
3666
- });
3667
- addToggleButtonIfRegistered('tablecolheader', {
3668
- tooltip: 'Column header',
3669
- icon: 'table-left-header',
3670
- command: 'mceTableColType',
3671
- onAction: changeColumnHeader(editor),
3672
- onSetup: selectionTargets.onSetupTableColumnHeaders
3673
- });
3674
- };
3675
- const addToolbars = (editor) => {
3676
- const isEditableTable = (table) => editor.dom.is(table, 'table') && editor.getBody().contains(table) && editor.dom.isEditable(table.parentNode);
3677
- const toolbar = getToolbar(editor);
3678
- if (toolbar.length > 0) {
3679
- editor.ui.registry.addContextToolbar('table', {
3680
- predicate: isEditableTable,
3681
- items: toolbar,
3682
- scope: 'node',
3683
- position: 'node'
3684
- });
3685
- }
3686
- };
3687
-
3688
- const onSetupEditable = (editor) => (api) => {
3689
- const nodeChanged = () => {
3690
- api.setEnabled(editor.selection.isEditable());
3691
- };
3692
- editor.on('NodeChange', nodeChanged);
3693
- nodeChanged();
3694
- return () => {
3695
- editor.off('NodeChange', nodeChanged);
3696
- };
3697
- };
3698
- const addMenuItems = (editor, selectionTargets) => {
3699
- const cmd = (command) => () => editor.execCommand(command);
3700
- // TODO: TINY-8172 Unwind this when an alternative solution is found
3701
- const addMenuIfRegistered = (name, spec) => {
3702
- if (editor.queryCommandSupported(spec.command)) {
3703
- editor.ui.registry.addMenuItem(name, {
3704
- ...spec,
3705
- onAction: isFunction(spec.onAction) ? spec.onAction : cmd(spec.command)
3706
- });
3707
- return true;
3708
- }
3709
- else {
3710
- return false;
3711
- }
3712
- };
3713
- // TODO: TINY-8172 Unwind this when an alternative solution is found
3714
- const addToggleMenuIfRegistered = (name, spec) => {
3715
- if (editor.queryCommandSupported(spec.command)) {
3716
- editor.ui.registry.addToggleMenuItem(name, {
3717
- ...spec,
3718
- onAction: isFunction(spec.onAction) ? spec.onAction : cmd(spec.command)
3719
- });
3720
- }
3721
- };
3722
- const insertTableAction = (data) => {
3723
- editor.execCommand('mceInsertTable', false, {
3724
- rows: data.numRows,
3725
- columns: data.numColumns
3726
- });
3727
- };
3728
- const hasRowMenuItems = [
3729
- addMenuIfRegistered('tableinsertrowbefore', {
3730
- text: 'Insert row before',
3731
- icon: 'table-insert-row-above',
3732
- command: 'mceTableInsertRowBefore',
3733
- onSetup: selectionTargets.onSetupCellOrRow
3734
- }),
3735
- addMenuIfRegistered('tableinsertrowafter', {
3736
- text: 'Insert row after',
3737
- icon: 'table-insert-row-after',
3738
- command: 'mceTableInsertRowAfter',
3739
- onSetup: selectionTargets.onSetupCellOrRow
3740
- }),
3741
- addMenuIfRegistered('tabledeleterow', {
3742
- text: 'Delete row',
3743
- icon: 'table-delete-row',
3744
- command: 'mceTableDeleteRow',
3745
- onSetup: selectionTargets.onSetupCellOrRow
3746
- }),
3747
- addMenuIfRegistered('tablerowprops', {
3748
- text: 'Row properties',
3749
- icon: 'table-row-properties',
3750
- command: 'mceTableRowProps',
3751
- onSetup: selectionTargets.onSetupCellOrRow
3752
- }),
3753
- addMenuIfRegistered('tablecutrow', {
3754
- text: 'Cut row',
3755
- icon: 'cut-row',
3756
- command: 'mceTableCutRow',
3757
- onSetup: selectionTargets.onSetupCellOrRow
3758
- }),
3759
- addMenuIfRegistered('tablecopyrow', {
3760
- text: 'Copy row',
3761
- icon: 'duplicate-row',
3762
- command: 'mceTableCopyRow',
3763
- onSetup: selectionTargets.onSetupCellOrRow
3764
- }),
3765
- addMenuIfRegistered('tablepasterowbefore', {
3766
- text: 'Paste row before',
3767
- icon: 'paste-row-before',
3768
- command: 'mceTablePasteRowBefore',
3769
- onSetup: selectionTargets.onSetupPasteable(getRows)
3770
- }),
3771
- addMenuIfRegistered('tablepasterowafter', {
3772
- text: 'Paste row after',
3773
- icon: 'paste-row-after',
3774
- command: 'mceTablePasteRowAfter',
3775
- onSetup: selectionTargets.onSetupPasteable(getRows)
3776
- }),
3777
- ];
3778
- const hasColumnMenuItems = [
3779
- addMenuIfRegistered('tableinsertcolumnbefore', {
3780
- text: 'Insert column before',
3781
- icon: 'table-insert-column-before',
3782
- command: 'mceTableInsertColBefore',
3783
- onSetup: selectionTargets.onSetupColumn("onFirst" /* LockedDisable.onFirst */)
3784
- }),
3785
- addMenuIfRegistered('tableinsertcolumnafter', {
3786
- text: 'Insert column after',
3787
- icon: 'table-insert-column-after',
3788
- command: 'mceTableInsertColAfter',
3789
- onSetup: selectionTargets.onSetupColumn("onLast" /* LockedDisable.onLast */)
3790
- }),
3791
- addMenuIfRegistered('tabledeletecolumn', {
3792
- text: 'Delete column',
3793
- icon: 'table-delete-column',
3794
- command: 'mceTableDeleteCol',
3795
- onSetup: selectionTargets.onSetupColumn("onAny" /* LockedDisable.onAny */)
3796
- }),
3797
- addMenuIfRegistered('tablecutcolumn', {
3798
- text: 'Cut column',
3799
- icon: 'cut-column',
3800
- command: 'mceTableCutCol',
3801
- onSetup: selectionTargets.onSetupColumn("onAny" /* LockedDisable.onAny */)
3802
- }),
3803
- addMenuIfRegistered('tablecopycolumn', {
3804
- text: 'Copy column',
3805
- icon: 'duplicate-column',
3806
- command: 'mceTableCopyCol',
3807
- onSetup: selectionTargets.onSetupColumn("onAny" /* LockedDisable.onAny */)
3808
- }),
3809
- addMenuIfRegistered('tablepastecolumnbefore', {
3810
- text: 'Paste column before',
3811
- icon: 'paste-column-before',
3812
- command: 'mceTablePasteColBefore',
3813
- onSetup: selectionTargets.onSetupPasteableColumn(getColumns, "onFirst" /* LockedDisable.onFirst */)
3814
- }),
3815
- addMenuIfRegistered('tablepastecolumnafter', {
3816
- text: 'Paste column after',
3817
- icon: 'paste-column-after',
3818
- command: 'mceTablePasteColAfter',
3819
- onSetup: selectionTargets.onSetupPasteableColumn(getColumns, "onLast" /* LockedDisable.onLast */)
3820
- }),
3821
- ];
3822
- const hasCellMenuItems = [
3823
- addMenuIfRegistered('tablecellprops', {
3824
- text: 'Cell properties',
3825
- icon: 'table-cell-properties',
3826
- command: 'mceTableCellProps',
3827
- onSetup: selectionTargets.onSetupCellOrRow
3828
- }),
3829
- addMenuIfRegistered('tablemergecells', {
3830
- text: 'Merge cells',
3831
- icon: 'table-merge-cells',
3832
- command: 'mceTableMergeCells',
3833
- onSetup: selectionTargets.onSetupMergeable
3834
- }),
3835
- addMenuIfRegistered('tablesplitcells', {
3836
- text: 'Split cell',
3837
- icon: 'table-split-cells',
3838
- command: 'mceTableSplitCells',
3839
- onSetup: selectionTargets.onSetupUnmergeable
3840
- }),
3841
- ];
3842
- if (!hasTableGrid(editor)) {
3843
- editor.ui.registry.addMenuItem('inserttable', {
3844
- text: 'Table',
3845
- icon: 'table',
3846
- onAction: cmd('mceInsertTableDialog'),
3847
- onSetup: onSetupEditable(editor)
3848
- });
3849
- }
3850
- else {
3851
- editor.ui.registry.addNestedMenuItem('inserttable', {
3852
- text: 'Table',
3853
- icon: 'table',
3854
- getSubmenuItems: () => [{ type: 'fancymenuitem', fancytype: 'inserttable', onAction: insertTableAction }],
3855
- onSetup: onSetupEditable(editor)
3856
- });
3857
- }
3858
- // TINY-3636: We want a way to use the dialog even when tablegrid true.
3859
- // If tablegrid false then inserttable and inserttabledialog are the same,
3860
- // but that's preferrable to breaking things at this point.
3861
- editor.ui.registry.addMenuItem('inserttabledialog', {
3862
- text: 'Insert table',
3863
- icon: 'table',
3864
- onAction: cmd('mceInsertTableDialog'),
3865
- onSetup: onSetupEditable(editor)
3866
- });
3867
- addMenuIfRegistered('tableprops', {
3868
- text: 'Table properties',
3869
- onSetup: selectionTargets.onSetupTable,
3870
- command: 'mceTableProps'
3871
- });
3872
- addMenuIfRegistered('deletetable', {
3873
- text: 'Delete table',
3874
- icon: 'table-delete-table',
3875
- onSetup: selectionTargets.onSetupTable,
3876
- command: 'mceTableDelete'
3877
- });
3878
- // if any of the row menu items returned true
3879
- if (contains(hasRowMenuItems, true)) {
3880
- editor.ui.registry.addNestedMenuItem('row', {
3881
- type: 'nestedmenuitem',
3882
- text: 'Row',
3883
- getSubmenuItems: constant('tableinsertrowbefore tableinsertrowafter tabledeleterow tablerowprops | tablecutrow tablecopyrow tablepasterowbefore tablepasterowafter')
3884
- });
3885
- }
3886
- if (contains(hasColumnMenuItems, true)) {
3887
- editor.ui.registry.addNestedMenuItem('column', {
3888
- type: 'nestedmenuitem',
3889
- text: 'Column',
3890
- getSubmenuItems: constant('tableinsertcolumnbefore tableinsertcolumnafter tabledeletecolumn | tablecutcolumn tablecopycolumn tablepastecolumnbefore tablepastecolumnafter')
3891
- });
3892
- }
3893
- if (contains(hasCellMenuItems, true)) {
3894
- editor.ui.registry.addNestedMenuItem('cell', {
3895
- type: 'nestedmenuitem',
3896
- text: 'Cell',
3897
- getSubmenuItems: constant('tablecellprops tablemergecells tablesplitcells')
3898
- });
3899
- }
3900
- editor.ui.registry.addContextMenu('table', {
3901
- update: () => {
3902
- // context menu fires before node change, so check the selection here first
3903
- selectionTargets.resetTargets();
3904
- // ignoring element since it's monitored elsewhere
3905
- return selectionTargets.targets().fold(constant(''), (targets) => {
3906
- // If clicking in a caption, then we shouldn't show the cell/row/column options
3907
- if (name(targets.element) === 'caption') {
3908
- return 'tableprops deletetable';
3909
- }
3910
- else {
3911
- return 'cell row column | advtablesort | tableprops deletetable';
3912
- }
3913
- });
3914
- }
3915
- });
3916
- const tableClassList = filterNoneItem(getTableClassList(editor));
3917
- if (tableClassList.length !== 0 && editor.queryCommandSupported('mceTableToggleClass')) {
3918
- editor.ui.registry.addNestedMenuItem('tableclass', {
3919
- icon: 'table-classes',
3920
- text: 'Table styles',
3921
- getSubmenuItems: () => buildMenuItems(editor, tableClassList, 'tableclass', (value) => editor.execCommand('mceTableToggleClass', false, value)),
3922
- onSetup: selectionTargets.onSetupTable
3923
- });
3924
- }
3925
- const tableCellClassList = filterNoneItem(getCellClassList(editor));
3926
- if (tableCellClassList.length !== 0 && editor.queryCommandSupported('mceTableCellToggleClass')) {
3927
- editor.ui.registry.addNestedMenuItem('tablecellclass', {
3928
- icon: 'table-cell-classes',
3929
- text: 'Cell styles',
3930
- getSubmenuItems: () => buildMenuItems(editor, tableCellClassList, 'tablecellclass', (value) => editor.execCommand('mceTableCellToggleClass', false, value)),
3931
- onSetup: selectionTargets.onSetupCellOrRow
3932
- });
3933
- }
3934
- // TODO: TINY-8172 Unwind this when an alternative solution is found
3935
- if (editor.queryCommandSupported('mceTableApplyCellStyle')) {
3936
- editor.ui.registry.addNestedMenuItem('tablecellvalign', {
3937
- icon: 'vertical-align',
3938
- text: 'Vertical align',
3939
- getSubmenuItems: () => buildMenuItems(editor, verticalAlignValues, 'tablecellverticalalign', applyTableCellStyle(editor, 'vertical-align')),
3940
- onSetup: selectionTargets.onSetupCellOrRow
3941
- });
3942
- editor.ui.registry.addNestedMenuItem('tablecellborderwidth', {
3943
- icon: 'border-width',
3944
- text: 'Border width',
3945
- getSubmenuItems: () => buildMenuItems(editor, getTableBorderWidths(editor), 'tablecellborderwidth', applyTableCellStyle(editor, 'border-width')),
3946
- onSetup: selectionTargets.onSetupCellOrRow
3947
- });
3948
- editor.ui.registry.addNestedMenuItem('tablecellborderstyle', {
3949
- icon: 'border-style',
3950
- text: 'Border style',
3951
- getSubmenuItems: () => buildMenuItems(editor, getTableBorderStyles(editor), 'tablecellborderstyle', applyTableCellStyle(editor, 'border-style')),
3952
- onSetup: selectionTargets.onSetupCellOrRow
3953
- });
3954
- editor.ui.registry.addNestedMenuItem('tablecellbackgroundcolor', {
3955
- icon: 'cell-background-color',
3956
- text: 'Background color',
3957
- getSubmenuItems: () => buildColorMenu(editor, getTableBackgroundColorMap(editor), 'background-color'),
3958
- onSetup: selectionTargets.onSetupCellOrRow
3959
- });
3960
- editor.ui.registry.addNestedMenuItem('tablecellbordercolor', {
3961
- icon: 'cell-border-color',
3962
- text: 'Border color',
3963
- getSubmenuItems: () => buildColorMenu(editor, getTableBorderColorMap(editor), 'border-color'),
3964
- onSetup: selectionTargets.onSetupCellOrRow
3965
- });
3966
- }
3967
- addToggleMenuIfRegistered('tablecaption', {
3968
- icon: 'table-caption',
3969
- text: 'Table caption',
3970
- command: 'mceTableToggleCaption',
3971
- onSetup: selectionTargets.onSetupTableWithCaption
3972
- });
3973
- addToggleMenuIfRegistered('tablerowheader', {
3974
- text: 'Row header',
3975
- icon: 'table-top-header',
3976
- command: 'mceTableRowType',
3977
- onAction: changeRowHeader(editor),
3978
- onSetup: selectionTargets.onSetupTableRowHeaders
3979
- });
3980
- addToggleMenuIfRegistered('tablecolheader', {
3981
- text: 'Column header',
3982
- icon: 'table-left-header',
3983
- command: 'mceTableColType',
3984
- onAction: changeColumnHeader(editor),
3985
- onSetup: selectionTargets.onSetupTableRowHeaders
3986
- });
3987
- };
3988
-
3989
- const Plugin = (editor) => {
3990
- const selectionTargets = getSelectionTargets(editor);
3991
- register(editor);
3992
- registerCommands(editor);
3993
- addMenuItems(editor, selectionTargets);
3994
- addButtons(editor, selectionTargets);
3995
- addToolbars(editor);
3996
- };
3997
- var Plugin$1 = () => {
3998
- global$3.add('table', Plugin);
3999
- };
4000
-
4001
- Plugin$1();
4002
- /** *****
4003
- * DO NOT EXPORT ANYTHING
4004
- *
4005
- * IF YOU DO ROLLUP WILL LEAVE A GLOBAL ON THE PAGE
4006
- *******/
4007
-
4008
- })();