decidim-decidim_awesome 0.8.0 → 0.12.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +363 -0
- data/README.md +375 -100
- data/Rakefile +2 -1
- data/app/cells/concerns/decidim/decidim_awesome/global_menu_cell_override.rb +20 -0
- data/app/cells/concerns/decidim/decidim_awesome/proposal_l_cell_override.rb +26 -0
- data/app/cells/decidim/decidim_awesome/content_blocks/map/show.erb +5 -12
- data/app/cells/decidim/decidim_awesome/content_blocks/map_cell.rb +7 -7
- data/app/cells/decidim/decidim_awesome/voting/proposal_metadata_cell.rb +69 -0
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_base_cell.rb +40 -0
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/modal.erb +18 -0
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/show.erb +40 -0
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/vote_block_for.erb +16 -0
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_cell.rb +90 -0
- data/app/commands/concerns/decidim/decidim_awesome/admin/needs_constraint_helpers.rb +2 -2
- data/app/commands/concerns/decidim/decidim_awesome/proposals/admin/update_proposal_override.rb +31 -0
- data/app/commands/concerns/decidim/decidim_awesome/proposals/create_collaborative_draft_override.rb +27 -0
- data/app/commands/concerns/decidim/decidim_awesome/proposals/create_proposal_override.rb +27 -0
- data/app/commands/concerns/decidim/decidim_awesome/proposals/update_collaborative_draft_override.rb +27 -0
- data/app/commands/concerns/decidim/decidim_awesome/proposals/update_proposal_override.rb +26 -0
- data/app/commands/concerns/decidim/decidim_awesome/system/create_organization_override.rb +29 -0
- data/app/commands/concerns/decidim/decidim_awesome/system/update_organization_override.rb +35 -0
- data/app/commands/concerns/decidim/decidim_awesome/update_account_override.rb +30 -0
- data/app/commands/decidim/decidim_awesome/admin/create_constraint.rb +3 -3
- data/app/commands/decidim/decidim_awesome/admin/create_custom_redirect.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/create_menu_hack.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/create_proposal_custom_field.rb +5 -4
- data/app/commands/decidim/decidim_awesome/admin/create_scoped_admin.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/create_scoped_style.rb +4 -3
- data/app/commands/decidim/decidim_awesome/admin/destroy_constraint.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/destroy_custom_redirect.rb +2 -2
- data/app/commands/decidim/decidim_awesome/admin/destroy_menu_hack.rb +2 -2
- data/app/commands/decidim/decidim_awesome/admin/destroy_proposal_custom_field.rb +7 -4
- data/app/commands/decidim/decidim_awesome/admin/destroy_scoped_admin.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/destroy_scoped_style.rb +7 -5
- data/app/commands/decidim/decidim_awesome/admin/rename_scope_label.rb +2 -2
- data/app/commands/decidim/decidim_awesome/admin/update_config.rb +2 -3
- data/app/commands/decidim/decidim_awesome/admin/update_constraint.rb +3 -3
- data/app/commands/decidim/decidim_awesome/admin/update_custom_redirect.rb +3 -3
- data/app/commands/decidim/decidim_awesome/admin/update_menu_hack.rb +1 -1
- data/app/commands/decidim/decidim_awesome/command.rb +8 -0
- data/app/commands/decidim/decidim_awesome/create_editor_image.rb +2 -2
- data/app/controllers/concerns/decidim/decidim_awesome/admin/maintenance_context.rb +43 -0
- data/app/controllers/concerns/decidim/decidim_awesome/admin_accountability/admin/filterable.rb +67 -0
- data/app/controllers/concerns/decidim/decidim_awesome/admin_accountability/admin/filterable_helper.rb +38 -0
- data/app/controllers/concerns/decidim/decidim_awesome/check_login_authorizations.rb +60 -0
- data/app/controllers/concerns/decidim/decidim_awesome/content_security_policy.rb +34 -0
- data/app/controllers/concerns/decidim/decidim_awesome/limit_pending_amendments.rb +35 -0
- data/app/controllers/concerns/decidim/decidim_awesome/needs_awesome_config.rb +0 -2
- data/app/controllers/concerns/decidim/decidim_awesome/not_found_redirect.rb +3 -3
- data/app/controllers/concerns/decidim/decidim_awesome/proposals/memoize_extra_fields.rb +23 -0
- data/app/controllers/concerns/decidim/decidim_awesome/proposals/orderable_override.rb +94 -0
- data/app/controllers/concerns/decidim/decidim_awesome/proposals/proposal_votes_controller_override.rb +64 -0
- data/app/controllers/concerns/decidim/decidim_awesome/use_user_time_zone.rb +32 -0
- data/app/controllers/decidim/decidim_awesome/admin/admin_accountability_controller.rb +72 -0
- data/app/controllers/decidim/decidim_awesome/admin/admin_authorizations_controller.rb +122 -0
- data/app/controllers/decidim/decidim_awesome/admin/application_controller.rb +2 -0
- data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +21 -17
- data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +17 -8
- data/app/controllers/decidim/decidim_awesome/admin/constraints_controller.rb +27 -20
- data/app/controllers/decidim/decidim_awesome/admin/custom_redirects_controller.rb +6 -8
- data/app/controllers/decidim/decidim_awesome/admin/maintenance_controller.rb +76 -0
- data/app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb +6 -8
- data/app/controllers/decidim/decidim_awesome/admin/proposal_custom_fields_controller.rb +14 -6
- data/app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb +2 -2
- data/app/controllers/decidim/decidim_awesome/admin/scoped_styles_controller.rb +14 -6
- data/app/controllers/decidim/decidim_awesome/blank_component_controller.rb +8 -3
- data/app/controllers/decidim/decidim_awesome/editor_images_controller.rb +3 -5
- data/app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb +18 -5
- data/app/controllers/decidim/decidim_awesome/required_authorizations_controller.rb +58 -0
- data/app/forms/concerns/decidim/decidim_awesome/account_form_override.rb +25 -0
- data/app/forms/concerns/decidim/decidim_awesome/proposals/proposal_form_customizations.rb +57 -0
- data/app/forms/concerns/decidim/decidim_awesome/proposals/proposal_form_override.rb +21 -0
- data/app/forms/concerns/decidim/decidim_awesome/system/organization_form_override.rb +34 -0
- data/app/forms/decidim/decidim_awesome/admin/config_form.rb +88 -20
- data/app/forms/decidim/decidim_awesome/admin/custom_redirect_form.rb +3 -3
- data/app/forms/decidim/decidim_awesome/admin/intergram_form.rb +4 -0
- data/app/forms/decidim/decidim_awesome/admin/menu_form.rb +5 -5
- data/app/helpers/concerns/decidim/decidim_awesome/amendments_helper_override.rb +65 -0
- data/app/helpers/concerns/decidim/decidim_awesome/breadcrumb_helper_override.rb +23 -0
- data/app/helpers/concerns/decidim/decidim_awesome/proposals/application_helper_override.rb +110 -0
- data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +12 -29
- data/app/helpers/decidim/decidim_awesome/admin/system_checker_helpers.rb +4 -0
- data/app/helpers/decidim/decidim_awesome/map_helper.rb +38 -52
- data/app/jobs/decidim/decidim_awesome/destroy_private_data_job.rb +22 -0
- data/app/jobs/decidim/decidim_awesome/export_admin_actions_job.rb +28 -0
- data/app/models/concerns/decidim/decidim_awesome/has_proposal_extra_fields.rb +80 -0
- data/app/models/concerns/decidim/decidim_awesome/has_vote_weight.rb +30 -0
- data/app/models/decidim/decidim_awesome/awesome_config.rb +1 -2
- data/app/models/decidim/decidim_awesome/config_constraint.rb +0 -2
- data/app/models/decidim/decidim_awesome/editor_image.rb +0 -3
- data/app/models/decidim/decidim_awesome/paper_trail_version.rb +117 -0
- data/app/models/decidim/decidim_awesome/proposal_extra_field.rb +45 -0
- data/app/models/decidim/decidim_awesome/vote_weight.rb +30 -0
- data/app/overrides/decidim/account/show/add_timezone_select.html.erb.deface +3 -0
- data/app/overrides/decidim/admin/officializations/index/add_modal.html.erb.deface +3 -0
- data/app/overrides/decidim/admin/officializations/index/add_td.html.erb.deface +5 -0
- data/app/overrides/decidim/admin/officializations/index/add_th.html.erb.deface +5 -0
- data/app/overrides/decidim/proposals/admin/proposals/_form/replace_editor.html.erb.deface +3 -0
- data/app/overrides/decidim/proposals/admin/proposals/show/add_private_body.html.erb.deface +7 -0
- data/app/overrides/decidim/proposals/admin/proposals/show/replace_body.html.erb.deface +5 -0
- data/app/overrides/decidim/proposals/proposals/_proposal_aside/limit_amendments_modal.html.erb.deface +5 -0
- data/app/overrides/decidim/proposals/proposals/_vote_button/replace_vote_button.html.erb.deface +7 -0
- data/app/overrides/decidim/proposals/proposals/_votes_count/replace_counter.html.erb.deface +10 -0
- data/app/overrides/decidim/system/organizations/_advanced_settings/add_awesome_config.html.erb.deface +9 -0
- data/app/{views/layouts/decidim/_head.html.erb → overrides/layouts/decidim/_decidim_javascript/add_awesome_tags.html.erb.deface} +2 -1
- data/app/overrides/layouts/decidim/_head/add_awesome_tags.html.erb.deface +7 -0
- data/app/overrides/layouts/decidim/admin/_header/add_awesome_custom_styles.html.erb.deface +3 -0
- data/app/overrides/layouts/decidim/admin/_header/add_awesome_tags.html.erb.deface +10 -0
- data/app/packs/entrypoints/decidim_admin_decidim_awesome.js +2 -2
- data/app/packs/entrypoints/decidim_admin_decidim_awesome_global.js +4 -0
- data/app/packs/entrypoints/decidim_admin_decidim_awesome_global.scss +1 -0
- data/app/packs/entrypoints/decidim_admin_decidim_awesome_search_form.scss +1 -0
- data/app/packs/entrypoints/decidim_decidim_awesome.js +2 -2
- data/app/packs/entrypoints/decidim_decidim_awesome_map.scss +1 -1
- data/app/packs/entrypoints/decidim_editor.js +14 -0
- data/app/packs/images/decidim/decidim_awesome/handcard.svg +14 -0
- data/app/packs/images/decidim/decidim_awesome/handcheck.svg +17 -0
- data/app/packs/images/decidim/decidim_awesome/pokecode-logo.png +0 -0
- data/app/packs/src/decidim/decidim_awesome/admin/auto_edit.js +96 -69
- data/app/packs/src/decidim/decidim_awesome/admin/check_redirections.js +46 -41
- data/app/packs/src/decidim/decidim_awesome/admin/codemirror.js +3 -3
- data/app/packs/src/decidim/decidim_awesome/admin/constraint_form_events.js +115 -0
- data/app/packs/src/decidim/decidim_awesome/admin/custom_fields_builder.js +19 -14
- data/app/packs/src/decidim/decidim_awesome/admin/form_exit_warn.js +23 -11
- data/app/packs/src/decidim/decidim_awesome/admin/proposal_sortings.js +26 -0
- data/app/packs/src/decidim/decidim_awesome/admin/tabs_change.js +31 -0
- data/app/packs/src/decidim/decidim_awesome/admin/user_picker.js +34 -20
- data/app/packs/src/decidim/decidim_awesome/admin/verification_selects.js +21 -0
- data/app/packs/src/decidim/decidim_awesome/admin/verifications.js +43 -0
- data/app/packs/src/decidim/decidim_awesome/amendments/show_modal_on_limits.js +28 -0
- data/app/packs/src/decidim/decidim_awesome/awesome_admin.js +7 -16
- data/app/packs/src/decidim/decidim_awesome/awesome_admin_global.js +2 -0
- data/app/packs/src/decidim/decidim_awesome/awesome_application.js +2 -15
- data/app/packs/src/decidim/decidim_awesome/awesome_map/api/fetcher.js +48 -23
- data/app/packs/src/decidim/decidim_awesome/awesome_map/api/meetings_fetcher.js +9 -12
- data/app/packs/src/decidim/decidim_awesome/awesome_map/api/proposals_fetcher.js +28 -0
- data/app/packs/src/decidim/decidim_awesome/awesome_map/awesome_map.js +15 -15
- data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/controller.js +70 -37
- data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/meetings_controller.js +11 -7
- data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/proposals_controller.js +9 -16
- data/app/packs/src/decidim/decidim_awesome/awesome_map/controls_ui.js +75 -45
- data/app/packs/src/decidim/decidim_awesome/awesome_map/load_map.js +28 -18
- data/app/packs/src/decidim/decidim_awesome/editor/index.js +94 -0
- data/app/packs/src/decidim/decidim_awesome/forms/autosave.js +29 -28
- data/app/packs/src/decidim/decidim_awesome/forms/custom_fields_renderer.js +55 -42
- data/app/packs/src/decidim/decidim_awesome/forms/rich_text_plugin.js +30 -32
- data/app/packs/src/decidim/decidim_awesome/proposals/custom_fields.js +32 -16
- data/app/packs/src/decidim/decidim_awesome/proposals/images.js +16 -10
- data/app/packs/src/decidim/decidim_awesome/voting/voting_cards.js +72 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/admin_accountability.scss +67 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/auto_edits.scss +11 -12
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/check_redirections.scss +15 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/codemirror.scss +24 -12
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/constraints.scss +49 -29
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/custom_fields.scss +28 -71
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/custom_styles.scss +48 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/intergram_fixes.scss +11 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/user_picker.scss +17 -26
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/verifications.scss +99 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/amendments/modal.scss +5 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin.scss +14 -49
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin_global.scss +20 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_application.scss +4 -18
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_iframe/iframe.scss +1 -1
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +41 -35
- data/app/packs/stylesheets/decidim/decidim_awesome/forms/autosave.scss +6 -6
- data/app/packs/stylesheets/decidim/decidim_awesome/forms/custom_fields.scss +118 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/shared/spinner.scss +26 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/voting/voting_cards.scss +205 -0
- data/app/permissions/decidim/decidim_awesome/admin/permissions.rb +57 -1
- data/app/permissions/decidim/decidim_awesome/permissions.rb +11 -6
- data/app/presenters/concerns/decidim/decidim_awesome/breadcrumb_root_menu_item_presenter_override.rb +23 -0
- data/app/presenters/{decidim → concerns/decidim}/decidim_awesome/menu_item_presenter_override.rb +10 -2
- data/app/presenters/{decidim → concerns/decidim}/decidim_awesome/menu_presenter_override.rb +8 -0
- data/app/presenters/concerns/decidim/decidim_awesome/proposals/proposal_presenter_override.rb +20 -0
- data/app/presenters/decidim/decidim_awesome/admin_log/component_presenter_override.rb +28 -0
- data/app/presenters/decidim/decidim_awesome/admin_log/user_presenter_override.rb +46 -0
- data/app/presenters/decidim/decidim_awesome/paper_trail_base_presenter.rb +28 -0
- data/app/presenters/decidim/decidim_awesome/participatory_space_role_presenter.rb +45 -0
- data/app/presenters/decidim/decidim_awesome/private_data_presenter.rb +70 -0
- data/app/presenters/decidim/decidim_awesome/role_base_presenter.rb +102 -0
- data/app/presenters/decidim/decidim_awesome/user_entity_presenter.rb +50 -0
- data/app/queries/decidim/decidim_awesome/private_data_finder.rb +19 -0
- data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_methods.rb +72 -0
- data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_override.rb +38 -0
- data/app/serializers/decidim/decidim_awesome/paper_trail_version_serializer.rb +37 -0
- data/app/serializers/decidim/decidim_awesome/proposals/private_proposal_serializer.rb +34 -0
- data/app/types/concerns/decidim/decidim_awesome/add_proposal_type_custom_fields.rb +59 -0
- data/app/types/concerns/decidim/decidim_awesome/add_proposal_type_vote_weights.rb +20 -0
- data/app/uploaders/decidim/decidim_awesome/image_uploader.rb +12 -0
- data/app/validators/concerns/decidim/decidim_awesome/etiquette_validator_override.rb +41 -0
- data/app/views/decidim/decidim_awesome/account/_timezone_select.html.erb +3 -0
- data/app/views/decidim/decidim_awesome/admin/admin_accountability/index.html.erb +71 -0
- data/app/views/decidim/decidim_awesome/admin/admin_authorizations/authorization.html.erb +20 -0
- data/app/views/decidim/decidim_awesome/admin/admin_authorizations/callout.html.erb +3 -0
- data/app/views/decidim/decidim_awesome/admin/admin_authorizations/conflict.html.erb +5 -0
- data/app/views/decidim/decidim_awesome/admin/admin_authorizations/edit.html.erb +41 -0
- data/app/views/decidim/decidim_awesome/admin/checks/_assets_tester.html.erb +2 -0
- data/app/views/decidim/decidim_awesome/admin/checks/index.html.erb +51 -48
- data/app/views/decidim/decidim_awesome/admin/config/_autoedit_box_label.html.erb +7 -2
- data/app/views/decidim/decidim_awesome/admin/config/_constraints.html.erb +25 -18
- data/app/views/decidim/decidim_awesome/admin/config/_form_admins.html.erb +7 -6
- data/app/views/decidim/decidim_awesome/admin/config/_form_editors.html.erb +12 -16
- data/app/views/decidim/decidim_awesome/admin/config/_form_livechat.html.erb +39 -23
- data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_custom_fields.html.erb +35 -17
- data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_private_custom_fields.html.erb +1 -0
- data/app/views/decidim/decidim_awesome/admin/config/_form_proposals.html.erb +92 -6
- data/app/views/decidim/decidim_awesome/admin/config/_form_scoped_admin_styles.html.erb +1 -0
- data/app/views/decidim/decidim_awesome/admin/config/_form_scoped_styles.html.erb +48 -0
- data/app/views/decidim/decidim_awesome/admin/config/_form_surveys.html.erb +16 -6
- data/app/views/decidim/decidim_awesome/admin/config/_form_verifications.html.erb +15 -0
- data/app/views/decidim/decidim_awesome/admin/config/show.html.erb +22 -12
- data/app/views/decidim/decidim_awesome/admin/constraints/_form.html.erb +1 -49
- data/app/views/decidim/decidim_awesome/admin/constraints/new.html.erb +14 -9
- data/app/views/decidim/decidim_awesome/admin/constraints/no_permissions.html.erb +6 -0
- data/app/views/decidim/decidim_awesome/admin/constraints/show.html.erb +14 -9
- data/app/views/decidim/decidim_awesome/admin/custom_redirects/_form.html.erb +20 -5
- data/app/views/decidim/decidim_awesome/admin/custom_redirects/edit.html.erb +5 -5
- data/app/views/decidim/decidim_awesome/admin/custom_redirects/index.html.erb +14 -13
- data/app/views/decidim/decidim_awesome/admin/custom_redirects/new.html.erb +5 -5
- data/app/views/decidim/decidim_awesome/admin/maintenance/_private_data.html.erb +44 -0
- data/app/views/decidim/decidim_awesome/admin/maintenance/show.html.erb +44 -0
- data/app/views/decidim/decidim_awesome/admin/menu_hacks/_form.html.erb +6 -6
- data/app/views/decidim/decidim_awesome/admin/menu_hacks/edit.html.erb +21 -12
- data/app/views/decidim/decidim_awesome/admin/menu_hacks/index.html.erb +39 -42
- data/app/views/decidim/decidim_awesome/admin/menu_hacks/new.html.erb +21 -12
- data/app/views/decidim/decidim_awesome/admin/officializations/_participants_td.html.erb +25 -0
- data/app/views/decidim/decidim_awesome/admin/officializations/_participants_th.html.erb +1 -0
- data/app/views/decidim/decidim_awesome/admin/officializations/_verification_modal.html.erb +9 -0
- data/app/views/decidim/decidim_awesome/admin/proposals/_editor.html.erb +8 -5
- data/app/views/decidim/decidim_awesome/admin/proposals/_private_body.html.erb +20 -0
- data/app/views/decidim/decidim_awesome/admin/shared/_filters_with_date.html.erb +61 -0
- data/app/views/decidim/decidim_awesome/amendments/_modal.html.erb +23 -0
- data/app/views/decidim/decidim_awesome/custom_fields/_form_render.html.erb +8 -2
- data/app/views/decidim/decidim_awesome/iframe_component/iframe/show.html.erb +7 -12
- data/app/views/decidim/decidim_awesome/map_component/map/_map_template.html.erb +53 -37
- data/app/views/decidim/decidim_awesome/map_component/map/show.html.erb +14 -5
- data/app/views/decidim/decidim_awesome/required_authorizations/index.html.erb +66 -0
- data/app/views/decidim/decidim_awesome/system/organizations/_admin_allowed_authorizations.html.erb +5 -0
- data/app/views/decidim/decidim_awesome/voting/voting_cards/_show_vote_button.html.erb +3 -0
- data/app/views/decidim/decidim_awesome/voting/voting_cards/_show_votes_count.html.erb +1 -0
- data/app/views/layouts/decidim/decidim_awesome/_awesome_config.html.erb +11 -8
- data/app/views/layouts/decidim/decidim_awesome/_custom_styles.html.erb +1 -1
- data/app/views/layouts/decidim/decidim_awesome/_intergram_widget.html.erb +9 -6
- data/app/views/layouts/decidim/decidim_awesome/admin/_base.html.erb +12 -0
- data/app/views/layouts/decidim/decidim_awesome/admin/_custom_styles.html.erb +3 -0
- data/app/views/layouts/decidim/decidim_awesome/admin/admin_authorizations.html.erb +7 -0
- data/app/views/layouts/decidim/decidim_awesome/admin/application.html.erb +3 -0
- data/app/views/layouts/decidim/decidim_awesome/admin/maintenance.html.erb +19 -0
- data/config/assets.rb +5 -34
- data/config/i18n-tasks.yml +30 -0
- data/config/locales/ca.yml +335 -26
- data/config/locales/cs.yml +331 -22
- data/config/locales/de.yml +642 -0
- data/config/locales/en.yml +403 -33
- data/config/locales/es.yml +333 -24
- data/config/locales/eu.yml +623 -20
- data/config/locales/fr.yml +282 -23
- data/config/locales/hu.yml +268 -0
- data/config/locales/it.yml +155 -24
- data/config/locales/ja.yml +334 -25
- data/config/locales/lt.yml +94 -0
- data/config/locales/nl.yml +20 -19
- data/config/locales/pt-BR.yml +31 -24
- data/config/locales/ro-RO.yml +152 -0
- data/config/locales/sv.yml +28 -12
- data/config/rubocop/disabled.yml +11 -0
- data/config/rubocop/faker.yml +480 -0
- data/config/rubocop/rails.yml +88 -0
- data/config/rubocop/rspec.yml +65 -0
- data/config/rubocop/ruby.yml +1210 -0
- data/db/migrate/20231006113837_create_decidim_awesome_vote_weights.rb +13 -0
- data/db/migrate/20231006113841_create_decidim_awesome_proposal_extra_fields.rb +14 -0
- data/db/migrate/20240306175331_rename_editor_images_awesome_config.rb +18 -0
- data/db/migrate/20240531224204_add_decidim_awesome_proposal_private_fields.rb +29 -0
- data/db/migrate/20240729164227_add_decidim_awesome_proposal_private_fields_date.rb +20 -0
- data/db/seeds.rb +4 -4
- data/lib/decidim/decidim_awesome/admin_engine.rb +41 -6
- data/lib/decidim/decidim_awesome/api/types/localized_custom_fields_type.rb +22 -0
- data/lib/decidim/decidim_awesome/api/types/translated_custom_fields_type.rb +51 -0
- data/lib/decidim/decidim_awesome/authorizator.rb +34 -0
- data/lib/decidim/decidim_awesome/awesome.rb +236 -29
- data/lib/decidim/decidim_awesome/awesome_helpers.rb +57 -17
- data/lib/decidim/decidim_awesome/checksums.yml +95 -20
- data/lib/decidim/decidim_awesome/config.rb +25 -17
- data/lib/decidim/decidim_awesome/context_analyzers/request_analyzer.rb +3 -3
- data/lib/decidim/decidim_awesome/custom_fields.rb +13 -5
- data/lib/decidim/decidim_awesome/engine.rb +250 -19
- data/lib/decidim/decidim_awesome/iframe_component/component.rb +4 -4
- data/lib/decidim/decidim_awesome/lock.rb +47 -0
- data/lib/decidim/decidim_awesome/map_component/component.rb +2 -2
- data/lib/decidim/decidim_awesome/menu.rb +201 -0
- data/lib/decidim/decidim_awesome/menu_hacker.rb +7 -5
- data/{app/middleware/decidim/decidim_awesome → lib/decidim/decidim_awesome/middleware}/current_config.rb +5 -3
- data/lib/decidim/decidim_awesome/request_memoizer.rb +16 -0
- data/lib/decidim/decidim_awesome/system_checker.rb +6 -2
- data/lib/decidim/decidim_awesome/test/factories.rb +31 -9
- data/lib/decidim/decidim_awesome/test/initializer.rb +22 -6
- data/lib/decidim/decidim_awesome/test/layouts/decidim/_head.html.erb +2 -2
- data/lib/decidim/decidim_awesome/test/layouts/decidim/admin/_header.html.erb +2 -2
- data/lib/decidim/decidim_awesome/test/shared_examples/action_log_presenter_examples.rb +61 -0
- data/lib/decidim/decidim_awesome/test/shared_examples/{box_label_editor.rb → box_label_editor_examples.rb} +22 -22
- data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +24 -6
- data/lib/decidim/decidim_awesome/test/shared_examples/custom_fields_examples.rb +155 -0
- data/lib/decidim/decidim_awesome/test/shared_examples/custom_redirects_contexts.rb +7 -7
- data/lib/decidim/decidim_awesome/test/shared_examples/custom_styles_examples.rb +156 -0
- data/lib/decidim/decidim_awesome/test/shared_examples/editor_examples.rb +42 -58
- data/lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb +9 -8
- data/lib/decidim/decidim_awesome/test/shared_examples/scoped_admins_examples.rb +40 -29
- data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +129 -38
- data/lib/decidim/decidim_awesome/version.rb +2 -2
- data/lib/decidim/decidim_awesome/voting_manifest.rb +55 -0
- data/lib/decidim/decidim_awesome.rb +1 -3
- data/lib/tasks/decidim_awesome_upgrade_tasks.rake +9 -0
- data/lib/tasks/decidim_awesome_webpacker_tasks.rake +2 -0
- data/package.json +54 -0
- metadata +192 -86
- data/app/forms/decidim/decidim_awesome/proposals/proposal_wizard_create_step_form_override.rb +0 -38
- data/app/helpers/decidim/decidim_awesome/amendments_helper_override.rb +0 -48
- data/app/helpers/decidim/decidim_awesome/proposals/application_helper_override.rb +0 -78
- data/app/jobs/decidim/decidim_awesome/migrate_legacy_images_job.rb +0 -106
- data/app/packs/entrypoints/decidim_admin_decidim_awesome_custom_fields.js +0 -2
- data/app/packs/entrypoints/decidim_decidim_awesome_admin_form_exit_warn.js +0 -1
- data/app/packs/images/decidim/decidim_awesome/platoniq-logo.png +0 -0
- data/app/packs/src/decidim/decidim_awesome/admin/constraints.js +0 -55
- data/app/packs/src/decidim/decidim_awesome/editors/editor.js +0 -190
- data/app/packs/src/decidim/decidim_awesome/editors/tabs_focus.js +0 -22
- data/app/packs/src/vendor/image-resize.min.js +0 -1
- data/app/packs/src/vendor/image-upload.min.js +0 -6
- data/app/packs/src/vendor/leaflet.featuregroup.subgroup.js +0 -184
- data/app/packs/stylesheets/decidim/decidim_awesome/editors/markdown_editor.scss +0 -19
- data/app/packs/stylesheets/decidim/decidim_awesome/editors/quill_editor.scss +0 -58
- data/app/packs/stylesheets/vendor/select2-foundation-theme.scss +0 -348
- data/app/uploaders/decidim/cw/decidim_awesome/image_uploader.rb +0 -26
- data/app/views/decidim/decidim_awesome/admin/config/_form_styles.html.erb +0 -26
- data/app/views/decidim/decidim_awesome/admin/config/_modal.html.erb +0 -11
- data/app/views/decidim/proposals/admin/proposals/_form.html.erb +0 -101
- data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +0 -83
- data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +0 -1
- data/app/views/layouts/decidim/admin/_header.html.erb +0 -5
- data/app/views/layouts/decidim/admin/decidim_awesome.html.erb +0 -75
- data/app/views/v0.25/decidim/proposals/collaborative_drafts/_show.html.erb +0 -128
- data/app/views/v0.25/layouts/decidim/_head.html.erb +0 -41
- data/app/views/v0.25/layouts/decidim/admin/_header.html.erb +0 -11
- data/app/views/v0.26/decidim/proposals/collaborative_drafts/_show.html.erb +0 -128
- data/app/views/v0.26/layouts/decidim/_head.html.erb +0 -45
- data/app/views/v0.26/layouts/decidim/admin/_header.html.erb +0 -11
- data/lib/decidim/decidim_awesome/content_parsers/editor_images_parser.rb +0 -39
- data/lib/tasks/decidim_awesome_active_storage_migrations_tasks.rake +0 -37
- /data/app/models/{decidim → concerns/decidim}/decidim_awesome/user_override.rb +0 -0
@@ -1,78 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module DecidimAwesome
|
5
|
-
module Proposals
|
6
|
-
module ApplicationHelperOverride
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
|
9
|
-
included do
|
10
|
-
alias_method :decidim_text_editor_for_proposal_body, :text_editor_for_proposal_body
|
11
|
-
alias_method :decidim_safe_content?, :safe_content?
|
12
|
-
|
13
|
-
# replace safe content to consider all custom fields save (then embeded html will be rendered)
|
14
|
-
def safe_content?
|
15
|
-
awesome_proposal_custom_fields.present? || decidim_safe_content?
|
16
|
-
end
|
17
|
-
|
18
|
-
# replace normal method to draw the editor
|
19
|
-
def text_editor_for_proposal_body(form)
|
20
|
-
custom_fields = awesome_proposal_custom_fields
|
21
|
-
|
22
|
-
return decidim_text_editor_for_proposal_body(form) if custom_fields.blank?
|
23
|
-
|
24
|
-
render_proposal_custom_fields_override(custom_fields, form, :body)
|
25
|
-
end
|
26
|
-
|
27
|
-
# replace admin method to draw the editor (multi lang)
|
28
|
-
def admin_editor_for_proposal_body(form)
|
29
|
-
custom_fields = awesome_proposal_custom_fields
|
30
|
-
|
31
|
-
return form.translated(:editor, :body, hashtaggable: true) if custom_fields.blank?
|
32
|
-
|
33
|
-
locales = form.send(:locales)
|
34
|
-
|
35
|
-
return render_proposal_custom_fields_override(custom_fields, form, "body_#{locales.first}", locales.first) if locales.length == 1
|
36
|
-
|
37
|
-
tabs_id = form.send(:sanitize_tabs_selector, form.options[:tabs_id] || "#{form.object_name}-body-tabs")
|
38
|
-
|
39
|
-
label_tabs = form.content_tag(:div, class: "label--tabs") do
|
40
|
-
field_label = form.send(:label_i18n, "body", form.label_for("proposal_custom_fields"))
|
41
|
-
|
42
|
-
language_selector = "".html_safe
|
43
|
-
language_selector = form.create_language_selector(locales, tabs_id, "body") if form.options[:label] != false
|
44
|
-
|
45
|
-
safe_join [field_label, language_selector]
|
46
|
-
end
|
47
|
-
|
48
|
-
tabs_content = form.content_tag(:div, class: "tabs-content", data: { tabs_content: tabs_id }) do
|
49
|
-
locales.each_with_index.inject("".html_safe) do |string, (locale, index)|
|
50
|
-
tab_content_id = "#{tabs_id}-body-panel-#{index}"
|
51
|
-
string + content_tag(:div, class: form.send(:tab_element_class_for, "panel", index), id: tab_content_id) do
|
52
|
-
render_proposal_custom_fields_override(custom_fields, form, "body_#{locale}", locale)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
safe_join [label_tabs, tabs_content]
|
58
|
-
end
|
59
|
-
|
60
|
-
def render_proposal_custom_fields_override(fields, form, name, locale = nil)
|
61
|
-
custom_fields = Decidim::DecidimAwesome::CustomFields.new(fields)
|
62
|
-
custom_fields.translate!
|
63
|
-
|
64
|
-
body = if form_presenter.proposal.body.is_a?(Hash) && locale.present?
|
65
|
-
form_presenter.body(extras: false, all_locales: true).with_indifferent_access[locale]
|
66
|
-
else
|
67
|
-
form_presenter.body(extras: false)
|
68
|
-
end
|
69
|
-
|
70
|
-
custom_fields.apply_xml(body) if body.present?
|
71
|
-
form.object.errors.add(name, custom_fields.errors) if custom_fields.errors
|
72
|
-
render partial: "decidim/decidim_awesome/custom_fields/form_render", locals: { spec: custom_fields.to_json, form: form, name: name }
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
@@ -1,106 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module DecidimAwesome
|
5
|
-
class MigrateLegacyImagesJob < ApplicationJob
|
6
|
-
queue_as :default
|
7
|
-
|
8
|
-
def perform(organization_id, mappings = [], logger = Rails.logger)
|
9
|
-
@organization_id = organization_id
|
10
|
-
@routes_mappings = mappings
|
11
|
-
@logger = logger
|
12
|
-
|
13
|
-
migrate_all!
|
14
|
-
transform_images_urls
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
attr_reader :routes_mappings, :logger
|
20
|
-
|
21
|
-
def migrate_all!
|
22
|
-
Decidim::CarrierWaveMigratorService.migrate_attachment!(
|
23
|
-
klass: Decidim::DecidimAwesome::EditorImage,
|
24
|
-
cw_attribute: "image",
|
25
|
-
cw_uploader: Decidim::Cw::DecidimAwesome::ImageUploader,
|
26
|
-
as_attribute: "file",
|
27
|
-
logger: @logger,
|
28
|
-
routes_mappings: routes_mappings
|
29
|
-
)
|
30
|
-
end
|
31
|
-
|
32
|
-
def transform_images_urls
|
33
|
-
mappings = routes_mappings.map do |mapping|
|
34
|
-
klass, id = mapping[:instance].split("#")
|
35
|
-
next unless klass == "Decidim::DecidimAwesome::EditorImage"
|
36
|
-
|
37
|
-
instance = Decidim::DecidimAwesome::EditorImage.find_by(id: id)
|
38
|
-
|
39
|
-
next if instance.blank?
|
40
|
-
|
41
|
-
mapping.merge!(instance: instance)
|
42
|
-
end.compact
|
43
|
-
|
44
|
-
editor_images_available_attributes.each do |model, attributes|
|
45
|
-
model.all.each do |item|
|
46
|
-
attributes.each do |attribute|
|
47
|
-
item.update(attribute => rewrite_value(item.send(attribute), mappings))
|
48
|
-
end
|
49
|
-
end
|
50
|
-
@logger.info "Updated model #{model.name} (attributes: #{attributes.join(", ")})"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def rewrite_value(value, mappings)
|
55
|
-
if value.is_a?(Hash)
|
56
|
-
value.transform_values do |nested_value|
|
57
|
-
rewrite_value(nested_value, mappings)
|
58
|
-
end
|
59
|
-
else
|
60
|
-
parser = Decidim::DecidimAwesome::ContentParsers::EditorImagesParser.new(value, routes_mappings: mappings)
|
61
|
-
parser.rewrite
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def editor_images_available_attributes
|
66
|
-
{
|
67
|
-
"Decidim::Accountability::Result" => %w(description),
|
68
|
-
"Decidim::Proposals::Proposal" => %w(body answer cost_report execution_period),
|
69
|
-
"Decidim::Votings::Voting" => %w(description),
|
70
|
-
"Decidim::Elections::Question" => %w(description),
|
71
|
-
"Decidim::Elections::Answer" => %w(description),
|
72
|
-
"Decidim::Elections::Election" => %w(description),
|
73
|
-
"Decidim::Initiative" => %w(description answer),
|
74
|
-
"Decidim::InitiativesType" => %w(description extra_fields_legal_information),
|
75
|
-
"Decidim::Assembly" => %w(short_description description purpose_of_action composition internal_organisation announcement closing_date_reason special_features),
|
76
|
-
"Decidim::Forms::Questionnaire" => %w(description tos),
|
77
|
-
"Decidim::Forms::Question" => %w(description),
|
78
|
-
"Decidim::Organization" => %w(welcome_notification_body admin_terms_of_use_body description highlighted_content_banner_short_description id_documents_explanation_text),
|
79
|
-
"Decidim::StaticPage" => %w(content),
|
80
|
-
"Decidim::ContextualHelpSection" => %w(content),
|
81
|
-
"Decidim::Category" => %w(description),
|
82
|
-
"Decidim::Blogs::Post" => %w(body),
|
83
|
-
"Decidim::Pages::Page" => %w(body),
|
84
|
-
"Decidim::Sortitions::Sortition" => %w(additional_info witnesses cancel_reason),
|
85
|
-
"Decidim::Consultations::Question" => %w(title question_context what_is_decided instructions),
|
86
|
-
"Decidim::Consultation" => %w(description),
|
87
|
-
"Decidim::Debates::Debate" => %w(description instructions information_updates conclusions),
|
88
|
-
"Decidim::Budgets::Budget" => %w(description),
|
89
|
-
"Decidim::Budgets::Project" => %w(description),
|
90
|
-
"Decidim::ConferenceSpeaker" => %w(short_bio),
|
91
|
-
"Decidim::Conferences::RegistrationType" => %w(description),
|
92
|
-
"Decidim::Conference" => %w(short_description description objectives registration_terms),
|
93
|
-
"Decidim::ParticipatoryProcessGroup" => %w(description),
|
94
|
-
"Decidim::ParticipatoryProcess" => %w(short_description description announcement),
|
95
|
-
"Decidim::ParticipatoryProcessStep" => %w(description),
|
96
|
-
"Decidim::Meetings::AgendaItem" => %w(description),
|
97
|
-
"Decidim::Meetings::Meeting" => %w(registration_terms description registration_email_custom_content closing_report)
|
98
|
-
}.each_with_object({}) do |(main_model, attributes), hash|
|
99
|
-
hash[main_model.constantize] = attributes
|
100
|
-
rescue NameError
|
101
|
-
hash
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
import "src/decidim/decidim_awesome/admin/form_exit_warn"
|
Binary file
|
@@ -1,55 +0,0 @@
|
|
1
|
-
$(() => {
|
2
|
-
const $modal = $("#constraintsModal");
|
3
|
-
if (!$modal.length) {
|
4
|
-
return;
|
5
|
-
}
|
6
|
-
|
7
|
-
$(".decidim_awesome-form").on("click", ".constraints-editor .add-condition,.constraints-editor .edit-condition", (e) => {
|
8
|
-
e.preventDefault();
|
9
|
-
const $this = $(e.target)
|
10
|
-
const url = $this.attr("href");
|
11
|
-
const $callout = $this.closest(".constraints-editor").find(".callout");
|
12
|
-
$callout.hide();
|
13
|
-
$callout.removeClass("alert success");
|
14
|
-
$modal.find(".modal-content").html("");
|
15
|
-
$modal.addClass("loading");
|
16
|
-
$modal.data("url", url);
|
17
|
-
$modal.foundation("open");
|
18
|
-
$modal.find(".modal-content").load(url, () => {
|
19
|
-
$modal.removeClass("loading");
|
20
|
-
});
|
21
|
-
});
|
22
|
-
|
23
|
-
// Custom event listener to reload the modal if needed
|
24
|
-
document.body.addEventListener("constraint:change", (e) => {
|
25
|
-
const vars = e.detail.map((setting) => `${setting.key}=${setting.value}`);
|
26
|
-
const url = `${$modal.data("url")}&${vars.join("&")}`;
|
27
|
-
// console.log("constraint:change vars:", vars, "url:", url)
|
28
|
-
$modal.addClass("loading");
|
29
|
-
$modal.find(".modal-content").load(url, () => {
|
30
|
-
$modal.removeClass("loading");
|
31
|
-
});
|
32
|
-
});
|
33
|
-
|
34
|
-
// Rails AJAX events
|
35
|
-
document.body.addEventListener("ajax:error", (responseText) => {
|
36
|
-
// console.log("ajax:error", responseText)
|
37
|
-
const $container = $(`.constraints-editor[data-key="${responseText.detail[0].key}"]`)
|
38
|
-
const $callout = $container.find(".callout");
|
39
|
-
$callout.show();
|
40
|
-
$callout.contents("p").html(`${responseText.detail[0].message}: <strong>${responseText.detail[0].error}</strong>`);
|
41
|
-
$callout.addClass("alert");
|
42
|
-
});
|
43
|
-
|
44
|
-
document.body.addEventListener("ajax:success", (responseText) => {
|
45
|
-
// console.log("ajax:success", responseText)
|
46
|
-
const $container = $(`.constraints-editor[data-key="${responseText.detail[0].key}"]`)
|
47
|
-
const $callout = $container.find(".callout");
|
48
|
-
$modal.foundation("close");
|
49
|
-
$callout.show();
|
50
|
-
$callout.contents("p").html(responseText.detail[0].message);
|
51
|
-
$callout.addClass("success");
|
52
|
-
// reconstruct list
|
53
|
-
$container.replaceWith(responseText.detail[0].html);
|
54
|
-
});
|
55
|
-
});
|
@@ -1,190 +0,0 @@
|
|
1
|
-
/* eslint-disable require-jsdoc */
|
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
|
-
|
17
|
-
// In 0.26 these files come with Decidim in the folder src/decidim/vendor so the awesome one's could be removed
|
18
|
-
import "src/vendor/image-resize.min"
|
19
|
-
import "src/vendor/image-upload.min"
|
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, class_name) => (class_name.match(/(^|\s)ql-\S+/g) || []).join(" "));
|
31
|
-
$(container).removeClass((index, class_name) => (class_name.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
|
-
|
45
|
-
let quillToolbar = [
|
46
|
-
["bold", "italic", "underline", "linebreak"],
|
47
|
-
[{ list: "ordered" }, { list: "bullet" }],
|
48
|
-
["link", "clean"],
|
49
|
-
["code", "blockquote"],
|
50
|
-
[{ "indent": "-1"}, { "indent": "+1" }]
|
51
|
-
];
|
52
|
-
|
53
|
-
let addImage = false;
|
54
|
-
|
55
|
-
if (toolbar === "full") {
|
56
|
-
quillToolbar = [
|
57
|
-
[{ header: [2, 3, 4, 5, 6, false] }],
|
58
|
-
...quillToolbar
|
59
|
-
];
|
60
|
-
if (DecidimAwesome.allow_images_in_full_editor) {
|
61
|
-
quillToolbar.push(["video", "image"]);
|
62
|
-
addImage = true;
|
63
|
-
} else {
|
64
|
-
quillToolbar.push(["video"]);
|
65
|
-
}
|
66
|
-
} else if (toolbar === "basic") {
|
67
|
-
if (DecidimAwesome.allow_images_in_small_editor) {
|
68
|
-
quillToolbar.push(["video", "image"]);
|
69
|
-
addImage = true;
|
70
|
-
} else {
|
71
|
-
quillToolbar.push(["video"]);
|
72
|
-
}
|
73
|
-
} else if (DecidimAwesome.allow_images_in_small_editor) {
|
74
|
-
quillToolbar.push(["image"]);
|
75
|
-
addImage = true;
|
76
|
-
}
|
77
|
-
|
78
|
-
let modules = {
|
79
|
-
linebreak: {},
|
80
|
-
toolbar: {
|
81
|
-
container: quillToolbar,
|
82
|
-
handlers: {
|
83
|
-
"linebreak": lineBreakButtonHandler
|
84
|
-
}
|
85
|
-
}
|
86
|
-
};
|
87
|
-
const $input = $(container).siblings('input[type="hidden"]');
|
88
|
-
container.innerHTML = $input.val() || "";
|
89
|
-
const token = $('meta[name="csrf-token"]').attr("content");
|
90
|
-
if (addImage) {
|
91
|
-
modules.imageResize = {
|
92
|
-
modules: ["Resize", "DisplaySize"]
|
93
|
-
}
|
94
|
-
modules.imageUpload = {
|
95
|
-
url: $(container).data("uploadImagesPath") || DecidimAwesome.editor_uploader_path,
|
96
|
-
method: "POST",
|
97
|
-
name: "image",
|
98
|
-
withCredentials: false,
|
99
|
-
headers: { "X-CSRF-Token": token },
|
100
|
-
callbackOK: (serverResponse, next) => {
|
101
|
-
$("div.ql-toolbar").last().removeClass("editor-loading")
|
102
|
-
next(serverResponse.url);
|
103
|
-
},
|
104
|
-
callbackKO: (serverError) => {
|
105
|
-
$("div.ql-toolbar").last().removeClass("editor-loading")
|
106
|
-
console.error(`Image upload error: ${serverError.message}`);
|
107
|
-
},
|
108
|
-
checkBeforeSend: (file, next) => {
|
109
|
-
$("div.ql-toolbar").last().addClass("editor-loading")
|
110
|
-
next(file);
|
111
|
-
}
|
112
|
-
}
|
113
|
-
}
|
114
|
-
const quill = new Quill(container, {
|
115
|
-
modules: modules,
|
116
|
-
formats: quillFormats,
|
117
|
-
theme: "snow"
|
118
|
-
});
|
119
|
-
|
120
|
-
if (disabled) {
|
121
|
-
quill.disable();
|
122
|
-
}
|
123
|
-
|
124
|
-
quill.on("text-change", () => {
|
125
|
-
const text = quill.getText();
|
126
|
-
|
127
|
-
// Triggers CustomEvent with the cursor position
|
128
|
-
// It is required in input_mentions.js
|
129
|
-
let event = new CustomEvent("quill-position", {
|
130
|
-
detail: quill.getSelection()
|
131
|
-
});
|
132
|
-
container.dispatchEvent(event);
|
133
|
-
|
134
|
-
if (text === "\n" || text === "\n\n") {
|
135
|
-
$input.val("");
|
136
|
-
} else {
|
137
|
-
$input.val(quill.root.innerHTML);
|
138
|
-
}
|
139
|
-
});
|
140
|
-
// After editor is ready, linebreak_module deletes two extraneous new lines
|
141
|
-
quill.emitter.emit("editor-ready");
|
142
|
-
|
143
|
-
if (addImage) {
|
144
|
-
const text = $(container).data("dragAndDropHelpText") || DecidimAwesome.texts.drag_and_drop_image;
|
145
|
-
$(container).after(`<p class="help-text" style="margin-top:-1.5rem;">${text}</p>`);
|
146
|
-
}
|
147
|
-
|
148
|
-
// After editor is ready, linebreak_module deletes two extraneous new lines
|
149
|
-
quill.emitter.emit("editor-ready");
|
150
|
-
|
151
|
-
return quill;
|
152
|
-
}
|
153
|
-
|
154
|
-
export function createMarkdownEditor(container) {
|
155
|
-
const t = DecidimAwesome.texts.drag_and_drop_image;
|
156
|
-
const token = $('meta[name="csrf-token"]').attr("content");
|
157
|
-
const $input = $(container).siblings('input[type="hidden"]');
|
158
|
-
const $faker = $('<textarea name="faker-inscrybmde"/>');
|
159
|
-
const $form = $(container).closest("form");
|
160
|
-
const europa = new Europa();
|
161
|
-
$faker.val(europa.convert($input.val()));
|
162
|
-
$faker.insertBefore($(container));
|
163
|
-
$(container).hide();
|
164
|
-
const inscrybmde = new InscrybMDE({
|
165
|
-
element: $faker[0],
|
166
|
-
spellChecker: false,
|
167
|
-
renderingConfig: {
|
168
|
-
codeSyntaxHighlighting: true,
|
169
|
-
hljs: hljs
|
170
|
-
}
|
171
|
-
});
|
172
|
-
$faker[0].InscrybMDE = inscrybmde;
|
173
|
-
|
174
|
-
// Allow image upload
|
175
|
-
if (DecidimAwesome.allow_images_in_markdown_editor) {
|
176
|
-
$(inscrybmde.gui.statusbar).prepend(`<span class="help-text" style="float:left;margin:0;text-align:left;">${t}</span>`);
|
177
|
-
inlineAttachment.editors.codemirror4.attach(inscrybmde.codemirror, {
|
178
|
-
uploadUrl: DecidimAwesome.editor_uploader_path,
|
179
|
-
uploadFieldName: "image",
|
180
|
-
jsonFieldName: "url",
|
181
|
-
extraHeaders: { "X-CSRF-Token": token }
|
182
|
-
});
|
183
|
-
}
|
184
|
-
|
185
|
-
// convert to html on submit
|
186
|
-
$form.on("submit", () => {
|
187
|
-
// e.preventDefault();
|
188
|
-
$input.val(inscrybmde.markdown(inscrybmde.value()));
|
189
|
-
});
|
190
|
-
}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* When switching tabs in i18n fields, autofocus on the markdown if exists
|
3
|
-
*/
|
4
|
-
$(() => {
|
5
|
-
// Event launched by foundation
|
6
|
-
$("[data-tabs]").on("change.zf.tabs", (event) => {
|
7
|
-
const $container = $(event.target).closest(".label--tabs").next(".tabs-content").find(".tabs-panel.is-active");
|
8
|
-
// fix inscrybmde if present
|
9
|
-
let $input = $container.find('[name="faker-inscrybmde"]');
|
10
|
-
if ($input.length > 0) {
|
11
|
-
$input[0].InscrybMDE.codemirror.refresh();
|
12
|
-
}
|
13
|
-
// fix custom fields if present
|
14
|
-
$input = $container.find(".proposal_custom_field:first");
|
15
|
-
if ($input.length > 0) {
|
16
|
-
// saves current data to the hidden field for the lang
|
17
|
-
window.DecidimAwesome.CustomFieldsRenderer.storeData();
|
18
|
-
// init the current language
|
19
|
-
window.DecidimAwesome.CustomFieldsRenderer.init($input);
|
20
|
-
}
|
21
|
-
});
|
22
|
-
});
|
@@ -1 +0,0 @@
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ImageResize=e():t.ImageResize=e()}(this,function(){return function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=38)}([function(t,e){function n(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}t.exports=n},function(t,e,n){var o=n(22),r="object"==typeof self&&self&&self.Object===Object&&self,i=o||r||Function("return this")();t.exports=i},function(t,e){function n(t){return null!=t&&"object"==typeof t}t.exports=n},function(t,e,n){function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}var r=n(75),i=n(76),a=n(77),s=n(78),u=n(79);o.prototype.clear=r,o.prototype.delete=i,o.prototype.get=a,o.prototype.has=s,o.prototype.set=u,t.exports=o},function(t,e,n){function o(t,e){for(var n=t.length;n--;)if(r(t[n][0],e))return n;return-1}var r=n(8);t.exports=o},function(t,e,n){function o(t){return null==t?void 0===t?u:s:c&&c in Object(t)?i(t):a(t)}var r=n(16),i=n(64),a=n(87),s="[object Null]",u="[object Undefined]",c=r?r.toStringTag:void 0;t.exports=o},function(t,e,n){function o(t,e){var n=t.__data__;return r(e)?n["string"==typeof e?"string":"hash"]:n.map}var r=n(73);t.exports=o},function(t,e,n){var o=n(11),r=o(Object,"create");t.exports=r},function(t,e){function n(t,e){return t===e||t!==t&&e!==e}t.exports=n},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}n.d(e,"a",function(){return r});var r=function t(e){o(this,t),this.onCreate=function(){},this.onDestroy=function(){},this.onUpdate=function(){},this.overlay=e.overlay,this.img=e.img,this.options=e.options,this.requestUpdate=e.onUpdate}},function(t,e,n){function o(t,e,n){"__proto__"==e&&r?r(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var r=n(21);t.exports=o},function(t,e,n){function o(t,e){var n=i(t,e);return r(n)?n:void 0}var r=n(48),i=n(65);t.exports=o},function(t,e,n){function o(t){return null!=t&&i(t.length)&&!r(t)}var r=n(13),i=n(30);t.exports=o},function(t,e,n){function o(t){if(!i(t))return!1;var e=r(t);return e==s||e==u||e==a||e==c}var r=n(5),i=n(0),a="[object AsyncFunction]",s="[object Function]",u="[object GeneratorFunction]",c="[object Proxy]";t.exports=o},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,n){var o=n(11),r=n(1),i=o(r,"Map");t.exports=i},function(t,e,n){var o=n(1),r=o.Symbol;t.exports=r},function(t,e){function n(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}t.exports=n},function(t,e,n){function o(t,e,n){(void 0===n||i(t[e],n))&&(void 0!==n||e in t)||r(t,e,n)}var r=n(10),i=n(8);t.exports=o},function(t,e,n){function o(t,e,n,l,f){t!==e&&a(e,function(a,c){if(u(a))f||(f=new r),s(t,e,c,n,o,l,f);else{var p=l?l(t[c],a,c+"",t,e,f):void 0;void 0===p&&(p=a),i(t,c,p)}},c)}var r=n(41),i=n(18),a=n(46),s=n(51),u=n(0),c=n(32);t.exports=o},function(t,e,n){function o(t,e){return a(i(t,e,r),t+"")}var r=n(26),i=n(89),a=n(90);t.exports=o},function(t,e,n){var o=n(11),r=function(){try{var t=o(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();t.exports=r},function(t,e,n){(function(e){var n="object"==typeof e&&e&&e.Object===Object&&e;t.exports=n}).call(e,n(107))},function(t,e,n){var o=n(88),r=o(Object.getPrototypeOf,Object);t.exports=r},function(t,e){function n(t,e){return!!(e=null==e?o:e)&&("number"==typeof t||r.test(t))&&t>-1&&t%1==0&&t<e}var o=9007199254740991,r=/^(?:0|[1-9]\d*)$/;t.exports=n},function(t,e){function n(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||o)}var o=Object.prototype;t.exports=n},function(t,e){function n(t){return t}t.exports=n},function(t,e,n){var o=n(47),r=n(2),i=Object.prototype,a=i.hasOwnProperty,s=i.propertyIsEnumerable,u=o(function(){return arguments}())?o:function(t){return r(t)&&a.call(t,"callee")&&!s.call(t,"callee")};t.exports=u},function(t,e){var n=Array.isArray;t.exports=n},function(t,e,n){(function(t){var o=n(1),r=n(102),i="object"==typeof e&&e&&!e.nodeType&&e,a=i&&"object"==typeof t&&t&&!t.nodeType&&t,s=a&&a.exports===i,u=s?o.Buffer:void 0,c=u?u.isBuffer:void 0,l=c||r;t.exports=l}).call(e,n(14)(t))},function(t,e){function n(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=o}var o=9007199254740991;t.exports=n},function(t,e,n){var o=n(49),r=n(54),i=n(86),a=i&&i.isTypedArray,s=a?r(a):o;t.exports=s},function(t,e,n){function o(t){return a(t)?r(t,!0):i(t)}var r=n(43),i=n(50),a=n(12);t.exports=o},function(t,e,n){"use strict";e.a={modules:["DisplaySize","Toolbar","Resize"],overlayStyles:{position:"absolute",boxSizing:"border-box",border:"1px dashed #444"},handleStyles:{position:"absolute",height:"12px",width:"12px",backgroundColor:"white",border:"1px solid #777",boxSizing:"border-box",opacity:"0.80"},displayStyles:{position:"absolute",font:"12px/1.0 Arial, Helvetica, sans-serif",padding:"4px 8px",textAlign:"center",backgroundColor:"white",color:"#333",border:"1px solid #777",boxSizing:"border-box",opacity:"0.80",cursor:"default"},toolbarStyles:{position:"absolute",top:"-12px",right:"0",left:"0",height:"0",minWidth:"100px",font:"12px/1.0 Arial, Helvetica, sans-serif",textAlign:"center",color:"#333",boxSizing:"border-box",cursor:"default"},toolbarButtonStyles:{display:"inline-block",width:"24px",height:"24px",background:"white",border:"1px solid #999",verticalAlign:"middle"},toolbarButtonSvgStyles:{fill:"#444",stroke:"#444",strokeWidth:"2"}}},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=n(9);n.d(e,"a",function(){return s});var s=function(t){function e(){var t,n,i,a;o(this,e);for(var s=arguments.length,u=Array(s),c=0;c<s;c++)u[c]=arguments[c];return n=i=r(this,(t=e.__proto__||Object.getPrototypeOf(e)).call.apply(t,[this].concat(u))),i.onCreate=function(){i.display=document.createElement("div"),Object.assign(i.display.style,i.options.displayStyles),i.overlay.appendChild(i.display)},i.onDestroy=function(){},i.onUpdate=function(){if(i.display&&i.img){var t=i.getCurrentSize();if(i.display.innerHTML=t.join(" × "),t[0]>120&&t[1]>30)Object.assign(i.display.style,{right:"4px",bottom:"4px",left:"auto"});else if("right"==i.img.style.float){var e=i.display.getBoundingClientRect();Object.assign(i.display.style,{right:"auto",bottom:"-"+(e.height+4)+"px",left:"-"+(e.width+4)+"px"})}else{var n=i.display.getBoundingClientRect();Object.assign(i.display.style,{right:"-"+(n.width+4)+"px",bottom:"-"+(n.height+4)+"px",left:"auto"})}}},i.getCurrentSize=function(){return[i.img.width,Math.round(i.img.width/i.img.naturalWidth*i.img.naturalHeight)]},a=n,r(i,a)}return i(e,t),e}(a.a)},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=n(9);n.d(e,"a",function(){return s});var s=function(t){function e(){var t,n,i,a;o(this,e);for(var s=arguments.length,u=Array(s),c=0;c<s;c++)u[c]=arguments[c];return n=i=r(this,(t=e.__proto__||Object.getPrototypeOf(e)).call.apply(t,[this].concat(u))),i.onCreate=function(){i.boxes=[],i.addBox("nwse-resize"),i.addBox("nesw-resize"),i.addBox("nwse-resize"),i.addBox("nesw-resize"),i.positionBoxes()},i.onDestroy=function(){i.setCursor("")},i.positionBoxes=function(){var t=-parseFloat(i.options.handleStyles.width)/2+"px",e=-parseFloat(i.options.handleStyles.height)/2+"px";[{left:t,top:e},{right:t,top:e},{right:t,bottom:e},{left:t,bottom:e}].forEach(function(t,e){Object.assign(i.boxes[e].style,t)})},i.addBox=function(t){var e=document.createElement("div");Object.assign(e.style,i.options.handleStyles),e.style.cursor=t,e.style.width=i.options.handleStyles.width+"px",e.style.height=i.options.handleStyles.height+"px",e.addEventListener("mousedown",i.handleMousedown,!1),i.overlay.appendChild(e),i.boxes.push(e)},i.handleMousedown=function(t){i.dragBox=t.target,i.dragStartX=t.clientX,i.preDragWidth=i.img.width||i.img.naturalWidth,i.setCursor(i.dragBox.style.cursor),document.addEventListener("mousemove",i.handleDrag,!1),document.addEventListener("mouseup",i.handleMouseup,!1)},i.handleMouseup=function(){i.setCursor(""),document.removeEventListener("mousemove",i.handleDrag),document.removeEventListener("mouseup",i.handleMouseup)},i.handleDrag=function(t){if(i.img){var e=t.clientX-i.dragStartX;i.dragBox===i.boxes[0]||i.dragBox===i.boxes[3]?i.img.width=Math.round(i.preDragWidth-e):i.img.width=Math.round(i.preDragWidth+e),i.requestUpdate()}},i.setCursor=function(t){[document.body,i.img].forEach(function(e){e.style.cursor=t})},a=n,r(i,a)}return i(e,t),e}(a.a)},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=n(105),s=n.n(a),u=n(104),c=n.n(u),l=n(106),f=n.n(l),p=n(9);n.d(e,"a",function(){return b});var d=window.Quill.imports.parchment,h=new d.Attributor.Style("float","float"),y=new d.Attributor.Style("margin","margin"),v=new d.Attributor.Style("display","display"),b=function(t){function e(){var t,n,i,a;o(this,e);for(var u=arguments.length,l=Array(u),p=0;p<u;p++)l[p]=arguments[p];return n=i=r(this,(t=e.__proto__||Object.getPrototypeOf(e)).call.apply(t,[this].concat(l))),i.onCreate=function(){i.toolbar=document.createElement("div"),Object.assign(i.toolbar.style,i.options.toolbarStyles),i.overlay.appendChild(i.toolbar),i._defineAlignments(),i._addToolbarButtons()},i.onDestroy=function(){},i.onUpdate=function(){},i._defineAlignments=function(){i.alignments=[{icon:s.a,apply:function(){v.add(i.img,"inline"),h.add(i.img,"left"),y.add(i.img,"0 1em 1em 0")},isApplied:function(){return"left"==h.value(i.img)}},{icon:c.a,apply:function(){v.add(i.img,"block"),h.remove(i.img),y.add(i.img,"auto")},isApplied:function(){return"auto"==y.value(i.img)}},{icon:f.a,apply:function(){v.add(i.img,"inline"),h.add(i.img,"right"),y.add(i.img,"0 0 1em 1em")},isApplied:function(){return"right"==h.value(i.img)}}]},i._addToolbarButtons=function(){var t=[];i.alignments.forEach(function(e,n){var o=document.createElement("span");t.push(o),o.innerHTML=e.icon,o.addEventListener("click",function(){t.forEach(function(t){return t.style.filter=""}),e.isApplied()?(h.remove(i.img),y.remove(i.img),v.remove(i.img)):(i._selectButton(o),e.apply()),i.requestUpdate()}),Object.assign(o.style,i.options.toolbarButtonStyles),n>0&&(o.style.borderLeftWidth="0"),Object.assign(o.children[0].style,i.options.toolbarButtonSvgStyles),e.isApplied()&&i._selectButton(o),i.toolbar.appendChild(o)})},i._selectButton=function(t){t.style.filter="invert(20%)"},a=n,r(i,a)}return i(e,t),e}(p.a)},function(t,e,n){var o=n(17),r=n(20),i=n(63),a=n(101),s=r(function(t){return t.push(void 0,i),o(a,void 0,t)});t.exports=s},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var r=n(37),i=n.n(r),a=n(33),s=n(34),u=n(36),c=n(35),l={DisplaySize:s.a,Toolbar:u.a,Resize:c.a},f=function t(e){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o(this,t),this.initializeModules=function(){n.removeModules(),n.modules=n.moduleClasses.map(function(t){return new(l[t]||t)(n)}),n.modules.forEach(function(t){t.onCreate()}),n.onUpdate()},this.onUpdate=function(){n.repositionElements(),n.modules.forEach(function(t){t.onUpdate()})},this.removeModules=function(){n.modules.forEach(function(t){t.onDestroy()}),n.modules=[]},this.handleClick=function(t){if(t.target&&t.target.tagName&&"IMG"===t.target.tagName.toUpperCase()){if(n.img===t.target)return;n.img&&n.hide(),n.show(t.target)}else n.img&&n.hide()},this.show=function(t){n.img=t,n.showOverlay(),n.initializeModules()},this.showOverlay=function(){n.overlay&&n.hideOverlay(),n.quill.setSelection(null),n.setUserSelect("none"),document.addEventListener("keyup",n.checkImage,!0),n.quill.root.addEventListener("input",n.checkImage,!0),n.overlay=document.createElement("div"),Object.assign(n.overlay.style,n.options.overlayStyles),n.quill.root.parentNode.appendChild(n.overlay),n.repositionElements()},this.hideOverlay=function(){n.overlay&&(n.quill.root.parentNode.removeChild(n.overlay),n.overlay=void 0,document.removeEventListener("keyup",n.checkImage),n.quill.root.removeEventListener("input",n.checkImage),n.setUserSelect(""))},this.repositionElements=function(){if(n.overlay&&n.img){var t=n.quill.root.parentNode,e=n.img.getBoundingClientRect(),o=t.getBoundingClientRect();Object.assign(n.overlay.style,{left:e.left-o.left-1+t.scrollLeft+"px",top:e.top-o.top+t.scrollTop+"px",width:e.width+"px",height:e.height+"px"})}},this.hide=function(){n.hideOverlay(),n.removeModules(),n.img=void 0},this.setUserSelect=function(t){["userSelect","mozUserSelect","webkitUserSelect","msUserSelect"].forEach(function(e){n.quill.root.style[e]=t,document.documentElement.style[e]=t})},this.checkImage=function(t){n.img&&(46!=t.keyCode&&8!=t.keyCode||window.Quill.find(n.img).deleteAt(0),n.hide())},this.quill=e;var s=!1;r.modules&&(s=r.modules.slice()),this.options=i()({},r,a.a),s!==!1&&(this.options.modules=s),document.execCommand("enableObjectResizing",!1,"false"),this.quill.root.addEventListener("click",this.handleClick,!1),this.quill.root.parentNode.style.position=this.quill.root.parentNode.style.position||"relative",this.moduleClasses=this.options.modules,this.modules=[]};e.default=f,window.Quill&&window.Quill.register("modules/imageResize",f)},function(t,e,n){function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}var r=n(66),i=n(67),a=n(68),s=n(69),u=n(70);o.prototype.clear=r,o.prototype.delete=i,o.prototype.get=a,o.prototype.has=s,o.prototype.set=u,t.exports=o},function(t,e,n){function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}var r=n(80),i=n(81),a=n(82),s=n(83),u=n(84);o.prototype.clear=r,o.prototype.delete=i,o.prototype.get=a,o.prototype.has=s,o.prototype.set=u,t.exports=o},function(t,e,n){function o(t){var e=this.__data__=new r(t);this.size=e.size}var r=n(3),i=n(92),a=n(93),s=n(94),u=n(95),c=n(96);o.prototype.clear=i,o.prototype.delete=a,o.prototype.get=s,o.prototype.has=u,o.prototype.set=c,t.exports=o},function(t,e,n){var o=n(1),r=o.Uint8Array;t.exports=r},function(t,e,n){function o(t,e){var n=a(t),o=!n&&i(t),l=!n&&!o&&s(t),p=!n&&!o&&!l&&c(t),d=n||o||l||p,h=d?r(t.length,String):[],y=h.length;for(var v in t)!e&&!f.call(t,v)||d&&("length"==v||l&&("offset"==v||"parent"==v)||p&&("buffer"==v||"byteLength"==v||"byteOffset"==v)||u(v,y))||h.push(v);return h}var r=n(53),i=n(27),a=n(28),s=n(29),u=n(24),c=n(31),l=Object.prototype,f=l.hasOwnProperty;t.exports=o},function(t,e,n){function o(t,e,n){var o=t[e];s.call(t,e)&&i(o,n)&&(void 0!==n||e in t)||r(t,e,n)}var r=n(10),i=n(8),a=Object.prototype,s=a.hasOwnProperty;t.exports=o},function(t,e,n){var o=n(0),r=Object.create,i=function(){function t(){}return function(e){if(!o(e))return{};if(r)return r(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();t.exports=i},function(t,e,n){var o=n(62),r=o();t.exports=r},function(t,e,n){function o(t){return i(t)&&r(t)==a}var r=n(5),i=n(2),a="[object Arguments]";t.exports=o},function(t,e,n){function o(t){return!(!a(t)||i(t))&&(r(t)?d:u).test(s(t))}var r=n(13),i=n(74),a=n(0),s=n(97),u=/^\[object .+?Constructor\]$/,c=Function.prototype,l=Object.prototype,f=c.toString,p=l.hasOwnProperty,d=RegExp("^"+f.call(p).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");t.exports=o},function(t,e,n){function o(t){return a(t)&&i(t.length)&&!!s[r(t)]}var r=n(5),i=n(30),a=n(2),s={};s["[object Float32Array]"]=s["[object Float64Array]"]=s["[object Int8Array]"]=s["[object Int16Array]"]=s["[object Int32Array]"]=s["[object Uint8Array]"]=s["[object Uint8ClampedArray]"]=s["[object Uint16Array]"]=s["[object Uint32Array]"]=!0,s["[object Arguments]"]=s["[object Array]"]=s["[object ArrayBuffer]"]=s["[object Boolean]"]=s["[object DataView]"]=s["[object Date]"]=s["[object Error]"]=s["[object Function]"]=s["[object Map]"]=s["[object Number]"]=s["[object Object]"]=s["[object RegExp]"]=s["[object Set]"]=s["[object String]"]=s["[object WeakMap]"]=!1,t.exports=o},function(t,e,n){function o(t){if(!r(t))return a(t);var e=i(t),n=[];for(var o in t)("constructor"!=o||!e&&u.call(t,o))&&n.push(o);return n}var r=n(0),i=n(25),a=n(85),s=Object.prototype,u=s.hasOwnProperty;t.exports=o},function(t,e,n){function o(t,e,n,o,g,x,m){var _=t[n],j=e[n],w=m.get(j);if(w)return void r(t,n,w);var O=x?x(_,j,n+"",t,e,m):void 0,S=void 0===O;if(S){var E=l(j),A=!E&&p(j),z=!E&&!A&&v(j);O=j,E||A||z?l(_)?O=_:f(_)?O=s(_):A?(S=!1,O=i(j,!0)):z?(S=!1,O=a(j,!0)):O=[]:y(j)||c(j)?(O=_,c(_)?O=b(_):(!h(_)||o&&d(_))&&(O=u(j))):S=!1}S&&(m.set(j,O),g(O,j,o,x,m),m.delete(j)),r(t,n,O)}var r=n(18),i=n(56),a=n(57),s=n(58),u=n(71),c=n(27),l=n(28),f=n(99),p=n(29),d=n(13),h=n(0),y=n(100),v=n(31),b=n(103);t.exports=o},function(t,e,n){var o=n(98),r=n(21),i=n(26),a=r?function(t,e){return r(t,"toString",{configurable:!0,enumerable:!1,value:o(e),writable:!0})}:i;t.exports=a},function(t,e){function n(t,e){for(var n=-1,o=Array(t);++n<t;)o[n]=e(n);return o}t.exports=n},function(t,e){function n(t){return function(e){return t(e)}}t.exports=n},function(t,e,n){function o(t){var e=new t.constructor(t.byteLength);return new r(e).set(new r(t)),e}var r=n(42);t.exports=o},function(t,e,n){(function(t){function o(t,e){if(e)return t.slice();var n=t.length,o=c?c(n):new t.constructor(n);return t.copy(o),o}var r=n(1),i="object"==typeof e&&e&&!e.nodeType&&e,a=i&&"object"==typeof t&&t&&!t.nodeType&&t,s=a&&a.exports===i,u=s?r.Buffer:void 0,c=u?u.allocUnsafe:void 0;t.exports=o}).call(e,n(14)(t))},function(t,e,n){function o(t,e){var n=e?r(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}var r=n(55);t.exports=o},function(t,e){function n(t,e){var n=-1,o=t.length;for(e||(e=Array(o));++n<o;)e[n]=t[n];return e}t.exports=n},function(t,e,n){function o(t,e,n,o){var a=!n;n||(n={});for(var s=-1,u=e.length;++s<u;){var c=e[s],l=o?o(n[c],t[c],c,n,t):void 0;void 0===l&&(l=t[c]),a?i(n,c,l):r(n,c,l)}return n}var r=n(44),i=n(10);t.exports=o},function(t,e,n){var o=n(1),r=o["__core-js_shared__"];t.exports=r},function(t,e,n){function o(t){return r(function(e,n){var o=-1,r=n.length,a=r>1?n[r-1]:void 0,s=r>2?n[2]:void 0;for(a=t.length>3&&"function"==typeof a?(r--,a):void 0,s&&i(n[0],n[1],s)&&(a=r<3?void 0:a,r=1),e=Object(e);++o<r;){var u=n[o];u&&t(e,u,o,a)}return e})}var r=n(20),i=n(72);t.exports=o},function(t,e){function n(t){return function(e,n,o){for(var r=-1,i=Object(e),a=o(e),s=a.length;s--;){var u=a[t?s:++r];if(n(i[u],u,i)===!1)break}return e}}t.exports=n},function(t,e,n){function o(t,e,n,a,s,u){return i(t)&&i(e)&&(u.set(e,t),r(t,e,void 0,o,u),u.delete(e)),t}var r=n(19),i=n(0);t.exports=o},function(t,e,n){function o(t){var e=a.call(t,u),n=t[u];try{t[u]=void 0}catch(t){}var o=s.call(t);return e?t[u]=n:delete t[u],o}var r=n(16),i=Object.prototype,a=i.hasOwnProperty,s=i.toString,u=r?r.toStringTag:void 0;t.exports=o},function(t,e){function n(t,e){return null==t?void 0:t[e]}t.exports=n},function(t,e,n){function o(){this.__data__=r?r(null):{},this.size=0}var r=n(7);t.exports=o},function(t,e){function n(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}t.exports=n},function(t,e,n){function o(t){var e=this.__data__;if(r){var n=e[t];return n===i?void 0:n}return s.call(e,t)?e[t]:void 0}var r=n(7),i="__lodash_hash_undefined__",a=Object.prototype,s=a.hasOwnProperty;t.exports=o},function(t,e,n){function o(t){var e=this.__data__;return r?void 0!==e[t]:a.call(e,t)}var r=n(7),i=Object.prototype,a=i.hasOwnProperty;t.exports=o},function(t,e,n){function o(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=r&&void 0===e?i:e,this}var r=n(7),i="__lodash_hash_undefined__";t.exports=o},function(t,e,n){function o(t){return"function"!=typeof t.constructor||a(t)?{}:r(i(t))}var r=n(45),i=n(23),a=n(25);t.exports=o},function(t,e,n){function o(t,e,n){if(!s(n))return!1;var o=typeof e;return!!("number"==o?i(n)&&a(e,n.length):"string"==o&&e in n)&&r(n[e],t)}var r=n(8),i=n(12),a=n(24),s=n(0);t.exports=o},function(t,e){function n(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}t.exports=n},function(t,e,n){function o(t){return!!i&&i in t}var r=n(60),i=function(){var t=/[^.]+$/.exec(r&&r.keys&&r.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();t.exports=o},function(t,e){function n(){this.__data__=[],this.size=0}t.exports=n},function(t,e,n){function o(t){var e=this.__data__,n=r(e,t);return!(n<0)&&(n==e.length-1?e.pop():a.call(e,n,1),--this.size,!0)}var r=n(4),i=Array.prototype,a=i.splice;t.exports=o},function(t,e,n){function o(t){var e=this.__data__,n=r(e,t);return n<0?void 0:e[n][1]}var r=n(4);t.exports=o},function(t,e,n){function o(t){return r(this.__data__,t)>-1}var r=n(4);t.exports=o},function(t,e,n){function o(t,e){var n=this.__data__,o=r(n,t);return o<0?(++this.size,n.push([t,e])):n[o][1]=e,this}var r=n(4);t.exports=o},function(t,e,n){function o(){this.size=0,this.__data__={hash:new r,map:new(a||i),string:new r}}var r=n(39),i=n(3),a=n(15);t.exports=o},function(t,e,n){function o(t){var e=r(this,t).delete(t);return this.size-=e?1:0,e}var r=n(6);t.exports=o},function(t,e,n){function o(t){return r(this,t).get(t)}var r=n(6);t.exports=o},function(t,e,n){function o(t){return r(this,t).has(t)}var r=n(6);t.exports=o},function(t,e,n){function o(t,e){var n=r(this,t),o=n.size;return n.set(t,e),this.size+=n.size==o?0:1,this}var r=n(6);t.exports=o},function(t,e){function n(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}t.exports=n},function(t,e,n){(function(t){var o=n(22),r="object"==typeof e&&e&&!e.nodeType&&e,i=r&&"object"==typeof t&&t&&!t.nodeType&&t,a=i&&i.exports===r,s=a&&o.process,u=function(){try{return s&&s.binding&&s.binding("util")}catch(t){}}();t.exports=u}).call(e,n(14)(t))},function(t,e){function n(t){return r.call(t)}var o=Object.prototype,r=o.toString;t.exports=n},function(t,e){function n(t,e){return function(n){return t(e(n))}}t.exports=n},function(t,e,n){function o(t,e,n){return e=i(void 0===e?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=i(o.length-e,0),u=Array(s);++a<s;)u[a]=o[e+a];a=-1;for(var c=Array(e+1);++a<e;)c[a]=o[a];return c[e]=n(u),r(t,this,c)}}var r=n(17),i=Math.max;t.exports=o},function(t,e,n){var o=n(52),r=n(91),i=r(o);t.exports=i},function(t,e){function n(t){var e=0,n=0;return function(){var a=i(),s=r-(a-n);if(n=a,s>0){if(++e>=o)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var o=800,r=16,i=Date.now;t.exports=n},function(t,e,n){function o(){this.__data__=new r,this.size=0}var r=n(3);t.exports=o},function(t,e){function n(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}t.exports=n},function(t,e){function n(t){return this.__data__.get(t)}t.exports=n},function(t,e){function n(t){return this.__data__.has(t)}t.exports=n},function(t,e,n){function o(t,e){var n=this.__data__;if(n instanceof r){var o=n.__data__;if(!i||o.length<s-1)return o.push([t,e]),this.size=++n.size,this;n=this.__data__=new a(o)}return n.set(t,e),this.size=n.size,this}var r=n(3),i=n(15),a=n(40),s=200;t.exports=o},function(t,e){function n(t){if(null!=t){try{return r.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var o=Function.prototype,r=o.toString;t.exports=n},function(t,e){function n(t){return function(){return t}}t.exports=n},function(t,e,n){function o(t){return i(t)&&r(t)}var r=n(12),i=n(2);t.exports=o},function(t,e,n){function o(t){if(!a(t)||r(t)!=s)return!1;var e=i(t);if(null===e)return!0;var n=f.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&l.call(n)==p}var r=n(5),i=n(23),a=n(2),s="[object Object]",u=Function.prototype,c=Object.prototype,l=u.toString,f=c.hasOwnProperty,p=l.call(Object);t.exports=o},function(t,e,n){var o=n(19),r=n(61),i=r(function(t,e,n,r){o(t,e,n,r)});t.exports=i},function(t,e){function n(){return!1}t.exports=n},function(t,e,n){function o(t){return r(t,i(t))}var r=n(59),i=n(32);t.exports=o},function(t,e){t.exports='<svg viewbox="0 0 18 18">\n <line class="ql-stroke" x1="15" x2="3" y1="9" y2="9"></line>\n <line class="ql-stroke" x1="14" x2="4" y1="14" y2="14"></line>\n <line class="ql-stroke" x1="12" x2="6" y1="4" y2="4"></line>\n</svg>'},function(t,e){t.exports='<svg viewbox="0 0 18 18">\n <line class="ql-stroke" x1="3" x2="15" y1="9" y2="9"></line>\n <line class="ql-stroke" x1="3" x2="13" y1="14" y2="14"></line>\n <line class="ql-stroke" x1="3" x2="9" y1="4" y2="4"></line>\n</svg>'},function(t,e){t.exports='<svg viewbox="0 0 18 18">\n <line class="ql-stroke" x1="15" x2="3" y1="9" y2="9"></line>\n <line class="ql-stroke" x1="15" x2="5" y1="14" y2="14"></line>\n <line class="ql-stroke" x1="15" x2="9" y1="4" y2="4"></line>\n</svg>'},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n}])});
|
@@ -1,6 +0,0 @@
|
|
1
|
-
/* Origin: https://github.com/Platoniq/quill-image-upload */
|
2
|
-
(function () {
|
3
|
-
var exports = {};
|
4
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function e(e,t){for(var a=0;a<t.length;a++){var i=t[a];i.enumerable=i.enumerable||false;i.configurable=true;if("value"in i)i.writable=true;Object.defineProperty(e,i.key,i)}}return function(t,a,i){if(a)e(t.prototype,a);if(i)e(t,i);return t}}();function _classCallCheck(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}var ImageUpload=exports.ImageUpload=function(){function e(t){var a=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,e);this.quill=t;this.options=a;this.quill.getModule("toolbar").addHandler("image",this.selectLocalImage.bind(this));this.handleDrop=this.handleDrop.bind(this);this.handlePaste=this.handlePaste.bind(this);this.quill.root.addEventListener("drop",this.handleDrop,false);this.quill.root.addEventListener("paste",this.handlePaste,false)}_createClass(e,[{key:"selectLocalImage",value:function e(){var t=this;var a=document.createElement("input");a.setAttribute("type","file");a.click();a.onchange=function(){var e=a.files[0];if(/^image\//.test(e.type)){var i=t.options.checkBeforeSend||t.checkBeforeSend.bind(t);i(e,t.sendToServer.bind(t))}else{console.warn("You could only upload images.")}}}},{key:"checkBeforeSend",value:function e(t,a){a(t)}},{key:"sendToServer",value:function e(t){var a=this;if(this.options.customUploader){this.options.customUploader(t,function(e){a.insert(e)})}else{var i=this.options.url,n=this.options.method||"POST",s=this.options.name||"image",o=this.options.headers||{},r=this.options.callbackOK||this.uploadImageCallbackOK.bind(this),l=this.options.callbackKO||this.uploadImageCallbackKO.bind(this);if(i){var d=new FormData;d.append(s,t);if(this.options.csrf){d.append(this.options.csrf.token,this.options.csrf.hash)}var c=new XMLHttpRequest;c.open(n,i,true);for(var u in o){c.setRequestHeader(u,o[u])}c.onload=function(){if(c.status===200){r(JSON.parse(c.responseText),a.insert.bind(a))}else{l({code:c.status,type:c.statusText,body:c.responseText})}};if(this.options.withCredentials){c.withCredentials=true}c.send(d)}else{var f=new FileReader;f.onload=function(e){r(e.target.result,a.insert.bind(a))};f.readAsDataURL(t)}}}},{key:"handleDrop",value:function e(t){t.preventDefault();if(t.dataTransfer&&t.dataTransfer.files&&t.dataTransfer.files.length){if(document.caretRangeFromPoint){var a=document.getSelection();var i=document.caretRangeFromPoint(t.clientX,t.clientY);if(a&&i){a.setBaseAndExtent(i.startContainer,i.startOffset,i.startContainer,i.startOffset)}}this.readFiles(t.dataTransfer.files,this.sendToServer.bind(this))}}},{key:"handlePaste",value:function e(t){var a=this;var i=Quill.import("delta");if(t.clipboardData&&t.clipboardData.items&&t.clipboardData.items.length){this.readFiles(t.clipboardData.items,function(e){var t=a.quill.getSelection();if(t){a.quill.updateContents((new i).retain(t.index-1).delete(1))}setTimeout(function(){return a.sendToServer(e.getAsFile())},0)})}}},{key:"readFiles",value:function e(t,a){var i=this;[].forEach.call(t,function(e){if(!/^image\//.test(e.type)){return}var t=new FileReader;t.onload=function(t){var n=i.options.checkBeforeSend||i.checkBeforeSend.bind(i);n(e,a)};var n=e.getAsFile?e.getAsFile():e;if(n instanceof Blob){t.readAsDataURL(n)}})}},{key:"insert",value:function e(t){var a=(this.quill.getSelection()||{}).index||this.quill.getLength();this.quill.insertEmbed(a,"image",t,"user")}},{key:"uploadImageCallbackOK",value:function e(t,a){a(t)}},{key:"uploadImageCallbackKO",value:function e(t){alert(t)}}]);return e}();
|
5
|
-
window.Quill.register('modules/imageUpload', exports.ImageUpload);
|
6
|
-
})();
|