Skip to content

Commit

Permalink
Normalize link handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeyers committed Apr 16, 2024
1 parent ab8b9a0 commit 6899521
Show file tree
Hide file tree
Showing 10 changed files with 429 additions and 418 deletions.
10 changes: 2 additions & 8 deletions src/components/Editor/MarkdownEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,14 @@ export function MarkdownEditor({
extensions.push(datePlugins);
extensions.push(
EditorView.domEventHandlers({
focus: (evt, cm) => {
cm.dom.win.setTimeout(() => {
focus: (evt) => {
evt.win.setTimeout(() => {
this.app.workspace.activeEditor = this.owner;
if (Platform.isMobile) {
this.app.mobileToolbar.update();
}
});
},
blur: () => {
if (Platform.isMobile) {
this.app.mobileToolbar.update();
}
this.editorSuggest.close();
},
})
);

Expand Down
25 changes: 1 addition & 24 deletions src/components/Item/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const ItemInner = memo(function ItemInner({
};

dndManager.dragManager.emitter.on('dragStart', handler);

return () => {
dndManager.dragManager.emitter.off('dragStart', handler);
};
Expand All @@ -81,29 +80,8 @@ const ItemInner = memo(function ItemInner({
path,
});

const onContextMenu: JSX.MouseEventHandler<HTMLDivElement> = useCallback(
(e) => {
if (e.targetNode.instanceOf(HTMLTextAreaElement)) {
return;
}

e.preventDefault();
e.stopPropagation();

const internalLinkPath =
e.targetNode.instanceOf(HTMLAnchorElement) && e.targetNode.hasClass('internal-link')
? e.targetNode.dataset.href
: undefined;

showItemMenu(e, internalLinkPath);
},
[showItemMenu]
);

const onDoubleClick: JSX.MouseEventHandler<HTMLDivElement> = useCallback(
(e) => {
setEditState({ x: e.clientX, y: e.clientY });
},
(e) => setEditState({ x: e.clientX, y: e.clientY }),
[setEditState]
);

Expand All @@ -119,7 +97,6 @@ const ItemInner = memo(function ItemInner({

return (
<div
onContextMenu={onContextMenu}
// eslint-disable-next-line react/no-unknown-property
onDblClick={onDoubleClick}
className={c('item-content-wrapper')}
Expand Down
6 changes: 6 additions & 0 deletions src/components/Item/ItemContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ export function Tags({
return (
<a
href={tag}
onClick={(e) => {
e.preventDefault();
(stateManager.app as any).internalPlugins
.getPluginById('global-search')
.instance.openGlobalSearch(`tag:${tag}`);
}}
key={i}
className={`tag ${c('item-tag')} ${
searchQuery && tag.toLocaleLowerCase().contains(searchQuery) ? 'is-search-match' : ''
Expand Down
Loading

0 comments on commit 6899521

Please sign in to comment.