@haklex/rich-headless 0.0.65 → 0.0.66
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 +86 -0
- package/dist/transformers.d.ts.map +1 -1
- package/dist/transformers.mjs +4 -4
- package/package.json +6 -1
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# @haklex/rich-headless
|
|
2
|
+
|
|
3
|
+
Zero-React headless Lexical node registry for server-side parsing. Convert Lexical editor state JSON to Markdown without any browser or React dependency.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @haklex/rich-headless lexical
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Peer Dependencies
|
|
12
|
+
|
|
13
|
+
| Package | Version |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| `lexical` | `^0.41.0` |
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { createHeadlessEditor } from '@lexical/headless'
|
|
21
|
+
import { allHeadlessNodes, $toMarkdown } from '@haklex/rich-headless'
|
|
22
|
+
|
|
23
|
+
const editor = createHeadlessEditor({ nodes: allHeadlessNodes })
|
|
24
|
+
editor.setEditorState(editor.parseEditorState(jsonString))
|
|
25
|
+
editor.read(() => {
|
|
26
|
+
const markdown = $toMarkdown()
|
|
27
|
+
})
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Exports
|
|
31
|
+
|
|
32
|
+
### Node Registries
|
|
33
|
+
|
|
34
|
+
| Export | Description |
|
|
35
|
+
| --- | --- |
|
|
36
|
+
| `allHeadlessNodes` | All headless nodes (builtin + custom) |
|
|
37
|
+
| `builtinNodes` | Lexical builtin nodes (Heading, Quote, List, Link, Table, Code, HorizontalRule) |
|
|
38
|
+
| `customHeadlessNodes` | Custom headless nodes only |
|
|
39
|
+
|
|
40
|
+
### Node Classes
|
|
41
|
+
|
|
42
|
+
| Export | Description |
|
|
43
|
+
| --- | --- |
|
|
44
|
+
| `SpoilerNode` | Spoiler/hidden text (inline) |
|
|
45
|
+
| `RubyNode` | Ruby annotation (inline) |
|
|
46
|
+
| `DetailsNode` | Collapsible details block |
|
|
47
|
+
| `ImageNode` | Image |
|
|
48
|
+
| `VideoNode` | Video |
|
|
49
|
+
| `LinkCardNode` | Rich link card |
|
|
50
|
+
| `KaTeXInlineNode` | Inline KaTeX equation |
|
|
51
|
+
| `KaTeXBlockNode` | Block KaTeX equation |
|
|
52
|
+
| `MermaidNode` | Mermaid diagram |
|
|
53
|
+
| `MentionNode` | User mention (inline) |
|
|
54
|
+
| `CodeBlockNode` | Code block with language |
|
|
55
|
+
| `FootnoteNode` | Footnote reference (inline) |
|
|
56
|
+
| `FootnoteSectionNode` | Footnote definitions section |
|
|
57
|
+
| `EmbedNode` | Embedded content (iframe) |
|
|
58
|
+
| `CodeSnippetNode` | Multi-file code snippet |
|
|
59
|
+
| `GalleryNode` | Image gallery |
|
|
60
|
+
| `ExcalidrawNode` | Excalidraw drawing |
|
|
61
|
+
| `BannerNode` | Banner/callout with nested content |
|
|
62
|
+
| `AlertQuoteNode` | GitHub-style alert quote with nested content |
|
|
63
|
+
| `NestedDocNode` | Nested document with nested content |
|
|
64
|
+
| `GridContainerNode` | Grid layout container with cells |
|
|
65
|
+
|
|
66
|
+
### Markdown Conversion
|
|
67
|
+
|
|
68
|
+
| Export | Description |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| `$toMarkdown()` | Convert the current editor state to Markdown (call inside `editor.read()`) |
|
|
71
|
+
| `allHeadlessTransformers` | All Lexical-to-Markdown transformers |
|
|
72
|
+
|
|
73
|
+
### Sub-path Exports
|
|
74
|
+
|
|
75
|
+
| Import Path | Description |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| `@haklex/rich-headless` | All nodes, registries, and `$toMarkdown` |
|
|
78
|
+
| `@haklex/rich-headless/transformers` | Transformers only |
|
|
79
|
+
|
|
80
|
+
## Part of Haklex
|
|
81
|
+
|
|
82
|
+
This package is part of the [Haklex](../../README.md) rich editor ecosystem.
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../src/transformers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAE1B,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../src/transformers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAE1B,MAAM,mBAAmB,CAAC;AAyC3B,eAAO,MAAM,mBAAmB,EAAE,oBAQjC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,oBAajC,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,oBASlC,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,oBAStC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,oBAc9B,CAAC;AAIF,eAAO,MAAM,kBAAkB,EAAE,qBAIhC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,qBAIrC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,qBAInC,CAAC;AAIF,eAAO,MAAM,4BAA4B,EAAE,kBAY1C,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,kBAiBnC,CAAC;AAUF,eAAO,MAAM,qBAAqB,EAAE,kBAWnC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,oBASrC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,kBAWrC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,kBAcrC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,kBAWzC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,kBAUzC,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,kBAWvC,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,kBAS1C,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE,kBAW9C,CAAC;AAEF,eAAO,MAAM,iCAAiC,EAAE,kBAM/C,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,kBAuBrC,CAAC;AAIF,eAAO,MAAM,8BAA8B,EAAE,kBAsB5C,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,kBAMrC,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,kBAUvC,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,kBAS1C,CAAC;AAIF,eAAO,MAAM,uBAAuB,2CA+BnC,CAAC;AAEF,sEAAsE;AACtE,wBAAgB,WAAW,IAAI,MAAM,CAEpC"}
|
package/dist/transformers.mjs
CHANGED
|
@@ -62,8 +62,8 @@ const FOOTNOTE_TRANSFORMER = {
|
|
|
62
62
|
const KATEX_INLINE_TRANSFORMER = {
|
|
63
63
|
dependencies: [],
|
|
64
64
|
export: (node) => node.getType() === "katex-inline" ? `$${node.__equation ?? ""}$` : null,
|
|
65
|
-
importRegExp: /\$([
|
|
66
|
-
regExp: /\$([
|
|
65
|
+
importRegExp: /\$([^\n$]+)\$/,
|
|
66
|
+
regExp: /\$([^\n$]+)\$$/,
|
|
67
67
|
replace: NOOP,
|
|
68
68
|
trigger: "$",
|
|
69
69
|
type: "text-match"
|
|
@@ -77,8 +77,8 @@ const RUBY_TRANSFORMER = {
|
|
|
77
77
|
if (!reading) return base;
|
|
78
78
|
return `<ruby>${base}<rt>${reading}</rt></ruby>`;
|
|
79
79
|
},
|
|
80
|
-
importRegExp: /<ruby
|
|
81
|
-
regExp: /<ruby
|
|
80
|
+
importRegExp: /<ruby>([^<]*)<rt>([^<]*)<\/rt>(?:<rp>[^<]*<\/rp>)*<\/ruby>/i,
|
|
81
|
+
regExp: /<ruby>([^<]*)<rt>([^<]*)<\/rt>(?:<rp>[^<]*<\/rp>)*<\/ruby>$/i,
|
|
82
82
|
replace: NOOP,
|
|
83
83
|
trigger: ">",
|
|
84
84
|
type: "text-match"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haklex/rich-headless",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.66",
|
|
5
5
|
"description": "Headless Lexical node registry for server-side parsing (no React)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"exports": {
|
|
@@ -39,6 +39,11 @@
|
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/Innei/haklex.git",
|
|
45
|
+
"directory": "packages/rich-headless"
|
|
46
|
+
},
|
|
42
47
|
"scripts": {
|
|
43
48
|
"build": "vite build",
|
|
44
49
|
"dev:build": "vite build --watch"
|