@latentic/live-markdown 0.1.0 → 0.1.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.1] - 2026-08-24
4
+
5
+ ### Added
6
+
7
+ - `inlineScanRulesFacet`, `scanInline`, `escapeText`/`escapeAttr` and their
8
+ types are exported. 0.1.0 shipped the seam but left it unreachable: a
9
+ third-party extension could contribute a rule for a construct Lezer parses
10
+ (`nodeRulesFacet`, public since 0.0.1) but not for one it does not, which is
11
+ half a contract.
12
+
3
13
  ## [0.1.0] - 2026-08-24
4
14
 
5
15
  First release from the editor's own repository, and the first with CI on more
package/dist/index.d.ts CHANGED
@@ -160,6 +160,57 @@ declare function structural(why: string): NodeRule;
160
160
  */
161
161
  declare const nodeRulesFacet: Facet<Readonly<Record<string, NodeRule>>, Readonly<Record<string, NodeRule>>>;
162
162
 
163
+ /**
164
+ * Constructs Lezer never parses.
165
+ *
166
+ * Wikilinks, `==highlight==`, footnote references and `$math$` are not
167
+ * CommonMark, so no node exists for any of them and the editor finds each by
168
+ * scanning text (`codeContext.ts` documents the shared code guard). A renderer
169
+ * that walks the tree is therefore blind to all four — which is how a table cell
170
+ * came to show `$440 = 2 \times \frac{22}{7} \times r$` as literal source while
171
+ * the same expression rendered as mathematics in the paragraph above it.
172
+ *
173
+ * A feature contributes its pattern and its markup through this facet; the
174
+ * string renderers consult the facet and stay ignorant of what the constructs
175
+ * are. The decoration plugins keep their own viewport-scanning path — the two
176
+ * paths share the pattern, not the machinery, because one produces decorations
177
+ * over a live document and the other an HTML string.
178
+ */
179
+
180
+ interface InlineScanRule {
181
+ readonly name: string;
182
+ /** Global-flagged; the scanner drives `exec` and resets `lastIndex`. */
183
+ readonly pattern: RegExp;
184
+ /** Markup for one match. Escaping document text is the rule's job. */
185
+ render(match: RegExpExecArray): string;
186
+ /**
187
+ * Upgrade rendered markup to real DOM, after sanitisation. Only for a
188
+ * construct whose rendering is DOM rather than markup (KaTeX): the generated
189
+ * nodes bypass the sanitiser, so a hydrate reads inert text from the element
190
+ * it replaces and never trusts the document.
191
+ */
192
+ hydrate?(root: HTMLElement): void;
193
+ }
194
+ declare const inlineScanRulesFacet: Facet<InlineScanRule, readonly InlineScanRule[]>;
195
+ interface InlineScanMatch {
196
+ readonly from: number;
197
+ readonly to: number;
198
+ readonly html: string;
199
+ }
200
+ /**
201
+ * Every rule's matches in `text`, in document order, offset by `at`.
202
+ *
203
+ * Earliest wins, then longest — two constructs cannot both own one span, and
204
+ * the alternative (rule declaration order) would make the result depend on
205
+ * extension load order.
206
+ */
207
+ declare function scanInline(rules: readonly InlineScanRule[], text: string, at?: number): InlineScanMatch[];
208
+
209
+ /** Entity-escaping for the string renderers (table cells), which build HTML
210
+ * text rather than DOM and so must neutralise markup in document content. */
211
+ declare function escapeText(value: string): string;
212
+ declare function escapeAttr(value: string): string;
213
+
163
214
  /**
164
215
  * A syntax tree that reaches `pos`.
165
216
  *
@@ -801,4 +852,4 @@ interface ResolveWorkspaceLinkOptions {
801
852
  }
802
853
  declare function resolveWorkspaceLink(href: string, options: ResolveWorkspaceLinkOptions): ResolvedWorkspaceLink | null;
803
854
 
804
- export { type CaretContextSnapshot, type CodeMirrorEditorMode, CodeMirrorMarkdownEditor, type CodeMirrorMarkdownEditorProps, type ComposedExtension, type DocumentTextChange, type EditorSelectionSnapshot, type Frontmatter, type FrontmatterValue, type HighlightedSpan, IMAGE_EDIT_ALT_EVENT, type ImageEditAltEventDetail, type ImageInsertOptions, type ImageInsertResult, type ImageResolveContext, type MarkdownDocument, type MarkdownExtension, type MermaidRenderResult, type NodeContext, type NodeRule, type NodeRules, type OpenExternalUrl, type Paint, type ResolveImageSrc, type ResolveWorkspaceLinkOptions, type ResolvedWorkspaceLink, type SaveImageBytes, type SourceRange, type ToolbarContribution, blockCommands, buildImageMarkdown, composeExtensions, computeFileDir, defaultResolveImageSrc, dirnamePath, editorBaseTheme, extractImageBlobs, extractImageFiles, footnoteExtension, formatCommands, getCachedMermaidPng, hasUriScheme, headingLine, hideAlways, highlightExtension, highlightFenceSpans, imageInsertHandlers, insertImageBlob, isAbsolutePath, isMermaidFenceInfo, joinPath, line, mark, markdownDecorationsPlugin, mathExtension, mermaidExtension, nodeRulesFacet, onEditorUpdate, parseFrontmatter, parseWikilinkBody, pickImageFileForCaret, raw, renderMermaidToSvg, resolveWikilinkTarget, resolveWorkspaceLink, serializeMarkdown, setFrontmatterField, showImageActionMenu, structural, tableExtension, treeAt, warmMermaidPng, wikilinkExtension };
855
+ export { type CaretContextSnapshot, type CodeMirrorEditorMode, CodeMirrorMarkdownEditor, type CodeMirrorMarkdownEditorProps, type ComposedExtension, type DocumentTextChange, type EditorSelectionSnapshot, type Frontmatter, type FrontmatterValue, type HighlightedSpan, IMAGE_EDIT_ALT_EVENT, type ImageEditAltEventDetail, type ImageInsertOptions, type ImageInsertResult, type ImageResolveContext, type InlineScanMatch, type InlineScanRule, type MarkdownDocument, type MarkdownExtension, type MermaidRenderResult, type NodeContext, type NodeRule, type NodeRules, type OpenExternalUrl, type Paint, type ResolveImageSrc, type ResolveWorkspaceLinkOptions, type ResolvedWorkspaceLink, type SaveImageBytes, type SourceRange, type ToolbarContribution, blockCommands, buildImageMarkdown, composeExtensions, computeFileDir, defaultResolveImageSrc, dirnamePath, editorBaseTheme, escapeAttr, escapeText, extractImageBlobs, extractImageFiles, footnoteExtension, formatCommands, getCachedMermaidPng, hasUriScheme, headingLine, hideAlways, highlightExtension, highlightFenceSpans, imageInsertHandlers, inlineScanRulesFacet, insertImageBlob, isAbsolutePath, isMermaidFenceInfo, joinPath, line, mark, markdownDecorationsPlugin, mathExtension, mermaidExtension, nodeRulesFacet, onEditorUpdate, parseFrontmatter, parseWikilinkBody, pickImageFileForCaret, raw, renderMermaidToSvg, resolveWikilinkTarget, resolveWorkspaceLink, scanInline, serializeMarkdown, setFrontmatterField, showImageActionMenu, structural, tableExtension, treeAt, warmMermaidPng, wikilinkExtension };
package/dist/index.js CHANGED
@@ -5929,6 +5929,6 @@ function CodeMirrorMarkdownEditorInner({
5929
5929
  }
5930
5930
  var CodeMirrorMarkdownEditor = memo(CodeMirrorMarkdownEditorInner);
5931
5931
 
5932
- export { CodeMirrorMarkdownEditor, IMAGE_EDIT_ALT_EVENT, blockCommands, buildImageMarkdown, composeExtensions, computeFileDir, defaultResolveImageSrc, dirnamePath, editorBaseTheme, extractImageBlobs, extractImageFiles, footnoteExtension, formatCommands, getCachedMermaidPng, hasUriScheme, headingLine, hideAlways, highlightExtension, highlightFenceSpans, imageInsertHandlers, insertImageBlob, isAbsolutePath, isMermaidFenceInfo, joinPath, line, mark, markdownDecorationsPlugin, mathExtension, mermaidExtension, nodeRulesFacet, onEditorUpdate, parseFrontmatter, parseWikilinkBody, pickImageFileForCaret, raw, renderMermaidToSvg, resolveWikilinkTarget, resolveWorkspaceLink, serializeMarkdown, setFrontmatterField, showImageActionMenu, structural, tableExtension, treeAt, warmMermaidPng, wikilinkExtension };
5932
+ export { CodeMirrorMarkdownEditor, IMAGE_EDIT_ALT_EVENT, blockCommands, buildImageMarkdown, composeExtensions, computeFileDir, defaultResolveImageSrc, dirnamePath, editorBaseTheme, escapeAttr, escapeText, extractImageBlobs, extractImageFiles, footnoteExtension, formatCommands, getCachedMermaidPng, hasUriScheme, headingLine, hideAlways, highlightExtension, highlightFenceSpans, imageInsertHandlers, inlineScanRulesFacet, insertImageBlob, isAbsolutePath, isMermaidFenceInfo, joinPath, line, mark, markdownDecorationsPlugin, mathExtension, mermaidExtension, nodeRulesFacet, onEditorUpdate, parseFrontmatter, parseWikilinkBody, pickImageFileForCaret, raw, renderMermaidToSvg, resolveWikilinkTarget, resolveWorkspaceLink, scanInline, serializeMarkdown, setFrontmatterField, showImageActionMenu, structural, tableExtension, treeAt, warmMermaidPng, wikilinkExtension };
5933
5933
  //# sourceMappingURL=index.js.map
5934
5934
  //# sourceMappingURL=index.js.map