Skip to content

Commit

Permalink
Fix stuck mobile toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeyers committed Apr 17, 2024
1 parent 7d3d6e5 commit ab0850c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ package-lock.json
yarn*
dist
test-vault/
main.js
main.js
styles.css
46 changes: 28 additions & 18 deletions src/components/Editor/MarkdownEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,27 +106,31 @@ export function MarkdownEditor({
extensions.push(stateManagerField.init(() => stateManager));
extensions.push(datePlugins);
extensions.push(
EditorView.domEventHandlers({
focus: (evt) => {
if (Platform.isMobile) {
view.contentEl.addClass('is-mobile-editing');
}

evt.win.setTimeout(() => {
this.app.workspace.activeEditor = this.owner;
Prec.high(
EditorView.domEventHandlers({
focus: (evt) => {
if (Platform.isMobile) {
view.contentEl.addClass('is-mobile-editing');
}

evt.win.setTimeout(() => {
this.app.workspace.activeEditor = this.owner;
if (Platform.isMobile) {
this.app.mobileToolbar.update();
}
});
return true;
},
blur: () => {
this.app.workspace.activeEditor = null;
if (Platform.isMobile) {
view.contentEl.removeClass('is-mobile-editing');
this.app.mobileToolbar.update();
}
});
},
blur: () => {
this.app.workspace.activeEditor = null;
if (Platform.isMobile) {
view.contentEl.removeClass('is-mobile-editing');
this.app.mobileToolbar.update();
}
},
})
return true;
},
})
)
);

if (placeholder) extensions.push(placeholderExt(placeholder));
Expand Down Expand Up @@ -210,6 +214,12 @@ export function MarkdownEditor({
return () => {
if (Platform.isMobile) {
window.removeEventListener('keyboardDidShow', onShow);

if (app.workspace.activeEditor === controller) {
app.workspace.activeEditor = null;
(app as any).mobileToolbar.update();
view.contentEl.removeClass('is-mobile-editing');
}
}
view.plugin.removeChild(editor);
internalRef.current = null;
Expand Down

0 comments on commit ab0850c

Please sign in to comment.