doc: update daletl specification refactor all typescript code

This commit is contained in:
Artemy Egorov 2024-07-28 20:21:22 +03:00
parent 90db2e6c73
commit 9d8220f726
13 changed files with 99 additions and 396 deletions

View file

@ -1,85 +1,39 @@
# Daletl specification for Dalet v1.0-preview
## Data format
## Daletl
Daletl is data representation for Dalet interfaces. [DaletPack](./daletpack.md) serializes/deserializes into Daletl.
Daletl must be serialized as [DaletPack](./daletpack.md). All data transfer between server and client is done in this format.
### Root
Daletl root is array of tags. For convenience, we will use the json5 representation of the data.
Daletl root is array of tags. For convenience, we will use the typescript notation.
```json5
[]
```typescript
type Root = Tag[];
```
### Tag
All tags specification is in [Tags](./tags.md).
Each tag may be one of four types:
#### Data Representation
##### As array of 1-3 elements
1. Tag id
2. Tag body (optional if argument is null)
3. Tag argument (optional)
Tag id is integer number.
Body can be only a string, null, array of tags or tag (equals to array of tags with 1 tag).
Argument can be number or string.
###### Heading example
```json5
[1, "This is heading", 1]
```typescript
interface Tag {
id: number;
body: Tag[] | null;
argument: string | number | null;
}
```
###### Unordered list example
### Example
```json5
[
4,
[
[0, "Item 1"],
[0, "Item 2"],
],
]
```
##### As string
String becomes element tag.
```json5
"Element"
```
equals to
```json5
[0, "Element"]
```
##### As array of tags
If array not started with a number. The implication is that this turns into an “element” tag
```json5
["Element", [1, "Heading"]]
```
equals to
```json5
[
0,
[
[0, "Element"],
[1, "Heading"],
],
]
```typescript
const root: Root = [
{
id: 1,
body: "I am Heading with level 1",
argument: 1,
},
];
```

View file

@ -19,12 +19,6 @@ el: { h[1]: I am first level heading }
Element also used if no tag is specified.
```
**Daletl example (json5 representation)**:
```json5
"I am Element"
```
## 1. Heading
| Property | Description |
@ -46,12 +40,6 @@ h[1]: Dalet
h[3]: Low level
```
**Daletl example (json5 representation)**:
```json5
[1, "Dalet", 1]
```
## 2. Paragraph
| Property | Description |
@ -69,12 +57,6 @@ Paragraph is used for text formatting.
p: This is a paragraph
```
**Daletl example (json5 representation)**:
```json5
[2, "This is a paragraph"]
```
## 3. Line break
| Property | Description |
@ -92,12 +74,6 @@ Line break is used to insert a line break into the text.
br
```
**Daletl example (json5 representation)**:
```json5
3
```
## 4. Unordered list
| Property | Description |
@ -118,12 +94,6 @@ ul: {
}
```
**Daletl example (json5 representation)**:
```json5
[4, ["Item 1", "Item 2"]]
```
## 5. Ordered list
| Property | Description |
@ -145,12 +115,6 @@ ol: {
}
```
**Daletl example (json5 representation)**:
```json5
[5, ["Item", "Item", "Item"]]
```
## 6. Row
| Property | Description |
@ -181,13 +145,6 @@ Argument converts to numbers in daletl.
start -> 0
end -> 1
**Daletl example (json5 representation)**:
```json5
[6, ["Left", "Right"]]
[6, ["Left", "Right"], 0]
```
## 7. Link
| Property | Description |
@ -205,12 +162,6 @@ Link to other sites. On click the link opens in new tab.
link[https://example.com]: I am Link
```
**Daletl example (json5 representation)**:
```json5
[7, "I am Link", "https://example.com"]
```
## 8. Navlink
| Property | Description |
@ -228,12 +179,6 @@ Link to the same site. On click the link opens in current tab.
navlink[/specification]: I am Navlink
```
**Daletl example (json5 representation)**:
```json5
[8, "I am Navlink", "/specification"]
```
## 9. Button
| Property | Description |
@ -251,12 +196,6 @@ Same as link, but with button style.
btn[https://example.com]: I am Button
```
**Daletl example (json5 representation)**:
```json5
[9, "I am Button", "https://example.com"]
```
## 10. NavButton
| Property | Description |
@ -274,12 +213,6 @@ Same as navlink, but with button style.
navbtn[https://example.com]: I am NavButton
```
**Daletl example (json5 representation)**:
```json5
[10, "I am NavButton", "https://example.com"]
```
## 11. Image
| Property | Description |
@ -297,12 +230,6 @@ Displays an image.
img[/dalet.png]
```
**Daletl example (json5 representation)**:
```json5
[11, null, "/dalet.png"]
```
## 12. Table
| Property | Description |
@ -323,30 +250,6 @@ table: {
}
```
**Daletl example (json5 representation)**:
```json5
[
12,
[
[
13,
[
[0, "Name"],
[0, "Age"],
],
],
[
13,
[
[0, "Elon"],
[0, "53"],
],
],
],
]
```
## 13. Table Column
| Property | Description |
@ -367,18 +270,6 @@ tcol: {
}
```
**Daletl example (json5 representation)**:
```json5
[
13,
[
[0, "Name"],
[0, "Age"],
],
]
```
## 14. Table Primary Column
| Property | Description |
@ -399,18 +290,6 @@ tpcol: {
}
```
**Daletl example (json5 representation)**:
```json5
[
14,
[
[0, "Name"],
[0, "Age"],
],
]
```
## 15. Horizontal rule
| Property | Description |
@ -428,12 +307,6 @@ Creates a horizontal rule.
hr
```
**Daletl example (json5 representation)**:
```json5
15
```
## 16. Bold
| Property | Description |
@ -451,12 +324,6 @@ Creates **bold** text.
b: I am Bold
```
**Daletl example (json5 representation)**:
```json5
[16, "I am Bold"]
```
## 17. Italic
| Property | Description |
@ -474,12 +341,6 @@ Creates _italic_ text.
i: I am Italic
```
**Daletl example (json5 representation)**:
```json5
[17, "I am Italic"]
```
## 18. Blockquote
| Property | Description |
@ -497,12 +358,6 @@ Creates a blockquote.
bq: I am Blockquote
```
**Daletl example (json5 representation)**:
```json5
[18, "I am Blockquote"]
```
## 19. Footnote Link
| Property | Description |
@ -520,12 +375,6 @@ Link to footnote.
footlnk[1]
```
**Daletl example (json5 representation)**:
```json5
[19, null, 1]
```
## 20. Footnote
| Property | Description |
@ -543,12 +392,6 @@ Creates footnote.
footn[1]: I am Footnote
```
**Daletl example (json5 representation)**:
```json5
[20, "I am Footnote", 1]
```
## 21. Anchor
| Property | Description |
@ -566,12 +409,6 @@ Creates anchor. Like `<a href="#argument"></a>` in HTML.
a[0]
```
**Daletl example (json5 representation)**:
```json5
[21, null, 0]
```
## 22. Strikethrough
| Property | Description |
@ -589,12 +426,6 @@ Creates ~~strikethrough~~ text.
s: I am Strikethrough
```
**Daletl example (json5 representation)**:
```json5
[22, "I am Strikethrough"]
```
## 23. Superscript
| Property | Description |
@ -612,12 +443,6 @@ Creates ^superscript^ text.
sup: I am Superscript
```
**Daletl example (json5 representation)**:
```json5
[23, "I am Superscript"]
```
## 24. Subscript
| Property | Description |
@ -635,12 +460,6 @@ Creates ~subscript~ text.
sub: I am Subscript
```
**Daletl example (json5 representation)**:
```json5
[24, "I am Subscript"]
```
## 25. Disclosure
| Property | Description |
@ -658,12 +477,6 @@ Creates disclosure element.
disc[Click to expand]: I am Disclosure
```
**Daletl example (json5 representation)**:
```json5
[25, "I am Disclosure", "Click to expand"]
```
## 26. Block
| Property | Description |
@ -686,12 +499,6 @@ Argument converts to numbers in daletl.
start -> 0
end -> 1
**Daletl example (json5 representation)**:
```json5
[26, "I am Block", 0]
```
## 27. Carousel
| Property | Description |
@ -711,9 +518,3 @@ carousel: {
Example 2,
}
```
**Daletl example (json5 representation)**:
```json5
[27, ["Example 1", "Example 2"]]
```