nodebb-plugin-composer-default 10.2.3 → 10.2.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.2.3",
3
+ "version": "10.2.5",
4
4
  "description": "Default composer for NodeBB",
5
5
  "main": "library.js",
6
6
  "repository": {
@@ -77,15 +77,47 @@ define('composer/formatting', [
77
77
  formatting.addComposerButtons = function () {
78
78
  const fileForm = $('.formatting-bar .formatting-group #fileForm');
79
79
  buttons.forEach((btn) => {
80
- fileForm
81
- .before(`
80
+ let markup = ``;
81
+ if (Array.isArray(btn.dropdownItems) && btn.dropdownItems.length) {
82
+ markup = generateFormattingDropdown(btn);
83
+ } else {
84
+ markup = `
82
85
  <li data-format="${btn.name}" title="${btn.title || ''}" href="#" class="btn btn-sm btn-link text-reset position-relative" tabindex="-1">
83
86
  <i class="${btn.iconClass}"></i>
84
87
  </li>
85
- `);
88
+ `;
89
+ }
90
+ fileForm.before(markup);
86
91
  });
87
92
  };
88
93
 
94
+ function generateFormattingDropdown(btn) {
95
+ const dropdownItemsHtml = btn.dropdownItems.map(function (btn) {
96
+ let badgeHtml = '';
97
+ if (btn.badge) {
98
+ badgeHtml = `<span class="px-1 position-absolute top-0 start-100 translate-middle-x badge rounded text-bg-info"></span>`;
99
+ }
100
+ return `
101
+ <li data-format="${btn.name}">
102
+ <a href="#" class="dropdown-item rounded-1 position-relative">
103
+ <i class="${btn.iconClass} text-secondary"></i> ${btn.text}
104
+ ${badgeHtml}
105
+ </a>
106
+ </li>
107
+ `;
108
+ });
109
+ 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}">
112
+ <i class="${btn.iconClass}"></i>
113
+ </button>
114
+ <ul class="dropdown-menu p-1">
115
+ ${dropdownItemsHtml}
116
+ </ul>
117
+ </li>
118
+ `;
119
+ }
120
+
89
121
  formatting.addButton = function (iconClass, onClick, title, name) {
90
122
  name = name || iconClass.replace('fa fa-', '');
91
123
  formattingDispatchTable[name] = onClick;
@@ -96,6 +128,19 @@ define('composer/formatting', [
96
128
  });
97
129
  };
98
130
 
131
+ formatting.addDropdown = function (data) {
132
+ buttons.push({
133
+ iconClass: data.iconClass,
134
+ title: data.title,
135
+ dropdownItems: data.dropdownItems,
136
+ });
137
+ data.dropdownItems.forEach((btn) => {
138
+ if (btn.name && btn.onClick) {
139
+ formattingDispatchTable[btn.name] = btn.onClick;
140
+ }
141
+ });
142
+ };
143
+
99
144
  formatting.getDispatchTable = function () {
100
145
  return formattingDispatchTable;
101
146
  };
@@ -105,7 +150,7 @@ define('composer/formatting', [
105
150
  };
106
151
 
107
152
  formatting.addHandler = function (postContainer) {
108
- postContainer.on('click', '.formatting-bar li', function (event) {
153
+ postContainer.on('click', '.formatting-bar li[data-format]', function (event) {
109
154
  var format = $(this).attr('data-format');
110
155
  var textarea = $(this).parents('[component="composer"]').find('textarea')[0];
111
156
 
@@ -296,20 +296,14 @@
296
296
  }
297
297
  }
298
298
 
299
- @include media-breakpoint-up(sm) {
300
- html.composing {
301
- .composer {
302
- left: 15%;
303
- width: 70%;
304
- }
305
- }
299
+ @include media-breakpoint-down(lg) {
300
+ html.composing .composer { z-index: $zindex-modal; }
306
301
  }
307
302
 
308
303
  @include media-breakpoint-down(sm) {
309
304
  html.composing {
310
305
  .composer {
311
306
  height: 100%;
312
- z-index: $zindex-modal;
313
307
 
314
308
  .draft-icon {
315
309
  position: absolute;
@@ -333,7 +327,29 @@
333
327
  }
334
328
 
335
329
  @include media-breakpoint-up(sm) {
336
- @import './medium';
330
+ html.composing {
331
+ .composer {
332
+ left: 15%;
333
+ width: 70%;
334
+ min-height: 400px;
335
+
336
+ .resizer {
337
+ display: block;
338
+ }
339
+
340
+ .minimize {
341
+ display: block;
342
+ }
343
+ }
344
+ }
345
+ }
346
+
347
+ @include media-breakpoint-up(md) {
348
+ // without this formatting elements that are dropdowns are not visible on desktop.
349
+ // on mobile dropdowns use bottom-sheet and overflow is auto
350
+ .formatting-group {
351
+ overflow: visible!important;
352
+ }
337
353
  }
338
354
 
339
355
  @import './zen-mode';
@@ -5,6 +5,25 @@
5
5
  <li class="small spacer"></li>
6
6
  {{{ else }}}
7
7
  {{{ if (./visibility.desktop && ((isTopicOrMain && ./visibility.main) || (!isTopicOrMain && ./visibility.reply))) }}}
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}">
11
+ <i class="{./className}"></i>
12
+ </button>
13
+ <ul class="dropdown-menu p-1">
14
+ {{{ each ./dropdownItems }}}
15
+ <li data-format="{./name}">
16
+ <a href="#" class="dropdown-item rounded-1 position-relative">
17
+ <i class="{./className} text-secondary"></i> {./text}
18
+ {{{ if ./badge }}}
19
+ <span class="px-1 position-absolute top-0 start-100 translate-middle-x badge rounded text-bg-info"></span>
20
+ {{{ end }}}
21
+ </a>
22
+ </li>
23
+ {{{ end }}}
24
+ </ul>
25
+ </li>
26
+ {{{ else }}}
8
27
  <li class="btn btn-sm btn-link text-reset position-relative" tabindex="-1" data-format="{./name}" title="{./title}">
9
28
  <i class="{./className}"></i>
10
29
  {{{ if ./badge }}}
@@ -13,6 +32,7 @@
13
32
  </li>
14
33
  {{{ end }}}
15
34
  {{{ end }}}
35
+ {{{ end }}}
16
36
  {{{ end }}}
17
37
 
18
38
  {{{ if privileges.upload:post:image }}}
@@ -1,12 +0,0 @@
1
-
2
- .composer {
3
- min-height: 400px;
4
-
5
- .resizer {
6
- display: block;
7
- }
8
-
9
- .minimize {
10
- display: block;
11
- }
12
- }