@localess/richtext 4.0.2-dev.20260929213805 → 4.0.2-dev.20260930154740

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.
Files changed (3) hide show
  1. package/README.md +4 -2
  2. package/SKILL.md +8 -0
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -49,13 +49,15 @@ const html = renderRichTextToHtml(content.data.content);
49
49
 
50
50
  ### Overriding a node type
51
51
 
52
- Pass `renderers` to replace how one type is rendered — node types and mark types alike. A renderer receives the node's own `attrs`, `text` and `marks` plus its already-rendered `children`, so you only describe the wrapper:
52
+ Pass `renderers` to replace how one type is rendered — node types and mark types alike. A renderer receives the node's own `attrs`, `text` and `marks` plus its already-rendered `children`, so you only describe the wrapper. A custom `link` renderer receives an already-sanitized `href`; the returned string is trusted HTML, so escape what you interpolate (`escapeAttr` / `escapeHtml`):
53
53
 
54
54
  ```ts
55
+ import { escapeAttr, renderRichTextToHtml } from '@localess/richtext';
56
+
55
57
  const html = renderRichTextToHtml(content.data.content, {
56
58
  renderers: {
57
59
  heading: ({ attrs, children }) => `<h${attrs?.level} class="font-bold">${children}</h${attrs?.level}>`,
58
- link: ({ attrs, children }) => `<a href="${attrs?.href}" rel="noopener">${children}</a>`,
60
+ link: ({ attrs, children }) => `<a href="${escapeAttr(attrs?.href ?? '')}" rel="noopener">${children}</a>`,
59
61
  },
60
62
  });
61
63
  ```
package/SKILL.md CHANGED
@@ -115,6 +115,7 @@ export { renderRichTextToHtml } // HTML s
115
115
  export { normalizeInput, buildMarkTree, marksEqual, processAttrs, sanitizeElement } // walker helpers
116
116
  export { escapeHtml, escapeAttr, sanitizeUrl } // escaping / URL policy
117
117
  export { NODE_RENDER_MAP, MARK_RENDER_MAP, resolveHeadingTag } // default render table
118
+ export { RichTextParseError } // also on the parser subpaths
118
119
  export type {
119
120
  LocalessRichTextDocument, LocalessRichTextNode, LocalessRichTextNodeWithKey,
120
121
  LocalessRichTextMark, LocalessRichTextLinkAttrs, LocalessRichTextElement,
@@ -122,8 +123,15 @@ export type {
122
123
  LocalessRichTextRenderer, LocalessRichTextRenderers, LocalessRichTextRendererProps,
123
124
  LocalessRichTextHtmlOptions, NormalizeInputOptions, ProcessAttrsOptions,
124
125
  RichTextRenderSpec, MarkTreeSegment, MarkTreeText, MarkTreeMark,
126
+ RichTextParseOptions, RichTextParseResult, RichTextUnsupportedPolicy, RichTextUnsupportedReport,
125
127
  }
126
128
 
129
+ // @localess/richtext/html-parser, @localess/richtext/markdown-parser
130
+ export { parseHtmlToRichText } // html-parser
131
+ export { parseMarkdownToRichText } // markdown-parser
132
+ export { RichTextParseError }
133
+ export type { RichTextParseOptions, RichTextParseResult, RichTextUnsupportedPolicy, RichTextUnsupportedReport }
134
+
127
135
  // @localess/richtext/test-utils
128
136
  export { richTextFixtures }
129
137
  export type { RichTextFixture }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localess/richtext",
3
- "version": "4.0.2-dev.20260929213805",
3
+ "version": "4.0.2-dev.20260930154740",
4
4
  "description": "Framework-neutral rich text model and renderer for Localess's TipTap JSON content.",
5
5
  "keywords": [
6
6
  "localess",
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "license": "MIT",
60
60
  "dependencies": {
61
- "@localess/model": "4.0.2-dev.20260929213805"
61
+ "@localess/model": "4.0.2-dev.20260930154740"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@tiptap/extension-bold": "^3.22.5",