nodebb-plugin-composer-default 10.3.0 → 10.3.1

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-composer-default",
3
- "version": "10.3.0",
3
+ "version": "10.3.1",
4
4
  "description": "Default composer for NodeBB",
5
5
  "main": "library.js",
6
6
  "repository": {
@@ -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);
@@ -460,10 +460,11 @@ define('composer', [
460
460
  var title = postData.title.replace(/%/g, '%').replace(/,/g, ',');
461
461
  postData.category = await getSelectedCategory(postData);
462
462
  const privileges = postData.category ? postData.category.privileges : ajaxify.data.privileges;
463
+ const topicTemplate = isTopic && postData.category ? postData.category.topicTemplate : null;
463
464
  var data = {
464
465
  topicTitle: title,
465
466
  titleLength: title.length,
466
- body: translator.escape(utils.escapeHTML(postData.body)),
467
+ body: translator.escape(utils.escapeHTML(topicTemplate || postData.body)),
467
468
  mobile: composer.bsEnvironment === 'xs' || composer.bsEnvironment === 'sm',
468
469
  resizable: true,
469
470
  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 {