-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from siyuan-note/dev
Update
- Loading branch information
Showing
11 changed files
with
103 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
## 0.1.8 | ||
|
||
* [Add protyleSlash to the plugin](https://github.com/siyuan-note/siyuan/issues/8599) | ||
* [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) | ||
|
||
## 0.1.6 | ||
|
||
* add `fetchPost` example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,50 @@ | ||
<script lang="ts"> | ||
import { onDestroy, onMount } from "svelte"; | ||
import { version } from "@/api"; | ||
import { showMessage } from "siyuan"; | ||
import Typo from "@/libs/b3-typography.svelte"; | ||
import { version, sql as query } from "@/api"; | ||
import { showMessage, fetchPost, Protyle } from "siyuan"; | ||
export let name: string; | ||
export let i18n: any; | ||
export let app; | ||
let time; | ||
let ver; | ||
let time: string = ""; | ||
let ver: string; | ||
let intv1 = setInterval(async () => { | ||
time = new Date(); | ||
}, 1000); | ||
let divProtyle: HTMLDivElement; | ||
let protyle: any; | ||
let blockID: string = ''; | ||
onMount(async () => { | ||
time = new Date(); | ||
ver = await version(); | ||
fetchPost("/api/system/currentTime", {}, (response) => { | ||
time = new Date(response.data).toString(); | ||
}); | ||
protyle = await initProtyle(); | ||
}); | ||
/** | ||
* You must call this function when the component is destroyed. | ||
*/ | ||
onDestroy(() => { | ||
showMessage("Hello panel closed"); | ||
clearInterval(intv1); | ||
protyle.destroy(); | ||
}); | ||
$: time_str = new Date(time).toLocaleTimeString(); | ||
async function initProtyle() { | ||
let sql = "SELECT * FROM blocks ORDER BY RANDOM () LIMIT 1;"; | ||
let blocks: Block[] = await query(sql); | ||
blockID = blocks[0].id; | ||
return new Protyle(app, divProtyle, { | ||
blockId: blockID | ||
}); | ||
} | ||
</script> | ||
|
||
<div id="hello"> | ||
<div class="fn__flex"> | ||
<div class="fn__flex-1"> | ||
<h2>Hello {name} v{ver}</h2> | ||
</div> | ||
<div class="fn__flex-1 b3-label__text __text-right"> | ||
{time_str} | ||
</div> | ||
<div class="b3-dialog__content"> | ||
<div>API demo:</div> | ||
<div class="fn__hr" /> | ||
<div class="plugin-sample__time"> | ||
System current time: <span id="time">{time}</span> | ||
</div> | ||
|
||
<Typo> | ||
<h2>Wellcome to plugin sample with vite & svelte</h2> | ||
<p>{@html i18n.makesure}</p> | ||
</Typo> | ||
|
||
<div class="fn__hr" /> | ||
<div class="fn__hr" /> | ||
<div>Protyle demo: id = {blockID}</div> | ||
<div class="fn__hr" /> | ||
<div id="protyle" style="height: 360px;" bind:this={divProtyle}/> | ||
</div> | ||
|
||
<style lang="scss"> | ||
#hello { | ||
margin: 20px; | ||
div { | ||
margin-bottom: 10px; | ||
} | ||
} | ||
.__text-right { | ||
text-align: right; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,26 @@ | ||
#helloPanel { | ||
border: 1px rgb(189, 119, 119) dashed; | ||
} | ||
|
||
.plugin-sample { | ||
&__custom-tab { | ||
background-color: var(--b3-theme-background); | ||
height: 100%; | ||
width: 100%; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
&__custom-dock { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
&__time { | ||
background: var(--b3-card-info-background); | ||
border-radius: 4px; | ||
padding: 2px 8px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters