Skip to content

Commit

Permalink
🎨 fix #1342
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Dec 21, 2022
1 parent bf51c10 commit 9dbbc79
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@

### v3.9.0 / 2023-01

* [1342](https://github.com/Vanessa219/vditor/pull/1342) 初始化后不自动聚焦 `改进功能`
* [1341](https://github.com/Vanessa219/vditor/pull/1341) 支持 markmap `引入特性`
* [1335](https://github.com/Vanessa219/vditor/issues/1335) 嵌入 Iframe 时无法导出 PDF `修复缺陷`

### v3.8.18 / 2022-11-01
Expand Down
6 changes: 2 additions & 4 deletions src/ts/outline/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class Outline {
return html;
}

public toggle(vditor: IVditor, show = true) {
public toggle(vditor: IVditor, show = true, focus = true) {
const btnElement = vditor.toolbar.elements.outline?.firstElementChild;
if (show && window.innerWidth >= Constants.MOBILE_WIDTH) {
this.element.style.display = "block";
Expand All @@ -34,12 +34,10 @@ export class Outline {
this.element.style.display = "none";
btnElement?.classList.remove("vditor-menu--current");
}
if (getSelection().rangeCount > 0) {
if (focus && getSelection().rangeCount > 0) {
const range = getSelection().getRangeAt(0);
if (vditor[vditor.currentMode].element.contains(range.startContainer)) {
setSelectionFocus(range);
} else if (vditor[vditor.currentMode].element.contains(getSelection().focusNode)) {
vditor[vditor.currentMode].element.focus();
}
}
setPadding(vditor);
Expand Down
2 changes: 1 addition & 1 deletion src/ts/toolbar/EditMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const setEditMode = (vditor: IVditor, type: string, event: Event | string
vditor.toolbar.elements["edit-mode"].querySelector(`button[data-mode="${vditor.currentMode}"]`).classList.add("vditor-menu--current");
}

vditor.outline.toggle(vditor, vditor.currentMode !== "sv" && vditor.options.outline.enable);
vditor.outline.toggle(vditor, vditor.currentMode !== "sv" && vditor.options.outline.enable, typeof event !== "string");
};

export class EditMode extends MenuItem {
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ interface IVditor {
outline: {
element: HTMLElement,
render(vditor: IVditor): string,
toggle(vditor: IVditor, show?: boolean): void,
toggle(vditor: IVditor, show?: boolean, focus?: boolean): void,
};
toolbar?: {
elements?: { [key: string]: HTMLElement },
Expand Down

0 comments on commit 9dbbc79

Please sign in to comment.