Skip to content

Commit

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

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

* [421](https://github.com/Vanessa219/vditor/issues/421) 添加 bilibili 视频网站解析 `改进功能`
* [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) 点击侧边空白,光标会挪到尾部 `修复缺陷`
Expand Down
4 changes: 3 additions & 1 deletion src/ts/ir/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ 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.options.cache.after) {
vditor.options.cache.after(text);
}
}

if (vditor.devtools) {
Expand Down
6 changes: 6 additions & 0 deletions src/ts/markdown/mediaRender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const iframeRender = (element: HTMLElement, url: string) => {
const coubMatch = url.match(/(?:www\.|\/\/)coub\.com\/view\/(\w+)/);
const facebookMatch = url.match(/(?:www\.|\/\/)facebook\.com\/([^\/]+)\/videos\/([0-9]+)/);
const dailymotionMatch = url.match(/.+dailymotion.com\/(video|hub)\/(\w+)\?/);
const bilibiliMatch = url.match(/(?:www\.|\/\/)bilibili\.com\/video\/(\w+)/);

if (youtubeMatch && youtubeMatch[1].length === 11) {
element.insertAdjacentHTML("afterend",
Expand Down Expand Up @@ -44,6 +45,11 @@ const iframeRender = (element: HTMLElement, url: string) => {
`<iframe class="iframe__video"
src="https://www.dailymotion.com/embed/video/${dailymotionMatch[2]}"></iframe>`);
element.remove();
} else if (bilibiliMatch && bilibiliMatch[1]) {
element.insertAdjacentHTML("afterend",
`<iframe class="iframe__video"
src="//player.bilibili.com/player.html?bvid=${bilibiliMatch[1]}"></iframe>`);
element.remove();
}
};

Expand Down
4 changes: 3 additions & 1 deletion src/ts/sv/inputEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export const inputEvent = (vditor: IVditor, options = {
}
if (vditor.options.cache.enable) {
localStorage.setItem(vditor.options.cache.id, text);
vditor.options.cache?.after(text);
if (vditor.options.cache.after) {
vditor.options.cache.after(text);
}
}
vditor.preview.render(vditor);
if (options.enableAddUndoStack) {
Expand Down
4 changes: 3 additions & 1 deletion src/ts/wysiwyg/afterRenderEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ 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.options.cache.after) {
vditor.options.cache.after(text);
}
}

if (vditor.devtools) {
Expand Down

0 comments on commit f30a0c9

Please sign in to comment.