nodebb-plugin-composer-default 10.3.0 → 10.3.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,11 +92,23 @@ define('composer/categoryList', [
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
function updateTopicTemplate(postContainer, category, previousCategory) {
|
|
96
|
+
const currentText = postContainer.find('textarea.write').val();
|
|
97
|
+
const previousTopicTemplate = previousCategory && previousCategory.topicTemplate;
|
|
98
|
+
if (category && (!currentText.length || currentText === previousTopicTemplate) &&
|
|
99
|
+
currentText !== category.topicTemplate) {
|
|
100
|
+
postContainer.find('textarea.write').val(category.topicTemplate).trigger('input');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
95
104
|
async function changeCategory(postContainer, postData, selectedCategory) {
|
|
105
|
+
const previousCategory = postData.category;
|
|
96
106
|
postData.cid = selectedCategory.cid;
|
|
97
107
|
const categoryData = await window.fetch(`${config.relative_path}/api/category/${encodeURIComponent(selectedCategory.cid)}`).then(r => r.json());
|
|
98
108
|
postData.category = categoryData;
|
|
99
109
|
updateTaskbarByCategory(postContainer, categoryData);
|
|
110
|
+
updateTopicTemplate(postContainer, categoryData, previousCategory);
|
|
111
|
+
|
|
100
112
|
require(['composer/scheduler', 'composer/tags', 'composer/post-queue'], function (scheduler, tags, postQueue) {
|
|
101
113
|
scheduler.onChangeCategory(categoryData);
|
|
102
114
|
tags.onChangeCategory(postContainer, postData, selectedCategory.cid, categoryData);
|
|
@@ -226,7 +226,7 @@ define('composer/uploads', [
|
|
|
226
226
|
'[[error:parse-error]]';
|
|
227
227
|
|
|
228
228
|
if (xhr && xhr.status === 413) {
|
|
229
|
-
msg =
|
|
229
|
+
msg = '[[error:api.413]]';
|
|
230
230
|
}
|
|
231
231
|
alerts.error(msg);
|
|
232
232
|
$(window).trigger('action:composer.uploadError', {
|
package/static/lib/composer.js
CHANGED
|
@@ -52,16 +52,14 @@ define('composer', [
|
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
composer.posts[composer.active].modified = false;
|
|
55
|
+
composer.discardConfirm = bootbox.confirm('[[modules:composer.discard]]', function (confirm) {
|
|
56
|
+
if (confirm) {
|
|
57
|
+
composer.discard(composer.active);
|
|
58
|
+
} else {
|
|
59
|
+
composer.posts[composer.active].modified = true;
|
|
60
|
+
}
|
|
64
61
|
});
|
|
62
|
+
composer.posts[composer.active].modified = false;
|
|
65
63
|
}
|
|
66
64
|
});
|
|
67
65
|
|
|
@@ -378,15 +376,13 @@ define('composer', [
|
|
|
378
376
|
|
|
379
377
|
formatting.exitFullscreen();
|
|
380
378
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
btn.prop('disabled', false);
|
|
389
|
-
});
|
|
379
|
+
const btn = $(this).prop('disabled', true);
|
|
380
|
+
bootbox.confirm('[[modules:composer.discard]]', function (confirm) {
|
|
381
|
+
if (confirm) {
|
|
382
|
+
composer.discard(post_uuid);
|
|
383
|
+
removeComposerHistory();
|
|
384
|
+
}
|
|
385
|
+
btn.prop('disabled', false);
|
|
390
386
|
});
|
|
391
387
|
});
|
|
392
388
|
|
|
@@ -460,10 +456,11 @@ define('composer', [
|
|
|
460
456
|
var title = postData.title.replace(/%/g, '%').replace(/,/g, ',');
|
|
461
457
|
postData.category = await getSelectedCategory(postData);
|
|
462
458
|
const privileges = postData.category ? postData.category.privileges : ajaxify.data.privileges;
|
|
459
|
+
const topicTemplate = isTopic && postData.category ? postData.category.topicTemplate : null;
|
|
463
460
|
var data = {
|
|
464
461
|
topicTitle: title,
|
|
465
462
|
titleLength: title.length,
|
|
466
|
-
body: translator.escape(utils.escapeHTML(postData.body)),
|
|
463
|
+
body: translator.escape(utils.escapeHTML(topicTemplate || postData.body)),
|
|
467
464
|
mobile: composer.bsEnvironment === 'xs' || composer.bsEnvironment === 'sm',
|
|
468
465
|
resizable: true,
|
|
469
466
|
thumb: postData.thumb,
|
|
@@ -107,13 +107,11 @@
|
|
|
107
107
|
color: $body-color;
|
|
108
108
|
font-size: 16px;
|
|
109
109
|
width: 50%;
|
|
110
|
+
height: 28px;
|
|
111
|
+
padding: 4px 6px;
|
|
110
112
|
@include media-breakpoint-down(md) {
|
|
111
113
|
width: 100%;
|
|
112
114
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
height: 28px;
|
|
116
|
-
padding: 4px 6px;
|
|
117
115
|
}
|
|
118
116
|
|
|
119
117
|
.ui-autocomplete {
|