Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zuoez02/siyuan-package-custom-block
SiYuan Custom Block helper based on HTML block.
https://github.com/zuoez02/siyuan-package-custom-block
Last synced: about 1 month ago
JSON representation
SiYuan Custom Block helper based on HTML block.
- Host: GitHub
- URL: https://github.com/zuoez02/siyuan-package-custom-block
- Owner: zuoez02
- Created: 2023-08-17T14:11:41.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-14T01:25:37.000Z (about 1 year ago)
- Last Synced: 2024-03-14T15:51:05.025Z (10 months ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Siyuan Package Custom Block
> SiYuan Custom Block helper based on HTML block.
## Core logic
Add a root node in HTML block as a root of morden app. Storage initial data in the `data-custom-bloc k-data` attribute of element, `data-type` for block type identifier of current plugin, `data-plugin` for different plugin.
## Generate Content Example
```kramdown
{: id="20230817220934-xfjsliu" updated="20237422934"}
```## Plugin Code Example
```javascript
const siyuan = require("siyuan");
const { CustomBlock, CustomBlockManager } = require('siyuan-package-custom-block');class CarouselBlock extends CustomBlock {
static type = "CarouselBlock";
static css = ".hello { color: red; }";onBlockMenu(e) {
// e.detail: BlocksElement, menu, protyle
}onMount(el, data, plugin) {
console.log("hello world");
el.insertAdjacentHTML(
"afterbegin",
`hello ${data.name}`
);
}
}module.exports = class P extends siyuan.Plugin {
onload() {
CustomBlockManager.init(this);
CustomBlockManager.load(CarouselBlock);
const content = CustomBlockManager.buildBlock(CarouselBlock.type, {
name: "123",
});
console.log(content);
navigator.clipboard.writeText(content);
}
};
```## Attention
Update block is not working, still work on it.