mirror of
https://hk.gh-proxy.com/https://github.com/NodeBB/nodebb-plugin-composer-default.git
synced 2025-10-03 04:31:23 +08:00
This commit is contained in:
parent
3222cc06a7
commit
e2e72ccf84
2 changed files with 14 additions and 1 deletions
|
@ -460,10 +460,11 @@ define('composer', [
|
|||
var title = postData.title.replace(/%/g, '%').replace(/,/g, ',');
|
||||
postData.category = await getSelectedCategory(postData);
|
||||
const privileges = postData.category ? postData.category.privileges : ajaxify.data.privileges;
|
||||
const topicTemplate = isTopic && postData.category ? postData.category.topicTemplate : null;
|
||||
var data = {
|
||||
topicTitle: title,
|
||||
titleLength: title.length,
|
||||
body: translator.escape(utils.escapeHTML(postData.body)),
|
||||
body: translator.escape(utils.escapeHTML(topicTemplate || postData.body)),
|
||||
mobile: composer.bsEnvironment === 'xs' || composer.bsEnvironment === 'sm',
|
||||
resizable: true,
|
||||
thumb: postData.thumb,
|
||||
|
|
|
@ -92,11 +92,23 @@ define('composer/categoryList', [
|
|||
}
|
||||
}
|
||||
|
||||
function updateTopicTemplate(postContainer, category, previousCategory) {
|
||||
const currentText = postContainer.find('textarea.write').val();
|
||||
const previousTopicTemplate = previousCategory && previousCategory.topicTemplate;
|
||||
if (category && (!currentText.length || currentText === previousTopicTemplate) &&
|
||||
currentText !== category.topicTemplate) {
|
||||
postContainer.find('textarea.write').val(category.topicTemplate).trigger('input');
|
||||
}
|
||||
}
|
||||
|
||||
async function changeCategory(postContainer, postData, selectedCategory) {
|
||||
const previousCategory = postData.category;
|
||||
postData.cid = selectedCategory.cid;
|
||||
const categoryData = await window.fetch(`${config.relative_path}/api/category/${encodeURIComponent(selectedCategory.cid)}`).then(r => r.json());
|
||||
postData.category = categoryData;
|
||||
updateTaskbarByCategory(postContainer, categoryData);
|
||||
updateTopicTemplate(postContainer, categoryData, previousCategory);
|
||||
|
||||
require(['composer/scheduler', 'composer/tags', 'composer/post-queue'], function (scheduler, tags, postQueue) {
|
||||
scheduler.onChangeCategory(categoryData);
|
||||
tags.onChangeCategory(postContainer, postData, selectedCategory.cid, categoryData);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue