nodebb-plugin-composer-default 9.1.1 → 9.2.0

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": "9.1.1",
3
+ "version": "9.2.0",
4
4
  "description": "Default composer for NodeBB",
5
5
  "main": "library.js",
6
6
  "repository": {
@@ -3,6 +3,7 @@
3
3
  $(document).ready(function () {
4
4
  $(window).on('action:app.load', function () {
5
5
  require(['composer/drafts'], function (drafts) {
6
+ drafts.migrateGuest();
6
7
  drafts.loadOpen();
7
8
  });
8
9
  });
@@ -191,6 +191,10 @@ define('composer/drafts', ['api', 'alerts'], function (api, alerts) {
191
191
  };
192
192
 
193
193
  drafts.migrateThumbs = function (postContainer, postData) {
194
+ if (!app.uid) {
195
+ return;
196
+ }
197
+
194
198
  // If any thumbs were uploaded, migrate them to this new composer's uuid
195
199
  const newUUID = postContainer.attr('data-uuid');
196
200
  const draft = drafts.get(postData.save_id);
@@ -224,7 +228,7 @@ define('composer/drafts', ['api', 'alerts'], function (api, alerts) {
224
228
  open = [];
225
229
  }
226
230
 
227
- if (available.length && app.user && app.user.uid !== 0) {
231
+ if (available.length) {
228
232
  // Deconstruct each save_id and open up composer
229
233
  available.forEach(function (save_id) {
230
234
  if (!save_id) {
@@ -256,16 +260,17 @@ define('composer/drafts', ['api', 'alerts'], function (api, alerts) {
256
260
  if (type === 'cid') {
257
261
  composer.newTopic({
258
262
  cid: id,
263
+ handle: app.user && app.user.uid ? undefined : utils.escapeHTML(draft.handle),
259
264
  title: utils.escapeHTML(draft.title),
260
- body: draft.text,
261
- tags: [],
265
+ body: utils.escapeHTML(draft.text),
266
+ tags: String(draft.tags || '').split(','),
262
267
  });
263
268
  } else if (type === 'tid') {
264
269
  api.get('/topics/' + id, {}, function (err, topicObj) {
265
270
  if (err) {
266
271
  return alerts.error(err);
267
272
  }
268
- composer.newReply(id, undefined, topicObj.title, draft.text);
273
+ composer.newReply(id, undefined, topicObj.title, utils.escapeHTML(draft.text));
269
274
  });
270
275
  } else if (type === 'pid') {
271
276
  composer.editPost(id);
@@ -200,6 +200,7 @@ define('composer', [
200
200
  var pushData = {
201
201
  action: 'topics.post',
202
202
  cid: data.cid,
203
+ handle: data.handle,
203
204
  title: data.title || '',
204
205
  body: data.body || '',
205
206
  tags: data.tags || [],
@@ -317,9 +318,6 @@ define('composer', [
317
318
  postContainer.attr('data-uuid', post_uuid);
318
319
  }
319
320
 
320
- var titleEl = postContainer.find('input.title');
321
- var handleEl = postContainer.find('input.handle');
322
- var tagsEl = postContainer.find('input.tags');
323
321
  var bodyEl = postContainer.find('textarea');
324
322
  var submitBtn = postContainer.find('.composer-submit');
325
323
 
@@ -394,21 +392,7 @@ define('composer', [
394
392
  });
395
393
 
396
394
  drafts.init(postContainer, postData);
397
-
398
- var draft = drafts.get(postData.save_id);
399
- if (draft && draft.title) {
400
- titleEl.val(draft.title);
401
- }
402
- if (draft && draft.handle) {
403
- handleEl.val(draft.handle);
404
- }
405
- if (draft && draft.tags) {
406
- const tags = draft.tags.split(',');
407
- tags.forEach(function (tag) {
408
- tagsEl.tagsinput('add', tag);
409
- });
410
- }
411
- bodyEl.val(draft.text ? draft.text : postData.body);
395
+ const draft = drafts.get(postData.save_id);
412
396
 
413
397
  preview.render(postContainer, function () {
414
398
  preview.matchScroll(postContainer);
@@ -426,11 +410,7 @@ define('composer', [
426
410
  $('[data-format="zen"]').addClass('hidden');
427
411
  }
428
412
 
429
- hooks.fire('action:composer.enhanced', {
430
- postContainer: postContainer,
431
- postData: postData,
432
- draft: draft,
433
- });
413
+ hooks.fire('action:composer.enhanced', { postContainer, postData, draft });
434
414
  };
435
415
 
436
416
  async function getSelectedCategory(postData) {
@@ -463,6 +443,7 @@ define('composer', [
463
443
  var data = {
464
444
  title: title,
465
445
  titleLength: title.length,
446
+ body: postData.body,
466
447
  mobile: composer.bsEnvironment === 'xs' || composer.bsEnvironment === 'sm',
467
448
  resizable: true,
468
449
  thumb: postData.thumb,
@@ -101,7 +101,7 @@
101
101
  <span class="toggle-preview hide">[[modules:composer.show_preview]]</span>
102
102
  </div>
103
103
  <div class="pull-right draft-icon hidden-md hidden-lg"></div>
104
- <textarea class="write" tabindex="4" placeholder="[[modules:composer.textarea.placeholder]]"></textarea>
104
+ <textarea class="write" tabindex="4" placeholder="[[modules:composer.textarea.placeholder]]">{body}</textarea>
105
105
  </div>
106
106
  <div class="hidden-sm hidden-xs preview-container">
107
107
  <div class="help-text">