nodebb-plugin-composer-default 10.3.5 → 10.3.7
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
|
@@ -178,7 +178,9 @@ plugin.filterComposerBuild = async function (hookData) {
|
|
|
178
178
|
}
|
|
179
179
|
globalPrivileges['topics:tag'] = canTagTopics;
|
|
180
180
|
const cid = parseInt(req.query.cid, 10);
|
|
181
|
-
const topicTitle = topicData && topicData.title ?
|
|
181
|
+
const topicTitle = topicData && topicData.title ?
|
|
182
|
+
topicData.title :
|
|
183
|
+
validator.escape(String(req.query.title || ''));
|
|
182
184
|
return {
|
|
183
185
|
req: req,
|
|
184
186
|
res: res,
|
|
@@ -197,6 +199,13 @@ plugin.filterComposerBuild = async function (hookData) {
|
|
|
197
199
|
// can't use title property as that is used for page title
|
|
198
200
|
topicTitle: topicTitle,
|
|
199
201
|
titleLength: topicTitle ? topicTitle.length : 0,
|
|
202
|
+
titleLabel: translator.compile(
|
|
203
|
+
isEditing ?
|
|
204
|
+
'topic:composer.editing-in' :
|
|
205
|
+
'topic:composer.replying-to',
|
|
206
|
+
`"${topicTitle}"`
|
|
207
|
+
),
|
|
208
|
+
|
|
200
209
|
topic: topicData,
|
|
201
210
|
thumb: topicData ? topicData.thumb : '',
|
|
202
211
|
body: body,
|
package/package.json
CHANGED
package/static/lib/composer.js
CHANGED
|
@@ -226,23 +226,24 @@ define('composer', [
|
|
|
226
226
|
if (data.body) {
|
|
227
227
|
data.body = '> ' + data.body.replace(/\n/g, '\n> ') + '\n\n';
|
|
228
228
|
}
|
|
229
|
-
|
|
229
|
+
|
|
230
|
+
const composerTid = data.uuid ? composer.posts[data.uuid].tid : data.tid;
|
|
231
|
+
const inDifferentTopic = parseInt(data.tid, 10) !== parseInt(composerTid, 10);
|
|
232
|
+
const useTopicLink = data.title && (data.selectedPid || data.toPid) && inDifferentTopic;
|
|
233
|
+
const postHref = `${config.relative_path}/post/${encodeURIComponent(data.selectedPid || data.toPid)}`;
|
|
234
|
+
const topicLink = `[${escapedTitle}](${postHref})`;
|
|
235
|
+
|
|
236
|
+
const quoteKey = useTopicLink ?
|
|
237
|
+
'> [[modules:composer.user-said-in, ' + data.username + ', ' + topicLink + ']]\n>\n' :
|
|
238
|
+
'> [[modules:composer.user-said, ' + data.username + ', ' + postHref + ']]\n>\n';
|
|
239
|
+
|
|
230
240
|
if (data.uuid === undefined) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
});
|
|
238
|
-
} else {
|
|
239
|
-
composer.newReply({
|
|
240
|
-
tid: data.tid,
|
|
241
|
-
toPid: data.toPid,
|
|
242
|
-
title: data.title,
|
|
243
|
-
body: '[[modules:composer.user-said, ' + data.username + ']]\n' + data.body,
|
|
244
|
-
});
|
|
245
|
-
}
|
|
241
|
+
composer.newReply({
|
|
242
|
+
tid: data.tid,
|
|
243
|
+
toPid: data.toPid,
|
|
244
|
+
title: data.title,
|
|
245
|
+
body: quoteKey + data.body,
|
|
246
|
+
});
|
|
246
247
|
return;
|
|
247
248
|
} else if (data.uuid !== composer.active) {
|
|
248
249
|
// If the composer is not currently active, activate it
|
|
@@ -252,18 +253,13 @@ define('composer', [
|
|
|
252
253
|
var postContainer = $('.composer[data-uuid="' + data.uuid + '"]');
|
|
253
254
|
var bodyEl = postContainer.find('textarea');
|
|
254
255
|
var prevText = bodyEl.val();
|
|
255
|
-
if (data.title && (data.selectedPid || data.toPid)) {
|
|
256
|
-
translator.translate('[[modules:composer.user-said-in, ' + data.username + ', ' + link + ']]\n', config.defaultLang, onTranslated);
|
|
257
|
-
} else {
|
|
258
|
-
translator.translate('[[modules:composer.user-said, ' + data.username + ']]\n', config.defaultLang, onTranslated);
|
|
259
|
-
}
|
|
260
256
|
|
|
261
|
-
function
|
|
257
|
+
translator.translate(quoteKey, config.defaultLang, function (translated) {
|
|
262
258
|
composer.posts[data.uuid].body = (prevText.length ? prevText + '\n\n' : '') + translated + data.body;
|
|
263
259
|
bodyEl.val(composer.posts[data.uuid].body);
|
|
264
260
|
focusElements(postContainer);
|
|
265
261
|
preview.render(postContainer);
|
|
266
|
-
}
|
|
262
|
+
});
|
|
267
263
|
};
|
|
268
264
|
|
|
269
265
|
composer.newReply = function (data) {
|
|
@@ -448,18 +444,19 @@ define('composer', [
|
|
|
448
444
|
var isGuestPost = postData ? parseInt(postData.uid, 10) === 0 : false;
|
|
449
445
|
const isScheduled = postData.timestamp > Date.now();
|
|
450
446
|
|
|
451
|
-
// see
|
|
452
|
-
// https://github.com/NodeBB/NodeBB/issues/2994 and
|
|
453
|
-
// https://github.com/NodeBB/NodeBB/issues/1951
|
|
454
|
-
// remove when 1951 is resolved
|
|
455
|
-
|
|
456
|
-
var title = postData.title.replace(/%/g, '%').replace(/,/g, ',');
|
|
457
447
|
postData.category = await getSelectedCategory(postData);
|
|
458
448
|
const privileges = postData.category ? postData.category.privileges : ajaxify.data.privileges;
|
|
459
449
|
const topicTemplate = isTopic && postData.category ? postData.category.topicTemplate : '';
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
450
|
+
|
|
451
|
+
let data = {
|
|
452
|
+
topicTitle: postData.title,
|
|
453
|
+
titleLength: postData.title.length,
|
|
454
|
+
titleLabel: translator.compile(
|
|
455
|
+
isEditing ?
|
|
456
|
+
'topic:composer.editing-in' :
|
|
457
|
+
'topic:composer.replying-to',
|
|
458
|
+
`"${postData.title}"`
|
|
459
|
+
),
|
|
463
460
|
body: utils.escapeHTML(translator.escape(postData.body) || topicTemplate),
|
|
464
461
|
mobile: composer.bsEnvironment === 'xs' || composer.bsEnvironment === 'sm',
|
|
465
462
|
resizable: true,
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
</div>
|
|
13
13
|
{{{ end }}}
|
|
14
14
|
{{{ if !isTopicOrMain }}}
|
|
15
|
-
<h4 class="title text-bg-primary">{
|
|
15
|
+
<h4 class="title text-bg-primary">{titleLabel}</h4>
|
|
16
16
|
{{{ end }}}
|
|
17
17
|
<div class="display-scheduler p-2 {{{ if !canSchedule }}} hidden{{{ end }}}">
|
|
18
18
|
<i class="fa fa-clock-o"></i>
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
{{{ if isTopicOrMain }}}
|
|
16
16
|
<input class="title form-control h-100 rounded-1 shadow-none" type="text" placeholder="[[topic:composer.title-placeholder]]" value="{topicTitle}" />
|
|
17
17
|
{{{ else }}}
|
|
18
|
-
<span class="{{{ if !template.compose }}}d-none d-md-block{{{ else }}}d-block{{{ end }}} title h-100 text-truncate">{
|
|
18
|
+
<span class="{{{ if !template.compose }}}d-none d-md-block{{{ else }}}d-block{{{ end }}} title h-100 text-truncate">{titleLabel}</span>
|
|
19
19
|
{{{ end }}}
|
|
20
20
|
<div id="quick-search-container" class="quick-search-container mt-2 dropdown-menu d-block p-2 hidden">
|
|
21
21
|
<div class="text-center loading-indicator"><i class="fa fa-spinner fa-spin"></i></div>
|