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

Fix #274: Couldn't render UML which includes CJK

Yuki Takei 8 лет назад
Родитель
Сommit
89b6c0dba3
3 измененных файлов с 18 добавлено и 3 удалено
  1. 1 0
      package.json
  2. 2 3
      resource/js/util/markdown-it/plantuml.js
  3. 15 0
      yarn.lock

+ 1 - 0
package.json

@@ -115,6 +115,7 @@
     "passport-ldapauth": "^2.0.0",
     "passport-ldapauth": "^2.0.0",
     "passport-local": "^1.0.0",
     "passport-local": "^1.0.0",
     "pino-clf": "^1.0.2",
     "pino-clf": "^1.0.2",
+    "plantuml-encoder": "^1.2.5",
     "react": "^16.0.0",
     "react": "^16.0.0",
     "react-bootstrap": "^0.32.0",
     "react-bootstrap": "^0.32.0",
     "react-bootstrap-typeahead": "^2.0.2",
     "react-bootstrap-typeahead": "^2.0.2",

+ 2 - 3
resource/js/util/markdown-it/plantuml.js

@@ -1,3 +1,4 @@
+import plantumlEncoder from 'plantuml-encoder';
 import urljoin from 'url-join';
 import urljoin from 'url-join';
 
 
 export default class PlantUMLConfigurer {
 export default class PlantUMLConfigurer {
@@ -6,7 +7,6 @@ export default class PlantUMLConfigurer {
     this.crowi = crowi;
     this.crowi = crowi;
     const config = crowi.getConfig();
     const config = crowi.getConfig();
 
 
-    this.deflate = require('markdown-it-plantuml/lib/deflate.js');
     this.serverUrl = config.env.PLANTUML_URI || 'http://plantuml.com/plantuml';
     this.serverUrl = config.env.PLANTUML_URI || 'http://plantuml.com/plantuml';
 
 
     this.generateSource = this.generateSource.bind(this);
     this.generateSource = this.generateSource.bind(this);
@@ -19,8 +19,7 @@ export default class PlantUMLConfigurer {
   }
   }
 
 
   generateSource(umlCode) {
   generateSource(umlCode) {
-    const zippedCode =
-      this.deflate.encode64(this.deflate.zip_deflate('@startuml\n' + umlCode + '\n@enduml', 9));
+    const zippedCode = plantumlEncoder.encode(`@startuml\n${umlCode}\n@enduml`);
     return urljoin(this.serverUrl, 'svg' , zippedCode);
     return urljoin(this.serverUrl, 'svg' , zippedCode);
   }
   }
 }
 }

+ 15 - 0
yarn.lock

@@ -4409,6 +4409,10 @@ p-try@^1.0.0:
   version "1.0.0"
   version "1.0.0"
   resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3"
   resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3"
 
 
+pako@1.0.3:
+  version "1.0.3"
+  resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.3.tgz#5f515b0c6722e1982920ae8005eacb0b7ca73ccf"
+
 pako@~1.0.5:
 pako@~1.0.5:
   version "1.0.6"
   version "1.0.6"
   resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.6.tgz#0101211baa70c4bca4a0f63f2206e97b7dfaf258"
   resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.6.tgz#0101211baa70c4bca4a0f63f2206e97b7dfaf258"
@@ -4623,6 +4627,13 @@ pkginfo@^0.4.0:
   version "0.4.1"
   version "0.4.1"
   resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.4.1.tgz#b5418ef0439de5425fc4995042dced14fb2a84ff"
   resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.4.1.tgz#b5418ef0439de5425fc4995042dced14fb2a84ff"
 
 
+plantuml-encoder@^1.2.5:
+  version "1.2.5"
+  resolved "https://registry.yarnpkg.com/plantuml-encoder/-/plantuml-encoder-1.2.5.tgz#6b8e5b9e1a1dbd88b3fd9fb46f734eec7d44b548"
+  dependencies:
+    pako "1.0.3"
+    utf8-bytes "0.0.1"
+
 postcss-calc@^5.2.0:
 postcss-calc@^5.2.0:
   version "5.3.1"
   version "5.3.1"
   resolved "https://registry.yarnpkg.com/postcss-calc/-/postcss-calc-5.3.1.tgz#77bae7ca928ad85716e2fda42f261bf7c1d65b5e"
   resolved "https://registry.yarnpkg.com/postcss-calc/-/postcss-calc-5.3.1.tgz#77bae7ca928ad85716e2fda42f261bf7c1d65b5e"
@@ -6222,6 +6233,10 @@ uslug@^1.0.4:
   dependencies:
   dependencies:
     unorm ">= 1.0.0"
     unorm ">= 1.0.0"
 
 
+utf8-bytes@0.0.1:
+  version "0.0.1"
+  resolved "https://registry.yarnpkg.com/utf8-bytes/-/utf8-bytes-0.0.1.tgz#116b025448c9b500081cdfbf1f4d6c6c37d8837d"
+
 util-deprecate@~1.0.1:
 util-deprecate@~1.0.1:
   version "1.0.2"
   version "1.0.2"
   resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
   resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"