Conversation
limel-markdown gains a toMarkdown() method that returns its value with every whitelisted custom element replaced by what its rendered instance reports through the new MarkdownRepresentable interface, for targets that cannot render the element — a paste into another application, say. Today such an element is stripped from any HTML made of the markdown and left as raw markup in the plain text. Occurrences in the source are paired with rendered elements by tag name and order; when the counts disagree for a tag, every occurrence of it is dropped rather than risk attaching one element's representation to another. Elements without the method contribute their light-DOM text when written with a closing tag, and nothing otherwise, since without one the parser nests the following text inside the element and it is already in the source. The render started by a value change is now kept as a promise so the method can wait for the elements to exist before asking them. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-4300/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claude on behalf of Civing
@coderabbitai summary
Closes #4301. Part of Lundalogik/crm-insights-and-intelligence#392.
What
limel-markdowngains atoMarkdown()method: itsvaluewith every whitelisted custom element replaced by the markdown that element stands for, for targets that cannot render the element — a paste into another application, say.An element opts in by implementing the new
MarkdownRepresentableinterface (toMarkdown(): Promise<string>). The viewer detects the method on the rendered instances by duck typing, so it imports nothing from any consumer, and only whitelisted elements are ever asked — they are the only custom elements the sanitizer lets into the DOM, and the whitelist is checked explicitly as well.Why
The AI Assist copy action puts the answer's markdown on the clipboard. Custom elements in it —
<limebb-object-chip limetype="person" objectid="1234">— come out as raw markup in plain text and are stripped entirely from the rich flavour. The rendered chip already knows the person's name and URL; this lets the copy path ask it. The consumers (building-blocks for the chip, crm-components for the copy handler) follow in their own PRs once this is released.The rich text editor's serializer, which writes the tag itself so its markdown round-trips, is unchanged: that is the storage form, this is the export form.
How
substituteCustomElements(source, root, whitelist)pairs each written occurrence of a whitelisted tag with the rendered elements of that tag, by order, and splices in what each returns. Three written forms are recognised (self-closing, open through closing tag, open alone). When a tag's written and rendered counts disagree, every occurrence of that tag is removed rather than risk pairing wrongly. Elements without the method contribute their light-DOM text when written with a closing tag and nothing otherwise, since without one the parser nests the following text inside the element and it is already in the source.textChanged()keeps its render as a promise sotoMarkdown()can wait for the elements to exist before asking them.Review:
@alpha)Browsers tested:
(Check any that applies, it's ok to leave boxes unchecked if testing something didn't seem relevant.)
Windows:
Linux:
macOS:
Mobile:
🤖 Generated with Claude Code