Skip to content

Commit

Permalink
feat: Add toolbar icon functionality
Browse files Browse the repository at this point in the history
Other
>fix bug
  • Loading branch information
YU000jp committed Apr 18, 2023
1 parent e198f8b commit 6f0fe90
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import '@logseq/libs'; //https://plugins-doc.logseq.com/
import { BlockEntity, PageEntity, SettingSchemaDesc } from "@logseq/libs/dist/LSPlugin.user";

let graphName = "";//For command pallet

//main
const main = () => {


//check current graph
let graphName = "";//For command pallet

logseq.App.getCurrentGraph().then((graph) => {
if (graph) {
graphName = graph.name;
Expand Down Expand Up @@ -66,7 +67,7 @@ const main = () => {
divSticky.style.visibility = "hidden";
}
}

}
});
});
Expand All @@ -79,20 +80,13 @@ const main = () => {
setCSSclass();


//command pallet
logseq.App.registerCommandPalette({
key: "sticky-text",
label: "sticky-popup: Open sticky-text popup",
}, async () => {
mainStickyText(graphName);
});
logseq.App.registerCommandPalette({
key: "sticky-calendar",
label: "sticky-popup: Open sticky-calendar popup",
}, async () => {
mainStickyCalendar();
//toolbar-item
logseq.App.registerUIItem("toolbar", {
key: 'sticky-popup-open',
template: `<div data-on-click="openFromToolbar" style="font-size:20px">📌</div>`,
});


//main support
parent.document.body.classList.add('is-plugin-sticky-popup-enabled');
logseq.beforeunload(async () => {
Expand Down Expand Up @@ -144,7 +138,7 @@ const main = () => {
body:not(.sp-textZIndex) div#sticky-popup--sticky,
body:not(.sp-calendarZIndex) div#sticky-popup--sticky-calendar {
z-index: 1!important;
}import { *asEta } from 'eta';
}
nav[aria-label="Navigation menu"]{ /* navigation menuのz-indexを変更 */
z-index: var(--ls-z-index-level-5);
Expand Down Expand Up @@ -472,6 +466,18 @@ const model = {
stickyPosition("sticky-popup--sticky");
logseq.Editor.scrollToBlockInPage(logseq.settings?.screenPage, logseq.settings?.screenUuid);
},
openFromToolbar() {
logseq.updateSettings({
stickyLock: false,
});
if (logseq.settings?.graphLock === false && logseq.settings?.currentGraph !== graphName) {
logseq.UI.showMsg("Sticky Text popup is locked for the graph");
logseq.showSettingsUI();
} else {
mainStickyText(graphName);
}
mainStickyCalendar();
},
};
//end model

Expand Down

0 comments on commit 6f0fe90

Please sign in to comment.