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

Merge pull request #465 from weseek/master

release v3.1.5
Yuki Takei 7 лет назад
Родитель
Сommit
7e4273ccfe
7 измененных файлов с 37 добавлено и 9 удалено
  1. 5 1
      CHANGES.md
  2. 4 1
      lib/form/revision.js
  3. 5 1
      lib/models/revision.js
  4. 7 2
      lib/routes/page.js
  5. 7 0
      lib/views/widget/page_alerts.html
  6. 1 1
      package.json
  7. 8 3
      resource/js/legacy/crowi.js

+ 5 - 1
CHANGES.md

@@ -1,10 +1,14 @@
 CHANGES
 CHANGES
 ========
 ========
 
 
-## 3.1.4-RC
+## 3.1.5-RC
 
 
 * Feature: Support [blockdiag](http://blockdiag.com)
 * Feature: Support [blockdiag](http://blockdiag.com)
 * Feature: Add `BLOCKDIAG_URI` environment variable
 * Feature: Add `BLOCKDIAG_URI` environment variable
+
+## 3.1.4
+
+* Improvement: Enable to scroll revision-toc
 * Fix: sanitize `#raw-text-original` content with 'entities'
 * Fix: sanitize `#raw-text-original` content with 'entities'
 * Fix: page.rename api doesn't work
 * Fix: page.rename api doesn't work
 * Support: Upgrade libs
 * Support: Upgrade libs

+ 4 - 1
lib/form/revision.js

@@ -5,7 +5,10 @@ var form = require('express-form')
 
 
 module.exports = form(
 module.exports = form(
   field('pageForm.path').required(),
   field('pageForm.path').required(),
-  field('pageForm.body').required().custom(function(value) { return value.replace(/\r/g, '\n') }),
+  field('pageForm.body').required().custom(function(value) {
+    // see https://github.com/weseek/growi/issues/463
+    return value.replace(/\r\n?/g, '\n');
+  }),
   field('pageForm.currentRevision'),
   field('pageForm.currentRevision'),
   field('pageForm.grant').toInt().required(),
   field('pageForm.grant').toInt().required(),
   field('pageForm.grantUserGroupId'),
   field('pageForm.grantUserGroupId'),

+ 5 - 1
lib/models/revision.js

@@ -10,7 +10,11 @@ module.exports = function(crowi) {
 
 
   revisionSchema = new mongoose.Schema({
   revisionSchema = new mongoose.Schema({
     path: { type: String, required: true },
     path: { type: String, required: true },
-    body: { type: String, required: true },
+    body: { type: String, required: true, get: (data) => {
+      // replace CR/CRLF to LF above v3.1.5
+      // see https://github.com/weseek/growi/issues/463
+      return data.replace(/\r\n?/g, '\n');
+    }},
     format: { type: String, default: 'markdown' },
     format: { type: String, default: 'markdown' },
     author: { type: ObjectId, ref: 'User' },
     author: { type: ObjectId, ref: 'User' },
     createdAt: { type: Date, default: Date.now }
     createdAt: { type: Date, default: Date.now }

+ 7 - 2
lib/routes/page.js

@@ -607,11 +607,16 @@ module.exports = function(crowi, app) {
 
 
   actions.pageEdit = function(req, res) {
   actions.pageEdit = function(req, res) {
 
 
-    var pageForm = req.body.pageForm;
+    if (!req.form.isValid) {
+      req.flash('dangerMessage', 'Request is invalid.');
+      return res.redirect(req.headers.referer);
+    }
+
+    var pageForm = req.form.pageForm;
+    var path = pageForm.path;
     var body = pageForm.body;
     var body = pageForm.body;
     var currentRevision = pageForm.currentRevision;
     var currentRevision = pageForm.currentRevision;
     var grant = pageForm.grant;
     var grant = pageForm.grant;
-    var path = pageForm.path;
     var grantUserGroupId = pageForm.grantUserGroupId;
     var grantUserGroupId = pageForm.grantUserGroupId;
 
 
     // TODO: make it pluggable
     // TODO: make it pluggable

+ 7 - 0
lib/views/widget/page_alerts.html

@@ -79,5 +79,12 @@
       <a href="{{ page.path }}"><i class="icon-fw icon-arrow-right-circle"></i>{{ t('Show latest') }}</a>
       <a href="{{ page.path }}"><i class="icon-fw icon-arrow-right-circle"></i>{{ t('Show latest') }}</a>
     </div>
     </div>
     {% endif %}
     {% endif %}
+
+    {% set dmessage = req.flash('dangerMessage') %}
+    {% if dmessage.length %}
+    <div class="alert alert-danger m-b-15">
+      {{ dmessage }}
+    </div>
+    {% endif %}
   </div>
   </div>
 </div>
 </div>

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "growi",
   "name": "growi",
-  "version": "3.1.4-RC",
+  "version": "3.1.5-RC",
   "description": "Team collaboration software using markdown",
   "description": "Team collaboration software using markdown",
   "tags": [
   "tags": [
     "wiki",
     "wiki",

+ 8 - 3
resource/js/legacy/crowi.js

@@ -169,9 +169,10 @@ Crowi.handleKeyCtrlSlashHandler = (event) => {
 
 
 Crowi.initSlimScrollForRevisionToc = () => {
 Crowi.initSlimScrollForRevisionToc = () => {
   const revisionTocElem = document.querySelector('.growi .revision-toc');
   const revisionTocElem = document.querySelector('.growi .revision-toc');
+  const tocContentElem = document.querySelector('.growi .revision-toc .markdownIt-TOC');
 
 
   // growi layout only
   // growi layout only
-  if (revisionTocElem == null) {
+  if (revisionTocElem == null || tocContentElem == null) {
     return;
     return;
   }
   }
 
 
@@ -181,8 +182,12 @@ Crowi.initSlimScrollForRevisionToc = () => {
   }
   }
 
 
   function resetScrollbar(revisionTocTop) {
   function resetScrollbar(revisionTocTop) {
-    // inner height - revisionTocTop
-    const h = window.innerHeight - revisionTocTop;
+    // window height - revisionTocTop - .system-version height
+    let h = window.innerHeight - revisionTocTop - 20;
+
+    const tocContentHeight = tocContentElem.getBoundingClientRect().height + 15;  // add margin
+
+    h = Math.min(h, tocContentHeight);
 
 
     $('#revision-toc-content').slimScroll({
     $('#revision-toc-content').slimScroll({
       railVisible: true,
       railVisible: true,