Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Jun 23, 2023
1 parent 1c8dc96 commit 04fc545
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.8

* [Add plugin API protyle ](https://github.com/siyuan-note/siyuan/issues/8445)

## 0.1.7

* [Support build js and json](https://github.com/siyuan-note/plugin-sample/pull/8)
Expand Down
6 changes: 6 additions & 0 deletions src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@
justify-content: center;
align-items: center;
}

&__time {
background: var(--b3-card-info-background);
border-radius: 4px;
padding: 2px 8px;
}
}
24 changes: 19 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import {
getFrontend,
getBackend,
IModel,
Setting, fetchPost
Setting,
fetchPost,
Protyle
} from "siyuan";
import "./index.scss";

Expand Down Expand Up @@ -213,12 +215,24 @@ export default class PluginSample extends Plugin {
private showDialog() {
const dialog = new Dialog({
title: "Info",
content: '<div class="b3-dialog__content">System current time: <span id="time"></span></div>',
width: this.isMobile ? "92vw" : "520px",
content: `<div class="b3-dialog__content">
<div>API demo:</div>
<div class="fn__hr"></div>
<div class="plugin-sample__time">System current time: <span id="time"></span></div>
<div class="fn__hr"></div>
<div class="fn__hr"></div>
<div>Protyle demo:</div>
<div class="fn__hr"></div>
<div id="protyle" style="height: 360px;"></div>
</div>`,
width: this.isMobile ? "92vw" : "560px",
height: "540px",
});
new Protyle(this.app, dialog.element.querySelector("#protyle"), {
blockId: "20200812220555-lj3enxa",
})
fetchPost("/api/system/currentTime", {}, (response) => {
dialog.element.querySelector("#time").innerHTML = new Date(response.data).toString()

})
}

Expand All @@ -228,7 +242,7 @@ export default class PluginSample extends Plugin {
});
menu.addItem({
icon: "iconInfo",
label: "Dialog",
label: "Dialog(open help first)",
accelerator: this.commands[0].customHotkey,
click: () => {
this.showDialog()
Expand Down

0 comments on commit 04fc545

Please sign in to comment.