Skip to content

Commit

Permalink
feat(Add): toolbar button for opening the plugin settings
Browse files Browse the repository at this point in the history
  • Loading branch information
YU000jp committed Jan 20, 2024
1 parent 01569f4 commit f1ef1e2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "@logseq/libs"
import { BlockEntity, LSPluginBaseInfo, PageEntity } from "@logseq/libs/dist/LSPlugin.user"
import { setup as l10nSetup } from "logseq-l10n"; //https://github.com/sethyuan/logseq-l10n
import { setup as l10nSetup, t } from "logseq-l10n" //https://github.com/sethyuan/logseq-l10n
import fileBottom from './bottom.css?inline'
import { hierarchyForFirstLevelOnly, hierarchyRemoveBeginningLevel } from "./hierarchyList"
import { provideStyle, removeElementClass, removeElementId, removeProvideStyle, titleCollapsedRegisterEvent } from "./lib"
Expand Down Expand Up @@ -81,6 +81,17 @@ const main = async () => {
//設定変更のコールバック
onSettingsChanged()

//ツールバーに設定画面を開くボタンを追加
logseq.App.registerUIItem('toolbar', {
key: 'toolbarPageTagsAndHierarchy',
template: `<div><a class="button icon" data-on-click="toolbarPageTagsAndHierarchy" style="font-size:15px;color:#1f9ee1;opacity:unset" title="Page-tags and Hierarchy: ${t("plugin settings")}">🏷️</a></div>`,
})
//ツールバーボタンのクリックイベント
logseq.provideModel({
toolbarPageTagsAndHierarchy: () => logseq.showSettingsUI(),
})

//プラグインオフの場合はページ名の階層リンクを削除する
logseq.beforeunload(async () => {
const element = parent.document.getElementById("hierarchyLinks") as HTMLSpanElement | null
if (element) element.remove()
Expand Down

0 comments on commit f1ef1e2

Please sign in to comment.