nodebb-plugin-tenor-gif 3.1.2 → 3.1.4

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.
package/library.js CHANGED
@@ -46,10 +46,20 @@ plugin.registerFormatting = async (payload) => {
46
46
  return payload;
47
47
  };
48
48
 
49
+ plugin.filterMessagingLoadRoom = (payload) => {
50
+ payload.room.composerActions.push({
51
+ action: 'tenor-gif',
52
+ class: 'd-none d-md-flex',
53
+ icon: 'fa-tenor-gif',
54
+ title: 'Tenor GIF',
55
+ });
56
+ return payload;
57
+ };
58
+
49
59
  plugin.query = async (query) => {
50
60
  let { contentFilter, key, limit } = await meta.settings.get('tenor-gif');
51
61
  if (!limit || limit < 1 || limit > 50) {
52
- limit = 12;
62
+ limit = 15;
53
63
  }
54
64
 
55
65
  query = String(query).trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-tenor-gif",
3
- "version": "3.1.2",
3
+ "version": "3.1.4",
4
4
  "description": "",
5
5
  "main": "library.js",
6
6
  "repository": {
package/plugin.json CHANGED
@@ -4,7 +4,8 @@
4
4
  "hooks": [
5
5
  { "hook": "static:app.load", "method": "init" },
6
6
  { "hook": "filter:admin.header.build", "method": "addAdminNavigation" },
7
- { "hook": "filter:composer.formatting", "method": "registerFormatting" }
7
+ { "hook": "filter:composer.formatting", "method": "registerFormatting" },
8
+ { "hook": "filter:messaging.loadRoom", "method": "filterMessagingLoadRoom" }
8
9
  ],
9
10
  "scripts": [
10
11
  "static/lib/main.js"
@@ -7,14 +7,7 @@ define('admin/plugins/tenor-gif', ['settings'], function (Settings) {
7
7
  Settings.load('tenor-gif', $('.tenor-gif-settings'));
8
8
 
9
9
  $('#save').on('click', function () {
10
- Settings.save('tenor-gif', $('.tenor-gif-settings'), function () {
11
- app.alert({
12
- type: 'success',
13
- alert_id: 'tenor-gif-saved',
14
- title: 'Settings Saved',
15
- timeout: 5000,
16
- });
17
- });
10
+ Settings.save('tenor-gif', $('.tenor-gif-settings'));
18
11
  });
19
12
  };
20
13
 
@@ -17,6 +17,30 @@ $(document).ready(function () {
17
17
  }
18
18
  });
19
19
 
20
+ $(window).on('action:chat.loaded', (ev, container) => {
21
+ const containerEl = $(container);
22
+ const textarea = containerEl.find('[component="chat/input"]')[0];
23
+ containerEl.find('[data-action="tenor-gif"]').on('click', () => {
24
+ require([
25
+ 'composer/controls',
26
+ ], function (controls) {
27
+ Tenor.showModal(function (url, query, alt) {
28
+ const selectionStart = textarea.selectionStart;
29
+ const selectionEnd = textarea.selectionEnd;
30
+ if (selectionStart === selectionEnd) {
31
+ controls.insertIntoTextarea(textarea, '![' + alt + '](' + url + ')');
32
+ } else {
33
+ const wrapDelta = controls.wrapSelectionInTextareaWith(textarea, '![', '](' + url + ')');
34
+ controls.updateTextareaSelection(
35
+ textarea, selectionEnd + 4 - wrapDelta[1], selectionEnd + url.length + 4 - wrapDelta[1]
36
+ );
37
+ }
38
+ containerEl.find('[component="chat/input"]').trigger('input');
39
+ });
40
+ });
41
+ });
42
+ });
43
+
20
44
  Tenor.prepareFormattingTools = function () {
21
45
  require([
22
46
  'composer/formatting',
@@ -82,6 +106,13 @@ $(document).ready(function () {
82
106
  queryEl.focus();
83
107
  });
84
108
 
109
+ resultsEl.on('wheel', (e) => {
110
+ e.preventDefault();
111
+ resultsEl.get(0).scrollBy({
112
+ left: e.originalEvent.deltaY < 0 ? -50 : 50,
113
+ });
114
+ });
115
+
85
116
  queryEl.on('keyup', function () {
86
117
  if (queryTimeout) {
87
118
  clearTimeout(queryTimeout);
@@ -2,10 +2,11 @@
2
2
  #gif-results {
3
3
  overflow-x: auto;
4
4
  white-space: nowrap;
5
-
5
+ max-height: 80vh;
6
6
  img {
7
7
  cursor: pointer;
8
-
8
+ width: 33%;
9
+ padding: $spacer * 0.25;
9
10
  &:hover {
10
11
  opacity: 0.8;
11
12
  }
@@ -20,8 +21,8 @@
20
21
  font-family: sans;
21
22
  background: #333;
22
23
  color: #fff;
23
- padding: 0.25rem 0.5rem;
24
+ padding: 0.25rem 0.25rem;
24
25
  border-radius: 0.5em;
25
26
  position: relative;
26
- top: -0.15rem;
27
+ top: -0.1rem;
27
28
  }
@@ -28,7 +28,7 @@
28
28
  </div>
29
29
  <div class="mb-3">
30
30
  <label for="limit">Limit results</label>
31
- <input class="form-control" type="number" min="1" max="50" id="limit" placeholder="12" name="limit" />
31
+ <input class="form-control" type="number" min="1" max="50" id="limit" placeholder="15" name="limit" />
32
32
  </div>
33
33
  </div>
34
34
  </div>
@@ -1,4 +1,4 @@
1
1
  <div class="mb-3 d-flex flex-column gap-2">
2
2
  <input type="text" id="gif-query" class="form-control">
3
- <div id="gif-results" class="row row-cols-3 gy-3"></div>
3
+ <div id="gif-results" class="d-flex flex-column flex-wrap"></div>
4
4
  </div>