Skip to content

Commit

Permalink
添加英文文档
Browse files Browse the repository at this point in the history
  • Loading branch information
2234839 committed Jun 5, 2024
1 parent 34c750f commit 2b8bd4c
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 5 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# 思源表达式插件

[中文文档](./README.md) [English doc](./README_en.md)

[使用文档](#使用文档)

qq群:706761641 (心栈空间)
qq 群:706761641 (心栈空间)

### 同意以下约定后方可使用本产品

Expand Down Expand Up @@ -36,7 +38,7 @@ qq群:706761641 (心栈空间)

## 使用文档

给块添加自定义属性 expr ,值设置为合法 js 表达式,插件会使用 eval 对表达式进行求值,返回值将作为块内容以及自定义属性 expr-_value 的值。
给块添加自定义属性 expr ,值设置为合法 js 表达式,插件会使用 eval 对表达式进行求值,返回值将作为块内容以及自定义属性 expr-\_value 的值。

值如果为 Promise 会将 Promise 的结果作为块内容。

Expand All @@ -54,7 +56,7 @@ qq群:706761641 (心栈空间)

#### block

表达式可以直接输入 block 来获取表达式所在块的数据,其中以 `a_` 开头的为custom-expr的属性,其余均为块属性。
表达式可以直接输入 block 来获取表达式所在块的数据,其中以 `a_` 开头的为 custom-expr 的属性,其余均为块属性。

```js
const block = {
Expand Down
97 changes: 97 additions & 0 deletions README_en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
This is an AI-generated translation.

---

# SiYuan Expression Plugin

[Chinese Documentation](./README.md) [English Documentation](./README_en.md)

[Usage Documentation](#Usage Documentation)

QQ Group: 706761641 (XinZhan Space)

### You may use this product only after agreeing to the following terms

Trial Agreement:

You may try the product for any length of time, and after a month, if you find it useful, you will lose the trial qualification.

---

Paid Agreement:

You can use this product during the subscription period.

Situations that are considered as subscription: you have helped the author in any form, you have made a recognized contribution to society, or you are unable to pay.

Subscription amount: equivalent to 10 RMB, you can use any payment method, with no time limit (you can decide to take any payment measures at any time, but you can start using it now).

Subscription period: from the time of payment to the right to use for one hundred product updates or 365 days, whichever is longer in duration, and it is stackable. (That is, if I update more than a hundred times in a very short period, it will be calculated as one year)

[Pay through the Aifadian platform](https://afdian.net/@llej0)

It is not considered a violation of the payment agreement if you do not remember the above agreement.

---

Prohibition and Disclaimer Agreement:

It is prohibited to use this product for any illegal or disorderly activities.

The author is not responsible for any consequences arising from your use of this product.

## Usage Documentation

Add a custom attribute `expr` to a block, and set the value to a valid JavaScript expression. The plugin will use `eval` to evaluate the expression, and the returned value will be used as the block content and the value of the custom attribute `expr-_value`.

If the value is a Promise, the result of the Promise will be used as the block content.

### Automatic Evaluation

The plugin will continuously evaluate changes to blocks, but to avoid generating a large amount of computation and read/write operations, some optimizations have been made based on the block's `update` field. When the plugin is first launched, it will evaluate all expressions once, and after that, it will only evaluate the expressions of the blocks that have been updated.

Note! [Updating block attributes does not cause the block's `update` field to update](https://github.com/2234839/siyuan_expr/issues/1#issuecomment-2147809646), if you want to trigger the evaluation, you can manually modify the content of the block at will.

### Some special variables that can be directly referenced within the expression

#### expr

Plugin instance

#### block

The expression can directly input `block` to obtain the data of the block where the expression is located, where those starting with `a_` are attributes of `custom-expr`, and the rest are block attributes.

```js
const block = {
a_block_id: "Block ID",
a_box: "Notebook ID",
a_id: "Attribute ID",
a_name: "custom-expr",
a_path: "/Document ID/Document ID/Document ID.sy",
a_root_id: "Document ID",
a_type: "b",
a_value: "Expression script",
alias: "",
box: "Notebook ID",
content: "Block content",
created: "20240605121837",
fcontent: "",
hash: "f570917",
hpath: "Readable path",
ial: "Block attributes",
id: "Block ID",
length: 16,
markdown: "Block content markdown",
memo: "",
name: "",
parent_id: "Parent block ID",
path: "/Document ID/Document ID/Document ID.sy",
root_id: "Document ID",
sort: 10,
subtype: "",
tag: "",
type: "p",
updated: "20240605134312"
}
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "expr",
"version": "0.0.5",
"version": "0.0.6",
"type": "module",
"description": "",
"repository": "https://github.com/2234839/siyuan_expr",
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"zh_CN": "为 OceanPress 提供更多能力"
},
"readme": {
"en_US": "README.md",
"en_US": "README_en.md",
"zh_CN": "README.md"
},
"funding": {
Expand Down

0 comments on commit 2b8bd4c

Please sign in to comment.