From d9aa9696d4ab1fae4a3b28982ac8ccea4a276268 Mon Sep 17 00:00:00 2001 From: undefined Date: Tue, 31 May 2022 12:24:28 +0000 Subject: [PATCH] chore: replace cdn.jsdelivr.net/npm with unpkg.com --- README.md | 16 ++++++++-------- README_en_US.md | 18 +++++++++--------- __test__/util/Options.test.ts | 2 +- types/index.d.ts | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 00de160cc..488360f4d 100644 --- a/README.md +++ b/README.md @@ -141,9 +141,9 @@ const vditor = new Vditor(id, {options...}) * 在 HTML 中插入 CSS 和 JavaScript,可参考 [demo](https://b3log.org/vditor/demo/index.html) ```html - - - + + + ``` ### 示例代码 @@ -209,7 +209,7 @@ Markdown 输出的 HTML 所展现的外观。内置 ant-design, light,dark,w | select(value: string) | 编辑器中选中文字后触发 | - | | tab | tab 键操作字符串,支持 `\t` 及任意字符串 | - | | typewriterMode | 是否启用打字机模式 | false | -| cdn | 配置自建 CDN 地址 | `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}` | +| cdn | 配置自建 CDN 地址 | `https://unpkg.com/vditor@${VDITOR_VERSION}` | | mode | 可选模式:sv, ir, wysiwyg | 'ir' | | debugger | 是否显示日志 | false | | value | 编辑器初始化值 | '' | @@ -328,7 +328,7 @@ new Vditor('vditor', { | - | - | - | | current | 当前主题 | "light" | | list | 可选主题列表 | { "ant-design": "Ant Design", dark: "Dark", light: "Light", wechat: "WeChat" } | -| path | 主题样式地址 | `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}/dist/css/content-theme` | +| path | 主题样式地址 | `https://unpkg.com/vditor@${VDITOR_VERSION}/dist/css/content-theme` | #### options.preview.math @@ -359,7 +359,7 @@ new Vditor('vditor', { | delay | 提示 debounce 毫秒间隔 | 200 | | emoji | 默认表情,可从[lute/emoji_map](https://github.com/88250/lute/blob/master/parse/emoji_map.go) 中选取,也可自定义 | { '+1': '👍', '-1': '👎', 'heart': '❤️', 'cold_sweat': '😰' } | | emojiTail | 常用表情提示 | - | -| emojiPath | 表情图片地址 | `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}/dist/images/emoji` | +| emojiPath | 表情图片地址 | `https://unpkg.com/vditor@${VDITOR_VERSION}/dist/images/emoji` | | extend: IHintExtend[] | 对 @/话题等关键字自动补全的扩展 | [] | ```ts @@ -520,7 +520,7 @@ if (xhr.status === 200) { #### static methods -* 不需要进行编辑操作时,仅需引入 [`method.min.js`](https://cdn.jsdelivr.net/npm/vditor/dist/) 后如下直接调用 +* 不需要进行编辑操作时,仅需引入 [`method.min.js`](https://unpkg.com/vditor/dist/) 后如下直接调用 ```js Vditor.mermaidRender(document) @@ -600,7 +600,7 @@ options?: IPreviewOptions { ### CDN 切换 -由于使用了按需加载的机制,默认 CDN 为 [https://cdn.jsdelivr.net/npm/vditor](https://cdn.jsdelivr.net/npm/vditor)@版本号 +由于使用了按需加载的机制,默认 CDN 为 [https://unpkg.com/vditor](https://unpkg.com/vditor)@版本号 如果代码有修改或需要使用自建 CDN 的话,可按以下步骤进行操作: diff --git a/README_en_US.md b/README_en_US.md index a9f15e4ed..b95f6aa55 100644 --- a/README_en_US.md +++ b/README_en_US.md @@ -139,9 +139,9 @@ const vditor = new Vditor(id, {options...}) * Insert CSS and js in HTML, you can refer to [demo](https://b3log.org/vditor/demo/index.html) ```html - - - + + + ``` ### Demo code @@ -186,7 +186,7 @@ Can be filled with element `id` or element itself` HTMLElement` | select | Triggered after selecting text in the editor (value: string) | - | | tab | tab key operation string, support `\ t` and any string | - | | typewriterMode | Whether to enable typewriter mode | false | -| cdn | Configure self-built CDN address | `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}` | +| cdn | Configure self-built CDN address | `https://unpkg.com/vditor@${VDITOR_VERSION}` | | mode | Editing mode: sv, ir, wysiwyg | 'ir' | | debugger | Whether to display the log | false | | value | Editor initialization value | '' | @@ -280,7 +280,7 @@ new Vditor('vditor', { | - | - | - | | current | current Markdown Theme | "light" | | list | Choose Markdown Theme List | { "ant-design": "Ant Design", dark: "Dark", light: "Light", wechat: "WeChat" } | -| path | CSS Path | `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}/dist/css/content-theme` | +| path | CSS Path | `https://unpkg.com/vditor@${VDITOR_VERSION}/dist/css/content-theme` | #### options.preview.hljs @@ -335,7 +335,7 @@ Default: ["desktop", "tablet", "mobile", "mp-wechat", "zhihu"] | delay | Tip debounce millisecond interval | 200 | | emoji | The default emoji can be selected from [lute/emoji_map](https://github.com/88250/lute/blob/master/parse/emoji_map.go), or can be customized | { '+1': '👍', '-1': '👎', 'heart': '❤️', 'cold_sweat': '😰' } | | emojiTail | Common emoji | - | -| emojiPath | Emoji path | `https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}/dist/images/emoji` | +| emojiPath | Emoji path | `https://unpkg.com/vditor@${VDITOR_VERSION}/dist/images/emoji` | | extend: IHintExtend[] | @/# and other keyword auto-completion expansion | [] | ```ts @@ -474,7 +474,7 @@ xhr.send(JSON.stringify({url: src})); // src is the address of the image outside #### static methods -* When no editing operation is required, just introduce [`method.min.js`](https://cdn.jsdelivr.net/npm/vditor/dist/) and directly call +* When no editing operation is required, just introduce [`method.min.js`](https://unpkg.com/vditor/dist/) and directly call ```js Vditor.mermaidRender(document) @@ -504,7 +504,7 @@ options?: IPreviewOptions { transform?(html: string): string; // Callback method before rendering after?(); // Callback method after rendering cdn?: string; // Self-built CDN address - lazyLoadImage?: string; // use "https://cdn.jsdelivr.net/npm/vditor/dist/images/img-loading.svg" to lazy load image + lazyLoadImage?: string; // use "https://unpkg.com/vditor/dist/images/img-loading.svg" to lazy load image markdown?: options.preview.markdown; renderers?: ILuteRender; // Custom rendering method https://ld246.com/article/1588412297062 } @@ -553,7 +553,7 @@ options?: IPreviewOptions { ### CDN switch -Due to the on-demand loading mechanism, the default CDN is [https://cdn.jsdelivr.net/npm/vditor](https://cdn.jsdelivr.net/npm/vditor)@version number +Due to the on-demand loading mechanism, the default CDN is [https://unpkg.com/vditor](https://unpkg.com/vditor)@version number If the code is modified or you need to use a self-built CDN, you can follow the steps below: diff --git a/__test__/util/Options.test.ts b/__test__/util/Options.test.ts index 2fd4a75e8..dbbaf0d7b 100644 --- a/__test__/util/Options.test.ts +++ b/__test__/util/Options.test.ts @@ -140,7 +140,7 @@ describe("Options", () => { emoji: { "+1": "👍", }, - emojiPath: "https://cdn.jsdelivr.net/npm/vditor@version/dist/images/emoji", + emojiPath: "https://unpkg.com/vditor@version/dist/images/emoji", emojiTail: "前往设置", }, }); diff --git a/types/index.d.ts b/types/index.d.ts index eb185cf95..9a17ae7dd 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -550,7 +550,7 @@ interface IHint { delay?: number; /** 默认表情,可从 [lute/emoji_map](https://github.com/88250/lute/blob/master/parse/emoji_map.go#L32) 中选取,也可自定义 */ emoji?: IObject; - /** 表情图片地址。默认值: 'https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}/dist/images/emoji' */ + /** 表情图片地址。默认值: 'https://unpkg.com/vditor@${VDITOR_VERSION}/dist/images/emoji' */ emojiPath?: string; extend?: IHintExtend[]; } @@ -640,7 +640,7 @@ interface IOptions { upload?: IUpload; /** @link https://ld246.com/article/1549638745630#options-classes */ classes?: IClasses; - /** 配置自建 CDN 地址。默认值: 'https://cdn.jsdelivr.net/npm/vditor@${VDITOR_VERSION}' */ + /** 配置自建 CDN 地址。默认值: 'https://unpkg.com/vditor@${VDITOR_VERSION}' */ cdn?: string; /** tab 键操作字符串,支持 \t 及任意字符串 */ tab?: string;