@meowdown/core 0.78.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 +0 -4
- package/dist/index.d.ts +2 -27
- package/dist/index.js +1 -40
- package/package.json +2 -3
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,3 +1,4 @@
|
|
|
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";
|
|
@@ -12,32 +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/converters/check-roundtrip.d.ts
|
|
16
|
-
/**
|
|
17
|
-
* How faithfully markdown survives a parse-then-serialize round trip:
|
|
18
|
-
* - `exact`: byte-identical (modulo the trailing newline).
|
|
19
|
-
* - `normalizing`: bytes differ, but only as layout the parser reads back
|
|
20
|
-
* through - every content line survives and the output re-parses to the same
|
|
21
|
-
* document (e.g. a lazy continuation re-indented, or `>>>>>>> x` respaced to
|
|
22
|
-
* the seven blockquotes it already meant).
|
|
23
|
-
* - `lossy`: content changed - a content line differs or disappeared, or the
|
|
24
|
-
* output re-parses to a different document.
|
|
25
|
-
*/
|
|
26
|
-
type RoundTripFidelity = 'exact' | 'normalizing' | 'lossy';
|
|
27
|
-
/**
|
|
28
|
-
* Options for {@link checkRoundTrip}.
|
|
29
|
-
*/
|
|
30
|
-
interface CheckRoundTripOptions {
|
|
31
|
-
/**
|
|
32
|
-
* Whether to handle a leading `---` frontmatter block. Off by default.
|
|
33
|
-
*/
|
|
34
|
-
frontmatter?: boolean;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Classify how `markdown` survives the editor's parse-then-serialize round trip.
|
|
38
|
-
*/
|
|
39
|
-
export declare function checkRoundTrip(markdown: string, options?: CheckRoundTripOptions): RoundTripFidelity;
|
|
40
|
-
//#endregion
|
|
41
16
|
//#region src/extensions/frontmatter.d.ts
|
|
42
17
|
/**
|
|
43
18
|
* The raw YAML frontmatter body, stored verbatim (the text between the opening
|
|
@@ -1715,4 +1690,4 @@ export declare function docToParagraphMarkdown(doc: ProseMirrorNode): string;
|
|
|
1715
1690
|
*/
|
|
1716
1691
|
export declare function defineSingleParagraph(): PlainExtension;
|
|
1717
1692
|
//#endregion
|
|
1718
|
-
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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { LEZER_NODE_IDS, checkRoundTrip, collectInlineElements, getAutolinkHref, gfmParser, isSpaceChar, matchEmbed, parseInline, parseMarkdownAst, parseXPostId, serializeMarkdownAst } from "@meowdown/markdown";
|
|
1
2
|
import { Priority, Priority as Priority$1, createMarkBuilders, createNodeBuilders, defaultBlockAt, defineBaseCommands, defineBaseKeymap, defineClipboardSerializer, defineCommands, defineHistory, defineKeymap, defineMarkSpec, defineMarkView, defineNodeAttr, defineNodeSpec, definePlugin, findMarkRange, getMarkRange, getMarkType, getNodeType, isAllSelection, isApple, isAtBlockStart, isNodeSelection, isTextSelection, setBlockType, toggleNode, union, unsetBlockType, withPriority, withPriority as withPriority$1, withSkipCodeBlock } from "@prosekit/core";
|
|
2
3
|
import { defineCodeBlock, defineCodeBlockHighlight, defineCodeBlockPreviewPlugin, isCodeBlockPreviewHiddenDecoration } from "@prosekit/extensions/code-block";
|
|
3
4
|
import { definePlaceholder, definePlaceholder as definePlaceholder$1 } from "@prosekit/extensions/placeholder";
|
|
4
5
|
import { defineSearchCommands, defineSearchQuery, defineSearchStatusHandler, getSearchStatus, getSearchStatus as getSearchStatus$1 } from "@prosekit/extensions/search";
|
|
5
|
-
import { LEZER_NODE_IDS, collectInlineElements, getAutolinkHref, gfmParser, isSpaceChar, matchEmbed, parseInline, parseMarkdownAst, parseXPostId, serializeMarkdownAst } from "@meowdown/markdown";
|
|
6
6
|
import { isElementLike, isHTMLElement, isObject, once } from "@ocavue/utils";
|
|
7
7
|
import { defineBlockquote } from "@prosekit/extensions/blockquote";
|
|
8
8
|
import { defineDoc } from "@prosekit/extensions/doc";
|
|
@@ -7415,45 +7415,6 @@ function markdownToDoc(markdown, options = {}) {
|
|
|
7415
7415
|
return astToDoc(parseMarkdownAst(markdown, options), options.nodes);
|
|
7416
7416
|
}
|
|
7417
7417
|
|
|
7418
|
-
//#endregion
|
|
7419
|
-
//#region src/converters/check-roundtrip.ts
|
|
7420
|
-
function trimTrailingNewlines(text) {
|
|
7421
|
-
let end = text.length;
|
|
7422
|
-
while (end > 0 && text.charCodeAt(end - 1) === 10) end--;
|
|
7423
|
-
return text.slice(0, end);
|
|
7424
|
-
}
|
|
7425
|
-
/**
|
|
7426
|
-
* Classify how `markdown` survives the editor's parse-then-serialize round trip.
|
|
7427
|
-
*/
|
|
7428
|
-
function checkRoundTrip(markdown, options = {}) {
|
|
7429
|
-
const { frontmatter } = options;
|
|
7430
|
-
const doc = markdownToDoc(markdown, { frontmatter });
|
|
7431
|
-
let serialized = docToMarkdown(doc, { frontmatter });
|
|
7432
|
-
if (markdown === serialized) return "exact";
|
|
7433
|
-
markdown = trimTrailingNewlines(markdown);
|
|
7434
|
-
serialized = trimTrailingNewlines(serialized);
|
|
7435
|
-
if (markdown === serialized) return "exact";
|
|
7436
|
-
markdown = removeMarkdownStructure(markdown);
|
|
7437
|
-
serialized = removeMarkdownStructure(serialized);
|
|
7438
|
-
if (markdown === serialized) return "normalizing";
|
|
7439
|
-
markdown = removeNumberZeroPrefix(markdown);
|
|
7440
|
-
serialized = removeNumberZeroPrefix(serialized);
|
|
7441
|
-
if (markdown === serialized) return "normalizing";
|
|
7442
|
-
markdown = removeMathCodeBlockLanguage(markdown);
|
|
7443
|
-
serialized = removeMathCodeBlockLanguage(serialized);
|
|
7444
|
-
if (markdown === serialized) return "normalizing";
|
|
7445
|
-
return "lossy";
|
|
7446
|
-
}
|
|
7447
|
-
function removeMarkdownStructure(markdown) {
|
|
7448
|
-
return markdown.replaceAll(/[-+=_:|\\/[\]<>()`~$*#\s!]+/gu, "");
|
|
7449
|
-
}
|
|
7450
|
-
function removeNumberZeroPrefix(markdown) {
|
|
7451
|
-
return markdown.replaceAll(/0+/gu, "");
|
|
7452
|
-
}
|
|
7453
|
-
function removeMathCodeBlockLanguage(markdown) {
|
|
7454
|
-
return markdown.replaceAll(/math|latex/giu, "");
|
|
7455
|
-
}
|
|
7456
|
-
|
|
7457
7418
|
//#endregion
|
|
7458
7419
|
//#region src/extensions/code-block-languages.ts
|
|
7459
7420
|
const excludeLanguages = /* @__PURE__ */ new Set([
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meowdown/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.78.
|
|
4
|
+
"version": "0.78.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@floating-ui/dom": "^1.8.0",
|
|
27
27
|
"@lezer/highlight": "^1.2.3",
|
|
28
28
|
"@meowdown/embed": "0.3.1",
|
|
29
|
-
"@meowdown/markdown": "0.
|
|
29
|
+
"@meowdown/markdown": "0.74.0",
|
|
30
30
|
"@ocavue/utils": "^1.8.0",
|
|
31
31
|
"@post-embed/exporter": "^0.5.0",
|
|
32
32
|
"@post-embed/schema": "^0.5.2",
|
|
@@ -58,7 +58,6 @@
|
|
|
58
58
|
"@types/hast": "^3.0.5",
|
|
59
59
|
"@types/mdast": "^4.0.4",
|
|
60
60
|
"@vitest/browser-playwright": "^5.0.1",
|
|
61
|
-
"commonmark.json": "^0.31.0",
|
|
62
61
|
"dedent": "^1.7.2",
|
|
63
62
|
"diffable-html-snapshot": "^0.3.0",
|
|
64
63
|
"tsdown": "^0.23.0",
|