thredded 0.13.0 → 0.14.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.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +29 -25
  3. data/app/assets/images/thredded/lock.svg +1 -0
  4. data/app/assets/javascripts/thredded/components/mention_autocompletion.es6 +2 -1
  5. data/app/assets/javascripts/thredded/components/post_form.es6 +1 -1
  6. data/app/assets/javascripts/thredded/components/time_stamps.es6 +1 -1
  7. data/app/assets/javascripts/thredded/components/topic_form.es6 +1 -1
  8. data/app/assets/javascripts/thredded/components/users_select.es6 +1 -1
  9. data/app/assets/javascripts/thredded/dependencies/autosize.js +1 -0
  10. data/app/assets/javascripts/thredded/dependencies.js +1 -1
  11. data/app/assets/stylesheets/thredded/base/_variables.scss +4 -0
  12. data/app/assets/stylesheets/thredded/components/_form-list.scss +2 -1
  13. data/app/assets/stylesheets/thredded/components/_messageboard.scss +10 -1
  14. data/app/assets/stylesheets/thredded/components/_onebox.scss +0 -9
  15. data/app/assets/stylesheets/thredded/components/_post.scss +7 -1
  16. data/app/assets/stylesheets/thredded/components/_topics.scss +12 -0
  17. data/app/commands/thredded/create_messageboard.rb +3 -3
  18. data/app/commands/thredded/mark_all_read.rb +1 -1
  19. data/app/commands/thredded/notify_following_users.rb +40 -22
  20. data/app/commands/thredded/notify_private_topic_users.rb +1 -1
  21. data/app/controllers/concerns/thredded/new_post_params.rb +1 -1
  22. data/app/controllers/concerns/thredded/new_private_post_params.rb +1 -1
  23. data/app/controllers/thredded/application_controller.rb +1 -1
  24. data/app/controllers/thredded/autocomplete_users_controller.rb +1 -1
  25. data/app/controllers/thredded/messageboard_groups_controller.rb +2 -2
  26. data/app/controllers/thredded/messageboards_controller.rb +7 -7
  27. data/app/controllers/thredded/moderation_controller.rb +1 -1
  28. data/app/controllers/thredded/post_permalinks_controller.rb +1 -1
  29. data/app/controllers/thredded/post_previews_controller.rb +3 -3
  30. data/app/controllers/thredded/posts_controller.rb +9 -5
  31. data/app/controllers/thredded/preferences_controller.rb +2 -2
  32. data/app/controllers/thredded/private_post_permalinks_controller.rb +1 -1
  33. data/app/controllers/thredded/private_post_previews_controller.rb +3 -3
  34. data/app/controllers/thredded/private_posts_controller.rb +5 -5
  35. data/app/controllers/thredded/private_topic_previews_controller.rb +1 -1
  36. data/app/controllers/thredded/read_states_controller.rb +1 -1
  37. data/app/controllers/thredded/theme_previews_controller.rb +23 -23
  38. data/app/controllers/thredded/topic_previews_controller.rb +1 -1
  39. data/app/forms/thredded/private_topic_form.rb +1 -1
  40. data/app/forms/thredded/topic_form.rb +2 -2
  41. data/app/forms/thredded/user_preferences_form.rb +2 -2
  42. data/app/helpers/thredded/render_helper.rb +1 -1
  43. data/app/jobs/thredded/auto_follow_and_notify_job.rb +3 -3
  44. data/app/mailer_previews/thredded/base_mailer_preview.rb +5 -5
  45. data/app/mailer_previews/thredded/private_topic_mailer_preview.rb +1 -5
  46. data/app/mailers/thredded/post_mailer.rb +11 -6
  47. data/app/mailers/thredded/private_topic_mailer.rb +12 -8
  48. data/app/models/concerns/thredded/content_moderation_state.rb +1 -1
  49. data/app/models/thredded/topic.rb +1 -1
  50. data/app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb +0 -11
  51. data/app/models/thredded/user_permissions/moderate/none.rb +0 -11
  52. data/app/models/thredded/user_permissions/write/all.rb +0 -11
  53. data/app/models/thredded/user_permissions/write/none.rb +0 -11
  54. data/app/models/thredded/user_topic_follow.rb +4 -2
  55. data/app/notifiers/thredded/email_notifier.rb +6 -2
  56. data/app/policies/thredded/messageboard_policy.rb +3 -1
  57. data/app/policies/thredded/post_policy.rb +5 -1
  58. data/app/view_models/thredded/private_topic_view.rb +1 -1
  59. data/app/view_models/thredded/topic_email_view.rb +0 -4
  60. data/app/views/thredded/messageboards/_form.html.erb +6 -0
  61. data/app/views/thredded/messageboards/_messageboard.html.erb +1 -5
  62. data/app/views/thredded/messageboards/_messageboard_meta.html.erb +13 -0
  63. data/app/views/thredded/moderation/users.html.erb +2 -2
  64. data/app/views/thredded/post_mailer/post_notification.html.erb +9 -6
  65. data/app/views/thredded/post_mailer/post_notification.text.erb +9 -5
  66. data/app/views/thredded/preferences/_form.html.erb +9 -9
  67. data/app/views/thredded/private_topic_mailer/message_notification.html.erb +10 -4
  68. data/app/views/thredded/private_topic_mailer/message_notification.text.erb +11 -8
  69. data/app/views/thredded/private_topics/new.html.erb +1 -1
  70. data/app/views/thredded/shared/nav/_standalone.html.erb +1 -1
  71. data/app/views/thredded/theme_previews/show.html.erb +6 -4
  72. data/app/views/thredded/topics/_topic.html.erb +2 -1
  73. data/app/views/thredded/topics/index.html.erb +6 -1
  74. data/app/views/thredded/topics/new.html.erb +1 -1
  75. data/app/views/thredded/topics/show.html.erb +4 -0
  76. data/config/locales/de.yml +249 -0
  77. data/config/locales/en.yml +43 -0
  78. data/config/locales/es.yml +45 -0
  79. data/config/locales/fr.yml +247 -0
  80. data/config/locales/pl.yml +43 -0
  81. data/config/locales/pt-BR.yml +45 -0
  82. data/config/locales/ru.yml +43 -1
  83. data/config/locales/zh-CN.yml +238 -0
  84. data/db/migrate/20160329231848_create_thredded.rb +3 -2
  85. data/db/upgrade_migrations/20170811090735_upgrade_thredded_v0_13_to_v_014.rb +21 -0
  86. data/lib/generators/thredded/install/templates/initializer.rb +3 -3
  87. data/lib/thredded/database_seeder.rb +12 -12
  88. data/lib/thredded/engine.rb +1 -1
  89. data/lib/thredded/html_pipeline/onebox_filter.rb +2 -1
  90. data/lib/thredded/version.rb +1 -1
  91. data/lib/thredded.rb +2 -1
  92. data/vendor/assets/javascripts/autosize.min.js +6 -0
  93. data/vendor/assets/javascripts/textcomplete.min.js +2 -1
  94. metadata +19 -12
  95. data/vendor/assets/javascripts/autosize.js +0 -290
  96. /data/{app/notifiers → lib}/thredded/base_notifier.rb +0 -0
@@ -0,0 +1,238 @@
1
+ ---
2
+ zh-CN:
3
+ thredded:
4
+ content_moderation_states:
5
+ content_blocked_notice: 被锁定
6
+ content_blocked_notice_with_record_html: "%{moderator} 在%{time_ago}锁定"
7
+ email_notifier:
8
+ by_email: 电子邮箱
9
+ emails:
10
+ message_notification:
11
+ html:
12
+ email_sent_reason_html: 我们给你发送这封邮件是因为 %{user} 在一个私人对话中提到你,“<a href="%{post_url}">%{topic_title}</a>”。
13
+ post_lead_html: '%{user} 在<a href="%{post_url}">“%{topic_title}”</a>中发表了新消息:'
14
+ unsubscribe_instructions_html: :thredded.emails.post_notification.html.unsubscribe_instructions_html
15
+ subject: "%{user} 在“%{topic_title}”中发表了新消息"
16
+ text:
17
+ email_sent_reason: |-
18
+ 我们给你发送这封邮件是因为 %{user} 在一个私人对话中提到你,“%{topic_title}”。
19
+
20
+ 请到以下浏览对话:
21
+ %{post_url}
22
+ post_lead: "%{user} 在“%{topic_title}”中发表了新消息:"
23
+ unsubscribe_instructions: :thredded.emails.post_notification.text.unsubscribe_instructions
24
+ post_notification:
25
+ html:
26
+ email_sent_reason_html: 我们给你发送这封邮件是因为你关注了帖子: “<a href="%{post_url}">%{topic_title}</a>”。
27
+ post_lead_html: '%{user} 在<a href="%{post_url}">“%{topic_title}”</a>中说到:'
28
+ unsubscribe_instructions_html: 退订这些邮件, 请前往<a href="%{preferences_url}">设置</a>。
29
+ subject: "“%{topic_title}”有新回复"
30
+ text:
31
+ email_sent_reason: |-
32
+ 我们给你发送这封邮件是因为你关注了这个帖子“%{topic_title}“。
33
+
34
+ 请到以下浏览帖子:
35
+ %{post_url}
36
+ post_lead: "%{user} 在“%{topic_title}”中说到:"
37
+ unsubscribe_instructions: |-
38
+ 退订这些邮件,请前往设置:
39
+ %{unsubscribe_url}
40
+ errors:
41
+ login_required: 请先登录
42
+ not_authorized: 你没有权限访问该页面
43
+ private_topic_create_denied: 你没有权限创建私人对话
44
+ private_topic_not_found: 该私人对话不存在
45
+ form:
46
+ create_btn_submitting: 创建中...
47
+ preview: 预览
48
+ update: 更新
49
+ update_btn_submitting: 更新中...
50
+ messageboard:
51
+ create: 创建一个新板块
52
+ form:
53
+ create_btn_submitting: :thredded.form.create_btn_submitting
54
+ description_label: 描述
55
+ locked_label: 锁定
56
+ locked_notice: 这个消息板被锁定。只有版主可以在这里创建新的主题。
57
+ messageboard_group_id_label: 板块分组
58
+ no_group: 没有分组
59
+ title_label: 名称
60
+ update_btn_submitting: :thredded.form.update_btn_submitting
61
+ index:
62
+ page_title: 板块
63
+ last_updated_by_html: 最近由 <span>%{user}</span> 在%{time_ago}更新
64
+ topics_and_posts_counts: "%{topics_count} 帖子 / %{posts_count} 回复"
65
+ update: :thredded.form.update
66
+ updated_notice: 板块已更新
67
+ messageboard_group:
68
+ create: 创建一个新的板块分组
69
+ form:
70
+ create_btn_submitting: :thredded.form.create_btn_submitting
71
+ saved: 板块分组 %{name} 已创建
72
+ moderation:
73
+ approve_btn: 通过
74
+ block_btn: 锁定
75
+ moderation_state:
76
+ name: 审核状态
77
+ pending:
78
+ empty:
79
+ content: 所有回复已审核
80
+ title: 干的漂亮!
81
+ post_approved_html: "%{moderator} %{time_ago}通过了该内容"
82
+ post_blocked_html: "%{moderator} %{time_ago}锁定了该内容"
83
+ post_deleted_notice: 该内容已被删除
84
+ posts_content_changed_since_moderation_html: <a href="%{post_url}">该内容</a>已发生变化,以下是被审核时的内容:
85
+ search_users:
86
+ form_label: 搜索用户
87
+ form_placeholder: :thredded.moderation.search_users.form_label
88
+ no_results_message: 未找到有关 %{query} 的用户
89
+ results_message: 有关 %{query} 的所有用户
90
+ user:
91
+ name: 用户
92
+ nav:
93
+ all_messageboards: 所有板块
94
+ edit_messageboard: 编辑板块
95
+ edit_post: 编辑内容
96
+ edit_private_topic: :thredded.nav.edit_topic
97
+ edit_topic: 编辑
98
+ mark_all_read: 标记所有为已读
99
+ moderation: 审核
100
+ moderation_activity: 状况
101
+ moderation_history: 历史
102
+ moderation_pending: 待定
103
+ moderation_users: 用户
104
+ private_topics: 私人对话
105
+ settings: 通知设置
106
+ null_user_name: 删除用户
107
+ posts:
108
+ delete: 删除回复
109
+ delete_confirm: 你确定删除该回复吗?
110
+ deleted_notice: 你的回复已删除
111
+ edit: :thredded.nav.edit_post
112
+ form:
113
+ content_label: 内容
114
+ create_btn: 提交回复
115
+ create_btn_submitting: 回复中...
116
+ title_label: 回复
117
+ update_btn: 更新
118
+ update_btn_submitting: :thredded.form.update_btn_submitting
119
+ pending_moderation_notice: 你的回复将在审核之后公开发表
120
+ quote_btn: 引用
121
+ preferences:
122
+ edit:
123
+ page_title: :thredded.nav.settings
124
+ form:
125
+ auto_follow_topics:
126
+ hint: 自动关注所有新帖子,更改该设置将会更改所有板块的设置
127
+ label: 关注所有新帖子
128
+ follow_topics_on_mention:
129
+ hint: 当有人在帖子中@你时将自动关注该帖子
130
+ label: 关注那些@你的帖子
131
+ messageboard_auto_follow_topics:
132
+ hint: 自动关注该板块的所有新帖子,这将覆盖以上所有的设置
133
+ label: 关注所有新帖子
134
+ messageboard_follow_topics_on_mention:
135
+ hint: 当有人在该板块中@你时将自动关注该帖子
136
+ label: :thredded.preferences.form.follow_topics_on_mention.label
137
+ messageboard_notifications_for_followed_topics:
138
+ label: :thredded.preferences.form.notifications_for_followed_topics.label
139
+ notifications_for_followed_topics:
140
+ label: 关注帖子的通知
141
+ notifications_for_private_topics:
142
+ label: 私人对话的通知
143
+ submit_btn: 更新设置
144
+ update_btn_submitting: :thredded.form.update_btn_submitting
145
+ global_preferences_title: 全局设置
146
+ messageboard_preferences_nav_title: 板块设置
147
+ messageboard_preferences_title_html: "<em>%{messageboard}</em> 的相关设置"
148
+ updated_notice: 你的设置已经更新
149
+ private_posts:
150
+ form:
151
+ content_label: 对话消息
152
+ create_btn: 发送对话消息
153
+ create_btn_submitting: 发送中...
154
+ update_btn_submitting: :thredded.form.update_btn_submitting
155
+ private_topics:
156
+ create: :thredded.private_topics.form.create_btn
157
+ edit: 编辑
158
+ errors:
159
+ user_ids_length: 请指定至少一个用户
160
+ form:
161
+ content_label: :thredded.private_posts.form.content_label
162
+ create_btn: :thredded.private_posts.form.create_btn
163
+ create_btn_submitting: :thredded.private_posts.form.create_btn_submitting
164
+ title_label: :thredded.topics.form.title_label
165
+ title_placeholder_new: 对话标题
166
+ title_placeholder_start: 发布新对话
167
+ update_btn: 更新
168
+ update_btn_submitting: :thredded.private_posts.form.update_btn_submitting
169
+ users_label: 会话者
170
+ users_placeholder: 选择参与此对话的用户
171
+ no_private_topics:
172
+ create_btn: 创建你的第一个私人对话
173
+ title: 你没有私人对话
174
+ updated_notice: 标题已更新
175
+ recent_activity: 最近状况
176
+ search:
177
+ form:
178
+ btn_submit: :thredded.search.form.label
179
+ label: 搜索
180
+ placeholder: 搜索帖子和回复
181
+ time_ago: "%{time}前"
182
+ topics:
183
+ create: :thredded.topics.form.create_btn
184
+ delete_confirm: 你确定删除该帖子吗?一旦删除将无法恢复
185
+ delete_topic: 删除帖子
186
+ deleted_notice: 帖子已删除
187
+ edit: 编辑帖子
188
+ follow: 关注该帖子
189
+ followed_by: 关注者:
190
+ followed_by_noone: 无人关注该帖子
191
+ followed_notice: 你在关注该帖子
192
+ following:
193
+ auto: 由于自动关注开启你已关注该帖子
194
+ manual: 你正在关注该帖子
195
+ mentioned: 由于你被@到所以你自动关注该帖子
196
+ posted: 由于你参与了回复现已关注该帖子
197
+ form:
198
+ categories_placeholder: 分类
199
+ content_label: :thredded.posts.form.content_label
200
+ create_btn: 创建新帖子
201
+ messageboard_label: 板块
202
+ title_label: 标题
203
+ title_placeholder: :thredded.topics.form.title_label
204
+ title_placeholder_start: 发布新帖子
205
+ update_btn: 更新帖子
206
+ locked:
207
+ label: 锁定
208
+ message: 该帖子被某个审核者锁定
209
+ mark_as_unread: 标记未读
210
+ not_following: 你未关注该帖子
211
+ search:
212
+ no_results_in_messageboard_message_html: 在%{messageboard}板块中未找到 <q>%{query}</q> 相关的搜索结果
213
+ no_results_message_html: 没有关于 <q>%{query}</q> 的搜索结果
214
+ page_title: 搜索结果
215
+ results_in_messageboard_message_html: 在%{messageboard}板块中关于 <q>%{query}</q> 的搜索结果
216
+ results_message_html: 关于 <q>%{query}</q> 的搜索结果
217
+ search_in_all_messageboards_btn: 搜索全站
218
+ started_by_html: "%{user} %{time_ago}发布"
219
+ sticky:
220
+ label: 置顶
221
+ unfollow: 取消关注
222
+ unfollowed_notice: 你不再关注该帖子
223
+ updated_notice: 帖子已更新
224
+ users:
225
+ currently_online: 目前在线
226
+ last_active_html: 最后活跃%{time_ago}
227
+ posted_in_topic_html: 在%{topic_link}中回复到:
228
+ posts_count:
229
+ one: 一个回复
230
+ other: "%{count} 个回复"
231
+ recent_activity: :thredded.recent_activity
232
+ started_topic_html: 发布帖子 %{topic_link}
233
+ started_topics_count:
234
+ one: 发布一个帖子
235
+ other: 发布 %{count} 个帖子
236
+ user_posted_in_topic_html: "%{user_link} 回复在 %{topic_link}"
237
+ user_since_html: 用户自%{time_ago}
238
+ user_started_topic_html: "%{user_link} 发布 %{topic_link}"
@@ -44,6 +44,7 @@ class CreateThredded < Thredded::BaseMigration
44
44
  t.references :last_topic, index: false
45
45
  t.references :messageboard_group, index: false
46
46
  t.timestamps null: false
47
+ t.boolean :locked, null: false, default: false
47
48
  t.index [:messageboard_group_id], name: :index_thredded_messageboards_on_messageboard_group_id
48
49
  t.index [:slug], name: :index_thredded_messageboards_on_slug
49
50
  end
@@ -140,7 +141,7 @@ class CreateThredded < Thredded::BaseMigration
140
141
  order: { moderation_state_changed_at: :desc },
141
142
  name: :index_thredded_user_details_for_moderations
142
143
  t.index %i[latest_activity_at], name: :index_thredded_user_details_on_latest_activity_at
143
- t.index %i[user_id], name: :index_thredded_user_details_on_user_id
144
+ t.index %i[user_id], name: :index_thredded_user_details_on_user_id, unique: true
144
145
  end
145
146
 
146
147
  create_table :thredded_messageboard_users do |t|
@@ -162,7 +163,7 @@ class CreateThredded < Thredded::BaseMigration
162
163
  t.boolean :follow_topics_on_mention, default: true, null: false
163
164
  t.boolean :auto_follow_topics, default: false, null: false
164
165
  t.timestamps null: false
165
- t.index [:user_id], name: :index_thredded_user_preferences_on_user_id
166
+ t.index [:user_id], name: :index_thredded_user_preferences_on_user_id, unique: true
166
167
  end
167
168
 
168
169
  create_table :thredded_user_messageboard_preferences do |t|
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thredded/base_migration'
4
+
5
+ class UpgradeThreddedV013ToV014 < Thredded::BaseMigration
6
+ def change
7
+ add_column :thredded_messageboards, :locked, :boolean, null: false, default: false
8
+ remove_index :thredded_user_details,
9
+ name: :index_thredded_user_details_on_user_id
10
+ add_index :thredded_user_details,
11
+ :user_id,
12
+ name: :index_thredded_user_details_on_user_id,
13
+ unique: true
14
+ remove_index :thredded_user_preferences,
15
+ name: :index_thredded_user_preferences_on_user_id
16
+ add_index :thredded_user_preferences,
17
+ :user_id,
18
+ name: :index_thredded_user_preferences_on_user_id,
19
+ unique: true
20
+ end
21
+ end
@@ -20,15 +20,15 @@ Thredded.user_name_column = :name
20
20
  # When linking to a user, Thredded will use this lambda to spit out
21
21
  # the path or url to your user. This lambda is evaluated in the view context.
22
22
  Thredded.user_path = lambda do |user|
23
- user_path = :"#{Thredded.user_class_name.underscore}_path"
23
+ user_path = :"#{Thredded.user_class_name.demodulize.underscore}_path"
24
24
  main_app.respond_to?(user_path) ? main_app.send(user_path, user) : "/users/#{user.to_param}"
25
25
  end
26
26
 
27
27
  # This method is used by Thredded controllers and views to fetch the currently signed-in user
28
- Thredded.current_user_method = :"current_#{Thredded.user_class_name.underscore}"
28
+ Thredded.current_user_method = :"current_#{Thredded.user_class_name.demodulize.underscore}"
29
29
 
30
30
  # User avatar URL. rb-gravatar gem is used by default:
31
- Thredded.avatar_url = ->(user) { Gravatar.src(user.email, 128, 'mm') }
31
+ Thredded.avatar_url = ->(user) { Gravatar.src(user.email, 156, 'mm') }
32
32
 
33
33
  # ==> Database Configuration
34
34
  # By default, thredded uses integers for record ID route constraints.
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'factory_girl_rails'
3
+ require 'factory_bot_rails'
4
4
  require_relative '../../spec/support/features/fake_content'
5
5
 
6
6
  # rubocop:disable HandleExceptions
7
7
  begin
8
- if FactoryGirl.factories.instance_variable_get(:@items).none?
8
+ if FactoryBot.factories.instance_variable_get(:@items).none?
9
9
  require_relative '../../spec/factories'
10
10
  end
11
11
  rescue NameError
@@ -71,7 +71,7 @@ module Thredded
71
71
  log "Creating #{additional_messageboards.length} additional messageboards..."
72
72
  additional_messageboards.each do |(name, description, group_id)|
73
73
  messageboard = Messageboard.create!(name: name, description: description, messageboard_group_id: group_id)
74
- FactoryGirl.create_list(:topic, 1 + rand(3), messageboard: messageboard, with_posts: 1)
74
+ FactoryBot.create_list(:topic, 1 + rand(3), messageboard: messageboard, with_posts: 1)
75
75
  end
76
76
  end
77
77
 
@@ -184,7 +184,7 @@ module Thredded
184
184
 
185
185
  def create
186
186
  log 'Creating first user...'
187
- FactoryGirl.create(:user, :approved, :admin, name: 'Joe', email: 'joe@example.com')
187
+ FactoryBot.create(:user, :approved, :admin, name: 'Joe', email: 'joe@example.com')
188
188
  end
189
189
  end
190
190
 
@@ -196,8 +196,8 @@ module Thredded
196
196
  log "Creating #{count} users..."
197
197
  approved_users_count = (count * 0.97).round
198
198
  [seeder.first_user] +
199
- FactoryGirl.create_list(:user, approved_users_count, :approved) +
200
- FactoryGirl.create_list(:user, count - approved_users_count)
199
+ FactoryBot.create_list(:user, approved_users_count, :approved) +
200
+ FactoryBot.create_list(:user, count - approved_users_count)
201
201
  end
202
202
  end
203
203
 
@@ -206,7 +206,7 @@ module Thredded
206
206
 
207
207
  def create
208
208
  log 'Creating a messageboard...'
209
- @first_messageboard = FactoryGirl.create(
209
+ @first_messageboard = FactoryBot.create(
210
210
  :messageboard,
211
211
  name: 'Main Board',
212
212
  slug: 'main-board',
@@ -220,7 +220,7 @@ module Thredded
220
220
 
221
221
  def create(count: 1, messageboard: seeder.first_messageboard)
222
222
  log "Creating #{count} topics in #{messageboard.name}..."
223
- FactoryGirl.create_list(
223
+ FactoryBot.create_list(
224
224
  :topic, count,
225
225
  messageboard: messageboard,
226
226
  user: seeder.users.sample,
@@ -234,7 +234,7 @@ module Thredded
234
234
 
235
235
  def create(count: 1)
236
236
  Array.new(count) do
237
- FactoryGirl.create(
237
+ FactoryBot.create(
238
238
  :private_topic,
239
239
  user: seeder.users[1..-1].sample,
240
240
  last_user: seeder.users.sample,
@@ -254,8 +254,8 @@ module Thredded
254
254
  posts_count = (count.min + rand(count.max + 1))
255
255
  posts = range_of_dates_in_order(up_to: last_post_at, count: posts_count).map.with_index do |written_at, i|
256
256
  author = i.zero? ? topic.user : seeder.users.sample
257
- FactoryGirl.create(:post, postable: topic, messageboard: seeder.first_messageboard,
258
- user: author, created_at: written_at, updated_at: written_at)
257
+ FactoryBot.create(:post, postable: topic, messageboard: seeder.first_messageboard,
258
+ user: author, created_at: written_at, updated_at: written_at)
259
259
  end
260
260
  topic.update!(last_user_id: posts.last.user.id, updated_at: last_post_at, last_post_at: last_post_at)
261
261
  posts
@@ -280,7 +280,7 @@ module Thredded
280
280
  seeder.private_topics.flat_map do |topic|
281
281
  (count.min + rand(count.max + 1)).times do |i|
282
282
  author = i.zero? ? topic.user : topic.users.sample
283
- FactoryGirl.create(:private_post, postable: topic, user: author)
283
+ FactoryBot.create(:private_post, postable: topic, user: author)
284
284
  end
285
285
  end
286
286
  end
@@ -6,7 +6,7 @@ module Thredded
6
6
 
7
7
  config.generators do |g|
8
8
  g.test_framework :rspec, fixture: true
9
- g.fixture_replacement :factory_girl, dir: 'spec/factories'
9
+ g.fixture_replacement :factory_bot, dir: 'spec/factories'
10
10
  g.helper false
11
11
  end
12
12
 
@@ -13,7 +13,8 @@ module Thredded
13
13
  add_attributes: {
14
14
  'iframe' => {
15
15
  'seamless' => 'seamless',
16
- 'sandbox' => 'allow-same-origin allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox',
16
+ 'sandbox' => 'allow-same-origin allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox' \
17
+ ' allow-presentation',
17
18
  }
18
19
  },
19
20
  transformers: (Sanitize::Config::ONEBOX[:transformers] || []) + [
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Thredded
4
- VERSION = '0.13.0'
4
+ VERSION = '0.14.0'
5
5
  end
data/lib/thredded.rb CHANGED
@@ -37,6 +37,7 @@ require 'thredded/view_hooks/renderer'
37
37
  # Require these explicitly so that they do not need to be required if used in the initializer:
38
38
  require 'thredded/content_formatter'
39
39
  require 'thredded/email_transformer'
40
+ require 'thredded/base_notifier'
40
41
 
41
42
  require 'thredded/collection_to_strings_with_cache_renderer'
42
43
 
@@ -96,7 +97,7 @@ module Thredded
96
97
 
97
98
  self.active_user_threshold = 5.minutes
98
99
  self.admin_column = :admin
99
- self.avatar_url = ->(user) { Gravatar.src(user.email, 128, 'mm') }
100
+ self.avatar_url = ->(user) { Gravatar.src(user.email, 156, 'mm') }
100
101
  self.layout = 'thredded/application'
101
102
  self.moderator_column = :admin
102
103
  self.user_name_column = :name
@@ -0,0 +1,6 @@
1
+ /*!
2
+ Autosize 4.0.0
3
+ license: MIT
4
+ http://www.jacklmoore.com/autosize
5
+ */
6
+ !function(e,t){if("function"==typeof define&&define.amd)define(["exports","module"],t);else if("undefined"!=typeof exports&&"undefined"!=typeof module)t(exports,module);else{var n={exports:{}};t(n.exports,n),e.autosize=n.exports}}(this,function(e,t){"use strict";function n(e){function t(){var t=window.getComputedStyle(e,null);"vertical"===t.resize?e.style.resize="none":"both"===t.resize&&(e.style.resize="horizontal"),s="content-box"===t.boxSizing?-(parseFloat(t.paddingTop)+parseFloat(t.paddingBottom)):parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth),isNaN(s)&&(s=0),l()}function n(t){var n=e.style.width;e.style.width="0px",e.offsetWidth,e.style.width=n,e.style.overflowY=t}function o(e){for(var t=[];e&&e.parentNode&&e.parentNode instanceof Element;)e.parentNode.scrollTop&&t.push({node:e.parentNode,scrollTop:e.parentNode.scrollTop}),e=e.parentNode;return t}function r(){var t=e.style.height,n=o(e),r=document.documentElement&&document.documentElement.scrollTop;e.style.height="";var i=e.scrollHeight+s;return 0===e.scrollHeight?void(e.style.height=t):(e.style.height=i+"px",u=e.clientWidth,n.forEach(function(e){e.node.scrollTop=e.scrollTop}),void(r&&(document.documentElement.scrollTop=r)))}function l(){r();var t=Math.round(parseFloat(e.style.height)),o=window.getComputedStyle(e,null),i="content-box"===o.boxSizing?Math.round(parseFloat(o.height)):e.offsetHeight;if(i!==t?"hidden"===o.overflowY&&(n("scroll"),r(),i="content-box"===o.boxSizing?Math.round(parseFloat(window.getComputedStyle(e,null).height)):e.offsetHeight):"hidden"!==o.overflowY&&(n("hidden"),r(),i="content-box"===o.boxSizing?Math.round(parseFloat(window.getComputedStyle(e,null).height)):e.offsetHeight),a!==i){a=i;var l=d("autosize:resized");try{e.dispatchEvent(l)}catch(e){}}}if(e&&e.nodeName&&"TEXTAREA"===e.nodeName&&!i.has(e)){var s=null,u=e.clientWidth,a=null,c=function(){e.clientWidth!==u&&l()},p=function(t){window.removeEventListener("resize",c,!1),e.removeEventListener("input",l,!1),e.removeEventListener("keyup",l,!1),e.removeEventListener("autosize:destroy",p,!1),e.removeEventListener("autosize:update",l,!1),Object.keys(t).forEach(function(n){e.style[n]=t[n]}),i.delete(e)}.bind(e,{height:e.style.height,resize:e.style.resize,overflowY:e.style.overflowY,overflowX:e.style.overflowX,wordWrap:e.style.wordWrap});e.addEventListener("autosize:destroy",p,!1),"onpropertychange"in e&&"oninput"in e&&e.addEventListener("keyup",l,!1),window.addEventListener("resize",c,!1),e.addEventListener("input",l,!1),e.addEventListener("autosize:update",l,!1),e.style.overflowX="hidden",e.style.wordWrap="break-word",i.set(e,{destroy:p,update:l}),t()}}function o(e){var t=i.get(e);t&&t.destroy()}function r(e){var t=i.get(e);t&&t.update()}var i="function"==typeof Map?new Map:function(){var e=[],t=[];return{has:function(t){return e.indexOf(t)>-1},get:function(n){return t[e.indexOf(n)]},set:function(n,o){e.indexOf(n)===-1&&(e.push(n),t.push(o))},delete:function(n){var o=e.indexOf(n);o>-1&&(e.splice(o,1),t.splice(o,1))}}}(),d=function(e){return new Event(e,{bubbles:!0})};try{new Event("test")}catch(e){d=function(e){var t=document.createEvent("Event");return t.initEvent(e,!0,!1),t}}var l=null;"undefined"==typeof window||"function"!=typeof window.getComputedStyle?(l=function(e){return e},l.destroy=function(e){return e},l.update=function(e){return e}):(l=function(e,t){return e&&Array.prototype.forEach.call(e.length?e:[e],function(e){return n(e,t)}),e},l.destroy=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],o),e},l.update=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],r),e}),t.exports=l});
@@ -1 +1,2 @@
1
- !function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=11)}([function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=function(){function e(t,r,i){n(this,e),this.data=t,this.term=r,this.strategy=i}return r(e,[{key:"replace",value:function(e,t){var n=this.strategy.replace(this.data);if(null!==n){Array.isArray(n)&&(t=n[1]+t,n=n[0]);var r=this.strategy.matchText(e);return n=n.replace(/\$&/g,r[0]).replace(/\$(\d+)/g,function(e,t){return r[parseInt(t,10)]}),[[e.slice(0,r.index),n,e.slice(r.index+r[0].length)].join(""),t]}}},{key:"render",value:function(){return this.strategy.template(this.data,this.term)}}]),e}();t.default=i},function(e){"use strict";function t(){}function n(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function r(){this._events=new t,this._eventsCount=0}var i=Object.prototype.hasOwnProperty,o="~";Object.create&&(t.prototype=Object.create(null),(new t).__proto__||(o=!1)),r.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)i.call(e,t)&&n.push(o?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},r.prototype.listeners=function(e,t){var n=o?o+e:e,r=this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var i=0,s=r.length,u=new Array(s);i<s;i++)u[i]=r[i].fn;return u},r.prototype.emit=function(e,t,n,r,i,s){var u=o?o+e:e;if(!this._events[u])return!1;var a,l,c=this._events[u],h=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),h){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,i),!0;case 6:return c.fn.call(c.context,t,n,r,i,s),!0}for(l=1,a=new Array(h-1);l<h;l++)a[l-1]=arguments[l];c.fn.apply(c.context,a)}else{var f,d=c.length;for(l=0;l<d;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),h){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;case 4:c[l].fn.call(c[l].context,t,n,r);break;default:if(!a)for(f=1,a=new Array(h-1);f<h;f++)a[f-1]=arguments[f];c[l].fn.apply(c[l].context,a)}}return!0},r.prototype.on=function(e,t,r){var i=new n(t,r||this),s=o?o+e:e;return this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],i]:this._events[s].push(i):(this._events[s]=i,this._eventsCount++),this},r.prototype.once=function(e,t,r){var i=new n(t,r||this,!0),s=o?o+e:e;return this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],i]:this._events[s].push(i):(this._events[s]=i,this._eventsCount++),this},r.prototype.removeListener=function(e,n,r,i){var s=o?o+e:e;if(!this._events[s])return this;if(!n)return 0==--this._eventsCount?this._events=new t:delete this._events[s],this;var u=this._events[s];if(u.fn)u.fn!==n||i&&!u.once||r&&u.context!==r||(0==--this._eventsCount?this._events=new t:delete this._events[s]);else{for(var a=0,l=[],c=u.length;a<c;a++)(u[a].fn!==n||i&&!u[a].once||r&&u[a].context!==r)&&l.push(u[a]);l.length?this._events[s]=1===l.length?l[0]:l:0==--this._eventsCount?this._events=new t:delete this._events[s]}return this},r.prototype.removeAllListeners=function(e){var n;return e?(n=o?o+e:e,this._events[n]&&(0==--this._eventsCount?this._events=new t:delete this._events[n])):(this._events=new t,this._eventsCount=0),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prototype.setMaxListeners=function(){return this},r.prefixed=o,r.EventEmitter=r,e.exports=r},function(e,t){"use strict";function n(e){var t=e.getBoundingClientRect(),n=e.ownerDocument,r=n.defaultView,i=n.documentElement,o={top:t.top+r.pageYOffset,left:t.left+r.pageXOffset};return i&&(o.top-=i.clientTop,o.left-=i.clientLeft),o}function r(e){return e>=o&&e<=s}function i(e){var t=window.getComputedStyle(e);if(r(t.lineHeight.charCodeAt(0)))return r(t.lineHeight.charCodeAt(t.lineHeight.length-1))?parseFloat(t.lineHeight,10)*parseFloat(t.fontSize,10):parseFloat(t.lineHeight,10);var n=document.body;if(!n)return 0;var i=document.createElement(e.nodeName);i.innerHTML="&nbsp;",i.style.fontSize=t.fontSize,i.style.fontFamily=t.fontFamily,n.appendChild(i);var o=i.offsetHeight;return n.removeChild(i),o}Object.defineProperty(t,"__esModule",{value:!0}),t.calculateElementOffset=n,t.getLineHeightPx=i;var o=(t.createCustomEvent=function(){return"function"==typeof window.CustomEvent?function(e,t){return new document.defaultView.CustomEvent(e,{cancelable:t&&t.cancelable||!1,detail:t&&t.detail||void 0})}:function(e,t){var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!1,t&&t.cancelable||!1,t&&t.detail||void 0),n}}(),"0".charCodeAt(0)),s="9".charCodeAt(0)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(2),l=n(0),c=(r(l),n(1)),h=r(c),f=function(e){function t(){return i(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return s(t,e),u(t,[{key:"destroy",value:function(){return this}},{key:"applySearchResult",value:function(){throw new Error("Not implemented.")}},{key:"getCursorOffset",value:function(){throw new Error("Not implemented.")}},{key:"getBeforeCursor",value:function(){throw new Error("Not implemented.")}},{key:"getAfterCursor",value:function(){throw new Error("Not implemented.")}},{key:"emitMoveEvent",value:function(e){var t=(0,a.createCustomEvent)("move",{cancelable:!0,detail:{code:e}});return this.emit("move",t),t}},{key:"emitEnterEvent",value:function(){var e=(0,a.createCustomEvent)("enter",{cancelable:!0});return this.emit("enter",e),e}},{key:"emitChangeEvent",value:function(){var e=(0,a.createCustomEvent)("change",{detail:{beforeCursor:this.getBeforeCursor()}});return this.emit("change",e),e}},{key:"emitEscEvent",value:function(){var e=(0,a.createCustomEvent)("esc",{cancelable:!0});return this.emit("esc",e),e}},{key:"getCode",value:function(e){return 8===e.keyCode?"BS":9===e.keyCode?"ENTER":13===e.keyCode?"ENTER":27===e.keyCode?"ESC":38===e.keyCode?"UP":40===e.keyCode?"DOWN":78===e.keyCode&&e.ctrlKey?"DOWN":80===e.keyCode&&e.ctrlKey?"UP":"OTHER"}}]),t}(h.default);t.default=f},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e){return e}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(12),u=function(e){return e&&e.__esModule?e:{default:e}}(s),a=function(){function e(t){r(this,e),this.props=t,this.cache=t.cache?{}:null}return o(e,[{key:"destroy",value:function(){return this.cache=null,this}},{key:"buildQuery",value:function(e){if("function"==typeof this.props.context){var t=this.props.context(e);if("string"==typeof t)e=t;else if(!t)return null}var n=this.matchText(e);return n?new u.default(this,n[this.index],n):null}},{key:"search",value:function(e,t,n){this.cache?this.searchWithCache(e,t,n):this.props.search(e,t,n)}},{key:"replace",value:function(e){return this.props.replace(e)}},{key:"searchWithCache",value:function(e,t,n){var r=this;this.cache&&this.cache[e]?t(this.cache[e]):this.props.search(e,function(n){r.cache&&(r.cache[e]=n),t(n)},n)}},{key:"matchText",value:function(e){return"function"==typeof this.match?this.match(e):e.match(this.match)}},{key:"match",get:function(){return this.props.match}},{key:"index",get:function(){return"number"==typeof this.props.index?this.props.index:2}},{key:"template",get:function(){return this.props.template||i}}]),e}();t.default=a},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,n,r)}if("value"in i)return i.value;var s=i.get;if(void 0!==s)return s.call(r)},l=n(3),c=r(l),h=n(2),f=n(0),d=(r(f),n(13)),p=["onInput","onKeydown"],v=function(e){function t(e){i(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.el=e,p.forEach(function(e){n[e]=n[e].bind(n)}),n.startListening(),n}return s(t,e),u(t,[{key:"destroy",value:function(){return a(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this),this.stopListening(),this.el=null,this}},{key:"applySearchResult",value:function(e){var t=e.replace(this.getBeforeCursor(),this.getAfterCursor());Array.isArray(t)&&(this.el.value=t[0]+t[1],this.el.selectionStart=this.el.selectionEnd=t[0].length,this.el.dispatchEvent(new Event("input"))),this.el.focus()}},{key:"getCursorOffset",value:function(){var e=(0,h.calculateElementOffset)(this.el),t=this.getElScroll(),n=this.getCursorPosition(),r=(0,h.getLineHeightPx)(this.el),i=e.top-t.top+n.top+r,o=e.left-t.left+n.left;if("rtl"!==this.el.dir)return{top:i,left:o,lineHeight:r};if(document.documentElement){return{top:i,right:document.documentElement.clientWidth-o,lineHeight:r}}}},{key:"getBeforeCursor",value:function(){return this.el.value.substring(0,this.el.selectionEnd)}},{key:"getAfterCursor",value:function(){return this.el.value.substring(this.el.selectionEnd)}},{key:"getElScroll",value:function(){return{top:this.el.scrollTop,left:this.el.scrollLeft}}},{key:"getCursorPosition",value:function(){return d(this.el,this.el.selectionEnd)}},{key:"onInput",value:function(){this.emitChangeEvent()}},{key:"onKeydown",value:function(e){var t=this.getCode(e),n=void 0;"UP"===t||"DOWN"===t?n=this.emitMoveEvent(t):"ENTER"===t?n=this.emitEnterEvent():"ESC"===t&&(n=this.emitEscEvent()),n&&n.defaultPrevented&&e.preventDefault()}},{key:"startListening",value:function(){this.el.addEventListener("input",this.onInput),this.el.addEventListener("keydown",this.onKeydown)}},{key:"stopListening",value:function(){this.el.removeEventListener("input",this.onInput),this.el.removeEventListener("keydown",this.onKeydown)}}]),t}(c.default);t.default=v},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(8),l=r(a),c=n(3),h=(r(c),n(9)),f=r(h),d=n(4),p=r(d),v=n(0),y=(r(v),n(1)),m=r(y),g=["handleChange","handleEnter","handleEsc","handleHit","handleMove","handleSelect"],b=function(e){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this,t);var r=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return r.completer=new l.default,r.isQueryInFlight=!1,r.nextPendingQuery=null,r.dropdown=new f.default(n.dropdown||{}),r.editor=e,r.options=n,g.forEach(function(e){r[e]=r[e].bind(r)}),r.startListening(),r}return s(t,e),u(t,[{key:"destroy",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.completer.destroy(),this.dropdown.destroy(),e&&this.editor.destroy(),this.stopListening(),this}},{key:"register",value:function(e){var t=this;return e.forEach(function(e){t.completer.registerStrategy(new p.default(e))}),this}},{key:"trigger",value:function(e){return this.isQueryInFlight?this.nextPendingQuery=e:(this.isQueryInFlight=!0,this.nextPendingQuery=null,this.completer.run(e)),this}},{key:"handleHit",value:function(e){var t=e.searchResults;t.length?this.dropdown.render(t,this.editor.getCursorOffset()):this.dropdown.deactivate(),this.isQueryInFlight=!1,null!==this.nextPendingQuery&&this.trigger(this.nextPendingQuery)}},{key:"handleMove",value:function(e){"UP"===e.detail.code?this.dropdown.up(e):this.dropdown.down(e)}},{key:"handleEnter",value:function(e){var t=this.dropdown.getActiveItem();t&&(this.dropdown.select(t),e.preventDefault())}},{key:"handleEsc",value:function(e){this.dropdown.shown&&(this.dropdown.deactivate(),e.preventDefault())}},{key:"handleChange",value:function(e){this.trigger(e.detail.beforeCursor)}},{key:"handleSelect",value:function(e){this.emit("select",e),e.defaultPrevented||this.editor.applySearchResult(e.detail.searchResult)}},{key:"startListening",value:function(){var e=this;this.editor.on("move",this.handleMove).on("enter",this.handleEnter).on("esc",this.handleEsc).on("change",this.handleChange),this.dropdown.on("select",this.handleSelect),["show","shown","render","rendered","selected","hidden","hide"].forEach(function(t){e.dropdown.on(t,function(){return e.emit(t)})}),this.completer.on("hit",this.handleHit)}},{key:"stopListening",value:function(){this.completer.removeAllListeners(),this.dropdown.removeAllListeners(),this.editor.removeListener("move",this.handleMove).removeListener("enter",this.handleEnter).removeListener("esc",this.handleEsc).removeListener("change",this.handleChange)}}]),t}(m.default);t.default=b},function(e){var t;t=function(){return this}();try{t=t||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(t=window)}e.exports=t},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(1),l=r(a),c=n(4),h=(r(c),n(0)),f=(r(h),["handleQueryResult"]),d=function(e){function t(){i(this,t);var e=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.strategies=[],f.forEach(function(t){e[t]=e[t].bind(e)}),e}return s(t,e),u(t,[{key:"destroy",value:function(){return this.strategies.forEach(function(e){return e.destroy()}),this}},{key:"registerStrategy",value:function(e){return this.strategies.push(e),this}},{key:"run",value:function(e){var t=this.extractQuery(e);t?t.execute(this.handleQueryResult):this.handleQueryResult([])}},{key:"extractQuery",value:function(e){for(var t=0;t<this.strategies.length;t++){var n=this.strategies[t].buildQuery(e);if(n)return n}return null}},{key:"handleQueryResult",value:function(e){this.emit("hit",{searchResults:e})}}]),t}(l.default);t.default=d},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(10),l=r(a),c=n(0),h=(r(c),n(2)),f=n(1),d=r(f),p="dropdown-menu textcomplete-dropdown",v=function(e){function t(e){var n=e.className,r=void 0===n?p:n,s=e.footer,u=e.header,a=e.maxCount,l=void 0===a?10:a,c=e.placement,h=e.rotate,f=void 0===h||h,d=e.style;i(this,t);var v=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return v.shown=!1,v.items=[],v.footer=s,v.header=u,v.maxCount=l,v.el.className=r,v.rotate=f,v.placement=c,d&&Object.keys(d).forEach(function(e){v.el.style[e]=d[e]}),v}return s(t,e),u(t,null,[{key:"createElement",value:function(){var e=document.createElement("ul"),t=e.style;t.display="none",t.position="absolute",t.zIndex="10000";var n=document.body;return n&&n.appendChild(e),e}}]),u(t,[{key:"destroy",value:function(){var e=this.el.parentNode;return e&&e.removeChild(this.el),this.clear()._el=null,this}},{key:"render",value:function(e,t){var n=(0,h.createCustomEvent)("render",{cancelable:!0});if(this.emit("render",n),n.defaultPrevented)return this;var r=e.map(function(e){return e.data}),i=e.slice(0,this.maxCount||e.length).map(function(e){return new l.default(e)});return this.clear().setStrategyId(e[0]).renderEdge(r,"header").append(i).renderEdge(r,"footer").setOffset(t).show(),this.emit("rendered",(0,h.createCustomEvent)("rendered")),this}},{key:"deactivate",value:function(){return this.hide().clear()}},{key:"select",value:function(e){var t={searchResult:e.searchResult},n=(0,h.createCustomEvent)("select",{cancelable:!0,detail:t});return this.emit("select",n),n.defaultPrevented?this:(this.deactivate(),this.emit("selected",(0,h.createCustomEvent)("selected",{detail:t})),this)}},{key:"up",value:function(e){return this.shown?this.moveActiveItem("prev",e):this}},{key:"down",value:function(e){return this.shown?this.moveActiveItem("next",e):this}},{key:"getActiveItem",value:function(){return this.items.find(function(e){return e.active})}},{key:"append",value:function(e){var t=this,n=document.createDocumentFragment();return e.forEach(function(e){t.items.push(e),e.appended(t),n.appendChild(e.el)}),this.el.appendChild(n),this}},{key:"setOffset",value:function(e){if(e.left?this.el.style.left=e.left+"px":e.right&&(this.el.style.right=e.right+"px"),this.isPlacementTop()){var t=document.documentElement;t&&(this.el.style.bottom=t.clientHeight-e.top+e.lineHeight+"px")}else this.el.style.top=e.top+"px";return this}},{key:"show",value:function(){if(!this.shown){var e=(0,h.createCustomEvent)("show",{cancelable:!0});if(this.emit("show",e),e.defaultPrevented)return this;this.el.style.display="block",this.shown=!0,this.emit("shown",(0,h.createCustomEvent)("shown"))}return this}},{key:"hide",value:function(){if(this.shown){var e=(0,h.createCustomEvent)("hide",{cancelable:!0});if(this.emit("hide",e),e.defaultPrevented)return this;this.el.style.display="none",this.shown=!1,this.emit("hidden",(0,h.createCustomEvent)("hidden"))}return this}},{key:"clear",value:function(){return this.el.innerHTML="",this.items.forEach(function(e){return e.destroy()}),this.items=[],this}},{key:"moveActiveItem",value:function(e,t){var n=this.getActiveItem(),r=void 0;return r=n?n[e]:"next"===e?this.items[0]:this.items[this.items.length-1],r&&(r.activate(),t.preventDefault()),this}},{key:"setStrategyId",value:function(e){var t=e&&e.strategy.props.id;return t?this.el.setAttribute("data-strategy",t):this.el.removeAttribute("data-strategy"),this}},{key:"renderEdge",value:function(e,t){var n=("header"===t?this.header:this.footer)||"",r="function"==typeof n?n(e):n,i=document.createElement("li");return i.classList.add("textcomplete-"+t),i.innerHTML=r,this.el.appendChild(i),this}},{key:"isPlacementTop",value:function(){return"top"===this.placement}},{key:"el",get:function(){return this._el||(this._el=t.createElement()),this._el}}]),t}(d.default);t.default=v},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.CLASS_NAME=void 0;var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(0),s=(function(e){e&&e.__esModule}(o),t.CLASS_NAME="textcomplete-item"),u=s+" active",a=["onClick","onMouseover"],l=function(){function e(t){var n=this;r(this,e),this.searchResult=t,this.active=!1,a.forEach(function(e){n[e]=n[e].bind(n)})}return i(e,[{key:"destroy",value:function(){this.el.removeEventListener("mousedown",this.onClick,!1),this.el.removeEventListener("mouseover",this.onMouseover,!1),this.el.removeEventListener("touchstart",this.onClick,!1),this._el=null}},{key:"appended",value:function(e){this.dropdown=e,this.siblings=e.items,this.index=this.siblings.length-1}},{key:"activate",value:function(){if(!this.active){var e=this.dropdown.getActiveItem();e&&e.deactivate(),this.active=!0,this.el.className=u}return this}},{key:"deactivate",value:function(){return this.active&&(this.active=!1,this.el.className=s),this}},{key:"onClick",value:function(e){e.preventDefault(),this.dropdown.select(this)}},{key:"onMouseover",value:function(){this.activate()}},{key:"el",get:function(){if(this._el)return this._el;var e=document.createElement("li");e.className=this.active?u:s;var t=document.createElement("a");return t.innerHTML=this.searchResult.render(),e.appendChild(t),this._el=e,e.addEventListener("mousedown",this.onClick),e.addEventListener("mouseover",this.onMouseover),e.addEventListener("touchstart",this.onClick),e}},{key:"next",get:function(){var e=void 0;if(this.index===this.siblings.length-1){if(!this.dropdown.rotate)return null;e=0}else e=this.index+1;return this.siblings[e]}},{key:"prev",get:function(){var e=void 0;if(0===this.index){if(!this.dropdown.rotate)return null;e=this.siblings.length-1}else e=this.index-1;return this.siblings[e]}}]),e}();t.default=l},function(e,t,n){"use strict";(function(e){function t(e){return e&&e.__esModule?e:{default:e}}var r=n(6),i=t(r),o=n(5),s=t(o),u=void 0;u=e.Textcomplete&&e.Textcomplete.editors?e.Textcomplete.editors:{},u.Textarea=s.default,e.Textcomplete=i.default,e.Textcomplete.editors=u}).call(t,n(7))},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(0),s=function(e){return e&&e.__esModule?e:{default:e}}(o),u=function(){function e(t,n,i){r(this,e),this.strategy=t,this.term=n,this.match=i}return i(e,[{key:"execute",value:function(e){var t=this;this.strategy.search(this.term,function(n){e(n.map(function(e){return new s.default(e,t.term,t.strategy)}))},this.match)}}]),e}();t.default=u},function(e){!function(){function t(e,t,o){if(!r)throw new Error("textarea-caret-position#getCaretCoordinates should only be called in a browser");var s=o&&o.debug||!1;if(s){var u=document.querySelector("#input-textarea-caret-position-mirror-div");u&&u.parentNode.removeChild(u)}var a=document.createElement("div");a.id="input-textarea-caret-position-mirror-div",document.body.appendChild(a);var l=a.style,c=window.getComputedStyle?getComputedStyle(e):e.currentStyle;l.whiteSpace="pre-wrap","INPUT"!==e.nodeName&&(l.wordWrap="break-word"),l.position="absolute",s||(l.visibility="hidden"),n.forEach(function(e){l[e]=c[e]}),i?e.scrollHeight>parseInt(c.height)&&(l.overflowY="scroll"):l.overflow="hidden",a.textContent=e.value.substring(0,t),"INPUT"===e.nodeName&&(a.textContent=a.textContent.replace(/\s/g," "));var h=document.createElement("span");h.textContent=e.value.substring(t)||".",a.appendChild(h);var f={top:h.offsetTop+parseInt(c.borderTopWidth),left:h.offsetLeft+parseInt(c.borderLeftWidth)};return s?h.style.backgroundColor="#aaa":document.body.removeChild(a),f}var n=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize","MozTabSize"],r="undefined"!=typeof window,i=r&&null!=window.mozInnerScreenX;void 0!==e&&void 0!==e.exports?e.exports=t:r&&(window.getCaretCoordinates=t)}()}]);
1
+ /** https://unpkg.com/textcomplete@0.14.5/dist/textcomplete.min.js **/
2
+ !function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=6)}([function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(2),s=(function(e){e&&e.__esModule}(o),function(){function e(t,n,i){r(this,e),this.data=t,this.term=n,this.strategy=i}return i(e,[{key:"replace",value:function(e,t){var n=this.strategy.replace(this.data);if(null!==n){Array.isArray(n)&&(t=n[1]+t,n=n[0]);var r=this.strategy.matchText(e);if(r)return n=n.replace(/\$&/g,r[0]).replace(/\$(\d)/g,function(e,t){return r[parseInt(t,10)]}),[[e.slice(0,r.index),n,e.slice(r.index+r[0].length)].join(""),t]}}},{key:"render",value:function(){return this.strategy.template(this.data,this.term)}}]),e}());t.default=s},function(e){"use strict";function t(){}function n(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function r(){this._events=new t,this._eventsCount=0}var i=Object.prototype.hasOwnProperty,o="~";Object.create&&(t.prototype=Object.create(null),(new t).__proto__||(o=!1)),r.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)i.call(e,t)&&n.push(o?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},r.prototype.listeners=function(e,t){var n=o?o+e:e,r=this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var i=0,s=r.length,u=new Array(s);i<s;i++)u[i]=r[i].fn;return u},r.prototype.emit=function(e,t,n,r,i,s){var u=o?o+e:e;if(!this._events[u])return!1;var a,l,c=this._events[u],h=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),h){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,i),!0;case 6:return c.fn.call(c.context,t,n,r,i,s),!0}for(l=1,a=new Array(h-1);l<h;l++)a[l-1]=arguments[l];c.fn.apply(c.context,a)}else{var f,d=c.length;for(l=0;l<d;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),h){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;case 4:c[l].fn.call(c[l].context,t,n,r);break;default:if(!a)for(f=1,a=new Array(h-1);f<h;f++)a[f-1]=arguments[f];c[l].fn.apply(c[l].context,a)}}return!0},r.prototype.on=function(e,t,r){var i=new n(t,r||this),s=o?o+e:e;return this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],i]:this._events[s].push(i):(this._events[s]=i,this._eventsCount++),this},r.prototype.once=function(e,t,r){var i=new n(t,r||this,!0),s=o?o+e:e;return this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],i]:this._events[s].push(i):(this._events[s]=i,this._eventsCount++),this},r.prototype.removeListener=function(e,n,r,i){var s=o?o+e:e;if(!this._events[s])return this;if(!n)return 0==--this._eventsCount?this._events=new t:delete this._events[s],this;var u=this._events[s];if(u.fn)u.fn!==n||i&&!u.once||r&&u.context!==r||(0==--this._eventsCount?this._events=new t:delete this._events[s]);else{for(var a=0,l=[],c=u.length;a<c;a++)(u[a].fn!==n||i&&!u[a].once||r&&u[a].context!==r)&&l.push(u[a]);l.length?this._events[s]=1===l.length?l[0]:l:0==--this._eventsCount?this._events=new t:delete this._events[s]}return this},r.prototype.removeAllListeners=function(e){var n;return e?(n=o?o+e:e,this._events[n]&&(0==--this._eventsCount?this._events=new t:delete this._events[n])):(this._events=new t,this._eventsCount=0),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prototype.setMaxListeners=function(){return this},r.prefixed=o,r.EventEmitter=r,e.exports=r},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e){return e}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(10),u=function(e){return e&&e.__esModule?e:{default:e}}(s),a=function(){function e(t){r(this,e),this.props=t,this.cache=t.cache?{}:null}return o(e,[{key:"destroy",value:function(){return this.cache=null,this}},{key:"buildQuery",value:function(e){if("function"==typeof this.props.context){var t=this.props.context(e);if("string"==typeof t)e=t;else if(!t)return null}var n=this.matchText(e);return n?new u.default(this,n[this.index],n):null}},{key:"search",value:function(e,t,n){this.cache?this.searchWithCache(e,t,n):this.props.search(e,t,n)}},{key:"replace",value:function(e){return this.props.replace(e)}},{key:"searchWithCache",value:function(e,t,n){var r=this;this.cache&&this.cache[e]?t(this.cache[e]):this.props.search(e,function(n){r.cache&&(r.cache[e]=n),t(n)},n)}},{key:"matchText",value:function(e){return"function"==typeof this.match?this.match(e):e.match(this.match)}},{key:"match",get:function(){return this.props.match}},{key:"index",get:function(){return"number"==typeof this.props.index?this.props.index:2}},{key:"template",get:function(){return this.props.template||i}}]),e}();t.default=a},function(e,t){"use strict";function n(e){var t=e.getBoundingClientRect(),n=e.ownerDocument,r=n.defaultView,i=n.documentElement,o={top:t.top+r.pageYOffset,left:t.left+r.pageXOffset};return i&&(o.top-=i.clientTop,o.left-=i.clientLeft),o}function r(e){return e>=o&&e<=s}function i(e){var t=window.getComputedStyle(e);if(r(t.lineHeight.charCodeAt(0)))return r(t.lineHeight.charCodeAt(t.lineHeight.length-1))?parseFloat(t.lineHeight)*parseFloat(t.fontSize):parseFloat(t.lineHeight);var n=document.body;if(!n)return 0;var i=document.createElement(e.nodeName);i.innerHTML="&nbsp;",i.style.fontSize=t.fontSize,i.style.fontFamily=t.fontFamily,n.appendChild(i);var o=i.offsetHeight;return n.removeChild(i),o}Object.defineProperty(t,"__esModule",{value:!0}),t.calculateElementOffset=n,t.getLineHeightPx=i;var o=(t.createCustomEvent=function(){return"function"==typeof window.CustomEvent?function(e,t){return new document.defaultView.CustomEvent(e,{cancelable:t&&t.cancelable||!1,detail:t&&t.detail||void 0})}:function(e,t){var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!1,t&&t.cancelable||!1,t&&t.detail||void 0),n}}(),"0".charCodeAt(0)),s="9".charCodeAt(0)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(1),l=r(a),c=n(3),h=n(0),f=(r(h),function(e){function t(){return i(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return s(t,e),u(t,[{key:"destroy",value:function(){return this}},{key:"applySearchResult",value:function(){throw new Error("Not implemented.")}},{key:"getCursorOffset",value:function(){throw new Error("Not implemented.")}},{key:"getBeforeCursor",value:function(){throw new Error("Not implemented.")}},{key:"emitMoveEvent",value:function(e){var t=(0,c.createCustomEvent)("move",{cancelable:!0,detail:{code:e}});return this.emit("move",t),t}},{key:"emitEnterEvent",value:function(){var e=(0,c.createCustomEvent)("enter",{cancelable:!0});return this.emit("enter",e),e}},{key:"emitChangeEvent",value:function(){var e=(0,c.createCustomEvent)("change",{detail:{beforeCursor:this.getBeforeCursor()}});return this.emit("change",e),e}},{key:"emitEscEvent",value:function(){var e=(0,c.createCustomEvent)("esc",{cancelable:!0});return this.emit("esc",e),e}},{key:"getCode",value:function(e){return 9===e.keyCode?"ENTER":13===e.keyCode?"ENTER":27===e.keyCode?"ESC":38===e.keyCode?"UP":40===e.keyCode?"DOWN":78===e.keyCode&&e.ctrlKey?"DOWN":80===e.keyCode&&e.ctrlKey?"UP":"OTHER"}}]),t}(l.default));t.default=f},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(1),l=r(a),c=n(11),h=r(c),f=n(0),d=(r(f),n(3)),p="dropdown-menu textcomplete-dropdown",v=function(e){function t(e){i(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));n.shown=!1,n.items=[],n.activeItem=null,n.footer=e.footer,n.header=e.header,n.maxCount=e.maxCount||10,n.el.className=e.className||p,n.rotate=!e.hasOwnProperty("rotate")||e.rotate,n.placement=e.placement;var r=e.style;return r&&Object.keys(r).forEach(function(e){n.el.style[e]=r[e]}),n}return s(t,e),u(t,null,[{key:"createElement",value:function(){var e=document.createElement("ul"),t=e.style;t.display="none",t.position="absolute",t.zIndex="10000";var n=document.body;return n&&n.appendChild(e),e}}]),u(t,[{key:"destroy",value:function(){var e=this.el.parentNode;return e&&e.removeChild(this.el),this.clear()._el=null,this}},{key:"render",value:function(e,t){var n=(0,d.createCustomEvent)("render",{cancelable:!0});if(this.emit("render",n),n.defaultPrevented)return this;var r=e.map(function(e){return e.data}),i=e.slice(0,this.maxCount||e.length).map(function(e){return new h.default(e)});return this.clear().setStrategyId(e[0]).renderEdge(r,"header").append(i).renderEdge(r,"footer").setOffset(t).show(),this.emit("rendered",(0,d.createCustomEvent)("rendered")),this}},{key:"deactivate",value:function(){return this.hide().clear()}},{key:"select",value:function(e){var t={searchResult:e.searchResult},n=(0,d.createCustomEvent)("select",{cancelable:!0,detail:t});return this.emit("select",n),n.defaultPrevented?this:(this.deactivate(),this.emit("selected",(0,d.createCustomEvent)("selected",{detail:t})),this)}},{key:"up",value:function(e){return this.shown?this.moveActiveItem("prev",e):this}},{key:"down",value:function(e){return this.shown?this.moveActiveItem("next",e):this}},{key:"getActiveItem",value:function(){return this.activeItem}},{key:"append",value:function(e){var t=this,n=document.createDocumentFragment();return e.forEach(function(e){t.items.push(e),e.appended(t),n.appendChild(e.el)}),this.el.appendChild(n),this}},{key:"setOffset",value:function(e){if(e.left?this.el.style.left=e.left+"px":e.right&&(this.el.style.right=e.right+"px"),this.isPlacementTop()){var t=document.documentElement;t&&(this.el.style.bottom=t.clientHeight-e.top+e.lineHeight+"px")}else this.el.style.top=e.top+"px";return this}},{key:"show",value:function(){if(!this.shown){var e=(0,d.createCustomEvent)("show",{cancelable:!0});if(this.emit("show",e),e.defaultPrevented)return this;this.el.style.display="block",this.shown=!0,this.emit("shown",(0,d.createCustomEvent)("shown"))}return this}},{key:"hide",value:function(){if(this.shown){var e=(0,d.createCustomEvent)("hide",{cancelable:!0});if(this.emit("hide",e),e.defaultPrevented)return this;this.el.style.display="none",this.shown=!1,this.emit("hidden",(0,d.createCustomEvent)("hidden"))}return this}},{key:"clear",value:function(){return this.el.innerHTML="",this.items.forEach(function(e){return e.destroy()}),this.items=[],this}},{key:"moveActiveItem",value:function(e,t){var n="next"===e?this.activeItem?this.activeItem.next:this.items[0]:this.activeItem?this.activeItem.prev:this.items[this.items.length-1];return n&&(n.activate(),t.preventDefault()),this}},{key:"setStrategyId",value:function(e){var t=e&&e.strategy.props.id;return t?this.el.setAttribute("data-strategy",t):this.el.removeAttribute("data-strategy"),this}},{key:"renderEdge",value:function(e,t){var n=("header"===t?this.header:this.footer)||"",r="function"==typeof n?n(e):n,i=document.createElement("li");return i.classList.add("textcomplete-"+t),i.innerHTML=r,this.el.appendChild(i),this}},{key:"isPlacementTop",value:function(){return"top"===this.placement}},{key:"el",get:function(){return this._el||(this._el=t.createElement()),this._el}}]),t}(l.default);t.default=v},function(e,t,n){"use strict";(function(e){function t(e){return e&&e.__esModule?e:{default:e}}var r=n(8),i=t(r),o=n(12),s=t(o),u=void 0;u=e.Textcomplete&&e.Textcomplete.editors?e.Textcomplete.editors:{},u.Textarea=s.default,e.Textcomplete=i.default,e.Textcomplete.editors=u}).call(t,n(7))},function(e){var t;t=function(){return this}();try{t=t||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(t=window)}e.exports=t},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(9),l=r(a),c=n(4),h=(r(c),n(5)),f=r(h),d=n(2),p=r(d),v=n(0),y=(r(v),n(1)),m=r(y),g=["handleChange","handleEnter","handleEsc","handleHit","handleMove","handleSelect"],b=function(e){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this,t);var r=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return r.completer=new l.default,r.isQueryInFlight=!1,r.nextPendingQuery=null,r.dropdown=new f.default(n.dropdown||{}),r.editor=e,r.options=n,g.forEach(function(e){r[e]=r[e].bind(r)}),r.startListening(),r}return s(t,e),u(t,[{key:"destroy",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.completer.destroy(),this.dropdown.destroy(),e&&this.editor.destroy(),this.stopListening(),this}},{key:"register",value:function(e){var t=this;return e.forEach(function(e){t.completer.registerStrategy(new p.default(e))}),this}},{key:"trigger",value:function(e){return this.isQueryInFlight?this.nextPendingQuery=e:(this.isQueryInFlight=!0,this.nextPendingQuery=null,this.completer.run(e)),this}},{key:"handleHit",value:function(e){var t=e.searchResults;t.length?this.dropdown.render(t,this.editor.getCursorOffset()):this.dropdown.deactivate(),this.isQueryInFlight=!1,null!==this.nextPendingQuery&&this.trigger(this.nextPendingQuery)}},{key:"handleMove",value:function(e){"UP"===e.detail.code?this.dropdown.up(e):this.dropdown.down(e)}},{key:"handleEnter",value:function(e){var t=this.dropdown.getActiveItem();t?(this.dropdown.select(t),e.preventDefault()):this.dropdown.deactivate()}},{key:"handleEsc",value:function(e){this.dropdown.shown&&(this.dropdown.deactivate(),e.preventDefault())}},{key:"handleChange",value:function(e){null!=e.detail.beforeCursor?this.trigger(e.detail.beforeCursor):this.dropdown.deactivate()}},{key:"handleSelect",value:function(e){this.emit("select",e),e.defaultPrevented||this.editor.applySearchResult(e.detail.searchResult)}},{key:"startListening",value:function(){var e=this;this.editor.on("move",this.handleMove).on("enter",this.handleEnter).on("esc",this.handleEsc).on("change",this.handleChange),this.dropdown.on("select",this.handleSelect),["show","shown","render","rendered","selected","hidden","hide"].forEach(function(t){e.dropdown.on(t,function(){return e.emit(t)})}),this.completer.on("hit",this.handleHit)}},{key:"stopListening",value:function(){this.completer.removeAllListeners(),this.dropdown.removeAllListeners(),this.editor.removeListener("move",this.handleMove).removeListener("enter",this.handleEnter).removeListener("esc",this.handleEsc).removeListener("change",this.handleChange)}}]),t}(m.default);t.default=b},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(1),l=r(a),c=n(2),h=(r(c),n(0)),f=(r(h),["handleQueryResult"]),d=function(e){function t(){i(this,t);var e=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.strategies=[],f.forEach(function(t){e[t]=e[t].bind(e)}),e}return s(t,e),u(t,[{key:"destroy",value:function(){return this.strategies.forEach(function(e){return e.destroy()}),this}},{key:"registerStrategy",value:function(e){return this.strategies.push(e),this}},{key:"run",value:function(e){var t=this.extractQuery(e);t?t.execute(this.handleQueryResult):this.handleQueryResult([])}},{key:"extractQuery",value:function(e){for(var t=0;t<this.strategies.length;t++){var n=this.strategies[t].buildQuery(e);if(n)return n}return null}},{key:"handleQueryResult",value:function(e){this.emit("hit",{searchResults:e})}}]),t}(l.default);t.default=d},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(0),u=r(s),a=n(2),l=(r(a),function(){function e(t,n,r){i(this,e),this.strategy=t,this.term=n,this.match=r}return o(e,[{key:"execute",value:function(e){var t=this;this.strategy.search(this.term,function(n){e(n.map(function(e){return new u.default(e,t.term,t.strategy)}))},this.match)}}]),e}());t.default=l},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.CLASS_NAME=void 0;var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(5),u=(r(s),n(0)),a=(r(u),t.CLASS_NAME="textcomplete-item"),l=a+" active",c=["onClick","onMouseover"],h=function(){function e(t){var n=this;i(this,e),this.searchResult=t,this.active=!1,c.forEach(function(e){n[e]=n[e].bind(n)})}return o(e,[{key:"destroy",value:function(){this.el.removeEventListener("mousedown",this.onClick,!1),this.el.removeEventListener("mouseover",this.onMouseover,!1),this.el.removeEventListener("touchstart",this.onClick,!1),this.active&&(this.dropdown.activeItem=null),this._el=null}},{key:"appended",value:function(e){this.dropdown=e,this.siblings=e.items,this.index=this.siblings.length-1}},{key:"activate",value:function(){if(!this.active){var e=this.dropdown.getActiveItem();e&&e.deactivate(),this.dropdown.activeItem=this,this.active=!0,this.el.className=l}return this}},{key:"deactivate",value:function(){return this.active&&(this.active=!1,this.el.className=a,this.dropdown.activeItem=null),this}},{key:"onClick",value:function(e){e.preventDefault(),this.dropdown.select(this)}},{key:"onMouseover",value:function(){this.activate()}},{key:"el",get:function(){if(this._el)return this._el;var e=document.createElement("li");e.className=this.active?l:a;var t=document.createElement("a");return t.innerHTML=this.searchResult.render(),e.appendChild(t),this._el=e,e.addEventListener("mousedown",this.onClick),e.addEventListener("mouseover",this.onMouseover),e.addEventListener("touchstart",this.onClick),e}},{key:"next",get:function(){var e=void 0;if(this.index===this.siblings.length-1){if(!this.dropdown.rotate)return null;e=0}else e=this.index+1;return this.siblings[e]}},{key:"prev",get:function(){var e=void 0;if(0===this.index){if(!this.dropdown.rotate)return null;e=this.siblings.length-1}else e=this.index-1;return this.siblings[e]}}]),e}();t.default=h},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,n,r)}if("value"in i)return i.value;var s=i.get;if(void 0!==s)return s.call(r)},l=n(13),c=r(l),h=n(4),f=r(h),d=n(3),p=n(0),v=(r(p),n(14)),y=["onInput","onKeydown"],m=function(e){function t(e){i(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.el=e,y.forEach(function(e){n[e]=n[e].bind(n)}),n.startListening(),n}return s(t,e),u(t,[{key:"destroy",value:function(){return a(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this),this.stopListening(),this.el=null,this}},{key:"applySearchResult",value:function(e){var t=this.getBeforeCursor();if(null!=t){var n=e.replace(t,this.getAfterCursor());this.el.focus(),Array.isArray(n)&&((0,c.default)(this.el,n[0],n[1]),this.el.dispatchEvent(new Event("input")))}}},{key:"getCursorOffset",value:function(){var e=(0,d.calculateElementOffset)(this.el),t=this.getElScroll(),n=this.getCursorPosition(),r=(0,d.getLineHeightPx)(this.el),i=e.top-t.top+n.top+r,o=e.left-t.left+n.left;return"rtl"!==this.el.dir?{top:i,left:o,lineHeight:r}:{top:i,right:document.documentElement?document.documentElement.clientWidth-o:0,lineHeight:r}}},{key:"getBeforeCursor",value:function(){return this.el.selectionStart!==this.el.selectionEnd?null:this.el.value.substring(0,this.el.selectionEnd)}},{key:"getAfterCursor",value:function(){return this.el.value.substring(this.el.selectionEnd)}},{key:"getElScroll",value:function(){return{top:this.el.scrollTop,left:this.el.scrollLeft}}},{key:"getCursorPosition",value:function(){return v(this.el,this.el.selectionEnd)}},{key:"onInput",value:function(){this.emitChangeEvent()}},{key:"onKeydown",value:function(e){var t=this.getCode(e),n=void 0;"UP"===t||"DOWN"===t?n=this.emitMoveEvent(t):"ENTER"===t?n=this.emitEnterEvent():"ESC"===t&&(n=this.emitEscEvent()),n&&n.defaultPrevented&&e.preventDefault()}},{key:"startListening",value:function(){this.el.addEventListener("input",this.onInput),this.el.addEventListener("keydown",this.onKeydown)}},{key:"stopListening",value:function(){this.el.removeEventListener("input",this.onInput),this.el.removeEventListener("keydown",this.onKeydown)}}]),t}(f.default);t.default=m},function(e,t){"use strict";function n(){if("undefined"!=typeof Event)return new Event("input",{bubbles:!0,cancelable:!0});var e=document.createEvent("Event");return e.initEvent("input",!0,!0),e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){for(var i=e.value,o=t+(r||""),s=document.activeElement,u=0,a=0;u<i.length&&u<o.length&&i[u]===o[u];)u++;for(;i.length-a-1>=0&&o.length-a-1>=0&&i[i.length-a-1]===o[o.length-a-1];)a++;u=Math.min(u,Math.min(i.length,o.length)-a),e.setSelectionRange(u,i.length-a);var l=o.substring(u,o.length-a);return e.focus(),document.execCommand("insertText",!1,l)||(e.value=o,e.dispatchEvent(n())),e.setSelectionRange(t.length,t.length),s&&s.focus(),e}},function(e){!function(){function t(e,t,o){if(!r)throw new Error("textarea-caret-position#getCaretCoordinates should only be called in a browser");var s=o&&o.debug||!1;if(s){var u=document.querySelector("#input-textarea-caret-position-mirror-div");u&&u.parentNode.removeChild(u)}var a=document.createElement("div");a.id="input-textarea-caret-position-mirror-div",document.body.appendChild(a);var l=a.style,c=window.getComputedStyle?getComputedStyle(e):e.currentStyle;l.whiteSpace="pre-wrap","INPUT"!==e.nodeName&&(l.wordWrap="break-word"),l.position="absolute",s||(l.visibility="hidden"),n.forEach(function(e){l[e]=c[e]}),i?e.scrollHeight>parseInt(c.height)&&(l.overflowY="scroll"):l.overflow="hidden",a.textContent=e.value.substring(0,t),"INPUT"===e.nodeName&&(a.textContent=a.textContent.replace(/\s/g," "));var h=document.createElement("span");h.textContent=e.value.substring(t)||".",a.appendChild(h);var f={top:h.offsetTop+parseInt(c.borderTopWidth),left:h.offsetLeft+parseInt(c.borderLeftWidth)};return s?h.style.backgroundColor="#aaa":document.body.removeChild(a),f}var n=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize","MozTabSize"],r="undefined"!=typeof window,i=r&&null!=window.mozInnerScreenX;void 0!==e&&void 0!==e.exports?e.exports=t:r&&(window.getCaretCoordinates=t)}()}]);