@haklex/rich-headless 0.0.64 → 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 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,CAAA;AA6C1B,eAAO,MAAM,mBAAmB,EAAE,oBASjC,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,oBAajC,CAAA;AAED,eAAO,MAAM,oBAAoB,EAAE,oBAWlC,CAAA;AAED,eAAO,MAAM,wBAAwB,EAAE,oBAWtC,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,oBAgB9B,CAAA;AAID,eAAO,MAAM,kBAAkB,EAAE,qBAIhC,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,qBAIrC,CAAA;AAED,eAAO,MAAM,qBAAqB,EA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() === "katex-inline" ? `$${node.__equation ?? ""}$` : null,
65
- importRegExp: /\$([^$\n]+)\$/,
66
- regExp: /\$([^$\n]+)\$$/,
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>\s*([\s\S]*?)\s*<rt>\s*([\s\S]*?)\s*<\/rt>\s*(?:<rp>[\s\S]*?<\/rp>\s*)*<\/ruby>/i,
81
- regExp: /<ruby>\s*([\s\S]*?)\s*<rt>\s*([\s\S]*?)\s*<\/rt>\s*(?:<rp>[\s\S]*?<\/rp>\s*)*<\/ruby>$/i,
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.64",
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"
package/LICENSE DELETED
@@ -1,28 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Innei
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
22
-
23
-
24
- Additional Terms and Conditions
25
-
26
- ----------------
27
-
28
- Use of this software is governed by the terms of MIT and, in addition, by the terms and conditions described in the additional file (ADDITIONAL_TERMS.md). By using this software, you agree to abide by these additional terms and conditions.