Initial Upload
Some checks failed
Create Release on Tag Push / build (push) Has been cancelled

This commit is contained in:
MassiveBox 2025-03-31 19:14:17 +02:00
parent 777f31761c
commit eaca7fc192
Signed by: massivebox
GPG key ID: 9B74D3A59181947D
20 changed files with 469 additions and 1718 deletions

57
src/helper.ts Normal file
View file

@ -0,0 +1,57 @@
import { Plugin } from 'siyuan';
import {DATA_PATH, EMBED_PATH} from "@/const";
const drawIcon: string = `
<symbol id="iconDraw" viewBox="0 0 28 28">
<path clip-rule="evenodd" d="M26.4097 9.61208C27.196 8.8358 27.1969 7.57578 26.4117 6.79842L21.1441 1.58305C20.3597 0.806412 19.0875 0.805538 18.302 1.5811L3.55214 16.1442C3.15754 16.5338 2.87982 17.024 2.74985 17.5603L1.05726 24.5451C0.697341 26.0304 2.09375 27.3461 3.57566 26.918L10.3372 24.9646C10.8224 24.8244 11.2642 24.5658 11.622 24.2125L26.4097 9.61208ZM20.4642 12.6725L10.2019 22.8047C10.0827 22.9225 9.9354 23.0087 9.77366 23.0554L4.17079 24.6741C3.65448 24.8232 3.16963 24.359 3.2962 23.8367L4.70476 18.024C4.74809 17.8453 4.84066 17.6819 4.97219 17.552L15.195 7.45865L20.4642 12.6725ZM21.8871 11.2676L16.618 6.05372L19.0185 3.68356C19.4084 3.29865 20.0354 3.29908 20.4247 3.68454L24.271 7.49266C24.6666 7.88436 24.6661 8.52374 24.27 8.91488L21.8871 11.2676Z" fill-rule="evenodd"/>
</symbol>
`;
export function loadIcons(p: Plugin) {
const icons = drawIcon;
p.addIcons(icons);
}
export function getMenuHTML(icon: string, text: string): string {
return `
<div class="b3-list-item__first">
<svg class="b3-list-item__graphic">
<use xlink:href="#${icon}"></use>
</svg>
<span class="b3-list-item__text">${text}</span>
</div>
`;
}
export function generateSiyuanId() {
const now = new Date();
const year = now.getFullYear().toString();
const month = (now.getMonth() + 1).toString().padStart(2, '0');
const day = now.getDate().toString().padStart(2, '0');
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
const seconds = now.getSeconds().toString().padStart(2, '0');
const timestamp = `${year}${month}${day}${hours}${minutes}${seconds}`;
const characters = 'abcdefghijklmnopqrstuvwxyz';
let random = '';
for (let i = 0; i < 7; i++) {
random += characters.charAt(Math.floor(Math.random() * characters.length));
}
return `${timestamp}-${random}`;
}
export function idToPath(id: string) {
return DATA_PATH + '/' + id + '.svg';
}
// [Edit](siyuan://plugins/siyuan-jsdraw-pluginwhiteboard/?icon=iconDraw&title=Drawing&data={"id":"${id}"})
// ![Drawing](assets/${id}.svg)
export function getPreviewHTML(id: string): string {
return `
<iframe src="${EMBED_PATH + id}&antiCache=0"></iframe>
`
}