From 36e373eb692f0c1d03167087ff2971f7f72cf994 Mon Sep 17 00:00:00 2001 From: Raccoon Date: Sat, 11 Apr 2020 05:34:04 +0800 Subject: [PATCH 01/48] fix: server not stop when app cannot connect to db Signed-off-by: Raccoon --- app.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app.js b/app.js index 449262abac..fc9a23d562 100644 --- a/app.js +++ b/app.js @@ -272,12 +272,18 @@ models.sequelize.sync().then(function () { } else { throw new Error('server still not ready after db synced') } +}).catch(err => { + logger.error('Can\'t sync database'); + logger.error(err.stack) + logger.error('Process will exit now.') + process.exit(1) }) // log uncaught exception process.on('uncaughtException', function (err) { logger.error('An uncaught exception has occured.') logger.error(err) + console.error(err) logger.error('Process will exit now.') process.exit(1) }) From fb02ee392230fc2b458b6a3ae0263b295983c0bd Mon Sep 17 00:00:00 2001 From: Raccoon Date: Sat, 11 Apr 2020 05:34:39 +0800 Subject: [PATCH 02/48] feat: add mindmap-lib support Signed-off-by: Raccoon --- package-lock.json | 356 +++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + public/js/extra.js | 52 +++++-- public/js/index.js | 2 +- 4 files changed, 396 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 143b463f72..5f2d1d053d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -558,6 +558,266 @@ "@types/node": "*" } }, + "@types/d3": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/@types/d3/-/d3-5.7.2.tgz", + "integrity": "sha512-7/wClB8ycneWGy3jdvLfXKTd5SoTg9hji7IdJ0RuO9xTY54YpJ8zlcFADcXhY1J3kCBwxp+/1jeN6a5OMwgYOw==", + "dev": true, + "requires": { + "@types/d3-array": "^1", + "@types/d3-axis": "*", + "@types/d3-brush": "*", + "@types/d3-chord": "*", + "@types/d3-collection": "*", + "@types/d3-color": "*", + "@types/d3-contour": "*", + "@types/d3-dispatch": "*", + "@types/d3-drag": "*", + "@types/d3-dsv": "*", + "@types/d3-ease": "*", + "@types/d3-fetch": "*", + "@types/d3-force": "*", + "@types/d3-format": "*", + "@types/d3-geo": "*", + "@types/d3-hierarchy": "*", + "@types/d3-interpolate": "*", + "@types/d3-path": "*", + "@types/d3-polygon": "*", + "@types/d3-quadtree": "*", + "@types/d3-random": "*", + "@types/d3-scale": "*", + "@types/d3-scale-chromatic": "*", + "@types/d3-selection": "*", + "@types/d3-shape": "*", + "@types/d3-time": "*", + "@types/d3-time-format": "*", + "@types/d3-timer": "*", + "@types/d3-transition": "*", + "@types/d3-voronoi": "*", + "@types/d3-zoom": "*" + } + }, + "@types/d3-array": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@types/d3-array/-/d3-array-1.2.7.tgz", + "integrity": "sha512-51vHWuUyDOi+8XuwPrTw3cFqyh2Slg9y8COYkRfjCPG9TfYqY0hoNPzv/8BrcAy0FeQBzqEo/D/8Nk2caOQJnA==", + "dev": true + }, + "@types/d3-axis": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/@types/d3-axis/-/d3-axis-1.0.12.tgz", + "integrity": "sha512-BZISgSD5M8TgURyNtcPAmUB9sk490CO1Thb6/gIn0WZTt3Y50IssX+2Z0vTccoqZksUDTep0b+o4ofXslvNbqg==", + "dev": true, + "requires": { + "@types/d3-selection": "*" + } + }, + "@types/d3-brush": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@types/d3-brush/-/d3-brush-1.1.0.tgz", + "integrity": "sha512-yz5Y94XpUARimOlLk+RWM1cZh1FrtmSGOyDQfCArsMa6kAnhjF3EserSTDnHAuVuNATMoTIOPHa7pjG2iTkPYA==", + "dev": true, + "requires": { + "@types/d3-selection": "*" + } + }, + "@types/d3-chord": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@types/d3-chord/-/d3-chord-1.0.9.tgz", + "integrity": "sha512-UA6lI9CVW5cT5Ku/RV4hxoFn4mKySHm7HEgodtfRthAj1lt9rKZEPon58vyYfk+HIAm33DtJJgZwMXy2QgyPXw==", + "dev": true + }, + "@types/d3-collection": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/d3-collection/-/d3-collection-1.0.8.tgz", + "integrity": "sha512-y5lGlazdc0HNO0F3UUX2DPE7OmYvd9Kcym4hXwrJcNUkDaypR5pX+apuMikl9LfTxKItJsY9KYvzBulpCKyvuQ==", + "dev": true + }, + "@types/d3-color": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@types/d3-color/-/d3-color-1.2.2.tgz", + "integrity": "sha512-6pBxzJ8ZP3dYEQ4YjQ+NVbQaOflfgXq/JbDiS99oLobM2o72uAST4q6yPxHv6FOTCRC/n35ktuo8pvw/S4M7sw==", + "dev": true + }, + "@types/d3-contour": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@types/d3-contour/-/d3-contour-1.3.0.tgz", + "integrity": "sha512-AUCUIjEnC5lCGBM9hS+MryRaFLIrPls4Rbv6ktqbd+TK/RXZPwOy9rtBWmGpbeXcSOYCJTUDwNJuEnmYPJRxHQ==", + "dev": true, + "requires": { + "@types/d3-array": "*", + "@types/geojson": "*" + } + }, + "@types/d3-dispatch": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@types/d3-dispatch/-/d3-dispatch-1.0.7.tgz", + "integrity": "sha512-M+z84G7UKwK6hEPnGCSccOg8zJ3Nk2hgDQ9sCstHXgsFU0sMxlIZVKqKB5oxUDbALqQG6ucg0G9e8cmOSlishg==", + "dev": true + }, + "@types/d3-drag": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@types/d3-drag/-/d3-drag-1.2.3.tgz", + "integrity": "sha512-rWB5SPvkYVxW3sqUxHOJUZwifD0KqvKwvt1bhNqcLpW6Azsd0BJgRNcyVW8GAferaAk5r8dzeZnf9zKlg9+xMQ==", + "dev": true, + "requires": { + "@types/d3-selection": "*" + } + }, + "@types/d3-dsv": { + "version": "1.0.36", + "resolved": "https://registry.npmjs.org/@types/d3-dsv/-/d3-dsv-1.0.36.tgz", + "integrity": "sha512-jbIWQ27QJcBNMZbQv0NSQMHnBDCmxghAxePxgyiPH1XPCRkOsTBei7jcdi3fDrUCGpCV3lKrSZFSlOkhUQVClA==", + "dev": true + }, + "@types/d3-ease": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@types/d3-ease/-/d3-ease-1.0.9.tgz", + "integrity": "sha512-U5ADevQ+W6fy32FVZZC9EXallcV/Mi12A5Tkd0My5MrC7T8soMQEhlDAg88XUWm0zoCQlB4XV0en/24LvuDB4Q==", + "dev": true + }, + "@types/d3-fetch": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@types/d3-fetch/-/d3-fetch-1.1.5.tgz", + "integrity": "sha512-o9c0ItT5/Gl3wbNuVpzRnYX1t3RghzeWAjHUVLuyZJudiTxC4f/fC0ZPFWLQ2lVY8pAMmxpV8TJ6ETYCgPeI3A==", + "dev": true, + "requires": { + "@types/d3-dsv": "*" + } + }, + "@types/d3-force": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@types/d3-force/-/d3-force-1.2.1.tgz", + "integrity": "sha512-jqK+I36uz4kTBjyk39meed5y31Ab+tXYN/x1dn3nZEus9yOHCLc+VrcIYLc/aSQ0Y7tMPRlIhLetulME76EiiA==", + "dev": true + }, + "@types/d3-format": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@types/d3-format/-/d3-format-1.3.1.tgz", + "integrity": "sha512-KAWvReOKMDreaAwOjdfQMm0HjcUMlQG47GwqdVKgmm20vTd2pucj0a70c3gUSHrnsmo6H2AMrkBsZU2UhJLq8A==", + "dev": true + }, + "@types/d3-geo": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@types/d3-geo/-/d3-geo-1.11.1.tgz", + "integrity": "sha512-Ox8WWOG3igDRoep/dNsGbOiSJYdUG3ew/6z0ETvHyAtXZVBjOE0S96zSSmzgl0gqQ3RdZjn2eeJOj9oRcMZPkQ==", + "dev": true, + "requires": { + "@types/geojson": "*" + } + }, + "@types/d3-hierarchy": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/@types/d3-hierarchy/-/d3-hierarchy-1.1.6.tgz", + "integrity": "sha512-vvSaIDf/Ov0o3KwMT+1M8+WbnnlRiGjlGD5uvk83a1mPCTd/E5x12bUJ/oP55+wUY/4Kb5kc67rVpVGJ2KUHxg==", + "dev": true + }, + "@types/d3-interpolate": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@types/d3-interpolate/-/d3-interpolate-1.3.1.tgz", + "integrity": "sha512-z8Zmi08XVwe8e62vP6wcA+CNuRhpuUU5XPEfqpG0hRypDE5BWNthQHB1UNWWDB7ojCbGaN4qBdsWp5kWxhT1IQ==", + "dev": true, + "requires": { + "@types/d3-color": "*" + } + }, + "@types/d3-path": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/d3-path/-/d3-path-1.0.8.tgz", + "integrity": "sha512-AZGHWslq/oApTAHu9+yH/Bnk63y9oFOMROtqPAtxl5uB6qm1x2lueWdVEjsjjV3Qc2+QfuzKIwIR5MvVBakfzA==", + "dev": true + }, + "@types/d3-polygon": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@types/d3-polygon/-/d3-polygon-1.0.7.tgz", + "integrity": "sha512-Xuw0eSjQQKs8jTiNbntWH0S+Xp+JyhqxmQ0YAQ3rDu6c3kKMFfgsaGN7Jv5u3zG6yVX/AsLP/Xs/QRjmi9g43Q==", + "dev": true + }, + "@types/d3-quadtree": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@types/d3-quadtree/-/d3-quadtree-1.0.7.tgz", + "integrity": "sha512-0ajFawWicfjsaCLh6NzxOyVDYhQAmMFbsiI3MPGLInorauHFEh9/Cl6UHNf+kt/J1jfoxKY/ZJaKAoDpbvde5Q==", + "dev": true + }, + "@types/d3-random": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@types/d3-random/-/d3-random-1.1.2.tgz", + "integrity": "sha512-Jui+Zn28pQw/3EayPKaN4c/PqTvqNbIPjHkgIIFnxne1FdwNjfHtAIsZIBMKlquQNrrMjFzCrlF2gPs3xckqaA==", + "dev": true + }, + "@types/d3-scale": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@types/d3-scale/-/d3-scale-2.2.0.tgz", + "integrity": "sha512-oQFanN0/PiR2oySHfj+zAAkK1/p4LD32Nt1TMVmzk+bYHk7vgIg/iTXQWitp1cIkDw4LMdcgvO63wL+mNs47YA==", + "dev": true, + "requires": { + "@types/d3-time": "*" + } + }, + "@types/d3-scale-chromatic": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@types/d3-scale-chromatic/-/d3-scale-chromatic-1.3.1.tgz", + "integrity": "sha512-Ny3rLbV5tnmqgW7w/poCcef4kXP8mHPo/p8EjTS5d9OUk8MlqAeRaM8eF7Vyv7QMLiIXNE94Pa1cMLSPkXQBoQ==", + "dev": true + }, + "@types/d3-selection": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@types/d3-selection/-/d3-selection-1.4.1.tgz", + "integrity": "sha512-bv8IfFYo/xG6dxri9OwDnK3yCagYPeRIjTlrcdYJSx+FDWlCeBDepIHUpqROmhPtZ53jyna0aUajZRk0I3rXNA==", + "dev": true + }, + "@types/d3-shape": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@types/d3-shape/-/d3-shape-1.3.2.tgz", + "integrity": "sha512-LtD8EaNYCaBRzHzaAiIPrfcL3DdIysc81dkGlQvv7WQP3+YXV7b0JJTtR1U3bzeRieS603KF4wUo+ZkJVenh8w==", + "dev": true, + "requires": { + "@types/d3-path": "*" + } + }, + "@types/d3-time": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@types/d3-time/-/d3-time-1.0.10.tgz", + "integrity": "sha512-aKf62rRQafDQmSiv1NylKhIMmznsjRN+MnXRXTqHoqm0U/UZzVpdrtRnSIfdiLS616OuC1soYeX1dBg2n1u8Xw==", + "dev": true + }, + "@types/d3-time-format": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-2.1.1.tgz", + "integrity": "sha512-tJSyXta8ZyJ52wDDHA96JEsvkbL6jl7wowGmuf45+fAkj5Y+SQOnz0N7/H68OWmPshPsAaWMQh+GAws44IzH3g==", + "dev": true + }, + "@types/d3-timer": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@types/d3-timer/-/d3-timer-1.0.9.tgz", + "integrity": "sha512-WvfJ3LFxBbWjqRGz9n7GJt08RrTHPJDVsIwwoCMROlqF+iDacYiAFjf9oqnq0mXpb2juA2N/qjKP+MKdal3YNQ==", + "dev": true + }, + "@types/d3-transition": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/@types/d3-transition/-/d3-transition-1.1.6.tgz", + "integrity": "sha512-/F+O2r4oz4G9ATIH3cuSCMGphAnl7VDx7SbENEK0NlI/FE8Jx2oiIrv0uTrpg7yF/AmuWbqp7AGdEHAPIh24Gg==", + "dev": true, + "requires": { + "@types/d3-selection": "*" + } + }, + "@types/d3-voronoi": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/@types/d3-voronoi/-/d3-voronoi-1.1.9.tgz", + "integrity": "sha512-DExNQkaHd1F3dFPvGA/Aw2NGyjMln6E9QzsiqOcBgnE+VInYnFBHBBySbZQts6z6xD+5jTfKCP7M4OqMyVjdwQ==", + "dev": true + }, + "@types/d3-zoom": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/@types/d3-zoom/-/d3-zoom-1.7.4.tgz", + "integrity": "sha512-5jnFo/itYhJeB2khO/lKe730kW/h2EbKMOvY0uNp3+7NdPm4w63DwPEMxifQZ7n902xGYK5DdU67FmToSoy4VA==", + "dev": true, + "requires": { + "@types/d3-interpolate": "*", + "@types/d3-selection": "*" + } + }, "@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", @@ -587,6 +847,12 @@ "resolved": "https://registry.npmjs.org/@types/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", "integrity": "sha512-mky/O83TXmGY39P1H9YbUpjV6l6voRYlufqfFCvel8l1phuy8HRjdWc1rrPuN53ITBJlbyMSV6z3niOySO5pgQ==" }, + "@types/geojson": { + "version": "7946.0.7", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.7.tgz", + "integrity": "sha512-wE2v81i4C4Ol09RtsWFAqg3BUitWbHSpSlIo+bNdsCJijO9sjme+zm+73ZMCa/qMC8UEERxzGbvmr1cffo2SiQ==", + "dev": true + }, "@types/ldapjs": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/ldapjs/-/ldapjs-1.0.5.tgz", @@ -4071,6 +4337,15 @@ "d3-dsv": "1" } }, + "d3-flextree": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/d3-flextree/-/d3-flextree-2.1.1.tgz", + "integrity": "sha512-P0SK6bRm0PT5ZZON8Lh/aOcFfr4rO53kaYCXCgwBCvsHJcYjtOb8fNrgmpOmCMCgfrT9EczXzD8wqEO8mlkBrA==", + "dev": true, + "requires": { + "d3-hierarchy": "^1.1.5" + } + }, "d3-force": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/d3-force/-/d3-force-1.2.1.tgz", @@ -8137,6 +8412,12 @@ "integrity": "sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE=", "dev": true }, + "is-docker": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.0.0.tgz", + "integrity": "sha512-pJEdRugimx4fBMra5z2/5iRdZ63OhYV0vr0Dwm5+xtW4D1FvRkB8hamMIhnWfyJeDdyr/aa7BDyNbtG38VxgoQ==", + "dev": true + }, "is-dotfile": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", @@ -9398,6 +9679,63 @@ "resolved": "https://registry.npmjs.org/marked/-/marked-0.6.3.tgz", "integrity": "sha512-Fqa7eq+UaxfMriqzYLayfqAE40WN03jf+zHjT18/uXNuzjq3TY0XTbrAoPeqSJrAmPz11VuUA+kBPYOhHt9oOQ==" }, + "markmap-lib": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/markmap-lib/-/markmap-lib-0.4.2.tgz", + "integrity": "sha512-/1ITvE8HiI+8GLgL//ggH2LNy19Kg3nNcOijK/DcKtH7grJ1TO6k4No/IqCSiM8JjiQbxYDosSHGZKqp6Lyj1A==", + "dev": true, + "requires": { + "@babel/runtime": "^7.9.2", + "@types/d3": "^5.7.2", + "commander": "^5.0.0", + "d3": "^5.15.0", + "d3-flextree": "^2.1.1", + "open": "^7.0.3", + "remarkable": "^2.0.0" + }, + "dependencies": { + "@babel/runtime": { + "version": "7.9.2", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.9.2.tgz", + "integrity": "sha512-NE2DtOdufG7R5vnfQUTehdTfNycfUANEtCa9PssN9O/xmTzP4E08UI797ixaei6hBEVL9BI/PsdJS5x7mWoB9Q==", + "dev": true, + "requires": { + "regenerator-runtime": "^0.13.4" + } + }, + "autolinker": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/autolinker/-/autolinker-3.14.1.tgz", + "integrity": "sha512-yvsRHIaY51EYDml6MGlbqyJGfl4n7zezGYf+R7gvM8c5LNpRGc4SISkvgAswSS8SWxk/OrGCylKV9mJyVstz7w==", + "dev": true, + "requires": { + "tslib": "^1.9.3" + } + }, + "commander": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-5.0.0.tgz", + "integrity": "sha512-JrDGPAKjMGSP1G0DUoaceEJ3DZgAfr/q6X7FVk4+U5KxUSKviYGM2k6zWkfyyBHy5rAtzgYJFa1ro2O9PtoxwQ==", + "dev": true + }, + "regenerator-runtime": { + "version": "0.13.5", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz", + "integrity": "sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA==", + "dev": true + }, + "remarkable": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/remarkable/-/remarkable-2.0.0.tgz", + "integrity": "sha512-3gvKFAgL4xmmVRKAMNm6UzDo/rO2gPVkZrWagp6AXEA4JvCcMcRx9aapYbb7AJAmLLvi/u06+EhzqoS7ha9qOg==", + "dev": true, + "requires": { + "argparse": "^1.0.10", + "autolinker": "^3.11.0" + } + } + } + }, "math-interval-parser": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/math-interval-parser/-/math-interval-parser-1.1.0.tgz", @@ -10835,6 +11173,24 @@ } } }, + "open": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/open/-/open-7.0.3.tgz", + "integrity": "sha512-sP2ru2v0P290WFfv49Ap8MF6PkzGNnGlAwHweB4WR4mr5d2d0woiCluUeJ218w7/+PmoBy9JmYgD5A4mLcWOFA==", + "dev": true, + "requires": { + "is-docker": "^2.0.0", + "is-wsl": "^2.1.1" + }, + "dependencies": { + "is-wsl": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.1.1.tgz", + "integrity": "sha512-umZHcSrwlDHo2TGMXv0DZ8dIUGunZ2Iv68YZnrmCiBPkZ4aaOhtv7pXJKeki9k3qJ3RJr0cDyitcl5wEH3AYog==", + "dev": true + } + } + }, "openid": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/openid/-/openid-2.0.6.tgz", diff --git a/package.json b/package.json index f28dc4cd41..b045d6132c 100644 --- a/package.json +++ b/package.json @@ -181,6 +181,7 @@ "less": "~3.9.0", "less-loader": "~4.1.0", "markdown-it-ruby": "^0.1.1", + "markmap-lib": "^0.4.2", "mini-css-extract-plugin": "~0.4.1", "mocha": "~5.2.0", "mock-require": "~3.0.3", diff --git a/public/js/extra.js b/public/js/extra.js index 99233c097b..8325b39a22 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -11,6 +11,9 @@ import unescapeHTML from 'lodash/unescape' import isURL from 'validator/lib/isURL' +import { transform } from 'markmap-lib/dist/transform.common' +import { markmap } from 'markmap-lib/dist/view.common' + import { stripTags } from '../../utils/string' import getUIElements from './lib/editor/ui-elements' @@ -483,6 +486,24 @@ export function finishView (view) { } }) + // markmap + view.find('div.markmap.raw').removeClass('raw').each(async (key, value) => { + const $elem = $(value).parent().parent() + const $value = $(value) + const content = $value.text() + $value.unwrap() + try { + const data = transform(content) + $elem.html(`
`) + markmap($elem.find('svg.markmap.rendered')[0], data, { + duration: 0 + }) + } catch (err) { + $elem.html(`
${escapeHTML(err)}
`) + console.warn(err) + } + }) + // image href new window(emoji not included) const images = view.find('img.raw[src]').removeClass('raw') images.each((key, value) => { @@ -1031,20 +1052,23 @@ export function scrollToHash () { function highlightRender (code, lang) { if (!lang || /no(-?)highlight|plain|text/.test(lang)) { return } code = escapeHTML(code) - if (lang === 'sequence') { - return `
${code}
` - } else if (lang === 'flow') { - return `
${code}
` - } else if (lang === 'graphviz') { - return `
${code}
` - } else if (lang === 'mermaid') { - return `
${code}
` - } else if (lang === 'abc') { - return `
${code}
` - } else if (lang === 'vega') { - return `
${code}
` - } else if (lang === 'geo') { - return `
${code}
` + switch (lang) { + case 'sequence': + return `
${code}
` + case 'flow': + return `
${code}
` + case 'graphviz': + return `
${code}
` + case 'mermaid': + return `
${code}
` + case 'abc': + return `
${code}
` + case 'vega': + return `
${code}
` + case 'geo': + return `
${code}
` + case 'markmap': + return `
${code}
` } const result = { value: code diff --git a/public/js/index.js b/public/js/index.js index b1a0a479a1..ff3dbe5d71 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -102,7 +102,7 @@ var cursorActivityDebounce = 50 var cursorAnimatePeriod = 100 var supportContainers = ['success', 'info', 'warning', 'danger', 'spoiler'] var supportCodeModes = ['javascript', 'typescript', 'jsx', 'htmlmixed', 'htmlembedded', 'css', 'xml', 'clike', 'clojure', 'ruby', 'python', 'shell', 'php', 'sql', 'haskell', 'coffeescript', 'yaml', 'pug', 'lua', 'cmake', 'nginx', 'perl', 'sass', 'r', 'dockerfile', 'tiddlywiki', 'mediawiki', 'go', 'gherkin'].concat(hljs.listLanguages()) -var supportCharts = ['sequence', 'flow', 'graphviz', 'mermaid', 'abc', 'plantuml', 'vega', 'geo'] +var supportCharts = ['sequence', 'flow', 'graphviz', 'mermaid', 'abc', 'plantuml', 'vega', 'geo', 'markmap'] var supportHeaders = [ { text: '# h1', From 65b040545cb62ff04ceea910968adf80fafd7a69 Mon Sep 17 00:00:00 2001 From: Raccoon Date: Sun, 12 Apr 2020 00:59:12 +0800 Subject: [PATCH 03/48] style: fix markmap height to 300px Signed-off-by: Raccoon --- public/css/extra.css | 10 ++++++++++ public/js/extra.js | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/public/css/extra.css b/public/css/extra.css index 2b23ad2413..e795bc1b01 100644 --- a/public/css/extra.css +++ b/public/css/extra.css @@ -84,6 +84,16 @@ height: 250px; } +/* markmap */ +.markmap-container { + height: 300px; +} + +.markmap-container > svg { + width: 100%; + height: 100%; +} + .MJX_Assistive_MathML { display: none; } diff --git a/public/js/extra.js b/public/js/extra.js index 8325b39a22..50904c6e34 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -494,8 +494,8 @@ export function finishView (view) { $value.unwrap() try { const data = transform(content) - $elem.html(`
`) - markmap($elem.find('svg.markmap.rendered')[0], data, { + $elem.html(`
`) + markmap($elem.find('svg')[0], data, { duration: 0 }) } catch (err) { From 99afa20e34034e1a955d54af4d92a50129555152 Mon Sep 17 00:00:00 2001 From: Raccoon Date: Sun, 12 Apr 2020 16:36:20 +0800 Subject: [PATCH 04/48] fix: lint Signed-off-by: Raccoon --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index fc9a23d562..1de8347797 100644 --- a/app.js +++ b/app.js @@ -273,7 +273,7 @@ models.sequelize.sync().then(function () { throw new Error('server still not ready after db synced') } }).catch(err => { - logger.error('Can\'t sync database'); + logger.error('Can\'t sync database') logger.error(err.stack) logger.error('Process will exit now.') process.exit(1) From e8b1a679b3250d66bae2affaf62348de46093f71 Mon Sep 17 00:00:00 2001 From: Raccoon Date: Sun, 12 Apr 2020 17:06:20 +0800 Subject: [PATCH 05/48] style: markmap style on slide mode Signed-off-by: Raccoon --- public/css/slide.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/css/slide.css b/public/css/slide.css index 72275c6a9f..f30726192a 100644 --- a/public/css/slide.css +++ b/public/css/slide.css @@ -344,3 +344,7 @@ html, body { .print-pdf .footer { display: none; } + +.markmap-container { + background: #f7f7f7; +} From b36648a92884b91936d2f55b7eb7633632e47ddb Mon Sep 17 00:00:00 2001 From: Raccoon Date: Mon, 13 Apr 2020 15:02:44 +0800 Subject: [PATCH 06/48] feat: add codemirror support markmap syntax Signed-off-by: Raccoon --- public/js/lib/editor/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/js/lib/editor/index.js b/public/js/lib/editor/index.js index 830670e365..5b7e424993 100644 --- a/public/js/lib/editor/index.js +++ b/public/js/lib/editor/index.js @@ -139,9 +139,14 @@ export default class Editor { return null } } + CodeMirror.defineMode('vega', function (config, modeConfig) { return CodeMirror.overlayMode(CodeMirror.getMode(config, 'application/ld+json'), ignoreOverlay) }) + + CodeMirror.defineMode('markmap', function (config, modeConfig) { + return CodeMirror.overlayMode(CodeMirror.getMode(config, 'gfm'), ignoreOverlay) + }) } on (event, cb) { From b2af9d9fb79300c6e926c3fbf743ef35235b1dc9 Mon Sep 17 00:00:00 2001 From: zent00 Date: Tue, 28 Apr 2020 10:59:15 +0800 Subject: [PATCH 07/48] Update zh-CN.json Signed-off-by: zent00 --- locales/zh-CN.json | 120 +++++++++++++++++++++++---------------------- 1 file changed, 62 insertions(+), 58 deletions(-) diff --git a/locales/zh-CN.json b/locales/zh-CN.json index 93e1c86f82..687b9f56bd 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -1,117 +1,121 @@ { "Collaborative markdown notes": "Markdown 协作笔记", - "Realtime collaborative markdown notes on all platforms.": "使用 Markdown 的跨平台即时协作笔记", - "Best way to write and share your knowledge in markdown.": "您使用 Markdown 写作与分享知识的最佳方式", + "Realtime collaborative markdown notes on all platforms.": "使用 Markdown 的跨平台即时协作笔记。", + "Best way to write and share your knowledge in markdown.": "写作与分享 Markdown 的最佳平台。", "Intro": "简介", "History": "历史", - "New guest note": "建立访客笔记", - "Collaborate with URL": "使用网址协作", + "New guest note": "新建访客笔记", + "Collaborate with URL": "实时协作", "Support charts and MathJax": "支持图表与 MathJax", - "Support slide mode": "支持简报模式", + "Support slide mode": "支持幻灯模式", "Sign In": "登录", "Below is the history from browser": "以下为来自浏览器的历史", "Welcome!": "欢迎!", - "New note": "建立笔记", + "New note": "新建笔记", "or": "或", "Sign Out": "登出", "Explore all features": "探索所有功能", "Select tags...": "选择标签...", "Search keyword...": "搜索关键字...", - "Sort by title": "用标题排序", + "Sort by title": "按标题排序", "Title": "标题", - "Sort by time": "用时间排序", + "Sort by time": "按时间排序", "Time": "时间", "Export history": "导出历史", "Import history": "导入历史", "Clear history": "清空历史", "Refresh history": "刷新历史", - "No history": "没有历史", + "No history": "无历史记录", "Import from browser": "从浏览器导入", "Releases": "版本", - "Are you sure?": "你确定吗?", - "Do you really want to delete this note?": "确定要删除这个文件吗?", - "All users will lose their connection.": "所有用户将失去连接", + "Are you sure?": "您确定吗?", + "Do you really want to delete this note?": "您确定要删除这篇笔记吗?", + "All users will lose their connection.": "所有用户将失去连接。", "Cancel": "取消", - "Yes, do it!": "没错,就这样办!", + "Yes, do it!": "是的,就这样做!", "Choose method": "选择方式", "Sign in via %s": "通过 %s 登录", - "New": "新增", + "New": "新建", "Publish": "发表", - "Extra": "增益", + "Extra": "附加功能", "Revision": "修订版本", - "Slide Mode": "简报模式", + "Slide Mode": "幻灯模式", "Export": "导出", "Import": "导入", "Clipboard": "剪贴板", "Download": "下载", - "Raw HTML": "纯 HTML", + "Raw HTML": "原始 HTML", "Edit": "编辑", - "View": "检视", + "View": "预览", "Both": "双栏", "Help": "帮助", "Upload Image": "上传图片", "Menu": "菜单", - "This page need refresh": "此页面需要重新整理", - "You have an incompatible client version.": "您使用的是不相容的客户端", - "Refresh to update.": "请重新整理来更新", - "New version available!": "新版本来了!", - "See releases notes here": "请由此查阅更新纪录", - "Refresh to enjoy new features.": "请重新整理来享受最新功能", - "Your user state has changed.": "您的使用者状态已变更", - "Refresh to load new user state.": "请重新整理来载入新的使用者状态", - "Refresh": "重新整理", - "Contacts": "联络方式", + "This page need refresh": "此页面需要刷新", + "You have an incompatible client version.": "您的客户端版本不兼容。", + "Refresh to update.": "刷新页面以更新。", + "New version available!": "新版本可用!", + "See releases notes here": "在此查看更新记录", + "Refresh to enjoy new features.": "刷新页面以体验新功能。", + "Your user state has changed.": "您的用户状态已变更。", + "Refresh to load new user state.": "刷新页面以加载新的用户状态。", + "Refresh": "刷新", + "Contacts": "联系我们", "Report an issue": "报告问题", "Meet us on %s": "在 %s 上联系我们", - "Send us email": "寄信给我们", - "Documents": "文件", - "Features": "功能简介", - "YAML Metadata": "YAML Metadata", - "Slide Example": "简报范例", - "Cheatsheet": "快速简表", + "Send us email": "给我们发送电子邮件", + "Documents": "文档", + "Features": "功能", + "YAML Metadata": "YAML 元数据", + "Slide Example": "幻灯范例", + "Cheatsheet": "速查表", "Example": "范例", "Syntax": "语法", "Header": "标题", - "Unordered List": "无序清单", - "Ordered List": "有序清单", - "Todo List": "待办事项", + "Unordered List": "无序列表", + "Ordered List": "有序列表", + "Todo List": "清单", "Blockquote": "引用", "Bold font": "粗体", "Italics font": "斜体", "Strikethrough": "删除线", - "Inserted text": "插入文字", - "Marked text": "标记文字", + "Inserted text": "下划线文字", + "Marked text": "高亮文字", "Link": "链接", "Image": "图片", "Code": "代码", - "Externals": "外部", - "This is a alert area.": "这是警告区块", + "Externals": "外部扩展", + "This is a alert area.": "这是一个警告区块。", "Revert": "还原", "Import from clipboard": "从剪贴板导入", - "Paste your markdown or webpage here...": "在这里贴上 Markdown 或是网页内容...", + "Paste your markdown or webpage here...": "在这里粘贴 Markdown 或网页内容...", "Clear": "清除", - "This note is locked": "此份笔记已被锁定", - "Sorry, only owner can edit this note.": "抱歉,只有拥有者可以编辑此笔记", + "This note is locked": "这篇笔记已被锁定", + "Sorry, only owner can edit this note.": "抱歉,只有所有者可以编辑这篇笔记。", "OK": "好的", - "Reach the limit": "到达上限", - "Sorry, you've reached the max length this note can be.": "抱歉,您已使用到此份笔记可用的最大长度", - "Please reduce the content or divide it to more notes, thank you!": "请减少内容或是将内容切成更多笔记,谢谢!", + "Reach the limit": "达到上限", + "Sorry, you've reached the max length this note can be.": "抱歉,您的这篇笔记已达到可用的最大长度。", + "Please reduce the content or divide it to more notes, thank you!": "请减少笔记的内容。", "Import from Gist": "从 Gist 导入", - "Paste your gist url here...": "在这里贴上 gist 网址...", + "Paste your gist url here...": "在这里粘贴 Gist 网址...", "Import from Snippet": "从 Snippet 导入", "Select From Available Projects": "从可用的项目中选择", - "Select From Available Snippets": "从可用的 Snippets 中选择", - "OR": "或是", + "Select From Available Snippets": "从可用的 Snippet 中选择", + "OR": "或", "Export to Snippet": "导出到 Snippet", "Select Visibility Level": "选择可见层级", "Night Theme": "夜间主题", - "Follow us on %s and %s.": "在%s和%s上关注我们", - "Privacy": "隐私政策", + "Follow us on %s and %s.": "在 %s 和 %s 上关注我们", + "Privacy": "隐私", "Terms of Use": "使用条款", - "Do you really want to delete your user account?": "你确定真的想要删除帐户?", - "This will delete your account, all notes that are owned by you and remove all references to your account from other notes.": "我们将会删除你的帐户、你所拥有的笔记、以及你在别人笔记里的作者纪录。", + "Do you really want to delete your user account?": "您确定要删除帐户吗?", + "This will delete your account, all notes that are owned by you and remove all references to your account from other notes.": "您的帐户、您所拥有的笔记、他人笔记中对您帐户的引用都将被删除。", "Delete user": "删除帐户", - "Export user data": "汇出使用者资料", - "Help us translating on %s": "来 %s 帮我们翻译", - "Source Code": "源码" -} \ No newline at end of file + "Export user data": "导出用户数据", + "Help us translating on %s": "在 %s 上帮我们翻译", + "Source Code": "源代码", + "Powered by %s": "由 %s 驱动", + "Register": "注册", + "Export with pandoc": "导出为 Pandoc", + "Select output format": "选择输出格式" +} From 65222df23c43de00a5cb4dcb57461c9d260bd126 Mon Sep 17 00:00:00 2001 From: zent00 Date: Tue, 28 Apr 2020 11:09:22 +0800 Subject: [PATCH 08/48] fix typography of footer Signed-off-by: zent00 --- locales/zh-CN.json | 4 ++-- public/views/index/body.ejs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/locales/zh-CN.json b/locales/zh-CN.json index 687b9f56bd..667f457fe2 100644 --- a/locales/zh-CN.json +++ b/locales/zh-CN.json @@ -100,7 +100,7 @@ "Paste your gist url here...": "在这里粘贴 Gist 网址...", "Import from Snippet": "从 Snippet 导入", "Select From Available Projects": "从可用的项目中选择", - "Select From Available Snippets": "从可用的 Snippet 中选择", + "Select From Available Snippets": "从可用的 Snippets 中选择", "OR": "或", "Export to Snippet": "导出到 Snippet", "Select Visibility Level": "选择可见层级", @@ -116,6 +116,6 @@ "Source Code": "源代码", "Powered by %s": "由 %s 驱动", "Register": "注册", - "Export with pandoc": "导出为 Pandoc", + "Export with pandoc": "使用 Pandoc 导出", "Select output format": "选择输出格式" } diff --git a/public/views/index/body.ejs b/public/views/index/body.ejs index 7b5200706f..db20b0e3c7 100644 --- a/public/views/index/body.ejs +++ b/public/views/index/body.ejs @@ -151,7 +151,7 @@

- <%- __('Powered by %s', 'CodiMD') %> | <%= __('Releases') %>| <%= __('Source Code') %><% if(privacyStatement) { %> | <%= __('Privacy') %><% } %><% if(termsOfUse) { %> | <%= __('Terms of Use') %><% } %> + <%- __('Powered by %s', 'CodiMD') %> | <%= __('Releases') %> | <%= __('Source Code') %><% if(privacyStatement) { %> | <%= __('Privacy') %><% } %><% if(termsOfUse) { %> | <%= __('Terms of Use') %><% } %>