@fiduswriter/frontend 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (359) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +66 -0
  3. package/dist/admin_console/index.d.ts +8 -0
  4. package/dist/admin_console/index.d.ts.map +1 -0
  5. package/dist/admin_console/index.js +54 -0
  6. package/dist/admin_console/index.js.map +1 -0
  7. package/dist/api/index.d.ts +193 -0
  8. package/dist/api/index.d.ts.map +1 -0
  9. package/dist/api/index.js +6 -0
  10. package/dist/api/index.js.map +1 -0
  11. package/dist/app/index.d.ts +74 -0
  12. package/dist/app/index.d.ts.map +1 -0
  13. package/dist/app/index.js +471 -0
  14. package/dist/app/index.js.map +1 -0
  15. package/dist/common/index.d.ts +3 -0
  16. package/dist/common/index.d.ts.map +1 -0
  17. package/dist/common/index.js +3 -0
  18. package/dist/common/index.js.map +1 -0
  19. package/dist/common/templates.d.ts +3 -0
  20. package/dist/common/templates.d.ts.map +1 -0
  21. package/dist/common/templates.js +42 -0
  22. package/dist/common/templates.js.map +1 -0
  23. package/dist/common/user_util.d.ts +6 -0
  24. package/dist/common/user_util.d.ts.map +1 -0
  25. package/dist/common/user_util.js +16 -0
  26. package/dist/common/user_util.js.map +1 -0
  27. package/dist/document_templates/actions.d.ts +11 -0
  28. package/dist/document_templates/actions.d.ts.map +1 -0
  29. package/dist/document_templates/actions.js +141 -0
  30. package/dist/document_templates/actions.js.map +1 -0
  31. package/dist/document_templates/editor.d.ts +28 -0
  32. package/dist/document_templates/editor.d.ts.map +1 -0
  33. package/dist/document_templates/editor.js +139 -0
  34. package/dist/document_templates/editor.js.map +1 -0
  35. package/dist/document_templates/index.d.ts +3 -0
  36. package/dist/document_templates/index.d.ts.map +1 -0
  37. package/dist/document_templates/index.js +3 -0
  38. package/dist/document_templates/index.js.map +1 -0
  39. package/dist/document_templates/menu.d.ts +7 -0
  40. package/dist/document_templates/menu.d.ts.map +1 -0
  41. package/dist/document_templates/menu.js +62 -0
  42. package/dist/document_templates/menu.js.map +1 -0
  43. package/dist/document_templates/overview.d.ts +52 -0
  44. package/dist/document_templates/overview.d.ts.map +1 -0
  45. package/dist/document_templates/overview.js +274 -0
  46. package/dist/document_templates/overview.js.map +1 -0
  47. package/dist/document_templates/templates.d.ts +3 -0
  48. package/dist/document_templates/templates.d.ts.map +1 -0
  49. package/dist/document_templates/templates.js +9 -0
  50. package/dist/document_templates/templates.js.map +1 -0
  51. package/dist/documents/importer/docx/import.d.ts +5 -0
  52. package/dist/documents/importer/docx/import.d.ts.map +1 -0
  53. package/dist/documents/importer/docx/import.js +15 -0
  54. package/dist/documents/importer/docx/import.js.map +1 -0
  55. package/dist/documents/importer/docx/index.d.ts +2 -0
  56. package/dist/documents/importer/docx/index.d.ts.map +1 -0
  57. package/dist/documents/importer/docx/index.js +2 -0
  58. package/dist/documents/importer/docx/index.js.map +1 -0
  59. package/dist/documents/importer/native/file.d.ts +7 -0
  60. package/dist/documents/importer/native/file.d.ts.map +1 -0
  61. package/dist/documents/importer/native/file.js +60 -0
  62. package/dist/documents/importer/native/file.js.map +1 -0
  63. package/dist/documents/importer/native/import.d.ts +41 -0
  64. package/dist/documents/importer/native/import.d.ts.map +1 -0
  65. package/dist/documents/importer/native/import.js +126 -0
  66. package/dist/documents/importer/native/import.js.map +1 -0
  67. package/dist/documents/importer/native/index.d.ts +3 -0
  68. package/dist/documents/importer/native/index.d.ts.map +1 -0
  69. package/dist/documents/importer/native/index.js +3 -0
  70. package/dist/documents/importer/native/index.js.map +1 -0
  71. package/dist/documents/importer/odt/import.d.ts +5 -0
  72. package/dist/documents/importer/odt/import.d.ts.map +1 -0
  73. package/dist/documents/importer/odt/import.js +16 -0
  74. package/dist/documents/importer/odt/import.js.map +1 -0
  75. package/dist/documents/importer/odt/index.d.ts +2 -0
  76. package/dist/documents/importer/odt/index.d.ts.map +1 -0
  77. package/dist/documents/importer/odt/index.js +2 -0
  78. package/dist/documents/importer/odt/index.js.map +1 -0
  79. package/dist/documents/importer/pandoc/import.d.ts +5 -0
  80. package/dist/documents/importer/pandoc/import.d.ts.map +1 -0
  81. package/dist/documents/importer/pandoc/import.js +37 -0
  82. package/dist/documents/importer/pandoc/import.js.map +1 -0
  83. package/dist/documents/importer/pandoc/index.d.ts +2 -0
  84. package/dist/documents/importer/pandoc/index.d.ts.map +1 -0
  85. package/dist/documents/importer/pandoc/index.js +2 -0
  86. package/dist/documents/importer/pandoc/index.js.map +1 -0
  87. package/dist/documents/importer/register.d.ts +4 -0
  88. package/dist/documents/importer/register.d.ts.map +1 -0
  89. package/dist/documents/importer/register.js +4 -0
  90. package/dist/documents/importer/register.js.map +1 -0
  91. package/dist/documents/overview/actions.d.ts +32 -0
  92. package/dist/documents/overview/actions.d.ts.map +1 -0
  93. package/dist/documents/overview/actions.js +725 -0
  94. package/dist/documents/overview/actions.js.map +1 -0
  95. package/dist/documents/overview/index.d.ts +98 -0
  96. package/dist/documents/overview/index.d.ts.map +1 -0
  97. package/dist/documents/overview/index.js +814 -0
  98. package/dist/documents/overview/index.js.map +1 -0
  99. package/dist/documents/overview/menu.d.ts +28 -0
  100. package/dist/documents/overview/menu.d.ts.map +1 -0
  101. package/dist/documents/overview/menu.js +222 -0
  102. package/dist/documents/overview/menu.js.map +1 -0
  103. package/dist/documents/overview/templates.d.ts +31 -0
  104. package/dist/documents/overview/templates.d.ts.map +1 -0
  105. package/dist/documents/overview/templates.js +39 -0
  106. package/dist/documents/overview/templates.js.map +1 -0
  107. package/dist/documents/revisions/index.d.ts +14 -0
  108. package/dist/documents/revisions/index.d.ts.map +1 -0
  109. package/dist/documents/revisions/index.js +143 -0
  110. package/dist/documents/revisions/index.js.map +1 -0
  111. package/dist/documents/revisions/templates.d.ts +4 -0
  112. package/dist/documents/revisions/templates.d.ts.map +1 -0
  113. package/dist/documents/revisions/templates.js +36 -0
  114. package/dist/documents/revisions/templates.js.map +1 -0
  115. package/dist/documents/tools.d.ts +16 -0
  116. package/dist/documents/tools.d.ts.map +1 -0
  117. package/dist/documents/tools.js +69 -0
  118. package/dist/documents/tools.js.map +1 -0
  119. package/dist/error_hook/index.d.ts +19 -0
  120. package/dist/error_hook/index.d.ts.map +1 -0
  121. package/dist/error_hook/index.js +75 -0
  122. package/dist/error_hook/index.js.map +1 -0
  123. package/dist/feedback/index.d.ts +12 -0
  124. package/dist/feedback/index.d.ts.map +1 -0
  125. package/dist/feedback/index.js +125 -0
  126. package/dist/feedback/index.js.map +1 -0
  127. package/dist/index.d.ts +42 -0
  128. package/dist/index.d.ts.map +1 -0
  129. package/dist/index.js +48 -0
  130. package/dist/index.js.map +1 -0
  131. package/dist/indexed_db/index.d.ts +24 -0
  132. package/dist/indexed_db/index.d.ts.map +1 -0
  133. package/dist/indexed_db/index.js +175 -0
  134. package/dist/indexed_db/index.js.map +1 -0
  135. package/dist/maintenance/index.d.ts +19 -0
  136. package/dist/maintenance/index.d.ts.map +1 -0
  137. package/dist/maintenance/index.js +223 -0
  138. package/dist/maintenance/index.js.map +1 -0
  139. package/dist/menu/index.d.ts +25 -0
  140. package/dist/menu/index.d.ts.map +1 -0
  141. package/dist/menu/index.js +229 -0
  142. package/dist/menu/index.js.map +1 -0
  143. package/dist/menu/templates.d.ts +6 -0
  144. package/dist/menu/templates.d.ts.map +1 -0
  145. package/dist/menu/templates.js +10 -0
  146. package/dist/menu/templates.js.map +1 -0
  147. package/dist/pages/404.d.ts +9 -0
  148. package/dist/pages/404.d.ts.map +1 -0
  149. package/dist/pages/404.js +12 -0
  150. package/dist/pages/404.js.map +1 -0
  151. package/dist/pages/flatpage.d.ts +12 -0
  152. package/dist/pages/flatpage.d.ts.map +1 -0
  153. package/dist/pages/flatpage.js +39 -0
  154. package/dist/pages/flatpage.js.map +1 -0
  155. package/dist/pages/offline.d.ts +10 -0
  156. package/dist/pages/offline.d.ts.map +1 -0
  157. package/dist/pages/offline.js +27 -0
  158. package/dist/pages/offline.js.map +1 -0
  159. package/dist/pages/setup.d.ts +10 -0
  160. package/dist/pages/setup.d.ts.map +1 -0
  161. package/dist/pages/setup.js +22 -0
  162. package/dist/pages/setup.js.map +1 -0
  163. package/dist/plugins/menu/index.d.ts +3 -0
  164. package/dist/plugins/menu/index.d.ts.map +1 -0
  165. package/dist/plugins/menu/index.js +2 -0
  166. package/dist/plugins/menu/index.js.map +1 -0
  167. package/dist/prelogin/index.d.ts +51 -0
  168. package/dist/prelogin/index.d.ts.map +1 -0
  169. package/dist/prelogin/index.js +131 -0
  170. package/dist/prelogin/index.js.map +1 -0
  171. package/dist/prelogin/templates.d.ts +20 -0
  172. package/dist/prelogin/templates.d.ts.map +1 -0
  173. package/dist/prelogin/templates.js +50 -0
  174. package/dist/prelogin/templates.js.map +1 -0
  175. package/dist/state_plugins/contributor_input/add_button.d.ts +22 -0
  176. package/dist/state_plugins/contributor_input/add_button.d.ts.map +1 -0
  177. package/dist/state_plugins/contributor_input/add_button.js +106 -0
  178. package/dist/state_plugins/contributor_input/add_button.js.map +1 -0
  179. package/dist/state_plugins/contributor_input/helpers.d.ts +3 -0
  180. package/dist/state_plugins/contributor_input/helpers.d.ts.map +1 -0
  181. package/dist/state_plugins/contributor_input/helpers.js +23 -0
  182. package/dist/state_plugins/contributor_input/helpers.js.map +1 -0
  183. package/dist/state_plugins/contributor_input/index.d.ts +4 -0
  184. package/dist/state_plugins/contributor_input/index.d.ts.map +1 -0
  185. package/dist/state_plugins/contributor_input/index.js +4 -0
  186. package/dist/state_plugins/contributor_input/index.js.map +1 -0
  187. package/dist/state_plugins/contributor_input/node_view.d.ts +20 -0
  188. package/dist/state_plugins/contributor_input/node_view.d.ts.map +1 -0
  189. package/dist/state_plugins/contributor_input/node_view.js +85 -0
  190. package/dist/state_plugins/contributor_input/node_view.js.map +1 -0
  191. package/dist/state_plugins/index.d.ts +3 -0
  192. package/dist/state_plugins/index.d.ts.map +1 -0
  193. package/dist/state_plugins/index.js +3 -0
  194. package/dist/state_plugins/index.js.map +1 -0
  195. package/dist/state_plugins/tag_input/helpers.d.ts +5 -0
  196. package/dist/state_plugins/tag_input/helpers.d.ts.map +1 -0
  197. package/dist/state_plugins/tag_input/helpers.js +55 -0
  198. package/dist/state_plugins/tag_input/helpers.js.map +1 -0
  199. package/dist/state_plugins/tag_input/index.d.ts +5 -0
  200. package/dist/state_plugins/tag_input/index.d.ts.map +1 -0
  201. package/dist/state_plugins/tag_input/index.js +5 -0
  202. package/dist/state_plugins/tag_input/index.js.map +1 -0
  203. package/dist/state_plugins/tag_input/node_view.d.ts +19 -0
  204. package/dist/state_plugins/tag_input/node_view.d.ts.map +1 -0
  205. package/dist/state_plugins/tag_input/node_view.js +85 -0
  206. package/dist/state_plugins/tag_input/node_view.js.map +1 -0
  207. package/dist/state_plugins/tag_input/tag_editor.d.ts +4 -0
  208. package/dist/state_plugins/tag_input/tag_editor.d.ts.map +1 -0
  209. package/dist/state_plugins/tag_input/tag_editor.js +160 -0
  210. package/dist/state_plugins/tag_input/tag_editor.js.map +1 -0
  211. package/dist/state_plugins/tag_input/tag_editor_plugins.d.ts +5 -0
  212. package/dist/state_plugins/tag_input/tag_editor_plugins.d.ts.map +1 -0
  213. package/dist/state_plugins/tag_input/tag_editor_plugins.js +64 -0
  214. package/dist/state_plugins/tag_input/tag_editor_plugins.js.map +1 -0
  215. package/dist/types.d.ts +53 -0
  216. package/dist/types.d.ts.map +1 -0
  217. package/dist/types.js +2 -0
  218. package/dist/types.js.map +1 -0
  219. package/dist/user/auth/email_confirm.d.ts +23 -0
  220. package/dist/user/auth/email_confirm.d.ts.map +1 -0
  221. package/dist/user/auth/email_confirm.js +123 -0
  222. package/dist/user/auth/email_confirm.js.map +1 -0
  223. package/dist/user/auth/email_confirm_templates.d.ts +12 -0
  224. package/dist/user/auth/email_confirm_templates.d.ts.map +1 -0
  225. package/dist/user/auth/email_confirm_templates.js +30 -0
  226. package/dist/user/auth/email_confirm_templates.js.map +1 -0
  227. package/dist/user/auth/login.d.ts +13 -0
  228. package/dist/user/auth/login.d.ts.map +1 -0
  229. package/dist/user/auth/login.js +186 -0
  230. package/dist/user/auth/login.js.map +1 -0
  231. package/dist/user/auth/password_reset_change.d.ts +11 -0
  232. package/dist/user/auth/password_reset_change.d.ts.map +1 -0
  233. package/dist/user/auth/password_reset_change.js +101 -0
  234. package/dist/user/auth/password_reset_change.js.map +1 -0
  235. package/dist/user/auth/password_reset_request.d.ts +10 -0
  236. package/dist/user/auth/password_reset_request.d.ts.map +1 -0
  237. package/dist/user/auth/password_reset_request.js +82 -0
  238. package/dist/user/auth/password_reset_request.js.map +1 -0
  239. package/dist/user/auth/signup.d.ts +9 -0
  240. package/dist/user/auth/signup.d.ts.map +1 -0
  241. package/dist/user/auth/signup.js +148 -0
  242. package/dist/user/auth/signup.js.map +1 -0
  243. package/dist/user/auth/two_factor.d.ts +10 -0
  244. package/dist/user/auth/two_factor.d.ts.map +1 -0
  245. package/dist/user/auth/two_factor.js +201 -0
  246. package/dist/user/auth/two_factor.js.map +1 -0
  247. package/dist/user/contacts/add_dialog.d.ts +7 -0
  248. package/dist/user/contacts/add_dialog.d.ts.map +1 -0
  249. package/dist/user/contacts/add_dialog.js +84 -0
  250. package/dist/user/contacts/add_dialog.js.map +1 -0
  251. package/dist/user/contacts/delete_dialog.d.ts +6 -0
  252. package/dist/user/contacts/delete_dialog.d.ts.map +1 -0
  253. package/dist/user/contacts/delete_dialog.js +38 -0
  254. package/dist/user/contacts/delete_dialog.js.map +1 -0
  255. package/dist/user/contacts/index.d.ts +35 -0
  256. package/dist/user/contacts/index.d.ts.map +1 -0
  257. package/dist/user/contacts/index.js +234 -0
  258. package/dist/user/contacts/index.js.map +1 -0
  259. package/dist/user/contacts/invite.d.ts +9 -0
  260. package/dist/user/contacts/invite.d.ts.map +1 -0
  261. package/dist/user/contacts/invite.js +21 -0
  262. package/dist/user/contacts/invite.js.map +1 -0
  263. package/dist/user/contacts/menu.d.ts +7 -0
  264. package/dist/user/contacts/menu.d.ts.map +1 -0
  265. package/dist/user/contacts/menu.js +62 -0
  266. package/dist/user/contacts/menu.js.map +1 -0
  267. package/dist/user/contacts/respond_invite.d.ts +9 -0
  268. package/dist/user/contacts/respond_invite.d.ts.map +1 -0
  269. package/dist/user/contacts/respond_invite.js +65 -0
  270. package/dist/user/contacts/respond_invite.js.map +1 -0
  271. package/dist/user/contacts/templates.d.ts +7 -0
  272. package/dist/user/contacts/templates.d.ts.map +1 -0
  273. package/dist/user/contacts/templates.js +24 -0
  274. package/dist/user/contacts/templates.js.map +1 -0
  275. package/dist/user/profile/delete_user.d.ts +8 -0
  276. package/dist/user/profile/delete_user.d.ts.map +1 -0
  277. package/dist/user/profile/delete_user.js +56 -0
  278. package/dist/user/profile/delete_user.js.map +1 -0
  279. package/dist/user/profile/dialogs.d.ts +10 -0
  280. package/dist/user/profile/dialogs.d.ts.map +1 -0
  281. package/dist/user/profile/dialogs.js +311 -0
  282. package/dist/user/profile/dialogs.js.map +1 -0
  283. package/dist/user/profile/index.d.ts +27 -0
  284. package/dist/user/profile/index.d.ts.map +1 -0
  285. package/dist/user/profile/index.js +254 -0
  286. package/dist/user/profile/index.js.map +1 -0
  287. package/dist/user/profile/templates.d.ts +22 -0
  288. package/dist/user/profile/templates.d.ts.map +1 -0
  289. package/dist/user/profile/templates.js +261 -0
  290. package/dist/user/profile/templates.js.map +1 -0
  291. package/dist/workers/adjust_doc_to_template.d.ts +11 -0
  292. package/dist/workers/adjust_doc_to_template.d.ts.map +1 -0
  293. package/dist/workers/adjust_doc_to_template.js +26 -0
  294. package/dist/workers/adjust_doc_to_template.js.map +1 -0
  295. package/package.json +225 -0
  296. package/src/admin_console/index.ts +84 -0
  297. package/src/api/index.ts +149 -0
  298. package/src/app/index.ts +605 -0
  299. package/src/common/index.ts +2 -0
  300. package/src/common/templates.ts +49 -0
  301. package/src/common/user_util.ts +16 -0
  302. package/src/document_templates/actions.ts +179 -0
  303. package/src/document_templates/editor.ts +177 -0
  304. package/src/document_templates/index.ts +2 -0
  305. package/src/document_templates/menu.ts +74 -0
  306. package/src/document_templates/overview.ts +335 -0
  307. package/src/document_templates/templates.ts +9 -0
  308. package/src/documents/importer/docx/import.ts +25 -0
  309. package/src/documents/importer/docx/index.ts +1 -0
  310. package/src/documents/importer/native/file.ts +112 -0
  311. package/src/documents/importer/native/import.ts +219 -0
  312. package/src/documents/importer/native/index.ts +2 -0
  313. package/src/documents/importer/odt/import.ts +26 -0
  314. package/src/documents/importer/odt/index.ts +1 -0
  315. package/src/documents/importer/pandoc/import.ts +57 -0
  316. package/src/documents/importer/pandoc/index.ts +1 -0
  317. package/src/documents/importer/register.ts +8 -0
  318. package/src/documents/overview/actions.ts +1031 -0
  319. package/src/documents/overview/index.ts +1006 -0
  320. package/src/documents/overview/menu.ts +311 -0
  321. package/src/documents/overview/templates.ts +64 -0
  322. package/src/documents/revisions/index.ts +183 -0
  323. package/src/documents/revisions/templates.ts +42 -0
  324. package/src/documents/tools.ts +107 -0
  325. package/src/error_hook/index.ts +129 -0
  326. package/src/feedback/index.ts +185 -0
  327. package/src/global.d.ts +22 -0
  328. package/src/index.ts +95 -0
  329. package/src/indexed_db/index.ts +217 -0
  330. package/src/maintenance/index.ts +258 -0
  331. package/src/menu/index.ts +267 -0
  332. package/src/menu/templates.ts +21 -0
  333. package/src/pages/404.ts +13 -0
  334. package/src/pages/flatpage.ts +43 -0
  335. package/src/pages/offline.ts +39 -0
  336. package/src/pages/setup.ts +34 -0
  337. package/src/plugins/menu/index.ts +3 -0
  338. package/src/prelogin/index.ts +175 -0
  339. package/src/prelogin/templates.ts +86 -0
  340. package/src/types.ts +63 -0
  341. package/src/user/auth/email_confirm.ts +153 -0
  342. package/src/user/auth/email_confirm_templates.ts +76 -0
  343. package/src/user/auth/login.ts +221 -0
  344. package/src/user/auth/password_reset_change.ts +120 -0
  345. package/src/user/auth/password_reset_request.ts +107 -0
  346. package/src/user/auth/signup.ts +182 -0
  347. package/src/user/auth/two_factor.ts +244 -0
  348. package/src/user/contacts/add_dialog.ts +104 -0
  349. package/src/user/contacts/delete_dialog.ts +40 -0
  350. package/src/user/contacts/index.ts +289 -0
  351. package/src/user/contacts/invite.ts +24 -0
  352. package/src/user/contacts/menu.ts +70 -0
  353. package/src/user/contacts/respond_invite.ts +76 -0
  354. package/src/user/contacts/templates.ts +29 -0
  355. package/src/user/profile/delete_user.ts +71 -0
  356. package/src/user/profile/dialogs.ts +363 -0
  357. package/src/user/profile/index.ts +359 -0
  358. package/src/user/profile/templates.ts +299 -0
  359. package/src/workers/adjust_doc_to_template.ts +41 -0
@@ -0,0 +1,267 @@
1
+ import {keyName} from "w3c-keyname"
2
+
3
+ import {dropdownSelect, whenReady} from "fwtoolkit"
4
+ import {headerNavTemplate} from "./templates.js"
5
+ import type {App, MenuPlugins, NavItem, SiteMenuLike} from "../types.js"
6
+
7
+ // Bindings for the top menu on overview pages
8
+
9
+ export class SiteMenu implements SiteMenuLike {
10
+ app: App
11
+ activeItem: string | undefined
12
+ navItems: NavItem[]
13
+ listeners: {onKeydown?: (event: KeyboardEvent) => void}
14
+ keyboardShortcuts: Map<string, NavItem>
15
+ plugins?: Record<string, {init(): void}>
16
+
17
+ constructor(app: App, activeItem?: string) {
18
+ this.app = app
19
+ this.activeItem = activeItem
20
+ this.navItems = [
21
+ {
22
+ text: gettext("Documents"),
23
+ url: "/",
24
+ title: gettext("edit documents"),
25
+ id: "documents",
26
+ order: 0,
27
+ keys: "Alt-d"
28
+ },
29
+ {
30
+ text: gettext("Bibliography"),
31
+ url: "/bibliography/",
32
+ title: gettext("manage bibliography library"),
33
+ id: "bibliography",
34
+ order: 1,
35
+ keys: "Alt-b"
36
+ },
37
+ {
38
+ text: gettext("Images"),
39
+ url: "/usermedia/",
40
+ title: gettext("manage image files"),
41
+ id: "images",
42
+ order: 2,
43
+ keys: "Alt-m"
44
+ }
45
+ ]
46
+ this.listeners = {}
47
+ this.keyboardShortcuts = new Map()
48
+ }
49
+
50
+ init(): void {
51
+ this.activatePlugins()
52
+ this.setupKeyboardShortcuts()
53
+ const currentActive = this.navItems.find(
54
+ item => item.id === this.activeItem
55
+ )
56
+ if (currentActive) {
57
+ currentActive.active = true
58
+ }
59
+
60
+ whenReady().then(() => {
61
+ this.sortMenu()
62
+ this.renderMenu()
63
+ this.bindPreferencePullDown()
64
+ this.bindKeyboardNavigation()
65
+ })
66
+ }
67
+
68
+ setupKeyboardShortcuts(): void {
69
+ this.navItems.forEach(navItem => {
70
+ if (navItem.keys) {
71
+ this.keyboardShortcuts.set(navItem.keys.toLowerCase(), navItem)
72
+ }
73
+ })
74
+ }
75
+
76
+ bindKeyboardNavigation(): void {
77
+ this.listeners.onKeydown = event => this.onKeydown(event)
78
+ document.body.addEventListener("keydown", this.listeners.onKeydown)
79
+ }
80
+
81
+ onKeydown(event: KeyboardEvent): void {
82
+ const name = keyName(event)
83
+
84
+ if (event.altKey) {
85
+ const shortcut = "alt-" + name.toLowerCase()
86
+ const navItem = this.keyboardShortcuts.get(shortcut)
87
+ if (navItem) {
88
+ event.preventDefault()
89
+ event.stopPropagation()
90
+ this.app.goTo(navItem.url)
91
+ return
92
+ }
93
+ }
94
+ const headerNav = document.getElementById("header-nav") as HTMLElement
95
+ const siteMenuItems: HTMLElement[] = Array.from(
96
+ headerNav.querySelectorAll(".fw-nav-item a")
97
+ )
98
+ const currentFocus = document.activeElement as HTMLElement
99
+ const overviewMenu = document.getElementById("fw-overview-menu")
100
+ const isInSiteMenu = headerNav.contains(currentFocus)
101
+ const isInOverviewDropdown = overviewMenu
102
+ ?.querySelector(".fw-pulldown.fw-left")
103
+ ?.contains(currentFocus)
104
+
105
+ if (!isInSiteMenu && !overviewMenu?.contains(currentFocus)) {
106
+ return
107
+ }
108
+
109
+ let currentIndex = -1
110
+ if (isInSiteMenu) {
111
+ currentIndex = parseInt(currentFocus.dataset.index ?? "-1")
112
+ }
113
+ switch (name) {
114
+ case "ArrowLeft": {
115
+ if (isInSiteMenu) {
116
+ event.preventDefault()
117
+ const prevIndex =
118
+ currentIndex > 0
119
+ ? currentIndex - 1
120
+ : siteMenuItems.length - 1
121
+ siteMenuItems[prevIndex].focus()
122
+ }
123
+ break
124
+ }
125
+ case "ArrowRight": {
126
+ if (isInSiteMenu) {
127
+ event.preventDefault()
128
+ const nextIndex =
129
+ currentIndex < siteMenuItems.length - 1
130
+ ? currentIndex + 1
131
+ : 0
132
+ siteMenuItems[nextIndex].focus()
133
+ }
134
+ break
135
+ }
136
+ case "ArrowDown": {
137
+ if (isInSiteMenu && overviewMenu) {
138
+ event.preventDefault()
139
+ // Focus first overview menu item
140
+ const firstOverviewItem = overviewMenu.querySelector(
141
+ "button, div.dropdown"
142
+ )
143
+
144
+ if (firstOverviewItem) {
145
+ ;(firstOverviewItem as HTMLElement).focus()
146
+ }
147
+ }
148
+ break
149
+ }
150
+ case "ArrowUp": {
151
+ if (
152
+ overviewMenu?.contains(currentFocus) &&
153
+ !isInOverviewDropdown
154
+ ) {
155
+ event.preventDefault()
156
+ // Focus the site menu item that's above the current overview menu item
157
+ const siteMenuItem = siteMenuItems[0]
158
+ if (siteMenuItem) {
159
+ siteMenuItem.focus()
160
+ }
161
+ }
162
+ break
163
+ }
164
+ case "Enter":
165
+ case " ": {
166
+ if (isInSiteMenu) {
167
+ event.preventDefault()
168
+ ;(currentFocus as HTMLElement).click()
169
+ }
170
+ break
171
+ }
172
+ }
173
+ }
174
+
175
+ sortMenu(): void {
176
+ this.navItems.sort((a, b) => a.order - b.order)
177
+ }
178
+
179
+ renderMenu(): void {
180
+ const headerNav = document.getElementById("header-nav") as HTMLElement
181
+ headerNav.innerHTML = headerNavTemplate({
182
+ navItems: this.navItems,
183
+ getAccessKeyHTML: (text, keys) => this.getAccessKeyHTML(text, keys)
184
+ })
185
+ }
186
+
187
+ bindPreferencePullDown(): void {
188
+ const pulldown = document.getElementById(
189
+ "user-preferences-pulldown"
190
+ ) as HTMLSelectElement
191
+ const button =
192
+ document.getElementById("preferences-btn") || false
193
+ dropdownSelect(pulldown, {
194
+ button,
195
+ onChange: value => {
196
+ switch (value) {
197
+ case "profile":
198
+ this.app.goTo("/user/profile/")
199
+ break
200
+ case "contacts":
201
+ this.app.goTo("/user/contacts/")
202
+ break
203
+ case "logout":
204
+ // Clear all E2EE data from sessionStorage (document keys,
205
+ // passwords, decrypted titles, and passphrase keys).
206
+ for (let i = sessionStorage.length - 1; i >= 0; i--) {
207
+ const key = sessionStorage.key(i)
208
+ if (key && key.startsWith("e2ee_")) {
209
+ sessionStorage.removeItem(key)
210
+ }
211
+ }
212
+ import("fwtoolkit/network").then(({post}) =>
213
+ post("/api/user/logout/").then(() => {
214
+ window.location.href =
215
+ this.app.routes[""].app === "document"
216
+ ? "/"
217
+ : "/documents/"
218
+ })
219
+ )
220
+ break
221
+ }
222
+ }
223
+ })
224
+ }
225
+
226
+ activatePlugins(): void {
227
+ // Add plugins, but only once.
228
+ if (!this.plugins) {
229
+ this.plugins = {}
230
+ }
231
+ const pluginInstances = this.plugins
232
+
233
+ const plugins: MenuPlugins = this.app.menuPlugins || []
234
+
235
+ plugins.forEach(([app, plugin]) => {
236
+ if (!this.app.settings.APPS.includes(app)) {
237
+ return
238
+ }
239
+ Object.values(plugin).forEach(pluginExport => {
240
+ if (typeof pluginExport === "function") {
241
+ pluginInstances[pluginExport.name] = new pluginExport(this)
242
+ pluginInstances[pluginExport.name].init()
243
+ }
244
+ })
245
+ })
246
+ }
247
+
248
+ destroy(): void {
249
+ document.body.removeEventListener(
250
+ "keydown",
251
+ this.listeners.onKeydown as EventListener
252
+ )
253
+ this.listeners = {}
254
+ }
255
+
256
+ getAccessKeyHTML(text: string, accessKey?: string): string {
257
+ if (!accessKey) {
258
+ return text
259
+ }
260
+ const key = accessKey.split("-")[1] // Get the key part after "Alt-"
261
+ const index = text.toLowerCase().indexOf(key.toLowerCase())
262
+ if (index === -1) {
263
+ return text
264
+ }
265
+ return `${text.substring(0, index)}<span class="fw-access-key">${text.charAt(index)}</span>${text.substring(index + 1)}`
266
+ }
267
+ }
@@ -0,0 +1,21 @@
1
+ import type {NavItem} from "../types.js"
2
+
3
+ export const headerNavTemplate = ({
4
+ navItems,
5
+ getAccessKeyHTML
6
+ }: {
7
+ navItems: NavItem[]
8
+ getAccessKeyHTML: (text: string, keys?: string) => string
9
+ }): string =>
10
+ `<div class="fw-container fw-nav-container">
11
+ ${navItems
12
+ .map(
13
+ (navItem, index) =>
14
+ `<p class="fw-nav-item ${navItem.active ? "active-menu-wrapper" : ""}" role="presentation">
15
+ <a class="fw-header-navigation-text" href="${navItem.url}" title="${navItem.title}" role="menuitem" data-index=${index}>
16
+ ${getAccessKeyHTML(navItem.text, navItem.keys)}
17
+ </a>
18
+ </p>`
19
+ )
20
+ .join("")}
21
+ </div>`
@@ -0,0 +1,13 @@
1
+ import {PreloginPage} from "../prelogin/index.js"
2
+ import type {PreloginApp} from "../prelogin/index.js"
3
+
4
+ export class Page404 extends PreloginPage {
5
+ constructor({app, language}: {app: PreloginApp; language: string}) {
6
+ super({app, language})
7
+ this.title = gettext("Page not found")
8
+ this.contents = `<div class="fw-login-left">
9
+ <h1 class="fw-login-title">${gettext("Error 404")}</h1>
10
+ <p>${gettext("The page you are looking for cannot be found.")}</p>
11
+ </div>`
12
+ }
13
+ }
@@ -0,0 +1,43 @@
1
+ import {ensureCSS, postJson, whenReady} from "fwtoolkit"
2
+ import {PreloginPage} from "../prelogin/index.js"
3
+ import type {PreloginApp} from "../prelogin/index.js"
4
+
5
+ export class FlatPage extends PreloginPage {
6
+ url: string
7
+
8
+ constructor({app, language}: {app: PreloginApp; language: string}, url: string) {
9
+ super({app, language})
10
+ this.url = url
11
+ }
12
+
13
+ init(): Promise<void> {
14
+ return Promise.all([
15
+ whenReady(),
16
+ this.getPageData(),
17
+ ensureCSS([staticUrl("css/flatpage.css")])
18
+ ]).then(() => {
19
+ this.activateFidusPlugins()
20
+ this.render()
21
+ this.bind()
22
+ })
23
+ }
24
+
25
+ getPageData(): Promise<void> {
26
+ return postJson("/api/base/flatpage/", {url: this.url})
27
+ .then(({json}) => {
28
+ const data = json as {title: string; content: string}
29
+ this.title = data.title
30
+ this.contents = `<div class="fw-flatpage">
31
+ <h1 class="fw-login-title">${data.title}</h1>
32
+ ${data.content}
33
+ </div>`
34
+ })
35
+ .catch(() => {
36
+ this.title = gettext("Page not found")
37
+ this.contents = `<div>
38
+ <h1 class="fw-login-title">${gettext("Error 404")}</h1>
39
+ <p>${gettext("The page you are looking for cannot be found.")}</p>
40
+ </div>`
41
+ })
42
+ }
43
+ }
@@ -0,0 +1,39 @@
1
+ import {PreloginPage} from "../prelogin/index.js"
2
+ import type {PreloginApp} from "../prelogin/index.js"
3
+
4
+ export class OfflinePage extends PreloginPage {
5
+ constructor({app, language}: {app: PreloginApp; language: string}) {
6
+ super({app, language})
7
+ this.title = gettext("Disconnected")
8
+ this.contents = `<div class="fw-login-left">
9
+ <h1 class="fw-login-title">${gettext("Disconnected")}</h1>
10
+ <p>${interpolate(
11
+ gettext(
12
+ "You are currently disconnected from the %(appName)s server."
13
+ ),
14
+ {appName: this.app.name},
15
+ true
16
+ )}</p>
17
+ </div>`
18
+
19
+ this.footerLinks = this.footerLinks.filter(link => link.external) // We only show external links as internal links will not work
20
+
21
+ this.headerLinks = [
22
+ {
23
+ type: "button",
24
+ text: gettext("Reload page"),
25
+ link: window.location.pathname
26
+ }
27
+ ]
28
+ }
29
+
30
+ init(): Promise<void> {
31
+ return super
32
+ .init()
33
+ .then(() =>
34
+ document
35
+ .querySelectorAll("#lang-selection,.feedback-tab")
36
+ .forEach(el => ((el as HTMLElement).style.visibility = "hidden"))
37
+ )
38
+ }
39
+ }
@@ -0,0 +1,34 @@
1
+ import {PreloginPage} from "../prelogin/index.js"
2
+ import type {PreloginApp} from "../prelogin/index.js"
3
+
4
+ export class SetupPage extends PreloginPage {
5
+ constructor({app, language}: {app: PreloginApp; language: string}) {
6
+ super({app, language})
7
+ this.title = gettext("Update")
8
+ this.contents = `<div class="fw-login-left">
9
+ <h1 class="fw-login-title">${gettext("Update")}</h1>
10
+ <p>${interpolate(
11
+ gettext(
12
+ "The %(appName)s server is currently being updated. Please wait."
13
+ ),
14
+ {appName: this.app.name},
15
+ true
16
+ )}</p>
17
+ </div>`
18
+
19
+ this.footerLinks = this.footerLinks.filter(link => link.external) // We only show external links as internal links will not work
20
+
21
+ this.headerLinks = []
22
+ }
23
+
24
+ init(): Promise<void> {
25
+ setTimeout(() => this.app.goTo(window.location.pathname), 5000)
26
+ return super
27
+ .init()
28
+ .then(() =>
29
+ document
30
+ .querySelectorAll("#lang-selection,.feedback-tab")
31
+ .forEach(el => ((el as HTMLElement).style.visibility = "hidden"))
32
+ )
33
+ }
34
+ }
@@ -0,0 +1,3 @@
1
+ import type {MenuPlugins} from "../../types.js"
2
+
3
+ export const plugins: MenuPlugins = []
@@ -0,0 +1,175 @@
1
+ import {ensureCSS, setDocTitle, setLanguage, whenReady} from "fwtoolkit"
2
+ import {FeedbackTab} from "../feedback/index.js"
3
+ import type {RouteMap, Settings} from "../types.js"
4
+
5
+ import {basePreloginTemplate} from "./templates.js"
6
+
7
+ interface FooterLink {
8
+ text: string
9
+ link: string
10
+ external?: boolean
11
+ }
12
+
13
+ interface HeaderLink {
14
+ type?: string
15
+ text: string
16
+ link: string
17
+ }
18
+
19
+ export interface PreloginApp {
20
+ routes: RouteMap
21
+ settings: Settings
22
+ goTo: (url: string) => void
23
+ name: string
24
+ config: Record<string, unknown>
25
+ }
26
+
27
+ interface PluginExport {
28
+ new (options: {page: PreloginPage}): {init(): void}
29
+ }
30
+
31
+ interface PreloginPageOptions {
32
+ app: PreloginApp
33
+ language: string
34
+ plugins?: Array<[string, Record<string, PluginExport>]>
35
+ }
36
+
37
+ export class PreloginPage {
38
+ app: PreloginApp
39
+ language: string
40
+ pluginLoaders: Array<[string, Record<string, PluginExport>]>
41
+ plugins: Record<string, {init(): void}> | null
42
+ title: string
43
+ contents: string
44
+ footerLinks: FooterLink[]
45
+ headerLinks: HeaderLink[]
46
+ dom!: HTMLElement
47
+
48
+ constructor({app, language, plugins = []}: PreloginPageOptions) {
49
+ this.app = app
50
+ this.language = language
51
+ this.pluginLoaders = []
52
+ this.plugins = null
53
+ this.title = ""
54
+ this.contents = ""
55
+ this.footerLinks = (this.app.settings?.FOOTER_LINKS as FooterLink[] | undefined)?.length
56
+ ? (this.app.settings.FOOTER_LINKS as FooterLink[])
57
+ : [
58
+ {
59
+ text: gettext("Terms and Conditions"),
60
+ link: "/pages/terms/"
61
+ },
62
+ {
63
+ text: gettext("Privacy policy"),
64
+ link: "/pages/privacy/"
65
+ },
66
+ {
67
+ text: gettext("Equations and Math with MathLive"),
68
+ link: "https://github.com/arnog/mathlive#readme",
69
+ external: true
70
+ },
71
+ {
72
+ text: gettext("Citations with Citation Style Language"),
73
+ link: "https://citationstyles.org/",
74
+ external: true
75
+ },
76
+ {
77
+ text: gettext("Editing with ProseMirror"),
78
+ link: "https://prosemirror.net/",
79
+ external: true
80
+ }
81
+ ]
82
+ this.headerLinks = [
83
+ {
84
+ type: "button",
85
+ text: gettext("Log in"),
86
+ link:
87
+ this.app.routes[""].app === "document" ? "/" : "/documents/"
88
+ }
89
+ ]
90
+
91
+ // Stash page-specific plugins for late activation
92
+ this._pluginModules = plugins
93
+ }
94
+
95
+ private _pluginModules: Array<[string, Record<string, PluginExport>]>
96
+
97
+ activateFidusPlugins(): void {
98
+ if (this.plugins) {
99
+ // Plugins have been activated already
100
+ return
101
+ }
102
+ // Add plugins.
103
+ this.plugins = {}
104
+
105
+ // Plugins for the specific page
106
+ this.pluginLoaders.forEach(([app, plugin]) => {
107
+ if (!this.app.settings.APPS.includes(app)) {
108
+ return
109
+ }
110
+
111
+ Object.values(plugin).forEach(pluginExport => {
112
+ if (typeof pluginExport === "function") {
113
+ this.plugins![pluginExport.name] = new pluginExport({
114
+ page: this
115
+ })
116
+ this.plugins![pluginExport.name].init()
117
+ }
118
+ })
119
+ })
120
+
121
+ // General plugins for all prelogin pages
122
+ this._pluginModules.forEach(([app, plugin]) => {
123
+ if (!this.app.settings.APPS.includes(app)) {
124
+ return
125
+ }
126
+
127
+ Object.values(plugin).forEach(pluginExport => {
128
+ if (typeof pluginExport === "function") {
129
+ this.plugins![pluginExport.name] = new pluginExport({
130
+ page: this
131
+ })
132
+ this.plugins![pluginExport.name].init()
133
+ }
134
+ })
135
+ })
136
+ }
137
+
138
+ init(): Promise<void> {
139
+ return whenReady().then(() => {
140
+ this.activateFidusPlugins()
141
+ this.render()
142
+ this.bind()
143
+ })
144
+ }
145
+
146
+ bind(): void {
147
+ this.dom
148
+ .querySelector(".fw-login-logo")!
149
+ .addEventListener("click", () => this.app.goTo("/"))
150
+ this.dom
151
+ .querySelector("#lang-selection")!
152
+ .addEventListener("change", event => {
153
+ this.language = (event.target as HTMLSelectElement).value
154
+ return setLanguage(this.app.config, this.language)
155
+ })
156
+ }
157
+
158
+ render(): void {
159
+ this.dom = document.createElement("body")
160
+ this.dom.classList.add("prelogin")
161
+ this.dom.classList.add("fw-scrollable")
162
+ this.dom.innerHTML = basePreloginTemplate({
163
+ language: this.language,
164
+ headerLinks: this.headerLinks,
165
+ footerLinks: this.footerLinks,
166
+ contents: this.contents,
167
+ settings: this.app.settings
168
+ })
169
+ document.body = this.dom
170
+ ensureCSS([staticUrl("css/prelogin.css")])
171
+ setDocTitle(this.title, this.app)
172
+ const feedbackTab = new FeedbackTab()
173
+ feedbackTab.init()
174
+ }
175
+ }
@@ -0,0 +1,86 @@
1
+ import {langName} from "fwtoolkit"
2
+
3
+ interface HeaderLink {
4
+ type?: string
5
+ text: string
6
+ link: string
7
+ }
8
+
9
+ interface FooterLink {
10
+ text: string
11
+ link: string
12
+ external?: boolean
13
+ }
14
+
15
+ interface BasePreloginTemplateOptions {
16
+ contents: string
17
+ language: string
18
+ headerLinks?: HeaderLink[]
19
+ footerLinks?: FooterLink[]
20
+ settings?: Record<string, unknown>
21
+ }
22
+
23
+ export const basePreloginTemplate = ({
24
+ contents,
25
+ language,
26
+ headerLinks = [],
27
+ footerLinks = [],
28
+ settings = {}
29
+ }: BasePreloginTemplateOptions): string => `
30
+ <div id="fw-wait">
31
+ <i class="fa fa-spinner fa-pulse"></i>
32
+ </div>
33
+ <header class="fw-header prelogin" role="banner">
34
+ <div class="fw-container">
35
+ <h1 class="fw-login-logo"><span class="fw-logo-text"></span><img src="${staticUrl("svg/icon.svg")}" alt="Logo"/></h1>
36
+ <nav id="header-nav" role="navigation" aria-label="${gettext("Site navigation")}">${headerLinks
37
+ .map(hLink => {
38
+ let returnValue
39
+ switch (hLink.type) {
40
+ case "label":
41
+ returnValue = `<label>${hLink.text}</label>`
42
+ break
43
+ case "button":
44
+ returnValue = `<a class="fw-button fw-orange fw-uppercase" href="${hLink.link}" title="${hLink.text}">${hLink.text}</a>`
45
+ break
46
+ default:
47
+ returnValue = ""
48
+ }
49
+ return returnValue
50
+ })
51
+ .join("")}</nav>
52
+ ${
53
+ settings?.BRANDING_LOGO
54
+ ? `<div class="fw-login-branding-logo"><img src="${staticUrl(settings.BRANDING_LOGO as string)}" alt="Brand logo" /></div>`
55
+ : ""
56
+ }
57
+ </div>
58
+ ${
59
+ settings?.IS_FREE
60
+ ? `<div class="star"><img src="${staticUrl("img/free_star.avif")}" alt="Free"></div>`
61
+ : ""
62
+ }
63
+ </header>
64
+ <div class="fw-contents prelogin">
65
+ ${contents}
66
+ </div>
67
+ <footer id="footer-menu" class="prelogin">
68
+ <div class="fw-container">
69
+ <ul class="fw-footer-links">
70
+ ${footerLinks
71
+ .map(
72
+ fLink =>
73
+ `<li><a href="${fLink.link}" target="_blank"${fLink.external ? ' rel="noreferrer"' : ""}>${fLink.text}</a></li>`
74
+ )
75
+ .join("")}
76
+ </ul>
77
+ <select id="lang-selection" aria-label="${gettext("Select language")}">
78
+ ${((settings?.LANGUAGES as Array<[string, string]>) || [])
79
+ .map(
80
+ ([code, _name]) =>
81
+ `<option value="${code}" ${language === code ? "selected" : ""}>${langName(code)}</option>`
82
+ )
83
+ .join("")}
84
+ </select>
85
+ </div>
86
+ </footer>`