Преглед изворни кода

Merge commit '9d6ea8169f94c7fa26ea00e0d451c474d8fca7c2' into imprv/remove-PageTagRelation-when-complete-delete-page

yusuketk пре 6 година
родитељ
комит
49c8585573

+ 0 - 4
.eslintrc.js

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

+ 4 - 0
CHANGES.md

@@ -2,13 +2,17 @@
 
 ## 3.5.3-RC
 
+* Improvement: Calculate string width when save with Spreadsheet like GUI (Handsontable)
 * Fix: Search Result Page doesn't work
 * Fix: Create/Update page API returns data includes author's password hash
+* Fix: Dropdown to copy page path/URL/MarkdownLink shows under CodeMirror vscrollbar
+* Fix: Link to /trash in Dropdown menu
 
 ## 3.5.2
 
 * Feature: Remain metadata option when Move/Rename page
 * Improvement: Support code highlight for Swift and Kotlin
+* Fix: Couldn't restrict page with user group permission
 * Fix: Couldn't duplicate a page when it restricted by a user group permission
 * Fix: Consider timezone on admin page
 * Fix: Editor doesn't work on Microsoft Edge

+ 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 ReactDOM from 'react-dom';
 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 ReactDOM from 'react-dom';
@@ -340,7 +340,7 @@ $(() => {
     if (input2 === '') {
       prefix2 = prefix2.slice(0, -1);
     }
-    top.location.href = `${prefix1 + input1 + prefix2 + input2}#edit`;
+    window.location.href = `${prefix1 + input1 + prefix2 + input2}#edit`;
     return false;
   });
 
@@ -352,7 +352,7 @@ $(() => {
     if (name.match(/.+\/$/)) {
       name = name.substr(0, name.length - 1);
     }
-    top.location.href = `${pathUtils.encodePagePath(name)}#edit`;
+    window.location.href = `${pathUtils.encodePagePath(name)}#edit`;
     return false;
   });
 
@@ -387,7 +387,7 @@ $(() => {
         }
         else {
           const page = res.page;
-          top.location.href = `${page.path}?renamed=${pagePath}`;
+          window.location.href = `${page.path}?renamed=${pagePath}`;
         }
       });
 
@@ -424,7 +424,7 @@ $(() => {
       }
       else {
         const page = res.page;
-        top.location.href = `${page.path}?duplicated=${pagePath}`;
+        window.location.href = `${page.path}?duplicated=${pagePath}`;
       }
     });
 
@@ -456,7 +456,7 @@ $(() => {
       }
       else {
         const page = res.page;
-        top.location.href = page.path;
+        window.location.href = page.path;
       }
     });
 
@@ -481,7 +481,7 @@ $(() => {
       }
       else {
         const page = res.page;
-        top.location.href = page.path;
+        window.location.href = page.path;
       }
     });
 
@@ -500,7 +500,7 @@ $(() => {
           $('#delete-errors').addClass('alert-danger');
         }
         else {
-          top.location.href = `${res.path}?unlinked=true`;
+          window.location.href = `${res.path}?unlinked=true`;
         }
       });
 
@@ -527,7 +527,7 @@ $(() => {
     $('#edit').removeClass('active');
     $('body').removeClass('on-edit');
     $('body').removeClass('builtin-editor');
-    location.hash = '#';
+    window.location.hash = '#';
   });
 
   /*
@@ -598,7 +598,7 @@ $(() => {
 
       const editorContainer = appContainer.getContainer('EditorContainer');
       editorContainer.saveDraft(path, template);
-      top.location.href = `${path}#edit`;
+      window.location.href = `${path}#edit`;
     });
 
     if (!isSeen) {
@@ -675,7 +675,7 @@ $(() => {
     $('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
       window.location.hash = '#';
-      window.history.replaceState('', '', location.href);
+      window.history.replaceState('', '', window.location.href);
     });
   }
   else {
@@ -689,7 +689,7 @@ $(() => {
       window.history.replaceState('', 'HackMD', '#hackmd');
     });
     $('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
     $(document).on('click', 'a[href="#edit"]', () => {
@@ -707,8 +707,8 @@ window.addEventListener('load', (e) => {
   const { appContainer } = window;
 
   // 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' });
 
       $('a[data-toggle="tab"][href="#edit"]').tab('show');
@@ -718,14 +718,14 @@ window.addEventListener('load', (e) => {
       // focus
       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' });
 
       $('a[data-toggle="tab"][href="#hackmd"]').tab('show');
       $('body').addClass('on-edit');
       $('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');
     }
   }
@@ -767,7 +767,7 @@ window.addEventListener('load', (e) => {
     });
   }
 
-  Crowi.highlightSelectedSection(location.hash);
+  Crowi.highlightSelectedSection(window.location.hash);
   Crowi.modifyScrollTop();
   Crowi.initSlimScrollForRevisionToc();
   Crowi.initAffix();
@@ -780,14 +780,14 @@ window.addEventListener('hashchange', (e) => {
   Crowi.modifyScrollTop();
 
   // 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');
     }
-    else if (location.hash === '#hackmd') {
+    else if (window.location.hash === '#hackmd') {
       $('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');
     }
   }

+ 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
 const domParser = new (window.DOMParser)();
 
+const defaultOptions = { stringLength: stringWidth };
+
 /**
  * markdown table class for markdown-table module
  *   ref. https://github.com/wooorm/markdown-table
@@ -19,7 +21,7 @@ export default class MarkdownTable {
 
   constructor(table, options) {
     this.table = table || [];
-    this.options = options || {};
+    this.options = Object.assign(options || {}, defaultOptions);
 
     this.toString = this.toString.bind(this);
   }
@@ -139,7 +141,7 @@ export default class MarkdownTable {
         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;
     left: $left-margin;
-    z-index: 1;
+    z-index: 7; // forward than .CodeMirror-vscrollbar
     width: calc(100% - #{$left-margin} - #{$right-margin});
     padding-top: 3px;
     pointer-events: none; // disable pointer-events because it becomes an obstacle
@@ -184,13 +184,16 @@ body.on-edit {
       .autoformat-markdown-table-activated .CodeMirror-cursor {
         &:after {
           position: relative;
-          top: -16px;
-          left: 5px;
+          top: -1.1em;
+          left: 0.3em;
           display: block;
-          width: 14px;
-          height: 14px;
+          width: 1em;
+          height: 1em;
           content: ' ';
+
           background-image: url(/images/icons/editor/table.svg);
+          background-repeat: no-repeat;
+          background-size: 1em;
         }
       }
 

+ 1 - 1
src/server/views/layout/layout.html

@@ -145,7 +145,7 @@
             <li><a href="/me"><i class="icon-fw icon-wrench"></i>{{ t('User Settings') }}</a></li>
             <li role="separator" class="divider"></li>
             <li><a href="/user/{{ user.username }}#user-draft-list"><i class="icon-fw icon-docs"></i>{{ t('List Drafts') }}</a></li>
-            <li><a href="/user"><i class="icon-fw icon-trash"></i>{{ t('Deleted Pages') }}</a></li>
+            <li><a href="/trash"><i class="icon-fw icon-trash"></i>{{ t('Deleted Pages') }}</a></li>
             <li role="separator" class="divider"></li>
             <li><a href="/logout"><i class="icon-fw icon-power"></i>{{ t('Sign out') }}</a></li>
           </ul>