nodebb-plugin-markdown 13.2.5 → 13.2.7
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/index.js +4 -2
- package/lib/controllers.js +7 -14
- package/package.json +1 -1
- package/public/js/markdown.js +1 -1
- package/public/templates/modals/markdown-help.tpl +1 -1
package/index.js
CHANGED
|
@@ -24,13 +24,15 @@ const Markdown = {
|
|
|
24
24
|
const hostMiddleware = nodebb.require('./src/middleware');
|
|
25
25
|
const routeHelpers = nodebb.require('./src/routes/helpers');
|
|
26
26
|
const middlewares = [
|
|
27
|
-
hostMiddleware.maintenanceMode,
|
|
27
|
+
hostMiddleware.maintenanceMode,
|
|
28
|
+
hostMiddleware.registrationComplete,
|
|
29
|
+
hostMiddleware.pluginHooks,
|
|
28
30
|
];
|
|
29
31
|
|
|
30
32
|
routeHelpers.setupAdminPageRoute(router, '/admin/plugins/markdown', controllers.renderAdmin);
|
|
31
33
|
|
|
32
34
|
// Return raw markdown via GET
|
|
33
|
-
router.get('/api/post/:pid/raw', middlewares, controllers.retrieveRaw);
|
|
35
|
+
router.get('/api/post/:pid/raw', middlewares, routeHelpers.tryRoute(controllers.retrieveRaw));
|
|
34
36
|
|
|
35
37
|
Markdown.init();
|
|
36
38
|
await Markdown.loadThemes();
|
package/lib/controllers.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
|
|
5
5
|
const parent = module.parent.exports;
|
|
6
|
-
const
|
|
6
|
+
const postsAPI = nodebb.require('./src/api/posts');
|
|
7
7
|
const file = nodebb.require('./src/file');
|
|
8
8
|
const { paths } = nodebb.require('./src/constants');
|
|
9
9
|
|
|
@@ -22,21 +22,14 @@ Controllers.renderAdmin = async function renderAdmin(req, res) {
|
|
|
22
22
|
});
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
Controllers.retrieveRaw = function
|
|
25
|
+
Controllers.retrieveRaw = async function (req, res, next) {
|
|
26
26
|
const pid = parseInt(req.params.pid, 10);
|
|
27
|
-
|
|
28
27
|
if (!pid) {
|
|
29
28
|
return next();
|
|
30
29
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
res.json({
|
|
38
|
-
pid: pid,
|
|
39
|
-
content: content,
|
|
40
|
-
});
|
|
41
|
-
});
|
|
30
|
+
const content = await postsAPI.getRawPost({ uid: req.uid }, { pid });
|
|
31
|
+
if (content === null) {
|
|
32
|
+
return next();
|
|
33
|
+
}
|
|
34
|
+
res.json({ pid, content });
|
|
42
35
|
};
|
package/package.json
CHANGED
package/public/js/markdown.js
CHANGED
|
@@ -51,7 +51,7 @@ export function prepareFormattingTools() {
|
|
|
51
51
|
'translator',
|
|
52
52
|
], function (formatting, controls, translator) {
|
|
53
53
|
if (formatting && controls) {
|
|
54
|
-
translator.getTranslations(
|
|
54
|
+
translator.getTranslations(config.userLang, 'markdown', function (strings) {
|
|
55
55
|
// used for h1,h2...h6
|
|
56
56
|
function formatHeading(heading, textarea, selectionStart, selectionEnd) {
|
|
57
57
|
if (selectionStart === selectionEnd) {
|