nodebb-plugin-composer-default 10.3.24 → 10.3.26
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 +1 -1
- package/static/lib/composer/drafts.js +40 -40
- package/static/lib/composer/tags.js +1 -1
- package/static/lib/composer.js +25 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
define('composer/drafts', ['api', 'hooks'
|
|
3
|
+
define('composer/drafts', ['api', 'hooks'], function (api, hooks) {
|
|
4
4
|
const drafts = {};
|
|
5
5
|
const draftSaveDelay = 1000;
|
|
6
6
|
drafts.init = function (postContainer, postData) {
|
|
@@ -250,51 +250,51 @@ define('composer/drafts', ['api', 'hooks', 'alerts'], function (api, hooks, aler
|
|
|
250
250
|
}
|
|
251
251
|
};
|
|
252
252
|
|
|
253
|
-
function openComposer(save_id, draft) {
|
|
253
|
+
async function openComposer(save_id, draft) {
|
|
254
254
|
const saveObj = save_id.split(':');
|
|
255
255
|
const uid = saveObj[1];
|
|
256
256
|
// Don't open other peoples' drafts
|
|
257
257
|
if (parseInt(app.user.uid, 10) !== parseInt(uid, 10)) {
|
|
258
258
|
return;
|
|
259
259
|
}
|
|
260
|
-
require(
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
260
|
+
const composer = await app.require('composer');
|
|
261
|
+
if (draft.action === 'topics.post') {
|
|
262
|
+
let composerData = {
|
|
263
|
+
fromDraft: true,
|
|
264
|
+
save_id: draft.save_id,
|
|
265
|
+
cid: draft.cid,
|
|
266
|
+
handle: app.user && app.user.uid ? undefined : utils.escapeHTML(draft.handle),
|
|
267
|
+
title: utils.escapeHTML(draft.title),
|
|
268
|
+
body: draft.text,
|
|
269
|
+
tags: String(draft.tags || '').split(','),
|
|
270
|
+
thumbs: draft.thumbs || [],
|
|
271
|
+
};
|
|
272
|
+
({ composerData } = await hooks.fire('filter:composer.drafts.open', { draft, composerData }));
|
|
273
|
+
composer.newTopic(composerData);
|
|
274
|
+
} else if (draft.action === 'posts.reply') {
|
|
275
|
+
const topicObj = await api.get('/topics/' + draft.tid, {});
|
|
276
|
+
let composerData = {
|
|
277
|
+
fromDraft: true,
|
|
278
|
+
save_id: draft.save_id,
|
|
279
|
+
tid: draft.tid,
|
|
280
|
+
toPid: draft.toPid,
|
|
281
|
+
title: topicObj.title,
|
|
282
|
+
body: draft.text,
|
|
283
|
+
};
|
|
284
|
+
({ composerData } = await hooks.fire('filter:composer.drafts.open', { draft, composerData }));
|
|
285
|
+
composer.newReply(composerData);
|
|
286
|
+
} else if (draft.action === 'posts.edit') {
|
|
287
|
+
let composerData = {
|
|
288
|
+
fromDraft: true,
|
|
289
|
+
save_id: draft.save_id,
|
|
290
|
+
pid: draft.pid,
|
|
291
|
+
title: draft.title ? utils.escapeHTML(draft.title) : undefined,
|
|
292
|
+
body: draft.text,
|
|
293
|
+
thumbs: draft.thumbs || [],
|
|
294
|
+
};
|
|
295
|
+
({ composerData } = await hooks.fire('filter:composer.drafts.open', { draft, composerData }));
|
|
296
|
+
composer.editPost(composerData);
|
|
297
|
+
}
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
// Feature detection courtesy of: https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API
|
|
@@ -17,7 +17,7 @@ define('composer/tags', ['alerts'], function (alerts) {
|
|
|
17
17
|
maxTags = ajaxify.data.hasOwnProperty('maxTags') ? ajaxify.data.maxTags : config.maximumTagsPerTopic;
|
|
18
18
|
|
|
19
19
|
tagEl.tagsinput({
|
|
20
|
-
tagClass: 'badge
|
|
20
|
+
tagClass: 'badge rounded-1',
|
|
21
21
|
confirmKeys: [13, 44],
|
|
22
22
|
trimValue: true,
|
|
23
23
|
});
|
package/static/lib/composer.js
CHANGED
|
@@ -253,20 +253,24 @@ define('composer', [
|
|
|
253
253
|
});
|
|
254
254
|
};
|
|
255
255
|
|
|
256
|
-
composer.newReply = function (data) {
|
|
257
|
-
translator.translate(data.body, config.defaultLang
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
256
|
+
composer.newReply = async function (data) {
|
|
257
|
+
const translated = await translator.translate(data.body, config.defaultLang);
|
|
258
|
+
let pushData = {
|
|
259
|
+
fromDraft: data.fromDraft,
|
|
260
|
+
save_id: data.save_id,
|
|
261
|
+
action: 'posts.reply',
|
|
262
|
+
tid: data.tid,
|
|
263
|
+
toPid: data.toPid,
|
|
264
|
+
title: data.title,
|
|
265
|
+
body: translated,
|
|
266
|
+
modified: !!(translated && translated.length),
|
|
267
|
+
isMain: false,
|
|
268
|
+
};
|
|
269
|
+
({ pushData } = await hooks.fire('filter:composer.reply.push', {
|
|
270
|
+
data: data,
|
|
271
|
+
pushData: pushData,
|
|
272
|
+
}));
|
|
273
|
+
push(pushData);
|
|
270
274
|
};
|
|
271
275
|
|
|
272
276
|
composer.editPost = function (data) {
|
|
@@ -880,5 +884,12 @@ define('composer', [
|
|
|
880
884
|
}
|
|
881
885
|
};
|
|
882
886
|
|
|
887
|
+
composer.updateFormattingBtnBadgeCount = function (postContainer, formatName, count) {
|
|
888
|
+
const formatEl = postContainer.find(`[data-format="${formatName}"]`);
|
|
889
|
+
formatEl.find('.badge')
|
|
890
|
+
.text(count)
|
|
891
|
+
.toggleClass('hidden', !count);
|
|
892
|
+
};
|
|
893
|
+
|
|
883
894
|
return composer;
|
|
884
895
|
});
|