nodebb-plugin-markdown 13.2.5 → 13.2.6

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 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, hostMiddleware.registrationComplete, hostMiddleware.pluginHooks,
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();
@@ -3,7 +3,7 @@
3
3
  const path = require('path');
4
4
 
5
5
  const parent = module.parent.exports;
6
- const posts = nodebb.require('./src/posts');
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 retrieveRaw(req, res, next) {
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
- posts.getPostField(pid, 'content', (err, content) => {
33
- if (err) {
34
- return next(err);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-markdown",
3
- "version": "13.2.5",
3
+ "version": "13.2.6",
4
4
  "description": "A Markdown parser for NodeBB",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -51,7 +51,7 @@ export function prepareFormattingTools() {
51
51
  'translator',
52
52
  ], function (formatting, controls, translator) {
53
53
  if (formatting && controls) {
54
- translator.getTranslations(window.config.userLang, 'markdown', function (strings) {
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) {