Просмотр исходного кода

Merge pull request #1119 from weseek/imprv/eslint-warnings

Imprv/eslint warnings
Yuki Takei 6 лет назад
Родитель
Сommit
1ffb36ed24

+ 0 - 4
.eslintrc.js

@@ -30,10 +30,6 @@ module.exports = {
         FunctionExpression: { body: 1, parameters: 2 },
         FunctionExpression: { body: 1, parameters: 2 },
       },
       },
     ],
     ],
-    'react/jsx-filename-extension': [
-      'warn',
-      { extensions: ['.jsx']},
-    ],
     // eslint-plugin-import rules
     // eslint-plugin-import rules
     'import/no-unresolved': [2, { ignore: ['^@'] }], // ignore @alias/..., @commons/..., ...
     'import/no-unresolved': [2, { ignore: ['^@'] }], // ignore @alias/..., @commons/..., ...
   },
   },

+ 2 - 0
CHANGES.md

@@ -2,6 +2,8 @@
 
 
 ## 3.5.3-RC
 ## 3.5.3-RC
 
 
+* Improvement: Calculate string width when save with Spreadsheet like GUI (Handsontable)
+* Fix: Dropdown to copy page path/URL/MarkdownLink shows under CodeMirror vscrollbar
 * Fix: Search Result Page doesn't work
 * Fix: Search Result Page doesn't work
 * Fix: Create/Update page API returns data includes author's password hash
 * Fix: Create/Update page API returns data includes author's password hash
 
 

+ 0 - 2
src/client/js/app.js → src/client/js/app.jsx

@@ -1,5 +1,3 @@
-/* eslint-disable max-len */
-
 import React from 'react';
 import React from 'react';
 import ReactDOM from 'react-dom';
 import ReactDOM from 'react-dom';
 import { Provider } from 'unstated';
 import { Provider } from 'unstated';

+ 0 - 0
src/client/js/components/Admin/CustomCssEditor.js → src/client/js/components/Admin/CustomCssEditor.jsx


+ 0 - 0
src/client/js/components/Admin/CustomHeaderEditor.js → src/client/js/components/Admin/CustomHeaderEditor.jsx


+ 0 - 0
src/client/js/components/Admin/CustomScriptEditor.js → src/client/js/components/Admin/CustomScriptEditor.jsx


+ 0 - 0
src/client/js/components/Page/PagePath.js → src/client/js/components/Page/PagePath.jsx


+ 0 - 0
src/client/js/components/Page/RevisionBody.js → src/client/js/components/Page/RevisionBody.jsx


+ 0 - 0
src/client/js/components/PageAttachment/Attachment.js → src/client/js/components/PageAttachment/Attachment.jsx


+ 0 - 0
src/client/js/components/PageAttachment/DeleteAttachmentModal.js → src/client/js/components/PageAttachment/DeleteAttachmentModal.jsx


+ 0 - 0
src/client/js/components/PageAttachment/PageAttachmentList.js → src/client/js/components/PageAttachment/PageAttachmentList.jsx


+ 0 - 0
src/client/js/components/PageEditor/MarkdownTableUtil.jsx → src/client/js/components/PageEditor/MarkdownTableUtil.js


+ 0 - 0
src/client/js/components/SearchForm.js → src/client/js/components/SearchForm.jsx


+ 0 - 0
src/client/js/components/SearchPage.js → src/client/js/components/SearchPage.jsx


+ 0 - 0
src/client/js/components/SearchTypeahead.js → src/client/js/components/SearchTypeahead.jsx


+ 21 - 21
src/client/js/legacy/crowi.js

@@ -1,4 +1,4 @@
-/* eslint no-restricted-globals: ['error', 'locaion'] */
+/* eslint-disable react/jsx-filename-extension */
 
 
 import React from 'react';
 import React from 'react';
 import ReactDOM from 'react-dom';
 import ReactDOM from 'react-dom';
@@ -340,7 +340,7 @@ $(() => {
     if (input2 === '') {
     if (input2 === '') {
       prefix2 = prefix2.slice(0, -1);
       prefix2 = prefix2.slice(0, -1);
     }
     }
-    top.location.href = `${prefix1 + input1 + prefix2 + input2}#edit`;
+    window.location.href = `${prefix1 + input1 + prefix2 + input2}#edit`;
     return false;
     return false;
   });
   });
 
 
@@ -352,7 +352,7 @@ $(() => {
     if (name.match(/.+\/$/)) {
     if (name.match(/.+\/$/)) {
       name = name.substr(0, name.length - 1);
       name = name.substr(0, name.length - 1);
     }
     }
-    top.location.href = `${pathUtils.encodePagePath(name)}#edit`;
+    window.location.href = `${pathUtils.encodePagePath(name)}#edit`;
     return false;
     return false;
   });
   });
 
 
@@ -387,7 +387,7 @@ $(() => {
         }
         }
         else {
         else {
           const page = res.page;
           const page = res.page;
-          top.location.href = `${page.path}?renamed=${pagePath}`;
+          window.location.href = `${page.path}?renamed=${pagePath}`;
         }
         }
       });
       });
 
 
@@ -424,7 +424,7 @@ $(() => {
       }
       }
       else {
       else {
         const page = res.page;
         const page = res.page;
-        top.location.href = `${page.path}?duplicated=${pagePath}`;
+        window.location.href = `${page.path}?duplicated=${pagePath}`;
       }
       }
     });
     });
 
 
@@ -456,7 +456,7 @@ $(() => {
       }
       }
       else {
       else {
         const page = res.page;
         const page = res.page;
-        top.location.href = page.path;
+        window.location.href = page.path;
       }
       }
     });
     });
 
 
@@ -481,7 +481,7 @@ $(() => {
       }
       }
       else {
       else {
         const page = res.page;
         const page = res.page;
-        top.location.href = page.path;
+        window.location.href = page.path;
       }
       }
     });
     });
 
 
@@ -500,7 +500,7 @@ $(() => {
           $('#delete-errors').addClass('alert-danger');
           $('#delete-errors').addClass('alert-danger');
         }
         }
         else {
         else {
-          top.location.href = `${res.path}?unlinked=true`;
+          window.location.href = `${res.path}?unlinked=true`;
         }
         }
       });
       });
 
 
@@ -527,7 +527,7 @@ $(() => {
     $('#edit').removeClass('active');
     $('#edit').removeClass('active');
     $('body').removeClass('on-edit');
     $('body').removeClass('on-edit');
     $('body').removeClass('builtin-editor');
     $('body').removeClass('builtin-editor');
-    location.hash = '#';
+    window.location.hash = '#';
   });
   });
 
 
   /*
   /*
@@ -598,7 +598,7 @@ $(() => {
 
 
       const editorContainer = appContainer.getContainer('EditorContainer');
       const editorContainer = appContainer.getContainer('EditorContainer');
       editorContainer.saveDraft(path, template);
       editorContainer.saveDraft(path, template);
-      top.location.href = `${path}#edit`;
+      window.location.href = `${path}#edit`;
     });
     });
 
 
     if (!isSeen) {
     if (!isSeen) {
@@ -675,7 +675,7 @@ $(() => {
     $('a[data-toggle="tab"][href="#revision-body"]').on('show.bs.tab', () => {
     $('a[data-toggle="tab"][href="#revision-body"]').on('show.bs.tab', () => {
       // couln't solve https://github.com/weseek/crowi-plus/issues/119 completely -- 2017.07.03 Yuki Takei
       // couln't solve https://github.com/weseek/crowi-plus/issues/119 completely -- 2017.07.03 Yuki Takei
       window.location.hash = '#';
       window.location.hash = '#';
-      window.history.replaceState('', '', location.href);
+      window.history.replaceState('', '', window.location.href);
     });
     });
   }
   }
   else {
   else {
@@ -689,7 +689,7 @@ $(() => {
       window.history.replaceState('', 'HackMD', '#hackmd');
       window.history.replaceState('', 'HackMD', '#hackmd');
     });
     });
     $('a[data-toggle="tab"][href="#revision-body"]').on('show.bs.tab', () => {
     $('a[data-toggle="tab"][href="#revision-body"]').on('show.bs.tab', () => {
-      window.history.replaceState('', '', location.href.replace(location.hash, ''));
+      window.history.replaceState('', '', window.location.href.replace(window.location.hash, ''));
     });
     });
     // replace all href="#edit" link behaviors
     // replace all href="#edit" link behaviors
     $(document).on('click', 'a[href="#edit"]', () => {
     $(document).on('click', 'a[href="#edit"]', () => {
@@ -707,8 +707,8 @@ window.addEventListener('load', (e) => {
   const { appContainer } = window;
   const { appContainer } = window;
 
 
   // hash on page
   // hash on page
-  if (location.hash) {
-    if ((location.hash === '#edit' || location.hash === '#edit-form') && $('.tab-pane#edit').length > 0) {
+  if (window.location.hash) {
+    if ((window.location.hash === '#edit' || window.location.hash === '#edit-form') && $('.tab-pane#edit').length > 0) {
       appContainer.setState({ editorMode: 'builtin' });
       appContainer.setState({ editorMode: 'builtin' });
 
 
       $('a[data-toggle="tab"][href="#edit"]').tab('show');
       $('a[data-toggle="tab"][href="#edit"]').tab('show');
@@ -718,14 +718,14 @@ window.addEventListener('load', (e) => {
       // focus
       // focus
       Crowi.setCaretLineAndFocusToEditor();
       Crowi.setCaretLineAndFocusToEditor();
     }
     }
-    else if (location.hash === '#hackmd' && $('.tab-pane#hackmd').length > 0) {
+    else if (window.location.hash === '#hackmd' && $('.tab-pane#hackmd').length > 0) {
       appContainer.setState({ editorMode: 'hackmd' });
       appContainer.setState({ editorMode: 'hackmd' });
 
 
       $('a[data-toggle="tab"][href="#hackmd"]').tab('show');
       $('a[data-toggle="tab"][href="#hackmd"]').tab('show');
       $('body').addClass('on-edit');
       $('body').addClass('on-edit');
       $('body').addClass('hackmd');
       $('body').addClass('hackmd');
     }
     }
-    else if (location.hash === '#revision-history' && $('.tab-pane#revision-history').length > 0) {
+    else if (window.location.hash === '#revision-history' && $('.tab-pane#revision-history').length > 0) {
       $('a[data-toggle="tab"][href="#revision-history"]').tab('show');
       $('a[data-toggle="tab"][href="#revision-history"]').tab('show');
     }
     }
   }
   }
@@ -767,7 +767,7 @@ window.addEventListener('load', (e) => {
     });
     });
   }
   }
 
 
-  Crowi.highlightSelectedSection(location.hash);
+  Crowi.highlightSelectedSection(window.location.hash);
   Crowi.modifyScrollTop();
   Crowi.modifyScrollTop();
   Crowi.initSlimScrollForRevisionToc();
   Crowi.initSlimScrollForRevisionToc();
   Crowi.initAffix();
   Crowi.initAffix();
@@ -780,14 +780,14 @@ window.addEventListener('hashchange', (e) => {
   Crowi.modifyScrollTop();
   Crowi.modifyScrollTop();
 
 
   // hash on page
   // hash on page
-  if (location.hash) {
-    if (location.hash === '#edit') {
+  if (window.location.hash) {
+    if (window.location.hash === '#edit') {
       $('a[data-toggle="tab"][href="#edit"]').tab('show');
       $('a[data-toggle="tab"][href="#edit"]').tab('show');
     }
     }
-    else if (location.hash === '#hackmd') {
+    else if (window.location.hash === '#hackmd') {
       $('a[data-toggle="tab"][href="#hackmd"]').tab('show');
       $('a[data-toggle="tab"][href="#hackmd"]').tab('show');
     }
     }
-    else if (location.hash === '#revision-history') {
+    else if (window.location.hash === '#revision-history') {
       $('a[data-toggle="tab"][href="#revision-history"]').tab('show');
       $('a[data-toggle="tab"][href="#revision-history"]').tab('show');
     }
     }
   }
   }

+ 4 - 2
src/client/js/models/MarkdownTable.js

@@ -11,6 +11,8 @@ const linePartOfTableRE = /^\|[^\r\n]*|[^\r\n]*\|$|([^|\r\n]+\|[^|\r\n]*)+/; //
 // set up DOMParser
 // set up DOMParser
 const domParser = new (window.DOMParser)();
 const domParser = new (window.DOMParser)();
 
 
+const defaultOptions = { stringLength: stringWidth };
+
 /**
 /**
  * markdown table class for markdown-table module
  * markdown table class for markdown-table module
  *   ref. https://github.com/wooorm/markdown-table
  *   ref. https://github.com/wooorm/markdown-table
@@ -19,7 +21,7 @@ export default class MarkdownTable {
 
 
   constructor(table, options) {
   constructor(table, options) {
     this.table = table || [];
     this.table = table || [];
-    this.options = options || {};
+    this.options = Object.assign(options || {}, defaultOptions);
 
 
     this.toString = this.toString.bind(this);
     this.toString = this.toString.bind(this);
   }
   }
@@ -139,7 +141,7 @@ export default class MarkdownTable {
         contents.push(row);
         contents.push(row);
       }
       }
     }
     }
-    return (new MarkdownTable(contents, { align: aligns, stringLength: stringWidth }));
+    return (new MarkdownTable(contents, { align: aligns }));
   }
   }
 
 
 }
 }

+ 8 - 5
src/client/styles/scss/_on-edit.scss

@@ -90,7 +90,7 @@ body.on-edit {
 
 
     position: absolute;
     position: absolute;
     left: $left-margin;
     left: $left-margin;
-    z-index: 1;
+    z-index: 7; // forward than .CodeMirror-vscrollbar
     width: calc(100% - #{$left-margin} - #{$right-margin});
     width: calc(100% - #{$left-margin} - #{$right-margin});
     padding-top: 3px;
     padding-top: 3px;
     pointer-events: none; // disable pointer-events because it becomes an obstacle
     pointer-events: none; // disable pointer-events because it becomes an obstacle
@@ -184,13 +184,16 @@ body.on-edit {
       .autoformat-markdown-table-activated .CodeMirror-cursor {
       .autoformat-markdown-table-activated .CodeMirror-cursor {
         &:after {
         &:after {
           position: relative;
           position: relative;
-          top: -16px;
-          left: 5px;
+          top: -1.1em;
+          left: 0.3em;
           display: block;
           display: block;
-          width: 14px;
-          height: 14px;
+          width: 1em;
+          height: 1em;
           content: ' ';
           content: ' ';
+
           background-image: url(/images/icons/editor/table.svg);
           background-image: url(/images/icons/editor/table.svg);
+          background-repeat: no-repeat;
+          background-size: 1em;
         }
         }
       }
       }