nodebb-plugin-composer-default 10.2.13 → 10.2.15

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.2.13",
3
+ "version": "10.2.15",
4
4
  "description": "Default composer for NodeBB",
5
5
  "main": "library.js",
6
6
  "repository": {
package/plugin.json CHANGED
@@ -28,6 +28,7 @@
28
28
  "composer/tags.js": "./static/lib/composer/tags.js",
29
29
  "composer/uploads.js": "./static/lib/composer/uploads.js",
30
30
  "composer/autocomplete.js": "./static/lib/composer/autocomplete.js",
31
+ "composer/post-queue.js": "./static/lib/composer/post-queue.js",
31
32
  "../admin/plugins/composer-default.js": "./static/lib/admin.js"
32
33
  },
33
34
  "templates": "static/templates"
@@ -97,9 +97,10 @@ define('composer/categoryList', [
97
97
  const categoryData = await window.fetch(`${config.relative_path}/api/category/${selectedCategory.cid}`).then(r => r.json());
98
98
  postData.category = categoryData;
99
99
  updateTaskbarByCategory(postContainer, categoryData);
100
- require(['composer/scheduler', 'composer/tags'], function (scheduler, tags) {
100
+ require(['composer/scheduler', 'composer/tags', 'composer/post-queue'], function (scheduler, tags, postQueue) {
101
101
  scheduler.onChangeCategory(categoryData);
102
102
  tags.onChangeCategory(postContainer, postData, selectedCategory.cid, categoryData);
103
+ postQueue.onChangeCategory(postContainer, postData);
103
104
 
104
105
  $(window).trigger('action:composer.changeCategory', {
105
106
  postContainer: postContainer,
@@ -75,7 +75,8 @@ define('composer/formatting', [
75
75
  };
76
76
 
77
77
  formatting.addComposerButtons = function () {
78
- const fileForm = $('.formatting-bar .formatting-group #fileForm');
78
+ const formattingBarEl = $('.formatting-bar');
79
+ const fileForm = formattingBarEl.find('.formatting-group #fileForm');
79
80
  buttons.forEach((btn) => {
80
81
  let markup = ``;
81
82
  if (Array.isArray(btn.dropdownItems) && btn.dropdownItems.length) {
@@ -89,6 +90,12 @@ define('composer/formatting', [
89
90
  }
90
91
  fileForm.before(markup);
91
92
  });
93
+ formattingBarEl.tooltip({
94
+ selector: '.formatting-group>li',
95
+ container: '#content',
96
+ animation: false,
97
+ trigger: 'hover',
98
+ });
92
99
  };
93
100
 
94
101
  function generateFormattingDropdown(btn) {
@@ -107,8 +114,8 @@ define('composer/formatting', [
107
114
  `;
108
115
  });
109
116
  return `
110
- <li class="dropdown bottom-sheet" tab-index="-1">
111
- <button class="btn btn-sm btn-link text-reset" data-bs-toggle="dropdown" title="${btn.title}">
117
+ <li class="dropdown bottom-sheet" tab-index="-1" title="${btn.title}">
118
+ <button class="btn btn-sm btn-link text-reset" data-bs-toggle="dropdown" >
112
119
  <i class="${btn.iconClass}"></i>
113
120
  </button>
114
121
  <ul class="dropdown-menu p-1">
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ define('composer/post-queue', [], function () {
4
+ const postQueue = {};
5
+
6
+ postQueue.isExempt = async function (postData) {
7
+ if (!config.postQueue || app.user.isAdmin || app.user.isGlobalMod || app.user.isMod) {
8
+ return true;
9
+ }
10
+ return await socket.emit('plugins.composer.isExemptFromPostQueue', { postData: postData });
11
+ };
12
+
13
+ postQueue.onChangeCategory = async function (postContainer, postData) {
14
+ if (!config.postQueue) {
15
+ return;
16
+ }
17
+ const isExempt = await postQueue.isExempt(postData);
18
+ postContainer.find('[component="composer/post-queue/alert"]')
19
+ .toggleClass('hidden', isExempt);
20
+ };
21
+
22
+ return postQueue;
23
+ });
@@ -12,6 +12,7 @@ define('composer', [
12
12
  'composer/resize',
13
13
  'composer/autocomplete',
14
14
  'composer/scheduler',
15
+ 'composer/post-queue',
15
16
  'scrollStop',
16
17
  'topicThumbs',
17
18
  'api',
@@ -22,7 +23,7 @@ define('composer', [
22
23
  'search',
23
24
  'screenfull',
24
25
  ], function (taskbar, translator, uploads, formatting, drafts, tags,
25
- categoryList, preview, resize, autocomplete, scheduler, scrollStop,
26
+ categoryList, preview, resize, autocomplete, scheduler, postQueue, scrollStop,
26
27
  topicThumbs, api, bootbox, alerts, hooks, messagesModule, search, screenfull) {
27
28
  var composer = {
28
29
  active: undefined,
@@ -476,6 +477,7 @@ define('composer', [
476
477
  tagWhitelist: postData.category ? postData.category.tagWhitelist : ajaxify.data.tagWhitelist,
477
478
  privileges: app.user.privileges,
478
479
  selectedCategory: postData.category,
480
+ exemptFromPostQueue: await postQueue.isExempt(postData),
479
481
  submitOptions: [
480
482
  // Add items using `filter:composer.create`, or just add them to the <ul> in DOM
481
483
  // {
@@ -6,8 +6,8 @@
6
6
  {{{ else }}}
7
7
  {{{ if (./visibility.desktop && ((isTopicOrMain && ./visibility.main) || (!isTopicOrMain && ./visibility.reply))) }}}
8
8
  {{{ if ./dropdownItems.length }}}
9
- <li class="dropdown bottom-sheet" tabindex="-1">
10
- <button class="btn btn-sm btn-link text-reset" data-bs-toggle="dropdown" title="{./title}">
9
+ <li class="dropdown bottom-sheet" tabindex="-1" title="{./title}">
10
+ <button class="btn btn-sm btn-link text-reset" data-bs-toggle="dropdown">
11
11
  <i class="{./className}"></i>
12
12
  </button>
13
13
  <ul class="dropdown-menu p-1">
@@ -1,5 +1,6 @@
1
1
  <div class="write-preview-container d-flex gap-2 flex-grow-1 overflow-auto">
2
- <div class="write-container d-flex d-md-flex w-50">
2
+ <div class="write-container d-flex d-md-flex w-50 position-relative">
3
+ <div component="composer/post-queue/alert" class="{{{ if exemptFromPostQueue }}}hidden{{{ end }}} m-2 alert alert-info position-absolute top-0 start-0 alert-dismissible">[[modules:composer.post-queue-alert]]<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>
3
4
  <div class="float-end draft-icon hidden-md hidden-lg"></div>
4
5
  <textarea class="write shadow-none rounded-1 w-100 form-control" tabindex="4" placeholder="[[modules:composer.textarea.placeholder]]">{body}</textarea>
5
6
  </div>
package/websockets.js CHANGED
@@ -66,5 +66,29 @@ Sockets.renderHelp = async function () {
66
66
  };
67
67
 
68
68
  Sockets.getFormattingOptions = async function () {
69
- return await module.parent.exports.getFormattingOptions();
69
+ return await require('./library').getFormattingOptions();
70
+ };
71
+
72
+ Sockets.isExemptFromPostQueue = async function (socket, data) {
73
+ if (!data || !data.postData) {
74
+ throw new Error('[[error:invalid-data]]');
75
+ }
76
+ if (socket.uid <= 0) {
77
+ return false;
78
+ }
79
+
80
+ let shouldQueue = false;
81
+ const { postData } = data;
82
+ if (postData.action === 'posts.reply') {
83
+ shouldQueue = await posts.shouldQueue(socket.uid, {
84
+ tid: postData.tid,
85
+ content: postData.content || '',
86
+ });
87
+ } else if (postData.action === 'topics.post') {
88
+ shouldQueue = await posts.shouldQueue(socket.uid, {
89
+ cid: postData.cid,
90
+ content: postData.content || '',
91
+ });
92
+ }
93
+ return !shouldQueue;
70
94
  };