Skip to content

Commit

Permalink
🎨 fix #420
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed May 17, 2020
1 parent 49b239b commit 69e84c6
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@

### v3.2.7 / 2020-05-xx

* [420](https://github.com/Vanessa219/vditor/issues/420) 缓存时可以提供一个回调吗,我想同步到服务器上 `改进功能`
* [419](https://github.com/Vanessa219/vditor/issues/419) outline after update at smartphone `改进功能`
* [418](https://github.com/Vanessa219/vditor/issues/418) 点击侧边空白,光标会挪到尾部 `修复缺陷`
* [415](https://github.com/Vanessa219/vditor/issues/415) using local JS file `修复缺陷`
Expand Down Expand Up @@ -114,7 +115,9 @@
* 添加静态方法 `mindmapRender`
* 为 `IMarkdownConfig` 添加 `sanitize`, `listMarker` 配置
* IPreviewOptions.anchor 从 boolean 修改为 number
* static-preview.html => preview.html
* static-preview.html => preview.html,static.html => vditor.b3log.org/demo/render.html
* 添加 options.cache.after(text:string)


### v3.1.23 / 2020-05-05

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ Can be filled with element `id` or element itself` HTMLElement`
| - | - | - |
| enable | Whether to use localStorage for caching | true |
| id | Cache key, the first parameter is an element and when caching is enabled **required** | - |
| after | cache callback (markdown: string): void | - |

#### options.preview

Expand Down
1 change: 1 addition & 0 deletions src/ts/ir/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const processAfterRender = (vditor: IVditor, options = {

if (vditor.options.cache.enable) {
localStorage.setItem(vditor.options.cache.id, text);
vditor.options.cache?.after(text);
}

if (vditor.devtools) {
Expand Down
1 change: 1 addition & 0 deletions src/ts/sv/inputEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const inputEvent = (vditor: IVditor, options = {
}
if (vditor.options.cache.enable) {
localStorage.setItem(vditor.options.cache.id, text);
vditor.options.cache?.after(text);
}
vditor.preview.render(vditor);
if (options.enableAddUndoStack) {
Expand Down
1 change: 1 addition & 0 deletions src/ts/wysiwyg/afterRenderEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const afterRenderEvent = (vditor: IVditor, options = {

if (vditor.options.cache.enable) {
localStorage.setItem(vditor.options.cache.id, text);
vditor.options.cache?.after(text);
}

if (vditor.devtools) {
Expand Down
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ interface IOptions {
cache?: {
id?: string;
enable?: boolean;
after?(markdown: string): void;
};
/** 编辑模式。默认值: 'wysiwyg' */
mode?: "wysiwyg" | "sv" | "ir";
Expand Down

0 comments on commit 69e84c6

Please sign in to comment.