@haklex/rich-ext-code-snippet 0.5.0 → 0.6.0

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 CHANGED
@@ -10,10 +10,10 @@ pnpm add @haklex/rich-ext-code-snippet
10
10
 
11
11
  ## Peer Dependencies
12
12
 
13
- | Package | Version |
14
- | --- | --- |
13
+ | Package | Version |
14
+ | --------- | --------- |
15
15
  | `lexical` | `^0.41.0` |
16
- | `react` | `>= 19` |
16
+ | `react` | `>= 19` |
17
17
 
18
18
  Key runtime dependencies include `@codemirror/*` (editor engine), `@dnd-kit/*` (drag-and-drop), and `shiki` (syntax highlighting).
19
19
 
@@ -21,45 +21,58 @@ Key runtime dependencies include `@codemirror/*` (editor engine), `@dnd-kit/*` (
21
21
 
22
22
  ### Register nodes in your editor config
23
23
 
24
+ Edit (read + write):
25
+
24
26
  ```ts
25
- import { codeSnippetEditNodes } from '@haklex/rich-ext-code-snippet'
27
+ import { codeSnippetEditNodes } from '@haklex/rich-ext-code-snippet/edit';
26
28
 
27
- // Add to your Lexical editor node list
28
- const editorConfig = {
29
- nodes: [...codeSnippetEditNodes],
30
- }
29
+ const editorConfig = { nodes: [...codeSnippetEditNodes] };
31
30
  ```
32
31
 
33
- For static/read-only rendering:
32
+ Static / read-only:
34
33
 
35
34
  ```ts
36
- import { codeSnippetNodes } from '@haklex/rich-ext-code-snippet/static'
35
+ import { codeSnippetNodes } from '@haklex/rich-ext-code-snippet/node';
37
36
 
38
- const staticConfig = {
39
- nodes: [...codeSnippetNodes],
40
- }
37
+ const staticConfig = { nodes: [...codeSnippetNodes] };
41
38
  ```
42
39
 
43
40
  ### Use renderers
44
41
 
45
42
  ```tsx
46
- import { CodeSnippetEditRenderer } from '@haklex/rich-ext-code-snippet'
47
- import { CodeSnippetRenderer } from '@haklex/rich-ext-code-snippet/static'
43
+ import { CodeSnippetEditRenderer } from '@haklex/rich-ext-code-snippet/edit';
44
+ import { CodeSnippetRenderer } from '@haklex/rich-ext-code-snippet/renderer';
48
45
  ```
49
46
 
50
47
  ### Markdown transformer
51
48
 
52
49
  ```ts
53
- import { CODE_SNIPPET_BLOCK_TRANSFORMER } from '@haklex/rich-ext-code-snippet'
50
+ import { CODE_SNIPPET_BLOCK_TRANSFORMER } from '@haklex/rich-ext-code-snippet/node';
54
51
 
55
- // Add to your Lexical markdown transformers array
56
- const transformers = [CODE_SNIPPET_BLOCK_TRANSFORMER]
52
+ const transformers = [CODE_SNIPPET_BLOCK_TRANSFORMER];
57
53
  ```
58
54
 
55
+ ### Tree-shake the default renderer
56
+
57
+ The default `CodeSnippetRenderer` is **not** statically imported by `CodeSnippetNode`. Register a custom renderer through `RendererConfig` to drop the heavy default chunk:
58
+
59
+ ```ts
60
+ import { CODE_SNIPPET_NODE_KEY, codeSnippetNodes } from '@haklex/rich-ext-code-snippet/node';
61
+ import type { RichRendererModule } from '@haklex/rich-compose';
62
+
63
+ const lightModule: RichRendererModule = {
64
+ name: 'code-snippet',
65
+ nodes: codeSnippetNodes,
66
+ renderers: { [CODE_SNIPPET_NODE_KEY]: MyLightCodeSnippet },
67
+ };
68
+ ```
69
+
70
+ `@haklex/rich-compose`'s `codeSnippetModule` lazy-loads the default renderer via `lazyRenderers`; the override pattern above bypasses it entirely.
71
+
59
72
  ### Import styles
60
73
 
61
74
  ```ts
62
- import '@haklex/rich-ext-code-snippet/style.css'
75
+ import '@haklex/rich-ext-code-snippet/style.css';
63
76
  ```
64
77
 
65
78
  ## Exports
@@ -77,17 +90,24 @@ import '@haklex/rich-ext-code-snippet/style.css'
77
90
  - `CodeSnippetRenderer` -- static renderer (no heavy UI deps)
78
91
  - `CodeSnippetEditRenderer` -- edit renderer with CodeMirror, drag-and-drop tabs
79
92
 
93
+ ### Slot Key
94
+
95
+ - `CODE_SNIPPET_NODE_KEY` -- `'CodeSnippet'` constant for `RendererConfig` slot lookup
96
+
80
97
  ### Transformers
81
98
 
82
99
  - `CODE_SNIPPET_BLOCK_TRANSFORMER` -- Markdown block transformer
83
100
 
84
- ### Sub-path Exports
101
+ ## Sub-path Exports
85
102
 
86
- | Path | Description |
87
- | --- | --- |
88
- | `@haklex/rich-ext-code-snippet` | Full exports (edit + static) |
89
- | `@haklex/rich-ext-code-snippet/static` | Static-only (no CodeMirror/dnd-kit deps) |
90
- | `@haklex/rich-ext-code-snippet/style.css` | Stylesheet |
103
+ | Path | Description |
104
+ | ----------------------------------------- | --------------------------------------------------------- |
105
+ | `@haklex/rich-ext-code-snippet` | Full exports (node + renderer + edit) |
106
+ | `@haklex/rich-ext-code-snippet/node` | Lightweight node + slot key + types — no default renderer |
107
+ | `@haklex/rich-ext-code-snippet/renderer` | Default `CodeSnippetRenderer` (heavy) |
108
+ | `@haklex/rich-ext-code-snippet/edit` | Edit-mode node + `CodeSnippetEditRenderer` |
109
+ | `@haklex/rich-ext-code-snippet/static` | Convenience: node + renderer (SSR bundle) |
110
+ | `@haklex/rich-ext-code-snippet/style.css` | Stylesheet |
91
111
 
92
112
  ## Part of Haklex
93
113
 
@@ -1 +1 @@
1
- {"version":3,"file":"augment.d.ts","sourceRoot":"","sources":["../src/augment.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAEvD,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,cAAc;QACtB,WAAW,CAAC,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAA;KACtD;CACF;AAED,OAAO,EAAE,CAAA"}
1
+ {"version":3,"file":"augment.d.ts","sourceRoot":"","sources":["../src/augment.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,cAAc;QACtB,WAAW,CAAC,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC;KACvD;CACF;AAED,OAAO,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../src/edit.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAIjD,YAAY,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAA;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACnE,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,6BAA6B,CAAA;AAEpC,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAyB,CAAA"}
1
+ {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../src/edit.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAIlD,YAAY,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AAErC,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAyB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,CAAA;AAElB,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAIjD,YAAY,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AACxE,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,GAChB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAA;AAC9C,OAAO,EAAE,8BAA8B,EAAE,MAAM,eAAe,CAAA;AAC9D,YAAY,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAEjE,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAqB,CAAA"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAIlD,YAAY,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,GAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,8BAA8B,EAAE,MAAM,eAAe,CAAC;AAC/D,YAAY,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAElE,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAqB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAA;AACrB,OAAO,WAAW,CAAA;AAElB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAE3D,OAAO,EAAE,mBAAmB,EAAE,CAAA;AAC9B,YAAY,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AACjE,eAAe,mBAAmB,CAAA"}
1
+ {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AACtB,OAAO,WAAW,CAAC;AAEnB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAC/B,YAAY,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAClE,eAAe,mBAAmB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"slot.d.ts","sourceRoot":"","sources":["../src/slot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAG,aAAsB,CAAA"}
1
+ {"version":3,"file":"slot.d.ts","sourceRoot":"","sources":["../src/slot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAG,aAAsB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../src/static.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../src/static.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,QAAQ,EAAE,CAAA;CAClB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haklex/rich-ext-code-snippet",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Multi-file code snippet extension",
5
5
  "repository": {
6
6
  "type": "git",
@@ -44,9 +44,9 @@
44
44
  "@dnd-kit/sortable": "^10.0.0",
45
45
  "@dnd-kit/utilities": "^3.2.2",
46
46
  "shiki": "^4.0.2",
47
- "@haklex/rich-headless": "0.5.0",
48
- "@haklex/cm-editor": "0.5.0",
49
- "@haklex/rich-renderer-codeblock": "0.5.0"
47
+ "@haklex/cm-editor": "0.6.0",
48
+ "@haklex/rich-headless": "0.6.0",
49
+ "@haklex/rich-renderer-codeblock": "0.6.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@lexical/react": "^0.44.0",
@@ -66,9 +66,9 @@
66
66
  "lexical": "^0.44.0",
67
67
  "lucide-react": "^1.0.0",
68
68
  "react": ">=19",
69
- "@haklex/rich-editor": "0.5.0",
70
- "@haklex/rich-editor-ui": "0.5.0",
71
- "@haklex/rich-style-token": "0.5.0"
69
+ "@haklex/rich-editor": "0.6.0",
70
+ "@haklex/rich-editor-ui": "0.6.0",
71
+ "@haklex/rich-style-token": "0.6.0"
72
72
  },
73
73
  "publishConfig": {
74
74
  "access": "public"