Selaa lähdekoodia

Merge remote-tracking branch 'origin/master' into rc/3.1.0

Yuki Takei 8 vuotta sitten
vanhempi
sitoutus
8d0792e4b8

+ 1 - 1
CHANGES.md

@@ -3,7 +3,7 @@ CHANGES
 
 ## 3.0.14
 
-* 
+* Improvement: Auto-format markdown tables which includes multibyte text
 
 ## 3.0.13
 

+ 9 - 4
config/webpack.common.js

@@ -3,7 +3,6 @@
  */
 
 const webpack = require('webpack');
-const path = require('path');
 const helpers = require('./helpers');
 
 /*
@@ -44,8 +43,8 @@ module.exports = function(options) {
       extensions: ['.js', '.json'],
       modules: [helpers.root('src'), helpers.root('node_modules')],
       alias: {
-        '@root': path.resolve(__dirname, '../'),
-        '@alias/logger': path.resolve(__dirname, '../lib/service/logger'),
+        '@root': helpers.root('/'),
+        '@alias/logger': helpers.root('lib/service/logger'),
         // replace bunyan
         'bunyan': 'browser-bunyan',
       }
@@ -54,7 +53,13 @@ module.exports = function(options) {
       rules: [
         {
           test: /.jsx?$/,
-          exclude: /node_modules/,
+          exclude: {
+            test:    helpers.root('node_modules'),
+            exclude: [  // include as a result
+              helpers.root('node_modules/string-width'),
+              helpers.root('node_modules/is-fullwidth-code-point'), // depends from string-width
+            ]
+          },
           use: [{
             loader: 'babel-loader?cacheDirectory',
             options: {

+ 5 - 3
lib/util/swigFunctions.js

@@ -1,5 +1,6 @@
 module.exports = function(crowi, app, req, locals) {
   var debug = require('debug')('growi:lib:swigFunctions')
+    , stringWidth = require('string-width')
     , Page = crowi.model('Page')
     , Config = crowi.model('Config')
     , User = crowi.model('User')
@@ -28,10 +29,11 @@ module.exports = function(crowi, app, req, locals) {
   };
 
   locals.getAppTitleFontSize = function(appTitle) {
+    let appTitleWidth = stringWidth(appTitle);
     let fontSize = 22;
-    if (appTitle.length < 13) { /* do nothing */ }
-    else if (appTitle.length < 21) {
-      fontSize -= 3 * (Math.floor((appTitle.length - 13) / 3) + 1);
+    if (appTitleWidth < 13) { /* do nothing */ }
+    else if (appTitleWidth < 21) {
+      fontSize -= 3 * (Math.floor((appTitleWidth - 13) / 3) + 1);
     }
     else  {
       fontSize = 11;

+ 1 - 0
package.json

@@ -167,6 +167,7 @@
     "sinon": "^5.0.2",
     "sinon-chai": "^3.0.0",
     "socket.io-client": "^2.0.3",
+    "string-width": "^2.1.1",
     "style-loader": "^0.21.0",
     "throttle-debounce": "^1.0.1",
     "toastr": "^2.1.2",

+ 0 - 2
resource/js/app.js

@@ -21,7 +21,6 @@ import RevisionPath     from './components/Page/RevisionPath';
 import RevisionUrl      from './components/Page/RevisionUrl';
 import BookmarkButton   from './components/BookmarkButton';
 import NewPageNameInputter from './components/NewPageNameInputter';
-import SearchTypeahead  from './components/SearchTypeahead';
 
 import CustomCssEditor  from './components/Admin/CustomCssEditor';
 import CustomScriptEditor from './components/Admin/CustomScriptEditor';
@@ -29,7 +28,6 @@ import CustomHeaderEditor from './components/Admin/CustomHeaderEditor';
 
 import * as entities from 'entities';
 
-
 if (!window) {
   window = {};
 }

+ 4 - 3
resource/js/components/PageEditor/MarkdownTableUtil.js

@@ -1,4 +1,5 @@
-import markdown_table from 'markdown-table';
+import markdownTable from 'markdown-table';
+import stringWidth from 'string-width';
 
 /**
  * Utility for markdown table
@@ -128,7 +129,7 @@ class MarkdownTableUtil {
         contents.push(row);
       }
     }
-    return (new MarkdownTable(contents, { align: aligns }));
+    return (new MarkdownTable(contents, { align: aligns, stringLength: stringWidth }));
   }
 
   /**
@@ -200,7 +201,7 @@ class MarkdownTable {
   }
 
   toString() {
-    return markdown_table(this.table, this.options);
+    return markdownTable(this.table, this.options);
   }
 }
 

+ 0 - 5
resource/styles/scss/_admin.scss

@@ -26,11 +26,6 @@
         margin-left: 1em;
       }
     }
-
-    // override CodeMirror styles
-    .CodeMirror pre {
-      font-family: $font-family-monospace;
-    }
   }
 
   .admin-security {

+ 0 - 3
resource/styles/scss/_on-edit.scss

@@ -174,9 +174,6 @@ body.on-edit {
     padding-right: 0;
     // override CodeMirror styles
     .CodeMirror {
-      pre {
-        font-family: $font-family-monospace-not-strictly;
-      }
       .cm-matchhighlight {
         background-color: cyan;
       }

+ 1 - 1
resource/styles/scss/_variables.scss

@@ -1,2 +1,2 @@
 // override bootstrap
-$font-family-monospace-not-strictly:   Monaco, Menlo, Consolas, "Courier New", MeiryoKe_Console, "M+ 1m", monospace;
+$font-family-monospace-not-strictly: Monaco, Menlo, Consolas, "Courier New", MeiryoKe_Gothic, monospace;