@meowdown/core 0.33.1 → 0.35.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/README.md +5 -2
- package/dist/index.d.ts +95 -20
- package/dist/index.js +19 -17
- package/dist/style.css +98 -7
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -33,13 +33,14 @@ const markdown = docToMarkdown(editor.state.doc)
|
|
|
33
33
|
- Bullet lists (`- item`, `* item`, `+ item`)
|
|
34
34
|
- Ordered lists (`1. item`, `2) item`, etc.)
|
|
35
35
|
- Blockquotes (`> quote`)
|
|
36
|
-
- Fenced code blocks (` ```lang\ncode\n``` `)
|
|
36
|
+
- Fenced code blocks (` ```lang\ncode\n``` `), keeping tilde fences (`~~~`) and fence lengths through a round-trip
|
|
37
|
+
- Indented code blocks (four leading spaces)
|
|
37
38
|
- Thematic breaks (`---`, `***`, `___`)
|
|
38
39
|
- Bold (`**bold**`), italic (`*italic*`), and inline code
|
|
39
40
|
- Links (`[text](url)`), images (``), and autolinks (`<https://example.com>`)
|
|
40
41
|
- Hard line breaks
|
|
41
42
|
- GitHub Flavored Markdown (GFM)
|
|
42
|
-
- Tables
|
|
43
|
+
- Tables, including column alignment (`:--`, `:-:`, `--:`)
|
|
43
44
|
- Strikethrough (`~~text~~`)
|
|
44
45
|
- Task lists (`- [ ]`, `- [x]`)
|
|
45
46
|
- Autolinks for `www.`, scheme, and email URLs
|
|
@@ -117,6 +118,8 @@ A host can render chosen file links as inline **file pills**: pass `resolveFileL
|
|
|
117
118
|
|
|
118
119
|
Rendered images are resizable: drag the corner handle and the chosen size is written back into the source as a trailing comment, `<!-- {"width":320,"height":240} -->`, which round-trips as plain Markdown. A comment immediately after an image is folded into its mark and drives the image's `width` and `height` attributes, so the box keeps its dimensions before the image loads; any other comment stays literal text.
|
|
119
120
|
|
|
121
|
+
GFM table column alignment (`| :-: |` in the delimiter row) is kept as an `align` attribute on every cell and rendered through a `data-align` DOM attribute (`text-align` in the bundled stylesheet). Alignment is a column property: the header row's cells carry the source of truth, data cells (including rows inserted later) follow it automatically. Change it with the `setTableColumnAlign` command (`editor.commands.setTableColumnAlign('center')`, `null` resets to `---`), and read the alignment of the selection's column with [`getTableColumnAlign`](https://npmx.dev/package-docs/@meowdown%2Fcore#function-getTableColumnAlign).
|
|
122
|
+
|
|
120
123
|
Pasting a lone tweet or YouTube link can auto-embed it: [`defineEmbedPaste`](https://npmx.dev/package-docs/@meowdown%2Fcore#function-defineEmbedPaste) (`@meowdown/react`'s `embedPaste` prop, on by default).
|
|
121
124
|
|
|
122
125
|
Pasting rich-text HTML from a browser (a bullet list, **bold**, a link, ...) converts it to Markdown so the formatting survives instead of arriving as plain text: [`defineHTMLPaste`](https://npmx.dev/package-docs/@meowdown%2Fcore#function-defineHTMLPaste) rewrites the clipboard's `text/html` through the unified (rehype / remark) pipeline; meowdown's own clipboard (tagged `data-pm-slice`) and any paste landing in a code block are left to the default path. Going the other way, [`defineMarkdownCopy`](https://npmx.dev/package-docs/@meowdown%2Fcore#function-defineMarkdownCopy) serializes copied content to Markdown for the clipboard's `text/plain` flavor. Neither is part of `defineEditorExtension`; `@meowdown/react` applies both by default, a headless host adds them explicitly.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Editor, Extension, ExtractMarkBuilders, ExtractNodeBuilders, PlainExtension, Priority, Union, withPriority } from "@prosekit/core";
|
|
2
2
|
import { PlaceholderOptions, definePlaceholder } from "@prosekit/extensions/placeholder";
|
|
3
3
|
import { defineReadonly } from "@prosekit/extensions/readonly";
|
|
4
|
-
import { CodeBlockAttrs } from "@prosekit/extensions/code-block";
|
|
5
4
|
import { Command, EditorState } from "@prosekit/pm/state";
|
|
6
5
|
import { EditorView } from "@prosekit/pm/view";
|
|
6
|
+
import { CodeBlockAttrs, CodeBlockAttrs as CodeBlockAttrs$1 } from "@prosekit/extensions/code-block";
|
|
7
7
|
import { Mark, ProseMirrorNode } from "@prosekit/pm/model";
|
|
8
8
|
import { HorizontalRuleExtension } from "@prosekit/extensions/horizontal-rule";
|
|
9
9
|
import { VirtualElement } from "@floating-ui/dom";
|
|
@@ -56,6 +56,60 @@ type ListMarker = '.' | ')' | '-' | '*' | '+' | null;
|
|
|
56
56
|
*/
|
|
57
57
|
type TaskMarker = 'x' | 'X' | null;
|
|
58
58
|
//#endregion
|
|
59
|
+
//#region src/extensions/table-column-align.d.ts
|
|
60
|
+
/**
|
|
61
|
+
* Column alignment of a GFM table, encoded by the delimiter row: `:--` for
|
|
62
|
+
* left, `:-:` for center, `--:` for right.
|
|
63
|
+
*/
|
|
64
|
+
type TableColumnAlign = 'left' | 'center' | 'right';
|
|
65
|
+
interface MeowdownTableCellAttrs {
|
|
66
|
+
/**
|
|
67
|
+
* The column alignment this cell renders with. Defaults to null, which
|
|
68
|
+
* renders with the default left alignment and serializes the delimiter
|
|
69
|
+
* column as `---`.
|
|
70
|
+
*/
|
|
71
|
+
align?: TableColumnAlign | null;
|
|
72
|
+
}
|
|
73
|
+
type TableCellAlignExtension = Extension<{
|
|
74
|
+
Nodes: {
|
|
75
|
+
tableCell: MeowdownTableCellAttrs;
|
|
76
|
+
};
|
|
77
|
+
}>;
|
|
78
|
+
type TableHeaderCellAlignExtension = Extension<{
|
|
79
|
+
Nodes: {
|
|
80
|
+
tableHeaderCell: MeowdownTableCellAttrs;
|
|
81
|
+
};
|
|
82
|
+
}>;
|
|
83
|
+
/**
|
|
84
|
+
* The column alignment of the table column the selection sits in, or
|
|
85
|
+
* undefined when the selection is outside a table or the column has no
|
|
86
|
+
* alignment.
|
|
87
|
+
*/
|
|
88
|
+
declare function getTableColumnAlign(state: EditorState): TableColumnAlign | undefined;
|
|
89
|
+
type TableColumnAlignCommandsExtension = Extension<{
|
|
90
|
+
Commands: {
|
|
91
|
+
setTableColumnAlign: [align: TableColumnAlign | null];
|
|
92
|
+
};
|
|
93
|
+
}>;
|
|
94
|
+
type TableColumnAlignExtension = Union<[TableCellAlignExtension, TableHeaderCellAlignExtension, PlainExtension, TableColumnAlignCommandsExtension]>;
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/extensions/code-block.d.ts
|
|
97
|
+
type CodeBlockFenceStyle = 'tilde' | 'indented';
|
|
98
|
+
interface MeowdownCodeBlockAttrs extends CodeBlockAttrs$1 {
|
|
99
|
+
/**
|
|
100
|
+
* How the code block was written in the source: a tilde fence (`~~~`) or an
|
|
101
|
+
* indented block (four leading spaces). `null` (the default) is a backtick
|
|
102
|
+
* fence, so a block created in the editor serializes to the canonical form.
|
|
103
|
+
*/
|
|
104
|
+
fenceStyle?: CodeBlockFenceStyle | null;
|
|
105
|
+
/**
|
|
106
|
+
* The number of characters in the opening fence, kept only when it exceeds
|
|
107
|
+
* CommonMark's three-character minimum. `null` (the default) lets the
|
|
108
|
+
* serializer pick the shortest fence the content allows.
|
|
109
|
+
*/
|
|
110
|
+
fenceLength?: number | null;
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
59
113
|
//#region src/extensions/horizontal-rule.d.ts
|
|
60
114
|
interface MeowdownHorizontalRuleAttrs {
|
|
61
115
|
/**
|
|
@@ -312,6 +366,17 @@ text: string, /** Host options; omit for the default parse. */
|
|
|
312
366
|
|
|
313
367
|
options?: FileLinkOptions): MarkChunk[];
|
|
314
368
|
//#endregion
|
|
369
|
+
//#region src/extensions/mark-mode.d.ts
|
|
370
|
+
/**
|
|
371
|
+
* Controls how markdown syntax characters are rendered and how the
|
|
372
|
+
* editor serializes content to the clipboard.
|
|
373
|
+
*
|
|
374
|
+
* - 'hide': syntax chars never visible; copy strips them.
|
|
375
|
+
* - 'focus': syntax chars hidden by default; revealed near cursor; copy strips them.
|
|
376
|
+
* - 'show': syntax chars always visible (dim grey); copy keeps them.
|
|
377
|
+
*/
|
|
378
|
+
type MarkMode = 'hide' | 'focus' | 'show';
|
|
379
|
+
//#endregion
|
|
315
380
|
//#region src/extensions/extension.d.ts
|
|
316
381
|
declare function defineEditorExtensionImpl(options: EditorExtensionOptions): import("@prosekit/core").Union<readonly [import("@prosekit/core").Extension<{
|
|
317
382
|
Nodes: import("@prosekit/core").SimplifyDeeper<{
|
|
@@ -378,7 +443,19 @@ declare function defineEditorExtensionImpl(options: EditorExtensionOptions): imp
|
|
|
378
443
|
Nodes: {
|
|
379
444
|
tableHeaderCell: import("@prosekit/pm/model").Attrs;
|
|
380
445
|
};
|
|
381
|
-
}>]>, import("@prosekit/core").PlainExtension, import("@prosekit/extensions/table").TableCommandsExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension]>, import("@prosekit/extensions/code-block").CodeBlockExtension,
|
|
446
|
+
}>]>, TableColumnAlignExtension, import("@prosekit/core").PlainExtension, import("@prosekit/extensions/table").TableCommandsExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension]>, import("@prosekit/core").Union<readonly [import("@prosekit/extensions/code-block").CodeBlockExtension, import("@prosekit/core").Extension<{
|
|
447
|
+
Nodes: {
|
|
448
|
+
codeBlock: {
|
|
449
|
+
fenceStyle?: CodeBlockFenceStyle | null;
|
|
450
|
+
};
|
|
451
|
+
};
|
|
452
|
+
}>, import("@prosekit/core").Extension<{
|
|
453
|
+
Nodes: {
|
|
454
|
+
codeBlock: {
|
|
455
|
+
fenceLength?: number | null;
|
|
456
|
+
};
|
|
457
|
+
};
|
|
458
|
+
}>, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension]>, MeowdownHorizontalRuleExtension, import("@prosekit/core").Extension<{
|
|
382
459
|
Nodes: {
|
|
383
460
|
htmlComment: MeowdownHTMLCommentAttrs;
|
|
384
461
|
};
|
|
@@ -452,7 +529,11 @@ declare function defineEditorExtensionImpl(options: EditorExtensionOptions): imp
|
|
|
452
529
|
updateLink: [attrs: LinkAttrs];
|
|
453
530
|
removeLink: [];
|
|
454
531
|
};
|
|
455
|
-
}>, import("@prosekit/core").PlainExtension, import("@prosekit/core").
|
|
532
|
+
}>, import("@prosekit/core").PlainExtension, import("@prosekit/core").Union<readonly [import("@prosekit/core").PlainExtension, import("@prosekit/core").Extension<{
|
|
533
|
+
Commands: {
|
|
534
|
+
setMarkMode: [mode: MarkMode];
|
|
535
|
+
};
|
|
536
|
+
}>]>, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").BaseCommandsExtension, import("@prosekit/core").HistoryExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").Extension<{
|
|
456
537
|
Commands: {
|
|
457
538
|
insertMarkdown: [markdown: string];
|
|
458
539
|
selectText: [anchor: number, head?: number | undefined];
|
|
@@ -468,11 +549,17 @@ declare function defineEditorExtensionImpl(options: EditorExtensionOptions): imp
|
|
|
468
549
|
}>, import("@prosekit/core").PlainExtension]>]>;
|
|
469
550
|
type EditorExtension = ReturnType<typeof defineEditorExtensionImpl>;
|
|
470
551
|
/**
|
|
471
|
-
* Options for {@link defineEditorExtension}. Creation-time configuration:
|
|
472
|
-
* is baked into the editor's parse pipeline, so changing it
|
|
473
|
-
* rebuilding the editor.
|
|
552
|
+
* Options for {@link defineEditorExtension}. Creation-time configuration:
|
|
553
|
+
* `resolveFileLink` is baked into the editor's parse pipeline, so changing it
|
|
554
|
+
* requires rebuilding the editor; `markMode` is only the initial value.
|
|
474
555
|
*/
|
|
475
|
-
type EditorExtensionOptions = FileLinkOptions
|
|
556
|
+
type EditorExtensionOptions = FileLinkOptions & {
|
|
557
|
+
/**
|
|
558
|
+
* The initial mark mode, applied from the first paint. Defaults to
|
|
559
|
+
* `'focus'`. Switch later with the `setMarkMode` command.
|
|
560
|
+
*/
|
|
561
|
+
markMode?: MarkMode;
|
|
562
|
+
};
|
|
476
563
|
declare function defineEditorExtension(options?: EditorExtensionOptions): EditorExtension;
|
|
477
564
|
type TypedEditor = Editor<EditorExtension>;
|
|
478
565
|
//#endregion
|
|
@@ -842,18 +929,6 @@ interface MarkHoverHit<Payload> {
|
|
|
842
929
|
type LinkHoverHandler = (hit: MarkHoverHit<LinkUnit> | undefined) => void;
|
|
843
930
|
declare function defineLinkHoverHandler(onHoverChange: LinkHoverHandler): PlainExtension;
|
|
844
931
|
//#endregion
|
|
845
|
-
//#region src/extensions/mark-mode.d.ts
|
|
846
|
-
/**
|
|
847
|
-
* Controls how markdown syntax characters are rendered and how the
|
|
848
|
-
* editor serializes content to the clipboard.
|
|
849
|
-
*
|
|
850
|
-
* - 'hide': syntax chars never visible; copy strips them.
|
|
851
|
-
* - 'focus': syntax chars hidden by default; revealed near cursor; copy strips them.
|
|
852
|
-
* - 'show': syntax chars always visible (dim grey); copy keeps them.
|
|
853
|
-
*/
|
|
854
|
-
type MarkMode = 'hide' | 'focus' | 'show';
|
|
855
|
-
declare function defineMarkMode(mode: MarkMode): PlainExtension;
|
|
856
|
-
//#endregion
|
|
857
932
|
//#region src/extensions/mark-names.d.ts
|
|
858
933
|
declare const MARK_NAMES: readonly ["mdWikilink", "mdImage", "mdFile", "mdMark", "mdEm", "mdStrong", "mdCode", "mdLinkText", "mdLinkUri", "mdLinkTitle", "mdDel", "mdHighlight", "mdTag", "mdPack"];
|
|
859
934
|
type MarkName = (typeof MARK_NAMES)[number];
|
|
@@ -914,4 +989,4 @@ declare function getVirtualElementFromRange(view: EditorView, range: PositionRan
|
|
|
914
989
|
//#region src/extensions/spell-check.d.ts
|
|
915
990
|
declare function defineSpellCheckPlugin(spellCheck: boolean): import("@prosekit/core").PlainExtension;
|
|
916
991
|
//#endregion
|
|
917
|
-
export { type AcceptPendingReplacementOptions, type CheckRoundTripOptions, type CodeBlockAttrs, type CodeToken, type DocToMarkdownOptions, EDITOR_KEY_BINDINGS, 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 LinkAttrs, type LinkClickHandler, type LinkClickPayload, type LinkCopyHandler, type LinkCopyPayload, type LinkEditHandler, type LinkEditOptions, type LinkHoverHandler, type LinkUnit, type MarkChunk, type MarkMode, type MarkName, type MarkdownToDocOptions, type MdFileAttrs, type MdImageAttrs, type MdLinkTextAttrs, type MdWikilinkAttrs, type MeowdownHTMLCommentAttrs, type NodeName, type PendingReplacement, type PendingReplacementEvent, type PendingReplacementHandler, type PendingReplacementMode, type PendingReplacementOutcome, type PlaceholderOptions, type PositionRange, Priority, type RoundTripFidelity, type StartPendingReplacementOptions, type TagClickHandler, type TagClickPayload, type TypedEditor, type TypedMarkBuilders, type VirtualElement, type WikilinkClickHandler, type WikilinkClickPayload, buildFileMarkdown, checkRoundTrip, codeBlockLanguages, defaultResolveImageUrl, defineBulletAfterHeading, defineCodeBlockSyntaxHighlight, defineEditorExtension, defineEmbedPaste, defineExitBoundaryHandler, defineFileClickHandler, defineFilePaste, defineFileView, defineFollowLinkHandler, defineHTMLComment, defineHTMLPaste, defineImage, defineImageClickHandler, defineLinkClickHandler, defineLinkCommands, defineLinkEditKeymap, defineLinkHoverHandler,
|
|
992
|
+
export { type AcceptPendingReplacementOptions, type CheckRoundTripOptions, type CodeBlockAttrs, type CodeBlockFenceStyle, type CodeToken, type DocToMarkdownOptions, EDITOR_KEY_BINDINGS, 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 LinkAttrs, type LinkClickHandler, type LinkClickPayload, type LinkCopyHandler, type LinkCopyPayload, type LinkEditHandler, type LinkEditOptions, type LinkHoverHandler, type LinkUnit, type MarkChunk, type MarkMode, type MarkName, type MarkdownToDocOptions, type MdFileAttrs, type MdImageAttrs, type MdLinkTextAttrs, type MdWikilinkAttrs, type MeowdownCodeBlockAttrs, type MeowdownHTMLCommentAttrs, type MeowdownTableCellAttrs, type NodeName, type PendingReplacement, type PendingReplacementEvent, type PendingReplacementHandler, type PendingReplacementMode, type PendingReplacementOutcome, type PlaceholderOptions, type PositionRange, Priority, type RoundTripFidelity, type StartPendingReplacementOptions, type TableColumnAlign, type TagClickHandler, type TagClickPayload, type TypedEditor, type TypedMarkBuilders, type VirtualElement, type WikilinkClickHandler, type WikilinkClickPayload, buildFileMarkdown, checkRoundTrip, codeBlockLanguages, defaultResolveImageUrl, defineBulletAfterHeading, defineCodeBlockSyntaxHighlight, defineEditorExtension, defineEmbedPaste, defineExitBoundaryHandler, defineFileClickHandler, defineFilePaste, defineFileView, defineFollowLinkHandler, defineHTMLComment, defineHTMLPaste, defineImage, defineImageClickHandler, defineLinkClickHandler, defineLinkCommands, defineLinkEditKeymap, defineLinkHoverHandler, defineMarkdownCopy, definePendingReplacementHandler, definePlaceholder, defineReadonly, defineSpellCheckPlugin, defineTagClickHandler, defineWikilinkClickHandler, defineWikilinkTrigger, docToMarkdown, getCodeTokens, getLinkUnitAt, getMarkBuilders, getPendingReplacement, getSelectedText, getTableColumnAlign, getVirtualElementFromRange, inlineTextToMarkChunks, insertLink, isSelectionInTableCell, listenForTweetHeight, markdownToDoc, matchEmbed, removeLink, updateLink, withPriority };
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import{Priority as e,Priority as t,createMarkBuilders as n,createNodeBuilders as r,defineBaseCommands as i,defineBaseKeymap as a,defineCommands as o,defineDOMEventHandler as s,defineHistory as c,defineKeymap as l,defineMarkSpec as u,defineMarkView as d,defineNodeAttr as f,defineNodeSpec as p,definePlugin as m,getMarkRange as
|
|
2
|
-
`)}function kt(e){let{selection:t}=e;if(!t.empty)return w.empty;let n=t.$head,{parent:r}=n;if(!r.isTextblock||r.type.spec.code)return w.empty;let i=h(n,ee(e.schema,`mdPack`));return i?w.create(e.doc,[C.inline(i.from,i.to,{class:`show`})]):w.empty}function k(e,t){let n=Dt(t);return n?e.flatMap(e=>e.modes.includes(n)?[e.name]:[]):[]}function At(e,t,n){for(let r of n){let n=O(e,t,r);if(n)return n}}function A(e,t,n){let r=At(e,t,n);return r&&r.to===t?r:void 0}function jt(e,t,n){let r=At(e,t,n);return r&&r.from===t?r:void 0}function Mt(e,t){let{from:n,to:r,empty:i}=e.selection;if(i)return;let a=At(e,n,t);return a&&a.from===n&&a.to===r?a:void 0}function Nt(e,t){return S.create(e.doc,t.from,t.to)}function Pt(e){return(t,n)=>{let r=k(e,t);if(r.length===0||!g(t.selection))return!1;let i=t.selection;if(i.empty){let e=jt(t,i.from,r);if(e)return n?.(t.tr.setSelection(Nt(t,e))),!0;if(A(t,i.from,r)){let e=t.doc.resolve(i.from);return i.from>=e.end()?!1:(n?.(t.tr.setSelection(S.create(t.doc,i.from+1))),!0)}return!1}let a=Mt(t,r);return a?(n?.(t.tr.setSelection(S.create(t.doc,a.to))),!0):!1}}function Ft(e){return(t,n)=>{let r=k(e,t);if(r.length===0||!g(t.selection))return!1;let i=t.selection;if(i.empty){let e=A(t,i.from,r);return e?(n?.(t.tr.setSelection(Nt(t,e))),!0):!1}let a=Mt(t,r);return a?(n?.(t.tr.setSelection(S.create(t.doc,a.from))),!0):!1}}function It(e){return(t,n)=>{let r=k(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=A(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!jt(t,i,r)||i<=t.doc.resolve(i).start()?!1:(n?.(t.tr.delete(i-1,i)),!0)}}function Lt(e){return(t,n)=>{let r=k(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=jt(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!A(t,i,r)||i>=t.doc.resolve(i).end()?!1:(n?.(t.tr.delete(i,i+1)),!0)}}const Rt=`md-atom-selected`;function zt(e){return new b({key:new x(`atom-mark-selection`),props:{decorations:t=>{let n=k(e,t);if(n.length===0)return;let r=Mt(t,n);if(r)return w.create(t.doc,[C.inline(r.from,r.to,{class:Rt})]);let{from:i,to:a,empty:o}=t.selection;if(o)return null;let s=[];return t.doc.nodesBetween(i,a,(e,t)=>{e.marks.some(e=>n.includes(e.type.name))&&s.push(C.inline(t,t+e.nodeSize,{class:Rt}))}),w.create(t.doc,s)}}})}function Bt({marks:e}){return _(v(l({ArrowRight:Pt(e),ArrowLeft:Ft(e),Backspace:It(e),Delete:Lt(e)}),t.high),m(zt(e)))}const j=new Map,Vt=new Map;async function Ht(e){let t=j.get(e);if(t!==void 0)return t;let n=Ce.matchLanguageName(we,e,!0);if(!n)return j.set(e,null),null;let r=n.support;if(!r)try{r=await n.load()}catch(t){return console.error(`[meowdown] Failed to load language "${e}":`,t),j.set(e,null),null}return j.set(e,r),r}function Ut(e,t){let n=Vt.get(e);if(n)return n;let r=De({parse:e=>t.language.parser.parse(e.content),highlighter:Te});return Vt.set(e,r),r}const Wt=e=>{let t=e.language?.trim();if(!t)return[];let n=j.get(t);return n===null?[]:n?Ut(t,n)(e):Ht(t).then(()=>void 0)};function Gt(){return he({parser:Wt,nodeTypes:[`codeBlock`]})}function Kt(e,t){let n=t.language.parser.parse(e),r=[];return Ee(n,Te,(e,t,n)=>{r.push([e,t,n])}),r}function qt(e,t){let n=t.trim();if(!n)return[];let r=j.get(n);return r===null?[]:r?Kt(e,r):Ht(n).then(t=>t?Kt(e,t):[])}function Jt(e,t){return(n,r)=>{if(r){let i=S.create(n.doc,e,t);r(n.tr.setSelection(i))}return!0}}function Yt(e,t,n){return(r,i)=>{if(i){let a=S.between(e,t,n);i(r.tr.setSelection(a))}return!0}}function Xt(e){return(t,n)=>{if(!e.trim())return!1;let r=Y(e,{nodes:Hi(t.schema)}).content;if(r.childCount===0)return!1;let i=r.childCount===1&&r.child(0).type.name===`paragraph`?new T(r,1,1):new T(r,0,T.maxOpen(r).openEnd);if(n){let e=t.tr,r=e.selection;(!g(r)||!r.empty)&&e.setSelection(S.near(r.$from)),n(e.replaceSelection(i).scrollIntoView())}return!0}}function Zt(){return o({insertMarkdown:Xt,selectText:Jt,selectTextBetween:Yt})}const Qt=(e,t,n)=>{let{selection:r}=e;return r.empty||n?.composing?!1:(t?.(e.tr.setSelection(S.near(r.$head))),!0)};function $t(){return v(l({Escape:Qt}),t.low)}function en(){return f({type:`doc`,attr:`frontmatter`,default:null})}function tn(){return p({name:`heading`,whitespace:`pre`})}function nn(){return f({type:`heading`,attr:`setextUnderline`,default:null,toDOM:e=>e==null?null:[`data-setext-underline`,String(e)],parseDOM:e=>{let t=e.getAttribute(`data-setext-underline`);if(t==null)return null;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>0?n:null}})}function rn(){return f({type:`heading`,attr:`closingHashes`,default:null,toDOM:e=>e==null?null:[`data-closing-hashes`,String(e)],parseDOM:e=>{let t=e.getAttribute(`data-closing-hashes`);if(t==null)return null;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>0?n:null}})}function M(e){return le(oe({type:`heading`,attrs:{level:e}}))}const an=(e,t,n)=>ie(e,n)?.parent.type.name===`heading`?se()(e,t,n):!1;function on(){return l({"Mod-1":M(1),"Mod-2":M(2),"Mod-3":M(3),"Mod-4":M(4),"Mod-5":M(5),"Mod-6":M(6),Backspace:an})}function sn(){return _(Me(),tn(),nn(),rn(),je(),Ae(),on())}function cn(){return f({type:`horizontalRule`,attr:`marker`,default:null,toDOM:e=>e?[`data-hr-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-hr-marker`)})}function ln(){return _(Ne(),cn())}function un(){return p({name:`htmlComment`,group:`block`,atom:!0,selectable:!1,attrs:{content:{default:``}},toDOM:e=>[`div`,{"data-html-comment":e.attrs.content,style:`display: none`}],parseDOM:[{tag:`div[data-html-comment]`,getAttrs:e=>({content:e.getAttribute(`data-html-comment`)??``})}]})}function dn(e){let[t,n,r]=e;return[t,n,r.map(e=>e.toJSON())]}function fn(e,t){let[n,r,i]=t;return[n,r,i.map(t=>ke.fromJSON(e,t))]}var N=class e extends ze{constructor(e){super(),this.chunks=e}apply(e){if(this.chunks.length===0)return Be.ok(e);let t=e.content.size,n;for(let[r,i,a]of this.chunks){if(r>=i)continue;let o=Math.max(0,Math.min(r,t)),s=Math.max(o,Math.min(i,t));o>=s||e.nodesBetween(o,s,(t,r)=>{if(!t.isText)return!0;let i=Math.max(o,r),c=Math.min(s,r+t.nodeSize);if(i>=c)return!1;let l=t.marks;for(let t of l)t.isInSet(a)||(n??=new Ve(e),n.removeMark(i,c,t));for(let t of a)t.isInSet(l)||(n??=new Ve(e),n.addMark(i,c,t));return!1})}return Be.ok(n?n.doc:e)}invert(e){if(this.chunks.length===0)return pn;let t=this.chunks[0][0],n=this.chunks[0][1];for(let[,e]of this.chunks)e>n&&(n=e);let r=e.content.size,i=Math.max(0,Math.min(t,r)),a=Math.max(i,Math.min(n,r));return new Re(i,a,e.slice(i,a),!1)}map(e){return null}toJSON(){return{stepType:`batchSetMark`,chunks:this.chunks.map(dn)}}static fromJSON(t,n){let r=n.chunks;return new e(r.map(e=>fn(t,e)))}};ze.jsonID(`batchSetMark`,N);const pn=new N([]),mn=new Set([`com`,`br`,`net`,`jp`,`org`,`in`,`de`,`ru`,`it`,`fr`]),hn=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;function gn(e){let t=e.indexOf(`/`);return t===-1?e:e.slice(0,t)}function _n(e){let t=e.split(`.`);if(t.length<2)return!1;let n=t[t.length-1].toLowerCase();if(!mn.has(n)||t[t.length-2].length<3)return!1;for(let e of t)if(e.length>63||!hn.test(e))return!1;return!0}function P(e){return e===32||e===9||e===10||e===13}const vn=/^[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:\/[^\s<]*)?/i,yn=/[\s(*_~]/;function bn(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45}function xn(e,t,n){let r=0;for(let i=0;i<t;i++)e[i]===n&&r++;return r}function Sn(e){let t=e.length;for(;;){let n=e[t-1];if(/[?!.,:*_~]/.test(n)||n===`)`&&xn(e,t,`)`)>xn(e,t,`(`))t--;else if(n===`;`){let n=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(e.slice(0,t));if(!n)break;t=n.index}else break}return t}const Cn={parseInline:[{name:`BareAutolink`,before:`Link`,parse(e,t,n){if(!bn(t)||e.hasOpenLink)return-1;let r=e.slice(n-1,n);if(r!==``&&!yn.test(r))return-1;let i=vn.exec(e.slice(n,e.end));if(!i)return-1;let a=Sn(i[0]);return a===0||!_n(gn(i[0].slice(0,a)))?-1:e.addElement(e.elt(`URL`,n,n+a))}}]};function wn(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45||e===95||e>127&&/[\p{L}\p{N}]/u.test(String.fromCharCode(e))}function Tn(e){return e>=65&&e<=90||e>=97&&e<=122||e>127&&/\p{L}/u.test(String.fromCharCode(e))}const En={defineNodes:[{name:`Hashtag`}],parseInline:[{name:`Hashtag`,parse(e,t,n){if(t!==35||!/\s|^$/.test(e.slice(n-1,n)))return-1;let r=n+1,i=!1;for(;r<e.end;){let t=e.char(r);if(!wn(t))break;i||=Tn(t),r++}return i?e.addElement(e.elt(`Hashtag`,n,r)):-1}}]},Dn={resolve:`Highlight`,mark:`HighlightMark`},On=/[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~\u{A1}\u{2010}-\u{2027}]/u,kn={defineNodes:[{name:`Highlight`},{name:`HighlightMark`}],parseInline:[{name:`Highlight`,after:`Emphasis`,parse(e,t,n){if(t!==61||e.char(n+1)!==61||e.char(n+2)===61)return-1;let r=e.slice(n-1,n),i=e.slice(n+2,n+3),a=/\s|^$/.test(r),o=/\s|^$/.test(i),s=On.test(r),c=On.test(i);return e.addDelimiter(Dn,n,n+2,!o&&(!c||a||s),!a&&(!s||o||c))}}]},An={defineNodes:[{name:`Wikilink`},{name:`WikilinkMark`}],parseInline:[{name:`Wikilink`,before:`Link`,parse(e,t,n){if(t!==91||e.char(n+1)!==91)return-1;let r=!1;for(let t=n+2;t<e.end-1;t++){let i=e.char(t);if(i===93){if(e.char(t+1)!==93||!r)return-1;let i=t+2;return e.addElement(e.elt(`Wikilink`,n,i,[e.elt(`WikilinkMark`,n,n+2),e.elt(`WikilinkMark`,t,i)]))}if(i===91||i===10)return-1;i!==32&&i!==9&&(r=!0)}return-1}}]};function jn(e){return e.end}const F=Ue.configure([He,En,An,Cn,kn]),Mn=F.configure({parseInline:[{name:`SkipInline`,before:`Escape`,parse:jn}]});function I(e){return F.parseInline(e,0)}function L(e,t,n=[]){for(let r of e)t(r)&&n.push(r),L(r.children,t,n);return n}function Nn(e){let t={};for(let n of e.nodeSet.types)t[n.name]=n.id;return t}const R=Nn(F),Pn=/^<!--\s*(\{[^}]*\})\s*-->$/,Fn=/<!--\s*\{[^}]*\}\s*-->$/;function In(e){let t=Pn.exec(e.trim());if(!t)return;let n;try{n=JSON.parse(t[1])}catch{return}if(typeof n!=`object`||!n)return;let r=Ln(n);return Object.keys(r).length>0?r:void 0}function Ln(e){let t={},{width:n,height:r}=e;return typeof n==`number`&&Number.isFinite(n)&&n>0&&(t.width=Math.round(n)),typeof r==`number`&&Number.isFinite(r)&&r>0&&(t.height=Math.round(r)),t}function Rn(e){return`<!-- ${JSON.stringify(e)} -->`}function zn(e){return e.replace(Fn,``)}function Bn(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}function Vn(e){let t=e.replace(/^\[\[/,``).replace(/\]\]$/,``),n=t.indexOf(`|`);return n<0?{target:t.trim(),display:``}:{target:t.slice(0,n).trim(),display:t.slice(n+1).trim()}}function Hn(){return e=>{let t=e.attrs,n=document.createElement(`span`);n.className=`md-wikilink-view md-atom-view`;let r=document.createElement(`span`);r.className=`md-wikilink-view-preview md-atom-view-preview`,r.contentEditable=`false`,r.dataset.testid=`wikilink`,n.appendChild(r);let i=document.createElement(`span`);i.className=`md-wikilink-view-label`,i.contentEditable=`false`,i.textContent=t.display||t.target,r.appendChild(i);let a=document.createElement(`span`);return a.className=`md-wikilink-view-content md-atom-view-content`,n.appendChild(a),{dom:n,contentDOM:a,ignoreMutation:e=>!a.contains(e.target)}}}function Un(){return d({name:`mdWikilink`,constructor:Hn()})}const Wn=new Map([[R.Emphasis,`mdEm`],[R.StrongEmphasis,`mdStrong`],[R.InlineCode,`mdCode`],[R.Strikethrough,`mdDel`],[R.Highlight,`mdHighlight`],[R.EmphasisMark,`mdMark`],[R.CodeMark,`mdMark`],[R.LinkMark,`mdMark`],[R.StrikethroughMark,`mdMark`],[R.HighlightMark,`mdMark`],[R.URL,`mdLinkUri`],[R.LinkTitle,`mdLinkTitle`],[R.Hashtag,`mdTag`],[R.WikilinkMark,`mdMark`]]);function Gn(e,t,n){let r=I(t),i=[];return B(r,[],0,t.length,t,e,i,n),i}function Kn(e){if(/^[a-z][a-z0-9+.-]*:/i.test(e))return e;if(/^[^\s@]+@[^\s@]+$/.test(e))return`mailto:${e}`;if(/^www\./i.test(e)||_n(gn(e)))return`https://${e}`}function z(e){return e.slice(1,-1).replaceAll(/\\(.)/g,`$1`)}function B(e,t,n,r,i,a,o,s){let c=n;for(let n=0;n<e.length;n++){let r=e[n];r.from>c&&V(o,c,r.from,t);let l=r.type;if(l===R.Link){let e=Yn(r,t,i,a,s);e?V(o,r.from,r.to,e):Xn(r,t,i,a,o)}else if(l===R.Image){let s=Zn(r,e[n+1],i);Qn(r,t,i,a,o,s),s&&n++,c=s?s.to:r.to;continue}else if(l===R.Wikilink)$n(r,t,i,a,o);else if(l===R.URL){let e=Kn(i.slice(r.from,r.to)),n=e?a.mdLinkText.create({href:e}):a.mdLinkUri.create();V(o,r.from,r.to,[...t,n])}else{let e;l===R.Emphasis?e=`italic`:l===R.StrongEmphasis?e=`bold`:l===R.InlineCode?e=`code`:l===R.Strikethrough?e=`strike`:l===R.Highlight?e=`highlight`:l===R.Autolink&&(e=`autolink`);let n=e?[...t,a.mdPack.create({key:e})]:t,c=Wn.get(l),u=c?[...n,a[c].create()]:n;r.children.length===0?V(o,r.from,r.to,u):B(r.children,u,r.from,r.to,i,a,o,s)}c=r.to}c<r&&V(o,c,r,t)}function qn(e){let t=-1,n=-1,r=null,i=null,a=0;for(let o of e.children)o.type===R.LinkMark?(a++,a===1&&(t=o.to),a===2&&(n=o.from)):o.type===R.URL&&r===null?r=o:o.type===R.LinkTitle&&i===null&&(i=o);return{labelFrom:t,labelTo:n,urlNode:r,titleNode:i}}function Jn(e){let t=e.split(/[?#]/,1)[0],n=t.split(/[/\\]/).findLast(Boolean)??t;try{return decodeURIComponent(n)}catch{return n}}function Yn(e,t,n,r,i){let a=i?.resolveFileLink;if(!a)return;let{labelFrom:o,labelTo:s,urlNode:c,titleNode:l}=qn(e);if(o<0||s<0||!c)return;let u=n.slice(c.from,c.to);if(!u)return;let d=n.slice(o,s),f=l?z(n.slice(l.from,l.to)):``;if(!a({href:u,label:d,title:f}))return;let p=d||Jn(u);return[...t,r.mdFile.create({href:u,name:p,title:f})]}function Xn(e,t,n,r,i){let{labelTo:a,urlNode:o,titleNode:s}=qn(e),c=o?n.slice(o.from,o.to):``,l=s?z(n.slice(s.from,s.to)):``,u=c?r.mdLinkText.create({href:c}):null,d=e=>a>=0&&e<a&&u!==null,f=r.mdPack.create({key:`link`,data:{href:c,title:l}}),p=[...t,f],m=e.from;for(let t of e.children){if(t.from>m){let e=d(m)?[...p,u]:p;V(i,m,t.from,e)}let e=d(t.from)?[...p,u]:p;if(t.type===R.Wikilink){$n(t,e,n,r,i),m=t.to;continue}let a=Wn.get(t.type),o=a?[...e,r[a].create()]:e;t.children.length===0?V(i,t.from,t.to,o):B(t.children,o,t.from,t.to,n,r,i,void 0),m=t.to}m<e.to&&V(i,m,e.to,p)}function Zn(e,t,n){if(!t||t.type!==R.Comment||t.from!==e.to)return;let r=In(n.slice(t.from,t.to));if(r)return{magic:r,to:t.to}}function Qn(e,t,n,r,i,a){let o=e.children.find(e=>e.type===R.URL);if(!o){Xn(e,t,n,r,i);return}let s=e.children.filter(e=>e.type===R.LinkMark),c=e.children.find(e=>e.type===R.LinkTitle),l=n.slice(o.from,o.to),u=s.length>=2?n.slice(s[0].to,s[1].from):``,d=c?z(n.slice(c.from,c.to)):``,f=a?.magic.width??null,p=a?.magic.height??null,m=a?.to??e.to;V(i,e.from,m,[...t,r.mdImage.create({src:l,alt:u,title:d,width:f,height:p})])}function $n(e,t,n,r,i){let{target:a,display:o}=Vn(n.slice(e.from,e.to));V(i,e.from,e.to,[...t,r.mdWikilink.create({target:a,display:o})])}function V(e,t,n,r){if(t>=n)return;let i=e.at(-1);if(i&&i[1]===t&&Bn(i[2],r)){e[e.length-1]=[i[0],n,i[2]];return}e.push([t,n,r])}const er=`inline-marks-applied`;let tr=0,nr=0;function rr(e,t){let n=1/0,r=-1/0;for(let t of e)for(let e of t.mapping.maps)e.forEach((e,t,i,a)=>{i<n&&(n=i),a>r&&(r=a)});let i=t.doc.content.size;return n>r?{from:0,to:i}:{from:Math.max(0,n),to:Math.min(i,r)}}function ir(e){let t=new WeakMap;function n(n,r,i){let a=t.get(n);if(a?nr++:(tr++,a=Gn(Bi(i),n.textContent,e),t.set(n,a)),r===0)return a;let o=[];for(let[e,t,n]of a)o.push([e+r,t+r,n]);return o}function r(e,t){let r=[];return e.doc.nodesBetween(t.from,t.to,(t,i)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;if(t.childCount===0)return!1;let a=n(t,i+1,e.schema);return a.length>0&&r.push(...a),!1}),r}return new b({key:new x(`inline-mark`),appendTransaction(e,t,n){for(let t of e)if(t.getMeta(er))return null;let i=r(n,rr(e,n));if(i.length===0)return null;let a=n.tr.step(new N(i));return a.setMeta(er,!0),a.setMeta(`addToHistory`,!1),a},view(e){return e.dispatch(ar(e.state)),{}}})}function ar(e){return e.tr.setMeta(`inline-marks-trigger`,!0)}function or(e){return m(ir(e))}function sr(){return u({name:`mdImage`,inclusive:!1,attrs:{src:{default:``},alt:{default:``},title:{default:``},width:{default:null},height:{default:null}},toDOM:()=>[`span`,{class:`md-image`},0],parseDOM:[{tag:`span.md-image`}]})}function cr(){return u({name:`mdMark`,inclusive:!1,toDOM:()=>[`span`,{class:`md-mark`},0],parseDOM:[{tag:`span.md-mark`}]})}function lr(){return u({name:`mdEm`,toDOM:()=>[`em`,0],parseDOM:[{tag:`em`}]})}function ur(){return u({name:`mdStrong`,toDOM:()=>[`strong`,0],parseDOM:[{tag:`strong`}]})}function dr(){return u({name:`mdCode`,toDOM:()=>[`code`,0],parseDOM:[{tag:`code`}]})}function fr(){return u({name:`mdLinkText`,inclusive:!1,attrs:{href:{default:``}},toDOM:e=>[`a`,{class:`md-link`,href:e.attrs.href},0],parseDOM:[{tag:`a`,getAttrs:e=>({href:e.getAttribute(`href`)??``})}]})}function pr(){return u({name:`mdLinkUri`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-uri`},0],parseDOM:[{tag:`span.md-link-uri`}]})}function mr(){return u({name:`mdLinkTitle`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-title`},0],parseDOM:[{tag:`span.md-link-title`}]})}function hr(){return u({name:`mdDel`,toDOM:()=>[`del`,0],parseDOM:[{tag:`del`}]})}function gr(){return u({name:`mdHighlight`,toDOM:()=>[`mark`,0],parseDOM:[{tag:`mark`}]})}function _r(){return u({name:`mdTag`,toDOM:()=>[`span`,{class:`md-tag`},0],parseDOM:[{tag:`span.md-tag`}]})}function vr(){return u({name:`mdWikilink`,inclusive:!1,attrs:{target:{default:``},display:{default:``}},toDOM:()=>[`span`,{class:`md-wikilink`},0],parseDOM:[{tag:`span.md-wikilink`}]})}function yr(){return u({name:`mdFile`,inclusive:!1,attrs:{href:{default:``},name:{default:``},title:{default:``}},toDOM:()=>[`span`,{class:`md-file`},0],parseDOM:[{tag:`span.md-file`}]})}function br(){return u({name:`mdPack`,excludes:``,inclusive:!1,attrs:{key:{},data:{default:null}},toDOM:e=>[`span`,{class:`md-pack`,"data-key":e.attrs.key},0],parseDOM:[{tag:`span.md-pack`}]})}function xr(){return _(cr(),lr(),ur(),dr(),fr(),pr(),mr(),hr(),gr(),_r(),vr(),sr(),yr(),br())}function Sr(e,t=0){let n=t,r=0;for(let t=0;t<e.length;t++)e.charCodeAt(t)===96?(r++,r>n&&(n=r)):r=0;return n}const H={em:{node:R.Emphasis,delim:`*`},strong:{node:R.StrongEmphasis,delim:`**`},code:{node:R.InlineCode,delim:"`"},del:{node:R.Strikethrough,delim:`~~`},highlight:{node:R.Highlight,delim:`==`}},Cr=new Set([R.EmphasisMark,R.CodeMark,R.LinkMark,R.StrikethroughMark,R.HighlightMark]);function U(e){return[e.children[0],e.children.at(-1)]}function wr(e){let{type:t,children:n}=e;if(t===R.Emphasis||t===R.StrongEmphasis||t===R.Strikethrough||t===R.Highlight)return[n[0].to,n.at(-1).from];if(t===R.Link||t===R.Image){let e=n.find((e,t)=>t>0&&e.type===R.LinkMark);return e?[n[0].to,e.from]:null}return null}function W(e,t,n){for(let r of e){if(r.to<=t||r.from>=n||t<=r.from&&r.to<=n)continue;let i=wr(r);return i&&i[0]<=t&&n<=i[1]?W(r.children,t,n):W(e,Math.min(t,r.from),Math.max(n,r.to))}return[t,n]}function Tr(e,t,n){for(let r of e)if(!(r.to<=t||r.from>=n)&&(t>r.from||r.to>n))return Tr(e,Math.min(t,r.from),Math.max(n,r.to));return[t,n]}function Er(e,t,n){for(;t<n&&P(e.charCodeAt(t));)t++;for(;n>t&&P(e.charCodeAt(n-1));)n--;return[t,n]}function Dr(e,t,n,r){let i=L(I(e),e=>e.type===r.node||Cr.has(e.type));for(let r=t;r<n;r++)if(!P(e.charCodeAt(r))&&i.every(e=>!(e.from<=r&&r<e.to)))return!1;return!0}function Or(e,t,n,r,i){let a=I(e),o=L(a,e=>e.type===r.node);return i?jr(e,o,t,n):kr(e,a,o,t,n,r)}function kr(e,t,n,r,i,a){for(let e=0;e!==i-r;){e=i-r,[r,i]=W(t,r,i);for(let e of n)e.to===r&&(r=e.from),e.from===i&&(i=e.to)}let o=[];for(let e of n)if(r<=e.from&&e.to<=i){let[t,n]=U(e);o.push({from:t.from,to:t.to,insert:``}),o.push({from:n.from,to:n.to,insert:``})}let[s,c]=Ar(e,r,i,o,a);return o.push({from:r,to:r,insert:s},{from:i,to:i,insert:c}),o}function Ar(e,t,n,r,i){if(i.node!==R.InlineCode)return[i.delim,i.delim];let a=e.slice(t,n);for(let e of[...r].sort((e,t)=>t.from-e.from))a=a.slice(0,e.from-t)+a.slice(e.to-t);let o="`".repeat(Sr(a)+1),s=a.startsWith("`")||a.endsWith("`")?` `:``;return[o+s,s+o]}function jr(e,t,n,r){let i=[];for(let a of t){if(a.to<=n||a.from>=r)continue;let[t,o]=U(a),s=Math.max(n,t.to),c=Math.min(r,o.from);for(s>=c&&([s,c]=[t.to,o.from]),[s,c]=Tr(a.children.slice(1,-1),s,c);s>t.to&&P(e.charCodeAt(s-1));)s--;for(;c<o.from&&P(e.charCodeAt(c));)c++;s>t.to?i.push({from:s,to:s,insert:e.slice(o.from,o.to)}):i.push({from:t.from,to:t.to,insert:``}),c<o.from?i.push({from:c,to:c,insert:e.slice(t.from,t.to)}):i.push({from:o.from,to:o.to,insert:``})}return i}function Mr(e,t,n){let{delim:r}=n,i=r.length;if(e.slice(t-i,t)===r&&e.startsWith(r,t)&&e[t-i-1]!==r[0]&&e[t+i]!==r[0])return{kind:`unwrap`,from:t-i,to:t+i};let a=I(e),o=L(a,e=>e.type===n.node).findLast(e=>e.from<=t&&t<=e.to);if(o){let[e,n]=U(o);return{kind:`move`,pos:t===o.from?e.to:t===o.to?n.from:o.to}}return Nr(a,t)||e[t-1]===r[0]||e[t]===r[0]?null:{kind:`insert`,pos:t}}function Nr(e,t){for(let n of e)if(n.from<t&&t<n.to){let e=wr(n);return!e||t<e[0]||t>e[1]?!0:Nr(n.children,t)}return!1}function G(e){return(t,n)=>{if(t.selection.empty)return Pr(e,t,n);let{from:r,to:i,anchor:a,head:o}=t.selection,s=[];t.doc.nodesBetween(r,i,(t,n)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;let a=t.textContent,o=n+1,[c,l]=Er(a,Math.max(r-o,0),Math.min(i-o,a.length));return c<l&&s.push({text:a,base:o,from:c,to:l,active:Dr(a,c,l,e)}),!1});let c=s.length>0&&s.every(e=>e.active),l=s.filter(e=>c||!e.active).flatMap(t=>Or(t.text,t.from,t.to,e,c).map(e=>({from:e.from+t.base,to:e.to+t.base,insert:e.insert})));if(l.length===0)return!1;if(n){let e=t.tr;l.sort((e,t)=>t.from-e.from||t.to-e.to);for(let t of l)t.insert?e.insertText(t.insert,t.from,t.to):e.delete(t.from,t.to);e.setSelection(S.create(e.doc,e.mapping.map(a,a<=o?1:-1),e.mapping.map(o,o<a?1:-1))),n(e.scrollIntoView())}return!0}}function Pr(e,t,n){let{$from:r}=t.selection,i=r.parent;if(!i.isTextblock||i.type.spec.code)return!1;let a=Mr(i.textContent,r.parentOffset,e);if(!a)return!1;if(n){let i=r.start(),o=t.tr;a.kind===`unwrap`&&o.delete(i+a.from,i+a.to),a.kind===`move`&&o.setSelection(S.create(o.doc,i+a.pos)),a.kind===`insert`&&(o.insertText(e.delim+e.delim,i+a.pos),o.setSelection(S.create(o.doc,i+a.pos+e.delim.length))),n(o.scrollIntoView())}return!0}function Fr(){return o({toggleEm:()=>G(H.em),toggleStrong:()=>G(H.strong),toggleCode:()=>G(H.code),toggleDel:()=>G(H.del),toggleHighlight:()=>G(H.highlight)})}function Ir(){return l({"Mod-b":G(H.strong),"Mod-i":G(H.em),"Mod-e":G(H.code),"Mod-Shift-x":G(H.del),"Mod-Shift-h":G(H.highlight)})}function Lr(){return _(Fr(),Ir())}function Rr(e,t,n){let r;return e.doc.nodesBetween(t.from,t.to,(e,i)=>(e.isText&&e.marks.some(e=>e.type.name===n)&&(r={from:Math.max(i,t.from),to:Math.min(i+e.nodeSize,t.to)}),!0)),r}function K(e,t){let n=O(e,t,`mdLinkText`),r=O(e,t,`mdPack`),i=r??n;if(!i)return;let a=r?.mark.attrs,o=n?.mark.attrs?.href??``;if(!r||a?.key!==`link`)return{unit:{from:i.from,to:i.to},href:o,title:``};let s=Rr(e,i,`mdLinkUri`),c=s?s.from-2:i.to-3,l=s?s.from:i.to-1;return{unit:{from:i.from,to:i.to},label:{from:i.from+1,to:c},dest:{from:l,to:i.to-1},href:a.data.href,title:a.data.title}}function zr(e){let t=e.trim();return t?Kn(t)??t:``}function Br(e,t){return e+(t?` "${t.replaceAll(/(["\\])/g,String.raw`\$1`)}"`:``)}function Vr(e){let{selection:t}=e,{$from:n,$to:r,empty:i}=t;if(i||!n.sameParent(r)||!g(t))return;let a=n.parent;if(!a.isTextblock||a.type.spec.code)return;let o=n.start(),[s,c]=Er(a.textContent,n.parentOffset,r.parentOffset);if(!(s>=c))return{from:o+s,to:o+c}}function Hr(e={}){return(t,n)=>{let r=Br(zr(e.href??``),e.title??``),i=Vr(t);if(!i)return!1;if(n){let{from:e,to:a}=i,o=t.tr,s=`](${r})`;o.insertText(s,a).insertText(`[`,e),n(o.setSelection(S.create(o.doc,e,a+1+s.length)).scrollIntoView())}return!0}}function Ur(e){return(t,n)=>{let r=K(t,t.selection.from);if(!r?.dest)return!1;let i=Br(zr(e.href??r.href),e.title??r.title);return n&&n(t.tr.insertText(i,r.dest.from,r.dest.to).scrollIntoView()),!0}}function Wr(){return(e,t)=>{let n=K(e,e.selection.from);return n?.label?(t&&t(e.tr.delete(n.label.to,n.unit.to).delete(n.unit.from,n.label.from).scrollIntoView()),!0):!1}}function Gr(){return o({insertLink:Hr,updateLink:Ur,removeLink:Wr})}function Kr(e){return(t,n,r)=>{let i=K(t,t.selection.from);if(i){if(n&&r){let{unit:{from:a,to:o}}=i;n(t.tr.setSelection(S.create(t.doc,a,o)).scrollIntoView()),r.focus(),e({from:a,to:o,link:i})}return!0}let a=Vr(t);if(a){if(n&&r){let{from:i,to:o}=a;n(t.tr.setSelection(S.create(t.doc,i,o)).scrollIntoView()),r.focus(),e({from:i,to:o,link:void 0})}return!0}return!1}}function qr(e){return l({"Mod-k":Kr(e)})}function Jr(){return f({type:`list`,attr:`marker`,default:null,splittable:!0,toDOM:e=>e===`)`||e===`*`||e===`+`?[`data-list-marker`,e]:null,parseDOM:e=>{let t=e.getAttribute(`data-list-marker`);return t===`)`||t===`*`||t===`+`?t:null}})}function Yr(){return f({type:`list`,attr:`taskMarker`,default:null,splittable:!0,toDOM:e=>e===`X`?[`data-list-task-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-list-task-marker`)===`X`?`X`:null})}function Xr(e){return e===2||e===3||e===4}function Zr(){return f({type:`list`,attr:`markerGap`,default:1,splittable:!0,toDOM:e=>Xr(e)?[`data-list-marker-gap`,String(e)]:null,parseDOM:e=>{let t=Number.parseInt(e.getAttribute(`data-list-marker-gap`)??``,10);return Xr(t)?t:1}})}const Qr=[D(/^\s?([*-])\s$/,{kind:`bullet`,collapsed:!1}),D(/^\s?(\d+)\.\s$/,({match:e})=>{let t=e[1],n=t?parseInt(t,10):void 0;return{kind:`ordered`,collapsed:!1,order:n&&n>=2&&Number.isSafeInteger(n)?n:null}}),D(/^\s?\[([\sXx]?)]\s$/,({match:e})=>({kind:`task`,checked:[`x`,`X`].includes(e[1]),collapsed:!1})),D(/^\s?\+\s$/,{kind:`task`,marker:`+`,checked:!1,collapsed:!1})];function $r(){return _(Qr.map(We))}function ei(){return E({kind:`task`,marker:`+`})}function ti(){return E({kind:`task`,marker:null})}function ni(){return o({wrapInCircleTask:ei,wrapInSquareTask:ti})}function ri(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.name===`list`)return n.attrs}return null}function ii(){return(e,t,n)=>{let r=ri(e),i=r?.kind===`task`&&r.marker!==`+`,a;return a=i&&!r?.checked?{kind:`task`,marker:r?.marker??null,checked:!0}:i&&r?.checked?{kind:`bullet`,marker:null,checked:!1}:{kind:`task`,marker:null,checked:!1},E(a)(e,t,n)}}function ai(){return(e,t,n)=>{let r=ri(e),i=r?.kind===`task`&&r.marker===`+`,a;return a=i&&!r?.checked?{kind:`task`,marker:`+`,checked:!0}:i&&r?.checked?{kind:`bullet`,marker:null,checked:!1}:{kind:`task`,marker:`+`,checked:!1},E(a)(e,t,n)}}function oi(e){return e.type.name===`list`&&e.attrs.kind===`bullet`&&e.childCount>=2&&e.firstChild?.type!==e.type}const si=e=>{let t=e.attrs;return t.kind===`task`?{...t,checked:!t.checked}:oi(e)?{...t,collapsed:!t.collapsed}:t};function ci(){return m(()=>[new b({props:{handleDOMEvents:{mousedown:(e,t)=>tt({view:e,event:t,onListClick:si})}}}),Qe(),new b({props:{transformCopied:nt}}),$e()])}function li(){return o({toggleListCollapsed:()=>et({isToggleable:oi})})}function ui(){return l({"Mod-Enter":ii(),"Mod-Shift-Enter":ai(),"Mod-.":et({isToggleable:oi}),"Mod-Shift-7":Ze({kind:`ordered`,collapsed:!1}),"Mod-Shift-8":Ze({kind:`bullet`,collapsed:!1}),"Mod-Shift-9":Ze({kind:`task`,checked:!1,collapsed:!1})})}function di(){return _(Ye(),ci(),qe(),Ge(),Je(),Ke(),$r(),ui(),Jr(),Yr(),Zr(),ni(),li())}function fi(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;e--){let n=t.node(e).type.name;if(n===`tableCell`||n===`tableHeaderCell`)return!0}return!1}const pi=`paragraph`;function mi(){return _(p({name:`tableCell`,content:pi}),p({name:`tableHeaderCell`,content:pi}))}const hi=(e,t)=>{let{selection:n}=e;return!dt(n)||!n.isColSelection()||!n.isRowSelection()?!1:ut(e,t)};function gi(){return v(l({Backspace:hi,Delete:hi}),t.high)}function _i(){return _(lt(),ct(),rt(),st(),mi(),ot({allowTableNodeSelection:!0}),it(),at(),gi())}function vi(e){let{selection:t}=e,{$from:n,$to:r}=t;if(ae(t)&&n.depth===0||n.depth>0&&r.depth>0&&n.index(0)===r.index(0))return n.index(0)}function yi(e){return(t,n)=>{if(fi(t))return!1;let r=vi(t);if(r==null)return!1;let i=r+e;if(i<0||i>=t.doc.childCount)return!1;if(n){let{selection:a}=t,o=Math.min(r,i),s=a.$from.posAtIndex(o,0),c=t.doc.child(o),l=t.doc.child(o+1),u=t.tr.replaceWith(s,s+c.nodeSize+l.nodeSize,[l,c]),d=e===-1?-c.nodeSize:l.nodeSize,f=ae(a)?xe.create(u.doc,a.from+d):S.create(u.doc,a.anchor+d,a.head+d);u.setSelection(f),n(u.scrollIntoView())}return!0}}function bi(e){return(t,n,r)=>Xe(e)(t,n,r)||yi(e===`up`?-1:1)(t,n,r)}function xi(){return l({"Alt-ArrowUp":bi(`up`),"Alt-ArrowDown":bi(`down`)})}function Si(){return p({name:`paragraph`,content:`inline*`,group:`block`,whitespace:`pre`,parseDOM:[{tag:`p`}],toDOM(){return[`p`,0]}})}function Ci(){return _(v(Si(),t.highest),ft(),pt())}const q=new x(`meowdownPendingReplacement`);function J(e){return q.getState(e)?.pending??null}function wi(e,t){switch(e.type){case`start`:return{pending:{from:e.from,to:e.to,mode:e.mode,text:``}};case`append`:return t.pending?{pending:{...t.pending,text:t.pending.text+e.text}}:t;case`accept`:return t.pending?{pending:null,ended:{pending:t.pending,outcome:`accepted`}}:t;case`discard`:return t.pending?{pending:null,ended:{pending:t.pending,outcome:`discarded`}}:t}}const Ti=new b({key:q,state:{init:()=>({pending:null}),apply:(e,t)=>{let n=e.getMeta(q);if(n)return wi(n,t);if(e.docChanged&&t.pending){let n=e.mapping.mapResult(t.pending.from,1),r=e.mapping.mapResult(t.pending.to,-1),i=Math.min(n.pos,r.pos),a=Math.max(n.pos,r.pos);return(n.deletedAfter&&r.deletedBefore||i>=a)&&t.pending.mode===`replace`?{pending:null,ended:{pending:t.pending,outcome:`discarded`}}:{pending:{...t.pending,from:i,to:a}}}return t}},props:{decorations:e=>{let t=J(e);return!t||t.from>=t.to?null:w.create(e.doc,[C.inline(t.from,t.to,{class:`md-pending-replacement`})])}}});function Ei(e){return(t,n)=>{let{from:r,to:i,mode:a}=e;return r<0||i>t.doc.content.size||r>i||r===i&&a===`replace`?!1:(n?.(t.tr.setMeta(q,{type:`start`,from:r,to:i,mode:a})),!0)}}function Di(e){return(t,n)=>J(t)?(n?.(t.tr.setMeta(q,{type:`append`,text:e})),!0):!1}function Oi(){return(e,t)=>J(e)?(t?.(e.tr.setMeta(q,{type:`discard`})),!0):!1}function ki(e={}){return(t,n)=>{let r=J(t);if(!r||!r.text.trim())return!1;if(n){let i=e.mode??r.mode,a=Hi(t.schema),o=Y(r.text,{nodes:a}),s=t.tr;if(s.setMeta(q,{type:`accept`}),i===`append`){let e=t.doc.resolve(r.to).after(1);s.insert(e,o.content),s.setSelection(S.near(s.doc.resolve(e+o.content.size),-1))}else{let e=t.doc.resolve(r.from),n=t.doc.resolve(r.to),i=o.childCount===1?o.firstChild:null;i?.type.name===`paragraph`&&e.sameParent(n)&&e.parent.isTextblock?(s.replaceWith(r.from,r.to,i.content),s.setSelection(S.near(s.doc.resolve(r.from+i.content.size),-1))):(s.replaceRange(r.from,r.to,new T(o.content,0,0)),s.setSelection(S.near(s.doc.resolve(s.mapping.map(r.to)),-1)))}n(s.scrollIntoView())}return!0}}function Ai(){return o({startPendingReplacement:Ei,appendPendingReplacementText:Di,acceptPendingReplacement:ki,discardPendingReplacement:Oi})}function ji(){return l({"Mod-Enter":ki(),Escape:Oi()})}function Mi(){return _(m(Ti),Ai(),ji())}function Ni(e){return m(new b({view:()=>({update:(t,n)=>{let r=q.getState(n),i=q.getState(t.state);!i||r===i||(i.pending?i.pending!==r?.pending&&e({type:`update`,pending:i.pending}):i.ended&&i.ended!==r?.ended&&e({type:`ended`,pending:i.ended.pending,outcome:i.ended.outcome}))}})}))}function Pi(e){return _(Ci(),ge(),en(),ye(),pe(),di(),sn(),_i(),me(),ln(),un(),xr(),Gt(),$t(),xi(),or(e),Lr(),Gr(),Un(),Bt({marks:[{name:`mdImage`,modes:[`hide`,`focus`,`show`]},{name:`mdWikilink`,modes:[`hide`,`focus`,`show`]},{name:`mdFile`,modes:[`hide`,`focus`,`show`]}]}),a(),i(),c(),_e(),be(),ve(),Zt(),Mi())}function Fi(e={}){return Pi(e)}const Ii=y(()=>{let e=Fi().schema;if(e==null)throw Error(`Unexpected empty schema`);return e}),Li=y(()=>r(Ii())),Ri=y(()=>n(Ii())),zi=`meowdown_mark_builders`;function Bi(e){let t=e.cached[zi];if(t)return t;let r=n(e);return e.cached[zi]=r,r}const Vi=`meowdown_node_builders`;function Hi(e){let t=e.cached[Vi];if(t)return t;let n=r(e);return e.cached[Vi]=n,n}function Y(e,t={}){let{nodes:n=Li(),frontmatter:r=!1}=t,i,a=e;if(r){let[t,n]=Wi(e);i=t,n&&(a=e.slice(n))}let o=Gi(n,Mn.parse(a).cursor(),a);return n.doc(i===void 0?{}:{frontmatter:i},o)}const Ui=/^---[ \t]*\r?\n([\s\S]*?\n)?---[ \t]*(?:\r?\n|$)/;function Wi(e){let t=Ui.exec(e);return t?[(t[1]??``).replace(/\r?\n$/,``),t[0].length]:[]}function Gi(e,t,n){let r=[];if(!t.firstChild())return r;do r.push(...Ki(e,t,n));while(t.nextSibling());return t.parent(),r}function Ki(e,t,n){switch(t.type.id){case R.ATXHeading1:return[X(e,t,n,1,!1)];case R.ATXHeading2:return[X(e,t,n,2,!1)];case R.ATXHeading3:return[X(e,t,n,3,!1)];case R.ATXHeading4:return[X(e,t,n,4,!1)];case R.ATXHeading5:return[X(e,t,n,5,!1)];case R.ATXHeading6:return[X(e,t,n,6,!1)];case R.SetextHeading1:return[X(e,t,n,1,!0)];case R.SetextHeading2:return[X(e,t,n,2,!0)];case R.Paragraph:return[Q(e,t,n)];case R.CommentBlock:return[Qi(e,t,n)];case R.HTMLBlock:case R.ProcessingInstructionBlock:return[Q(e,t,n)];case R.Blockquote:return[$i(e,t,n)];case R.BulletList:return ea(e,t,n,`bullet`);case R.OrderedList:return ea(e,t,n,`ordered`);case R.FencedCode:case R.CodeBlock:return[na(e,t,n)];case R.HorizontalRule:{let r=n.slice(t.from,t.to).trimEnd();return[e.horizontalRule({marker:r===`---`?null:r})]}case R.Table:return[ra(e,t,n)];case R.Task:return[Q(e,t,n)];default:return n.slice(t.from,t.to).trim()===``?[]:(console.warn(`[meowdown] unsupported lezer block "${t.type.name}"`),[Q(e,t,n)])}}function X(e,t,n,r,i){let a=t.from,o=t.from,s=t.to,c=-1,l=-1;if(t.firstChild()){t.type.id===R.HeaderMark&&t.from===a&&(o=t.to);let e=-1,n=-1,r=-1;do e=t.type.id,n=t.from,r=t.to;while(t.nextSibling());e===R.HeaderMark&&n>o&&(s=n,c=n,l=r),t.parent()}let u=Xi(n.slice(o,s),Z(n,o)).trim(),d=i?qi(n,c,l)||1:null,f=!i&&c>=0&&Ji(n,c,l)||null;return e.heading({level:r,setextUnderline:d,closingHashes:f},u)}function qi(e,t,n){if(t<0)return 0;let r=0;for(let i=t;i<n;i++){let t=e.charCodeAt(i);(t===61||t===45)&&r++}return r}function Ji(e,t,n){if(t<0)return 0;let r=0;for(let i=t;i<n;i++)e.charCodeAt(i)===35&&r++;return r}function Z(e,t){let n=e.lastIndexOf(`
|
|
3
|
-
`,t-1)+1,r=0;for(let i=n;i<t;i++)r+=e.charCodeAt(i)===9?4-r%4:1;return r}function
|
|
1
|
+
import{Priority as e,Priority as t,createMarkBuilders as n,createNodeBuilders as r,defineBaseCommands as i,defineBaseKeymap as a,defineCommands as o,defineDOMEventHandler as s,defineHistory as c,defineKeymap as l,defineMarkSpec as u,defineMarkView as d,defineNodeAttr as f,defineNodeSpec as p,definePlugin as m,getMarkRange as ee,getMarkType as te,getNodeType as ne,isAllSelection as re,isApple as ie,isAtBlockStart as ae,isNodeSelection as oe,isTextSelection as h,toggleNode as se,union as g,unsetBlockType as ce,withPriority as le,withPriority as _,withSkipCodeBlock as ue}from"@prosekit/core";import{definePlaceholder as de}from"@prosekit/extensions/placeholder";import{defineReadonly as fe}from"@prosekit/extensions/readonly";import{isElementLike as pe,once as v}from"@ocavue/utils";import{defineBlockquote as me}from"@prosekit/extensions/blockquote";import{defineDoc as he}from"@prosekit/extensions/doc";import{defineGapCursor as ge}from"@prosekit/extensions/gap-cursor";import{defineModClickPrevention as _e}from"@prosekit/extensions/mod-click-prevention";import{defineText as ve}from"@prosekit/extensions/text";import{defineVirtualSelection as ye}from"@prosekit/extensions/virtual-selection";import{NodeSelection as be,Plugin as y,PluginKey as b,Selection as xe,TextSelection as x}from"@prosekit/pm/state";import{Decoration as S,DecorationSet as C}from"@prosekit/pm/view";import{LanguageDescription as Se}from"@codemirror/language";import{languages as Ce}from"@codemirror/language-data";import{classHighlighter as we,highlightTree as Te}from"@lezer/highlight";import{defineCodeBlock as Ee,defineCodeBlockHighlight as De}from"@prosekit/extensions/code-block";import{createParser as Oe}from"prosemirror-highlight/lezer";import{defineTextBlockEnterRule as ke}from"@prosekit/extensions/enter-rule";import{defineInputRule as Ae,defineTextBlockInputRule as je}from"@prosekit/extensions/input-rule";import{DOMSerializer as Me,Mark as Ne,Slice as w}from"@prosekit/pm/model";import{defineHeadingCommands as Pe,defineHeadingInputRule as Fe,defineHeadingSpec as Ie}from"@prosekit/extensions/heading";import{defineHorizontalRule as Le}from"@prosekit/extensions/horizontal-rule";import{AddMarkStep as Re,AddNodeMarkStep as ze,RemoveMarkStep as Be,RemoveNodeMarkStep as Ve,ReplaceStep as He,Step as Ue,StepResult as We,Transform as Ge}from"@prosekit/pm/transform";import{GFM as Ke,parser as qe}from"@lezer/markdown";import{defineListCommands as Je,defineListDropIndicator as Ye,defineListKeymap as Xe,defineListSerializer as Ze,defineListSpec as Qe,moveList as $e,toggleList as et,wrapInList as tt}from"@prosekit/extensions/list";import{createListRenderingPlugin as nt,createSafariInputMethodWorkaroundPlugin as rt,createToggleCollapsedCommand as it,handleListMarkerMouseDown as at,unwrapListSlice as ot,wrappingListInputRule as T}from"prosemirror-flat-list";import{defineTableCellSpec as st,defineTableCommands as ct,defineTableDropIndicator as lt,defineTableEditingPlugin as ut,defineTableHeaderCellSpec as dt,defineTableRowSpec as ft,defineTableSpec as pt,deleteTable as mt,isCellSelection as ht}from"@prosekit/extensions/table";import{defineParagraphCommands as gt,defineParagraphKeymap as _t}from"@prosekit/extensions/paragraph";import{closeHistory as vt}from"@prosekit/pm/history";import yt from"rehype-parse";import bt from"rehype-remark";import xt from"remark-gfm";import St from"remark-stringify";import{unified as Ct}from"unified";import{registerResizableHandleElement as wt,registerResizableRootElement as Tt}from"@prosekit/web/resizable";import{triggerAutocomplete as Et}from"@prosekit/extensions/autocomplete";function E(e,t,n){let r=e.doc.content.size;if(t<0||t>r)return;let i=e.doc.resolve(t);if(!(!i.parent.isTextblock||i.parent.type.spec.code))return ee(i,n)}const Dt=new Set([`mdMark`,`mdLinkUri`,`mdLinkTitle`]),D=new b(`mark-mode`);function Ot(e){return D.getState(e)}function kt(e){return new y({key:D,state:{init:()=>e,apply:(e,t)=>e.getMeta(D)??t},props:{attributes:t=>({"data-mark-mode":Ot(t)??e}),decorations:e=>Ot(e)===`focus`?Nt(e):void 0,clipboardTextSerializer:(e,t)=>Ot(t.state)===`show`?``:Mt(e)}})}function At(e){return(t,n)=>O(t)===e?!1:(n?.(t.tr.setMeta(D,e)),!0)}function jt(e){return g(m(kt(e)),o({setMarkMode:At}))}function O(e){return D.getState(e)}function Mt(e){let t=[];return e.content.forEach(e=>{let n=[];e.descendants(e=>!e.isText||!e.text?!0:(e.marks.some(e=>Dt.has(e.type.name))||n.push(e.text),!1)),t.push(n.join(``))}),t.join(`
|
|
2
|
+
`)}function Nt(e){let{selection:t}=e;if(!t.empty)return C.empty;let n=t.$head,{parent:r}=n;if(!r.isTextblock||r.type.spec.code)return C.empty;let i=ee(n,te(e.schema,`mdPack`));return i?C.create(e.doc,[S.inline(i.from,i.to,{class:`show`})]):C.empty}const Pt=[`mdImage`,`mdWikilink`,`mdFile`];function k(e,t){let n=O(t);return n?e.flatMap(e=>e.modes.includes(n)?[e.name]:[]):[]}function Ft(e,t,n){for(let r of n){let n=E(e,t,r);if(n)return n}}function A(e,t,n){let r=Ft(e,t,n);return r&&r.to===t?r:void 0}function It(e,t,n){let r=Ft(e,t,n);return r&&r.from===t?r:void 0}function Lt(e,t){let{from:n,to:r,empty:i}=e.selection;if(i)return;let a=Ft(e,n,t);return a&&a.from===n&&a.to===r?a:void 0}function Rt(e,t){return x.create(e.doc,t.from,t.to)}function zt(e){return(t,n)=>{let r=k(e,t);if(r.length===0||!h(t.selection))return!1;let i=t.selection;if(i.empty){let e=It(t,i.from,r);if(e)return n?.(t.tr.setSelection(Rt(t,e))),!0;if(A(t,i.from,r)){let e=t.doc.resolve(i.from);return i.from>=e.end()?!1:(n?.(t.tr.setSelection(x.create(t.doc,i.from+1))),!0)}return!1}let a=Lt(t,r);return a?(n?.(t.tr.setSelection(x.create(t.doc,a.to))),!0):!1}}function Bt(e){return(t,n)=>{let r=k(e,t);if(r.length===0||!h(t.selection))return!1;let i=t.selection;if(i.empty){let e=A(t,i.from,r);return e?(n?.(t.tr.setSelection(Rt(t,e))),!0):!1}let a=Lt(t,r);return a?(n?.(t.tr.setSelection(x.create(t.doc,a.from))),!0):!1}}function Vt(e){return(t,n)=>{let r=k(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=A(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!It(t,i,r)||i<=t.doc.resolve(i).start()?!1:(n?.(t.tr.delete(i-1,i)),!0)}}function Ht(e){return(t,n)=>{let r=k(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=It(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!A(t,i,r)||i>=t.doc.resolve(i).end()?!1:(n?.(t.tr.delete(i,i+1)),!0)}}const Ut=`md-atom-selected`;function Wt(e){return new y({key:new b(`atom-mark-selection`),props:{decorations:t=>{let n=k(e,t);if(n.length===0)return;let r=Lt(t,n);if(r)return C.create(t.doc,[S.inline(r.from,r.to,{class:Ut})]);let{from:i,to:a,empty:o}=t.selection;if(o)return null;let s=[];return t.doc.nodesBetween(i,a,(e,t)=>{e.marks.some(e=>n.includes(e.type.name))&&s.push(S.inline(t,t+e.nodeSize,{class:Ut}))}),C.create(t.doc,s)}}})}function Gt({marks:e}){return g(_(l({ArrowRight:zt(e),ArrowLeft:Bt(e),Backspace:Vt(e),Delete:Ht(e)}),t.high),m(Wt(e)))}const j=new Map,Kt=new Map;async function qt(e){let t=j.get(e);if(t!==void 0)return t;let n=Se.matchLanguageName(Ce,e,!0);if(!n)return j.set(e,null),null;let r=n.support;if(!r)try{r=await n.load()}catch(t){return console.error(`[meowdown] Failed to load language "${e}":`,t),j.set(e,null),null}return j.set(e,r),r}function Jt(e,t){let n=Kt.get(e);if(n)return n;let r=Oe({parse:e=>t.language.parser.parse(e.content),highlighter:we});return Kt.set(e,r),r}const Yt=e=>{let t=e.language?.trim();if(!t)return[];let n=j.get(t);return n===null?[]:n?Jt(t,n)(e):qt(t).then(()=>void 0)};function Xt(){return De({parser:Yt,nodeTypes:[`codeBlock`]})}function Zt(e,t){let n=t.language.parser.parse(e),r=[];return Te(n,we,(e,t,n)=>{r.push([e,t,n])}),r}function Qt(e,t){let n=t.trim();if(!n)return[];let r=j.get(n);return r===null?[]:r?Zt(e,r):qt(n).then(t=>t?Zt(e,t):[])}function $t(){return f({type:`codeBlock`,attr:`fenceStyle`,default:null,toDOM:e=>e==null?null:[`data-fence-style`,e],parseDOM:e=>{let t=e.getAttribute(`data-fence-style`);return t===`tilde`||t===`indented`?t:null}})}function en(){return f({type:`codeBlock`,attr:`fenceLength`,default:null,toDOM:e=>e==null?null:[`data-fence-length`,String(e)],parseDOM:e=>{let t=e.getAttribute(`data-fence-length`);if(t==null)return null;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>3?n:null}})}function tn(e){return{language:e[1]||``,fenceStyle:`tilde`}}function nn(){return je({regex:/^~~~(\S*)\s$/,type:`codeBlock`,attrs:tn})}function rn(){return ke({regex:/^~~~(\S*)$/,type:`codeBlock`,attrs:tn})}function an(){return g(Ee(),$t(),en(),nn(),rn())}function on(e,t){return(n,r)=>{if(r){let i=x.create(n.doc,e,t);r(n.tr.setSelection(i))}return!0}}function sn(e,t,n){return(r,i)=>{if(i){let a=x.between(e,t,n);i(r.tr.setSelection(a))}return!0}}function cn(e){return(t,n)=>{if(!e.trim())return!1;let r=X(e,{nodes:Qa(t.schema)}).content;if(r.childCount===0)return!1;let i=r.childCount===1&&r.child(0).type.name===`paragraph`?new w(r,1,1):new w(r,0,w.maxOpen(r).openEnd);if(n){let e=t.tr,r=e.selection;(!h(r)||!r.empty)&&e.setSelection(x.near(r.$from)),n(e.replaceSelection(i).scrollIntoView())}return!0}}function ln(){return o({insertMarkdown:cn,selectText:on,selectTextBetween:sn})}const un=(e,t,n)=>{let{selection:r}=e;return r.empty||n?.composing?!1:(t?.(e.tr.setSelection(x.near(r.$head))),!0)};function dn(){return _(l({Escape:un}),t.low)}function fn(){return f({type:`doc`,attr:`frontmatter`,default:null})}function pn(){return p({name:`heading`,whitespace:`pre`})}function mn(){return f({type:`heading`,attr:`setextUnderline`,default:null,toDOM:e=>e==null?null:[`data-setext-underline`,String(e)],parseDOM:e=>{let t=e.getAttribute(`data-setext-underline`);if(t==null)return null;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>0?n:null}})}function hn(){return f({type:`heading`,attr:`closingHashes`,default:null,toDOM:e=>e==null?null:[`data-closing-hashes`,String(e)],parseDOM:e=>{let t=e.getAttribute(`data-closing-hashes`);if(t==null)return null;let n=Number.parseInt(t,10);return Number.isSafeInteger(n)&&n>0?n:null}})}function M(e){return ue(se({type:`heading`,attrs:{level:e}}))}const gn=(e,t,n)=>ae(e,n)?.parent.type.name===`heading`?ce()(e,t,n):!1;function _n(){return l({"Mod-1":M(1),"Mod-2":M(2),"Mod-3":M(3),"Mod-4":M(4),"Mod-5":M(5),"Mod-6":M(6),Backspace:gn})}function vn(){return g(Ie(),pn(),mn(),hn(),Fe(),Pe(),_n())}const yn=new Set([`mdMark`,`mdLinkUri`,`mdLinkTitle`]);function bn(e,t){if(t<0||t+1>e.doc.content.size)return;let n=e.doc.resolve(t),r=n.parent.maybeChild(n.index());if(!(r==null||!r.isText))return r.marks}function N(e,t){let n=bn(e,t);return n==null?!1:n.some(e=>yn.has(e.type.name))}function P(e,t){if(t<0||t>e.doc.content.size)return!1;let n=e.doc.resolve(t);return n.parent.isTextblock&&!n.parent.type.spec.code}function F(e,t){if(!P(e,t))return;let n=e.doc.resolve(t).start(),r=t;for(;r>n&&N(e,r-1);)r--;return r<t?{from:r,to:t}:void 0}function I(e,t){if(!P(e,t))return;let n=e.doc.resolve(t).end(),r=t;for(;r<n&&N(e,r);)r++;return r>t?{from:t,to:r}:void 0}function xn(e,t){return N(e,t-1)&&N(e,t)}function Sn(e,t){if(!xn(e,t))return;let n=F(e,t),r=I(e,t);if(!(n==null||r==null))return{from:n.from,to:r.to}}function Cn(e,t,n){let r=bn(e,t);return r!=null&&n.isInSet(r)}function wn(e,t){let n=bn(e,t);if(n==null)return;let r=te(e.schema,`mdPack`),i=n.filter(e=>e.type===r);if(i.length===0)return;let a=e.doc.resolve(t),o=a.start(),s=a.end(),c;for(let n of i){let r=t;for(;r>o&&Cn(e,r-1,n);)r--;let i=t+1;for(;i<s&&Cn(e,i,n);)i++;(c==null||i-r<c.to-c.from)&&(c={from:r,to:i})}return c}function L(e,t,n){let r=wn(e,n===`from`?t.from:t.to-1);return r==null?!1:n===`from`?r.from===t.from:r.to===t.to}function Tn(e,t,n){let r=L(e,t,`from`),i=L(e,t,`to`);return r&&!i?t.from:i&&!r?t.to:n-t.from<=t.to-n?t.from:t.to}function En(e,t,n,r){if(!P(e,n))return n;let i=Sn(e,n);if(i!=null)return r?Tn(e,i,n):n>=t?i.to:i.from;if(!r)return n;let a=F(e,n);if(a!=null&&L(e,a,`from`))return a.from;let o=I(e,n);return o!=null&&L(e,o,`to`)?o.to:n}function Dn(e,t){if(!P(e,t))return;let n=N(e,t-1),r=N(e,t);if(n!==r)return r?`left`:`right`}function On(e,t){let n=wn(e,t);if(n==null)return[];let r=I(e,n.from),i=F(e,n.to),a=[];return i!=null&&a.push(i),r!=null&&(i==null||r.from!==i.from)&&a.push(r),a}const kn=new b(`meowdown-hidden-run-snap`),An=new b(`meowdown-hidden-run-beforeinput`);function jn(){let e=!1;return new y({key:kn,props:{handleDOMEvents:{compositionstart:()=>(e=!0,!1),compositionend:()=>(e=!1,!1)}},appendTransaction:(t,n,r)=>{if(e||O(r)!==`hide`)return null;let i=r.selection;if(!h(i))return null;let a=t.some(e=>e.getMeta(`pointer`)!=null);if(i.empty){let e=En(r,n.selection.head,i.head,a);return e===i.head?null:r.tr.setSelection(x.create(r.doc,e))}let o=Sn(r,i.from)?.from??i.from,s=Sn(r,i.to)?.to??i.to;if(o===i.from&&s===i.to)return null;let c=i.anchor===i.from?o:s,l=i.head===i.from?o:s;return r.tr.setSelection(x.create(r.doc,c,l))}})}const Mn=(e,t)=>{if(O(e)!==`hide`)return!1;let n=e.selection;if(!h(n)||!n.empty)return!1;let r=En(e,n.head,n.head,!0);return r===n.head||t?.(e.tr.setSelection(x.create(e.doc,r))),!1};function Nn(e){return(t,n)=>{if(O(t)!==`hide`)return!1;let r=t.selection;if(!h(r)||!r.empty)return!1;let i=r.$head;if(!i.parent.isTextblock||i.parent.type.spec.code)return!1;let a=e===-1?F(t,r.head):I(t,r.head);if(a==null)return!1;let o=On(t,e===-1?a.to-1:a.from),s=t.tr;if(o.length===0)s.delete(a.from,a.to);else for(let e of o)s.delete(e.from,e.to);return n?.(s),!0}}const Pn=Nn(-1),Fn=Nn(1);function In(){return new y({key:An,props:{handleDOMEvents:{beforeinput:(e,t)=>{if(e.composing)return!1;let n=t.inputType===`deleteContentBackward`?Pn:t.inputType===`deleteContentForward`?Fn:void 0;return n==null||!n(e.state,e.dispatch)?!1:(t.preventDefault(),!0)}}}})}function Ln(){return g(m(jn()),m(In()),_(l({Enter:Mn,Backspace:Pn,Delete:Fn}),t.highest))}function Rn(){return f({type:`horizontalRule`,attr:`marker`,default:null,toDOM:e=>e?[`data-hr-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-hr-marker`)})}function zn(){return g(Le(),Rn())}function Bn(){return p({name:`htmlComment`,group:`block`,atom:!0,selectable:!1,attrs:{content:{default:``}},toDOM:e=>[`div`,{"data-html-comment":e.attrs.content,style:`display: none`}],parseDOM:[{tag:`div[data-html-comment]`,getAttrs:e=>({content:e.getAttribute(`data-html-comment`)??``})}]})}function Vn(e){let[t,n,r]=e;return[t,n,r.map(e=>e.toJSON())]}function Hn(e,t){let[n,r,i]=t;return[n,r,i.map(t=>Ne.fromJSON(e,t))]}var R=class e extends Ue{constructor(e){super(),this.chunks=e}apply(e){if(this.chunks.length===0)return We.ok(e);let t=e.content.size,n;for(let[r,i,a]of this.chunks){if(r>=i)continue;let o=Math.max(0,Math.min(r,t)),s=Math.max(o,Math.min(i,t));o>=s||e.nodesBetween(o,s,(t,r)=>{if(!t.isText)return!0;let i=Math.max(o,r),c=Math.min(s,r+t.nodeSize);if(i>=c)return!1;let l=t.marks;for(let t of l)t.isInSet(a)||(n??=new Ge(e),n.removeMark(i,c,t));for(let t of a)t.isInSet(l)||(n??=new Ge(e),n.addMark(i,c,t));return!1})}return We.ok(n?n.doc:e)}invert(e){if(this.chunks.length===0)return Un;let t=this.chunks[0][0],n=this.chunks[0][1];for(let[,e]of this.chunks)e>n&&(n=e);let r=e.content.size,i=Math.max(0,Math.min(t,r)),a=Math.max(i,Math.min(n,r));return new He(i,a,e.slice(i,a),!1)}map(e){return null}toJSON(){return{stepType:`batchSetMark`,chunks:this.chunks.map(Vn)}}static fromJSON(t,n){let r=n.chunks;return new e(r.map(e=>Hn(t,e)))}};Ue.jsonID(`batchSetMark`,R);const Un=new R([]),Wn=new Set([`com`,`br`,`net`,`jp`,`org`,`in`,`de`,`ru`,`it`,`fr`]),Gn=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;function Kn(e){let t=e.indexOf(`/`);return t===-1?e:e.slice(0,t)}function qn(e){let t=e.split(`.`);if(t.length<2)return!1;let n=t[t.length-1].toLowerCase();if(!Wn.has(n)||t[t.length-2].length<3)return!1;for(let e of t)if(e.length>63||!Gn.test(e))return!1;return!0}function z(e){return e===32||e===9||e===10||e===13}const Jn=/^[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:\/[^\s<]*)?/i,Yn=/[\s(*_~]/;function Xn(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45}function Zn(e,t,n){let r=0;for(let i=0;i<t;i++)e[i]===n&&r++;return r}function Qn(e){let t=e.length;for(;;){let n=e[t-1];if(/[?!.,:*_~]/.test(n)||n===`)`&&Zn(e,t,`)`)>Zn(e,t,`(`))t--;else if(n===`;`){let n=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(e.slice(0,t));if(!n)break;t=n.index}else break}return t}const $n={parseInline:[{name:`BareAutolink`,before:`Link`,parse(e,t,n){if(!Xn(t)||e.hasOpenLink)return-1;let r=e.slice(n-1,n);if(r!==``&&!Yn.test(r))return-1;let i=Jn.exec(e.slice(n,e.end));if(!i)return-1;let a=Qn(i[0]);return a===0||!qn(Kn(i[0].slice(0,a)))?-1:e.addElement(e.elt(`URL`,n,n+a))}}]};function er(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45||e===95||e>127&&/[\p{L}\p{N}]/u.test(String.fromCharCode(e))}function tr(e){return e>=65&&e<=90||e>=97&&e<=122||e>127&&/\p{L}/u.test(String.fromCharCode(e))}const nr={defineNodes:[{name:`Hashtag`}],parseInline:[{name:`Hashtag`,parse(e,t,n){if(t!==35||!/\s|^$/.test(e.slice(n-1,n)))return-1;let r=n+1,i=!1;for(;r<e.end;){let t=e.char(r);if(!er(t))break;i||=tr(t),r++}return i?e.addElement(e.elt(`Hashtag`,n,r)):-1}}]},rr={resolve:`Highlight`,mark:`HighlightMark`},ir=/[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~\u{A1}\u{2010}-\u{2027}]/u,ar={defineNodes:[{name:`Highlight`},{name:`HighlightMark`}],parseInline:[{name:`Highlight`,after:`Emphasis`,parse(e,t,n){if(t!==61||e.char(n+1)!==61||e.char(n+2)===61)return-1;let r=e.slice(n-1,n),i=e.slice(n+2,n+3),a=/\s|^$/.test(r),o=/\s|^$/.test(i),s=ir.test(r),c=ir.test(i);return e.addDelimiter(rr,n,n+2,!o&&(!c||a||s),!a&&(!s||o||c))}}]},or={defineNodes:[{name:`Wikilink`},{name:`WikilinkMark`}],parseInline:[{name:`Wikilink`,before:`Link`,parse(e,t,n){if(t!==91||e.char(n+1)!==91)return-1;let r=!1;for(let t=n+2;t<e.end-1;t++){let i=e.char(t);if(i===93){if(e.char(t+1)!==93||!r)return-1;let i=t+2;return e.addElement(e.elt(`Wikilink`,n,i,[e.elt(`WikilinkMark`,n,n+2),e.elt(`WikilinkMark`,t,i)]))}if(i===91||i===10)return-1;i!==32&&i!==9&&(r=!0)}return-1}}]};function sr(e){return e.end}const cr=qe.configure([Ke,nr,or,$n,ar]),lr=cr.configure({parseInline:[{name:`SkipInline`,before:`Escape`,parse:sr}]});function B(e){return cr.parseInline(e,0)}function V(e,t,n=[]){for(let r of e)t(r)&&n.push(r),V(r.children,t,n);return n}function ur(e){let t={};for(let n of e.nodeSet.types)t[n.name]=n.id;return t}const H=ur(cr),dr=/^<!--\s*(\{[^}]*\})\s*-->$/,fr=/<!--\s*\{[^}]*\}\s*-->$/;function pr(e){let t=dr.exec(e.trim());if(!t)return;let n;try{n=JSON.parse(t[1])}catch{return}if(typeof n!=`object`||!n)return;let r=mr(n);return Object.keys(r).length>0?r:void 0}function mr(e){let t={},{width:n,height:r}=e;return typeof n==`number`&&Number.isFinite(n)&&n>0&&(t.width=Math.round(n)),typeof r==`number`&&Number.isFinite(r)&&r>0&&(t.height=Math.round(r)),t}function hr(e){return`<!-- ${JSON.stringify(e)} -->`}function gr(e){return e.replace(fr,``)}function _r(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}function vr(e){let t=e.replace(/^\[\[/,``).replace(/\]\]$/,``),n=t.indexOf(`|`);return n<0?{target:t.trim(),display:``}:{target:t.slice(0,n).trim(),display:t.slice(n+1).trim()}}function yr(){return e=>{let t=e.attrs,n=document.createElement(`span`);n.className=`md-wikilink-view md-atom-view`;let r=document.createElement(`span`);r.className=`md-wikilink-view-preview md-atom-view-preview`,r.contentEditable=`false`,r.dataset.testid=`wikilink`,n.appendChild(r);let i=document.createElement(`span`);i.className=`md-wikilink-view-label`,i.contentEditable=`false`,i.textContent=t.display||t.target,r.appendChild(i);let a=document.createElement(`span`);return a.className=`md-wikilink-view-content md-atom-view-content`,n.appendChild(a),{dom:n,contentDOM:a,ignoreMutation:e=>!a.contains(e.target)}}}function br(){return d({name:`mdWikilink`,constructor:yr()})}const xr=new Map([[H.Emphasis,`mdEm`],[H.StrongEmphasis,`mdStrong`],[H.InlineCode,`mdCode`],[H.Strikethrough,`mdDel`],[H.Highlight,`mdHighlight`],[H.EmphasisMark,`mdMark`],[H.CodeMark,`mdMark`],[H.LinkMark,`mdMark`],[H.StrikethroughMark,`mdMark`],[H.HighlightMark,`mdMark`],[H.URL,`mdLinkUri`],[H.LinkTitle,`mdLinkTitle`],[H.Hashtag,`mdTag`],[H.WikilinkMark,`mdMark`]]);function Sr(e,t,n){let r=B(t),i=[];return Tr(r,[],0,t.length,t,e,i,n),i}function Cr(e){if(/^[a-z][a-z0-9+.-]*:/i.test(e))return e;if(/^[^\s@]+@[^\s@]+$/.test(e))return`mailto:${e}`;if(/^www\./i.test(e)||qn(Kn(e)))return`https://${e}`}function wr(e){return e.slice(1,-1).replaceAll(/\\(.)/g,`$1`)}function Tr(e,t,n,r,i,a,o,s){let c=n;for(let n=0;n<e.length;n++){let r=e[n];r.from>c&&U(o,c,r.from,t);let l=r.type;if(l===H.Link){let e=Or(r,t,i,a,s);e?U(o,r.from,r.to,e):kr(r,t,i,a,o)}else if(l===H.Image){let s=Ar(r,e[n+1],i);jr(r,t,i,a,o,s),s&&n++,c=s?s.to:r.to;continue}else if(l===H.Wikilink)Mr(r,t,i,a,o);else if(l===H.URL){let e=Cr(i.slice(r.from,r.to)),n=e?a.mdLinkText.create({href:e}):a.mdLinkUri.create();U(o,r.from,r.to,[...t,n])}else{let e;l===H.Emphasis?e=`italic`:l===H.StrongEmphasis?e=`bold`:l===H.InlineCode?e=`code`:l===H.Strikethrough?e=`strike`:l===H.Highlight?e=`highlight`:l===H.Autolink&&(e=`autolink`);let n=e?[...t,a.mdPack.create({key:e})]:t,c=xr.get(l),u=c?[...n,a[c].create()]:n;r.children.length===0?U(o,r.from,r.to,u):Tr(r.children,u,r.from,r.to,i,a,o,s)}c=r.to}c<r&&U(o,c,r,t)}function Er(e){let t=-1,n=-1,r=null,i=null,a=0;for(let o of e.children)o.type===H.LinkMark?(a++,a===1&&(t=o.to),a===2&&(n=o.from)):o.type===H.URL&&r===null?r=o:o.type===H.LinkTitle&&i===null&&(i=o);return{labelFrom:t,labelTo:n,urlNode:r,titleNode:i}}function Dr(e){let t=e.split(/[?#]/,1)[0],n=t.split(/[/\\]/).findLast(Boolean)??t;try{return decodeURIComponent(n)}catch{return n}}function Or(e,t,n,r,i){let a=i?.resolveFileLink;if(!a)return;let{labelFrom:o,labelTo:s,urlNode:c,titleNode:l}=Er(e);if(o<0||s<0||!c)return;let u=n.slice(c.from,c.to);if(!u)return;let d=n.slice(o,s),f=l?wr(n.slice(l.from,l.to)):``;if(!a({href:u,label:d,title:f}))return;let p=d||Dr(u);return[...t,r.mdFile.create({href:u,name:p,title:f})]}function kr(e,t,n,r,i){let{labelTo:a,urlNode:o,titleNode:s}=Er(e),c=o?n.slice(o.from,o.to):``,l=s?wr(n.slice(s.from,s.to)):``,u=c?r.mdLinkText.create({href:c}):null,d=e=>a>=0&&e<a&&u!==null,f=r.mdPack.create({key:`link`,data:{href:c,title:l}}),p=[...t,f],m=e.from;for(let t of e.children){if(t.from>m){let e=d(m)?[...p,u]:p;U(i,m,t.from,e)}let e=d(t.from)?[...p,u]:p;if(t.type===H.Wikilink){Mr(t,e,n,r,i),m=t.to;continue}let a=xr.get(t.type),o=a?[...e,r[a].create()]:e;t.children.length===0?U(i,t.from,t.to,o):Tr(t.children,o,t.from,t.to,n,r,i,void 0),m=t.to}m<e.to&&U(i,m,e.to,p)}function Ar(e,t,n){if(!t||t.type!==H.Comment||t.from!==e.to)return;let r=pr(n.slice(t.from,t.to));if(r)return{magic:r,to:t.to}}function jr(e,t,n,r,i,a){let o=e.children.find(e=>e.type===H.URL);if(!o){kr(e,t,n,r,i);return}let s=e.children.filter(e=>e.type===H.LinkMark),c=e.children.find(e=>e.type===H.LinkTitle),l=n.slice(o.from,o.to),u=s.length>=2?n.slice(s[0].to,s[1].from):``,d=c?wr(n.slice(c.from,c.to)):``,f=a?.magic.width??null,p=a?.magic.height??null,m=a?.to??e.to;U(i,e.from,m,[...t,r.mdImage.create({src:l,alt:u,title:d,width:f,height:p})])}function Mr(e,t,n,r,i){let{target:a,display:o}=vr(n.slice(e.from,e.to));U(i,e.from,e.to,[...t,r.mdWikilink.create({target:a,display:o})])}function U(e,t,n,r){if(t>=n)return;let i=e.at(-1);if(i&&i[1]===t&&_r(i[2],r)){e[e.length-1]=[i[0],n,i[2]];return}e.push([t,n,r])}const Nr=`inline-marks-applied`;let Pr=0,Fr=0;function Ir(e,t){let n=1/0,r=-1/0;for(let t of e)for(let e of t.mapping.maps)e.forEach((e,t,i,a)=>{i<n&&(n=i),a>r&&(r=a)});let i=t.doc.content.size;return n>r?{from:0,to:i}:{from:Math.max(0,n),to:Math.min(i,r)}}function Lr(e){let t=new WeakMap;function n(n,r,i){let a=t.get(n);if(a?Fr++:(Pr++,a=Sr(Xa(i),n.textContent,e),t.set(n,a)),r===0)return a;let o=[];for(let[e,t,n]of a)o.push([e+r,t+r,n]);return o}function r(e,t){let r=[];return e.doc.nodesBetween(t.from,t.to,(t,i)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;if(t.childCount===0)return!1;let a=n(t,i+1,e.schema);return a.length>0&&r.push(...a),!1}),r}return new y({key:new b(`inline-mark`),appendTransaction(e,t,n){for(let t of e)if(t.getMeta(Nr))return null;let i=r(n,Ir(e,n));if(i.length===0)return null;let a=n.tr.step(new R(i));return a.setMeta(Nr,!0),a.setMeta(`addToHistory`,!1),a},view(e){return e.dispatch(Rr(e.state)),{}}})}function Rr(e){return e.tr.setMeta(`inline-marks-trigger`,!0)}function zr(e){return m(Lr(e))}function Br(){return u({name:`mdImage`,inclusive:!1,attrs:{src:{default:``},alt:{default:``},title:{default:``},width:{default:null},height:{default:null}},toDOM:()=>[`span`,{class:`md-image`},0],parseDOM:[{tag:`span.md-image`}]})}function Vr(){return u({name:`mdMark`,inclusive:!1,toDOM:()=>[`span`,{class:`md-mark`},0],parseDOM:[{tag:`span.md-mark`}]})}function Hr(){return u({name:`mdEm`,toDOM:()=>[`em`,0],parseDOM:[{tag:`em`}]})}function Ur(){return u({name:`mdStrong`,toDOM:()=>[`strong`,0],parseDOM:[{tag:`strong`}]})}function Wr(){return u({name:`mdCode`,toDOM:()=>[`code`,0],parseDOM:[{tag:`code`}]})}function Gr(){return u({name:`mdLinkText`,inclusive:!1,attrs:{href:{default:``}},toDOM:e=>[`a`,{class:`md-link`,href:e.attrs.href},0],parseDOM:[{tag:`a`,getAttrs:e=>({href:e.getAttribute(`href`)??``})}]})}function Kr(){return u({name:`mdLinkUri`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-uri`},0],parseDOM:[{tag:`span.md-link-uri`}]})}function qr(){return u({name:`mdLinkTitle`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-title`},0],parseDOM:[{tag:`span.md-link-title`}]})}function Jr(){return u({name:`mdDel`,toDOM:()=>[`del`,0],parseDOM:[{tag:`del`}]})}function Yr(){return u({name:`mdHighlight`,toDOM:()=>[`mark`,0],parseDOM:[{tag:`mark`}]})}function Xr(){return u({name:`mdTag`,toDOM:()=>[`span`,{class:`md-tag`},0],parseDOM:[{tag:`span.md-tag`}]})}function Zr(){return u({name:`mdWikilink`,inclusive:!1,attrs:{target:{default:``},display:{default:``}},toDOM:()=>[`span`,{class:`md-wikilink`},0],parseDOM:[{tag:`span.md-wikilink`}]})}function Qr(){return u({name:`mdFile`,inclusive:!1,attrs:{href:{default:``},name:{default:``},title:{default:``}},toDOM:()=>[`span`,{class:`md-file`},0],parseDOM:[{tag:`span.md-file`}]})}function $r(){return u({name:`mdPack`,excludes:``,inclusive:!1,attrs:{key:{},data:{default:null}},toDOM:e=>[`span`,{class:`md-pack`,"data-key":e.attrs.key},0],parseDOM:[{tag:`span.md-pack`}]})}function ei(){return g(Vr(),Hr(),Ur(),Wr(),Gr(),Kr(),qr(),Jr(),Yr(),Xr(),Zr(),Br(),Qr(),$r())}function ti(e,t,n=0){let r=n,i=0;for(let n=0;n<e.length;n++)e.charCodeAt(n)===t?(i++,i>r&&(r=i)):i=0;return r}function ni(e,t=0){return ti(e,96,t)}const W={em:{node:H.Emphasis,delim:`*`},strong:{node:H.StrongEmphasis,delim:`**`},code:{node:H.InlineCode,delim:"`"},del:{node:H.Strikethrough,delim:`~~`},highlight:{node:H.Highlight,delim:`==`}},ri=new Set([H.EmphasisMark,H.CodeMark,H.LinkMark,H.StrikethroughMark,H.HighlightMark]);function ii(e){return[e.children[0],e.children.at(-1)]}function ai(e){let{type:t,children:n}=e;if(t===H.Emphasis||t===H.StrongEmphasis||t===H.Strikethrough||t===H.Highlight)return[n[0].to,n.at(-1).from];if(t===H.Link||t===H.Image){let e=n.find((e,t)=>t>0&&e.type===H.LinkMark);return e?[n[0].to,e.from]:null}return null}function oi(e,t,n){for(let r of e){if(r.to<=t||r.from>=n||t<=r.from&&r.to<=n)continue;let i=ai(r);return i&&i[0]<=t&&n<=i[1]?oi(r.children,t,n):oi(e,Math.min(t,r.from),Math.max(n,r.to))}return[t,n]}function si(e,t,n){for(let r of e)if(!(r.to<=t||r.from>=n)&&(t>r.from||r.to>n))return si(e,Math.min(t,r.from),Math.max(n,r.to));return[t,n]}function ci(e,t,n){for(;t<n&&z(e.charCodeAt(t));)t++;for(;n>t&&z(e.charCodeAt(n-1));)n--;return[t,n]}function li(e,t,n,r){let i=V(B(e),e=>e.type===r.node||ri.has(e.type));for(let r=t;r<n;r++)if(!z(e.charCodeAt(r))&&i.every(e=>!(e.from<=r&&r<e.to)))return!1;return!0}function ui(e,t,n,r,i){let a=B(e),o=V(a,e=>e.type===r.node);return i?pi(e,o,t,n):di(e,a,o,t,n,r)}function di(e,t,n,r,i,a){for(let e=0;e!==i-r;){e=i-r,[r,i]=oi(t,r,i);for(let e of n)e.to===r&&(r=e.from),e.from===i&&(i=e.to)}let o=[];for(let e of n)if(r<=e.from&&e.to<=i){let[t,n]=ii(e);o.push({from:t.from,to:t.to,insert:``}),o.push({from:n.from,to:n.to,insert:``})}let[s,c]=fi(e,r,i,o,a);return o.push({from:r,to:r,insert:s},{from:i,to:i,insert:c}),o}function fi(e,t,n,r,i){if(i.node!==H.InlineCode)return[i.delim,i.delim];let a=e.slice(t,n);for(let e of[...r].sort((e,t)=>t.from-e.from))a=a.slice(0,e.from-t)+a.slice(e.to-t);let o="`".repeat(ni(a)+1),s=a.startsWith("`")||a.endsWith("`")?` `:``;return[o+s,s+o]}function pi(e,t,n,r){let i=[];for(let a of t){if(a.to<=n||a.from>=r)continue;let[t,o]=ii(a),s=Math.max(n,t.to),c=Math.min(r,o.from);for(s>=c&&([s,c]=[t.to,o.from]),[s,c]=si(a.children.slice(1,-1),s,c);s>t.to&&z(e.charCodeAt(s-1));)s--;for(;c<o.from&&z(e.charCodeAt(c));)c++;s>t.to?i.push({from:s,to:s,insert:e.slice(o.from,o.to)}):i.push({from:t.from,to:t.to,insert:``}),c<o.from?i.push({from:c,to:c,insert:e.slice(t.from,t.to)}):i.push({from:o.from,to:o.to,insert:``})}return i}function mi(e,t,n){let{delim:r}=n,i=r.length;if(e.slice(t-i,t)===r&&e.startsWith(r,t)&&e[t-i-1]!==r[0]&&e[t+i]!==r[0])return{kind:`unwrap`,from:t-i,to:t+i};let a=B(e),o=V(a,e=>e.type===n.node).findLast(e=>e.from<=t&&t<=e.to);if(o){let[e,n]=ii(o);return{kind:`move`,pos:t===o.from?e.to:t===o.to?n.from:o.to}}return hi(a,t)||e[t-1]===r[0]||e[t]===r[0]?null:{kind:`insert`,pos:t}}function hi(e,t){for(let n of e)if(n.from<t&&t<n.to){let e=ai(n);return!e||t<e[0]||t>e[1]?!0:hi(n.children,t)}return!1}function G(e){return(t,n)=>{if(t.selection.empty)return gi(e,t,n);let{from:r,to:i,anchor:a,head:o}=t.selection,s=[];t.doc.nodesBetween(r,i,(t,n)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;let a=t.textContent,o=n+1,[c,l]=ci(a,Math.max(r-o,0),Math.min(i-o,a.length));return c<l&&s.push({text:a,base:o,from:c,to:l,active:li(a,c,l,e)}),!1});let c=s.length>0&&s.every(e=>e.active),l=s.filter(e=>c||!e.active).flatMap(t=>ui(t.text,t.from,t.to,e,c).map(e=>({from:e.from+t.base,to:e.to+t.base,insert:e.insert})));if(l.length===0)return!1;if(n){let e=t.tr;l.sort((e,t)=>t.from-e.from||t.to-e.to);for(let t of l)t.insert?e.insertText(t.insert,t.from,t.to):e.delete(t.from,t.to);e.setSelection(x.create(e.doc,e.mapping.map(a,a<=o?1:-1),e.mapping.map(o,o<a?1:-1))),n(e.scrollIntoView())}return!0}}function gi(e,t,n){let{$from:r}=t.selection,i=r.parent;if(!i.isTextblock||i.type.spec.code)return!1;let a=mi(i.textContent,r.parentOffset,e);if(!a)return!1;if(n){let i=r.start(),o=t.tr;a.kind===`unwrap`&&o.delete(i+a.from,i+a.to),a.kind===`move`&&o.setSelection(x.create(o.doc,i+a.pos)),a.kind===`insert`&&(o.insertText(e.delim+e.delim,i+a.pos),o.setSelection(x.create(o.doc,i+a.pos+e.delim.length))),n(o.scrollIntoView())}return!0}function _i(){return o({toggleEm:()=>G(W.em),toggleStrong:()=>G(W.strong),toggleCode:()=>G(W.code),toggleDel:()=>G(W.del),toggleHighlight:()=>G(W.highlight)})}function vi(){return l({"Mod-b":G(W.strong),"Mod-i":G(W.em),"Mod-e":G(W.code),"Mod-Shift-x":G(W.del),"Mod-Shift-h":G(W.highlight)})}function yi(){return g(_i(),vi())}function bi(e,t,n){let r;return e.doc.nodesBetween(t.from,t.to,(e,i)=>(e.isText&&e.marks.some(e=>e.type.name===n)&&(r={from:Math.max(i,t.from),to:Math.min(i+e.nodeSize,t.to)}),!0)),r}function K(e,t){let n=E(e,t,`mdLinkText`),r=E(e,t,`mdPack`),i=r??n;if(!i)return;let a=r?.mark.attrs,o=n?.mark.attrs?.href??``;if(!r||a?.key!==`link`)return{unit:{from:i.from,to:i.to},href:o,title:``};let s=bi(e,i,`mdLinkUri`),c=s?s.from-2:i.to-3,l=s?s.from:i.to-1;return{unit:{from:i.from,to:i.to},label:{from:i.from+1,to:c},dest:{from:l,to:i.to-1},href:a.data.href,title:a.data.title}}function xi(e){let t=e.trim();return t?Cr(t)??t:``}function Si(e,t){return e+(t?` "${t.replaceAll(/(["\\])/g,String.raw`\$1`)}"`:``)}function Ci(e){let{selection:t}=e,{$from:n,$to:r,empty:i}=t;if(i||!n.sameParent(r)||!h(t))return;let a=n.parent;if(!a.isTextblock||a.type.spec.code)return;let o=n.start(),[s,c]=ci(a.textContent,n.parentOffset,r.parentOffset);if(!(s>=c))return{from:o+s,to:o+c}}function wi(e={}){return(t,n)=>{let r=Si(xi(e.href??``),e.title??``),i=Ci(t);if(!i)return!1;if(n){let{from:e,to:a}=i,o=t.tr,s=`](${r})`;o.insertText(s,a).insertText(`[`,e),n(o.setSelection(x.create(o.doc,e,a+1+s.length)).scrollIntoView())}return!0}}function Ti(e){return(t,n)=>{let r=K(t,t.selection.from);if(!r?.dest)return!1;let i=Si(xi(e.href??r.href),e.title??r.title);return n&&n(t.tr.insertText(i,r.dest.from,r.dest.to).scrollIntoView()),!0}}function Ei(){return(e,t)=>{let n=K(e,e.selection.from);return n?.label?(t&&t(e.tr.delete(n.label.to,n.unit.to).delete(n.unit.from,n.label.from).scrollIntoView()),!0):!1}}function Di(){return o({insertLink:wi,updateLink:Ti,removeLink:Ei})}function Oi(e){return(t,n,r)=>{let i=K(t,t.selection.from);if(i){if(n&&r){let{unit:{from:a,to:o}}=i;n(t.tr.setSelection(x.create(t.doc,a,o)).scrollIntoView()),r.focus(),e({from:a,to:o,link:i})}return!0}let a=Ci(t);if(a){if(n&&r){let{from:i,to:o}=a;n(t.tr.setSelection(x.create(t.doc,i,o)).scrollIntoView()),r.focus(),e({from:i,to:o,link:void 0})}return!0}return!1}}function ki(e){return l({"Mod-k":Oi(e)})}function Ai(){return f({type:`list`,attr:`marker`,default:null,splittable:!0,toDOM:e=>e===`)`||e===`*`||e===`+`?[`data-list-marker`,e]:null,parseDOM:e=>{let t=e.getAttribute(`data-list-marker`);return t===`)`||t===`*`||t===`+`?t:null}})}function ji(){return f({type:`list`,attr:`taskMarker`,default:null,splittable:!0,toDOM:e=>e===`X`?[`data-list-task-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-list-task-marker`)===`X`?`X`:null})}function Mi(e){return e===2||e===3||e===4}function Ni(){return f({type:`list`,attr:`markerGap`,default:1,splittable:!0,toDOM:e=>Mi(e)?[`data-list-marker-gap`,String(e)]:null,parseDOM:e=>{let t=Number.parseInt(e.getAttribute(`data-list-marker-gap`)??``,10);return Mi(t)?t:1}})}const Pi=[T(/^\s?([*-])\s$/,{kind:`bullet`,collapsed:!1}),T(/^\s?(\d+)\.\s$/,({match:e})=>{let t=e[1],n=t?parseInt(t,10):void 0;return{kind:`ordered`,collapsed:!1,order:n&&n>=2&&Number.isSafeInteger(n)?n:null}}),T(/^\s?\[([\sXx]?)]\s$/,({match:e})=>({kind:`task`,checked:[`x`,`X`].includes(e[1]),collapsed:!1})),T(/^\s?\+\s$/,{kind:`task`,marker:`+`,checked:!1,collapsed:!1})];function Fi(){return g(Pi.map(Ae))}function Ii(){return tt({kind:`task`,marker:`+`})}function Li(){return tt({kind:`task`,marker:null})}function Ri(){return o({wrapInCircleTask:Ii,wrapInSquareTask:Li})}function zi(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.name===`list`)return n.attrs}return null}function Bi(){return(e,t,n)=>{let r=zi(e),i=r?.kind===`task`&&r.marker!==`+`,a;return a=i&&!r?.checked?{kind:`task`,marker:r?.marker??null,checked:!0}:i&&r?.checked?{kind:`bullet`,marker:null,checked:!1}:{kind:`task`,marker:null,checked:!1},tt(a)(e,t,n)}}function Vi(){return(e,t,n)=>{let r=zi(e),i=r?.kind===`task`&&r.marker===`+`,a;return a=i&&!r?.checked?{kind:`task`,marker:`+`,checked:!0}:i&&r?.checked?{kind:`bullet`,marker:null,checked:!1}:{kind:`task`,marker:`+`,checked:!1},tt(a)(e,t,n)}}function Hi(e){return e.type.name===`list`&&e.attrs.kind===`bullet`&&e.childCount>=2&&e.firstChild?.type!==e.type}const Ui=e=>{let t=e.attrs;return t.kind===`task`?{...t,checked:!t.checked}:Hi(e)?{...t,collapsed:!t.collapsed}:t};function Wi(){return m(()=>[new y({props:{handleDOMEvents:{mousedown:(e,t)=>at({view:e,event:t,onListClick:Ui})}}}),nt(),new y({props:{transformCopied:ot}}),rt()])}function Gi(){return o({toggleListCollapsed:()=>it({isToggleable:Hi})})}function Ki(){return l({"Mod-Enter":Bi(),"Mod-Shift-Enter":Vi(),"Mod-.":it({isToggleable:Hi}),"Mod-Shift-7":et({kind:`ordered`,collapsed:!1}),"Mod-Shift-8":et({kind:`bullet`,collapsed:!1}),"Mod-Shift-9":et({kind:`task`,checked:!1,collapsed:!1})})}function qi(){return g(Qe(),Wi(),Xe(),Je(),Ze(),Ye(),Fi(),Ki(),Ai(),ji(),Ni(),Ri(),Gi())}function Ji(e){return e===`left`||e===`center`||e===`right`?e:null}function Yi(){return f({type:`tableCell`,attr:`align`,default:null,toDOM:e=>e?[`data-align`,e]:null,parseDOM:e=>Ji(e.getAttribute(`data-align`))})}function Xi(){return f({type:`tableHeaderCell`,attr:`align`,default:null,toDOM:e=>e?[`data-align`,e]:null,parseDOM:e=>Ji(e.getAttribute(`data-align`))})}function Zi(e){for(let t=0;t<e.childCount;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++)if(n.child(e).type.name===`tableHeaderCell`)return t}return 0}function Qi(e){return e.child(Zi(e))}function $i(e,t){return t>=e.childCount?null:e.child(t).attrs.align??null}function ea(e,t,n){if(e.childCount===0)return;let r=Qi(e),i=t+1;for(let t=0;t<e.childCount;t++){let a=e.child(t),o=i+1;for(let e=0;e<a.childCount;e++){let t=a.child(e),i=$i(r,e);(t.attrs.align??null)!==i&&n.setNodeMarkup(o,void 0,{...t.attrs,align:i}),o+=t.nodeSize}i+=a.nodeSize}}function ta(e){let t,n;for(let r of e){if(!r.docChanged)continue;t!=null&&n!=null&&(t=r.mapping.map(t,-1),n=r.mapping.map(n,1));let e=r.mapping;for(let[r,i]of e.maps.entries()){let a=e.slice(r+1);i.forEach((e,r,i,o)=>{let s=a.map(i,-1),c=a.map(o,1);t=t==null?s:Math.min(t,s),n=n==null?c:Math.max(n,c)})}}if(!(t==null||n==null))return{from:t,to:n}}function na(){return new y({key:new b(`table-align-sync`),appendTransaction(e,t,n){if(!e.some(e=>e.docChanged))return;let r=ta(e);if(!r)return;let i=n.doc,a=Math.max(0,Math.min(r.from,i.content.size)),o=Math.max(a,Math.min(r.to,i.content.size)),s;return i.nodesBetween(a,o,(e,t)=>e.type.name===`table`?(s??=n.tr,ea(e,t,s),!1):!0),s?.docChanged?s:void 0}})}function ra(){return m(na())}function ia(e){let{selection:t}=e;if(ht(t)){let{$anchorCell:e,$headCell:n}=t,r=e.depth-1,i=e.index(),a=n.index();return{table:e.node(r),tablePos:e.before(r),firstColumn:Math.min(i,a),lastColumn:Math.max(i,a)}}let{$from:n}=t;for(let e=n.depth;e>2;e--){let t=n.node(e).type.name;if(t===`tableCell`||t===`tableHeaderCell`){let t=n.index(e-1);return{table:n.node(e-2),tablePos:n.before(e-2),firstColumn:t,lastColumn:t}}}}function aa(e){return(t,n)=>{let r=ia(t);if(!r||r.table.childCount===0)return!1;if(n){let{table:i,tablePos:a,firstColumn:o,lastColumn:s}=r,c=Zi(i),l=a+1;for(let e=0;e<c;e++)l+=i.child(e).nodeSize;let u=i.child(c),d=t.tr,f=l+1;for(let t=0;t<u.childCount;t++){let n=u.child(t);t>=o&&t<=s&&(n.attrs.align??null)!==e&&d.setNodeMarkup(f,void 0,{...n.attrs,align:e}),f+=n.nodeSize}n(d)}return!0}}function oa(e){let t=ia(e);if(!(!t||t.table.childCount===0))return $i(Qi(t.table),t.lastColumn)??void 0}function sa(){return o({setTableColumnAlign:aa})}function ca(){return g(Yi(),Xi(),ra(),sa())}function la(e){let{$from:t}=e.selection;for(let e=t.depth;e>0;e--){let n=t.node(e).type.name;if(n===`tableCell`||n===`tableHeaderCell`)return!0}return!1}const ua=`paragraph`;function da(){return g(p({name:`tableCell`,content:ua}),p({name:`tableHeaderCell`,content:ua}))}const fa=(e,t)=>{let{selection:n}=e;return!ht(n)||!n.isColSelection()||!n.isRowSelection()?!1:mt(e,t)};function pa(){return _(l({Backspace:fa,Delete:fa}),t.high)}function ma(){return g(pt(),ft(),st(),dt(),da(),ca(),ut({allowTableNodeSelection:!0}),ct(),lt(),pa())}function ha(e){let{selection:t}=e,{$from:n,$to:r}=t;if(oe(t)&&n.depth===0||n.depth>0&&r.depth>0&&n.index(0)===r.index(0))return n.index(0)}function ga(e){return(t,n)=>{if(la(t))return!1;let r=ha(t);if(r==null)return!1;let i=r+e;if(i<0||i>=t.doc.childCount)return!1;if(n){let{selection:a}=t,o=Math.min(r,i),s=a.$from.posAtIndex(o,0),c=t.doc.child(o),l=t.doc.child(o+1),u=t.tr.replaceWith(s,s+c.nodeSize+l.nodeSize,[l,c]),d=e===-1?-c.nodeSize:l.nodeSize,f=oe(a)?be.create(u.doc,a.from+d):x.create(u.doc,a.anchor+d,a.head+d);u.setSelection(f),n(u.scrollIntoView())}return!0}}function _a(e){return(t,n,r)=>$e(e)(t,n,r)||ga(e===`up`?-1:1)(t,n,r)}function va(){return l({"Alt-ArrowUp":_a(`up`),"Alt-ArrowDown":_a(`down`)})}function ya(){return p({name:`paragraph`,content:`inline*`,group:`block`,whitespace:`pre`,parseDOM:[{tag:`p`}],toDOM(){return[`p`,0]}})}function ba(){return g(_(ya(),t.highest),gt(),_t())}const q=new b(`meowdownPendingReplacement`);function J(e){return q.getState(e)?.pending??null}function xa(e,t){switch(e.type){case`start`:return{pending:{from:e.from,to:e.to,mode:e.mode,text:``}};case`append`:return t.pending?{pending:{...t.pending,text:t.pending.text+e.text}}:t;case`accept`:return t.pending?{pending:null,ended:{pending:t.pending,outcome:`accepted`}}:t;case`discard`:return t.pending?{pending:null,ended:{pending:t.pending,outcome:`discarded`}}:t}}const Sa=new y({key:q,state:{init:()=>({pending:null}),apply:(e,t)=>{let n=e.getMeta(q);if(n)return xa(n,t);if(e.docChanged&&t.pending){let n=e.mapping.mapResult(t.pending.from,1),r=e.mapping.mapResult(t.pending.to,-1),i=Math.min(n.pos,r.pos),a=Math.max(n.pos,r.pos);return(n.deletedAfter&&r.deletedBefore||i>=a)&&t.pending.mode===`replace`?{pending:null,ended:{pending:t.pending,outcome:`discarded`}}:{pending:{...t.pending,from:i,to:a}}}return t}},props:{decorations:e=>{let t=J(e);return!t||t.from>=t.to?null:C.create(e.doc,[S.inline(t.from,t.to,{class:`md-pending-replacement`})])}}});function Ca(e){return(t,n)=>{let{from:r,to:i,mode:a}=e;return r<0||i>t.doc.content.size||r>i||r===i&&a===`replace`?!1:(n?.(t.tr.setMeta(q,{type:`start`,from:r,to:i,mode:a})),!0)}}function wa(e){return(t,n)=>J(t)?(n?.(t.tr.setMeta(q,{type:`append`,text:e})),!0):!1}function Ta(){return(e,t)=>J(e)?(t?.(e.tr.setMeta(q,{type:`discard`})),!0):!1}function Ea(e={}){return(t,n)=>{let r=J(t);if(!r||!r.text.trim())return!1;if(n){let i=e.mode??r.mode,a=Qa(t.schema),o=X(r.text,{nodes:a}),s=t.tr;if(s.setMeta(q,{type:`accept`}),i===`append`){let e=t.doc.resolve(r.to).after(1);s.insert(e,o.content),s.setSelection(x.near(s.doc.resolve(e+o.content.size),-1))}else{let e=t.doc.resolve(r.from),n=t.doc.resolve(r.to),i=o.childCount===1?o.firstChild:null;i?.type.name===`paragraph`&&e.sameParent(n)&&e.parent.isTextblock?(s.replaceWith(r.from,r.to,i.content),s.setSelection(x.near(s.doc.resolve(r.from+i.content.size),-1))):(s.replaceRange(r.from,r.to,new w(o.content,0,0)),s.setSelection(x.near(s.doc.resolve(s.mapping.map(r.to)),-1)))}n(s.scrollIntoView())}return!0}}function Da(){return o({startPendingReplacement:Ca,appendPendingReplacementText:wa,acceptPendingReplacement:Ea,discardPendingReplacement:Ta})}function Oa(){return l({"Mod-Enter":Ea(),Escape:Ta()})}function ka(){return g(m(Sa),Da(),Oa())}function Aa(e){return m(new y({view:()=>({update:(t,n)=>{let r=q.getState(n),i=q.getState(t.state);!i||r===i||(i.pending?i.pending!==r?.pending&&e({type:`update`,pending:i.pending}):i.ended&&i.ended!==r?.ended&&e({type:`ended`,pending:i.ended.pending,outcome:i.ended.outcome}))}})}))}function ja(e){return e.left===0&&e.top===0&&e.right===0&&e.bottom===0}function Y(e,t,n){if(t<0||t>e.state.doc.content.size)return;let r;try{r=e.coordsAtPos(t,n)}catch{return}return ja(r)?void 0:r}function Ma(e){e.offsetWidth}const Na=new b(`meowdown-virtual-caret`),Pa=[`md-virtual-caret-blink`,`md-virtual-caret-blink2`];function Fa(e){let t=e.dom.ownerDocument.getSelection();if(t==null||t.rangeCount===0||!e.dom.contains(t.anchorNode))return;let n=t.getRangeAt(0).cloneRange();n.collapse(!0);let r=Array.from(n.getClientRects()).filter(e=>e.height>0);if(r.length===0)return;let i=r[r.length-1];return{left:i.left,top:i.top,height:i.height}}function Ia(e){let t=e.state,n=t.selection.head,r=F(t,n),i=I(t,n),a=r==null,o=[[n,a],[n,!a]];r!=null&&o.push([r.from,!0]),i!=null&&o.push([i.to,!1]);for(let[t,n]of o){let r=Y(e,t,n?-1:1);if(r!=null&&r.bottom>r.top)return{left:r.left,top:r.top,height:r.bottom-r.top}}}function La(e){let t=e.state,n=t.selection.head;for(let r of Pt){let i=E(t,n,r);if(i==null||i.from!==n&&i.to!==n)continue;let a=Ra(e,i.from+1);if(a==null)continue;let o=a.getBoundingClientRect();if(o.height!==0)return{left:i.to===n?o.right:o.left,top:o.top,height:o.height}}}function Ra(e,t){let{node:n}=e.domAtPos(t,0);return(n instanceof Element?n:n.parentElement)?.closest(`.md-atom-view`)?.querySelector(`.md-atom-view-preview`)??void 0}function za(e){let t=e.height*.19999999999999996;return{left:e.left,top:e.top-t/2,height:e.height+t}}function Ba(e){let t=Fa(e)??Ia(e);return t==null?La(e):za(t)}function Va(e,t){return e==null||t==null?e===t:e.left===t.left&&e.top===t.top&&e.height===t.height}var Ha=class{#e;#t;#n;#r;#i;#a;#o;#s=0;constructor(e){this.#e=e,this.#r=e.dom.ownerDocument,this.#t=this.#r.createElement(`div`),this.#t.className=`md-virtual-caret-layer`,this.#n=this.#t.appendChild(this.#r.createElement(`div`)),this.#n.className=`md-virtual-caret`,this.#n.dataset.testid=`virtual-caret`,e.dom.insertAdjacentElement(`afterend`,this.#t),this.#r.addEventListener(`selectionchange`,this.#l),typeof ResizeObserver<`u`&&(this.#i=new ResizeObserver(this.#l),this.#i.observe(e.dom)),this.#l()}update(e,t){e.state.selection.eq(t.selection)||this.#c(),this.#l()}destroy(){this.#r.removeEventListener(`selectionchange`,this.#l),this.#i?.disconnect(),this.#t.remove()}#c(){this.#s=1-this.#s,this.#n.style.animationName=Pa[this.#s]}#l=()=>{let e=this.#e;if(e.isDestroyed)return;let t=e.state,n=t.selection,r=h(n)&&n.empty?Ba(e):void 0,i=r!=null&&O(t)===`hide`?Dn(t,n.head):void 0;if(Va(r,this.#a)&&i===this.#o)return;let a=this.#a==null;if(this.#a=r,this.#o=i,i==null?delete this.#n.dataset.tail:this.#n.dataset.tail=i,r==null){this.#n.style.visibility=`hidden`;return}let o=this.#t.getBoundingClientRect();a&&(this.#n.style.transitionProperty=`none`),this.#n.style.visibility=``,this.#n.style.left=`${r.left-o.left}px`,this.#n.style.top=`${r.top-o.top}px`,this.#n.style.height=`${r.height}px`,a&&(Ma(this.#n),this.#n.style.transitionProperty=``)}};function Ua(){return m(new y({key:Na,view:e=>new Ha(e)}))}function Wa(e){return g(ba(),he(),fn(),ve(),me(),qi(),vn(),ma(),an(),zn(),Bn(),ei(),Xt(),dn(),va(),zr(e),yi(),Di(),br(),jt(e.markMode??`focus`),Ua(),Ln(),Gt({marks:Pt.map(e=>({name:e,modes:[`hide`,`focus`,`show`]}))}),a(),i(),c(),ge(),ye(),_e(),ln(),ka())}function Ga(e={}){return Wa(e)}const Ka=v(()=>{let e=Ga().schema;if(e==null)throw Error(`Unexpected empty schema`);return e}),qa=v(()=>r(Ka())),Ja=v(()=>n(Ka())),Ya=`meowdown_mark_builders`;function Xa(e){let t=e.cached[Ya];if(t)return t;let r=n(e);return e.cached[Ya]=r,r}const Za=`meowdown_node_builders`;function Qa(e){let t=e.cached[Za];if(t)return t;let n=r(e);return e.cached[Za]=n,n}function X(e,t={}){let{nodes:n=qa(),frontmatter:r=!1}=t,i,a=e;if(r){let[t,n]=eo(e);i=t,n&&(a=e.slice(n))}let o=to(n,lr.parse(a).cursor(),a);return n.doc(i===void 0?{}:{frontmatter:i},o)}const $a=/^---[ \t]*\r?\n([\s\S]*?\n)?---[ \t]*(?:\r?\n|$)/;function eo(e){let t=$a.exec(e);return t?[(t[1]??``).replace(/\r?\n$/,``),t[0].length]:[]}function to(e,t,n){let r=[];if(!t.firstChild())return r;do r.push(...no(e,t,n));while(t.nextSibling());return t.parent(),r}function no(e,t,n){switch(t.type.id){case H.ATXHeading1:return[Z(e,t,n,1,!1)];case H.ATXHeading2:return[Z(e,t,n,2,!1)];case H.ATXHeading3:return[Z(e,t,n,3,!1)];case H.ATXHeading4:return[Z(e,t,n,4,!1)];case H.ATXHeading5:return[Z(e,t,n,5,!1)];case H.ATXHeading6:return[Z(e,t,n,6,!1)];case H.SetextHeading1:return[Z(e,t,n,1,!0)];case H.SetextHeading2:return[Z(e,t,n,2,!0)];case H.Paragraph:return[$(e,t,n)];case H.CommentBlock:return[co(e,t,n)];case H.HTMLBlock:case H.ProcessingInstructionBlock:return[$(e,t,n)];case H.Blockquote:return[lo(e,t,n)];case H.BulletList:return uo(e,t,n,`bullet`);case H.OrderedList:return uo(e,t,n,`ordered`);case H.FencedCode:case H.CodeBlock:return[po(e,t,n)];case H.HorizontalRule:{let r=n.slice(t.from,t.to).trimEnd();return[e.horizontalRule({marker:r===`---`?null:r})]}case H.Table:return[mo(e,t,n)];case H.Task:return[$(e,t,n)];default:return n.slice(t.from,t.to).trim()===``?[]:(console.warn(`[meowdown] unsupported lezer block "${t.type.name}"`),[$(e,t,n)])}}function Z(e,t,n,r,i){let a=t.from,o=t.from,s=t.to,c=-1,l=-1;if(t.firstChild()){t.type.id===H.HeaderMark&&t.from===a&&(o=t.to);let e=-1,n=-1,r=-1;do e=t.type.id,n=t.from,r=t.to;while(t.nextSibling());e===H.HeaderMark&&n>o&&(s=n,c=n,l=r),t.parent()}let u=oo(n.slice(o,s),Q(n,o)).trim(),d=i?ro(n,c,l)||1:null,f=!i&&c>=0&&io(n,c,l)||null;return e.heading({level:r,setextUnderline:d,closingHashes:f},u)}function ro(e,t,n){if(t<0)return 0;let r=0;for(let i=t;i<n;i++){let t=e.charCodeAt(i);(t===61||t===45)&&r++}return r}function io(e,t,n){if(t<0)return 0;let r=0;for(let i=t;i<n;i++)e.charCodeAt(i)===35&&r++;return r}function Q(e,t){let n=e.lastIndexOf(`
|
|
3
|
+
`,t-1)+1,r=0;for(let i=n;i<t;i++)r+=e.charCodeAt(i)===9?4-r%4:1;return r}function ao(e,t){let n=0,r=0;for(;r<e.length&&n<t;){let t=e.charCodeAt(r);if(t===32)n+=1;else if(t===9)n+=4-n%4;else break;r++}return e.slice(r)}function oo(e,t){return t===0||!e.includes(`
|
|
4
4
|
`)?e:e.split(`
|
|
5
|
-
`).map((e,n)=>n===0?e:
|
|
6
|
-
`)}function
|
|
5
|
+
`).map((e,n)=>n===0?e:ao(e,t)).join(`
|
|
6
|
+
`)}function so(e,t,n){return e.paragraph(oo(t,n))}function $(e,t,n){let r=t.from,i=t.to,a=Q(n,r);if(t.firstChild()){let o=``,s=r;do t.type.id===H.QuoteMark&&(o+=n.slice(s,t.from),s=t.to,z(n.charCodeAt(s))&&(s+=1));while(t.nextSibling());return t.parent(),o+=n.slice(s,i),so(e,o,a)}return so(e,n.slice(r,i),a)}function co(e,t,n){let r=Q(n,t.from),i=oo(n.slice(t.from,t.to),r);return e.htmlComment({content:i})}function lo(e,t,n){let r=[];if(t.firstChild()){do{if(t.type.id===H.QuoteMark)continue;r.push(...no(e,t,n))}while(t.nextSibling());t.parent()}return e.blockquote(r)}function uo(e,t,n,r){let i=[];if(t.firstChild()){do t.type.id===H.ListItem&&i.push(fo(e,t,n,r));while(t.nextSibling());t.parent()}return i}function fo(e,t,n,r){let i=[],a,o,s,c,l,u;if(t.firstChild()){do{if(t.type.id!==H.ListMark&&u==null&&(u=Q(n,t.from)),t.type.id===H.ListMark){if(r===`ordered`){let e=n.charCodeAt(t.to-1);e===41?c=`)`:e===46&&(c=`.`);let r=Number.parseInt(n.slice(t.from,t.to),10);s=Number.isFinite(r)?r:1}else{let e=n.charCodeAt(t.from);c=e===42?`*`:e===43?`+`:`-`}l=Q(n,t.to);continue}if(r===`bullet`&&t.type.id===H.Task){let r=t.from,s=t.to;if(a=!1,t.firstChild()){if(t.type.id===H.TaskMarker){let e=n.charCodeAt(t.from+1);e===120?(a=!0,o=`x`):e===88&&(a=!0,o=`X`),r=t.to}t.parent()}z(n.charCodeAt(r))&&(r+=1);let c=n.slice(r,s);i.push(so(e,c,Q(n,r)));continue}i.push(...no(e,t,n))}while(t.nextSibling());t.parent()}let d=u!=null&&l!=null?u-l:1,f=a!=null,p=!f&&r===`bullet`&&c===`+`;return e.list({kind:f?`task`:r,order:r===`ordered`?s??1:null,checked:a??!1,collapsed:p,marker:p?null:c,taskMarker:o,markerGap:d>=2&&d<=4?d:1},i)}function po(e,t,n){let r=t.type.id===H.CodeBlock,i=``,a=``,o=r?`indented`:null,s=null,c=!1;if(t.firstChild()){do switch(t.type.id){case H.CodeMark:{if(c)break;c=!0,n.charCodeAt(t.from)===126&&(o=`tilde`);let e=t.to-t.from;e>3&&(s=e);break}case H.CodeInfo:i=n.slice(t.from,t.to);break;case H.CodeText:a+=n.slice(t.from,t.to);break}while(t.nextSibling());t.parent()}return e.codeBlock({language:i,fenceStyle:o,fenceLength:s},a)}function mo(e,t,n){let r=[];if(t.firstChild()){do t.type.id===H.TableDelimiter&&(r=ho(n.slice(t.from,t.to)));while(t.nextSibling());t.parent()}let i=[];if(t.firstChild()){do{let a=t.type.id;a===H.TableHeader?i.push(go(e,t,n,!0,r)):a===H.TableRow&&i.push(go(e,t,n,!1,r))}while(t.nextSibling());t.parent()}return e.table(i)}function ho(e){return e.split(`|`).map(e=>e.trim()).filter(e=>e!==``).map(e=>{let t=e.startsWith(`:`),n=e.endsWith(`:`);return t&&n?`center`:t?`left`:n?`right`:null})}function go(e,t,n,r,i){let a=i.length,o=Array(a).fill(``);if(t.firstChild()){let e=t.type.id===H.TableDelimiter,r=0;do if(t.type.id===H.TableDelimiter)r++;else if(t.type.id===H.TableCell){let i=r-+!!e;i>=0&&i<a&&(o[i]=n.slice(t.from,t.to).trim().replaceAll(String.raw`\|`,`|`))}while(t.nextSibling());t.parent()}let s=o.map((t,n)=>{let a=e.paragraph(t),o={align:i[n]};return r?e.tableHeaderCell(o,a):e.tableCell(o,a)});return e.tableRow(s)}function _o(e,t={}){let n=new xo;return t.frontmatter&&vo(e.attrs.frontmatter,n),So(e,n),n.finish()}function vo(e,t){e!==null&&(t.write(`---`),t.write(`
|
|
7
7
|
`),e!==``&&(t.write(e),t.write(`
|
|
8
|
-
`)),t.write(`---`),t.closeBlock())}const
|
|
9
|
-
`+i.repeat(Math.max(1,r))),t.closeBlock();return}t.write(
|
|
8
|
+
`)),t.write(`---`),t.closeBlock())}const yo=[``,`# `,`## `,`### `,`#### `,`##### `,`###### `];function bo(e,t){let n=e.attrs,r=n.setextUnderline;if(r!=null&&e.content.size>0&&n.level<=2){Eo(e,t);let i=n.level===1?`=`:`-`;t.write(`
|
|
9
|
+
`+i.repeat(Math.max(1,r))),t.closeBlock();return}t.write(yo[n.level]??`# `),Eo(e,t);let i=n.closingHashes;i!=null&&i>0&&t.write(` `+`#`.repeat(i)),t.closeBlock()}var xo=class{constructor(){this.parts=[],this.linePrefix=``,this.pendingFirst=null,this.atLineStart=!0,this.deferredBlankPrefix=null}write(e){if(e===``)return;if(this.emitDeferredBlankLine(),this.atLineStart&&=(this.parts.push(this.pendingFirst??this.linePrefix),this.pendingFirst=null,!1),!e.includes(`
|
|
10
10
|
`)){this.parts.push(e);return}let t=e.split(`
|
|
11
11
|
`);for(let e=0;e<t.length;e++)e>0&&this.parts.push(`
|
|
12
12
|
`,this.linePrefix),t[e]!==``&&this.parts.push(t[e])}closeBlock(){this.atLineStart&&this.pendingFirst!==null&&(this.emitDeferredBlankLine(),this.parts.push(this.pendingFirst.trimEnd()),this.pendingFirst=null,this.atLineStart=!1),this.atLineStart||this.parts.push(`
|
|
13
13
|
`),this.atLineStart=!0,this.deferredBlankPrefix=this.linePrefix}suppressBlank(){this.deferredBlankPrefix=null}withPrefix(e,t,n){let r=this.linePrefix,i=this.pendingFirst;if(this.linePrefix=r+e,t!==null){let e=i??r;this.pendingFirst=e+t}n(),this.linePrefix=r,this.pendingFirst=t===null?i:null}finish(){return this.parts.join(``).replace(/\s+$/,``)+`
|
|
14
14
|
`}emitDeferredBlankLine(){let e=this.deferredBlankPrefix;e!==null&&(this.parts.push(e.trimEnd(),`
|
|
15
|
-
`),this.deferredBlankPrefix=null)}};function
|
|
16
|
-
`),
|
|
17
|
-
`)),t.write(
|
|
18
|
-
`)
|
|
19
|
-
`),t.
|
|
15
|
+
`),this.deferredBlankPrefix=null)}};function So(e,t){switch(e.type.name){case`doc`:Co(e,t);return;case`paragraph`:Eo(e,t),t.closeBlock();return;case`heading`:bo(e,t);return;case`blockquote`:t.withPrefix(`> `,`> `,()=>Co(e,t)),t.closeBlock();return;case`list`:Do(e,t,To(e));return;case`codeBlock`:Oo(e,t);return;case`horizontalRule`:{let{marker:n}=e.attrs;t.write(n||`---`),t.closeBlock();return}case`htmlComment`:{let{content:n}=e.attrs;t.write(n),t.closeBlock();return}case`table`:Ao(e,t);return;case`text`:e.text&&t.write(e.text);return}}function Co(e,t,n=!1){let r=e.childCount,i=0;for(;i<r;){let a=e.child(i);if(a.type.name!==`list`){n&&i>0&&t.suppressBlank(),So(a,t),i++;continue}let o=i+1;for(;o<r&&e.child(o).type.name===`list`;)o++;let s=wo(e,i,o);for(let r=i;r<o;r++)(r===i?n&&i>0:s)&&t.suppressBlank(),Do(e.child(r),t,s);i=o}}function wo(e,t,n){for(let r=t;r<n;r++)if(!To(e.child(r)))return!1;return!0}function To(e){let t=e.childCount;for(let n=0;n<t;n++){let t=e.child(n);if(t.type.name!==`list`&&!(t.type.name===`paragraph`&&n===0))return!1}return!0}function Eo(e,t){let n=e.childCount;for(let r=0;r<n;r++){let n=e.child(r);n.isText&&n.text&&t.write(n.text)}}function Do(e,t,n){let{kind:r,marker:i,order:a,taskMarker:o,collapsed:s,markerGap:c,checked:l}=e.attrs,u=r===`task`?i===`+`?`+`:i===`*`?`*`:`-`:s?`+`:i===`*`?`*`:`-`,d=i===`)`?`)`:`.`,f=o===`X`?`X`:`x`,p=Math.min(Math.max(c??1,1),4),m=`${r===`ordered`?`${a??1}${d}`:u}${` `.repeat(p)}`,ee=r===`task`?`${m}[${l?f:` `}] `:m,te=` `.repeat(m.length);t.withPrefix(te,ee,()=>Co(e,t,n)),t.closeBlock()}function Oo(e,t){let n=e.attrs,r=n.language||``,i=e.textContent;if(n.fenceStyle===`indented`&&!r){let e=ko(i);if(e!=null){t.write(e),t.closeBlock();return}}let a=n.fenceStyle===`tilde`,o=ti(i,a?126:96,2)+1,s=(a?`~`:"`").repeat(Math.max(n.fenceLength??0,o));t.write(s),r&&t.write(r),t.write(`
|
|
16
|
+
`),i&&(t.write(i),t.write(`
|
|
17
|
+
`)),t.write(s),t.closeBlock()}function ko(e){if(e===``)return;let t=e.split(`
|
|
18
|
+
`);if(!(t[0]===``||t[t.length-1]===``)){for(let e=0;e<t.length;e++)t[e]!==``&&(t[e]=` ${t[e]}`);return t.join(`
|
|
19
|
+
`)}}function Ao(e,t){let n=e.childCount;if(n===0)return;let r=[],i=0,a=-1;for(let t=0;t<n;t++){let n=e.child(t),o=[],s=!1;for(let e=0;e<n.childCount;e++){let t=n.child(e);t.type.name===`tableHeaderCell`&&(s=!0),o.push(No(t))}s&&a<0&&(a=t),o.length>i&&(i=o.length),r.push(o)}if(i===0)return;let o=e.child(a>=0?a:0),s=[];for(let e=0;e<i;e++){let t=e<o.childCount?o.child(e):void 0,n=t?t.attrs.align:void 0;s.push(jo(n))}let c=`| `+s.join(` | `)+` |`,l=a>=0?r[a]:Array(i).fill(``);t.write(Mo(l,i)),t.write(`
|
|
20
|
+
`),t.write(c);for(let e=0;e<n;e++)e!==a&&(t.write(`
|
|
21
|
+
`),t.write(Mo(r[e],i)));t.closeBlock()}function jo(e){switch(e){case`left`:return`:--`;case`center`:return`:-:`;case`right`:return`--:`;default:return`---`}}function Mo(e,t){let n=`|`;for(let r=0;r<t;r++)n+=` `+(e[r]??``)+` |`;return n}function No(e){let t=e.textContent.trim();return!t.includes(`|`)&&!t.includes(`
|
|
20
22
|
`)?t:t.replaceAll(`|`,String.raw`\|`).replaceAll(`
|
|
21
|
-
`,` `)}function
|
|
22
|
-
`).filter(e=>!
|
|
23
|
-
`)}function Ga(e,t){let{from:n,to:r}=e.state.selection;e.dispatch(mt(e.state.tr.insertText(t,n,r)));let i=e.state.tr.insertText(``,n,n+t.length);e.dispatch(mt(i))}function Ka(){return m(new b({key:Ha,props:{handlePaste:(e,t,n)=>{let r=e.state.selection.$from.parent;if(!r.inlineContent||r.type.spec.code)return!1;let i=Wa(t,n);if(!i)return!1;let a=Ua(i);return a?(Ga(e,a),!0):!1}}}))}const qa=new x(`meowdown-exit-boundary`);function Ja(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):void 0:i;return!!(a&&Se.findFrom(a,t))}function Ya(e,t){let{state:n}=e,{selection:r}=n;return g(r)&&!r.empty||ne(r)||r.$from.parent.inlineContent&&!e.endOfTextblock(t<0?`up`:`down`)?!0:Ja(n,t)}function Xa(e){return new b({key:qa,props:{handleKeyDown:(t,n)=>{if(n.shiftKey||n.altKey||n.ctrlKey||n.metaKey)return!1;let r=n.key===`ArrowUp`?-1:n.key===`ArrowDown`?1:void 0;return!(!r||Ya(t,r)||e({direction:r<0?`up`:`down`,event:n})===!1)}}})}function Za(e){return v(m(Xa(e)),t.low)}function Qa(e){return!!e.type?.startsWith(`image/`)}function $a(e,t){return Qa(e)?``:`[${no(e.name)}](${t})`}function eo(e,t){return!e||!t.onFilePaste?[]:Array.from(e.files)}const to=e=>{console.error(`[meowdown] failed to save pasted file:`,e)};function no(e){return e.replaceAll(/[\\[\]]/g,String.raw`\$&`)}async function ro(e,t,n,r){let{onFilePaste:i}=n;if(!i)return;let a=n.onFileSaveError??to,o=r,s=!1;for(let n of t){let t;try{t=await i(n)}catch(e){a(e,n);continue}if(!t||e.isDestroyed)continue;let r=$a(n,t),c=s?`\n${r}`:r,l=o==null?e.state.tr.insertText(c):e.state.tr.insertText(c,o);e.dispatch(l),s=!0,o!=null&&(o+=c.length)}}function io(e){return new b({key:new x(`file-paste`),props:{handlePaste:(t,n)=>{let r=eo(n.clipboardData,e);return r.length===0?!1:(ro(t,r,e),!0)},handleDrop:(t,n)=>{let r=eo(n.dataTransfer,e);return r.length===0?!1:(ro(t,r,e,t.posAtCoords({left:n.clientX,top:n.clientY})?.pos),!0)}}})}function ao(e={}){return v(m(io(e)),t.high)}const oo=new x(`meowdown-file-click`);function so(e,t){let n=O(e,t,`mdFile`);if(!n)return;let{href:r,name:i}=n.mark.attrs;return{href:r,name:i}}function co(e){return m(new b({key:oo,props:{handleClick:(t,n,r)=>{let i=r.target?.closest?.(`.md-file-view-preview`);if(!i)return!1;let a=i.closest(`.md-file-view`)?.querySelector(`.md-file-view-content`);if(!a)return!1;let o=so(t.state,t.posAtDOM(a,0));return o?(e({href:o.href,name:o.name,event:r}),!0):!1}}}))}const lo=[`KB`,`MB`,`GB`,`TB`];function uo(e){let t=e,n=`B`;for(let e of lo){if(t<999.5)break;t/=1e3,n=e}return n===`B`?`${Math.round(t)} B`:`${t<9.95?Math.round(t*10)/10:Math.round(t)} ${n}`}const fo=new Map([[`pdf`,`pdf`],[`zip`,`archive`],[`tar`,`archive`],[`gz`,`archive`],[`tgz`,`archive`],[`rar`,`archive`],[`7z`,`archive`],[`doc`,`doc`],[`docx`,`doc`],[`pages`,`doc`],[`xls`,`sheet`],[`xlsx`,`sheet`],[`csv`,`sheet`],[`numbers`,`sheet`],[`ppt`,`slides`],[`pptx`,`slides`],[`key`,`slides`],[`mp3`,`audio`],[`wav`,`audio`],[`m4a`,`audio`],[`flac`,`audio`],[`ogg`,`audio`],[`mp4`,`video`],[`mov`,`video`],[`mkv`,`video`],[`webm`,`video`],[`txt`,`text`],[`md`,`text`]]);function po(e){let t=e.split(/[?#]/,1)[0],n=t.lastIndexOf(`.`);if(n<0)return`generic`;let r=t.slice(n+1).toLowerCase();return fo.get(r)??`generic`}const mo=`http://www.w3.org/2000/svg`;function ho(){let e=document.createElementNS(mo,`svg`);e.setAttribute(`class`,`md-file-view-icon`),e.setAttribute(`viewBox`,`0 0 24 24`),e.setAttribute(`aria-hidden`,`true`);for(let t of[`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,`M14 2v4a2 2 0 0 0 2 2h4`]){let n=document.createElementNS(mo,`path`);n.setAttribute(`d`,t),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`2`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`),e.appendChild(n)}return e}var go=class{#e;#t;#n;#r;#i;#a;#o=!1;constructor(e,t){this.#a=e.attrs,this.#e=document.createElement(`span`),this.#e.className=`md-file-view md-atom-view`,this.#n=document.createElement(`span`),this.#n.className=`md-file-view-preview md-atom-view-preview`,this.#n.contentEditable=`false`,this.#n.dataset.testid=`file-pill`,this.#n.dataset.fileKind=po(this.#a.href),this.#n.title=this.#a.name,this.#e.appendChild(this.#n),this.#n.appendChild(ho()),this.#r=document.createElement(`span`),this.#r.className=`md-file-view-name`,this.#r.textContent=this.#a.name,this.#n.appendChild(this.#r),this.#i=document.createElement(`span`),this.#i.className=`md-file-view-size`,this.#i.dataset.testid=`file-pill-size`,this.#n.appendChild(this.#i),this.#t=document.createElement(`span`),this.#t.className=`md-file-view-content md-atom-view-content`,this.#e.appendChild(this.#t),this.#s(t.resolveFileInfo)}get dom(){return this.#e}get contentDOM(){return this.#t}update(e){let t=e.attrs,n=this.#a;return t.href===n.href?(this.#a=t,t.name!==n.name&&(this.#r.textContent=t.name,this.#n.title=t.name),!0):!1}ignoreMutation(e){return!this.#t.contains(e.target)}destroy(){this.#o=!0}async#s(e){if(!e)return;let t;try{t=await e(this.#a.href)}catch(e){console.error(`[meowdown] resolveFileInfo failed:`,e);return}if(this.#o||!t)return;let{size:n}=t;n==null||!Number.isFinite(n)||n<0||(this.#i.textContent=uo(n))}};function _o(e={}){return d({name:`mdFile`,constructor:t=>new go(t,e)})}function vo(e){return m(new b({key:e.key,props:{handleClick:(t,n,r)=>{if(!r.target?.closest?.(e.selector))return!1;let i=e.findPayloadAt(t.state,n);return i==null?!1:(e.preventDefault&&r.preventDefault(),e.onClick(i,r),!0)}}}))}const yo=new x(`meowdown-tag-click`);function bo(e,t){let n=O(e,t,`mdTag`);if(!n)return;let r=e.doc.textBetween(n.from,n.to),i=r.startsWith(`#`)?r.slice(1):r;return{from:n.from,to:n.to,tag:i}}function xo(e){return vo({key:yo,selector:`.md-tag`,preventDefault:!1,findPayloadAt:(e,t)=>bo(e,t)?.tag,onClick:(t,n)=>e({tag:t,event:n})})}const So=new x(`meowdown-wikilink-click`);function Co(e,t){let n=O(e,t,`mdWikilink`);if(!n)return;let{target:r}=n.mark.attrs;return{from:n.from,to:n.to,target:r}}function wo(e){return vo({key:So,selector:`.md-wikilink-view-preview`,preventDefault:!1,findPayloadAt:(e,t)=>Co(e,t)?.target,onClick:(t,n)=>e({target:t,event:n})})}const To=new x(`meowdown-follow-link`);function Eo(e){return e.key!==`Enter`||e.shiftKey||e.altKey?!1:re?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Do(e){return new b({key:To,props:{handleKeyDown:(t,n)=>{if(!Eo(n))return!1;let{state:r}=t,i=r.selection.head,a=e.onWikilinkClick&&Co(r,i);if(a)return e.onWikilinkClick?.({target:a.target,event:n}),!0;let o=e.onTagClick&&bo(r,i);if(o)return e.onTagClick?.({tag:o.tag,event:n}),!0;let s=e.onFileClick&&so(r,i);if(s)return e.onFileClick?.({href:s.href,name:s.name,event:n}),!0;let c=e.onLinkClick&&K(r,i);return c?(e.onLinkClick?.({href:c.href,event:n}),!0):!1}}})}function Oo(e){return v(m(Do(e)),t.high)}const ko=(e,t)=>{let n={type:`highlight`,children:e.all(t)};return e.patch(t,n),n},Ao=(e,t,n,r)=>{let i=e,a=n.createTracker(r),o=a.move(`==`);return o+=a.move(n.containerPhrasing(i,{...a.current(),before:o,after:`=`})),o+=a.move(`==`),o};function jo(){return yt().use(ht).use(gt,{handlers:{mark:ko}}).use(_t).use(vt,{bullet:`-`,emphasis:`*`,strong:`*`,fence:"`",fences:!0,rule:`-`,ruleRepetition:3,listItemIndent:`one`,handlers:{highlight:Ao}}).freeze()}const Mo=y(jo);function No(e){return String(Mo().processSync(e))}const Po=new x(`meowdown-html-paste`);function Fo(){return m(new b({key:Po,props:{transformPastedHTML:(e,t)=>{if(e.includes(`data-pm-slice`))return e;let n=t.state.selection.$from.parent;if(!n.inlineContent||n.type.spec.code)return e;let r=No(e);if(!r.trim())return e;let i=Y(r,{nodes:Hi(t.state.schema)}),a=Oe.fromSchema(t.state.schema),o=document.createElement(`div`);return o.append(a.serializeFragment(i.content)),o.innerHTML}}}))}const Io=new x(`meowdown-image-click`);function Lo(e,t){let n=O(e,t,`mdImage`);if(!n)return;let{src:r,alt:i}=n.mark.attrs;return{from:n.from,to:n.to,src:r,alt:i}}function Ro(e){return m(new b({key:Io,props:{handleClick:(t,n,r)=>{let i=r.target?.closest?.(`.md-image-view-preview`);if(!i)return!1;let a=i.closest(`.md-image-view`)?.querySelector(`.md-image-view-content`);if(!a)return!1;let o=Lo(t.state,t.posAtDOM(a,0));return o?(e({src:o.src,alt:o.alt,event:r}),!0):!1}}}))}function zo(e){return/^https?:\/\//i.test(e)?e:void 0}function Bo(e){let t=document.createElement(`iframe`);return t.src=e.src,t.title=e.title,t.className=e.className,t.dataset.testid=e.testid,t.loading=`lazy`,t.referrerPolicy=`strict-origin-when-cross-origin`,t.setAttribute(`frameborder`,`0`),e.allow&&(t.allow=e.allow),e.allowFullscreen&&(t.allowFullscreen=!0),e.kind===`tweet`&&Pa(t),t}function Vo(e,t,n,r){if(n!=null&&r!=null){e.setAttribute(`data-width`,String(n)),e.setAttribute(`data-height`,String(r));return}let i=t.naturalWidth/t.naturalHeight;if(!Number.isFinite(i)||i<=0){n!=null&&e.setAttribute(`data-width`,String(n)),r!=null&&e.setAttribute(`data-height`,String(r));return}let a=n==null?Math.min(t.naturalHeight,500):n/i,o=n??a*i;e.setAttribute(`data-width`,String(Math.round(o))),e.setAttribute(`data-height`,String(Math.round(a)))}function Ho(e,t,n,r){let i=e.posAtDOM(t,0),a=O(e.state,i,`mdImage`);if(!a)return;let o=e.state.doc.textBetween(a.from,a.to),s=zn(o),c=a.from+s.length,l=o.slice(s.length),u=Rn({...In(l)??{},width:Math.round(n),height:Math.round(r)});u!==l&&e.dispatch(e.state.tr.insertText(u,c,a.to))}var Uo=class{#e;#t;#n;#r;#i;#a;#o;constructor(e,t,n){this.#i=e.attrs,this.#n=n,this.#r=t,this.#e=document.createElement(`span`),this.#e.className=`md-image-view md-atom-view`,this.#t=document.createElement(`span`),this.#t.className=`md-image-view-content md-atom-view-content`;let r=this.#s();r&&(r.contentEditable=`false`,this.#e.appendChild(r)),this.#e.appendChild(this.#t)}get dom(){return this.#e}get contentDOM(){return this.#t}update(e){let t=e.attrs,n=this.#i;return t.src===n.src?(this.#i=t,this.#o&&t.alt!==n.alt&&(this.#o.alt=t.alt),this.#a&&this.#o&&(t.width!==n.width||t.height!==n.height)&&Vo(this.#a,this.#o,t.width,t.height),!0):!1}ignoreMutation(e){return!this.#t.contains(e.target)}#s(){let{src:e}=this.#i,t=Va(e);if(t){let e=document.createElement(`span`);return e.className=`md-image-view-preview md-atom-view-preview`,e.appendChild(Bo(t)),e}let n=(this.#n.resolveImageUrl??zo)(e);if(!n)return;let r=document.createElement(`span`);return r.className=`md-image-view-preview md-atom-view-preview`,r.dataset.testid=`image-preview`,r.appendChild(this.#c(n)),r}#c(e){xt(),bt();let t=document.createElement(`prosekit-resizable-root`);t.className=`md-image-resizable`,t.dataset.testid=`image-resizable`,t.setAttribute(`data-loading`,``);let n=document.createElement(`img`);n.src=e,n.alt=this.#i.alt,n.draggable=!1,Vo(t,n,this.#i.width,this.#i.height),n.addEventListener(`load`,()=>{t.removeAttribute(`data-loading`);let e=n.naturalWidth/n.naturalHeight;!Number.isFinite(e)||e<=0||(t.setAttribute(`data-aspect-ratio`,String(e)),Vo(t,n,this.#i.width,this.#i.height))}),n.addEventListener(`error`,()=>{t.removeAttribute(`data-loading`)}),t.appendChild(n);let r=document.createElement(`prosekit-resizable-handle`);return r.className=`md-image-resize-handle`,r.setAttribute(`position`,`bottom-right`),r.addEventListener(`click`,e=>e.stopPropagation()),t.appendChild(r),t.addEventListener(`resizeEnd`,e=>{let{width:t,height:n}=e.detail;Ho(this.#r,this.#t,t,n)}),this.#a=t,this.#o=n,t}};function Wo(e={}){return d({name:`mdImage`,constructor:(t,n)=>new Uo(t,n,e)})}const Go={"Mod-b":`Bold`,"Mod-i":`Italic`,"Mod-e":`Inline code`,"Mod-Shift-x":`Strikethrough`,"Mod-Shift-h":`Highlight`,"Mod-k":`Link`,"Mod-Shift-k":`Insert a wikilink`,"Mod-1":`Heading 1`,"Mod-2":`Heading 2`,"Mod-3":`Heading 3`,"Mod-4":`Heading 4`,"Mod-5":`Heading 5`,"Mod-6":`Heading 6`,"Mod-.":`Fold or unfold a bullet`,"Mod-Enter":`Follow the link under the caret, or cycle a checkbox task`,"Mod-Shift-Enter":`Cycle a circle checkbox task`,"Mod-Shift-7":`Ordered list`,"Mod-Shift-8":`Bullet list`,"Mod-Shift-9":`Checkbox task list`,"Alt-ArrowUp":`Move the block or list item up`,"Alt-ArrowDown":`Move the block or list item down`,Escape:`Collapse the selection`},Ko=new x(`meowdown-link-click`);function qo(e){return vo({key:Ko,selector:`.md-link`,preventDefault:!0,findPayloadAt:(e,t)=>K(e,t)?.href,onClick:(t,n)=>e({href:t,event:n})})}function Jo(e){let t,n=(n,r)=>{let i=r.target;if(!i||!fe(i))return;let a=i.closest(e.selector);if(!a||a===t)return;let o=n.posAtDOM(a,0),s=e.findPayloadAt(n.state,o);s!=null&&(t=a,e.onHoverChange({payload:s,element:a}))},r=n=>{if(!t)return;let r=n.relatedTarget;r&&t.contains(r)||(t=void 0,e.onHoverChange(void 0))};return _(s(`mouseover`,(e,t)=>n(e,t)),s(`mouseout`,(e,t)=>r(t)))}function Yo(e){return Jo({selector:`.md-link`,findPayloadAt:(e,t)=>K(e,t),onHoverChange:e})}const Xo=new x(`meowdown-markdown-copy`);function Zo(){return m(new b({key:Xo,props:{clipboardTextSerializer:(e,t)=>{let n=e.content,r;try{r=t.state.schema.topNodeType.createAndFill(void 0,n)??void 0}catch{r=void 0}return r?$(r).replace(/\n+$/,``):n.textBetween(0,n.size,`
|
|
23
|
+
`,` `)}function Po(e){return e.replace(/\n+$/u,``)}function Fo(e){return/^[\s>]*$/u.test(e)}function Io(e){return e.split(`
|
|
24
|
+
`).filter(e=>!Fo(e))}function Lo(e){return e.trim().replaceAll(/\s+/gu,` `)}function Ro(e,t={}){let n=_o(X(e,{frontmatter:t.frontmatter}),{frontmatter:t.frontmatter});if(Po(n)===Po(e))return`exact`;let r=Io(e),i=Io(n);return r.length===i.length&&r.every((e,t)=>Lo(e)===Lo(i[t]))?`normalizing`:`lossy`}const zo=(e,t)=>{let{$from:n,empty:r}=e.selection;if(!r||n.depth!==1||n.index(0)!==0||n.parent.type.name!==`heading`||n.parentOffset!==n.parent.content.size)return!1;if(t){let r=ne(e.schema,`list`),i=ne(e.schema,`paragraph`),a=r.create({kind:`bullet`},i.create()),o=n.after(),s=e.tr.insert(o,a);s.setSelection(x.create(s.doc,o+2)),t(s.scrollIntoView())}return!0};function Bo(){return _(l({Enter:zo}),t.high)}const Vo=new Set([`MscGen`,`Xù`,`MsGenny`,`Angular Template`,`Brainfuck`,`Esper`,`Oz`,`Factor`,`Squirrel`,`Yacas`,`mIRC`,`FCL`,`ECL`,`MUMPS`,`Pig`,`Asterisk`,`Z80`]),Ho=Ce.map(e=>e.name).filter(e=>!Vo.has(e)).map(e=>({label:e,value:e.toLowerCase()})).concat({label:`Plain text`,value:``}).sort((e,t)=>e.label.localeCompare(t.label));function Uo(){return typeof window>`u`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches}const Wo=/^(?:www\.|mobile\.)?(?:twitter\.com|x\.com)$/i,Go=/\/status(?:es)?\/(\d+)/;function Ko(e){let t;try{t=new URL(e)}catch{return}if(Wo.test(t.hostname))return Go.exec(t.pathname)?.[1]}const qo=e=>{let t=Ko(e);if(!t)return;let n=Uo()?`dark`:`light`;return{kind:`tweet`,key:`tweet:${t}`,src:`https://platform.twitter.com/embed/Tweet.html?id=${t}&theme=${n}&dnt=true`,title:`Tweet`,className:`md-embed md-embed-tweet`,testid:`tweet-embed`}};function Jo(e){let t=t=>{if(t.source===e.contentWindow)try{let n=t.data?.[`twttr.embed`]?.params?.[0]?.height;typeof n==`number`&&(e.style.height=`${n}px`)}catch(e){console.warn(`[meowdown] failed to parse tweet resize message:`,e)}};window.addEventListener(`message`,t);let n=!1,r=()=>{n||(n=!0,window.removeEventListener(`message`,t),i.disconnect())},i=new MutationObserver(()=>{e.isConnected||r()});return i.observe(document.body,{childList:!0,subtree:!0}),r}const Yo=/^(?:www\.|m\.)?(?:youtube\.com|youtube-nocookie\.com)$/i,Xo=/^(?:www\.)?youtu\.be$/i,Zo=/^[\w-]{11}$/;function Qo(e){let t;try{t=new URL(e)}catch{return}let n=null;if(Xo.test(t.hostname))n=t.pathname.slice(1);else if(Yo.test(t.hostname)){let[,e,r]=t.pathname.split(`/`);t.pathname===`/watch`?n=t.searchParams.get(`v`):(e===`shorts`||e===`embed`||e===`live`)&&(n=r??null)}if(!n||!Zo.test(n))return;let r=t.searchParams.get(`start`)??t.searchParams.get(`t`),i=r?$o(r):void 0;return{videoId:n,startSeconds:i}}function $o(e){if(/^\d+$/.test(e))return Number(e);let t=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(e);if(!(!t||!t[1]&&!t[2]&&!t[3]))return Number(t[1]??0)*3600+Number(t[2]??0)*60+Number(t[3]??0)}const es=[e=>{let t=Qo(e);if(!t)return;let n=t.startSeconds?`?start=${t.startSeconds}`:``;return{kind:`youtube`,key:`youtube:${t.videoId}:${t.startSeconds??0}`,src:`https://www.youtube-nocookie.com/embed/${t.videoId}${n}`,title:`YouTube video`,className:`md-embed md-embed-youtube`,testid:`youtube-embed`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen`,allowFullscreen:!0}},qo];function ts(e){for(let t of es){let n=t(e);if(n)return n}}const ns=new b(`meowdown-embed-paste`);function rs(e){let t=e.trim();if(!(!t||/\s/.test(t)))return ts(t)?t:void 0}function is(e,t){return e.clipboardData?.getData(`text/plain`)||t.content.textBetween(0,t.content.size,`
|
|
25
|
+
`)}function as(e,t){let{from:n,to:r}=e.state.selection;e.dispatch(vt(e.state.tr.insertText(t,n,r)));let i=e.state.tr.insertText(``,n,n+t.length);e.dispatch(vt(i))}function os(){return m(new y({key:ns,props:{handlePaste:(e,t,n)=>{let r=e.state.selection.$from.parent;if(!r.inlineContent||r.type.spec.code)return!1;let i=is(t,n);if(!i)return!1;let a=rs(i);return a?(as(e,a),!0):!1}}}))}const ss=new b(`meowdown-exit-boundary`);function cs(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):void 0:i;return!!(a&&xe.findFrom(a,t))}function ls(e,t){let{state:n}=e,{selection:r}=n;return h(r)&&!r.empty||re(r)||r.$from.parent.inlineContent&&!e.endOfTextblock(t<0?`up`:`down`)?!0:cs(n,t)}function us(e){return new y({key:ss,props:{handleKeyDown:(t,n)=>{if(n.shiftKey||n.altKey||n.ctrlKey||n.metaKey)return!1;let r=n.key===`ArrowUp`?-1:n.key===`ArrowDown`?1:void 0;return!(!r||ls(t,r)||e({direction:r<0?`up`:`down`,event:n})===!1)}}})}function ds(e){return _(m(us(e)),t.low)}function fs(e){return!!e.type?.startsWith(`image/`)}function ps(e,t){return fs(e)?``:`[${gs(e.name)}](${t})`}function ms(e,t){return!e||!t.onFilePaste?[]:Array.from(e.files)}const hs=e=>{console.error(`[meowdown] failed to save pasted file:`,e)};function gs(e){return e.replaceAll(/[\\[\]]/g,String.raw`\$&`)}async function _s(e,t,n,r){let{onFilePaste:i}=n;if(!i)return;let a=n.onFileSaveError??hs,o=r,s=!1;for(let n of t){let t;try{t=await i(n)}catch(e){a(e,n);continue}if(!t||e.isDestroyed)continue;let r=ps(n,t),c=s?`\n${r}`:r,l=o==null?e.state.tr.insertText(c):e.state.tr.insertText(c,o);e.dispatch(l),s=!0,o!=null&&(o+=c.length)}}function vs(e){return new y({key:new b(`file-paste`),props:{handlePaste:(t,n)=>{let r=ms(n.clipboardData,e);return r.length===0?!1:(_s(t,r,e),!0)},handleDrop:(t,n)=>{let r=ms(n.dataTransfer,e);return r.length===0?!1:(_s(t,r,e,t.posAtCoords({left:n.clientX,top:n.clientY})?.pos),!0)}}})}function ys(e={}){return _(m(vs(e)),t.high)}const bs=new b(`meowdown-file-click`);function xs(e,t){let n=E(e,t,`mdFile`);if(!n)return;let{href:r,name:i}=n.mark.attrs;return{href:r,name:i}}function Ss(e){return m(new y({key:bs,props:{handleClick:(t,n,r)=>{let i=r.target?.closest?.(`.md-file-view-preview`);if(!i)return!1;let a=i.closest(`.md-file-view`)?.querySelector(`.md-file-view-content`);if(!a)return!1;let o=xs(t.state,t.posAtDOM(a,0));return o?(e({href:o.href,name:o.name,event:r}),!0):!1}}}))}const Cs=[`KB`,`MB`,`GB`,`TB`];function ws(e){let t=e,n=`B`;for(let e of Cs){if(t<999.5)break;t/=1e3,n=e}return n===`B`?`${Math.round(t)} B`:`${t<9.95?Math.round(t*10)/10:Math.round(t)} ${n}`}const Ts=new Map([[`pdf`,`pdf`],[`zip`,`archive`],[`tar`,`archive`],[`gz`,`archive`],[`tgz`,`archive`],[`rar`,`archive`],[`7z`,`archive`],[`doc`,`doc`],[`docx`,`doc`],[`pages`,`doc`],[`xls`,`sheet`],[`xlsx`,`sheet`],[`csv`,`sheet`],[`numbers`,`sheet`],[`ppt`,`slides`],[`pptx`,`slides`],[`key`,`slides`],[`mp3`,`audio`],[`wav`,`audio`],[`m4a`,`audio`],[`flac`,`audio`],[`ogg`,`audio`],[`mp4`,`video`],[`mov`,`video`],[`mkv`,`video`],[`webm`,`video`],[`txt`,`text`],[`md`,`text`]]);function Es(e){let t=e.split(/[?#]/,1)[0],n=t.lastIndexOf(`.`);if(n<0)return`generic`;let r=t.slice(n+1).toLowerCase();return Ts.get(r)??`generic`}const Ds=`http://www.w3.org/2000/svg`;function Os(){let e=document.createElementNS(Ds,`svg`);e.setAttribute(`class`,`md-file-view-icon`),e.setAttribute(`viewBox`,`0 0 24 24`),e.setAttribute(`aria-hidden`,`true`);for(let t of[`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,`M14 2v4a2 2 0 0 0 2 2h4`]){let n=document.createElementNS(Ds,`path`);n.setAttribute(`d`,t),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`2`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`),e.appendChild(n)}return e}var ks=class{#e;#t;#n;#r;#i;#a;#o=!1;constructor(e,t){this.#a=e.attrs,this.#e=document.createElement(`span`),this.#e.className=`md-file-view md-atom-view`,this.#n=document.createElement(`span`),this.#n.className=`md-file-view-preview md-atom-view-preview`,this.#n.contentEditable=`false`,this.#n.dataset.testid=`file-pill`,this.#n.dataset.fileKind=Es(this.#a.href),this.#n.title=this.#a.name,this.#e.appendChild(this.#n),this.#n.appendChild(Os()),this.#r=document.createElement(`span`),this.#r.className=`md-file-view-name`,this.#r.textContent=this.#a.name,this.#n.appendChild(this.#r),this.#i=document.createElement(`span`),this.#i.className=`md-file-view-size`,this.#i.dataset.testid=`file-pill-size`,this.#n.appendChild(this.#i),this.#t=document.createElement(`span`),this.#t.className=`md-file-view-content md-atom-view-content`,this.#e.appendChild(this.#t),this.#s(t.resolveFileInfo)}get dom(){return this.#e}get contentDOM(){return this.#t}update(e){let t=e.attrs,n=this.#a;return t.href===n.href?(this.#a=t,t.name!==n.name&&(this.#r.textContent=t.name,this.#n.title=t.name),!0):!1}ignoreMutation(e){return!this.#t.contains(e.target)}destroy(){this.#o=!0}async#s(e){if(!e)return;let t;try{t=await e(this.#a.href)}catch(e){console.error(`[meowdown] resolveFileInfo failed:`,e);return}if(this.#o||!t)return;let{size:n}=t;n==null||!Number.isFinite(n)||n<0||(this.#i.textContent=ws(n))}};function As(e={}){return d({name:`mdFile`,constructor:t=>new ks(t,e)})}function js(e){return m(new y({key:e.key,props:{handleClick:(t,n,r)=>{if(!r.target?.closest?.(e.selector))return!1;let i=e.findPayloadAt(t.state,n);return i==null?!1:(e.preventDefault&&r.preventDefault(),e.onClick(i,r),!0)}}}))}const Ms=new b(`meowdown-tag-click`);function Ns(e,t){let n=E(e,t,`mdTag`);if(!n)return;let r=e.doc.textBetween(n.from,n.to),i=r.startsWith(`#`)?r.slice(1):r;return{from:n.from,to:n.to,tag:i}}function Ps(e){return js({key:Ms,selector:`.md-tag`,preventDefault:!1,findPayloadAt:(e,t)=>Ns(e,t)?.tag,onClick:(t,n)=>e({tag:t,event:n})})}const Fs=new b(`meowdown-wikilink-click`);function Is(e,t){let n=E(e,t,`mdWikilink`);if(!n)return;let{target:r}=n.mark.attrs;return{from:n.from,to:n.to,target:r}}function Ls(e){return js({key:Fs,selector:`.md-wikilink-view-preview`,preventDefault:!1,findPayloadAt:(e,t)=>Is(e,t)?.target,onClick:(t,n)=>e({target:t,event:n})})}const Rs=new b(`meowdown-follow-link`);function zs(e){return e.key!==`Enter`||e.shiftKey||e.altKey?!1:ie?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Bs(e){return new y({key:Rs,props:{handleKeyDown:(t,n)=>{if(!zs(n))return!1;let{state:r}=t,i=r.selection.head,a=e.onWikilinkClick&&Is(r,i);if(a)return e.onWikilinkClick?.({target:a.target,event:n}),!0;let o=e.onTagClick&&Ns(r,i);if(o)return e.onTagClick?.({tag:o.tag,event:n}),!0;let s=e.onFileClick&&xs(r,i);if(s)return e.onFileClick?.({href:s.href,name:s.name,event:n}),!0;let c=e.onLinkClick&&K(r,i);return c?(e.onLinkClick?.({href:c.href,event:n}),!0):!1}}})}function Vs(e){return _(m(Bs(e)),t.high)}const Hs=(e,t)=>{let n={type:`highlight`,children:e.all(t)};return e.patch(t,n),n},Us=(e,t,n,r)=>{let i=e,a=n.createTracker(r),o=a.move(`==`);return o+=a.move(n.containerPhrasing(i,{...a.current(),before:o,after:`=`})),o+=a.move(`==`),o};function Ws(){return Ct().use(yt).use(bt,{handlers:{mark:Hs}}).use(xt).use(St,{bullet:`-`,emphasis:`*`,strong:`*`,fence:"`",fences:!0,rule:`-`,ruleRepetition:3,listItemIndent:`one`,handlers:{highlight:Us}}).freeze()}const Gs=v(Ws);function Ks(e){return String(Gs().processSync(e))}const qs=new b(`meowdown-html-paste`);function Js(){return m(new y({key:qs,props:{transformPastedHTML:(e,t)=>{if(e.includes(`data-pm-slice`))return e;let n=t.state.selection.$from.parent;if(!n.inlineContent||n.type.spec.code)return e;let r=Ks(e);if(!r.trim())return e;let i=X(r,{nodes:Qa(t.state.schema)}),a=Me.fromSchema(t.state.schema),o=document.createElement(`div`);return o.append(a.serializeFragment(i.content)),o.innerHTML}}}))}const Ys=new b(`meowdown-image-click`);function Xs(e,t){let n=E(e,t,`mdImage`);if(!n)return;let{src:r,alt:i}=n.mark.attrs;return{from:n.from,to:n.to,src:r,alt:i}}function Zs(e){return m(new y({key:Ys,props:{handleClick:(t,n,r)=>{let i=r.target?.closest?.(`.md-image-view-preview`);if(!i)return!1;let a=i.closest(`.md-image-view`)?.querySelector(`.md-image-view-content`);if(!a)return!1;let o=Xs(t.state,t.posAtDOM(a,0));return o?(e({src:o.src,alt:o.alt,event:r}),!0):!1}}}))}function Qs(e){return/^https?:\/\//i.test(e)?e:void 0}function $s(e){let t=document.createElement(`iframe`);return t.src=e.src,t.title=e.title,t.className=e.className,t.dataset.testid=e.testid,t.loading=`lazy`,t.referrerPolicy=`strict-origin-when-cross-origin`,t.setAttribute(`frameborder`,`0`),e.allow&&(t.allow=e.allow),e.allowFullscreen&&(t.allowFullscreen=!0),e.kind===`tweet`&&Jo(t),t}function ec(e,t,n,r){if(n!=null&&r!=null){e.setAttribute(`data-width`,String(n)),e.setAttribute(`data-height`,String(r));return}let i=t.naturalWidth/t.naturalHeight;if(!Number.isFinite(i)||i<=0){n!=null&&e.setAttribute(`data-width`,String(n)),r!=null&&e.setAttribute(`data-height`,String(r));return}let a=n==null?Math.min(t.naturalHeight,500):n/i,o=n??a*i;e.setAttribute(`data-width`,String(Math.round(o))),e.setAttribute(`data-height`,String(Math.round(a)))}function tc(e,t,n,r){let i=e.posAtDOM(t,0),a=E(e.state,i,`mdImage`);if(!a)return;let o=e.state.doc.textBetween(a.from,a.to),s=gr(o),c=a.from+s.length,l=o.slice(s.length),u=hr({...pr(l)??{},width:Math.round(n),height:Math.round(r)});u!==l&&e.dispatch(e.state.tr.insertText(u,c,a.to))}var nc=class{#e;#t;#n;#r;#i;#a;#o;constructor(e,t,n){this.#i=e.attrs,this.#n=n,this.#r=t,this.#e=document.createElement(`span`),this.#e.className=`md-image-view md-atom-view`,this.#t=document.createElement(`span`),this.#t.className=`md-image-view-content md-atom-view-content`;let r=this.#s();r&&(r.contentEditable=`false`,this.#e.appendChild(r)),this.#e.appendChild(this.#t)}get dom(){return this.#e}get contentDOM(){return this.#t}update(e){let t=e.attrs,n=this.#i;return t.src===n.src?(this.#i=t,this.#o&&t.alt!==n.alt&&(this.#o.alt=t.alt),this.#a&&this.#o&&(t.width!==n.width||t.height!==n.height)&&ec(this.#a,this.#o,t.width,t.height),!0):!1}ignoreMutation(e){return!this.#t.contains(e.target)}#s(){let{src:e}=this.#i,t=ts(e);if(t){let e=document.createElement(`span`);return e.className=`md-image-view-preview md-atom-view-preview`,e.appendChild($s(t)),e}let n=(this.#n.resolveImageUrl??Qs)(e);if(!n)return;let r=document.createElement(`span`);return r.className=`md-image-view-preview md-atom-view-preview`,r.dataset.testid=`image-preview`,r.appendChild(this.#c(n)),r}#c(e){Tt(),wt();let t=document.createElement(`prosekit-resizable-root`);t.className=`md-image-resizable`,t.dataset.testid=`image-resizable`,t.setAttribute(`data-loading`,``);let n=document.createElement(`img`);n.src=e,n.alt=this.#i.alt,n.draggable=!1,ec(t,n,this.#i.width,this.#i.height),n.addEventListener(`load`,()=>{t.removeAttribute(`data-loading`);let e=n.naturalWidth/n.naturalHeight;!Number.isFinite(e)||e<=0||(t.setAttribute(`data-aspect-ratio`,String(e)),ec(t,n,this.#i.width,this.#i.height))}),n.addEventListener(`error`,()=>{t.removeAttribute(`data-loading`)}),t.appendChild(n);let r=document.createElement(`prosekit-resizable-handle`);return r.className=`md-image-resize-handle`,r.setAttribute(`position`,`bottom-right`),r.addEventListener(`click`,e=>e.stopPropagation()),t.appendChild(r),t.addEventListener(`resizeEnd`,e=>{let{width:t,height:n}=e.detail;tc(this.#r,this.#t,t,n)}),this.#a=t,this.#o=n,t}};function rc(e={}){return d({name:`mdImage`,constructor:(t,n)=>new nc(t,n,e)})}const ic={"Mod-b":`Bold`,"Mod-i":`Italic`,"Mod-e":`Inline code`,"Mod-Shift-x":`Strikethrough`,"Mod-Shift-h":`Highlight`,"Mod-k":`Link`,"Mod-Shift-k":`Insert a wikilink`,"Mod-1":`Heading 1`,"Mod-2":`Heading 2`,"Mod-3":`Heading 3`,"Mod-4":`Heading 4`,"Mod-5":`Heading 5`,"Mod-6":`Heading 6`,"Mod-.":`Fold or unfold a bullet`,"Mod-Enter":`Follow the link under the caret, or cycle a checkbox task`,"Mod-Shift-Enter":`Cycle a circle checkbox task`,"Mod-Shift-7":`Ordered list`,"Mod-Shift-8":`Bullet list`,"Mod-Shift-9":`Checkbox task list`,"Alt-ArrowUp":`Move the block or list item up`,"Alt-ArrowDown":`Move the block or list item down`,Escape:`Collapse the selection`},ac=new b(`meowdown-link-click`);function oc(e){return js({key:ac,selector:`.md-link`,preventDefault:!0,findPayloadAt:(e,t)=>K(e,t)?.href,onClick:(t,n)=>e({href:t,event:n})})}function sc(e){let t,n=(n,r)=>{let i=r.target;if(!i||!pe(i))return;let a=i.closest(e.selector);if(!a||a===t)return;let o=n.posAtDOM(a,0),s=e.findPayloadAt(n.state,o);s!=null&&(t=a,e.onHoverChange({payload:s,element:a}))},r=n=>{if(!t)return;let r=n.relatedTarget;r&&t.contains(r)||(t=void 0,e.onHoverChange(void 0))};return g(s(`mouseover`,(e,t)=>n(e,t)),s(`mouseout`,(e,t)=>r(t)))}function cc(e){return sc({selector:`.md-link`,findPayloadAt:(e,t)=>K(e,t),onHoverChange:e})}const lc=new b(`meowdown-markdown-copy`);function uc(){return m(new y({key:lc,props:{clipboardTextSerializer:(e,t)=>{let n=e.content,r;try{r=t.state.schema.topNodeType.createAndFill(void 0,n)??void 0}catch{r=void 0}return r?_o(r).replace(/\n+$/,``):n.textBetween(0,n.size,`
|
|
24
26
|
`,`
|
|
25
|
-
`)}}}))}function
|
|
27
|
+
`)}}}))}function dc({allowEmpty:e}){return(t,n)=>{let{selection:r}=t;if(!h(r)||!e&&r.empty||!r.$head.sameParent(r.$anchor)||r.$head.parent.type.spec.code)return!1;let i=t.doc.textBetween(r.from,r.to);if(i.startsWith(`[[`))return!1;i.startsWith(`[`)&&(i=i.slice(1));let a=`[[`+i;if(n){let e=t.tr.insertText(a,r.from,r.to);e.setSelection(x.create(e.doc,r.from+a.length)),Et(e),n(e.scrollIntoView())}return!0}}function fc(){return l({"Mod-Shift-k":dc({allowEmpty:!0}),"[":dc({allowEmpty:!1})})}function pc(e){let{selection:t,schema:n}=e;if(t.empty)return``;let r=t.content().content;try{return _o(n.topNodeType.create(null,r)).replace(/\n+$/,``)}catch{return e.doc.textBetween(t.from,t.to,`
|
|
26
28
|
|
|
27
|
-
`)}}function
|
|
29
|
+
`)}}function mc(e,t){let n=new DOMRect(0,0,0,0),r=()=>{if(e.isDestroyed)return n;let r=Y(e,t.from,1)??Y(e,t.from,-1),i=Y(e,t.to,-1)??Y(e,t.to,1);if(r==null||i==null)return n;let a=Math.min(r.left,i.left),o=Math.max(r.right,i.right),s=Math.min(r.top,i.top),c=Math.max(r.bottom,i.bottom);return n=new DOMRect(a,s,o-a,c-s),n};return{getBoundingClientRect:r,getClientRects:()=>[r()]}}function hc(e){return e instanceof Re||e instanceof ze||e instanceof Be||e instanceof Ve||e instanceof R}function gc(e){for(let t of e)for(let e of t.steps)if(!hc(e))return!0;return!1}function _c(e){let t,n,r=!1,i,a=()=>{let n=t&&!t.isDestroyed&&t.dom;if(!n)return;let a=e&&!r;a!==i&&(i=a,n.spellcheck=a)},o=()=>{n&&clearTimeout(n),r=!0,a(),n=setTimeout(()=>{r=!1,a()},1200)};return{pause:o,apply(e){gc(e)&&o()},view(e){return t=e,{destroy(){t=void 0}}}}}function vc(e){let t=new b(`spell-check`);return new y({key:t,state:{init:()=>_c(e),apply:(e,t)=>t},view(e){return t.getState(e.state)?.view(e)||{}},props:{handleDOMEvents:{beforeinput:e=>{t.getState(e.state)?.pause()}}},appendTransaction(e,n){t.getState(n)?.apply(e)}})}function yc(e){return m(vc(e))}export{ic as EDITOR_KEY_BINDINGS,e as Priority,ps as buildFileMarkdown,Ro as checkRoundTrip,Ho as codeBlockLanguages,Qs as defaultResolveImageUrl,Bo as defineBulletAfterHeading,Xt as defineCodeBlockSyntaxHighlight,Ga as defineEditorExtension,os as defineEmbedPaste,ds as defineExitBoundaryHandler,Ss as defineFileClickHandler,ys as defineFilePaste,As as defineFileView,Vs as defineFollowLinkHandler,Bn as defineHTMLComment,Js as defineHTMLPaste,rc as defineImage,Zs as defineImageClickHandler,oc as defineLinkClickHandler,Di as defineLinkCommands,ki as defineLinkEditKeymap,cc as defineLinkHoverHandler,uc as defineMarkdownCopy,Aa as definePendingReplacementHandler,de as definePlaceholder,fe as defineReadonly,yc as defineSpellCheckPlugin,Ps as defineTagClickHandler,Ls as defineWikilinkClickHandler,fc as defineWikilinkTrigger,_o as docToMarkdown,Qt as getCodeTokens,K as getLinkUnitAt,Ja as getMarkBuilders,J as getPendingReplacement,pc as getSelectedText,oa as getTableColumnAlign,mc as getVirtualElementFromRange,Sr as inlineTextToMarkChunks,wi as insertLink,la as isSelectionInTableCell,Jo as listenForTweetHeight,X as markdownToDoc,ts as matchEmbed,Ei as removeLink,Ti as updateLink,le as withPriority};
|
package/dist/style.css
CHANGED
|
@@ -155,6 +155,8 @@
|
|
|
155
155
|
--meowdown-heading: light-dark(oklch(21% .006 286), oklch(98.5% 0 0));
|
|
156
156
|
--meowdown-muted: light-dark(oklch(44.2% .015 286), oklch(71.2% .013 286));
|
|
157
157
|
--meowdown-accent: light-dark(oklch(64.6% .194 41), oklch(75.8% .159 56));
|
|
158
|
+
--meowdown-caret: var(--meowdown-accent);
|
|
159
|
+
--meowdown-caret-glide: 80ms;
|
|
158
160
|
--meowdown-mark: var(--meowdown-muted);
|
|
159
161
|
--meowdown-highlight: light-dark(oklch(94.5% .124 102), oklch(47.6% .103 62));
|
|
160
162
|
--meowdown-border: light-dark(oklch(92% .004 286), oklch(37% .012 286));
|
|
@@ -187,13 +189,94 @@
|
|
|
187
189
|
.ProseMirror {
|
|
188
190
|
box-sizing: border-box;
|
|
189
191
|
color: var(--meowdown-text);
|
|
190
|
-
caret-color:
|
|
192
|
+
caret-color: #0000;
|
|
191
193
|
-webkit-font-smoothing: antialiased;
|
|
192
194
|
outline: none;
|
|
193
195
|
font-size: 1.0625rem;
|
|
194
196
|
line-height: 1.7;
|
|
195
197
|
}
|
|
196
198
|
|
|
199
|
+
.md-virtual-caret-layer {
|
|
200
|
+
pointer-events: none;
|
|
201
|
+
width: 0;
|
|
202
|
+
height: 0;
|
|
203
|
+
position: relative;
|
|
204
|
+
overflow: visible;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.md-virtual-caret-layer .md-virtual-caret {
|
|
208
|
+
box-sizing: border-box;
|
|
209
|
+
background: var(--meowdown-caret);
|
|
210
|
+
pointer-events: none;
|
|
211
|
+
-webkit-user-select: none;
|
|
212
|
+
user-select: none;
|
|
213
|
+
width: 2px;
|
|
214
|
+
transition: left var(--meowdown-caret-glide) cubic-bezier(.25, 1, .5, 1),
|
|
215
|
+
top var(--meowdown-caret-glide) cubic-bezier(.25, 1, .5, 1),
|
|
216
|
+
height var(--meowdown-caret-glide) cubic-bezier(.25, 1, .5, 1);
|
|
217
|
+
border-radius: 999px;
|
|
218
|
+
margin-left: -1px;
|
|
219
|
+
display: none;
|
|
220
|
+
position: absolute;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
@media (prefers-reduced-motion: reduce) {
|
|
224
|
+
.md-virtual-caret-layer .md-virtual-caret {
|
|
225
|
+
transition: none;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.ProseMirror.ProseMirror-focused ~ .md-virtual-caret-layer .md-virtual-caret {
|
|
230
|
+
animation: 1.2s ease-in-out infinite md-virtual-caret-blink;
|
|
231
|
+
display: block;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.md-virtual-caret-layer .md-virtual-caret[data-tail]:after {
|
|
235
|
+
content: "";
|
|
236
|
+
background: var(--meowdown-caret);
|
|
237
|
+
border-radius: 999px;
|
|
238
|
+
width: 6px;
|
|
239
|
+
height: 2px;
|
|
240
|
+
position: absolute;
|
|
241
|
+
bottom: 0;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.md-virtual-caret-layer .md-virtual-caret[data-tail="left"]:after {
|
|
245
|
+
right: 0;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.md-virtual-caret-layer .md-virtual-caret[data-tail="right"]:after {
|
|
249
|
+
left: 0;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
@keyframes md-virtual-caret-blink {
|
|
253
|
+
0%, 40% {
|
|
254
|
+
opacity: 1;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
60%, 90% {
|
|
258
|
+
opacity: 0;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
100% {
|
|
262
|
+
opacity: 1;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
@keyframes md-virtual-caret-blink2 {
|
|
267
|
+
0%, 40% {
|
|
268
|
+
opacity: 1;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
60%, 90% {
|
|
272
|
+
opacity: 0;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
100% {
|
|
276
|
+
opacity: 1;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
197
280
|
.meowdown-content {
|
|
198
281
|
padding-top: 1.25rem;
|
|
199
282
|
padding-right: var(--meowdown-gutter);
|
|
@@ -467,6 +550,14 @@
|
|
|
467
550
|
font-weight: 600;
|
|
468
551
|
}
|
|
469
552
|
|
|
553
|
+
.ProseMirror td[data-align="center"], .ProseMirror th[data-align="center"] {
|
|
554
|
+
text-align: center;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.ProseMirror td[data-align="right"], .ProseMirror th[data-align="right"] {
|
|
558
|
+
text-align: right;
|
|
559
|
+
}
|
|
560
|
+
|
|
470
561
|
.ProseMirror table.ProseMirror-selectednode td, .ProseMirror table.ProseMirror-selectednode th {
|
|
471
562
|
border-color: var(--meowdown-node-outline);
|
|
472
563
|
}
|
|
@@ -547,21 +638,21 @@
|
|
|
547
638
|
display: contents;
|
|
548
639
|
}
|
|
549
640
|
|
|
550
|
-
.ProseMirror[data-mark-mode="hide"] {
|
|
641
|
+
.ProseMirror[data-mark-mode="hide"], .ProseMirror[data-mark-mode="focus"] {
|
|
551
642
|
& .md-mark, & .md-link-uri, & .md-link-title {
|
|
552
|
-
|
|
643
|
+
letter-spacing: 0;
|
|
644
|
+
opacity: 0;
|
|
645
|
+
font-size: 0;
|
|
646
|
+
display: inline;
|
|
553
647
|
}
|
|
554
648
|
}
|
|
555
649
|
|
|
556
650
|
.ProseMirror[data-mark-mode="focus"] {
|
|
557
651
|
& .md-mark, & .md-link-uri, & .md-link-title {
|
|
558
|
-
opacity: 0;
|
|
559
|
-
font-size: 0;
|
|
560
|
-
display: inline;
|
|
561
|
-
|
|
562
652
|
&:has(.show) {
|
|
563
653
|
opacity: 1;
|
|
564
654
|
font-size: inherit;
|
|
655
|
+
letter-spacing: inherit;
|
|
565
656
|
}
|
|
566
657
|
}
|
|
567
658
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meowdown/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.35.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"@lezer/highlight": "^1.2.3",
|
|
26
26
|
"@lezer/markdown": "^1.6.4",
|
|
27
27
|
"@ocavue/utils": "^1.7.0",
|
|
28
|
-
"@prosekit/core": "^0.13.0-beta.
|
|
29
|
-
"@prosekit/extensions": "^0.18.0-beta.
|
|
30
|
-
"@prosekit/pm": "^0.1.19-beta.
|
|
31
|
-
"@prosekit/web": "^0.9.0-beta.
|
|
32
|
-
"prosemirror-flat-list": "^0.
|
|
28
|
+
"@prosekit/core": "^0.13.0-beta.5",
|
|
29
|
+
"@prosekit/extensions": "^0.18.0-beta.12",
|
|
30
|
+
"@prosekit/pm": "^0.1.19-beta.2",
|
|
31
|
+
"@prosekit/web": "^0.9.0-beta.17",
|
|
32
|
+
"prosemirror-flat-list": "^0.7.0",
|
|
33
33
|
"prosemirror-highlight": "^0.15.2",
|
|
34
34
|
"rehype-parse": "^9.0.1",
|
|
35
35
|
"rehype-remark": "^10.0.1",
|