@jasonwch/nodebb-plugin-meilisearch-r 1.1.0 → 1.1.2
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/package.json
CHANGED
|
@@ -92,19 +92,42 @@
|
|
|
92
92
|
user-select: none;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
/* Cap dropdown
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
/* Cap dropdown so it never overflows past the browser bottom bar when the
|
|
96
|
+
composer is in half-screen mode. Activated only on composer dropdowns
|
|
97
|
+
(data-meilisearch-decorated="1" set by static/lib/client/quick-search.js).
|
|
98
|
+
The max-height here is the single height control — the <ul> fills the
|
|
99
|
+
remaining space after the header and scrolls internally. */
|
|
99
100
|
.quick-search-container[data-meilisearch-decorated="1"] {
|
|
100
|
-
max-height:
|
|
101
|
+
max-height: 370px;
|
|
101
102
|
overflow: hidden;
|
|
102
103
|
display: flex;
|
|
103
104
|
flex-direction: column;
|
|
104
105
|
}
|
|
105
106
|
|
|
107
|
+
.quick-search-container[data-meilisearch-decorated="1"] .quick-search-results-container {
|
|
108
|
+
display: flex;
|
|
109
|
+
flex-direction: column;
|
|
110
|
+
flex: 1 1 auto;
|
|
111
|
+
min-height: 0;
|
|
112
|
+
overflow: hidden;
|
|
113
|
+
position: relative;
|
|
114
|
+
}
|
|
115
|
+
|
|
106
116
|
.quick-search-container[data-meilisearch-decorated="1"] .quick-search-results {
|
|
107
117
|
max-height: 260px !important;
|
|
108
118
|
overflow: auto;
|
|
109
119
|
flex: 1 1 auto;
|
|
120
|
+
min-height: 0;
|
|
121
|
+
padding-bottom: 2rem;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* Overlay the desktop "See more results" button at lower-right corner of the
|
|
125
|
+
scrolling results. No gradient, no padding — just the bare button. */
|
|
126
|
+
.quick-search-container[data-meilisearch-decorated="1"] .quick-search-results-container > .text-center.mt-2.d-none.d-md-block {
|
|
127
|
+
position: absolute;
|
|
128
|
+
bottom: 0;
|
|
129
|
+
right: 0;
|
|
130
|
+
z-index: 10;
|
|
131
|
+
margin-top: 0 !important;
|
|
132
|
+
padding: 0;
|
|
110
133
|
}
|
|
@@ -80,7 +80,10 @@ $(document).ready(function () {
|
|
|
80
80
|
// Render the template FIRST (async), then atomically remove + prepend.
|
|
81
81
|
// This prevents chat-search's MutationObserver from re-injecting its
|
|
82
82
|
// container during the await gap (which caused duplicate search boxes).
|
|
83
|
-
|
|
83
|
+
// Pre-translate placeholder (NodeBB 4.15.0 removed translator step from app.parseAndTranslate).
|
|
84
|
+
const translator = await app.require('translator');
|
|
85
|
+
const placeholder = await translator.translateKey('meilisearch:chatSearch.client.placeholder');
|
|
86
|
+
const html = await app.parseAndTranslate('client/partials/chats/search-bar', { placeholder: placeholder });
|
|
84
87
|
$('#global-chat-search-container').remove();
|
|
85
88
|
container.prepend(html);
|
|
86
89
|
restoreState();
|
|
@@ -138,19 +141,10 @@ $(document).ready(function () {
|
|
|
138
141
|
return text.replace(/\s+/g, ' ').trim();
|
|
139
142
|
}
|
|
140
143
|
|
|
141
|
-
async function translateHtml(html) {
|
|
142
|
-
return new Promise(function (resolve) {
|
|
143
|
-
require(['translator'], function (translator) {
|
|
144
|
-
translator.translate(html, function (translated) {
|
|
145
|
-
resolve(translator.unescape(translated));
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
|
|
151
144
|
async function executeSearch() {
|
|
152
145
|
const query = $('#global-chat-search').val();
|
|
153
146
|
const resultsContainer = $('#global-search-results');
|
|
147
|
+
const translator = await app.require('translator');
|
|
154
148
|
|
|
155
149
|
if (!query) {
|
|
156
150
|
resultsContainer.hide();
|
|
@@ -159,7 +153,8 @@ $(document).ready(function () {
|
|
|
159
153
|
return;
|
|
160
154
|
}
|
|
161
155
|
|
|
162
|
-
const
|
|
156
|
+
const searchingLabel = await translator.translateKey('meilisearch:chatSearch.client.searching');
|
|
157
|
+
const spinnerHtml = '<div class="text-center" style="padding:10px;"><i class="fa fa-spinner fa-spin"></i> ' + searchingLabel + '</div>';
|
|
163
158
|
resultsContainer.show().html(spinnerHtml);
|
|
164
159
|
window.chatSearchState.isOpen = true;
|
|
165
160
|
|
|
@@ -169,17 +164,22 @@ $(document).ready(function () {
|
|
|
169
164
|
socket.emit('plugins.meilisearch.chatSearchGlobal', payload, async function (err, messages) {
|
|
170
165
|
if (seq !== searchSeq) return;
|
|
171
166
|
if (err) {
|
|
172
|
-
const
|
|
167
|
+
const errorLabel = await translator.translateKey('meilisearch:chatSearch.client.error');
|
|
168
|
+
const errorHtml = '<div class="alert alert-danger" style="margin:5px;">' + errorLabel + '</div>';
|
|
173
169
|
resultsContainer.html(errorHtml);
|
|
174
170
|
return;
|
|
175
171
|
}
|
|
176
172
|
if (!messages || messages.length === 0) {
|
|
177
|
-
const
|
|
173
|
+
const noResultsLabel = await translator.translateKey('meilisearch:chatSearch.client.no-results');
|
|
174
|
+
const noResHtml = '<div class="text-center" style="padding:10px; color: var(--bs-secondary-color);">' + noResultsLabel + '</div>';
|
|
178
175
|
resultsContainer.html(noResHtml);
|
|
179
176
|
window.chatSearchState.resultsHtml = noResHtml;
|
|
180
177
|
return;
|
|
181
178
|
}
|
|
182
179
|
|
|
180
|
+
// Pre-translate unknown-user fallback (NodeBB 4.15.0 removed translator step from app.parseAndTranslate).
|
|
181
|
+
const unknownUserLabel = await translator.translateKey('meilisearch:chatSearch.client.unknown-user');
|
|
182
|
+
|
|
183
183
|
// Pre-process messages for the template
|
|
184
184
|
const preparedMessages = messages.map(function (msg) {
|
|
185
185
|
var ts = parseInt(msg.timestamp, 10);
|
|
@@ -195,7 +195,7 @@ $(document).ready(function () {
|
|
|
195
195
|
var chatLink = hasRank
|
|
196
196
|
? (config.relative_path || '') + '/user/' + app.user.userslug + '/chats/' + roomId + '/' + (rank + 1)
|
|
197
197
|
: (config.relative_path || '') + '/message/' + mid;
|
|
198
|
-
var senderName = (msg.user && msg.user.username) ? msg.user.username :
|
|
198
|
+
var senderName = (msg.user && msg.user.username) ? msg.user.username : unknownUserLabel;
|
|
199
199
|
|
|
200
200
|
return {
|
|
201
201
|
mid: mid,
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
function bindResultClick(resultEl) {
|
|
48
48
|
resultEl
|
|
49
49
|
.off('click.meili-minimize')
|
|
50
|
-
.on('click.meili-minimize', '
|
|
50
|
+
.on('click.meili-minimize', '.quick-search-results-container a', function () {
|
|
51
51
|
var composerEl = resultEl.closest('.composer');
|
|
52
52
|
if (!composerEl.length) { return; }
|
|
53
53
|
var hideBtn = composerEl.find('[data-action="hide"]').first();
|
|
@@ -86,19 +86,42 @@
|
|
|
86
86
|
user-select: none;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
/* Cap dropdown
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
/* Cap dropdown so it never overflows past the browser bottom bar when the
|
|
90
|
+
composer is in half-screen mode. Activated only on composer dropdowns
|
|
91
|
+
(data-meilisearch-decorated="1" set by static/lib/client/quick-search.js).
|
|
92
|
+
The max-height here is the single height control — the <ul> fills the
|
|
93
|
+
remaining space after the header and scrolls internally. */
|
|
93
94
|
.quick-search-container[data-meilisearch-decorated="1"] {
|
|
94
|
-
max-height:
|
|
95
|
+
max-height: 370px;
|
|
95
96
|
overflow: hidden;
|
|
96
97
|
display: flex;
|
|
97
98
|
flex-direction: column;
|
|
98
99
|
}
|
|
99
100
|
|
|
101
|
+
.quick-search-container[data-meilisearch-decorated="1"] .quick-search-results-container {
|
|
102
|
+
display: flex;
|
|
103
|
+
flex-direction: column;
|
|
104
|
+
flex: 1 1 auto;
|
|
105
|
+
min-height: 0;
|
|
106
|
+
overflow: hidden;
|
|
107
|
+
position: relative;
|
|
108
|
+
}
|
|
109
|
+
|
|
100
110
|
.quick-search-container[data-meilisearch-decorated="1"] .quick-search-results {
|
|
101
111
|
max-height: 260px !important;
|
|
102
112
|
overflow: auto;
|
|
103
113
|
flex: 1 1 auto;
|
|
114
|
+
min-height: 0;
|
|
115
|
+
padding-bottom: 2rem;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* Overlay the desktop "See more results" button at lower-right corner of the
|
|
119
|
+
scrolling results. No gradient, no padding — just the bare button. */
|
|
120
|
+
.quick-search-container[data-meilisearch-decorated="1"] .quick-search-results-container > .text-center.mt-2.d-none.d-md-block {
|
|
121
|
+
position: absolute;
|
|
122
|
+
bottom: 0;
|
|
123
|
+
right: 0;
|
|
124
|
+
z-index: 10;
|
|
125
|
+
margin-top: 0 !important;
|
|
126
|
+
padding: 0;
|
|
104
127
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div id="global-chat-search-container" data-plugin="meilisearch" style="padding: 10px; background-color: var(--bs-body-bg); border-bottom: 1px solid var(--bs-border-color); margin-bottom: 5px;">
|
|
2
2
|
<div class="input-group">
|
|
3
|
-
<input type="text" id="global-chat-search" class="form-control" placeholder="
|
|
3
|
+
<input type="text" id="global-chat-search" class="form-control" placeholder="{placeholder}" style="font-size: 14px; height: 34px;">
|
|
4
4
|
<span class="input-group-btn">
|
|
5
5
|
<button class="btn btn-primary" id="btn-chat-search" type="button" style="height: 34px;"><i class="fa fa-search"></i></button>
|
|
6
6
|
</span>
|