nodebb-plugin-composer-default 9.0.0 → 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 +4 -1
- package/static/less/composer.less +1 -0
- package/static/less/textcomplete.less +24 -0
- package/static/lib/client.js +1 -0
- package/static/lib/composer/autocomplete.js +10 -10
- package/static/lib/composer/drafts.js +10 -5
- package/static/lib/composer.js +4 -23
- package/static/templates/composer.tpl +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodebb-plugin-composer-default",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.2.0",
|
|
4
4
|
"description": "Default composer for NodeBB",
|
|
5
5
|
"main": "library.js",
|
|
6
6
|
"repository": {
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
"compatibility": "^2.5.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
+
"@textcomplete/contenteditable": "^0.1.12",
|
|
33
|
+
"@textcomplete/core": "^0.1.12",
|
|
34
|
+
"@textcomplete/textarea": "^0.1.12",
|
|
32
35
|
"screenfull": "^5.0.2",
|
|
33
36
|
"validator": "^13.7.0"
|
|
34
37
|
},
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.textcomplete-dropdown {
|
|
2
|
+
border: 1px solid #ddd;
|
|
3
|
+
background-color: white;
|
|
4
|
+
list-style: none;
|
|
5
|
+
padding: 0;
|
|
6
|
+
margin: 0;
|
|
7
|
+
|
|
8
|
+
li {
|
|
9
|
+
margin: 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.textcomplete-footer, .textcomplete-item {
|
|
13
|
+
border-top: 1px solid #ddd;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.textcomplete-item {
|
|
17
|
+
padding: 2px 5px;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
|
|
20
|
+
&:hover, &.active {
|
|
21
|
+
background-color: rgb(110, 183, 219);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
package/static/lib/client.js
CHANGED
|
@@ -65,23 +65,23 @@ define('composer/autocomplete', [
|
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
// This is a generic method that is also used by the chat
|
|
68
|
-
autocomplete.setup = function (
|
|
69
|
-
|
|
70
|
-
if (!
|
|
68
|
+
autocomplete.setup = function ({ element, strategies, options }) {
|
|
69
|
+
const targetEl = element.get(0);
|
|
70
|
+
if (!targetEl) {
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
var editor;
|
|
74
|
-
if (
|
|
75
|
-
editor = new TextareaEditor(
|
|
76
|
-
} else if (
|
|
77
|
-
editor = new ContenteditableEditor(
|
|
74
|
+
if (targetEl.nodeName === 'TEXTAREA') {
|
|
75
|
+
editor = new TextareaEditor(targetEl);
|
|
76
|
+
} else if (targetEl.nodeName === 'DIV' && targetEl.getAttribute('contenteditable') === 'true') {
|
|
77
|
+
editor = new ContenteditableEditor(targetEl);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// yuku-t/textcomplete inherits directionality from target element itself
|
|
81
|
-
|
|
81
|
+
targetEl.setAttribute('dir', document.querySelector('html').getAttribute('data-dir'));
|
|
82
82
|
|
|
83
|
-
var textcomplete = new Textcomplete(editor,
|
|
84
|
-
dropdown:
|
|
83
|
+
var textcomplete = new Textcomplete(editor, strategies, {
|
|
84
|
+
dropdown: options,
|
|
85
85
|
});
|
|
86
86
|
textcomplete.on('rendered', function () {
|
|
87
87
|
if (textcomplete.dropdown.items.length) {
|
|
@@ -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
|
|
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,
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
263
|
+
handle: app.user && app.user.uid ? undefined : utils.escapeHTML(draft.handle),
|
|
264
|
+
title: utils.escapeHTML(draft.title),
|
|
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);
|
package/static/lib/composer.js
CHANGED
|
@@ -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]]"
|
|
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">
|