Skip to content

Commit

Permalink
Merge pull request #100 from topherhunt/th/clean-title-text
Browse files Browse the repository at this point in the history
  • Loading branch information
pengx17 authored Mar 11, 2024
2 parents 8f96f42 + be24f29 commit 430ec3d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ UX is mainly brought from modern browsers:
Hint: you can change them in the Settings. After change, you need to restart the app.

![](./keybinding-settings.png)

## Contributing

- Please follow [Logseq's guidelines](https://github.com/logseq/logseq/blob/master/CONTRIBUTING.md) for contributions and Pull Requests.
- See the [logseq-plugin-template-react readme](https://github.com/pengx17/logseq-plugin-template-react?tab=readme-ov-file#how-to-get-started) for steps on how to build and test this plugin.
11 changes: 9 additions & 2 deletions src/PageTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ const Tabs = React.forwardRef<HTMLElement, TabsProps>(
};
}, []);

// Clean out link markup and internal block metadata from text shown in tab titles.
const cleanBlockTitle = (text: string): string => (
text
.replace(/\[([^\]]+)\]\([^\)]+\)/, "$1")
.replace(/\s+(id|background-color|collapsed):: .+/g, "")
)

const debouncedSwap = useDebounceFn(onSwapTab, 0);
const showTabs =
showSingleTab ||
Expand Down Expand Up @@ -180,9 +187,9 @@ const Tabs = React.forwardRef<HTMLElement, TabsProps>(
<span className="logseq-tab-title">
{tab.originalName ?? tab.name}{" "}
{isBlock(tab) && (
<span title={tab.content}>
<span title={cleanBlockTitle(tab.content)}>
<strong className="text-blue-600"></strong>
<span className="mx-1">{tab.content}</span>
<span className="mx-1">{cleanBlockTitle(tab.content)}</span>
</span>
)}
</span>
Expand Down

0 comments on commit 430ec3d

Please sign in to comment.