decidim-decidim_awesome 0.10.3 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of decidim-decidim_awesome might be problematic. Click here for more details.

Files changed (232) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -5
  3. data/README.md +65 -67
  4. data/app/cells/concerns/decidim/decidim_awesome/global_menu_cell_override.rb +20 -0
  5. data/app/cells/concerns/decidim/decidim_awesome/proposal_l_cell_override.rb +44 -0
  6. data/app/cells/decidim/decidim_awesome/content_blocks/map/show.erb +5 -12
  7. data/app/cells/decidim/decidim_awesome/voting/proposal_metadata_cell.rb +54 -0
  8. data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/modal.erb +18 -0
  9. data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/show.erb +37 -32
  10. data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_cell.rb +9 -4
  11. data/app/commands/concerns/decidim/decidim_awesome/admin/needs_constraint_helpers.rb +1 -1
  12. data/app/commands/concerns/decidim/decidim_awesome/proposals/create_proposal_override.rb +2 -2
  13. data/app/commands/concerns/decidim/decidim_awesome/proposals/update_proposal_override.rb +2 -2
  14. data/app/commands/decidim/decidim_awesome/admin/create_constraint.rb +1 -1
  15. data/app/commands/decidim/decidim_awesome/admin/destroy_custom_redirect.rb +1 -1
  16. data/app/commands/decidim/decidim_awesome/admin/destroy_menu_hack.rb +1 -1
  17. data/app/commands/decidim/decidim_awesome/admin/rename_scope_label.rb +1 -1
  18. data/app/commands/decidim/decidim_awesome/admin/update_constraint.rb +1 -1
  19. data/app/commands/decidim/decidim_awesome/admin/update_custom_redirect.rb +2 -2
  20. data/app/commands/decidim/decidim_awesome/command.rb +1 -7
  21. data/app/controllers/concerns/decidim/decidim_awesome/admin/maintenance_context.rb +1 -1
  22. data/app/controllers/concerns/decidim/decidim_awesome/admin_accountability/admin/filterable_helper.rb +3 -4
  23. data/app/controllers/concerns/decidim/decidim_awesome/content_security_policy.rb +34 -0
  24. data/app/controllers/concerns/decidim/decidim_awesome/not_found_redirect.rb +1 -1
  25. data/app/controllers/concerns/decidim/decidim_awesome/proposals/orderable_override.rb +22 -9
  26. data/app/controllers/concerns/decidim/decidim_awesome/proposals/proposal_votes_controller_override.rb +3 -3
  27. data/app/controllers/decidim/decidim_awesome/admin/admin_accountability_controller.rb +7 -7
  28. data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +7 -7
  29. data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +8 -10
  30. data/app/controllers/decidim/decidim_awesome/admin/constraints_controller.rb +20 -19
  31. data/app/controllers/decidim/decidim_awesome/admin/custom_redirects_controller.rb +6 -8
  32. data/app/controllers/decidim/decidim_awesome/admin/maintenance_controller.rb +2 -2
  33. data/app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb +6 -8
  34. data/app/controllers/decidim/decidim_awesome/admin/proposal_custom_fields_controller.rb +2 -2
  35. data/app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb +2 -2
  36. data/app/controllers/decidim/decidim_awesome/admin/scoped_styles_controller.rb +2 -2
  37. data/app/controllers/decidim/decidim_awesome/blank_component_controller.rb +8 -3
  38. data/app/controllers/decidim/decidim_awesome/editor_images_controller.rb +3 -3
  39. data/app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb +11 -5
  40. data/app/forms/concerns/decidim/decidim_awesome/proposals/proposal_wizard_create_step_form_override.rb +1 -1
  41. data/app/forms/decidim/decidim_awesome/admin/config_form.rb +13 -25
  42. data/app/forms/decidim/decidim_awesome/admin/custom_redirect_form.rb +2 -2
  43. data/app/forms/decidim/decidim_awesome/admin/intergram_form.rb +4 -0
  44. data/app/forms/decidim/decidim_awesome/admin/menu_form.rb +4 -4
  45. data/app/helpers/concerns/decidim/decidim_awesome/amendments_helper_override.rb +8 -1
  46. data/app/helpers/concerns/decidim/decidim_awesome/breadcrumb_helper_override.rb +23 -0
  47. data/app/helpers/concerns/decidim/decidim_awesome/proposals/application_helper_override.rb +23 -39
  48. data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +2 -2
  49. data/app/helpers/decidim/decidim_awesome/map_helper.rb +8 -27
  50. data/app/jobs/decidim/decidim_awesome/migrate_legacy_images_job.rb +5 -4
  51. data/app/middleware/decidim/decidim_awesome/current_config.rb +3 -5
  52. data/app/models/concerns/decidim/decidim_awesome/has_proposal_extra_fields.rb +1 -1
  53. data/app/models/decidim/decidim_awesome/awesome_config.rb +1 -1
  54. data/app/models/decidim/decidim_awesome/paper_trail_version.rb +4 -8
  55. data/app/models/decidim/decidim_awesome/proposal_extra_field.rb +1 -1
  56. data/app/models/decidim/decidim_awesome/vote_weight.rb +2 -2
  57. data/app/overrides/decidim/proposals/proposals/{show → _proposal_aside}/limit_amendments_modal.html.erb.deface +1 -1
  58. data/app/overrides/decidim/proposals/proposals/_vote_button/replace_vote_button.html.erb.deface +1 -1
  59. data/app/overrides/layouts/decidim/_decidim_javascript/add_awesome_tags.html.erb.deface +6 -0
  60. data/app/overrides/layouts/decidim/_head/add_awesome_tags.html.erb.deface +4 -11
  61. data/app/overrides/layouts/decidim/admin/_header/{replace_scripts.html.erb.deface → add_awesome_tags.html.erb.deface} +4 -4
  62. data/app/packs/entrypoints/decidim_admin_decidim_awesome.js +1 -2
  63. data/app/packs/entrypoints/decidim_admin_decidim_awesome_global.js +4 -0
  64. data/app/packs/entrypoints/decidim_admin_decidim_awesome_global.scss +1 -0
  65. data/app/packs/entrypoints/decidim_decidim_awesome.js +2 -2
  66. data/app/packs/entrypoints/decidim_editor.js +14 -0
  67. data/app/packs/src/decidim/decidim_awesome/admin/auto_edit.js +95 -70
  68. data/app/packs/src/decidim/decidim_awesome/admin/check_redirections.js +46 -41
  69. data/app/packs/src/decidim/decidim_awesome/admin/codemirror.js +3 -3
  70. data/app/packs/src/decidim/decidim_awesome/admin/constraint_form_events.js +115 -0
  71. data/app/packs/src/decidim/decidim_awesome/admin/custom_fields_builder.js +4 -1
  72. data/app/packs/src/decidim/decidim_awesome/admin/form_exit_warn.js +22 -11
  73. data/app/packs/src/decidim/decidim_awesome/admin/proposal_sortings.js +26 -8
  74. data/app/packs/src/decidim/decidim_awesome/admin/user_picker.js +34 -21
  75. data/app/packs/src/decidim/decidim_awesome/amendments/show_modal_on_limits.js +20 -22
  76. data/app/packs/src/decidim/decidim_awesome/awesome_admin.js +5 -16
  77. data/app/packs/src/decidim/decidim_awesome/awesome_admin_global.js +1 -0
  78. data/app/packs/src/decidim/decidim_awesome/awesome_application.js +0 -15
  79. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/fetcher.js +33 -11
  80. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/meetings_fetcher.js +9 -12
  81. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/proposals_fetcher.js +28 -0
  82. data/app/packs/src/decidim/decidim_awesome/awesome_map/awesome_map.js +3 -4
  83. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/controller.js +12 -12
  84. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/meetings_controller.js +11 -7
  85. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/proposals_controller.js +6 -13
  86. data/app/packs/src/decidim/decidim_awesome/awesome_map/controls_ui.js +51 -20
  87. data/app/packs/src/decidim/decidim_awesome/awesome_map/load_map.js +27 -18
  88. data/app/packs/src/decidim/decidim_awesome/editor/index.js +94 -0
  89. data/app/packs/src/decidim/decidim_awesome/forms/autosave.js +28 -23
  90. data/app/packs/src/decidim/decidim_awesome/forms/custom_fields_renderer.js +9 -14
  91. data/app/packs/src/decidim/decidim_awesome/forms/rich_text_plugin.js +27 -32
  92. data/app/packs/src/decidim/decidim_awesome/proposals/images.js +16 -10
  93. data/app/packs/src/decidim/decidim_awesome/voting/voting_cards.js +47 -38
  94. data/app/packs/stylesheets/decidim/decidim_awesome/admin/auto_edits.scss +11 -12
  95. data/app/packs/stylesheets/decidim/decidim_awesome/admin/check_redirections.scss +15 -0
  96. data/app/packs/stylesheets/decidim/decidim_awesome/admin/codemirror.scss +19 -12
  97. data/app/packs/stylesheets/decidim/decidim_awesome/admin/constraints.scss +8 -32
  98. data/app/packs/stylesheets/decidim/decidim_awesome/admin/custom_fields.scss +28 -78
  99. data/app/packs/stylesheets/decidim/decidim_awesome/admin/custom_styles.scss +48 -0
  100. data/app/packs/stylesheets/decidim/decidim_awesome/admin/intergram_fixes.scss +11 -0
  101. data/app/packs/stylesheets/decidim/decidim_awesome/admin/user_picker.scss +15 -24
  102. data/app/packs/stylesheets/decidim/decidim_awesome/amendments/modal.scss +5 -0
  103. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin.scss +9 -47
  104. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin_global.scss +3 -12
  105. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_application.scss +3 -19
  106. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_iframe/iframe.scss +1 -1
  107. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +27 -21
  108. data/app/packs/stylesheets/decidim/decidim_awesome/forms/autosave.scss +6 -6
  109. data/app/packs/stylesheets/decidim/decidim_awesome/forms/custom_fields.scss +32 -101
  110. data/app/packs/stylesheets/decidim/decidim_awesome/shared/spinner.scss +5 -26
  111. data/app/packs/stylesheets/decidim/decidim_awesome/voting/voting_cards.scss +34 -52
  112. data/app/permissions/decidim/decidim_awesome/permissions.rb +3 -4
  113. data/app/presenters/concerns/decidim/decidim_awesome/breadcrumb_root_menu_item_presenter_override.rb +23 -0
  114. data/app/presenters/concerns/decidim/decidim_awesome/menu_item_presenter_override.rb +10 -2
  115. data/app/presenters/concerns/decidim/decidim_awesome/menu_presenter_override.rb +8 -0
  116. data/app/presenters/decidim/decidim_awesome/participatory_space_role_presenter.rb +1 -1
  117. data/app/presenters/decidim/decidim_awesome/private_data_presenter.rb +11 -11
  118. data/app/presenters/decidim/decidim_awesome/user_entity_presenter.rb +1 -1
  119. data/app/queries/decidim/decidim_awesome/private_data_finder.rb +1 -1
  120. data/app/serializers/decidim/decidim_awesome/proposals/private_proposal_serializer.rb +0 -8
  121. data/app/views/decidim/decidim_awesome/admin/admin_accountability/index.html.erb +23 -17
  122. data/app/views/decidim/decidim_awesome/admin/checks/index.html.erb +1 -3
  123. data/app/views/decidim/decidim_awesome/admin/config/_autoedit_box_label.html.erb +3 -3
  124. data/app/views/decidim/decidim_awesome/admin/config/_constraints.html.erb +20 -21
  125. data/app/views/decidim/decidim_awesome/admin/config/_form_admins.html.erb +6 -5
  126. data/app/views/decidim/decidim_awesome/admin/config/_form_editors.html.erb +2 -2
  127. data/app/views/decidim/decidim_awesome/admin/config/_form_livechat.html.erb +39 -23
  128. data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_custom_fields.html.erb +4 -6
  129. data/app/views/decidim/decidim_awesome/admin/config/_form_proposals.html.erb +64 -76
  130. data/app/views/decidim/decidim_awesome/admin/config/_form_styles.html.erb +15 -11
  131. data/app/views/decidim/decidim_awesome/admin/config/_form_surveys.html.erb +8 -6
  132. data/app/views/decidim/decidim_awesome/admin/config/show.html.erb +22 -12
  133. data/app/views/decidim/decidim_awesome/admin/constraints/_form.html.erb +1 -49
  134. data/app/views/decidim/decidim_awesome/admin/constraints/new.html.erb +14 -9
  135. data/app/views/decidim/decidim_awesome/admin/constraints/show.html.erb +14 -9
  136. data/app/views/decidim/decidim_awesome/admin/custom_redirects/_form.html.erb +20 -5
  137. data/app/views/decidim/decidim_awesome/admin/custom_redirects/edit.html.erb +5 -5
  138. data/app/views/decidim/decidim_awesome/admin/custom_redirects/index.html.erb +15 -15
  139. data/app/views/decidim/decidim_awesome/admin/custom_redirects/new.html.erb +5 -5
  140. data/app/views/decidim/decidim_awesome/admin/maintenance/_private_data.html.erb +4 -4
  141. data/app/views/decidim/decidim_awesome/admin/menu_hacks/_form.html.erb +6 -6
  142. data/app/views/decidim/decidim_awesome/admin/menu_hacks/edit.html.erb +21 -12
  143. data/app/views/decidim/decidim_awesome/admin/menu_hacks/index.html.erb +16 -18
  144. data/app/views/decidim/decidim_awesome/admin/menu_hacks/new.html.erb +21 -12
  145. data/app/views/decidim/decidim_awesome/admin/shared/_filters_with_date.html.erb +14 -18
  146. data/app/views/decidim/decidim_awesome/amendments/_modal.html.erb +18 -11
  147. data/app/views/decidim/decidim_awesome/custom_fields/_form_render.html.erb +3 -5
  148. data/app/views/decidim/decidim_awesome/iframe_component/iframe/show.html.erb +7 -12
  149. data/app/views/decidim/decidim_awesome/map_component/map/_map_template.html.erb +53 -37
  150. data/app/views/decidim/decidim_awesome/map_component/map/show.html.erb +14 -5
  151. data/app/views/decidim/decidim_awesome/voting/voting_cards/_show_vote_button.html.erb +0 -3
  152. data/app/views/layouts/decidim/decidim_awesome/_awesome_config.html.erb +9 -7
  153. data/app/views/layouts/decidim/decidim_awesome/_intergram_widget.html.erb +9 -6
  154. data/app/views/layouts/decidim/decidim_awesome/admin/_base.html.erb +3 -12
  155. data/config/assets.rb +3 -33
  156. data/config/i18n-tasks.yml +1 -0
  157. data/config/locales/ca.yml +17 -94
  158. data/config/locales/cs.yml +15 -93
  159. data/config/locales/de.yml +15 -91
  160. data/config/locales/en.yml +24 -28
  161. data/config/locales/es.yml +18 -96
  162. data/config/locales/eu.yml +8 -18
  163. data/config/locales/fr.yml +15 -94
  164. data/config/locales/hu.yml +4 -18
  165. data/config/locales/it.yml +9 -26
  166. data/config/locales/ja.yml +16 -93
  167. data/config/locales/lt.yml +2 -4
  168. data/config/locales/nl.yml +8 -18
  169. data/config/locales/pt-BR.yml +11 -25
  170. data/config/locales/ro-RO.yml +2 -14
  171. data/config/locales/sv.yml +10 -21
  172. data/config/rubocop/disabled.yml +11 -0
  173. data/config/rubocop/faker.yml +480 -0
  174. data/config/rubocop/rails.yml +88 -0
  175. data/config/rubocop/rspec.yml +65 -0
  176. data/config/rubocop/ruby.yml +1210 -0
  177. data/db/migrate/20240306175331_rename_editor_images_awesome_config.rb +18 -0
  178. data/db/migrate/20240729164227_add_decidim_awesome_proposal_private_fields_date.rb +1 -1
  179. data/db/seeds.rb +3 -3
  180. data/lib/decidim/decidim_awesome/admin_engine.rb +4 -1
  181. data/lib/decidim/decidim_awesome/api/types/translated_custom_fields_type.rb +2 -3
  182. data/lib/decidim/decidim_awesome/awesome.rb +42 -28
  183. data/lib/decidim/decidim_awesome/awesome_helpers.rb +1 -1
  184. data/lib/decidim/decidim_awesome/checksums.yml +39 -60
  185. data/lib/decidim/decidim_awesome/config.rb +1 -1
  186. data/lib/decidim/decidim_awesome/custom_fields.rb +5 -5
  187. data/lib/decidim/decidim_awesome/engine.rb +24 -6
  188. data/lib/decidim/decidim_awesome/iframe_component/component.rb +1 -2
  189. data/lib/decidim/decidim_awesome/lock.rb +2 -2
  190. data/lib/decidim/decidim_awesome/map_component/component.rb +1 -1
  191. data/lib/decidim/decidim_awesome/menu.rb +33 -14
  192. data/lib/decidim/decidim_awesome/menu_hacker.rb +4 -8
  193. data/lib/decidim/decidim_awesome/system_checker.rb +2 -4
  194. data/lib/decidim/decidim_awesome/test/factories.rb +10 -10
  195. data/lib/decidim/decidim_awesome/test/initializer.rb +3 -11
  196. data/lib/decidim/decidim_awesome/test/layouts/decidim/_head.html.erb +2 -2
  197. data/lib/decidim/decidim_awesome/test/layouts/decidim/admin/_header.html.erb +2 -2
  198. data/lib/decidim/decidim_awesome/test/shared_examples/box_label_editor_examples.rb +18 -18
  199. data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +3 -3
  200. data/lib/decidim/decidim_awesome/test/shared_examples/custom_fields_examples.rb +11 -11
  201. data/lib/decidim/decidim_awesome/test/shared_examples/custom_redirects_contexts.rb +7 -7
  202. data/lib/decidim/decidim_awesome/test/shared_examples/editor_examples.rb +26 -66
  203. data/lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb +10 -9
  204. data/lib/decidim/decidim_awesome/test/shared_examples/scoped_admins_examples.rb +30 -20
  205. data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +19 -10
  206. data/lib/decidim/decidim_awesome/version.rb +2 -2
  207. data/lib/decidim/decidim_awesome/voting_manifest.rb +5 -10
  208. data/lib/decidim/decidim_awesome.rb +1 -2
  209. data/lib/tasks/decidim_awesome_active_storage_migrations_tasks.rake +1 -1
  210. data/lib/tasks/decidim_awesome_upgrade_tasks.rake +4 -0
  211. data/package.json +19 -28
  212. metadata +40 -56
  213. data/app/cells/concerns/decidim/decidim_awesome/proposal_m_cell_override.rb +0 -18
  214. data/app/cells/decidim/decidim_awesome/voting/voting_cards_counter/show.erb +0 -15
  215. data/app/cells/decidim/decidim_awesome/voting/voting_cards_counter/vote_button.erb +0 -15
  216. data/app/cells/decidim/decidim_awesome/voting/voting_cards_counter_cell.rb +0 -21
  217. data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_modal/show.erb +0 -16
  218. data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_modal_cell.rb +0 -20
  219. data/app/cells/decidim/proposals/proposal_m/footer.erb +0 -13
  220. data/app/overrides/layouts/decidim/_head/add_awesome_legacy_scripts.rb +0 -14
  221. data/app/overrides/layouts/decidim/admin/_header/replace_styles.html.erb.deface +0 -3
  222. data/app/packs/entrypoints/decidim_admin_decidim_awesome_custom_fields.js +0 -2
  223. data/app/packs/entrypoints/decidim_decidim_awesome_admin_form_exit_warn.js +0 -1
  224. data/app/packs/src/decidim/decidim_awesome/admin/constraints.js +0 -55
  225. data/app/packs/src/decidim/decidim_awesome/editors/editor.js +0 -213
  226. data/app/packs/stylesheets/decidim/decidim_awesome/editors/markdown_editor.scss +0 -19
  227. data/app/packs/stylesheets/decidim/decidim_awesome/editors/quill_editor.scss +0 -58
  228. data/app/packs/stylesheets/vendor/select2-foundation-theme.scss +0 -348
  229. data/app/serializers/concerns/decidim/decidim_awesome/proposal_serializer_override.rb +0 -65
  230. data/app/views/decidim/decidim_awesome/admin/config/_modal.html.erb +0 -11
  231. data/app/views/decidim/decidim_awesome/voting/voting_cards/_proposal_m_cell_footer.erb +0 -15
  232. /data/app/packs/src/decidim/decidim_awesome/{editors/tabs_focus.js → admin/tabs_change.js} +0 -0
@@ -1,213 +0,0 @@
1
- /* eslint-disable require-jsdoc, func-style */
2
-
3
- /*
4
- * Since version 0.25 we follow a different strategy and opt to destroy and override completely the original editor
5
- * That's because editors are instantiated directly instead of creating a global function to instantiate them
6
- */
7
-
8
- import lineBreakButtonHandler from "src/decidim/editor/linebreak_module"
9
- import InscrybMDE from "inscrybmde"
10
- import Europa from "europa"
11
- import "inline-attachment/src/inline-attachment";
12
- import "inline-attachment/src/codemirror-4.inline-attachment";
13
- import "inline-attachment/src/jquery.inline-attachment";
14
- import hljs from "highlight.js";
15
- import "highlight.js/styles/github.css";
16
- import "src/decidim/editor/clipboard_override"
17
- import "src/decidim/vendor/image-resize.min"
18
- import "src/decidim/vendor/image-upload.min"
19
- import { marked } from "marked";
20
-
21
- const DecidimAwesome = window.DecidimAwesome || {};
22
- const quillFormats = ["bold", "italic", "link", "underline", "header", "list", "video", "image", "alt", "break", "width", "style", "code", "blockquote", "indent"];
23
-
24
- // A tricky way to destroy the quill editor
25
- export function destroyQuillEditor(container) {
26
- if (container) {
27
- const content = $(container).find(".ql-editor").html();
28
- $(container).html(content);
29
- $(container).siblings(".ql-toolbar").remove();
30
- $(container).find("*[class*='ql-']").removeClass((index, className) => (className.match(/(^|\s)ql-\S+/g) || []).join(" "));
31
- $(container).removeClass((index, className) => (className.match(/(^|\s)ql-\S+/g) || []).join(" "));
32
- if ($(container).next().is("p.help-text")) {
33
- $(container).next().remove();
34
- }
35
- }
36
- else {
37
- console.error(`editor [${container}] not exists`);
38
- }
39
- }
40
-
41
- export function createQuillEditor(container) {
42
- const toolbar = $(container).data("toolbar");
43
- const disabled = $(container).data("disabled");
44
- const allowedEmptyContentSelector = "iframe,img";
45
-
46
- let quillToolbar = [
47
- ["bold", "italic", "underline", "linebreak"],
48
- [{ list: "ordered" }, { list: "bullet" }],
49
- ["link", "clean"],
50
- ["code", "blockquote"],
51
- [{ "indent": "-1"}, { "indent": "+1" }]
52
- ];
53
-
54
- let addImage = false;
55
-
56
- if (toolbar === "full") {
57
- quillToolbar = [
58
- [{ header: [2, 3, 4, 5, 6, false] }],
59
- ...quillToolbar
60
- ];
61
- if (DecidimAwesome.allow_images_in_full_editor) {
62
- quillToolbar.push(["video", "image"]);
63
- addImage = true;
64
- } else {
65
- quillToolbar.push(["video"]);
66
- }
67
- } else if (toolbar === "basic") {
68
- if (DecidimAwesome.allow_images_in_small_editor) {
69
- quillToolbar.push(["video", "image"]);
70
- addImage = true;
71
- } else {
72
- quillToolbar.push(["video"]);
73
- }
74
- } else if (DecidimAwesome.allow_images_in_small_editor) {
75
- quillToolbar.push(["image"]);
76
- addImage = true;
77
- }
78
-
79
- let modules = {
80
- linebreak: {},
81
- toolbar: {
82
- container: quillToolbar,
83
- handlers: {
84
- "linebreak": lineBreakButtonHandler
85
- }
86
- }
87
- };
88
-
89
- const $input = $(container).siblings('input[type="hidden"]');
90
- container.innerHTML = $input.val() || "";
91
- const token = $('meta[name="csrf-token"]').attr("content");
92
- if (addImage) {
93
- modules.imageResize = {
94
- modules: ["Resize", "DisplaySize"]
95
- }
96
- modules.imageUpload = {
97
- url: DecidimAwesome.editor_uploader_path,
98
- method: "POST",
99
- name: "image",
100
- withCredentials: false,
101
- headers: { "X-CSRF-Token": token },
102
- callbackOK: (serverResponse, next) => {
103
- $("div.ql-toolbar").last().removeClass("editor-loading")
104
- next(serverResponse.url);
105
- },
106
- callbackKO: (serverError) => {
107
- $("div.ql-toolbar").last().removeClass("editor-loading")
108
- let msg = serverError && serverError.body;
109
- try {
110
- msg = JSON.parse(msg).message;
111
- } catch (evt) { console.error("Parsing error", evt); }
112
- console.error(`Image upload error: ${msg}`);
113
- let $p = $(`<p class="text-alert help-text">${msg}</p>`);
114
- $(container).after($p)
115
- setTimeout(() => {
116
- $p.fadeOut(1000, () => {
117
- $p.destroy();
118
- });
119
- }, 3000);
120
- },
121
- checkBeforeSend: (file, next) => {
122
- $("div.ql-toolbar").last().addClass("editor-loading")
123
- next(file);
124
- }
125
- }
126
- }
127
- const quill = new Quill(container, {
128
- modules: modules,
129
- formats: quillFormats,
130
- theme: "snow"
131
- });
132
-
133
- if (disabled) {
134
- quill.disable();
135
- }
136
-
137
- quill.on("text-change", () => {
138
- const text = quill.getText();
139
-
140
- // Triggers CustomEvent with the cursor position
141
- // It is required in input_mentions.js
142
- let event = new CustomEvent("quill-position", {
143
- detail: quill.getSelection()
144
- });
145
- container.dispatchEvent(event);
146
-
147
- if ((text === "\n" || text === "\n\n") && quill.root.querySelectorAll(allowedEmptyContentSelector).length === 0) {
148
- $input.val("");
149
- } else {
150
- const emptyParagraph = "<p><br></p>";
151
- const cleanHTML = quill.root.innerHTML.replace(
152
- new RegExp(`^${emptyParagraph}|${emptyParagraph}$`, "g"),
153
- ""
154
- );
155
- $input.val(cleanHTML);
156
- }
157
- });
158
- // After editor is ready, linebreak_module deletes two extraneous new lines
159
- quill.emitter.emit("editor-ready");
160
-
161
- if (addImage) {
162
- const text = $(container).data("dragAndDropHelpText") || DecidimAwesome.texts.drag_and_drop_image;
163
- $(container).after(`<p class="help-text" style="margin-top:-1.5rem;">${text}</p>`);
164
- }
165
-
166
- // After editor is ready, linebreak_module deletes two extraneous new lines
167
- quill.emitter.emit("editor-ready");
168
-
169
- return quill;
170
- }
171
-
172
- export function createMarkdownEditor(container) {
173
- const text = DecidimAwesome.texts.drag_and_drop_image;
174
- const token = $('meta[name="csrf-token"]').attr("content");
175
- const $input = $(container).siblings('input[type="hidden"]');
176
- const $faker = $('<textarea name="faker-inscrybmde"/>');
177
- const $form = $(container).closest("form");
178
- const europa = new Europa();
179
- $faker.val(europa.convert($input.val()));
180
- $faker.insertBefore($(container));
181
- $(container).hide();
182
- const inscrybmde = new InscrybMDE({
183
- element: $faker[0],
184
- spellChecker: false,
185
- renderingConfig: {
186
- codeSyntaxHighlighting: true,
187
- hljs: hljs
188
- }
189
- });
190
- $faker[0].InscrybMDE = inscrybmde;
191
-
192
- // Allow image upload
193
- if (DecidimAwesome.allow_images_in_markdown_editor) {
194
- $(inscrybmde.gui.statusbar).prepend(`<span class="help-text" style="float:left;margin:0;text-align:left;">${text}</span>`);
195
- window.inlineAttachment.editors.codemirror4.attach(inscrybmde.codemirror, {
196
- uploadUrl: DecidimAwesome.editor_uploader_path,
197
- uploadFieldName: "image",
198
- jsonFieldName: "url",
199
- extraHeaders: { "X-CSRF-Token": token }
200
- });
201
- }
202
-
203
- // Allow linebreaks
204
- marked.setOptions({
205
- breaks: true
206
- });
207
-
208
- // convert to html on submit
209
- $form.on("submit", () => {
210
- // e.preventDefault();
211
- $input.val(marked(inscrybmde.value()));
212
- });
213
- }
@@ -1,19 +0,0 @@
1
- @import "inscrybmde/src/css/inscrybmde";
2
-
3
- // editor tweaks
4
- //
5
- .editor .CodeMirror {
6
- color: #333;
7
- font-weight: normal;
8
- line-height: 1.45;
9
-
10
- code {
11
- border: none;
12
- }
13
-
14
- .CodeMirror-code {
15
- span {
16
- color: #333 !important;
17
- }
18
- }
19
- }
@@ -1,58 +0,0 @@
1
- @import "stylesheets/decidim/variables";
2
- @import "stylesheets/decidim/utils/settings";
3
- @import "stylesheets/decidim/utils/mixins";
4
-
5
- .editor-loading {
6
- &::before {
7
- @include spinner(25px, $medium-gray, var(--primary), 800ms);
8
-
9
- float: right;
10
- content: "";
11
- vertical-align: middle;
12
- }
13
- }
14
- // some fix for the admin
15
- .form-group {
16
- .ql-container {
17
- background-color: white;
18
- }
19
- }
20
-
21
- // some fix for the public part
22
- .editor-container {
23
- overflow: hidden;
24
- }
25
-
26
- .editor.hashtags__container {
27
- > p.help-text {
28
- margin-top: -1rem;
29
- margin-bottom: 1.5rem;
30
- }
31
- }
32
-
33
- // For quill editors in custom fields
34
- .form-control[type="richtext"] {
35
- > p.help-text {
36
- margin-top: 0.2rem !important;
37
- }
38
-
39
- .ql-snow.ql-toolbar {
40
- button {
41
- width: 22px;
42
- margin: 1px 0;
43
- }
44
-
45
- + .ql-container.ql-snow {
46
- border-radius: 0;
47
- }
48
- }
49
- }
50
-
51
- .proposal_custom_fields_editor {
52
- .form-wrap.form-builder {
53
- .form-group > .form-control[type="richtext"] {
54
- padding: 0;
55
- border: none;
56
- }
57
- }
58
- }
@@ -1,348 +0,0 @@
1
- span.select2-container--foundation {
2
- vertical-align: top;
3
- }
4
-
5
- span.select2-container--foundation .selection {
6
- margin: 0 0 1rem;
7
- }
8
-
9
- .select2-container--foundation {
10
- /**
11
- * Search field in the Select2 dropdown.
12
- */
13
-
14
- /**
15
- * No outline for all search fields - in the dropdown
16
- * and inline in multi Select2s.
17
- */
18
-
19
- /* Clear the selection. */
20
-
21
- /**
22
- * Address disabled Select2 styles.
23
- *
24
- * @see https://select2.github.io/examples.html#disabled
25
- * @see http://getbootstrap.com/css/#forms-control-disabled
26
- */
27
-
28
- /* ------------------------------------*\
29
- #DROPDOWN
30
- \*------------------------------------ */
31
- }
32
-
33
- .select2-container--foundation .select2-selection {
34
- background-color: #fefefe;
35
- border: 1px solid #cacaca;
36
- border-radius: 0;
37
- color: #0a0a0a;
38
- font-family: inherit;
39
- font-size: 1rem;
40
- background: #fefefe;
41
- outline: 0;
42
- }
43
-
44
- .select2-container--foundation .select2-search--dropdown .select2-search__field {
45
- background-color: #fefefe;
46
- border: 1px solid #cacaca;
47
- border-radius: 0;
48
- color: #0a0a0a;
49
- font-family: inherit;
50
- font-size: 1rem;
51
- border-radius: 0;
52
- }
53
-
54
- .select2-container--foundation .select2-search__field {
55
- outline: 0;
56
-
57
- /* Firefox 18- */
58
-
59
- /**
60
- * Firefox 19+
61
- *
62
- * @see http://stackoverflow.com/questions/24236240/color-for-styled-placeholder-text-is-muted-in-firefox
63
- */
64
- }
65
-
66
- .select2-container--foundation .select2-search__field::-webkit-input-placeholder {
67
- color: #8a8a8a;
68
- }
69
-
70
- .select2-container--foundation .select2-search__field:-moz-placeholder {
71
- color: #8a8a8a;
72
- }
73
-
74
- .select2-container--foundation .select2-search__field::-moz-placeholder {
75
- color: #8a8a8a;
76
- opacity: 1;
77
- }
78
-
79
- .select2-container--foundation .select2-search__field:-ms-input-placeholder {
80
- color: #8a8a8a;
81
- }
82
-
83
- .select2-container--foundation .select2-results__option {
84
- /**
85
- * Disabled results.
86
- *
87
- * @see https://select2.github.io/examples.html#disabled-results
88
- */
89
-
90
- /**
91
- * Hover state.
92
- */
93
-
94
- /**
95
- * Selected state.
96
- */
97
- }
98
-
99
- .select2-container--foundation .select2-results__option[role=group] {
100
- padding: 0;
101
- }
102
-
103
- .select2-container--foundation .select2-results__option[role=group] strong {
104
- padding-left: .125rem;
105
- }
106
-
107
- .select2-container--foundation .select2-results__option[aria-disabled=true] {
108
- color: #8a8a8a;
109
- cursor: default;
110
- }
111
-
112
- .select2-container--foundation .select2-results__option--highlighted[aria-selected] {
113
- background-color: #2199e8;
114
- color: foreground(#2199e8);
115
- }
116
-
117
- .select2-container--foundation.select2-container--focus .select2-selection {
118
- border: 1px solid #8a8a8a;
119
- }
120
-
121
- .select2-container--foundation.select2-container--open .select2-selection {
122
- border: 1px solid #8a8a8a;
123
- border-radius: 0;
124
- }
125
-
126
- .select2-container--foundation.select2-container--open {
127
- /**
128
- * Make the dropdown arrow point up while the dropdown is visible.
129
- */
130
- }
131
-
132
- .select2-container--foundation.select2-container--open .select2-selection__arrow b {
133
- transform: rotate(180deg);
134
- }
135
-
136
- .select2-container--foundation .select2-choice {
137
- box-shadow: none;
138
- background-image: none;
139
- }
140
-
141
- .select2-container--foundation .select2-choice div {
142
- background-clip: padding-box;
143
- }
144
-
145
- .select2-container--foundation .select2-choice .select2-arrow {
146
- border: 0;
147
- border-radius: 0;
148
- background: transparent;
149
- background-image: none;
150
- }
151
-
152
- .select2-container--foundation *:focus {
153
- outline: 0;
154
- }
155
-
156
- .select2-container--foundation .select2-selection__clear {
157
- color: #8a8a8a;
158
- cursor: pointer;
159
- float: left;
160
- font-weight: bold;
161
- margin-right: 0;
162
- }
163
-
164
- .select2-container--foundation .select2-selection__clear:hover {
165
- color: #333;
166
- }
167
-
168
- .select2-container--foundation.select2-container--disabled .select2-selection {
169
- border: 1px solid #cacaca;
170
- }
171
-
172
- .select2-container--foundation.select2-container--disabled .select2-selection,
173
- .select2-container--foundation.select2-container--disabled .select2-search__field {
174
- cursor: default;
175
- }
176
-
177
- .select2-container--foundation.select2-container--disabled .select2-selection,
178
- .select2-container--foundation.select2-container--disabled .select2-selection--multiple .select2-selection__choice {
179
- background-color: #e6e6e6;
180
- color: foreground(#e6e6e6);
181
- }
182
-
183
- .select2-container--foundation.select2-container--disabled .select2-selection__clear,
184
- .select2-container--foundation.select2-container--disabled .select2-selection--multiple .select2-selection__choice__remove {
185
- display: none;
186
- }
187
-
188
- .select2-container--foundation .select2-dropdown {
189
- border: 1px solid #8a8a8a;
190
- border-top: 1px solid #cacaca;
191
- background: #fefefe;
192
- border-radius: 0;
193
- overflow-x: hidden;
194
- margin-top: -.0625rem;
195
- }
196
-
197
- .select2-container--foundation .select2-dropdown--above {
198
- margin-top: .0625rem;
199
- border-radius: 0;
200
- border-top: 1px solid #8a8a8a;
201
- border-bottom: 1px solid #cacaca;
202
- }
203
-
204
- .select2-container--foundation .select2-results > .select2-results__options {
205
- /* Limit the dropdown height. */
206
- max-height: 200px;
207
- overflow-y: auto;
208
- }
209
-
210
- /**
211
- * Temporary fix for https://github.com/select2/select2-bootstrap-theme/issues/9
212
- *
213
- * Provides `!important` for certain properties of the class applied to the
214
- * original `<select>` element to hide it.
215
- *
216
- * @see https://github.com/select2/select2/pull/3301
217
- * @see https://github.com/fk/select2/commit/31830c7b32cb3d8e1b12d5b434dee40a6e753ada
218
- */
219
- .form-control.select2-hidden-accessible {
220
- position: absolute !important;
221
- width: 1px !important;
222
- }
223
-
224
- /**
225
- * Display override for inline forms
226
- */
227
- .input-group span.select2-container--foundation {
228
- margin: 0;
229
- vertical-align: middle;
230
- }
231
-
232
- .input-group span.select2-container--foundation .selection .select2-selection {
233
- vertical-align: middle;
234
- border-radius: 0;
235
- }
236
-
237
- /****** Single SCSS *******/
238
- .select2-container--foundation .select2-selection--single,
239
- .select2-container--foundation .selection .select2-selection--single {
240
- height: 2.4375rem;
241
- line-height: 1.5;
242
- padding: .5rem;
243
- }
244
-
245
- .select2-container--foundation .select2-selection--single .select2-selection__rendered,
246
- .select2-container--foundation .selection .select2-selection--single .select2-selection__rendered {
247
- color: #0a0a0a;
248
- }
249
-
250
- .select2-container--foundation .select2-selection--single .select2-selection__arrow,
251
- .select2-container--foundation .selection .select2-selection--single .select2-selection__arrow {
252
- height: 2.4375rem;
253
- position: absolute;
254
- top: 0;
255
- right: 1px;
256
- width: 20px;
257
- }
258
-
259
- .select2-container--foundation .select2-selection--single .select2-selection__arrow b,
260
- .select2-container--foundation .selection .select2-selection--single .select2-selection__arrow b {
261
- border-color: #333 transparent transparent;
262
- top: 50%;
263
- border-style: solid;
264
- border-width: 6px 4px 0;
265
- height: 0;
266
- left: 50%;
267
- margin-left: -4px;
268
- margin-top: -2px;
269
- position: absolute;
270
- width: 0;
271
- }
272
-
273
- .select2-container--foundation .select2-selection--single .select2-selection__placeholder,
274
- .select2-container--foundation .selection .select2-selection--single .select2-selection__placeholder {
275
- color: #8a8a8a;
276
- }
277
-
278
- .select2-container--foundation .select2-selection--single .select2-selection__clear,
279
- .select2-container--foundation .selection .select2-selection--single .select2-selection__clear {
280
- cursor: pointer;
281
- float: right;
282
- font-weight: bold;
283
- }
284
-
285
- /****** Multiple SCSS *******/
286
- .select2-container--foundation .select2-selection--multiple {
287
- /* Clear the selection. */
288
- }
289
-
290
- .select2-container--foundation .select2-selection--multiple .select2-selection__choice__remove:hover {
291
- cursor: pointer;
292
- }
293
-
294
- .select2-container--foundation .select2-selection--multiple ul.select2-selection__rendered,
295
- .select2-container--foundation .select2-selection--multiple .select2-selection__rendered {
296
- display: inherit;
297
- box-sizing: border-box;
298
- list-style: none;
299
- margin: 0;
300
- padding: 0 5px;
301
- width: 100%;
302
- }
303
-
304
- .select2-container--foundation .select2-selection--multiple .select2-selection__choice {
305
- border-radius: 0;
306
- padding: .1875rem .3125rem;
307
- cursor: default;
308
- float: left;
309
- margin-right: .3125rem;
310
- margin-top: .125rem;
311
- margin-bottom: .125rem;
312
- border: 1px solid #8a8a8a;
313
- }
314
-
315
- .select2-container--foundation .select2-selection--multiple .select2-selection__choice__remove {
316
- margin-right: 6px;
317
- margin-left: 6px;
318
- float: right;
319
- }
320
-
321
- .select2-container--foundation .select2-selection--multiple .select2-search--inline .select2-search__field {
322
- background: transparent;
323
- line-height: 1.5;
324
- border: 0;
325
- margin-top: 0;
326
- min-width: 5rem;
327
- height: 2.375rem;
328
- box-shadow: none;
329
- margin: 0;
330
- margin-right: -2rem;
331
- }
332
-
333
- .select2-container--foundation .select2-selection--multiple .select2-selection__choice__remove {
334
- color: #8a8a8a;
335
- cursor: pointer;
336
- display: inline-block;
337
- font-weight: bold;
338
- margin-right: .25rem;
339
- }
340
-
341
- .select2-container--foundation .select2-selection--multiple .select2-selection__choice__remove:hover {
342
- color: #333;
343
- }
344
-
345
- .select2-container--foundation .select2-selection--multiple .select2-selection__clear {
346
- margin-right: .1875rem;
347
- margin-top: .5rem;
348
- }
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module DecidimAwesome
5
- module ProposalSerializerOverride
6
- extend ActiveSupport::Concern
7
-
8
- included do
9
- # Public: Exports a hash with the serialized data for this proposal.
10
- def serialize
11
- {
12
- id: proposal.id,
13
- category: {
14
- id: proposal.category.try(:id),
15
- name: proposal.category.try(:name) || empty_translatable
16
- },
17
- scope: {
18
- id: proposal.scope.try(:id),
19
- name: proposal.scope.try(:name) || empty_translatable
20
- },
21
- participatory_space: {
22
- id: proposal.participatory_space.id,
23
- url: Decidim::ResourceLocatorPresenter.new(proposal.participatory_space).url
24
- },
25
- component: { id: component.id },
26
- title: proposal.title,
27
- body: convert_to_plain_text(proposal.body),
28
- address: proposal.address,
29
- latitude: proposal.latitude,
30
- longitude: proposal.longitude,
31
- state: proposal.state.to_s,
32
- reference: proposal.reference,
33
- answer: ensure_translatable(proposal.answer),
34
- answered_at: proposal.answered_at,
35
- supports: proposal.proposal_votes_count,
36
- weights: proposal_vote_weights,
37
- endorsements: {
38
- total_count: proposal.endorsements.size,
39
- user_endorsements: user_endorsements
40
- },
41
- comments: proposal.comments_count,
42
- attachments: proposal.attachments.size,
43
- followers: proposal.follows.size,
44
- published_at: proposal.published_at,
45
- url: url,
46
- meeting_urls: meetings,
47
- related_proposals: related_proposals,
48
- is_amend: proposal.emendation?,
49
- original_proposal: {
50
- title: proposal&.amendable&.title,
51
- url: original_proposal_url
52
- }
53
- }
54
- end
55
-
56
- private
57
-
58
- def proposal_vote_weights
59
- proposal.update_vote_weights!
60
- proposal.vote_weights
61
- end
62
- end
63
- end
64
- end
65
- end