Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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.