@meowdown/core 0.68.3 → 0.70.0

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/dist/index.d.ts CHANGED
@@ -8,7 +8,9 @@ import { EditorView } from "@prosekit/pm/view";
8
8
  import { EditorNode, Mark, ProseMirrorNode } from "@prosekit/pm/model";
9
9
  import { ListAttrs } from "@prosekit/extensions/list";
10
10
  import { HorizontalRuleExtension } from "@prosekit/extensions/horizontal-rule";
11
+ import { Resolver } from "@post-embed/elements/x";
11
12
  import { render } from "katex";
13
+ import { XPost, YouTubeVideo } from "@post-embed/types";
12
14
  import { VirtualElement } from "@floating-ui/dom";
13
15
  //#region src/converters/check-roundtrip.d.ts
14
16
  /**
@@ -202,6 +204,10 @@ interface MdImageAttrs {
202
204
  * Display height in CSS pixels from the trailing comment, or `null`.
203
205
  */
204
206
  height: number | null;
207
+ /**
208
+ * The saved post-embed snapshot from the trailing comment, or `null`.
209
+ */
210
+ snapshot: object | null;
205
211
  /**
206
212
  * `wikiEmbed` when the source is `![[target]]`; otherwise `null`.
207
213
  */
@@ -513,6 +519,7 @@ interface ReferenceDefinitionIndex {
513
519
  definitions: ReferenceDefinitions;
514
520
  nodes: ReadonlySet<EditorNode>;
515
521
  }
522
+ export declare function isReferenceDefinitionNode(node: EditorNode, parent: EditorNode | null, index: number): boolean;
516
523
  export declare function collectReferenceDefinitions(doc: EditorNode): ReferenceDefinitionIndex;
517
524
  //#endregion
518
525
  //#region src/extensions/wiki-embed.d.ts
@@ -1033,62 +1040,6 @@ export declare const codeBlockLanguages: ReadonlyArray<LanguageItem>;
1033
1040
  */
1034
1041
  export declare function defineEmbedPaste(): PlainExtension;
1035
1042
  //#endregion
1036
- //#region src/extensions/embed-types.d.ts
1037
- /**
1038
- * A framework-agnostic description of an embed iframe. Both the editor's DOM
1039
- * mark view and the static React renderer build their own `<iframe>` from it, so
1040
- * the URL/attribute logic lives in one place while each side renders natively.
1041
- */
1042
- interface EmbedDescriptor {
1043
- readonly kind: 'tweet' | 'youtube';
1044
- /**
1045
- * Stable identity for the widget, unique per rendered embed (e.g. the video or
1046
- * tweet id). Keeps ProseMirror from rebuilding the iframe on every edit, and
1047
- * keys the React element, so the embed never reloads.
1048
- */
1049
- readonly key: string;
1050
- /**
1051
- * The iframe `src`.
1052
- */
1053
- readonly src: string;
1054
- /**
1055
- * The iframe `title`.
1056
- */
1057
- readonly title: string;
1058
- /**
1059
- * The iframe `class`, e.g. `md-embed md-embed-tweet`.
1060
- */
1061
- readonly className: string;
1062
- /**
1063
- * The iframe `data-testid`.
1064
- */
1065
- readonly testid: string;
1066
- /**
1067
- * The iframe `allow` policy, when the embed needs one.
1068
- */
1069
- readonly allow?: string;
1070
- /**
1071
- * Whether the iframe is fullscreen-capable.
1072
- */
1073
- readonly allowFullscreen?: boolean;
1074
- }
1075
- //#endregion
1076
- //#region src/extensions/tweet.d.ts
1077
- /**
1078
- * `Tweet.html` reports its rendered height via `postMessage`; size the iframe to
1079
- * fit and pass each reported height to `onHeight`. Returns a cleanup that
1080
- * removes the listener. The cleanup also runs once the iframe leaves the DOM, so
1081
- * the editor's DOM mark view (which has no destroy hook) is covered, while a
1082
- * React caller can call it on unmount.
1083
- */
1084
- export declare function listenForTweetHeight(iframe: HTMLIFrameElement, onHeight?: (height: number) => void): () => void;
1085
- //#endregion
1086
- //#region src/extensions/embed.d.ts
1087
- /**
1088
- * Detect a tweet/YouTube embed in an image `src`, or `undefined` for a plain image.
1089
- */
1090
- export declare function matchEmbed(src: string): EmbedDescriptor | undefined;
1091
- //#endregion
1092
1043
  //#region src/extensions/exit-boundary.d.ts
1093
1044
  /**
1094
1045
  * Payload for {@link ExitBoundaryHandler}.
@@ -1362,6 +1313,39 @@ interface FollowLinkHandlers {
1362
1313
  */
1363
1314
  export declare function defineFollowLinkHandler(handlers: FollowLinkHandlers): PlainExtension;
1364
1315
  //#endregion
1316
+ //#region src/extensions/post-embed.d.ts
1317
+ type XPostResolver = Resolver<XPost>;
1318
+ type YouTubeVideoResolver = Resolver<YouTubeVideo>;
1319
+ type PostEmbedKind = 'x-post' | 'youtube-video';
1320
+ /**
1321
+ * The post id of an X status URL, or `undefined` for any other `src`.
1322
+ */
1323
+ export declare function parseXPostId(src: string): string | undefined;
1324
+ /**
1325
+ * The post-embed card an image `src` renders as, or `undefined` for a plain image.
1326
+ */
1327
+ export declare function matchPostEmbed(src: string): PostEmbedKind | undefined;
1328
+ export declare const defaultResolveXPost: XPostResolver;
1329
+ export declare const defaultResolveYouTubeVideo: YouTubeVideoResolver;
1330
+ /**
1331
+ * The `snapshot` field of an image's magic comment: the card kind and the
1332
+ * data post-embed renders. The kind is stored explicitly, so a saved snapshot
1333
+ * is validated once, against the schema it names.
1334
+ */
1335
+ type PostEmbedSnapshot = {
1336
+ kind: 'x-post';
1337
+ data: XPost;
1338
+ } | {
1339
+ kind: 'youtube-video';
1340
+ data: YouTubeVideo;
1341
+ };
1342
+ /**
1343
+ * The snapshot a card renders from a saved JSON object, or `undefined` when
1344
+ * the object does not validate. Unknown fields are dropped, so a persisted
1345
+ * snapshot is exactly what the card needs.
1346
+ */
1347
+ export declare function parsePostEmbedSnapshot(value: unknown): PostEmbedSnapshot | undefined;
1348
+ //#endregion
1365
1349
  //#region src/extensions/image.d.ts
1366
1350
  type ImageUrlResolver = (src: string) => string | undefined;
1367
1351
  /**
@@ -1374,12 +1358,17 @@ interface ImageOptions {
1374
1358
  */
1375
1359
  resolveImageUrl?: ImageUrlResolver;
1376
1360
  /**
1377
- * Whether to write the height a tweet embed reports back into the trailing
1378
- * size comment, so the next load can seed the iframe at its final height.
1379
- * Defaults to `true`; disable when the document must never change without a
1380
- * user edit (e.g. deterministic tests).
1361
+ * Resolve the data behind an X post URL, rendered as a `post-embed-x-post`
1362
+ * card. Defaults to `defaultResolveXPost`, which fetches through
1363
+ * react-tweet's hosted proxy.
1364
+ */
1365
+ resolveXPost?: XPostResolver;
1366
+ /**
1367
+ * Resolve the data behind a YouTube video URL, rendered as a
1368
+ * `post-embed-youtube-video` card. Defaults to `defaultResolveYouTubeVideo`,
1369
+ * which reads YouTube's oEmbed endpoint.
1381
1370
  */
1382
- persistTweetHeight?: boolean;
1371
+ resolveYouTubeVideo?: YouTubeVideoResolver;
1383
1372
  }
1384
1373
  /**
1385
1374
  * Show an `src` as-is when it is an http(s) URL, otherwise skip rendering it.
@@ -1640,4 +1629,4 @@ export declare function getSelectedText(state: EditorState): string;
1640
1629
  */
1641
1630
  export declare function getVirtualElementFromRange(view: EditorView, range: PositionRange): VirtualElement;
1642
1631
  //#endregion
1643
- export { type AcceptPendingReplacementOptions, type CheckRoundTripOptions, type CodeBlockAttrs, type CodeBlockFenceStyle, type CodeToken, type DocToMarkdownOptions, type EditorExtension, type EditorExtensionOptions, type EmbedDescriptor, type ExitBoundaryHandler, type ExitBoundaryOptions, type FileClickHandler, type FileClickPayload, type FileInfo, type FileInfoResolver, type FileLinkOptions, type FileLinkPayload, type FileLinkResolver, type FilePasteHandler, type FilePasteOptions, type FileSaveErrorHandler, type FileViewOptions, type FollowLinkHandlers, type ImageClickHandler, type ImageClickPayload, type ImageOptions, type InlineMarkContext, type InlineMarkOptions, type KaTeXRender, type LanguageItem, type LinkAttrs, type LinkClickHandler, type LinkClickPayload, type LinkCopyHandler, type LinkCopyPayload, type LinkEditHandler, type LinkEditOptions, type LinkHoverHandler, type LinkHoverOptions, type LinkPreview, type LinkPreviewResolver, type LinkUnit, type ListMarker, type MarkChunk, type MarkMode, type MarkName, type MarkdownToDocOptions, type MdFileAttrs, type MdImageAttrs, type MdLinkTextAttrs, type MdMathAttrs, type MdWikilinkAttrs, type MeowdownCodeBlockAttrs, type MeowdownHTMLCommentAttrs, type MeowdownListAttrs, type MeowdownTableCellAttrs, type NodeName, type ParsedWikiEmbed, type PendingReplacement, type PendingReplacementEvent, type PendingReplacementHandler, type PendingReplacementMode, type PendingReplacementOutcome, type PlaceholderOptions, type PositionRange, Priority, type ReferenceDefinition, type ReferenceDefinitionIndex, type ReferenceDefinitions, type RoundTripFidelity, type SearchStatus, type SearchStatusHandler, type StartPendingReplacementOptions, type TableColumnAlign, type TagClickHandler, type TagClickPayload, type TypedEditor, type TypedMarkBuilders, type VirtualElement, type WikiEmbedOptions, type WikiEmbedResolution, type WikiEmbedResolver, type WikilinkClickHandler, type WikilinkClickPayload, type WikilinkHoverHandler, type WikilinkHoverHit, type WikilinkOptions, type WikilinkPayload, type WikilinkResolution, type WikilinkResolver, defineCodeBlockPreviewPlugin, definePlaceholder, defineReadonly, defineSearchStatusHandler, getSearchStatus, isCodeBlockPreviewHiddenDecoration, withPriority };
1632
+ export { type AcceptPendingReplacementOptions, type CheckRoundTripOptions, type CodeBlockAttrs, type CodeBlockFenceStyle, type CodeToken, type DocToMarkdownOptions, type EditorExtension, type EditorExtensionOptions, type ExitBoundaryHandler, type ExitBoundaryOptions, type FileClickHandler, type FileClickPayload, type FileInfo, type FileInfoResolver, type FileLinkOptions, type FileLinkPayload, type FileLinkResolver, type FilePasteHandler, type FilePasteOptions, type FileSaveErrorHandler, type FileViewOptions, type FollowLinkHandlers, type ImageClickHandler, type ImageClickPayload, type ImageOptions, type InlineMarkContext, type InlineMarkOptions, type KaTeXRender, type LanguageItem, type LinkAttrs, type LinkClickHandler, type LinkClickPayload, type LinkCopyHandler, type LinkCopyPayload, type LinkEditHandler, type LinkEditOptions, type LinkHoverHandler, type LinkHoverOptions, type LinkPreview, type LinkPreviewResolver, type LinkUnit, type ListMarker, type MarkChunk, type MarkMode, type MarkName, type MarkdownToDocOptions, type MdFileAttrs, type MdImageAttrs, type MdLinkTextAttrs, type MdMathAttrs, type MdWikilinkAttrs, type MeowdownCodeBlockAttrs, type MeowdownHTMLCommentAttrs, type MeowdownListAttrs, type MeowdownTableCellAttrs, type NodeName, type ParsedWikiEmbed, type PendingReplacement, type PendingReplacementEvent, type PendingReplacementHandler, type PendingReplacementMode, type PendingReplacementOutcome, type PlaceholderOptions, type PositionRange, type PostEmbedKind, type PostEmbedSnapshot, Priority, type ReferenceDefinition, type ReferenceDefinitionIndex, type ReferenceDefinitions, type RoundTripFidelity, type SearchStatus, type SearchStatusHandler, type StartPendingReplacementOptions, type TableColumnAlign, type TagClickHandler, type TagClickPayload, type TypedEditor, type TypedMarkBuilders, type VirtualElement, type WikiEmbedOptions, type WikiEmbedResolution, type WikiEmbedResolver, type WikilinkClickHandler, type WikilinkClickPayload, type WikilinkHoverHandler, type WikilinkHoverHit, type WikilinkOptions, type WikilinkPayload, type WikilinkResolution, type WikilinkResolver, type XPostResolver, type YouTubeVideoResolver, defineCodeBlockPreviewPlugin, definePlaceholder, defineReadonly, defineSearchStatusHandler, getSearchStatus, isCodeBlockPreviewHiddenDecoration, withPriority };