collavre 0.1.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 +7 -0
- data/README.md +221 -0
- data/Rakefile +8 -0
- data/app/assets/stylesheets/collavre/actiontext.css +577 -0
- data/app/assets/stylesheets/collavre/activity_logs.css +99 -0
- data/app/assets/stylesheets/collavre/comments_popup.css +692 -0
- data/app/assets/stylesheets/collavre/creatives.css +559 -0
- data/app/assets/stylesheets/collavre/dark_mode.css +118 -0
- data/app/assets/stylesheets/collavre/mention_menu.css +43 -0
- data/app/assets/stylesheets/collavre/popup.css +160 -0
- data/app/assets/stylesheets/collavre/print.css +37 -0
- data/app/assets/stylesheets/collavre/slide_view.css +79 -0
- data/app/assets/stylesheets/collavre/user_menu.css +34 -0
- data/app/channels/collavre/comments_presence_channel.rb +54 -0
- data/app/channels/collavre/slide_view_channel.rb +11 -0
- data/app/channels/collavre/topics_channel.rb +12 -0
- data/app/components/collavre/avatar_component.html.erb +15 -0
- data/app/components/collavre/avatar_component.rb +59 -0
- data/app/components/collavre/inbox/badge_component.html.erb +6 -0
- data/app/components/collavre/inbox/badge_component.rb +18 -0
- data/app/components/collavre/plans_timeline_component.html.erb +14 -0
- data/app/components/collavre/plans_timeline_component.rb +56 -0
- data/app/components/collavre/popup_menu_component.html.erb +6 -0
- data/app/components/collavre/popup_menu_component.rb +30 -0
- data/app/components/collavre/progress_filter_component.html.erb +5 -0
- data/app/components/collavre/progress_filter_component.rb +10 -0
- data/app/components/collavre/user_mention_menu_component.html.erb +3 -0
- data/app/components/collavre/user_mention_menu_component.rb +8 -0
- data/app/controllers/collavre/application_controller.rb +15 -0
- data/app/controllers/collavre/attachments_controller.rb +44 -0
- data/app/controllers/collavre/calendar_events_controller.rb +15 -0
- data/app/controllers/collavre/comment_read_pointers_controller.rb +80 -0
- data/app/controllers/collavre/comments/activity_logs_controller.rb +26 -0
- data/app/controllers/collavre/comments/reactions_controller.rb +82 -0
- data/app/controllers/collavre/comments_controller.rb +464 -0
- data/app/controllers/collavre/contacts_controller.rb +10 -0
- data/app/controllers/collavre/creative_expanded_states_controller.rb +27 -0
- data/app/controllers/collavre/creative_imports_controller.rb +24 -0
- data/app/controllers/collavre/creative_plans_controller.rb +69 -0
- data/app/controllers/collavre/creative_shares_controller.rb +79 -0
- data/app/controllers/collavre/creatives_controller.rb +535 -0
- data/app/controllers/collavre/devices_controller.rb +19 -0
- data/app/controllers/collavre/email_verifications_controller.rb +16 -0
- data/app/controllers/collavre/emails_controller.rb +11 -0
- data/app/controllers/collavre/github_auth_controller.rb +25 -0
- data/app/controllers/collavre/google_auth_controller.rb +43 -0
- data/app/controllers/collavre/inbox_items_controller.rb +64 -0
- data/app/controllers/collavre/invites_controller.rb +27 -0
- data/app/controllers/collavre/notion_auth_controller.rb +25 -0
- data/app/controllers/collavre/passwords_controller.rb +37 -0
- data/app/controllers/collavre/plans_controller.rb +110 -0
- data/app/controllers/collavre/sessions_controller.rb +57 -0
- data/app/controllers/collavre/topics_controller.rb +58 -0
- data/app/controllers/collavre/user_themes_controller.rb +58 -0
- data/app/controllers/collavre/users_controller.rb +390 -0
- data/app/helpers/collavre/application_helper.rb +4 -0
- data/app/helpers/collavre/comments_helper.rb +9 -0
- data/app/helpers/collavre/creatives_helper.rb +343 -0
- data/app/helpers/collavre/navigation_helper.rb +163 -0
- data/app/helpers/collavre/user_themes_helper.rb +4 -0
- data/app/javascript/collavre.js +26 -0
- data/app/javascript/components/InlineLexicalEditor.jsx +889 -0
- data/app/javascript/components/LinkPopup.jsx +112 -0
- data/app/javascript/components/creative_tree_row.js +503 -0
- data/app/javascript/components/plugins/attachment_cleanup_plugin.jsx +95 -0
- data/app/javascript/components/plugins/image_upload_plugin.jsx +162 -0
- data/app/javascript/controllers/click_target_controller.js +13 -0
- data/app/javascript/controllers/comment_controller.js +162 -0
- data/app/javascript/controllers/comments/__tests__/popup_controller.test.js +68 -0
- data/app/javascript/controllers/comments/form_controller.js +530 -0
- data/app/javascript/controllers/comments/list_controller.js +715 -0
- data/app/javascript/controllers/comments/mention_menu_controller.js +41 -0
- data/app/javascript/controllers/comments/popup_controller.js +385 -0
- data/app/javascript/controllers/comments/presence_controller.js +311 -0
- data/app/javascript/controllers/comments/topics_controller.js +338 -0
- data/app/javascript/controllers/common_popup_controller.js +55 -0
- data/app/javascript/controllers/creatives/drag_drop_controller.js +45 -0
- data/app/javascript/controllers/creatives/expansion_controller.js +222 -0
- data/app/javascript/controllers/creatives/import_controller.js +116 -0
- data/app/javascript/controllers/creatives/row_editor_controller.js +8 -0
- data/app/javascript/controllers/creatives/select_mode_controller.js +231 -0
- data/app/javascript/controllers/creatives/set_plan_modal_controller.js +107 -0
- data/app/javascript/controllers/creatives/tree_controller.js +218 -0
- data/app/javascript/controllers/index.js +79 -0
- data/app/javascript/controllers/link_creative_controller.js +91 -0
- data/app/javascript/controllers/popup_menu_controller.js +82 -0
- data/app/javascript/controllers/progress_filter_controller.js +35 -0
- data/app/javascript/controllers/reaction_picker_controller.js +107 -0
- data/app/javascript/controllers/share_invite_controller.js +15 -0
- data/app/javascript/controllers/share_user_search_controller.js +121 -0
- data/app/javascript/controllers/tabs_controller.js +43 -0
- data/app/javascript/creatives/drag_drop/dom.js +170 -0
- data/app/javascript/creatives/drag_drop/event_handlers.js +846 -0
- data/app/javascript/creatives/drag_drop/indicator.js +35 -0
- data/app/javascript/creatives/drag_drop/operations.js +116 -0
- data/app/javascript/creatives/drag_drop/state.js +31 -0
- data/app/javascript/creatives/tree_renderer.js +248 -0
- data/app/javascript/lib/api/__tests__/queue_manager.test.js +153 -0
- data/app/javascript/lib/api/creatives.js +79 -0
- data/app/javascript/lib/api/csrf_fetch.js +22 -0
- data/app/javascript/lib/api/drag_drop.js +31 -0
- data/app/javascript/lib/api/queue_manager.js +423 -0
- data/app/javascript/lib/apply_lexical_styles.js +15 -0
- data/app/javascript/lib/common_popup.js +195 -0
- data/app/javascript/lib/lexical/__tests__/action_text_attachment_node.test.jsx +91 -0
- data/app/javascript/lib/lexical/__tests__/attachment_payload.test.js +194 -0
- data/app/javascript/lib/lexical/action_text_attachment_node.js +459 -0
- data/app/javascript/lib/lexical/attachment_node.jsx +170 -0
- data/app/javascript/lib/lexical/attachment_payload.js +293 -0
- data/app/javascript/lib/lexical/dom_attachment_utils.js +66 -0
- data/app/javascript/lib/lexical/image_node.jsx +159 -0
- data/app/javascript/lib/lexical/style_attributes.js +40 -0
- data/app/javascript/lib/responsive_images.js +54 -0
- data/app/javascript/lib/turbo_stream_actions.js +33 -0
- data/app/javascript/lib/utils/markdown.js +23 -0
- data/app/javascript/modules/creative_guide.js +53 -0
- data/app/javascript/modules/creative_row_editor.js +1841 -0
- data/app/javascript/modules/creative_row_swipe.js +43 -0
- data/app/javascript/modules/creatives.js +15 -0
- data/app/javascript/modules/export_to_markdown.js +34 -0
- data/app/javascript/modules/inbox_panel.js +226 -0
- data/app/javascript/modules/lexical_inline_editor.jsx +133 -0
- data/app/javascript/modules/mention_menu.js +77 -0
- data/app/javascript/modules/plans_menu.js +39 -0
- data/app/javascript/modules/plans_timeline.js +397 -0
- data/app/javascript/modules/share_modal.js +73 -0
- data/app/javascript/modules/share_user_popup.js +77 -0
- data/app/javascript/modules/slide_view.js +163 -0
- data/app/javascript/services/cable.js +32 -0
- data/app/javascript/slide_view.js +2 -0
- data/app/javascript/utils/caret_position.js +42 -0
- data/app/javascript/utils/clipboard.js +40 -0
- data/app/jobs/collavre/ai_agent_job.rb +27 -0
- data/app/jobs/collavre/inbox_summary_job.rb +24 -0
- data/app/jobs/collavre/notion_export_job.rb +30 -0
- data/app/jobs/collavre/notion_sync_job.rb +48 -0
- data/app/jobs/collavre/permission_cache_cleanup_job.rb +36 -0
- data/app/jobs/collavre/permission_cache_job.rb +71 -0
- data/app/jobs/collavre/push_notification_job.rb +86 -0
- data/app/mailers/collavre/application_mailer.rb +17 -0
- data/app/mailers/collavre/creative_mailer.rb +9 -0
- data/app/mailers/collavre/email_verification_mailer.rb +20 -0
- data/app/mailers/collavre/inbox_mailer.rb +19 -0
- data/app/mailers/collavre/invitation_mailer.rb +16 -0
- data/app/mailers/collavre/passwords_mailer.rb +10 -0
- data/app/models/collavre/activity_log.rb +13 -0
- data/app/models/collavre/application_record.rb +5 -0
- data/app/models/collavre/calendar_event.rb +20 -0
- data/app/models/collavre/comment.rb +307 -0
- data/app/models/collavre/comment_presence_store.rb +30 -0
- data/app/models/collavre/comment_reaction.rb +11 -0
- data/app/models/collavre/comment_read_pointer.rb +26 -0
- data/app/models/collavre/contact.rb +23 -0
- data/app/models/collavre/creative.rb +413 -0
- data/app/models/collavre/creative_expanded_state.rb +11 -0
- data/app/models/collavre/creative_share.rb +122 -0
- data/app/models/collavre/creative_shares_cache.rb +18 -0
- data/app/models/collavre/current.rb +14 -0
- data/app/models/collavre/device.rb +13 -0
- data/app/models/collavre/email.rb +14 -0
- data/app/models/collavre/github_account.rb +10 -0
- data/app/models/collavre/github_repository_link.rb +19 -0
- data/app/models/collavre/inbox_item.rb +95 -0
- data/app/models/collavre/invitation.rb +22 -0
- data/app/models/collavre/label.rb +47 -0
- data/app/models/collavre/mcp_tool.rb +30 -0
- data/app/models/collavre/notion_account.rb +17 -0
- data/app/models/collavre/notion_block_link.rb +10 -0
- data/app/models/collavre/notion_page_link.rb +19 -0
- data/app/models/collavre/plan.rb +20 -0
- data/app/models/collavre/session.rb +24 -0
- data/app/models/collavre/system_setting.rb +144 -0
- data/app/models/collavre/tag.rb +10 -0
- data/app/models/collavre/task.rb +10 -0
- data/app/models/collavre/task_action.rb +10 -0
- data/app/models/collavre/topic.rb +12 -0
- data/app/models/collavre/user.rb +174 -0
- data/app/models/collavre/user_theme.rb +10 -0
- data/app/models/collavre/variation.rb +5 -0
- data/app/models/collavre/webauthn_credential.rb +11 -0
- data/app/services/collavre/ai_agent_service.rb +193 -0
- data/app/services/collavre/ai_client.rb +183 -0
- data/app/services/collavre/ai_system_prompt_renderer.rb +38 -0
- data/app/services/collavre/auto_theme_generator.rb +198 -0
- data/app/services/collavre/comment_link_formatter.rb +60 -0
- data/app/services/collavre/comments/action_executor.rb +262 -0
- data/app/services/collavre/comments/action_validator.rb +58 -0
- data/app/services/collavre/comments/calendar_command.rb +97 -0
- data/app/services/collavre/comments/command_processor.rb +37 -0
- data/app/services/collavre/comments/mcp_command.rb +109 -0
- data/app/services/collavre/comments/mcp_command_builder.rb +32 -0
- data/app/services/collavre/creatives/filter_pipeline.rb +196 -0
- data/app/services/collavre/creatives/filters/assignee_filter.rb +30 -0
- data/app/services/collavre/creatives/filters/base_filter.rb +24 -0
- data/app/services/collavre/creatives/filters/comment_filter.rb +21 -0
- data/app/services/collavre/creatives/filters/date_filter.rb +58 -0
- data/app/services/collavre/creatives/filters/progress_filter.rb +25 -0
- data/app/services/collavre/creatives/filters/search_filter.rb +28 -0
- data/app/services/collavre/creatives/filters/tag_filter.rb +16 -0
- data/app/services/collavre/creatives/importer.rb +47 -0
- data/app/services/collavre/creatives/index_query.rb +191 -0
- data/app/services/collavre/creatives/path_exporter.rb +131 -0
- data/app/services/collavre/creatives/permission_cache_builder.rb +194 -0
- data/app/services/collavre/creatives/permission_checker.rb +42 -0
- data/app/services/collavre/creatives/plan_tagger.rb +53 -0
- data/app/services/collavre/creatives/progress_service.rb +89 -0
- data/app/services/collavre/creatives/reorderer.rb +187 -0
- data/app/services/collavre/creatives/tree_builder.rb +231 -0
- data/app/services/collavre/creatives/tree_formatter.rb +36 -0
- data/app/services/collavre/gemini_parent_recommender.rb +77 -0
- data/app/services/collavre/github/client.rb +112 -0
- data/app/services/collavre/github/pull_request_analyzer.rb +280 -0
- data/app/services/collavre/github/pull_request_processor.rb +181 -0
- data/app/services/collavre/github/webhook_provisioner.rb +130 -0
- data/app/services/collavre/google_calendar_service.rb +149 -0
- data/app/services/collavre/link_preview_fetcher.rb +230 -0
- data/app/services/collavre/markdown_importer.rb +202 -0
- data/app/services/collavre/mcp_service.rb +217 -0
- data/app/services/collavre/notion_client.rb +231 -0
- data/app/services/collavre/notion_creative_exporter.rb +296 -0
- data/app/services/collavre/notion_service.rb +249 -0
- data/app/services/collavre/ppt_importer.rb +76 -0
- data/app/services/collavre/ruby_llm_interaction_logger.rb +34 -0
- data/app/services/collavre/system_events/context_builder.rb +41 -0
- data/app/services/collavre/system_events/dispatcher.rb +19 -0
- data/app/services/collavre/system_events/router.rb +72 -0
- data/app/services/collavre/tools/creative_retrieval_service.rb +138 -0
- data/app/views/admin/shared/_tabs.html.erb +4 -0
- data/app/views/collavre/comments/_activity_log_details.html.erb +23 -0
- data/app/views/collavre/comments/_comment.html.erb +147 -0
- data/app/views/collavre/comments/_comments_popup.html.erb +46 -0
- data/app/views/collavre/comments/_list.html.erb +10 -0
- data/app/views/collavre/comments/_presence_avatars.html.erb +8 -0
- data/app/views/collavre/comments/_reaction_picker.html.erb +15 -0
- data/app/views/collavre/comments/_read_receipts.html.erb +19 -0
- data/app/views/collavre/creatives/_add_button.html.erb +20 -0
- data/app/views/collavre/creatives/_delete_button.html.erb +12 -0
- data/app/views/collavre/creatives/_github_integration_modal.html.erb +77 -0
- data/app/views/collavre/creatives/_import_upload_zone.html.erb +10 -0
- data/app/views/collavre/creatives/_inline_edit_form.html.erb +89 -0
- data/app/views/collavre/creatives/_mobile_actions_menu.html.erb +24 -0
- data/app/views/collavre/creatives/_notion_integration_modal.html.erb +90 -0
- data/app/views/collavre/creatives/_set_plan_modal.html.erb +25 -0
- data/app/views/collavre/creatives/_share_button.html.erb +55 -0
- data/app/views/collavre/creatives/edit.html.erb +4 -0
- data/app/views/collavre/creatives/index.html.erb +192 -0
- data/app/views/collavre/creatives/new.html.erb +4 -0
- data/app/views/collavre/creatives/show.html.erb +29 -0
- data/app/views/collavre/creatives/slide_view.html.erb +20 -0
- data/app/views/collavre/email_verification_mailer/verify.html.erb +4 -0
- data/app/views/collavre/email_verification_mailer/verify.text.erb +2 -0
- data/app/views/collavre/emails/index.html.erb +19 -0
- data/app/views/collavre/emails/show.html.erb +5 -0
- data/app/views/collavre/inbox_items/_item.html.erb +18 -0
- data/app/views/collavre/inbox_items/_items.html.erb +3 -0
- data/app/views/collavre/inbox_items/_list.html.erb +7 -0
- data/app/views/collavre/inbox_items/index.html.erb +1 -0
- data/app/views/collavre/inbox_mailer/daily_summary.html.erb +11 -0
- data/app/views/collavre/inbox_mailer/daily_summary.text.erb +8 -0
- data/app/views/collavre/invitation_mailer/invite.html.erb +5 -0
- data/app/views/collavre/invitation_mailer/invite.text.erb +3 -0
- data/app/views/collavre/invites/show.html.erb +8 -0
- data/app/views/collavre/passwords/edit.html.erb +12 -0
- data/app/views/collavre/passwords/new.html.erb +17 -0
- data/app/views/collavre/passwords_mailer/reset.html.erb +4 -0
- data/app/views/collavre/passwords_mailer/reset.text.erb +2 -0
- data/app/views/collavre/sessions/new.html.erb +27 -0
- data/app/views/collavre/sessions/providers/_google.html.erb +7 -0
- data/app/views/collavre/sessions/providers/_passkey.html.erb +3 -0
- data/app/views/collavre/shared/_link_creative_modal.html.erb +6 -0
- data/app/views/collavre/shared/_navigation.html.erb +37 -0
- data/app/views/collavre/shared/navigation/_help_button.html.erb +1 -0
- data/app/views/collavre/shared/navigation/_inbox_button.html.erb +5 -0
- data/app/views/collavre/shared/navigation/_mobile_inbox_button.html.erb +3 -0
- data/app/views/collavre/shared/navigation/_mobile_plans_button.html.erb +1 -0
- data/app/views/collavre/shared/navigation/_panels.html.erb +18 -0
- data/app/views/collavre/shared/navigation/_plans_button.html.erb +3 -0
- data/app/views/collavre/shared/navigation/_search_form.html.erb +6 -0
- data/app/views/collavre/user_themes/index.html.erb +75 -0
- data/app/views/collavre/users/_app_header.html.erb +5 -0
- data/app/views/collavre/users/_contact_management.html.erb +77 -0
- data/app/views/collavre/users/_id_pwd_fields.html.erb +27 -0
- data/app/views/collavre/users/edit_ai.html.erb +79 -0
- data/app/views/collavre/users/edit_password.html.erb +27 -0
- data/app/views/collavre/users/index.html.erb +80 -0
- data/app/views/collavre/users/new.html.erb +33 -0
- data/app/views/collavre/users/new_ai.html.erb +87 -0
- data/app/views/collavre/users/passkeys.html.erb +43 -0
- data/app/views/collavre/users/show.html.erb +143 -0
- data/app/views/inbox/badge_component/_count.html.erb +2 -0
- data/app/views/layouts/collavre/slide.html.erb +29 -0
- data/config/locales/comments.en.yml +114 -0
- data/config/locales/comments.ko.yml +110 -0
- data/config/locales/contacts.en.yml +16 -0
- data/config/locales/contacts.ko.yml +16 -0
- data/config/locales/creatives.en.yml +183 -0
- data/config/locales/creatives.ko.yml +164 -0
- data/config/locales/invites.en.yml +19 -0
- data/config/locales/invites.ko.yml +17 -0
- data/config/locales/notifications.en.yml +8 -0
- data/config/locales/notifications.ko.yml +8 -0
- data/config/locales/plans.en.yml +12 -0
- data/config/locales/plans.ko.yml +19 -0
- data/config/locales/themes.en.yml +29 -0
- data/config/locales/themes.ko.yml +27 -0
- data/config/locales/users.en.yml +151 -0
- data/config/locales/users.ko.yml +146 -0
- data/config/routes.rb +92 -0
- data/db/migrate/20241201000000_create_notion_integrations.rb +29 -0
- data/db/migrate/20250128110017_create_creatives.rb +11 -0
- data/db/migrate/20250128120122_create_users.rb +11 -0
- data/db/migrate/20250128120123_create_sessions.rb +11 -0
- data/db/migrate/20250128123633_create_subscribers.rb +10 -0
- data/db/migrate/20250312000000_create_notion_block_links.rb +16 -0
- data/db/migrate/20250312010000_allow_multiple_notion_blocks_per_creative.rb +5 -0
- data/db/migrate/20250522115048_remove_name_from_creatives.rb +5 -0
- data/db/migrate/20250522190651_add_parent_id_to_creatives.rb +5 -0
- data/db/migrate/20250523133100_rename_inventory_count_to_progress.rb +13 -0
- data/db/migrate/20250523133101_add_sequence_to_creatives.rb +5 -0
- data/db/migrate/20250525205100_add_user_id_to_creatives.rb +10 -0
- data/db/migrate/20250527014217_create_creative_shares.rb +12 -0
- data/db/migrate/20250528142349_add_origin_id_to_creatives.rb +5 -0
- data/db/migrate/20250530060200_create_tags.rb +9 -0
- data/db/migrate/20250531105150_add_value_to_tags.rb +5 -0
- data/db/migrate/20250531140142_create_labels.rb +12 -0
- data/db/migrate/20250531140145_change_tag_to_label_reference.rb +6 -0
- data/db/migrate/20250601000000_create_comments.rb +10 -0
- data/db/migrate/20250601061830_drop_plans_and_variations.rb +6 -0
- data/db/migrate/20250604122600_add_owner_to_labels.rb +5 -0
- data/db/migrate/20250606000000_rename_email_address_to_email_in_users.rb +7 -0
- data/db/migrate/20250606150329_create_creative_hierarchies.rb +16 -0
- data/db/migrate/20250610142000_create_creative_expanded_states.rb +11 -0
- data/db/migrate/20250611030138_create_invitations.rb +15 -0
- data/db/migrate/20250611105524_create_inbox_items.rb +14 -0
- data/db/migrate/20250612150000_update_permissions.rb +43 -0
- data/db/migrate/20250612232913_add_email_verified_at_to_users.rb +5 -0
- data/db/migrate/20250616065905_add_avatar_to_users.rb +5 -0
- data/db/migrate/20250617092111_add_display_level_to_users.rb +5 -0
- data/db/migrate/20250620004558_create_emails.rb +13 -0
- data/db/migrate/20250621000000_create_comment_read_pointers.rb +11 -0
- data/db/migrate/20250622000000_add_completion_mark_to_users.rb +5 -0
- data/db/migrate/20250623000000_add_theme_to_users.rb +5 -0
- data/db/migrate/20250624000000_add_name_to_users.rb +18 -0
- data/db/migrate/20250714190000_create_devices.rb +17 -0
- data/db/migrate/20250715120000_add_notifications_enabled_to_users.rb +5 -0
- data/db/migrate/20250823000000_add_no_access_permission.rb +25 -0
- data/db/migrate/20250826000000_add_calendar_id_to_users.rb +5 -0
- data/db/migrate/20250827000000_add_google_oauth_tokens_to_users.rb +8 -0
- data/db/migrate/20250827061238_add_timezone_to_users.rb +5 -0
- data/db/migrate/20250828000000_create_calendar_events.rb +16 -0
- data/db/migrate/20250828060000_add_creative_to_calendar_events.rb +5 -0
- data/db/migrate/20250830141052_add_locale_to_users.rb +5 -0
- data/db/migrate/20250830141101_add_message_key_to_inbox_items.rb +6 -0
- data/db/migrate/20250902025423_remove_description_and_featured_image_from_creatives.rb +6 -0
- data/db/migrate/20250910000000_add_private_to_comments.rb +5 -0
- data/db/migrate/20250910105640_migrate_write_permissions_to_admin.rb +17 -0
- data/db/migrate/20250911084338_backfill_creative_in_comment_inbox_items.rb +27 -0
- data/db/migrate/20250923002959_deduplicate_device_fcm_tokens.rb +25 -0
- data/db/migrate/20250924000000_add_system_admin_to_users.rb +6 -0
- data/db/migrate/20250925000000_create_github_integrations.rb +26 -0
- data/db/migrate/20250927000000_add_webhook_secret_to_github_repository_links.rb +29 -0
- data/db/migrate/20250928000000_add_action_and_approver_to_comments.rb +6 -0
- data/db/migrate/20250928010000_add_action_execution_tracking_to_comments.rb +6 -0
- data/db/migrate/20250928105957_add_github_gemini_prompt_to_creatives.rb +5 -0
- data/db/migrate/20250929000000_add_comment_and_creative_refs_to_inbox_items.rb +6 -0
- data/db/migrate/20251001000001_create_contacts.rb +71 -0
- data/db/migrate/20251002000000_add_shared_by_to_creative_shares.rb +14 -0
- data/db/migrate/20251124120902_add_ai_fields_to_users.rb +7 -0
- data/db/migrate/20251124122218_add_created_by_id_to_users.rb +5 -0
- data/db/migrate/20251124124521_add_llm_api_key_to_users.rb +5 -0
- data/db/migrate/20251124130000_add_searchable_to_users.rb +6 -0
- data/db/migrate/20251125072705_migrate_linked_creative_children_to_origin.rb +28 -0
- data/db/migrate/20251126040752_add_description_to_creatives.rb +75 -0
- data/db/migrate/20251127000000_move_comments_from_linked_creatives_to_origins.rb +18 -0
- data/db/migrate/20251201073823_add_tools_to_users.rb +5 -0
- data/db/migrate/20251202062715_create_mcp_tools.rb +16 -0
- data/db/migrate/20251204125754_create_tasks_and_task_actions.rb +23 -0
- data/db/migrate/20251204125756_add_routing_expression_to_users.rb +5 -0
- data/db/migrate/20251204161133_set_default_routing_expression_for_ai_agents.rb +13 -0
- data/db/migrate/20251211033025_nullify_self_referencing_origins.rb +9 -0
- data/db/migrate/20251211080040_create_topics_and_add_topic_to_comments.rb +15 -0
- data/db/migrate/20251215143500_create_activity_logs.rb +16 -0
- data/db/migrate/20251222125727_create_webauthn_credentials.rb +14 -0
- data/db/migrate/20251222125839_add_webauthn_id_to_users.rb +5 -0
- data/db/migrate/20251223022315_create_comment_reactions.rb +13 -0
- data/db/migrate/20251223072625_create_user_themes.rb +11 -0
- data/db/migrate/20251230074456_add_creative_id_to_labels.rb +5 -0
- data/db/migrate/20251230113607_refactor_labels.rb +38 -0
- data/db/migrate/20251231010012_backfill_tags_for_labels.rb +15 -0
- data/db/migrate/20251231013234_drop_subscribers.rb +9 -0
- data/db/migrate/20260106090544_allow_null_user_id_in_creative_shares.rb +6 -0
- data/db/migrate/20260106160643_create_system_settings.rb +11 -0
- data/db/migrate/20260116000000_create_creative_shares_cache.rb +15 -0
- data/db/migrate/20260116000001_populate_creative_shares_cache.rb +23 -0
- data/db/migrate/20260119022933_make_source_share_id_nullable_in_creative_shares_caches.rb +7 -0
- data/db/migrate/20260119023446_populate_owner_cache_entries.rb +25 -0
- data/db/migrate/20260119100000_add_account_lockout_to_users.rb +6 -0
- data/db/migrate/20260119110000_add_last_active_at_to_sessions.rb +6 -0
- data/db/migrate/20260120045354_encrypt_oauth_tokens.rb +60 -0
- data/db/migrate/20260120162259_remove_fk_from_creative_shares_caches.rb +7 -0
- data/db/migrate/20260120163856_remove_timestamps_from_creative_shares_caches.rb +6 -0
- data/lib/collavre/configuration.rb +14 -0
- data/lib/collavre/engine.rb +77 -0
- data/lib/collavre/user_extensions.rb +29 -0
- data/lib/collavre/version.rb +3 -0
- data/lib/collavre.rb +26 -0
- data/lib/generators/collavre/install/install_generator.rb +105 -0
- data/lib/generators/collavre/install/templates/build.cjs.tt +100 -0
- data/lib/tasks/collavre_assets.rake +15 -0
- metadata +591 -0
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
|
2
|
+
import { renderMarkdownInContainer } from '../../lib/utils/markdown'
|
|
3
|
+
|
|
4
|
+
export default class extends Controller {
|
|
5
|
+
static targets = [
|
|
6
|
+
'form',
|
|
7
|
+
'textarea',
|
|
8
|
+
'submit',
|
|
9
|
+
'privateCheckbox',
|
|
10
|
+
'cancel',
|
|
11
|
+
'moveButton',
|
|
12
|
+
'searchButton',
|
|
13
|
+
'voiceButton',
|
|
14
|
+
'imageInput',
|
|
15
|
+
'imageButton',
|
|
16
|
+
'attachmentList',
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
connect() {
|
|
20
|
+
this.creativeId = null
|
|
21
|
+
this.editingId = null
|
|
22
|
+
this.sending = false
|
|
23
|
+
this.cachedImageFiles = null
|
|
24
|
+
|
|
25
|
+
this.handleSubmit = this.handleSubmit.bind(this)
|
|
26
|
+
this.handleSend = this.handleSend.bind(this)
|
|
27
|
+
this.defaultSubmitHTML = this.submitTarget.innerHTML
|
|
28
|
+
this.handlePointerSend = this.handlePointerSend.bind(this)
|
|
29
|
+
this.handleTouchSend = this.handleTouchSend.bind(this)
|
|
30
|
+
this.handleCancel = this.handleCancel.bind(this)
|
|
31
|
+
this.handleMoveClick = this.handleMoveClick.bind(this)
|
|
32
|
+
this.handleSearch = this.handleSearch.bind(this)
|
|
33
|
+
this.handleVoiceToggle = this.handleVoiceToggle.bind(this)
|
|
34
|
+
this.handleRecognitionStart = this.handleRecognitionStart.bind(this)
|
|
35
|
+
this.handleRecognitionEnd = this.handleRecognitionEnd.bind(this)
|
|
36
|
+
this.handleRecognitionResult = this.handleRecognitionResult.bind(this)
|
|
37
|
+
this.handleRecognitionError = this.handleRecognitionError.bind(this)
|
|
38
|
+
this.handleImageButtonClick = this.handleImageButtonClick.bind(this)
|
|
39
|
+
this.handleImageChange = this.handleImageChange.bind(this)
|
|
40
|
+
this.handleDragOver = this.handleDragOver.bind(this)
|
|
41
|
+
this.handleDrop = this.handleDrop.bind(this)
|
|
42
|
+
|
|
43
|
+
this.formTarget.addEventListener('submit', this.handleSubmit)
|
|
44
|
+
this.submitTarget.addEventListener('click', this.handleSend)
|
|
45
|
+
this.submitTarget.addEventListener('pointerup', this.handlePointerSend)
|
|
46
|
+
this.submitTarget.addEventListener('touchend', this.handleTouchSend, { passive: false })
|
|
47
|
+
this.cancelTarget?.addEventListener('click', this.handleCancel)
|
|
48
|
+
this.moveButtonTarget?.addEventListener('click', this.handleMoveClick)
|
|
49
|
+
this.searchButtonTarget?.addEventListener('click', this.handleSearch)
|
|
50
|
+
this.voiceButtonTarget?.addEventListener('click', this.handleVoiceToggle)
|
|
51
|
+
|
|
52
|
+
this.imageButtonTarget?.addEventListener('click', this.handleImageButtonClick)
|
|
53
|
+
this.imageInputTarget?.addEventListener('change', this.handleImageChange)
|
|
54
|
+
this.textareaTarget.addEventListener('dragover', this.handleDragOver)
|
|
55
|
+
this.textareaTarget.addEventListener('drop', this.handleDrop)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
this.recognition = null
|
|
59
|
+
this.listening = false
|
|
60
|
+
this.recognitionActive = false
|
|
61
|
+
|
|
62
|
+
this.textareaTarget.addEventListener('keydown', (event) => {
|
|
63
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
|
64
|
+
if (this.isMentionMenuVisible()) return
|
|
65
|
+
this.handleSend(event)
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
this.updateAttachmentList()
|
|
70
|
+
|
|
71
|
+
this.handleTopicChange = this.handleTopicChange.bind(this)
|
|
72
|
+
this.element.addEventListener('comments--topics:change', this.handleTopicChange)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
handleTopicChange(event) {
|
|
76
|
+
this.currentTopicId = event.detail.topicId
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
isMentionMenuVisible() {
|
|
81
|
+
const menu = document.getElementById('mention-menu')
|
|
82
|
+
return menu?.style.display === 'block'
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
disconnect() {
|
|
86
|
+
this.formTarget.removeEventListener('submit', this.handleSubmit)
|
|
87
|
+
this.submitTarget.removeEventListener('click', this.handleSend)
|
|
88
|
+
this.submitTarget.removeEventListener('pointerup', this.handlePointerSend)
|
|
89
|
+
this.submitTarget.removeEventListener('touchend', this.handleTouchSend)
|
|
90
|
+
this.cancelTarget?.removeEventListener('click', this.handleCancel)
|
|
91
|
+
this.moveButtonTarget?.removeEventListener('click', this.handleMoveClick)
|
|
92
|
+
this.searchButtonTarget?.removeEventListener('click', this.handleSearch)
|
|
93
|
+
this.voiceButtonTarget?.removeEventListener('click', this.handleVoiceToggle)
|
|
94
|
+
this.teardownSpeechRecognition()
|
|
95
|
+
this.imageButtonTarget?.removeEventListener('click', this.handleImageButtonClick)
|
|
96
|
+
this.imageInputTarget?.removeEventListener('change', this.handleImageChange)
|
|
97
|
+
this.textareaTarget.removeEventListener('dragover', this.handleDragOver)
|
|
98
|
+
this.textareaTarget.removeEventListener('drop', this.handleDrop)
|
|
99
|
+
this.element.removeEventListener('comments--topics:change', this.handleTopicChange)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
get listController() {
|
|
103
|
+
return this.application.getControllerForElementAndIdentifier(this.element, 'comments--list')
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
get presenceController() {
|
|
107
|
+
return this.application.getControllerForElementAndIdentifier(this.element, 'comments--presence')
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
onPopupOpened({ creativeId, canComment }) {
|
|
111
|
+
this.creativeId = creativeId
|
|
112
|
+
this.element.dataset.creativeId = creativeId || ''
|
|
113
|
+
this.formTarget.style.display = canComment ? '' : 'none'
|
|
114
|
+
this.resetForm()
|
|
115
|
+
if (canComment) {
|
|
116
|
+
requestAnimationFrame(() => this.textareaTarget.focus())
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
onPopupClosed() {
|
|
121
|
+
this.stopSpeechRecognition()
|
|
122
|
+
this.resetForm()
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
onSelectionChanged({ size, moving }) {
|
|
126
|
+
if (!this.moveButtonTarget) return
|
|
127
|
+
this.moveButtonTarget.disabled = moving || size === 0
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
focusTextarea() {
|
|
131
|
+
if (this.formTarget.style.display === 'none') return
|
|
132
|
+
requestAnimationFrame(() => this.textareaTarget.focus())
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
startEditing({ id, content, private: isPrivate }) {
|
|
136
|
+
this.editingId = id
|
|
137
|
+
this.textareaTarget.value = content || ''
|
|
138
|
+
if (this.privateCheckboxTarget) {
|
|
139
|
+
this.privateCheckboxTarget.checked = !!isPrivate
|
|
140
|
+
this.privateCheckboxTarget.dispatchEvent(new Event('change'))
|
|
141
|
+
}
|
|
142
|
+
this.clearImageAttachments()
|
|
143
|
+
this.submitTarget.textContent = this.element.dataset.updateCommentText
|
|
144
|
+
if (this.cancelTarget) this.cancelTarget.style.display = ''
|
|
145
|
+
this.focusTextarea()
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
resetForm() {
|
|
149
|
+
this.formTarget.reset()
|
|
150
|
+
this.editingId = null
|
|
151
|
+
this.submitTarget.innerHTML = this.defaultSubmitHTML
|
|
152
|
+
this.submitTarget.disabled = false
|
|
153
|
+
if (this.cancelTarget) this.cancelTarget.style.display = 'none'
|
|
154
|
+
this.presenceController?.clearManualTypingMessage()
|
|
155
|
+
this.clearImageAttachments()
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
setSendingState(isSending) {
|
|
159
|
+
if (!this.submitTarget) return
|
|
160
|
+
|
|
161
|
+
if (isSending) {
|
|
162
|
+
this.submitTarget.disabled = true
|
|
163
|
+
return
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
this.submitTarget.disabled = false
|
|
167
|
+
this.sending = false
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
handleSubmit(event) {
|
|
171
|
+
event.preventDefault()
|
|
172
|
+
this.handleSend(event)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
handleSend(event) {
|
|
176
|
+
event.preventDefault()
|
|
177
|
+
const hasText = this.textareaTarget.value.trim().length > 0
|
|
178
|
+
const hasImages = this.currentImageFiles().length > 0
|
|
179
|
+
if (this.sending || (!hasText && !hasImages) || !this.creativeId) return
|
|
180
|
+
this.sending = true
|
|
181
|
+
this.setSendingState(true)
|
|
182
|
+
this.presenceController?.stoppedTyping()
|
|
183
|
+
|
|
184
|
+
const wasPrivate = this.privateCheckboxTarget?.checked ?? false
|
|
185
|
+
|
|
186
|
+
const formData = new FormData(this.formTarget)
|
|
187
|
+
if (this.currentTopicId) {
|
|
188
|
+
formData.append('comment[topic_id]', this.currentTopicId)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
let url = `/creatives/${this.creativeId}/comments`
|
|
192
|
+
let method = 'POST'
|
|
193
|
+
if (this.editingId) {
|
|
194
|
+
url += `/${this.editingId}`
|
|
195
|
+
method = 'PATCH'
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
fetch(url, {
|
|
199
|
+
method,
|
|
200
|
+
headers: { 'X-CSRF-Token': document.querySelector('meta[name=csrf-token]').content },
|
|
201
|
+
body: formData,
|
|
202
|
+
})
|
|
203
|
+
.then((response) => {
|
|
204
|
+
if (response.ok) return response.text()
|
|
205
|
+
return response.json().then((json) => {
|
|
206
|
+
throw new Error(json.errors?.join(', ') || 'Unable to save comment')
|
|
207
|
+
})
|
|
208
|
+
})
|
|
209
|
+
.then((html) => {
|
|
210
|
+
const wasEditing = this.editingId
|
|
211
|
+
this.resetForm()
|
|
212
|
+
if (wasEditing) {
|
|
213
|
+
// If editing, just replace the item in place
|
|
214
|
+
this.renderCommentHtml(html, { replaceExisting: true })
|
|
215
|
+
} else {
|
|
216
|
+
// New Comment:
|
|
217
|
+
// 1. If we are in "History Mode" (scrolled up), sending a message should jump us to the latest.
|
|
218
|
+
// 2. Ideally, we just reload the "Latest" page to ensure sync and Live Mode.
|
|
219
|
+
// 3. Or, if we are already at latest, just append.
|
|
220
|
+
|
|
221
|
+
// Based on requirements: "jump to first page... message added immediately".
|
|
222
|
+
// Safest approach: Reset list to latest.
|
|
223
|
+
// However, to make it feel instant, we might want to append optimisticly or just let the reset handle it.
|
|
224
|
+
// A full reset causes a loading spinner.
|
|
225
|
+
// Better UX: Append to bottom, then ensure we are in "Live Mode".
|
|
226
|
+
|
|
227
|
+
// BUT, if we are in history, appending to bottom might leave a gap if we haven't loaded intermediate messages.
|
|
228
|
+
// So, if !allNewerLoaded, we MUST reset/reload to get the full latest context.
|
|
229
|
+
|
|
230
|
+
const listCtrl = this.listController
|
|
231
|
+
if (listCtrl) {
|
|
232
|
+
if (!listCtrl.allNewerLoaded) {
|
|
233
|
+
// In History Mode -> Reset to Latest
|
|
234
|
+
listCtrl.resetToLatest()
|
|
235
|
+
// Note: The new message is in `html`, but resetToLatest fetches from server.
|
|
236
|
+
// There might be a race condition if server value isn't ready, but usually ok.
|
|
237
|
+
// Alternatively, we manually clear list and append `html` + fetch prev?
|
|
238
|
+
// Reset is safest for data consistency.
|
|
239
|
+
} else {
|
|
240
|
+
// Already in Live Mode or at bottom -> Just append and scroll
|
|
241
|
+
this.renderCommentHtml(html, { replaceExisting: false })
|
|
242
|
+
listCtrl.scrollToBottom()
|
|
243
|
+
listCtrl.updateStickiness()
|
|
244
|
+
listCtrl.markCommentsRead()
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
.catch((error) => {
|
|
250
|
+
alert(error?.message || 'Failed to submit comment')
|
|
251
|
+
})
|
|
252
|
+
.finally(() => {
|
|
253
|
+
this.setSendingState(false)
|
|
254
|
+
})
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
handlePointerSend(event) {
|
|
258
|
+
if (event.pointerType !== 'mouse') {
|
|
259
|
+
this.handleSend(event)
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
handleTouchSend(event) {
|
|
264
|
+
event.preventDefault()
|
|
265
|
+
this.handleSend(event)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
handleCancel(event) {
|
|
269
|
+
event.preventDefault()
|
|
270
|
+
this.resetForm()
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
handleMoveClick(event) {
|
|
274
|
+
event.preventDefault()
|
|
275
|
+
this.listController?.openMoveModal()
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
handleSearch(event) {
|
|
279
|
+
event.preventDefault()
|
|
280
|
+
const query = this.textareaTarget.value.trim()
|
|
281
|
+
this.presenceController?.clearManualTypingMessage()
|
|
282
|
+
this.listController?.applySearchQuery(query || null)
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
handleVoiceToggle(event) {
|
|
286
|
+
event.preventDefault()
|
|
287
|
+
if (this.listening) {
|
|
288
|
+
this.stopSpeechRecognition()
|
|
289
|
+
} else {
|
|
290
|
+
this.startSpeechRecognition()
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
setupSpeechRecognition() {
|
|
295
|
+
if (this.recognition) return true
|
|
296
|
+
|
|
297
|
+
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition
|
|
298
|
+
if (!SpeechRecognition) {
|
|
299
|
+
alert(this.element.dataset.speechUnavailableText || 'Speech recognition not supported')
|
|
300
|
+
return false
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
this.recognition = new SpeechRecognition()
|
|
304
|
+
this.recognition.continuous = true
|
|
305
|
+
this.recognition.interimResults = false
|
|
306
|
+
this.recognition.lang = document.documentElement.lang || 'ko-KR'
|
|
307
|
+
this.recognition.addEventListener('start', this.handleRecognitionStart)
|
|
308
|
+
this.recognition.addEventListener('end', this.handleRecognitionEnd)
|
|
309
|
+
this.recognition.addEventListener('result', this.handleRecognitionResult)
|
|
310
|
+
this.recognition.addEventListener('error', this.handleRecognitionError)
|
|
311
|
+
return true
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
startSpeechRecognition() {
|
|
315
|
+
if (!this.setupSpeechRecognition()) return
|
|
316
|
+
if (this.listening) return
|
|
317
|
+
|
|
318
|
+
this.listening = true
|
|
319
|
+
this.tryStartRecognition()
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
stopSpeechRecognition() {
|
|
323
|
+
this.listening = false
|
|
324
|
+
if (this.recognition) {
|
|
325
|
+
if (this.recognitionActive) {
|
|
326
|
+
this.recognition.stop()
|
|
327
|
+
} else {
|
|
328
|
+
if (this.recognition.abort) this.recognition.abort()
|
|
329
|
+
try {
|
|
330
|
+
this.recognition.stop()
|
|
331
|
+
} catch (error) {
|
|
332
|
+
// ignore invalid state errors from stopping before start
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
this.updateVoiceButton(false)
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
tryStartRecognition() {
|
|
340
|
+
if (!this.recognition || this.recognitionActive) return
|
|
341
|
+
try {
|
|
342
|
+
this.recognition.start()
|
|
343
|
+
} catch (error) {
|
|
344
|
+
this.handleRecognitionError(error)
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
handleRecognitionStart() {
|
|
349
|
+
this.recognitionActive = true
|
|
350
|
+
if (!this.listening) {
|
|
351
|
+
this.recognition.stop()
|
|
352
|
+
return
|
|
353
|
+
}
|
|
354
|
+
this.updateVoiceButton(true)
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
handleRecognitionEnd() {
|
|
358
|
+
this.recognitionActive = false
|
|
359
|
+
if (this.listening) {
|
|
360
|
+
this.tryStartRecognition()
|
|
361
|
+
} else {
|
|
362
|
+
this.updateVoiceButton(false)
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
handleRecognitionResult(event) {
|
|
367
|
+
const latestResult = event.results[event.resultIndex]
|
|
368
|
+
const transcript = Array.from(latestResult || [])
|
|
369
|
+
.map((result) => result?.transcript)
|
|
370
|
+
.filter(Boolean)
|
|
371
|
+
.join(' ')
|
|
372
|
+
.trim()
|
|
373
|
+
|
|
374
|
+
if (!transcript) return
|
|
375
|
+
|
|
376
|
+
const currentValue = this.textareaTarget.value
|
|
377
|
+
const needsSpace = currentValue && !currentValue.endsWith(' ')
|
|
378
|
+
this.textareaTarget.value = `${currentValue}${needsSpace ? ' ' : ''}${transcript}`
|
|
379
|
+
this.textareaTarget.dispatchEvent(new Event('input'))
|
|
380
|
+
this.focusTextarea()
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
handleRecognitionError() {
|
|
384
|
+
this.listening = false
|
|
385
|
+
this.recognitionActive = false
|
|
386
|
+
this.updateVoiceButton(false)
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
updateVoiceButton(active) {
|
|
390
|
+
if (!this.voiceButtonTarget) return
|
|
391
|
+
this.voiceButtonTarget.textContent = active
|
|
392
|
+
? this.element.dataset.voiceStopText || '중지'
|
|
393
|
+
: this.element.dataset.voiceStartText || '음성'
|
|
394
|
+
this.voiceButtonTarget.classList.toggle('voice-input-active', active)
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
teardownSpeechRecognition() {
|
|
398
|
+
if (!this.recognition) return
|
|
399
|
+
this.stopSpeechRecognition()
|
|
400
|
+
this.recognition.removeEventListener('start', this.handleRecognitionStart)
|
|
401
|
+
this.recognition.removeEventListener('end', this.handleRecognitionEnd)
|
|
402
|
+
this.recognition.removeEventListener('result', this.handleRecognitionResult)
|
|
403
|
+
this.recognition.removeEventListener('error', this.handleRecognitionError)
|
|
404
|
+
this.recognition = null
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
handleImageButtonClick(event) {
|
|
408
|
+
event.preventDefault()
|
|
409
|
+
this.cachedImageFiles = this.currentImageFiles()
|
|
410
|
+
this.imageInputTarget?.click()
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
handleImageChange() {
|
|
414
|
+
if (!this.imageInputTarget) return
|
|
415
|
+
const newFiles = Array.from(this.imageInputTarget.files || [])
|
|
416
|
+
const existingFiles = this.cachedImageFiles ?? []
|
|
417
|
+
this.setImageFiles([...existingFiles, ...newFiles])
|
|
418
|
+
this.cachedImageFiles = null
|
|
419
|
+
this.updateAttachmentList()
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
handleDragOver(event) {
|
|
423
|
+
if (this.hasImageFromDataTransfer(event.dataTransfer)) {
|
|
424
|
+
event.preventDefault()
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
handleDrop(event) {
|
|
429
|
+
const imageFiles = this.extractImageFiles(event.dataTransfer)
|
|
430
|
+
if (!imageFiles.length) return
|
|
431
|
+
event.preventDefault()
|
|
432
|
+
this.setImageFiles([...this.currentImageFiles(), ...imageFiles])
|
|
433
|
+
this.updateAttachmentList()
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
extractImageFiles(dataTransfer) {
|
|
437
|
+
if (!dataTransfer) return []
|
|
438
|
+
const files = Array.from(dataTransfer.files || []).filter((file) => file.type?.startsWith('image/'))
|
|
439
|
+
if (files.length > 0) return files
|
|
440
|
+
if (!dataTransfer.items) return []
|
|
441
|
+
return Array.from(dataTransfer.items)
|
|
442
|
+
.map((item) => (item.kind === 'file' ? item.getAsFile() : null))
|
|
443
|
+
.filter((file) => file && file.type?.startsWith('image/'))
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
hasImageFromDataTransfer(dataTransfer) {
|
|
447
|
+
return this.extractImageFiles(dataTransfer).length > 0
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
setImageFiles(files) {
|
|
451
|
+
if (!this.imageInputTarget) return
|
|
452
|
+
const dataTransfer = new DataTransfer()
|
|
453
|
+
files.forEach((file) => dataTransfer.items.add(file))
|
|
454
|
+
this.imageInputTarget.files = dataTransfer.files
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
currentImageFiles() {
|
|
458
|
+
if (!this.imageInputTarget) return []
|
|
459
|
+
return Array.from(this.imageInputTarget.files || [])
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
clearImageAttachments() {
|
|
463
|
+
this.cachedImageFiles = null
|
|
464
|
+
this.setImageFiles([])
|
|
465
|
+
this.updateAttachmentList()
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
removeImageAttachment(index) {
|
|
469
|
+
const files = this.currentImageFiles().filter((_, fileIndex) => fileIndex !== index)
|
|
470
|
+
this.setImageFiles(files)
|
|
471
|
+
this.updateAttachmentList()
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
updateAttachmentList() {
|
|
475
|
+
if (!this.attachmentListTarget) return
|
|
476
|
+
const files = this.currentImageFiles()
|
|
477
|
+
this.attachmentListTarget.innerHTML = ''
|
|
478
|
+
if (!files.length) {
|
|
479
|
+
this.attachmentListTarget.style.display = 'none'
|
|
480
|
+
return
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
this.attachmentListTarget.style.display = ''
|
|
484
|
+
files.forEach((file, index) => {
|
|
485
|
+
const item = document.createElement('span')
|
|
486
|
+
item.className = 'comment-attachment-item'
|
|
487
|
+
item.textContent = file.name
|
|
488
|
+
|
|
489
|
+
const removeButton = document.createElement('button')
|
|
490
|
+
removeButton.type = 'button'
|
|
491
|
+
removeButton.className = 'comment-attachment-remove'
|
|
492
|
+
removeButton.setAttribute('aria-label', `Remove ${file.name}`)
|
|
493
|
+
removeButton.textContent = '×'
|
|
494
|
+
removeButton.addEventListener('click', () => this.removeImageAttachment(index))
|
|
495
|
+
|
|
496
|
+
item.appendChild(removeButton)
|
|
497
|
+
this.attachmentListTarget.appendChild(item)
|
|
498
|
+
})
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
renderCommentHtml(html, { replaceExisting = false } = {}) {
|
|
502
|
+
const listElement = document.getElementById('comments-list')
|
|
503
|
+
if (!listElement || !html) return
|
|
504
|
+
|
|
505
|
+
const parser = new DOMParser()
|
|
506
|
+
const doc = parser.parseFromString(html, 'text/html')
|
|
507
|
+
const commentElement = doc.querySelector('.comment-item')
|
|
508
|
+
if (!commentElement) return
|
|
509
|
+
|
|
510
|
+
this.removePlaceholder()
|
|
511
|
+
|
|
512
|
+
const existing = listElement.querySelector(`#${commentElement.id}`)
|
|
513
|
+
if (existing) {
|
|
514
|
+
existing.replaceWith(commentElement)
|
|
515
|
+
} else {
|
|
516
|
+
listElement.appendChild(commentElement)
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
renderMarkdownInContainer(commentElement)
|
|
520
|
+
if (replaceExisting) {
|
|
521
|
+
this.listController?.markCommentsRead()
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
removePlaceholder() {
|
|
526
|
+
const listElement = document.getElementById('comments-list')
|
|
527
|
+
const placeholder = listElement?.querySelector('#no-comments')
|
|
528
|
+
if (placeholder) placeholder.remove()
|
|
529
|
+
}
|
|
530
|
+
}
|