···260260 }
261261262262 byteOffset += textBytes.length;
263263+ } else if (child.type.name === "cardRef") {
264264+ const name = (child.attrs.name as string) || "";
265265+ const scryfallId = (child.attrs.scryfallId as string) || "";
266266+ const textBytes = new TextEncoder().encode(name);
267267+268268+ textParts.push(name);
269269+270270+ if (scryfallId) {
271271+ facets.push({
272272+ index: {
273273+ byteStart: byteOffset,
274274+ byteEnd: byteOffset + textBytes.length,
275275+ },
276276+ features: [
277277+ {
278278+ $type: "com.deckbelcher.richtext.facet#cardRef",
279279+ scryfallId,
280280+ },
281281+ ],
282282+ });
283283+ }
284284+285285+ byteOffset += textBytes.length;
263286 }
264264- // TODO: handle cardRef and other inline nodes
265287 });
266288267289 // Close any remaining active marks
···515537 schema.nodes.mention.create({
516538 handle,
517539 did: mentionFeature.did || null,
540540+ }),
541541+ );
542542+ continue;
543543+ }
544544+545545+ // Check for cardRef facet - these become inline nodes
546546+ const cardRefFeature = segment.features.find(
547547+ (f) =>
548548+ (f as { $type?: string }).$type ===
549549+ "com.deckbelcher.richtext.facet#cardRef",
550550+ ) as { $type: string; scryfallId?: string } | undefined;
551551+552552+ if (cardRefFeature) {
553553+ nodes.push(
554554+ schema.nodes.cardRef.create({
555555+ name: segment.text,
556556+ scryfallId: cardRefFeature.scryfallId || "",
518557 }),
519558 );
520559 continue;
+11-1
typelex/richtext-facet.tsp
···1111 index: ByteSlice;
12121313 @required
1414- features: (Mention | Link | Tag | Bold | Italic | Code | CodeBlock | unknown)[];
1414+ features: (Mention | Link | Tag | Bold | Italic | Code | CodeBlock | CardRef | unknown)[];
1515 }
16161717 /**
···8181 * Typically rendered as `<pre><code>` in HTML.
8282 */
8383 model CodeBlock {}
8484+8585+ /**
8686+ * Facet feature for a card reference.
8787+ * Links to a Magic: The Gathering card by Scryfall ID.
8888+ * The text is usually the card name.
8989+ */
9090+ model CardRef {
9191+ @required
9292+ scryfallId: string;
9393+ }
8494}