nodebb-plugin-composer-default 10.3.11 → 10.3.13

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/library.js CHANGED
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const url = require('url');
4
3
 
5
4
  const nconf = require.main.require('nconf');
6
5
  const validator = require('validator');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-composer-default",
3
- "version": "10.3.11",
3
+ "version": "10.3.13",
4
4
  "description": "Default composer for NodeBB",
5
5
  "main": "library.js",
6
6
  "repository": {
@@ -33,10 +33,13 @@ define('composer/autocomplete', [
33
33
  element: element,
34
34
  strategies: [],
35
35
  options: {
36
+ placement: 'bottom',
36
37
  style: {
37
38
  'z-index': 20000,
39
+ 'max-height': '250px',
40
+ overflow: 'auto',
38
41
  },
39
- className: dropdownClass + ' dropdown-menu textcomplete-dropdown',
42
+ className: dropdownClass + ' dropdown-menu textcomplete-dropdown ghost-scrollbar',
40
43
  },
41
44
  };
42
45
 
@@ -63,6 +63,7 @@ define('composer/preview', ['hooks'], function (hooks) {
63
63
  }
64
64
 
65
65
  function togglePreview(show) {
66
+ const isMobile = ['xs', 'sm'].includes(preview.env);
66
67
  if (isMobile) {
67
68
  previewContainer.classList.toggle('hide', false);
68
69
  writeContainer.classList.toggle('maximized', false);
@@ -40,7 +40,7 @@ define('composer', [
40
40
  localStorage.removeItem('category:' + data.data.cid + ':bookmark:clicked');
41
41
  });
42
42
 
43
- $(window).on('popstate', function () {
43
+ window.addEventListener('popstate', function () {
44
44
  var env = utils.findBootstrapEnvironment();
45
45
  if (composer.active && (env === 'xs' || env === 'sm')) {
46
46
  if (!composer.posts[composer.active].modified) {
@@ -74,29 +74,17 @@ define('composer', [
74
74
  var env = utils.findBootstrapEnvironment();
75
75
  var isMobile = env === 'xs' || env === 'sm';
76
76
 
77
- if (preview.toggle) {
78
- if (preview.env !== env && isMobile) {
79
- preview.env = env;
80
- preview.toggle(false);
81
- }
77
+ if (preview.toggle && preview.env !== env) {
82
78
  preview.env = env;
79
+ preview.toggle(!isMobile);
83
80
  }
84
81
 
85
82
  if (composer.active !== undefined) {
86
83
  resize.reposition($('.composer[data-uuid="' + composer.active + '"]'));
87
84
 
88
- if (!isMobile && window.location.pathname.startsWith(config.relative_path + '/compose')) {
89
- /*
90
- * If this conditional is met, we're no longer in mobile/tablet
91
- * resolution but we've somehow managed to have a mobile
92
- * composer load, so let's go back to the topic
93
- */
85
+ if (!isMobile && window.history.state && window.history.state.composerBackState) {
94
86
  history.back();
95
- } else if (isMobile && !window.location.pathname.startsWith(config.relative_path + '/compose')) {
96
- /*
97
- * In this case, we're in mobile/tablet resolution but the composer
98
- * that loaded was a regular composer, so let's fix the address bar
99
- */
87
+ } else if (isMobile) {
100
88
  mobileHistoryAppend();
101
89
  }
102
90
  }
@@ -562,27 +550,22 @@ define('composer', [
562
550
  }
563
551
 
564
552
  function mobileHistoryAppend() {
565
- var path = 'compose?p=' + window.location.pathname;
566
- var returnPath = window.location.pathname.slice(1) + window.location.search;
567
-
568
- // Remove relative path from returnPath
569
- if (config.relative_path && returnPath.startsWith(config.relative_path.slice(1))) {
570
- returnPath = returnPath.slice(config.relative_path.length - 1);
571
- if (returnPath.startsWith('/')) {
572
- returnPath = returnPath.slice(1);
573
- }
553
+ // add a fake entry to the browser history so that the user can
554
+ // press back to return to where they were before opening the composer
555
+ // popstate listener in this file closes the composer on mobile,
556
+ // browser automatically removes the fake entry when user presses back
557
+ if (window.history.state && !window.history.state.composerBackState) {
558
+ // modify current state so that ajaxify.go doesn't
559
+ // trigger when user presses back from composer
560
+ window.history.replaceState({
561
+ url: null,
562
+ returnPath: history.state.url,
563
+ }, ''); // 3rd param optional url, we dont change it
564
+
565
+ window.history.pushState({
566
+ composerBackState: true,
567
+ }, ''); // 3rd param optional url, we dont change it
574
568
  }
575
-
576
- // Add in return path to be caught by ajaxify when post is completed, or if back is pressed
577
- window.history.replaceState({
578
- url: null,
579
- returnPath: returnPath,
580
- }, '', `${config.relative_path}/${returnPath}`);
581
-
582
- // Update address bar in case f5 is pressed
583
- window.history.pushState({
584
- url: path,
585
- }, '', `${config.relative_path}/${returnPath}`);
586
569
  }
587
570
 
588
571
  function handleRemotePid(postContainer) {