@scrider/formatter 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -98,16 +98,37 @@ normalizeDelta(delta) // Normalize operations
|
|
|
98
98
|
|
|
99
99
|
### Block Handlers
|
|
100
100
|
|
|
101
|
+
Block handlers process complex block embeds (tables, alerts, footnotes, etc.) stored in Delta as `{ insert: { block: { type, ... } } }`. Pass them to conversion functions via `createDefaultBlockHandlers()` or register individually:
|
|
102
|
+
|
|
101
103
|
```typescript
|
|
102
104
|
import {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
boxBlockHandler,
|
|
105
|
+
createDefaultBlockHandlers,
|
|
106
|
+
deltaToHtml,
|
|
107
|
+
htmlToDelta,
|
|
108
|
+
createDefaultRegistry,
|
|
108
109
|
} from '@scrider/formatter';
|
|
110
|
+
|
|
111
|
+
const registry = createDefaultRegistry();
|
|
112
|
+
const blockHandlers = createDefaultBlockHandlers();
|
|
113
|
+
|
|
114
|
+
// Delta with an alert block → HTML
|
|
115
|
+
const html = deltaToHtml(delta, { registry, blockHandlers });
|
|
116
|
+
// → '<div class="markdown-alert markdown-alert-note">...</div>'
|
|
117
|
+
|
|
118
|
+
// HTML with block embeds → Delta
|
|
119
|
+
const delta = htmlToDelta(html, { registry, blockHandlers });
|
|
109
120
|
```
|
|
110
121
|
|
|
122
|
+
Built-in handlers:
|
|
123
|
+
|
|
124
|
+
| Handler | Block type | Description |
|
|
125
|
+
|---------|-----------|-------------|
|
|
126
|
+
| `tableBlockHandler` | `table` | Extended tables with colspan/rowspan, nested Delta cells |
|
|
127
|
+
| `alertBlockHandler` | `alert` | GitHub-style alerts (`[!NOTE]`, `[!TIP]`, `[!WARNING]`, etc.) |
|
|
128
|
+
| `footnotesBlockHandler` | `footnotes` | Footnotes with `[^id]` references |
|
|
129
|
+
| `columnsBlockHandler` | `columns` | Multi-column layout (CSS Grid) |
|
|
130
|
+
| `boxBlockHandler` | `box` | Inline-box with float/overflow |
|
|
131
|
+
|
|
111
132
|
## Ecosystem
|
|
112
133
|
|
|
113
134
|
```
|