@meowdown/core 0.77.0 → 0.78.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/README.md CHANGED
@@ -81,10 +81,6 @@ over a selection wraps it into an open wikilink (`[[selection`) with the
81
81
  wikilink menu searching it. `EDITOR_KEY_BINDINGS` exports this table as a
82
82
  literal object for host settings UIs.
83
83
 
84
- ## Round-trip fidelity
85
-
86
- [`checkRoundTrip(markdown)`](https://npmx.dev/package-docs/@meowdown%2Fcore#function-checkRoundTrip) reports how faithfully Markdown survives a parse-then-serialize round trip: `'exact'`, `'normalizing'`, or `'lossy'`.
87
-
88
84
  ## Styling
89
85
 
90
86
  `@meowdown/core/style.css` ships a default theme. Colors use `light-dark()`, so they follow the page's `color-scheme` (set `color-scheme: light dark` on `:root` for automatic dark mode). Override the `--meowdown-*` variables on `:root` or any ancestor; the full list, with a one-line description and default for each, lives in the commented `:root` block at the top of `style.css`, which is the single source of truth.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
+ import { CheckRoundTripOptions, RoundTripFidelity, checkRoundTrip } from "@meowdown/markdown";
1
2
  import { Editor, Extension, ExtractMarkBuilders, ExtractNodeBuilders, PlainExtension, Priority, Union, withPriority } from "@prosekit/core";
2
3
  import { CodeBlockAttrs, CodeBlockAttrs as CodeBlockAttrs$1, defineCodeBlockPreviewPlugin, isCodeBlockPreviewHiddenDecoration } from "@prosekit/extensions/code-block";
3
4
  import { PlaceholderOptions, PlaceholderOptions as PlaceholderOptions$1, definePlaceholder } from "@prosekit/extensions/placeholder";
4
- import { Command, EditorState, PluginKey } from "@prosekit/pm/state";
5
5
  import { SearchStatus, SearchStatusHandler, defineSearchStatusHandler, getSearchStatus } from "@prosekit/extensions/search";
6
+ import { Command, EditorState, PluginKey } from "@prosekit/pm/state";
6
7
  import { EditorView } from "@prosekit/pm/view";
7
8
  import { EditorNode, Mark, ProseMirrorNode } from "@prosekit/pm/model";
8
9
  import { ListAttrs } from "@prosekit/extensions/list";
@@ -12,35 +13,6 @@ import { YouTubeVideoClickEvent } from "@meowdown/embed/youtube";
12
13
  import { render } from "katex";
13
14
  import { XPost, YouTubeVideo } from "@post-embed/types";
14
15
  import { VirtualElement } from "@floating-ui/dom";
15
- //#region src/extensions/readonly.d.ts
16
- export declare function defineReadonly(getReadonly?: (state: EditorState) => boolean): PlainExtension;
17
- //#endregion
18
- //#region src/converters/check-roundtrip.d.ts
19
- /**
20
- * How faithfully markdown survives a parse-then-serialize round trip:
21
- * - `exact`: byte-identical (modulo the trailing newline).
22
- * - `normalizing`: bytes differ, but only as layout the parser reads back
23
- * through - every content line survives and the output re-parses to the same
24
- * document (e.g. a lazy continuation re-indented, or `>>>>>>> x` respaced to
25
- * the seven blockquotes it already meant).
26
- * - `lossy`: content changed - a content line differs or disappeared, or the
27
- * output re-parses to a different document.
28
- */
29
- type RoundTripFidelity = 'exact' | 'normalizing' | 'lossy';
30
- /**
31
- * Options for {@link checkRoundTrip}.
32
- */
33
- interface CheckRoundTripOptions {
34
- /**
35
- * Whether to handle a leading `---` frontmatter block. Off by default.
36
- */
37
- frontmatter?: boolean;
38
- }
39
- /**
40
- * Classify how `markdown` survives the editor's parse-then-serialize round trip.
41
- */
42
- export declare function checkRoundTrip(markdown: string, options?: CheckRoundTripOptions): RoundTripFidelity;
43
- //#endregion
44
16
  //#region src/extensions/frontmatter.d.ts
45
17
  /**
46
18
  * The raw YAML frontmatter body, stored verbatim (the text between the opening
@@ -1039,7 +1011,12 @@ interface FileLinkOptions {
1039
1011
  /**
1040
1012
  * Host options that influence source-backed inline atom parsing.
1041
1013
  */
1042
- type InlineMarkOptions = FileLinkOptions & WikiEmbedOptions & WikilinkOptions;
1014
+ type InlineMarkOptions = FileLinkOptions & WikiEmbedOptions & WikilinkOptions & {
1015
+ /**
1016
+ * Definitions supplied by the containing document.
1017
+ */
1018
+ referenceDefinitions?: ReferenceDefinitions;
1019
+ };
1043
1020
  interface InlineMarkContext {
1044
1021
  /**
1045
1022
  * Effective document-wide definitions, keyed by normalized reference label.
@@ -1153,7 +1130,7 @@ declare function defineEditorExtensionImpl(options: EditorExtensionOptions): imp
1153
1130
  }>, import("@prosekit/core").Extension<{
1154
1131
  Nodes: {
1155
1132
  list: {
1156
- taskMarker?: TaskMarker;
1133
+ taskMarker?: "x" | "X" | null;
1157
1134
  };
1158
1135
  };
1159
1136
  }>, import("@prosekit/core").Extension<{
@@ -1362,19 +1339,7 @@ interface DocToMarkdownOptions {
1362
1339
  frontmatter?: boolean;
1363
1340
  }
1364
1341
  /**
1365
- * Convert a ProseMirror document into a Markdown string.
1366
- *
1367
- * Performance design:
1368
- * - Output accumulates in a `string[]` buffer; joined once at the end.
1369
- * Avoids per-block intermediate strings while keeping the
1370
- * function-per-node-type readability of a switch dispatch.
1371
- * - Indent stack lives as a mutable `linePrefix` on the buffer object,
1372
- * restored via local variables across nested calls - no fresh
1373
- * context objects per recursion.
1374
- * - Inline content is walked directly (not via `node.textContent`) to
1375
- * skip one intermediate string allocation per leaf block.
1376
- * - Backtick fence width and cell escaping use single linear loops, no
1377
- * regex on the hot path.
1342
+ * Convert persisted editor content to Markdown through the shared block serializer.
1378
1343
  */
1379
1344
  export declare function docToMarkdown(node: ProseMirrorNode, options?: DocToMarkdownOptions): string;
1380
1345
  //#endregion
@@ -1549,6 +1514,9 @@ declare const NODE_NAMES: readonly ["doc", "text", "paragraph", "heading", "bloc
1549
1514
  type NodeName = (typeof NODE_NAMES)[number];
1550
1515
  export declare function isNodeOfType(node: ProseMirrorNode, name: NodeName): boolean;
1551
1516
  //#endregion
1517
+ //#region src/extensions/readonly.d.ts
1518
+ export declare function defineReadonly(getReadonly?: (state: EditorState) => boolean): PlainExtension;
1519
+ //#endregion
1552
1520
  //#region src/extensions/substitution.d.ts
1553
1521
  /**
1554
1522
  * Apply the editor's automatic plain-text substitutions.
@@ -1689,4 +1657,37 @@ export declare function getSelectedText(state: EditorState): string;
1689
1657
  */
1690
1658
  export declare function getVirtualElementFromRange(view: EditorView, range: PositionRange): VirtualElement;
1691
1659
  //#endregion
1692
- export { type AcceptPendingReplacementOptions, type CheckRoundTripOptions, type CodeBlockAttrs, type CodeBlockFenceStyle, type CodeToken, type DocToMarkdownOptions, type EditorConfig, 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 ImageUrlResolver, 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 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 XPostMediaClickHandler, type XPostResolver, type YouTubeVideoClickHandler, type YouTubeVideoResolver, defineCodeBlockPreviewPlugin, definePlaceholder, defineSearchStatusHandler, getSearchStatus, isCodeBlockPreviewHiddenDecoration, withPriority };
1660
+ //#region src/converters/paragraph.d.ts
1661
+ /**
1662
+ * Build one paragraph without interpreting block-opening Markdown.
1663
+ */
1664
+ export declare function paragraphMarkdownToDoc(markdown: string, nodes?: TypedNodeBuilders): ProseMirrorNode;
1665
+ /**
1666
+ * Flatten textblocks into one paragraph's source content.
1667
+ */
1668
+ export declare function docToParagraphMarkdown(doc: ProseMirrorNode): string;
1669
+ //#endregion
1670
+ //#region src/extensions/single-paragraph.d.ts
1671
+ /**
1672
+ * Keep editing and pasted content within one paragraph.
1673
+ * Opt into this extension for inline Markdown fields such as task paragraphs.
1674
+ * Register it alongside `defineMeowdown`, seed content with
1675
+ * `paragraphMarkdownToDoc`, and read edits with `docToParagraphMarkdown`.
1676
+ * Ordinary note editors should keep their full document behavior.
1677
+ *
1678
+ * Text input stays literal, before block input rules can consume prefixes.
1679
+ * Transactions and pasted blocks flatten to paragraph text separated by soft
1680
+ * lines. Reference definitions come from `referenceDefinitions` in the editor
1681
+ * config; definition-looking content in the field remains visible literal text.
1682
+ * Enter/submit, focus, and persistence remain the caller's responsibility.
1683
+ *
1684
+ * @example
1685
+ * const editor = createEditor({
1686
+ * extension: union(defineMeowdown({ referenceDefinitions }), defineSingleParagraph()),
1687
+ * defaultContent: paragraphMarkdownToDoc('Buy **milk**'),
1688
+ * })
1689
+ * const markdown = docToParagraphMarkdown(editor.state.doc)
1690
+ */
1691
+ export declare function defineSingleParagraph(): PlainExtension;
1692
+ //#endregion
1693
+ export { type AcceptPendingReplacementOptions, type CheckRoundTripOptions, type CodeBlockAttrs, type CodeBlockFenceStyle, type CodeToken, type DocToMarkdownOptions, type EditorConfig, 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 ImageUrlResolver, 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 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 XPostMediaClickHandler, type XPostResolver, type YouTubeVideoClickHandler, type YouTubeVideoResolver, checkRoundTrip, defineCodeBlockPreviewPlugin, definePlaceholder, defineSearchStatusHandler, getSearchStatus, isCodeBlockPreviewHiddenDecoration, withPriority };