From 11bb2f1560133d4a412558c82ebd839a75b32acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 30 May 2018 14:21:03 -0400 Subject: [PATCH] closes #6528 --- public/less/admin/admin.less | 1 + public/less/admin/manage/post-queue.less | 8 ++++++++ public/src/admin/manage/post-queue.js | 21 +++++++++++++++++---- src/controllers/admin/postqueue.js | 6 ++++++ src/socket.io/posts.js | 10 +++++++++- src/views/admin/manage/post-queue.tpl | 5 ++++- 6 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 public/less/admin/manage/post-queue.less diff --git a/public/less/admin/admin.less b/public/less/admin/admin.less index a2f2ee5891..364606bbda 100644 --- a/public/less/admin/admin.less +++ b/public/less/admin/admin.less @@ -16,6 +16,7 @@ @import "./manage/registration"; @import "./manage/users"; @import "./manage/admins-mods"; +@import "./manage/post-queue"; @import "./appearance/customise"; @import "./appearance/themes"; @import "./extend/plugins"; diff --git a/public/less/admin/manage/post-queue.less b/public/less/admin/manage/post-queue.less new file mode 100644 index 0000000000..b4139e02ef --- /dev/null +++ b/public/less/admin/manage/post-queue.less @@ -0,0 +1,8 @@ +.posts-list { + .post-content-editable { + textarea { + width: 100%; + height: 300px; + } + } +} diff --git a/public/src/admin/manage/post-queue.js b/public/src/admin/manage/post-queue.js index 9413a839e2..f3a023b5d2 100644 --- a/public/src/admin/manage/post-queue.js +++ b/public/src/admin/manage/post-queue.js @@ -22,15 +22,28 @@ define('admin/manage/post-queue', function () { return false; }); - $('.posts-list').on('input', '[data-id]', function () { + $('.posts-list').on('click', '.post-content', function () { var el = $(this); + el.addClass('hidden'); + var textareaParent = el.parent().find('.post-content-editable'); + textareaParent.removeClass('hidden').find('textarea').focus(); + }); + + $('.posts-list').on('blur', '.post-content-editable textarea', function () { + var textarea = $(this); + var preview = textarea.parent().parent().find('.post-content'); + var id = textarea.parents('[data-id]').attr('data-id'); + socket.emit('posts.editQueuedContent', { - id: el.attr('data-id'), - content: el.find('.post-content').html(), - }, function (err) { + id: id, + content: textarea.val(), + }, function (err, data) { if (err) { return app.alertError(err); } + preview.html(data.postData.content); + textarea.parent().addClass('hidden'); + preview.removeClass('hidden'); }); }); }; diff --git a/src/controllers/admin/postqueue.js b/src/controllers/admin/postqueue.js index 29c56b9f80..66ce1e237f 100644 --- a/src/controllers/admin/postqueue.js +++ b/src/controllers/admin/postqueue.js @@ -7,6 +7,7 @@ var user = require('../../user'); var topics = require('../../topics'); var categories = require('../../categories'); var pagination = require('../../pagination'); +var plugins = require('../../plugins'); var utils = require('../../utils'); var postQueueController = module.exports; @@ -79,6 +80,7 @@ function getQueuedPosts(ids, callback) { }); async.map(postData, function (postData, next) { + postData.data.rawContent = postData.data.content; async.waterfall([ function (next) { if (postData.data.cid) { @@ -95,6 +97,10 @@ function getQueuedPosts(ids, callback) { }, function (categoryData, next) { postData.category = categoryData; + plugins.fireHook('filter:parse.post', { postData: postData.data }, next); + }, + function (result, next) { + postData.data.content = result.postData.content; next(null, postData); }, ], next); diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js index b8c4695c69..69b87102c2 100644 --- a/src/socket.io/posts.js +++ b/src/socket.io/posts.js @@ -4,6 +4,7 @@ var async = require('async'); var posts = require('../posts'); var privileges = require('../privileges'); +var plugins = require('../plugins'); var meta = require('../meta'); var topics = require('../topics'); var user = require('../user'); @@ -184,7 +185,14 @@ SocketPosts.editQueuedContent = function (socket, data, callback) { if (!data || !data.id || !data.content) { return callback(new Error('[[error:invalid-data]]')); } - posts.editQueuedContent(socket.uid, data.id, data.content, callback); + async.waterfall([ + function (next) { + posts.editQueuedContent(socket.uid, data.id, data.content, next); + }, + function (next) { + plugins.fireHook('filter:parse.post', { postData: data }, next); + }, + ], callback); }; function acceptOrReject(method, socket, data, callback) { diff --git a/src/views/admin/manage/post-queue.tpl b/src/views/admin/manage/post-queue.tpl index 7a84b09ed4..03f7848f1d 100644 --- a/src/views/admin/manage/post-queue.tpl +++ b/src/views/admin/manage/post-queue.tpl @@ -42,7 +42,10 @@ {posts.data.title} - {posts.data.content} + {posts.data.content} + + +