nodebb-plugin-composer-default 10.3.3 → 10.3.5

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.3",
3
+ "version": "10.3.5",
4
4
  "description": "Default composer for NodeBB",
5
5
  "main": "library.js",
6
6
  "repository": {
@@ -27,6 +27,7 @@ define('composer/drafts', ['api', 'alerts'], function (api, alerts) {
27
27
  postContainer.on('click', '[component="category/list"] [data-cid]', utils.debounce(doSaveDraft, draftSaveDelay));
28
28
  postContainer.on('itemAdded', '.tags', utils.debounce(doSaveDraft, draftSaveDelay));
29
29
  postContainer.on('thumb.uploaded', doSaveDraft);
30
+ postContainer.on('composer.minimize', doSaveDraft);
30
31
 
31
32
  draftIconEl.on('animationend', function () {
32
33
  $(this).toggleClass('active', false);
@@ -84,48 +85,45 @@ define('composer/drafts', ['api', 'alerts'], function (api, alerts) {
84
85
  const raw = postContainer.find('textarea').val();
85
86
  const storage = getStorage(app.user.uid);
86
87
 
87
- if (raw.length || (title && title.length)) {
88
- const draftData = {
89
- save_id: postData.save_id,
90
- action: postData.action,
91
- text: raw,
92
- uuid: postContainer.attr('data-uuid'),
93
- timestamp: Date.now(),
94
- };
95
-
96
- if (postData.action === 'topics.post') {
97
- // New topic only
98
- const tags = postContainer.find('input.tags').val();
99
- draftData.tags = tags;
100
- draftData.title = title;
101
- draftData.cid = postData.cid;
102
- draftData.thumbs = postData.thumbs || [];
103
- } else if (postData.action === 'posts.reply') {
104
- // new reply only
105
- draftData.title = postData.title;
106
- draftData.tid = postData.tid;
107
- draftData.toPid = postData.toPid;
108
- } else if (postData.action === 'posts.edit') {
109
- draftData.pid = postData.pid;
110
- draftData.title = title || postData.title;
111
- draftData.thumbs = postData.thumbs || [];
112
- }
113
- if (!app.user.uid) {
114
- draftData.handle = postContainer.find('input.handle').val();
115
- }
88
+ const draftData = {
89
+ save_id: postData.save_id,
90
+ action: postData.action,
91
+ text: raw,
92
+ uuid: postContainer.attr('data-uuid'),
93
+ timestamp: Date.now(),
94
+ };
95
+
96
+ if (postData.action === 'topics.post') {
97
+ // New topic only
98
+ const tags = postContainer.find('input.tags').val();
99
+ draftData.tags = tags;
100
+ draftData.title = title;
101
+ draftData.cid = postData.cid;
102
+ draftData.thumbs = postData.thumbs || [];
103
+ } else if (postData.action === 'posts.reply') {
104
+ // new reply only
105
+ draftData.title = postData.title;
106
+ draftData.tid = postData.tid;
107
+ draftData.toPid = postData.toPid;
108
+ } else if (postData.action === 'posts.edit') {
109
+ draftData.pid = postData.pid;
110
+ draftData.title = title || postData.title;
111
+ draftData.thumbs = postData.thumbs || [];
112
+ }
113
+ if (!app.user.uid) {
114
+ draftData.handle = postContainer.find('input.handle').val();
115
+ }
116
116
 
117
- // save all draft data into single item as json
118
- storage.setItem(postData.save_id, JSON.stringify(draftData));
117
+ // save all draft data into single item as json
118
+ storage.setItem(postData.save_id, JSON.stringify(draftData));
119
+
120
+ $(window).trigger('action:composer.drafts.save', {
121
+ storage: storage,
122
+ postData: postData,
123
+ postContainer: postContainer,
124
+ });
125
+ draftIconEl.toggleClass('active', true);
119
126
 
120
- $(window).trigger('action:composer.drafts.save', {
121
- storage: storage,
122
- postData: postData,
123
- postContainer: postContainer,
124
- });
125
- draftIconEl.toggleClass('active', true);
126
- } else {
127
- drafts.removeDraft(postData.save_id);
128
- }
129
127
  }
130
128
  }
131
129
 
@@ -460,7 +460,7 @@ define('composer', [
460
460
  var data = {
461
461
  topicTitle: title,
462
462
  titleLength: title.length,
463
- body: translator.escape(utils.escapeHTML(postData.body || topicTemplate)),
463
+ body: utils.escapeHTML(translator.escape(postData.body) || topicTemplate),
464
464
  mobile: composer.bsEnvironment === 'xs' || composer.bsEnvironment === 'sm',
465
465
  resizable: true,
466
466
  thumb: postData.thumb,
@@ -871,6 +871,7 @@ define('composer', [
871
871
  post_uuid: post_uuid,
872
872
  });
873
873
 
874
+ postContainer.trigger('composer.minimize');
874
875
  onHide();
875
876
  };
876
877