Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Commit

Permalink
✨ 内容块动态查询嵌入 siyuan-note/siyuan#48
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Nov 17, 2020
1 parent 771ccdd commit cf0991a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 30 deletions.
18 changes: 9 additions & 9 deletions General Operations/Search_20200924100839-5oe1j4n.sy.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ For SQL search, use the built-in SQLite database (system temporary folder/siyuan

This table is used to store content block data.

| Field | Type | Description |
| -: | :-: | - |
| id | text | Self-incrementing primary key |
| block_id | text | Content block ID |
| box | text | Notebook name |
| path | text | Path of the document where the content block is located |
| tree_id | text | Abstract Syntax Tree ID, as the same as root node ID |
| content | text | Content block Markdown |
| type | text | Content block type |
| Field | Type | Description |
| -------: | :--: | ------------------------------------------------------- |
| id | text | Self-incrementing primary key |
| block_id | text | Content block ID |
| box | text | Notebook name |
| path | text | Path of the document where the content block is located |
| tree_id | text | Abstract Syntax Tree ID, as the same as root node ID |
| content | text | Content block Markdown |
| type | text | Content block type |

Example:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ The forward link is included in the content of the current block, which we can s

Entering `((` will trigger the content block quotation search, continue to enter as the search keyword, use the up and down keys to select in the search results and press Enter to complete the content block quotation. Please note that cross-notebook references are not supported.

The complete syntax of the content block quote is: `((id "text"))`, where the `id` is like: `202008250000-a1b2c3d`, consisting of time and 7 random characters, the content block id is when the content block is created It will be automatically generated; the following `text` is the custom anchor text for the content block in the quote. After the content block quote is established, hover the mouse over the anchor text and a preview floating layer will pop up to show the quoted content block.
The complete syntax of the content block quote is: `((id "text"))`, where the `id` is like: `202008250000-a1b2c3d`, consisting of time and 7 random characters, the content block id is when the content block is created It will be automatically generated; the following `text` is the custom anchor text for the content block in the quote. After the content block quote is established, hover the mouse over the anchor text and a preview floating layer will pop up to show the quoted content block. #Content block/Reference#

### Content block embedding
{: id="20200924101312-385dey5"}

Enter `!((` at the beginning of a new line and it will trigger the content block embedded search. Just like the content block reference, you can complete the embedding by selecting the content block you need in the search results. It also supports custom `text` anchor text After the embedding operation is completed, the embedded content block will be displayed directly below.
Enter `!((` at the beginning of a new line and it will trigger the content block embedded search. Just like the content block reference, you can complete the embedding by selecting the content block you need in the search results. It also supports custom `text` anchor text After the embedding operation is completed, the embedded content block will be displayed directly below. #Content block/Embed#

It is worth noting that the content block embedding itself is also a kind of content block, which means that we cannot use the content block embedding in the middle of a sentence, and can only embed at the beginning of a new line. The following is an example of content block embedding:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,13 @@ It needs to be used on its own line. The script syntax used is SQL. For details,
```sql
!{{ SELECT * FROM blocks WHERE (content LIKE '%content block%' AND content LIKE '%embed%') AND type ='NodeHeading' ORDER BY block_id DESC LIMIT 4 }}
```

Let's actually run it to see the effect.

The query contains paragraph blocks of both `In SiYuan` and `core concept` text, and excludes the current document (otherwise the paragraph block will also be included in the result set, because the current paragraph also contains these two texts. The following case is similar):

!{{SELECT * FROM blocks WHERE (content LIKE '%In SiYuan%' AND content LIKE '%core concept%') AND path NOT LIKE '%Content block dynamic query%'}}

Query paragraph blocks that contain both `#Content block/Embed#` tags and `#Content block/Reference#`:

!{{SELECT * FROM blocks WHERE (content LIKE '%#Content block/Embed#%' OR content LIKE '%#Content block/Reference#%') AND path NOT LIKE '%Content block dynamic query%'}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

Hover the mouse over the content block and the corresponding icon will appear on the left side of the content block. For format usage, please refer to ((20200924093441-ft2rhps "Markdown Complete Demo")).

| Icon | Type | ((20200925102736-x94e40g "Meta Type")) |
| -------------------------------------------- | -------------------- | -------------------------------------- |
| ![paragraph](assets/paragraph.svg) | Paragraph block | Leaf block |
| ![heading](assets/heading.svg) | Heading block | Leaf block |
| ![math-block](assets/math-block.svg) | Math Formula block | Leaf block |
| ![code-block](assets/code-block.svg) | Code block | Leaf block |
| ![table](assets/table.svg) | Table block | Leaf block |
| ![unordered-list](assets/unordered-list.svg) | Unordered List block | Container block |
| ![ordered-list](assets/ordered-list.svg) | Ordered List block | Container block |
| ![task-list](assets/task-list.svg) | To-do list block | Container block |
| ![list-item](assets/list-item.svg) | List Item block | Container block |
| ![blockquote](assets/blockquote.svg) | Blockquote block | Container block |
| ![doc](assets/doc.svg) | Document block | Container block |
| Icon | Type | ((20200925102736-x94e40g "Meta Type")) |
| - | - | - |
| ![paragraph](assets/paragraph.svg) | Paragraph block | Leaf block |
| ![heading](assets/heading.svg) | Heading block | Leaf block |
| ![math-block](assets/math-block.svg) | Math Formula block | Leaf block |
| ![code-block](assets/code-block.svg) | Code block | Leaf block |
| ![table](assets/table.svg) | Table block | Leaf block |
| ![unordered-list](assets/unordered-list.svg) | Unordered List block | Container block |
| ![ordered-list](assets/ordered-list.svg) | Ordered List block | Container block |
| ![task-list](assets/task-list.svg) | To-do list block | Container block |
| ![list-item](assets/list-item.svg) | List Item block | Container block |
| ![blockquote](assets/blockquote.svg) | Blockquote block | Container block |
| ![doc](assets/doc.svg) | Document block | Container block |

## Details of content block types

Below we introduce the details of these content block types.
Below we introduce the details of these content block types. #Content block/Type#

### Paragraph block

Expand Down Expand Up @@ -58,8 +58,8 @@ function hello() {}

![math-block](assets/table.svg)

| Column 1 | Column 2 |
| ------------------ | ------------------ |
| Column 1 | Column 2 |
| - | - |
| Row One Column One | Row One Column Two |
| Row Two Column One | Row Two Column Two |

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## The most commonly used content block is a paragraph block

"Content block" refers to a piece of content, and the most common content block is the familiar paragraph (Paragraph).
"#Content block#" refers to a piece of content, and the most common content block is the familiar paragraph (Paragraph).

In traditional Chinese typesetting, paragraphs are usually represented by indentation (two spaces) at the beginning of the paragraph. With the development of the Internet, it has gradually affected the representation of paragraphs. The most commonly used method is to increase the line spacing between paragraphs, or use blank lines to separate paragraphs.

Expand All @@ -10,10 +10,10 @@ In Markdown typesetting, paragraphs are separated by blank lines. This also coin

In actual use, it is not enough to rely on paragraph typesetting. It is often necessary to use Heading, List, Table, Blockquote, etc. to enrich our typesetting. These typographic styles are not only visually different, but more importantly, they express the semantics of the content to a certain extent. For example, when we see an unordered list, we can know that each list item is in an indiscriminate level relationship, while when we see an ordered list, the opposite is true.

Therefore, there are many content blocks ((20200924101225-k254i8g "types")), and different types of content blocks are defined by Markdown syntax. In other words, when users use Markdown, content blocks are formed **naturally**.
Therefore, there are many content blocks ((20200924101225-k254i8g "types")), and different types of content blocks are defined by Markdown syntax. In other words, when users use Markdown, content blocks are formed **naturally**. #Content block/Type#

## Combined content blocks

A document is a combination of some content blocks, and the content block is the basic unit. This is like Lego bricks, which can be combined using different basic modules. It is worth noting that the document itself is also a kind of content block. More precisely, the three content blocks of document block, list block, and block reference block are container blocks, and they can contain any other types of content blocks.
A document is a combination of some content blocks, and the content block is the basic unit. This is like Lego bricks, which can be combined using different basic modules. It is worth noting that the document itself is also a kind of content block. More precisely, the three content blocks of document block, list block, and block reference block are container blocks, and they can contain any other types of content blocks. #Content block/Combine#

At this point, we have been able to use content blocks to describe all content, so that we can use uniform usage to ((20200924101256-f8b1sbi "link content block")) . Logically, there is no page concept, which reduces unnecessary burdens in use and allows users to focus on the content block.

0 comments on commit cf0991a

Please sign in to comment.