Van 6 years ago
parent
commit
3df2e24495

+ 2 - 2
demo/index.js

@@ -97,8 +97,8 @@ window.vditorTest = new Vditor('vditorTest', {
     emoji: {
     emoji: {
       '+1': '👍',
       '+1': '👍',
       '-1': '👎',
       '-1': '👎',
-      'trollface': 'https://cdn.jsdelivr.net/npm/vditor@latest/src/assets/emoji/trollface.png',
-      'huaji': 'https://cdn.jsdelivr.net/npm/vditor@latest/src/assets/emoji/huaji.gif',
+      'trollface': 'https://unpkg.com/[email protected]/dist/images/emoji/trollface.png',
+      'huaji': 'https://unpkg.com/[email protected]/dist/images/emoji/huaji.gif',
     },
     },
     at: (key) => {
     at: (key) => {
       console.log(`atUser: ${key}`)
       console.log(`atUser: ${key}`)

+ 2 - 2
demo/static.html

@@ -34,8 +34,8 @@
     <meta name="twitter:url" content="https://github.com/b3log/vditor"/>
     <meta name="twitter:url" content="https://github.com/b3log/vditor"/>
     <meta property="og:image" content="https://cdn.jsdelivr.net/npm/vditor/dist/images/logo.png"/>
     <meta property="og:image" content="https://cdn.jsdelivr.net/npm/vditor/dist/images/logo.png"/>
     <meta name="twitter:image" content="https://cdn.jsdelivr.net/npm/vditor/dist/images/logo.png"/>
     <meta name="twitter:image" content="https://cdn.jsdelivr.net/npm/vditor/dist/images/logo.png"/>
-    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected].1/dist/index.classic.css" />
-    <script src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/index.min.js" defer></script>
+    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected].2/dist/index.classic.css" />
+    <script src="https://cdn.jsdelivr.net/npm/[email protected].2/dist/index.min.js" defer></script>
     <script src="static.js" defer></script>
     <script src="static.js" defer></script>
 </head>
 </head>
 <body>
 <body>

+ 2 - 5
demo/static.js

@@ -94,8 +94,8 @@ window.vditorTest = new Vditor('vditorTest', {
     emoji: {
     emoji: {
       '+1': '👍',
       '+1': '👍',
       '-1': '👎',
       '-1': '👎',
-      'trollface': 'https://cdn.jsdelivr.net/npm/vditor@latest/src/assets/emoji/trollface.png',
-      'huaji': 'https://cdn.jsdelivr.net/npm/vditor@latest/src/assets/emoji/huaji.gif',
+      'trollface': 'https://unpkg.com/[email protected]/dist/images/emoji/trollface.png',
+      'huaji': 'https://unpkg.com/[email protected]/dist/images/emoji/huaji.gif',
     },
     },
     at: (key) => {
     at: (key) => {
       console.log(`atUser: ${key}`)
       console.log(`atUser: ${key}`)
@@ -110,9 +110,6 @@ window.vditorTest = new Vditor('vditorTest', {
         }]
         }]
     },
     },
   },
   },
-  classes: {
-    preview: 'content-reset',
-  },
   focus: (val) => {
   focus: (val) => {
     console.log(`focus value: ${val}`)
     console.log(`focus value: ${val}`)
     console.log(
     console.log(

+ 2 - 2
package.json

@@ -1,7 +1,7 @@
 {
 {
   "name": "vditor",
   "name": "vditor",
-  "version": "1.3.0",
-  "cdn": "https://unpkg.com",
+  "version": "1.3.2",
+  "cdn": "https://cdn.jsdelivr.net/npm",
   "description": "A markdown editor written in TypeScript",
   "description": "A markdown editor written in TypeScript",
   "author": " Vanessa <[email protected]> (http://vanessa.b3log.org)",
   "author": " Vanessa <[email protected]> (http://vanessa.b3log.org)",
   "homepage": "https://hacpai.com/cr",
   "homepage": "https://hacpai.com/cr",

+ 1 - 1
src/assets/scss/_reset.scss

@@ -144,7 +144,7 @@
       font-family: $font-family-code;
       font-family: $font-family-code;
       word-break: break-word;
       word-break: break-word;
       background-size: 20px 20px;
       background-size: 20px 20px;
-      background-image: url("https://cdn.jsdelivr.net/npm/[email protected]/src/assets/images/code-bg.png");
+      background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8AgMAAABHkjHhAAAACVBMVEWAgIBaWlo+Pj7rTFvWAAAAA3RSTlMHCAw+VhR4AAAA+klEQVQoz4WSMW7EQAhFPxKWNh2FCx+HkaZI6RRb5DYbyVfIJXLKDCFoMbaTKSw/8ZnPAPjaH2xgZcUNUDADD7D9LtDBCLZ45fbkvo/30K8yeI64pPwl6znd/3n/Oe93P3ho9qeh72btTFzqkz0rsJle8Zr81OLEwZ1dv/713uWqvu2pl+k0fy7MWtj9r/tN5q/02z89qa/L4Dc2LvM93kezPfXlME/O86EbY/V9GB9ePX8G1/6W+/9h1dq/HGfTfzT3j/xNo7522Bfnqe5jO/fvhVthlfk434v3iO9zG/UOphyPeinPl1J8Gtaa7xPTa/Dk+RIs4deMvwGvcGsmsCvJ0AAAAABJRU5ErkJggg==);
     }
     }
 
 
     pre > code {
     pre > code {

BIN
src/images/code-bg.png


+ 0 - 1
src/ts/constants.ts

@@ -9,4 +9,3 @@ declare const CDN_PATH: string;
 const _CDN_PATH = CDN_PATH;
 const _CDN_PATH = CDN_PATH;
 
 
 export {_CDN_PATH as CDN_PATH};
 export {_CDN_PATH as CDN_PATH};
-

+ 2 - 2
src/ts/markdown/mathRender.ts

@@ -1,5 +1,5 @@
+import {CDN_PATH, VDITOR_VERSION} from "../constants";
 import {addStyle} from "../util/addStyle";
 import {addStyle} from "../util/addStyle";
-import {CDN, VDITOR_VERSION} from "../constants";
 
 
 export const mathRender = (element: HTMLElement) => {
 export const mathRender = (element: HTMLElement) => {
     const text = element.innerText;
     const text = element.innerText;
@@ -7,7 +7,7 @@ export const mathRender = (element: HTMLElement) => {
         import(/* webpackChunkName: "katex" */ "katex").then(() => {
         import(/* webpackChunkName: "katex" */ "katex").then(() => {
             import(/* webpackChunkName: "katex" */ "katex/contrib/auto-render/auto-render")
             import(/* webpackChunkName: "katex" */ "katex/contrib/auto-render/auto-render")
                 .then((renderMathInElement) => {
                 .then((renderMathInElement) => {
-                    addStyle(`${CDN}/vditor@${VDITOR_VERSION}/dist/js/[email protected]/katex.min.css`, "vditorKatexStyle");
+                    addStyle(`${CDN_PATH}/vditor@${VDITOR_VERSION}/dist/js/[email protected]/katex.min.css`, "vditorKatexStyle");
                     renderMathInElement.default(element, {
                     renderMathInElement.default(element, {
                         delimiters: [
                         delimiters: [
                             {left: "$$", right: "$$", display: true},
                             {left: "$$", right: "$$", display: true},

+ 3 - 2
src/ts/markdown/render.ts

@@ -1,10 +1,11 @@
+import {CDN_PATH, VDITOR_VERSION} from "../constants";
 import {addStyle} from "../util/addStyle";
 import {addStyle} from "../util/addStyle";
 import {task} from "./markdown-it-task";
 import {task} from "./markdown-it-task";
-import {CDN_PATH, VDITOR_VERSION} from "../constants";
 
 
 const initMarkdownIt = async (vditor: IVditor, includeHljs: boolean) => {
 const initMarkdownIt = async (vditor: IVditor, includeHljs: boolean) => {
     if (vditor.options.preview.hljs.style) {
     if (vditor.options.preview.hljs.style) {
-        addStyle(`${CDN_PATH}/vditor@${VDITOR_VERSION}/dist/js/[email protected]/styles/${vditor.options.preview.hljs.style}.min.css`,
+        addStyle(`${CDN_PATH}/vditor@${VDITOR_VERSION}/dist/js/[email protected]/styles/${
+            vditor.options.preview.hljs.style}.css`,
             "vditorHljsStyle");
             "vditorHljsStyle");
     }
     }
 
 

+ 4 - 5
webpack.config.js

@@ -51,8 +51,7 @@ module.exports = [
       filename: '[name].js',
       filename: '[name].js',
       path: path.resolve(__dirname, 'dist'),
       path: path.resolve(__dirname, 'dist'),
       chunkFilename: '[name].bundle.js',
       chunkFilename: '[name].bundle.js',
-      // publicPath: `https://cdn.jsdelivr.net/npm/vditor@${pkg.version}/`,
-      // publicPath: `https://static.hacpai.com/js/lib/vditor@${pkg.version}/`,
+      // pkg.cdn: https://static.hacpai.com/js/lib | https://unpkg.com | https://cdn.jsdelivr.net/npm
       publicPath: `${pkg.cdn}/vditor@${pkg.version}/dist/`,
       publicPath: `${pkg.cdn}/vditor@${pkg.version}/dist/`,
       libraryTarget: 'umd',
       libraryTarget: 'umd',
       library: 'Vditor',
       library: 'Vditor',
@@ -131,8 +130,8 @@ module.exports = [
         cacheGroups: {
         cacheGroups: {
           vendors: {
           vendors: {
             test: /null/,
             test: /null/,
-          }
-        }
+          },
+        },
       },
       },
     },
     },
   }, {
   }, {
@@ -190,6 +189,6 @@ module.exports = [
       new CopyPlugin([
       new CopyPlugin([
         {from: 'src/images', to: 'images'},
         {from: 'src/images', to: 'images'},
         {from: 'src/js', to: 'js'},
         {from: 'src/js', to: 'js'},
-      ])
+      ]),
     ],
     ],
   }]
   }]

+ 1 - 1
webpack.start.js

@@ -113,7 +113,7 @@ module.exports = {
     }),
     }),
     new webpack.DefinePlugin({
     new webpack.DefinePlugin({
       VDITOR_VERSION: JSON.stringify(pkg.version),
       VDITOR_VERSION: JSON.stringify(pkg.version),
-      PUBLIC_PATH: JSON.stringify(pkg.publicPath),
+      CDN_PATH: JSON.stringify(pkg.cdn),
     }),
     }),
     new CopyPlugin([
     new CopyPlugin([
       {from: 'src/images', to: 'images'},
       {from: 'src/images', to: 'images'},