@haklex/rich-static-renderer 0.0.83 → 0.0.85

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.
@@ -1,3 +1,3 @@
1
1
  import { RichRendererProps } from './types';
2
- export declare function RichRenderer({ value, variant, theme, className, style, as: Component, rendererConfig, extraNodes, builtinNodeOverrides, }: RichRendererProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function RichRenderer({ value, variant, theme, className, style, as: Component, nested, rendererConfig, extraNodes, builtinNodeOverrides, }: RichRendererProps): import("react/jsx-runtime").JSX.Element;
3
3
  //# sourceMappingURL=RichRenderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RichRenderer.d.ts","sourceRoot":"","sources":["../src/RichRenderer.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAuB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AA2MtE,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,OAAmB,EACnB,KAAe,EACf,SAAS,EACT,KAAK,EACL,EAAE,EAAE,SAAiB,EACrB,cAAc,EACd,UAAU,EACV,oBAAoB,GACrB,EAAE,iBAAiB,2CAmCnB"}
1
+ {"version":3,"file":"RichRenderer.d.ts","sourceRoot":"","sources":["../src/RichRenderer.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAuB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAkNtE,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,OAAmB,EACnB,KAAe,EACf,SAAS,EACT,KAAK,EACL,EAAE,EAAE,SAAiB,EACrB,MAAc,EACd,cAAc,EACd,UAAU,EACV,oBAAoB,GACrB,EAAE,iBAAiB,2CAoCnB"}
@@ -1,3 +1,3 @@
1
1
  import { ReactNode } from 'react';
2
- export declare function renderBuiltinNode(node: any, key: string, children: ReactNode[] | null, headingSlugs: Map<string, number>, _textContent?: string): ReactNode;
2
+ export declare function renderBuiltinNode(node: any, key: string, children: ReactNode[] | null, headingSlugs: Map<string, number>, textContent?: string): ReactNode;
3
3
  //# sourceMappingURL=renderBuiltinNode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderBuiltinNode.d.ts","sourceRoot":"","sources":["../../src/engine/renderBuiltinNode.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAkCtD,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,GAAG,EACT,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,EAC5B,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,YAAY,CAAC,EAAE,MAAM,GACpB,SAAS,CAuMX"}
1
+ {"version":3,"file":"renderBuiltinNode.d.ts","sourceRoot":"","sources":["../../src/engine/renderBuiltinNode.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAkCtD,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,GAAG,EACT,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,EAC5B,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,WAAW,CAAC,EAAE,MAAM,GACnB,SAAS,CAiNX"}
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { semanticClassNames, sharedStyles, RendererWrapper, RubyRenderer, getTagBgColor, LinkFavicon, getVariantClass, useOptionalNestedContentRenderer, allNodes, ColorSchemeProvider, RendererConfigProvider, FootnoteDefinitionsProvider, NestedContentRendererProvider, editorTheme } from "@haklex/rich-editor/static";
2
+ import { semanticClassNames, sharedStyles, RendererWrapper, RubyRenderer, getTagBgColor, detailsClassNames, detailsStyles, LinkFavicon, getVariantClass, useOptionalNestedContentRenderer, allNodes, ColorSchemeProvider, RendererConfigProvider, FootnoteDefinitionsProvider, NestedContentRendererProvider, editorTheme, gridClassNames, gridStyles } from "@haklex/rich-editor/static";
3
3
  import { PortalThemeProvider } from "@haklex/rich-style-token";
4
4
  import { createHeadlessEditor } from "@lexical/headless";
5
5
  import { $getRoot } from "lexical";
@@ -52,7 +52,7 @@ function extractText(node) {
52
52
  if (node.children) return node.children.map(extractText).join("");
53
53
  return "";
54
54
  }
55
- function renderBuiltinNode(node, key, children, headingSlugs, _textContent) {
55
+ function renderBuiltinNode(node, key, children, headingSlugs, textContent) {
56
56
  switch (node.type) {
57
57
  case "root": {
58
58
  return /* @__PURE__ */ jsx(Fragment, { children });
@@ -63,7 +63,7 @@ function renderBuiltinNode(node, key, children, headingSlugs, _textContent) {
63
63
  }
64
64
  case "heading": {
65
65
  const Tag = node.tag;
66
- const text = extractText(node);
66
+ const text = textContent || extractText(node);
67
67
  const baseSlug = textToSlug(text);
68
68
  let slug = baseSlug;
69
69
  if (baseSlug) {
@@ -91,6 +91,7 @@ function renderBuiltinNode(node, key, children, headingSlugs, _textContent) {
91
91
  case "listitem": {
92
92
  const isChecklist = node.checked !== void 0;
93
93
  const hasNestedList = node.children?.some((c) => c.type === "list");
94
+ const value = typeof node.value === "number" && node.value > 1 ? node.value : void 0;
94
95
  let cls;
95
96
  if (hasNestedList) {
96
97
  cls = shared$1("listNestedItem");
@@ -99,7 +100,7 @@ function renderBuiltinNode(node, key, children, headingSlugs, _textContent) {
99
100
  } else {
100
101
  cls = shared$1("listItem");
101
102
  }
102
- return /* @__PURE__ */ jsx("li", { className: cls, value: node.value, children }, key);
103
+ return /* @__PURE__ */ jsx("li", { className: cls, value, children }, key);
103
104
  }
104
105
  case "link": {
105
106
  return /* @__PURE__ */ jsxs(
@@ -139,26 +140,41 @@ function renderBuiltinNode(node, key, children, headingSlugs, _textContent) {
139
140
  }
140
141
  case "details": {
141
142
  const summary = node.summary || "";
142
- return /* @__PURE__ */ jsxs("details", { className: "rich-details", open: node.open || void 0, children: [
143
- /* @__PURE__ */ jsxs("summary", { className: "rich-details-summary", children: [
144
- /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "rich-details-chevron", children: /* @__PURE__ */ jsx(
145
- "svg",
146
- {
147
- fill: "none",
148
- height: "20",
149
- stroke: "currentColor",
150
- strokeLinecap: "round",
151
- strokeLinejoin: "round",
152
- strokeWidth: "1.5",
153
- viewBox: "0 0 20 20",
154
- width: "20",
155
- children: /* @__PURE__ */ jsx("path", { d: "M8 6L12 10L8 14" })
156
- }
157
- ) }),
158
- /* @__PURE__ */ jsx("span", { className: "rich-details-summary-text", children: summary })
159
- ] }),
160
- /* @__PURE__ */ jsx("div", { className: "rich-details-content", children })
161
- ] }, key);
143
+ return /* @__PURE__ */ jsxs(
144
+ "details",
145
+ {
146
+ className: `${detailsClassNames.details} ${detailsStyles.details}`,
147
+ open: node.open || void 0,
148
+ children: [
149
+ /* @__PURE__ */ jsxs("summary", { className: `${detailsClassNames.summary} ${detailsStyles.summary}`, children: [
150
+ /* @__PURE__ */ jsx(
151
+ "span",
152
+ {
153
+ "aria-hidden": "true",
154
+ className: `${detailsClassNames.chevron} ${detailsStyles.chevron}`,
155
+ children: /* @__PURE__ */ jsx(
156
+ "svg",
157
+ {
158
+ fill: "none",
159
+ height: "20",
160
+ stroke: "currentColor",
161
+ strokeLinecap: "round",
162
+ strokeLinejoin: "round",
163
+ strokeWidth: "1.5",
164
+ viewBox: "0 0 20 20",
165
+ width: "20",
166
+ children: /* @__PURE__ */ jsx("path", { d: "M8 6L12 10L8 14" })
167
+ }
168
+ )
169
+ }
170
+ ),
171
+ /* @__PURE__ */ jsx("span", { className: `${detailsClassNames.summaryText} ${detailsStyles.summaryText}`, children: summary })
172
+ ] }),
173
+ /* @__PURE__ */ jsx("div", { className: `${detailsClassNames.content} ${detailsStyles.content}`, children })
174
+ ]
175
+ },
176
+ key
177
+ );
162
178
  }
163
179
  case "spoiler": {
164
180
  return /* @__PURE__ */ jsx("span", { className: shared$1("spoiler"), role: "button", tabIndex: 0, children }, key);
@@ -297,7 +313,14 @@ function wrapDecoration(serialized, key, decoration) {
297
313
  );
298
314
  }
299
315
  case "grid-container": {
300
- return createElement("div", { key, className: "rich-grid-container" }, decoration);
316
+ return createElement(
317
+ "div",
318
+ {
319
+ key,
320
+ className: `${gridClassNames.container} ${gridStyles.container}`
321
+ },
322
+ decoration
323
+ );
301
324
  }
302
325
  default: {
303
326
  if (isValidElement(decoration)) {
@@ -347,14 +370,14 @@ function renderTree(node, editor, editorConfig, headingSlugs, key, blockId, buil
347
370
  );
348
371
  }
349
372
  }
350
- node.getTextContent ? node.getTextContent() : void 0;
373
+ const textContent = node.getTextContent ? node.getTextContent() : void 0;
351
374
  const override = builtinNodeOverrides?.[serialized.type];
352
375
  if (override) {
353
- const defaultRenderer = () => renderBuiltinNode(serialized, nodeKey, children, headingSlugs);
376
+ const defaultRenderer = () => renderBuiltinNode(serialized, nodeKey, children, headingSlugs, textContent);
354
377
  return applyBlockId(override(serialized, nodeKey, children, defaultRenderer), blockId, nodeKey);
355
378
  }
356
379
  return applyBlockId(
357
- renderBuiltinNode(serialized, nodeKey, children, headingSlugs),
380
+ renderBuiltinNode(serialized, nodeKey, children, headingSlugs, textContent),
358
381
  blockId,
359
382
  nodeKey
360
383
  );
@@ -434,6 +457,7 @@ function RichRenderer({
434
457
  className,
435
458
  style,
436
459
  as: Component = "div",
460
+ nested = false,
437
461
  rendererConfig,
438
462
  extraNodes,
439
463
  builtinNodeOverrides
@@ -455,6 +479,7 @@ function RichRenderer({
455
479
  {
456
480
  suppressHydrationWarning: true,
457
481
  className: classes,
482
+ "data-rich-nested": nested ? "true" : void 0,
458
483
  "data-theme": theme,
459
484
  style,
460
485
  children: content
package/dist/types.d.ts CHANGED
@@ -7,6 +7,7 @@ export interface RichRendererProps {
7
7
  builtinNodeOverrides?: Record<string, BuiltinNodeRenderer>;
8
8
  className?: string;
9
9
  extraNodes?: Array<Klass<LexicalNode>>;
10
+ nested?: boolean;
10
11
  rendererConfig?: RendererConfig;
11
12
  style?: CSSProperties;
12
13
  theme?: ColorScheme;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACjG,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,MAAM,MAAM,mBAAmB,GAAG,CAChC,IAAI,EAAE,GAAG,EACT,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,EAC5B,eAAe,EAAE,MAAM,SAAS,KAC7B,SAAS,CAAC;AAEf,MAAM,WAAW,iBAAiB;IAChC,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC;IACvC,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IACvC,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,KAAK,EAAE,qBAAqB,CAAC;IAC7B,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC7B"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACjG,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,MAAM,MAAM,mBAAmB,GAAG,CAChC,IAAI,EAAE,GAAG,EACT,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,EAC5B,eAAe,EAAE,MAAM,SAAS,KAC7B,SAAS,CAAC;AAEf,MAAM,WAAW,iBAAiB;IAChC,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC;IACvC,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IACvC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,KAAK,EAAE,qBAAqB,CAAC;IAC7B,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC7B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haklex/rich-static-renderer",
3
- "version": "0.0.83",
3
+ "version": "0.0.85",
4
4
  "description": "Headless SSR engine for Lexical rich content",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,8 +23,8 @@
23
23
  "@lexical/code": "npm:lexical-code-no-prism@0.41.0",
24
24
  "@lexical/headless": "^0.41.0",
25
25
  "lucide-react": "^0.577.0",
26
- "@haklex/rich-editor": "0.0.83",
27
- "@haklex/rich-style-token": "0.0.83"
26
+ "@haklex/rich-editor": "0.0.85",
27
+ "@haklex/rich-style-token": "0.0.85"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@lexical/extension": "^0.41.0",