@meowdown/core 0.22.0 → 0.24.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 +66 -30
- package/dist/index.d.ts +246 -200
- package/dist/index.js +14 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,27 +2,69 @@
|
|
|
2
2
|
|
|
3
3
|
The engine powering the editor in [`@meowdown/react`](https://www.npmjs.com/package/@meowdown/react): a hybrid (live-preview) Markdown editor core built on ProseKit and Lezer.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
5
|
+
[**Live demo**](https://meowdown.vercel.app/)
|
|
6
|
+
|
|
7
|
+
## Quick start
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @meowdown/core @prosekit/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Mount an editor into any DOM element, no framework required:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import '@meowdown/core/style.css'
|
|
17
|
+
import { createEditor } from '@prosekit/core'
|
|
18
|
+
import { defineEditorExtension, docToMarkdown, markdownToDoc } from '@meowdown/core'
|
|
19
|
+
|
|
20
|
+
const editor = createEditor({ extension: defineEditorExtension() })
|
|
21
|
+
editor.setContent(markdownToDoc('# Hello', { nodes: editor.nodes }))
|
|
22
|
+
editor.mount(document.querySelector<HTMLElement>('#editor')!)
|
|
23
|
+
|
|
24
|
+
// Serialize the current document back to Markdown at any time.
|
|
25
|
+
const markdown = docToMarkdown(editor.state.doc)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Supported Markdown features
|
|
29
|
+
|
|
30
|
+
- CommonMark
|
|
31
|
+
- ATX headings (`# Heading 1`, `## Heading 2`, etc.)
|
|
32
|
+
- Setext headings (`Heading 1\n===`, `Heading 2\n---`)
|
|
33
|
+
- Bullet lists (`- item`, `* item`, `+ item`)
|
|
34
|
+
- Ordered lists (`1. item`, `2) item`, etc.)
|
|
35
|
+
- Blockquotes (`> quote`)
|
|
36
|
+
- Fenced code blocks (` ```lang\ncode\n``` `)
|
|
37
|
+
- Thematic breaks (`---`, `***`, `___`)
|
|
38
|
+
- Bold (`**bold**`), italic (`*italic*`), and inline code
|
|
39
|
+
- Links (`[text](url)`), images (``), and autolinks (`<https://example.com>`)
|
|
40
|
+
- Hard line breaks
|
|
41
|
+
- GitHub Flavored Markdown (GFM)
|
|
42
|
+
- Tables
|
|
43
|
+
- Strikethrough (`~~text~~`)
|
|
44
|
+
- Task lists (`- [ ]`, `- [x]`)
|
|
45
|
+
- Autolinks for `www.`, scheme, and email URLs
|
|
46
|
+
- Wikilinks (`[[target]]` and `[[target|alias]]`)
|
|
47
|
+
- Highlight (`==highlight==`)
|
|
48
|
+
- Tags (`#tag`)
|
|
49
|
+
- Bare-domain autolinks (`google.com`, `sub.domain.io/path`)
|
|
50
|
+
|
|
51
|
+
## Keyboard shortcuts
|
|
52
|
+
|
|
53
|
+
`Mod` is Cmd on macOS and Ctrl elsewhere. Each formatting shortcut inserts or removes the literal Markdown delimiters around the selection; each heading shortcut toggles the current block to that level (or back to a paragraph).
|
|
54
|
+
|
|
55
|
+
| Key | Action | Markdown |
|
|
56
|
+
| ------------- | ------------- | ------------------- |
|
|
57
|
+
| `Mod-B` | Bold | `**bold**` |
|
|
58
|
+
| `Mod-I` | Italic | `*italic*` |
|
|
59
|
+
| `Mod-E` | Inline code | `` `code` `` |
|
|
60
|
+
| `Mod-Shift-X` | Strikethrough | `~~strikethrough~~` |
|
|
61
|
+
| `Mod-Shift-H` | Highlight | `==highlight==` |
|
|
62
|
+
| `Mod-1` | Heading 1 | `# heading` |
|
|
63
|
+
| `Mod-2` | Heading 2 | `## heading` |
|
|
64
|
+
| `Mod-3` | Heading 3 | `### heading` |
|
|
65
|
+
| `Mod-4` | Heading 4 | `#### heading` |
|
|
66
|
+
| `Mod-5` | Heading 5 | `##### heading` |
|
|
67
|
+
| `Mod-6` | Heading 6 | `###### heading` |
|
|
26
68
|
|
|
27
69
|
`EDITOR_KEY_BINDINGS` is a literal (`as const`) object mapping every key above to its description, for host settings UIs and keybinding-collision checks.
|
|
28
70
|
|
|
@@ -69,17 +111,11 @@ Pasting rich-text HTML from a browser (a bullet list, **bold**, a link, ...) con
|
|
|
69
111
|
|
|
70
112
|
Pressing Enter at the end of the document's first heading (the title line) can start a fresh empty bullet on the next line instead of a plain paragraph. `defineBulletAfterHeading()` binds this. It is not part of `defineEditorExtension`; add it explicitly.
|
|
71
113
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
`@meowdown/react`'s `<MarkdownView>` renders Markdown to a read-only React tree without an editor by reusing these building blocks, also exported for other renderers:
|
|
75
|
-
|
|
76
|
-
- `inlineTextToMarkChunks(getMarkBuilders(), text)`: the inline parser the editor uses, returning `[from, to, marks]` chunks (`MarkChunk`) for one line of source text.
|
|
77
|
-
- `getCodeTokens(code, language)`: syntax-highlight tokens (`CodeToken`, the tuple `[from, to, classes]`) tagged with the same `tok-*` classes as the editor. Returns synchronously once the Lezer grammar is cached, otherwise a promise.
|
|
78
|
-
- `matchEmbed(src)`: detects a tweet/YouTube image `src` and returns an `EmbedDescriptor` (no DOM); `listenForTweetHeight(iframe)` syncs a tweet iframe's height and returns a cleanup function.
|
|
114
|
+
Pressing ArrowUp on the first visual line or ArrowDown on the last, when the caret can move no further, can notify the host so it can move focus elsewhere (a previous/next note or page). `defineExitBoundaryHandler(({ direction, event }) => ...)` (or `@meowdown/react`'s `onExitBoundary` prop) fires with `direction` (`'up'` or `'down'`) and the original `KeyboardEvent`; return `false` to let the editor handle the key normally. It also fires for a selected node at the edge, and ignores arrows carrying a modifier. It is not part of `defineEditorExtension`; add it explicitly.
|
|
79
115
|
|
|
80
|
-
##
|
|
116
|
+
## API
|
|
81
117
|
|
|
82
|
-
|
|
118
|
+
See the full API reference [here](https://npmx.dev/package-docs/@meowdown%2Fcore/).
|
|
83
119
|
|
|
84
120
|
## License
|
|
85
121
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
import { Editor, Extension, ExtractMarkBuilders, ExtractNodeBuilders, PlainExtension, Priority, Union, withPriority } from "@prosekit/core";
|
|
2
|
+
import { PlaceholderOptions, definePlaceholder } from "@prosekit/extensions/placeholder";
|
|
3
|
+
import { defineReadonly } from "@prosekit/extensions/readonly";
|
|
2
4
|
import { CodeBlockAttrs } from "@prosekit/extensions/code-block";
|
|
3
5
|
import { HorizontalRuleExtension } from "@prosekit/extensions/horizontal-rule";
|
|
4
6
|
import { Mark, ProseMirrorNode } from "@prosekit/pm/model";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
//#region src/converters/check-roundtrip.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* How faithfully markdown survives a parse-then-serialize round trip:
|
|
10
|
+
* - `exact`: byte-identical (modulo the trailing newline).
|
|
11
|
+
* - `normalizing`: same non-blank lines ignoring trailing whitespace; only
|
|
12
|
+
* blank-line layout (including empty `>` lines inside a blockquote) or
|
|
13
|
+
* insignificant trailing whitespace differs.
|
|
14
|
+
* - `lossy`: a non-blank line changed, so content would be lost or altered.
|
|
15
|
+
*/
|
|
16
|
+
type RoundTripFidelity = 'exact' | 'normalizing' | 'lossy';
|
|
17
|
+
/** Options for {@link checkRoundTrip}. */
|
|
18
|
+
interface CheckRoundTripOptions {
|
|
19
|
+
/** Whether to handle a leading `---` frontmatter block. Off by default. */
|
|
20
|
+
frontmatter?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Classify how `markdown` survives the editor's parse-then-serialize round trip. */
|
|
23
|
+
declare function checkRoundTrip(markdown: string, options?: CheckRoundTripOptions): RoundTripFidelity;
|
|
24
|
+
//#endregion
|
|
8
25
|
//#region src/extensions/frontmatter.d.ts
|
|
9
26
|
/**
|
|
10
27
|
* The raw YAML frontmatter body, stored verbatim (the text between the opening
|
|
@@ -50,6 +67,41 @@ type HorizontalRuleMarkerExtension = Extension<{
|
|
|
50
67
|
}>;
|
|
51
68
|
type MeowdownHorizontalRuleExtension = Union<[HorizontalRuleExtension, HorizontalRuleMarkerExtension]>;
|
|
52
69
|
//#endregion
|
|
70
|
+
//#region src/extensions/html-comment.d.ts
|
|
71
|
+
interface MeowdownHTMLCommentAttrs {
|
|
72
|
+
/**
|
|
73
|
+
* The literal markdown comment, including its delimiters, e.g.
|
|
74
|
+
* `<!-- reflect-capture-page-text:start -->`. A multi-line comment keeps its
|
|
75
|
+
* embedded newlines verbatim so the round-trip is lossless.
|
|
76
|
+
*/
|
|
77
|
+
content: string;
|
|
78
|
+
}
|
|
79
|
+
type HTMLCommentExtension = Extension<{
|
|
80
|
+
Nodes: {
|
|
81
|
+
htmlComment: MeowdownHTMLCommentAttrs;
|
|
82
|
+
};
|
|
83
|
+
}>;
|
|
84
|
+
/**
|
|
85
|
+
* A block-level HTML comment (`<!-- ... -->`) as an invisible, atomic node.
|
|
86
|
+
*
|
|
87
|
+
* Markdown is the source of truth, so a comment must survive a round-trip — but
|
|
88
|
+
* a comment is, by definition, not rendered output. Rather than spilling the raw
|
|
89
|
+
* `<!-- ... -->` into a paragraph (where it reads as body text), the parser maps
|
|
90
|
+
* a `CommentBlock` onto this node: the text rides on the `content` attribute and
|
|
91
|
+
* `toDOM` hides it with `display: none`, so it stays in the document and
|
|
92
|
+
* serializes back verbatim while never showing in the editor. Useful for
|
|
93
|
+
* sentinel markers that tools embed around a region of a note.
|
|
94
|
+
*
|
|
95
|
+
* Only block-level comments (a `<!-- ... -->` that owns its line) become this
|
|
96
|
+
* node. An inline comment in the middle of a paragraph is left as literal text,
|
|
97
|
+
* and raw HTML blocks (`<div>…`) stay visible paragraphs — they can carry
|
|
98
|
+
* content a reader expects to see.
|
|
99
|
+
*
|
|
100
|
+
* The node is `atom` (no editable content) and not selectable: it is an opaque,
|
|
101
|
+
* invisible marker the cursor steps over rather than a block the user edits.
|
|
102
|
+
*/
|
|
103
|
+
declare function defineHTMLComment(): HTMLCommentExtension;
|
|
104
|
+
//#endregion
|
|
53
105
|
//#region src/extensions/inline-marks.d.ts
|
|
54
106
|
interface MdImageViewAttrs {
|
|
55
107
|
src: string;
|
|
@@ -128,7 +180,11 @@ declare function defineEditorExtensionImpl(): import("@prosekit/core").Union<rea
|
|
|
128
180
|
setextUnderline?: number | null;
|
|
129
181
|
};
|
|
130
182
|
};
|
|
131
|
-
}>, import("@prosekit/core").PlainExtension, import("@prosekit/extensions/heading").HeadingCommandsExtension, import("@prosekit/core").PlainExtension]>, import("@prosekit/core").Union<readonly [import("@prosekit/extensions/table").TableSpecExtension, import("@prosekit/extensions/table").TableRowSpecExtension, import("@prosekit/extensions/table").TableCellSpecExtension, import("@prosekit/extensions/table").TableHeaderCellSpecExtension, import("@prosekit/core").PlainExtension, import("@prosekit/extensions/table").TableCommandsExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension]>, import("@prosekit/extensions/code-block").CodeBlockExtension, MeowdownHorizontalRuleExtension, import("@prosekit/core").
|
|
183
|
+
}>, import("@prosekit/core").PlainExtension, import("@prosekit/extensions/heading").HeadingCommandsExtension, import("@prosekit/core").PlainExtension]>, import("@prosekit/core").Union<readonly [import("@prosekit/extensions/table").TableSpecExtension, import("@prosekit/extensions/table").TableRowSpecExtension, import("@prosekit/extensions/table").TableCellSpecExtension, import("@prosekit/extensions/table").TableHeaderCellSpecExtension, import("@prosekit/core").PlainExtension, import("@prosekit/extensions/table").TableCommandsExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension]>, import("@prosekit/extensions/code-block").CodeBlockExtension, MeowdownHorizontalRuleExtension, import("@prosekit/core").Extension<{
|
|
184
|
+
Nodes: {
|
|
185
|
+
htmlComment: MeowdownHTMLCommentAttrs;
|
|
186
|
+
};
|
|
187
|
+
}>, import("@prosekit/core").Union<readonly [import("@prosekit/core").Extension<{
|
|
132
188
|
Marks: {
|
|
133
189
|
mdMark: import("@prosekit/pm/model").Attrs;
|
|
134
190
|
};
|
|
@@ -197,63 +253,102 @@ type EditorExtension = ReturnType<typeof defineEditorExtensionImpl>;
|
|
|
197
253
|
declare function defineEditorExtension(): EditorExtension;
|
|
198
254
|
type TypedEditor = Editor<EditorExtension>;
|
|
199
255
|
//#endregion
|
|
200
|
-
//#region src/extensions/
|
|
256
|
+
//#region src/extensions/schema.d.ts
|
|
257
|
+
type TypedNodeBuilders = ExtractNodeBuilders<EditorExtension>;
|
|
258
|
+
type TypedMarkBuilders = ExtractMarkBuilders<EditorExtension>;
|
|
259
|
+
/** Typed mark builders bound to the shared schema. */
|
|
260
|
+
declare const getMarkBuilders: () => TypedMarkBuilders;
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region src/converters/md-to-pm.d.ts
|
|
263
|
+
/** Options for {@link markdownToDoc}. */
|
|
264
|
+
interface MarkdownToDocOptions {
|
|
265
|
+
/** Node builders to build the document with. Defaults to the shared schema's builders. */
|
|
266
|
+
nodes?: TypedNodeBuilders;
|
|
267
|
+
/** Whether to peel a leading `---` frontmatter block onto the doc's `frontmatter` attribute. Off by default. */
|
|
268
|
+
frontmatter?: boolean;
|
|
269
|
+
}
|
|
201
270
|
/**
|
|
202
|
-
*
|
|
203
|
-
* editor serializes content to the clipboard.
|
|
271
|
+
* Convert a markdown string into a ProseMirror document node.
|
|
204
272
|
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
273
|
+
* By default the document is built with the shared schema's node builders, so
|
|
274
|
+
* no editor is required. When the result will be loaded into a specific editor,
|
|
275
|
+
* pass that editor's `nodes` so the document uses the editor's own schema
|
|
276
|
+
* instance and can be inserted without a JSON round trip.
|
|
277
|
+
*
|
|
278
|
+
* The output follows the extension set defined in `../extensions/extension.ts`
|
|
279
|
+
* (doc, paragraph, text, heading, blockquote, list, codeBlock, table, tableRow,
|
|
280
|
+
* tableCell, tableHeaderCell, horizontalRule). The function does not produce
|
|
281
|
+
* inline marks because the markdown stays literal text - emphasis / link /
|
|
282
|
+
* inline-code characters survive verbatim.
|
|
208
283
|
*/
|
|
209
|
-
|
|
210
|
-
declare function defineMarkMode(mode: MarkMode): PlainExtension;
|
|
284
|
+
declare function markdownToDoc(markdown: string, options?: MarkdownToDocOptions): ProseMirrorNode;
|
|
211
285
|
//#endregion
|
|
212
|
-
//#region src/
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
286
|
+
//#region src/converters/pm-to-md.d.ts
|
|
287
|
+
/** Options for {@link docToMarkdown}. */
|
|
288
|
+
interface DocToMarkdownOptions {
|
|
289
|
+
/** Whether to serialize the doc's `frontmatter` attribute as a leading `---` block. Off by default. */
|
|
290
|
+
frontmatter?: boolean;
|
|
216
291
|
}
|
|
217
|
-
|
|
218
|
-
|
|
292
|
+
/**
|
|
293
|
+
* Convert a ProseMirror document into a Markdown string.
|
|
294
|
+
*
|
|
295
|
+
* Performance design:
|
|
296
|
+
* - Output accumulates in a `string[]` buffer; joined once at the end.
|
|
297
|
+
* Avoids per-block intermediate strings while keeping the
|
|
298
|
+
* function-per-node-type readability of a switch dispatch.
|
|
299
|
+
* - Indent stack lives as a mutable `linePrefix` on the buffer object,
|
|
300
|
+
* restored via local variables across nested calls - no fresh
|
|
301
|
+
* context objects per recursion.
|
|
302
|
+
* - Inline content is walked directly (not via `node.textContent`) to
|
|
303
|
+
* skip one intermediate string allocation per leaf block.
|
|
304
|
+
* - Backtick fence width and cell escaping use single linear loops, no
|
|
305
|
+
* regex on the hot path.
|
|
306
|
+
*/
|
|
307
|
+
declare function docToMarkdown(node: ProseMirrorNode, options?: DocToMarkdownOptions): string;
|
|
219
308
|
//#endregion
|
|
220
|
-
//#region src/extensions/
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
declare function
|
|
309
|
+
//#region src/extensions/bullet-after-heading.d.ts
|
|
310
|
+
/**
|
|
311
|
+
* "Type a title, press Return, start bullets." When this extension is applied,
|
|
312
|
+
* pressing Enter at the end of the document's first heading (the title line)
|
|
313
|
+
* drops the caret into a fresh empty bullet instead of a plain paragraph.
|
|
314
|
+
*/
|
|
315
|
+
declare function defineBulletAfterHeading(): PlainExtension;
|
|
227
316
|
//#endregion
|
|
228
|
-
//#region src/extensions/
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
317
|
+
//#region src/extensions/code-block-highlight.d.ts
|
|
318
|
+
/**
|
|
319
|
+
* Adds syntax highlighting to `codeBlock` nodes, parsing each block with the
|
|
320
|
+
* matching CodeMirror/Lezer grammar (loaded on demand from
|
|
321
|
+
* `@codemirror/language-data`). Tokens are tagged with `@lezer/highlight`
|
|
322
|
+
* `tok-*` classes; the default theme colors them per color scheme.
|
|
323
|
+
*/
|
|
324
|
+
declare function defineCodeBlockSyntaxHighlight(): Extension;
|
|
325
|
+
/** A highlighted span of code: `[from, to)` carries the `@lezer/highlight` classes. */
|
|
326
|
+
type CodeToken = readonly [from: number, to: number, classes: string];
|
|
327
|
+
/**
|
|
328
|
+
* Highlight `code` in `language` into `tok-*` token spans, the same classes the
|
|
329
|
+
* editor's decorations use. Returns synchronously when the grammar is already
|
|
330
|
+
* loaded (the common path, no render flash), and a `Promise` only when a grammar
|
|
331
|
+
* must load on demand. Returns `[]` for an empty or unsupported language.
|
|
332
|
+
*/
|
|
333
|
+
declare function getCodeTokens(code: string, language: string): CodeToken[] | Promise<CodeToken[]>;
|
|
237
334
|
//#endregion
|
|
238
|
-
//#region src/extensions/
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
declare function
|
|
255
|
-
/** Inline image/embed rendering (a mark view) plus paste/drop persistence. */
|
|
256
|
-
declare function defineImage(options?: ImageOptions): PlainExtension;
|
|
335
|
+
//#region src/extensions/code-block-languages.d.ts
|
|
336
|
+
/**
|
|
337
|
+
* A list of languages for code block syntax-highlight.
|
|
338
|
+
*/
|
|
339
|
+
declare const codeBlockLanguages: ReadonlyArray<{
|
|
340
|
+
label: string;
|
|
341
|
+
value: string;
|
|
342
|
+
}>;
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region src/extensions/embed-paste.d.ts
|
|
345
|
+
/**
|
|
346
|
+
* Auto-embed a pasted tweet or YouTube link. When the clipboard holds exactly
|
|
347
|
+
* one such URL, the link is rewritten to ``, which the image pipeline
|
|
348
|
+
* renders as a rich embed. Not part of `defineEditorExtension`; the React
|
|
349
|
+
* package applies it via the `embedPaste` prop (on by default).
|
|
350
|
+
*/
|
|
351
|
+
declare function defineEmbedPaste(): PlainExtension;
|
|
257
352
|
//#endregion
|
|
258
353
|
//#region src/extensions/embed/types.d.ts
|
|
259
354
|
/**
|
|
@@ -296,47 +391,24 @@ declare function listenForTweetHeight(iframe: HTMLIFrameElement): () => void;
|
|
|
296
391
|
/** Detect a tweet/YouTube embed in an image `src`, or `undefined` for a plain image. */
|
|
297
392
|
declare function matchEmbed(src: string): EmbedDescriptor | undefined;
|
|
298
393
|
//#endregion
|
|
299
|
-
//#region src/extensions/
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
declare function defineCodeBlockSyntaxHighlight(): Extension;
|
|
307
|
-
/** A highlighted span of code: `[from, to)` carries the `@lezer/highlight` classes. */
|
|
308
|
-
type CodeToken = readonly [from: number, to: number, classes: string];
|
|
309
|
-
/**
|
|
310
|
-
* Highlight `code` in `language` into `tok-*` token spans, the same classes the
|
|
311
|
-
* editor's decorations use. Returns synchronously when the grammar is already
|
|
312
|
-
* loaded (the common path, no render flash), and a `Promise` only when a grammar
|
|
313
|
-
* must load on demand. Returns `[]` for an empty or unsupported language.
|
|
314
|
-
*/
|
|
315
|
-
declare function getCodeTokens(code: string, language: string): CodeToken[] | Promise<CodeToken[]>;
|
|
316
|
-
//#endregion
|
|
317
|
-
//#region src/extensions/mark-chunk.d.ts
|
|
318
|
-
/**
|
|
319
|
-
* Contiguous range with a uniform inline-mark set.
|
|
320
|
-
*/
|
|
321
|
-
type MarkChunk = readonly [from: number, to: number, marks: readonly Mark[]];
|
|
322
|
-
//#endregion
|
|
323
|
-
//#region src/extensions/schema.d.ts
|
|
324
|
-
type TypedNodeBuilders = ExtractNodeBuilders<EditorExtension>;
|
|
325
|
-
type TypedMarkBuilders = ExtractMarkBuilders<EditorExtension>;
|
|
326
|
-
/** Typed mark builders bound to the shared schema. */
|
|
327
|
-
declare const getMarkBuilders: () => TypedMarkBuilders;
|
|
394
|
+
//#region src/extensions/exit-boundary.d.ts
|
|
395
|
+
interface ExitBoundaryOptions {
|
|
396
|
+
direction: 'up' | 'down';
|
|
397
|
+
event: KeyboardEvent;
|
|
398
|
+
}
|
|
399
|
+
type ExitBoundaryHandler = (options: ExitBoundaryOptions) => boolean | void;
|
|
400
|
+
declare function defineExitBoundaryHandler(onExitBoundary: ExitBoundaryHandler): PlainExtension;
|
|
328
401
|
//#endregion
|
|
329
|
-
//#region src/extensions/
|
|
402
|
+
//#region src/extensions/html-paste.d.ts
|
|
330
403
|
/**
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
404
|
+
* Paste foreign rich-text HTML as meowdown Markdown. Rewrites the clipboard's
|
|
405
|
+
* `text/html` through `transformPastedHTML`: foreign HTML is converted to a
|
|
406
|
+
* Markdown string, reparsed into meowdown nodes (literal source text, no marks),
|
|
407
|
+
* and re-serialized to HTML so ProseMirror's own clipboard parser inserts it with
|
|
408
|
+
* the right open depths. `<strong>bold</strong>` thus lands as the text `**bold**`,
|
|
409
|
+
* which the inline-mark plugin renders.
|
|
334
410
|
*/
|
|
335
|
-
declare function
|
|
336
|
-
|
|
337
|
-
marks: TypedMarkBuilders, /** The raw inline text of one textblock (no block prefix). */
|
|
338
|
-
|
|
339
|
-
text: string): MarkChunk[];
|
|
411
|
+
declare function defineHTMLPaste(): PlainExtension;
|
|
340
412
|
//#endregion
|
|
341
413
|
//#region src/extensions/image-click.d.ts
|
|
342
414
|
interface ImageClickPayload {
|
|
@@ -350,51 +422,43 @@ interface ImageClickPayload {
|
|
|
350
422
|
type ImageClickHandler = (payload: ImageClickPayload) => void;
|
|
351
423
|
declare function defineImageClickHandler(onClick: ImageClickHandler): PlainExtension;
|
|
352
424
|
//#endregion
|
|
353
|
-
//#region src/extensions/
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
*/
|
|
371
|
-
declare function
|
|
372
|
-
//#endregion
|
|
373
|
-
//#region src/extensions/markdown-copy.d.ts
|
|
374
|
-
/**
|
|
375
|
-
* Serialize copied/cut content to Markdown for the clipboard's `text/plain`, so
|
|
376
|
-
* pasting meowdown content into a plain-text field yields real Markdown (`- `
|
|
377
|
-
* list markers, blank-line block separation) instead of bare `textContent`.
|
|
378
|
-
*
|
|
379
|
-
* The copied fragment is wrapped in a `doc` so the existing block serializer can
|
|
380
|
-
* walk it. A purely inline fragment (a partial-paragraph copy) does not fit
|
|
381
|
-
* `doc`'s `block+` content, so it falls back to the inline text.
|
|
382
|
-
*/
|
|
383
|
-
declare function defineMarkdownCopy(): PlainExtension;
|
|
425
|
+
//#region src/extensions/image.d.ts
|
|
426
|
+
type ImageUrlResolver = (src: string) => string | undefined;
|
|
427
|
+
type ImagePasteHandler = (file: File) => string | undefined | Promise<string | undefined>;
|
|
428
|
+
type ImageSaveErrorHandler = (error: unknown, file: File) => void;
|
|
429
|
+
interface ImageOptions {
|
|
430
|
+
/**
|
|
431
|
+
* Map a markdown `src` to a displayable URL, or `undefined` to skip rendering
|
|
432
|
+
* that image. Defaults to `defaultResolveImageUrl`.
|
|
433
|
+
*/
|
|
434
|
+
resolveImageUrl?: ImageUrlResolver;
|
|
435
|
+
/** Persist a pasted/dropped image file and return its markdown `src`, or `undefined` to decline. */
|
|
436
|
+
onImagePaste?: ImagePasteHandler;
|
|
437
|
+
/** Called when persisting a pasted/dropped image throws. Defaults to `console.error`. */
|
|
438
|
+
onImageSaveError?: ImageSaveErrorHandler;
|
|
439
|
+
}
|
|
440
|
+
/** Show an `src` as-is when it is an http(s) URL, otherwise skip rendering it. */
|
|
441
|
+
declare function defaultResolveImageUrl(src: string): string | undefined;
|
|
442
|
+
/** Inline image/embed rendering (a mark view) plus paste/drop persistence. */
|
|
443
|
+
declare function defineImage(options?: ImageOptions): PlainExtension;
|
|
384
444
|
//#endregion
|
|
385
|
-
//#region src/extensions/
|
|
445
|
+
//#region src/extensions/mark-chunk.d.ts
|
|
386
446
|
/**
|
|
387
|
-
*
|
|
388
|
-
* pressing Enter at the end of the document's first heading (the title line)
|
|
389
|
-
* drops the caret into a fresh empty bullet instead of a plain paragraph.
|
|
447
|
+
* Contiguous range with a uniform inline-mark set.
|
|
390
448
|
*/
|
|
391
|
-
|
|
449
|
+
type MarkChunk = readonly [from: number, to: number, marks: readonly Mark[]];
|
|
392
450
|
//#endregion
|
|
393
|
-
//#region src/extensions/
|
|
451
|
+
//#region src/extensions/inline-text-to-mark-chunks.d.ts
|
|
394
452
|
/**
|
|
395
|
-
*
|
|
453
|
+
* Walk a textblock's inline content and produce a list of mark chunks
|
|
454
|
+
* with positions relative to the start of `text` (i.e. zero-based).
|
|
455
|
+
* Callers shift the chunks into the document's coordinate space.
|
|
396
456
|
*/
|
|
397
|
-
declare function
|
|
457
|
+
declare function inlineTextToMarkChunks(/** Typed mark builders bound to the target schema. */
|
|
458
|
+
|
|
459
|
+
marks: TypedMarkBuilders, /** The raw inline text of one textblock (no block prefix). */
|
|
460
|
+
|
|
461
|
+
text: string): MarkChunk[];
|
|
398
462
|
//#endregion
|
|
399
463
|
//#region src/extensions/key-bindings.d.ts
|
|
400
464
|
/** Human-readable descriptions of the editor's formatting and heading shortcuts. */
|
|
@@ -412,89 +476,71 @@ declare const EDITOR_KEY_BINDINGS: {
|
|
|
412
476
|
readonly 'Mod-6': "Heading 6";
|
|
413
477
|
};
|
|
414
478
|
//#endregion
|
|
415
|
-
//#region src/extensions/
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
declare const codeBlockLanguages: ReadonlyArray<{
|
|
420
|
-
label: string;
|
|
421
|
-
value: string;
|
|
422
|
-
}>;
|
|
423
|
-
//#endregion
|
|
424
|
-
//#region src/converters/pm-to-md.d.ts
|
|
425
|
-
/** Options for {@link docToMarkdown}. */
|
|
426
|
-
interface DocToMarkdownOptions {
|
|
427
|
-
/** Whether to serialize the doc's `frontmatter` attribute as a leading `---` block. Off by default. */
|
|
428
|
-
frontmatter?: boolean;
|
|
479
|
+
//#region src/extensions/link-click.d.ts
|
|
480
|
+
interface LinkClickPayload {
|
|
481
|
+
href: string;
|
|
482
|
+
event: MouseEvent;
|
|
429
483
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
*
|
|
433
|
-
* Performance design:
|
|
434
|
-
* - Output accumulates in a `string[]` buffer; joined once at the end.
|
|
435
|
-
* Avoids per-block intermediate strings while keeping the
|
|
436
|
-
* function-per-node-type readability of a switch dispatch.
|
|
437
|
-
* - Indent stack lives as a mutable `linePrefix` on the buffer object,
|
|
438
|
-
* restored via local variables across nested calls - no fresh
|
|
439
|
-
* context objects per recursion.
|
|
440
|
-
* - Inline content is walked directly (not via `node.textContent`) to
|
|
441
|
-
* skip one intermediate string allocation per leaf block.
|
|
442
|
-
* - Backtick fence width and cell escaping use single linear loops, no
|
|
443
|
-
* regex on the hot path.
|
|
444
|
-
*/
|
|
445
|
-
declare function docToMarkdown(node: ProseMirrorNode, options?: DocToMarkdownOptions): string;
|
|
484
|
+
type LinkClickHandler = (payload: LinkClickPayload) => void;
|
|
485
|
+
declare function defineLinkClickHandler(onClick: LinkClickHandler): PlainExtension;
|
|
446
486
|
//#endregion
|
|
447
|
-
//#region src/
|
|
448
|
-
/** Options for {@link markdownToDoc}. */
|
|
449
|
-
interface MarkdownToDocOptions {
|
|
450
|
-
/** Node builders to build the document with. Defaults to the shared schema's builders. */
|
|
451
|
-
nodes?: TypedNodeBuilders;
|
|
452
|
-
/** Whether to peel a leading `---` frontmatter block onto the doc's `frontmatter` attribute. Off by default. */
|
|
453
|
-
frontmatter?: boolean;
|
|
454
|
-
}
|
|
487
|
+
//#region src/extensions/mark-mode.d.ts
|
|
455
488
|
/**
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
* By default the document is built with the shared schema's node builders, so
|
|
459
|
-
* no editor is required. When the result will be loaded into a specific editor,
|
|
460
|
-
* pass that editor's `nodes` so the document uses the editor's own schema
|
|
461
|
-
* instance and can be inserted without a JSON round trip.
|
|
489
|
+
* Controls how markdown syntax characters are rendered and how the
|
|
490
|
+
* editor serializes content to the clipboard.
|
|
462
491
|
*
|
|
463
|
-
*
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
* inline marks because the markdown stays literal text - emphasis / link /
|
|
467
|
-
* inline-code characters survive verbatim.
|
|
492
|
+
* - 'hide': syntax chars never visible; copy strips them.
|
|
493
|
+
* - 'focus': syntax chars hidden by default; revealed near cursor; copy strips them.
|
|
494
|
+
* - 'show': syntax chars always visible (dim grey); copy keeps them.
|
|
468
495
|
*/
|
|
469
|
-
|
|
496
|
+
type MarkMode = 'hide' | 'focus' | 'show';
|
|
497
|
+
declare function defineMarkMode(mode: MarkMode): PlainExtension;
|
|
470
498
|
//#endregion
|
|
471
|
-
//#region src/
|
|
499
|
+
//#region src/extensions/mark-names.d.ts
|
|
500
|
+
declare const MARK_NAMES: readonly ["mdImageView", "mdImageSource", "mdMark", "mdEm", "mdStrong", "mdCode", "mdLinkText", "mdLinkUri", "mdDel", "mdHighlight", "mdTag", "mdWikilinkSource", "mdWikilinkView", "mdPack"];
|
|
501
|
+
type MarkName = (typeof MARK_NAMES)[number];
|
|
502
|
+
//#endregion
|
|
503
|
+
//#region src/extensions/markdown-copy.d.ts
|
|
472
504
|
/**
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
*
|
|
505
|
+
* Serialize copied/cut content to Markdown for the clipboard's `text/plain`, so
|
|
506
|
+
* pasting meowdown content into a plain-text field yields real Markdown (`- `
|
|
507
|
+
* list markers, blank-line block separation) instead of bare `textContent`.
|
|
508
|
+
*
|
|
509
|
+
* The copied fragment is wrapped in a `doc` so the existing block serializer can
|
|
510
|
+
* walk it. A purely inline fragment (a partial-paragraph copy) does not fit
|
|
511
|
+
* `doc`'s `block+` content, so it falls back to the inline text.
|
|
479
512
|
*/
|
|
480
|
-
|
|
481
|
-
/** Options for {@link checkRoundTrip}. */
|
|
482
|
-
interface CheckRoundTripOptions {
|
|
483
|
-
/** Whether to handle a leading `---` frontmatter block. Off by default. */
|
|
484
|
-
frontmatter?: boolean;
|
|
485
|
-
}
|
|
486
|
-
/** Classify how `markdown` survives the editor's parse-then-serialize round trip. */
|
|
487
|
-
declare function checkRoundTrip(markdown: string, options?: CheckRoundTripOptions): RoundTripFidelity;
|
|
513
|
+
declare function defineMarkdownCopy(): PlainExtension;
|
|
488
514
|
//#endregion
|
|
489
515
|
//#region src/extensions/node-names.d.ts
|
|
490
516
|
/**
|
|
491
517
|
* Every ProseMirror node name the editor schema knows about.
|
|
492
518
|
*/
|
|
493
|
-
declare const NODE_NAMES: readonly ["doc", "text", "paragraph", "heading", "blockquote", "list", "codeBlock", "horizontalRule", "table", "tableRow", "tableCell", "tableHeaderCell"];
|
|
519
|
+
declare const NODE_NAMES: readonly ["doc", "text", "paragraph", "heading", "blockquote", "list", "codeBlock", "horizontalRule", "htmlComment", "table", "tableRow", "tableCell", "tableHeaderCell"];
|
|
494
520
|
type NodeName = (typeof NODE_NAMES)[number];
|
|
495
521
|
//#endregion
|
|
496
|
-
//#region src/extensions/
|
|
497
|
-
|
|
498
|
-
|
|
522
|
+
//#region src/extensions/tag-click.d.ts
|
|
523
|
+
interface TagClickPayload {
|
|
524
|
+
/** The tag name, without the leading `#`. */
|
|
525
|
+
tag: string;
|
|
526
|
+
/** The originating click. Read modifier keys or position a popover from it. */
|
|
527
|
+
event: MouseEvent;
|
|
528
|
+
}
|
|
529
|
+
type TagClickHandler = (payload: TagClickPayload) => void;
|
|
530
|
+
declare function defineTagClickHandler(onClick: TagClickHandler): PlainExtension;
|
|
531
|
+
//#endregion
|
|
532
|
+
//#region src/extensions/wikilink-click.d.ts
|
|
533
|
+
interface WikilinkClickPayload {
|
|
534
|
+
target: string;
|
|
535
|
+
event: MouseEvent;
|
|
536
|
+
}
|
|
537
|
+
type WikilinkClickHandler = (payload: WikilinkClickPayload) => void;
|
|
538
|
+
declare function defineWikilinkClickHandler(onClick: WikilinkClickHandler): PlainExtension;
|
|
539
|
+
//#endregion
|
|
540
|
+
//#region src/extensions/wikilink-trigger.d.ts
|
|
541
|
+
/**
|
|
542
|
+
* Binds `Mod-Shift-k` to open the wikilink menu.
|
|
543
|
+
*/
|
|
544
|
+
declare function defineWikilinkTrigger(): PlainExtension;
|
|
499
545
|
//#endregion
|
|
500
|
-
export { type CheckRoundTripOptions, type CodeBlockAttrs, type CodeToken, type DocToMarkdownOptions, EDITOR_KEY_BINDINGS, type EditorExtension, type EmbedDescriptor, type ImageClickHandler, type ImageClickPayload, type ImageOptions, type LinkClickHandler, type LinkClickPayload, type MarkChunk, type MarkMode, type MarkName, type MarkdownToDocOptions, type MdImageViewAttrs, type MdLinkTextAttrs, type MdWikilinkViewAttrs, type NodeName, type PlaceholderOptions, Priority, type RoundTripFidelity, type TagClickHandler, type TagClickPayload, type TypedEditor, type TypedMarkBuilders, type WikilinkClickHandler, type WikilinkClickPayload, checkRoundTrip, codeBlockLanguages, defaultResolveImageUrl, defineBulletAfterHeading, defineCodeBlockSyntaxHighlight, defineEditorExtension, defineEmbedPaste, defineHTMLPaste, defineImage, defineImageClickHandler, defineLinkClickHandler, defineMarkMode, defineMarkdownCopy, definePlaceholder, defineReadonly, defineTagClickHandler, defineWikilinkClickHandler, defineWikilinkTrigger, docToMarkdown, getCodeTokens, getMarkBuilders, inlineTextToMarkChunks, listenForTweetHeight, markdownToDoc, matchEmbed, withPriority };
|
|
546
|
+
export { type CheckRoundTripOptions, type CodeBlockAttrs, type CodeToken, type DocToMarkdownOptions, EDITOR_KEY_BINDINGS, type EditorExtension, type EmbedDescriptor, type ExitBoundaryHandler, type ExitBoundaryOptions, type ImageClickHandler, type ImageClickPayload, type ImageOptions, type LinkClickHandler, type LinkClickPayload, type MarkChunk, type MarkMode, type MarkName, type MarkdownToDocOptions, type MdImageViewAttrs, type MdLinkTextAttrs, type MdWikilinkViewAttrs, type MeowdownHTMLCommentAttrs, type NodeName, type PlaceholderOptions, Priority, type RoundTripFidelity, type TagClickHandler, type TagClickPayload, type TypedEditor, type TypedMarkBuilders, type WikilinkClickHandler, type WikilinkClickPayload, checkRoundTrip, codeBlockLanguages, defaultResolveImageUrl, defineBulletAfterHeading, defineCodeBlockSyntaxHighlight, defineEditorExtension, defineEmbedPaste, defineExitBoundaryHandler, defineHTMLComment, defineHTMLPaste, defineImage, defineImageClickHandler, defineLinkClickHandler, defineMarkMode, defineMarkdownCopy, definePlaceholder, defineReadonly, defineTagClickHandler, defineWikilinkClickHandler, defineWikilinkTrigger, docToMarkdown, getCodeTokens, getMarkBuilders, inlineTextToMarkChunks, listenForTweetHeight, markdownToDoc, matchEmbed, withPriority };
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import{Priority as e,Priority as t,createMarkBuilders as n,createNodeBuilders as r,defineBaseCommands as i,defineBaseKeymap as a,defineCommands as o,defineHistory as s,defineKeymap as c,defineMarkSpec as l,defineMarkView as u,defineNodeAttr as d,defineNodeSpec as f,definePlugin as p,getMarkRange as m,getMarkType as ee,getNodeType as te,
|
|
2
|
-
`)}function mt(e){let{selection:t}=e;if(!t.empty)return b.empty;let n=t.$head,{parent:r}=n;if(!r.isTextblock||r.type.spec.code)return b.empty;let i=m(n,ee(e.schema,`mdPack`));return i?b.create(e.doc,[ge.inline(i.from,i.to,{class:`show`})]):b.empty}function T(e,t){let n=ft(t);return n?e.flatMap(e=>e.modes.includes(n)?[e.name]:[]):[]}function E(e,t,n){for(let r of n){let n=w(e,t,r);if(n)return n}}function D(e,t,n){let r=E(e,t,n);return r&&r.to===t?r:void 0}function O(e,t,n){let r=E(e,t,n);return r&&r.from===t?r:void 0}function k(e,t){let{from:n,to:r,empty:i}=e.selection;if(i)return;let a=E(e,n,t);return a&&a.from===n&&a.to===r?a:void 0}function ht(e,t){return y.create(e.doc,t.from,t.to)}function gt(e){return(t,n)=>{let r=T(e,t);if(r.length===0||!re(t.selection))return!1;let i=t.selection;if(i.empty){let e=O(t,i.from,r);if(e)return n?.(t.tr.setSelection(ht(t,e))),!0;if(D(t,i.from,r)){let e=t.doc.resolve(i.from);return i.from>=e.end()?!1:(n?.(t.tr.setSelection(y.create(t.doc,i.from+1))),!0)}return!1}let a=k(t,r);return a?(n?.(t.tr.setSelection(y.create(t.doc,a.to))),!0):!1}}function _t(e){return(t,n)=>{let r=T(e,t);if(r.length===0||!re(t.selection))return!1;let i=t.selection;if(i.empty){let e=D(t,i.from,r);return e?(n?.(t.tr.setSelection(ht(t,e))),!0):!1}let a=k(t,r);return a?(n?.(t.tr.setSelection(y.create(t.doc,a.from))),!0):!1}}function vt(e){return(t,n)=>{let r=T(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=D(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!O(t,i,r)||i<=t.doc.resolve(i).start()?!1:(n?.(t.tr.delete(i-1,i)),!0)}}function yt(e){return(t,n)=>{let r=T(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=O(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!D(t,i,r)||i>=t.doc.resolve(i).end()?!1:(n?.(t.tr.delete(i,i+1)),!0)}}function bt(e,t){return new _({key:new v(`atomic-mark-selection-${t}`),props:{decorations:n=>{let r=T(e,n);if(r.length===0)return;let i=k(n,r);if(i)return b.create(n.doc,[ge.inline(i.from,i.to,{class:t})])}}})}function xt({marks:e,selectedClass:n}){return h(g(c({ArrowRight:gt(e),ArrowLeft:_t(e),Backspace:vt(e),Delete:yt(e)}),t.high),p(bt(e,n)))}const A=new Map,St=new Map;async function Ct(e){let t=A.get(e);if(t!==void 0)return t;let n=_e.matchLanguageName(ve,e,!0);if(!n)return A.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),A.set(e,null),null}return A.set(e,r),r}function wt(e,t){let n=St.get(e);if(n)return n;let r=xe({parse:e=>t.language.parser.parse(e.content),highlighter:ye});return St.set(e,r),r}const Tt=e=>{let t=e.language?.trim();if(!t)return[];let n=A.get(t);return n===null?[]:n?wt(t,n)(e):Ct(t).then(()=>void 0)};function Et(){return ue({parser:Tt,nodeTypes:[`codeBlock`]})}function Dt(e,t){let n=t.language.parser.parse(e),r=[];return be(n,ye,(e,t,n)=>{r.push([e,t,n])}),r}function Ot(e,t){let n=t.trim();if(!n)return[];let r=A.get(n);return r===null?[]:r?Dt(e,r):Ct(n).then(t=>t?Dt(e,t):[])}function kt(){return d({type:`doc`,attr:`frontmatter`,default:null})}function At(){return f({name:`heading`,whitespace:`pre`})}function jt(){return d({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 j(e){return se(ie({type:`heading`,attrs:{level:e}}))}const Mt=(e,t,n)=>ne(e,n)?.parent.type.name===`heading`?ae()(e,t,n):!1;function Nt(){return c({"Mod-1":j(1),"Mod-2":j(2),"Mod-3":j(3),"Mod-4":j(4),"Mod-5":j(5),"Mod-6":j(6),Backspace:Mt})}function Pt(){return h(we(),At(),jt(),Ce(),Se(),Nt())}function Ft(){return d({type:`horizontalRule`,attr:`marker`,default:null,toDOM:e=>e?[`data-hr-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-hr-marker`)})}function It(){return h(Te(),Ft())}function Lt(e){let[t,n,r]=e;return[t,n,r.map(e=>e.toJSON())]}function Rt(e,t){let[n,r,i]=t;return[n,r,i.map(t=>je.fromJSON(e,t))]}var M=class e extends De{constructor(e){super(),this.chunks=e}apply(e){if(this.chunks.length===0)return Oe.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 ke(e),n.removeMark(i,c,t));for(let t of a)t.isInSet(l)||(n??=new ke(e),n.addMark(i,c,t));return!1})}return Oe.ok(n?n.doc:e)}invert(e){if(this.chunks.length===0)return zt;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 Ee(i,a,e.slice(i,a),!1)}map(e){return null}toJSON(){return{stepType:`batchSetMark`,chunks:this.chunks.map(Lt)}}static fromJSON(t,n){let r=n.chunks;return new e(r.map(e=>Rt(t,e)))}};De.jsonID(`batchSetMark`,M);const zt=new M([]),Bt=new Set([`com`,`br`,`net`,`jp`,`org`,`in`,`de`,`ru`,`it`,`fr`]),Vt=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;function Ht(e){let t=e.indexOf(`/`);return t===-1?e:e.slice(0,t)}function Ut(e){let t=e.split(`.`);if(t.length<2)return!1;let n=t[t.length-1].toLowerCase();if(!Bt.has(n)||t[t.length-2].length<3)return!1;for(let e of t)if(e.length>63||!Vt.test(e))return!1;return!0}function Wt(e){return e===32||e===9||e===10||e===13}const Gt=/^[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:\/[^\s<]*)?/i,Kt=/[\s(*_~]/;function qt(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45}function Jt(e,t,n){let r=0;for(let i=0;i<t;i++)e[i]===n&&r++;return r}function Yt(e){let t=e.length;for(;;){let n=e[t-1];if(/[?!.,:*_~]/.test(n)||n===`)`&&Jt(e,t,`)`)>Jt(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 Xt={parseInline:[{name:`BareAutolink`,before:`Link`,parse(e,t,n){if(!qt(t)||e.hasOpenLink)return-1;let r=e.slice(n-1,n);if(r!==``&&!Kt.test(r))return-1;let i=Gt.exec(e.slice(n,e.end));if(!i)return-1;let a=Yt(i[0]);return a===0||!Ut(Ht(i[0].slice(0,a)))?-1:e.addElement(e.elt(`URL`,n,n+a))}}]};function Zt(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 Qt(e){return e>=65&&e<=90||e>=97&&e<=122||e>127&&/\p{L}/u.test(String.fromCharCode(e))}const $t={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(!Zt(t))break;i||=Qt(t),r++}return i?e.addElement(e.elt(`Hashtag`,n,r)):-1}}]},en={resolve:`Highlight`,mark:`HighlightMark`},tn=/[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~\u{A1}\u{2010}-\u{2027}]/u,nn={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=tn.test(r),c=tn.test(i);return e.addDelimiter(en,n,n+2,!o&&(!c||a||s),!a&&(!s||o||c))}}]},rn={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 an(e){return e.end}const N=Ne.configure([Me,$t,rn,Xt,nn]),on=N.configure({parseInline:[{name:`SkipInline`,before:`Escape`,parse:an}]});function P(e){return N.parseInline(e,0)}function F(e,t,n=[]){for(let r of e)t(r)&&n.push(r),F(r.children,t,n);return n}function sn(e){let t={};for(let n of e.nodeSet.types)t[n.name]=n.id;return t}const I=sn(N);function cn(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 ln(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 un(){return e=>{let t=e.attrs,n=document.createElement(`span`);n.className=`md-wikilink-view`;let r=document.createElement(`span`);r.className=`md-wikilink-label`,r.contentEditable=`false`,r.dataset.testid=`wikilink`,r.textContent=t.display||t.target,n.appendChild(r);let i=document.createElement(`span`);return i.className=`md-wikilink-view-content`,n.appendChild(i),{dom:n,contentDOM:i,ignoreMutation:e=>!i.contains(e.target)}}}function dn(){return u({name:`mdWikilinkView`,constructor:un()})}const L=new Map([[I.Emphasis,`mdEm`],[I.StrongEmphasis,`mdStrong`],[I.InlineCode,`mdCode`],[I.Strikethrough,`mdDel`],[I.Highlight,`mdHighlight`],[I.EmphasisMark,`mdMark`],[I.CodeMark,`mdMark`],[I.LinkMark,`mdMark`],[I.StrikethroughMark,`mdMark`],[I.HighlightMark,`mdMark`],[I.URL,`mdLinkUri`],[I.Hashtag,`mdTag`],[I.WikilinkMark,`mdMark`]]);function fn(e,t){let n=P(t),r=[];return R(n,[],0,t.length,t,e,r),r}function pn(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)||Ut(Ht(e)))return`https://${e}`}function R(e,t,n,r,i,a,o){let s=n;for(let n of e){n.from>s&&z(o,s,n.from,t);let e=n.type;if(e===I.Link)mn(n,t,i,a,o);else if(e===I.Image)hn(n,t,i,a,o);else if(e===I.Wikilink)gn(n,t,i,a,o);else if(e===I.URL){let e=pn(i.slice(n.from,n.to)),r=e?a.mdLinkText.create({href:e}):a.mdLinkUri.create();z(o,n.from,n.to,[...t,r])}else{let r;e===I.Emphasis?r=`italic`:e===I.StrongEmphasis?r=`bold`:e===I.InlineCode?r=`code`:e===I.Strikethrough?r=`strike`:e===I.Highlight?r=`highlight`:e===I.Autolink&&(r=`autolink`);let s=r?[...t,a.mdPack.create({key:r})]:t,c=L.get(e),l=c?[...s,a[c].create()]:s;n.children.length===0?z(o,n.from,n.to,l):R(n.children,l,n.from,n.to,i,a,o)}s=n.to}s<r&&z(o,s,r,t)}function mn(e,t,n,r,i){let a=-1,o=null,s=0;for(let t of e.children)t.type===I.LinkMark?(s++,s===2&&(a=t.from)):t.type===I.URL&&o===null&&(o=t);let c=o?n.slice(o.from,o.to):``,l=c?r.mdLinkText.create({href:c}):null,u=e=>a>=0&&e<a&&l!==null,d=r.mdPack.create({key:`link_${c}`}),f=[...t,d],p=e.from;for(let t of e.children){if(t.from>p){let e=u(p)?[...f,l]:f;z(i,p,t.from,e)}let e=u(t.from)?[...f,l]:f;if(t.type===I.Wikilink){gn(t,e,n,r,i),p=t.to;continue}let a=L.get(t.type),o=a?[...e,r[a].create()]:e;t.children.length===0?z(i,t.from,t.to,o):R(t.children,o,t.from,t.to,n,r,i),p=t.to}p<e.to&&z(i,p,e.to,f)}function hn(e,t,n,r,i){let a=e.children.find(e=>e.type===I.URL);if(!a){mn(e,t,n,r,i);return}let o=e.children.filter(e=>e.type===I.LinkMark),s=n.slice(a.from,a.to),c=o.length>=2?n.slice(o[0].to,o[1].from):``,l=r.mdImageSource.create({src:s,alt:c}),u=r.mdImageView.create({src:s,alt:c}),d=r.mdPack.create({key:`image_${s}`}),f=e.to-1,p=e=>e>=f?[...t,d,l,u]:[...t,d,l],m=e.from;for(let t of e.children){t.from>m&&z(i,m,t.from,p(m));let e=L.get(t.type),a=e?[...p(t.from),r[e].create()]:p(t.from);t.children.length===0?z(i,t.from,t.to,a):R(t.children,a,t.from,t.to,n,r,i),m=t.to}m<e.to&&z(i,m,e.to,p(m))}function gn(e,t,n,r,i){let{target:a,display:o}=ln(n.slice(e.from,e.to)),s=r.mdWikilinkSource.create({target:a}),c=r.mdWikilinkView.create({target:a,display:o}),l=e.to-1,u=e=>e>=l?[...t,s,c]:[...t,s],d=e.from;for(let t of e.children){t.from>d&&z(i,d,t.from,u(d));let e=r.mdMark.create();t.from<l&&t.to>l?(z(i,t.from,l,[...u(t.from),e]),z(i,l,t.to,[...u(l),e])):z(i,t.from,t.to,[...u(t.from),e]),d=t.to}d<e.to&&z(i,d,e.to,u(d))}function z(e,t,n,r){if(t>=n)return;let i=e.at(-1);if(i&&i[1]===t&&cn(i[2],r)){e[e.length-1]=[i[0],n,i[2]];return}e.push([t,n,r])}const _n=x(()=>{let e=jr().schema;if(e==null)throw Error(`Unexpected empty schema`);return e}),vn=x(()=>r(_n())),yn=x(()=>n(_n())),bn=`meowdown_mark_builders`;function xn(e){let t=e.cached[bn];if(t)return t;let r=n(e);return e.cached[bn]=r,r}const Sn=`meowdown_node_builders`;function Cn(e){let t=e.cached[Sn];if(t)return t;let n=r(e);return e.cached[Sn]=n,n}const wn=`inline-marks-applied`,Tn=new WeakMap;let En=0,Dn=0;function On(e,t,n){let r=Tn.get(e);if(r?Dn++:(En++,r=fn(xn(n),e.textContent),Tn.set(e,r)),t===0)return r;let i=[];for(let[e,n,a]of r)i.push([e+t,n+t,a]);return i}function kn(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 An(e,t){let n=[];return e.doc.nodesBetween(t.from,t.to,(t,r)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;if(t.childCount===0)return!1;let i=On(t,r+1,e.schema);return i.length>0&&n.push(...i),!1}),n}function jn(){return new _({key:new v(`inline-mark`),appendTransaction(e,t,n){for(let t of e)if(t.getMeta(wn))return null;let r=An(n,kn(e,n));if(r.length===0)return null;let i=n.tr.step(new M(r));return i.setMeta(wn,!0),i.setMeta(`addToHistory`,!1),i},view(e){return e.dispatch(Mn(e.state)),{}}})}function Mn(e){return e.tr.setMeta(`inline-marks-trigger`,!0)}function Nn(){return p(jn())}function Pn(){return l({name:`mdImageView`,inclusive:!1,attrs:{src:{default:``},alt:{default:``}},toDOM:()=>[`span`,{class:`md-image-anchor`},0],parseDOM:[{tag:`span.md-image-anchor`}]})}function Fn(){return l({name:`mdImageSource`,inclusive:!1,attrs:{src:{default:``},alt:{default:``}},toDOM:()=>[`span`,{class:`md-image-source`},0],parseDOM:[{tag:`span.md-image-source`}]})}function In(){return l({name:`mdMark`,inclusive:!1,toDOM:()=>[`span`,{class:`md-mark`},0],parseDOM:[{tag:`span.md-mark`}]})}function Ln(){return l({name:`mdEm`,toDOM:()=>[`em`,0],parseDOM:[{tag:`em`}]})}function Rn(){return l({name:`mdStrong`,toDOM:()=>[`strong`,0],parseDOM:[{tag:`strong`}]})}function zn(){return l({name:`mdCode`,toDOM:()=>[`code`,0],parseDOM:[{tag:`code`}]})}function Bn(){return l({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 Vn(){return l({name:`mdLinkUri`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-uri`},0],parseDOM:[{tag:`span.md-link-uri`}]})}function Hn(){return l({name:`mdDel`,toDOM:()=>[`del`,0],parseDOM:[{tag:`del`}]})}function Un(){return l({name:`mdHighlight`,toDOM:()=>[`mark`,0],parseDOM:[{tag:`mark`}]})}function Wn(){return l({name:`mdTag`,toDOM:()=>[`span`,{class:`md-tag`},0],parseDOM:[{tag:`span.md-tag`}]})}function Gn(){return l({name:`mdWikilinkSource`,inclusive:!1,attrs:{target:{default:``}},toDOM:()=>[`span`,{class:`md-wikilink-source`},0],parseDOM:[{tag:`span.md-wikilink-source`}]})}function Kn(){return l({name:`mdWikilinkView`,inclusive:!1,attrs:{target:{default:``},display:{default:``}},toDOM:()=>[`span`,{class:`md-wikilink-anchor`},0],parseDOM:[{tag:`span.md-wikilink-anchor`}]})}function qn(){return l({name:`mdPack`,excludes:``,inclusive:!1,attrs:{key:{default:``}},toDOM:e=>[`span`,{class:`md-pack`,"data-key":e.attrs.key},0],parseDOM:[{tag:`span.md-pack`}]})}function Jn(){return h(In(),Ln(),Rn(),zn(),Bn(),Vn(),Hn(),Un(),Wn(),Gn(),Kn(),Fn(),Pn(),qn())}function Yn(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 B={em:{node:I.Emphasis,delim:`*`},strong:{node:I.StrongEmphasis,delim:`**`},code:{node:I.InlineCode,delim:"`"},del:{node:I.Strikethrough,delim:`~~`},highlight:{node:I.Highlight,delim:`==`}},Xn=new Set([I.EmphasisMark,I.CodeMark,I.LinkMark,I.StrikethroughMark,I.HighlightMark]);function V(e){return[e.children[0],e.children.at(-1)]}function Zn(e){let{type:t,children:n}=e;if(t===I.Emphasis||t===I.StrongEmphasis||t===I.Strikethrough||t===I.Highlight)return[n[0].to,n.at(-1).from];if(t===I.Link||t===I.Image){let e=n.find((e,t)=>t>0&&e.type===I.LinkMark);return e?[n[0].to,e.from]:null}return null}function H(e,t,n){for(let r of e){if(r.to<=t||r.from>=n||t<=r.from&&r.to<=n)continue;let i=Zn(r);return i&&i[0]<=t&&n<=i[1]?H(r.children,t,n):H(e,Math.min(t,r.from),Math.max(n,r.to))}return[t,n]}function Qn(e,t,n){for(let r of e)if(!(r.to<=t||r.from>=n)&&(t>r.from||r.to>n))return Qn(e,Math.min(t,r.from),Math.max(n,r.to));return[t,n]}const U=e=>e===` `||e===` `;function $n(e,t,n){for(;t<n&&U(e[t]);)t++;for(;n>t&&U(e[n-1]);)n--;return[t,n]}function er(e,t,n,r){let i=F(P(e),e=>e.type===r.node||Xn.has(e.type));for(let r=t;r<n;r++)if(!U(e[r])&&i.every(e=>!(e.from<=r&&r<e.to)))return!1;return!0}function tr(e,t,n,r,i){let a=P(e),o=F(a,e=>e.type===r.node);return i?ir(e,o,t,n):nr(e,a,o,t,n,r)}function nr(e,t,n,r,i,a){for(let e=0;e!==i-r;){e=i-r,[r,i]=H(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]=V(e);o.push({from:t.from,to:t.to,insert:``}),o.push({from:n.from,to:n.to,insert:``})}let[s,c]=rr(e,r,i,o,a);return o.push({from:r,to:r,insert:s},{from:i,to:i,insert:c}),o}function rr(e,t,n,r,i){if(i.node!==I.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(Yn(a)+1),s=a.startsWith("`")||a.endsWith("`")?` `:``;return[o+s,s+o]}function ir(e,t,n,r){let i=[];for(let a of t){if(a.to<=n||a.from>=r)continue;let[t,o]=V(a),s=Math.max(n,t.to),c=Math.min(r,o.from);for(s>=c&&([s,c]=[t.to,o.from]),[s,c]=Qn(a.children.slice(1,-1),s,c);s>t.to&&U(e[s-1]);)s--;for(;c<o.from&&U(e[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 ar(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=P(e),o=F(a,e=>e.type===n.node).findLast(e=>e.from<=t&&t<=e.to);if(o){let[e,n]=V(o);return{kind:`move`,pos:t===o.from?e.to:t===o.to?n.from:o.to}}return or(a,t)||e[t-1]===r[0]||e[t]===r[0]?null:{kind:`insert`,pos:t}}function or(e,t){for(let n of e)if(n.from<t&&t<n.to){let e=Zn(n);return!e||t<e[0]||t>e[1]?!0:or(n.children,t)}return!1}function W(e){return(t,n)=>{if(t.selection.empty)return sr(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]=$n(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:er(a,c,l,e)}),!1});let c=s.length>0&&s.every(e=>e.active),l=s.filter(e=>c||!e.active).flatMap(t=>tr(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(y.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 sr(e,t,n){let{$from:r}=t.selection,i=r.parent;if(!i.isTextblock||i.type.spec.code)return!1;let a=ar(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(y.create(o.doc,i+a.pos)),a.kind===`insert`&&(o.insertText(e.delim+e.delim,i+a.pos),o.setSelection(y.create(o.doc,i+a.pos+e.delim.length))),n(o.scrollIntoView())}return!0}function cr(){return o({toggleEm:()=>W(B.em),toggleStrong:()=>W(B.strong),toggleCode:()=>W(B.code),toggleDel:()=>W(B.del),toggleHighlight:()=>W(B.highlight)})}function lr(){return c({"Mod-b":W(B.strong),"Mod-i":W(B.em),"Mod-e":W(B.code),"Mod-Shift-x":W(B.del),"Mod-Shift-h":W(B.highlight)})}function ur(){return h(cr(),lr())}function dr(){return d({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 fr(){return d({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 pr(e){return e===2||e===3||e===4}function mr(){return d({type:`list`,attr:`markerGap`,default:1,splittable:!0,toDOM:e=>pr(e)?[`data-list-marker-gap`,String(e)]:null,parseDOM:e=>{let t=Number.parseInt(e.getAttribute(`data-list-marker-gap`)??``,10);return pr(t)?t:1}})}const hr=[C(/^\s?([*-])\s$/,{kind:`bullet`,collapsed:!1}),C(/^\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}}),C(/^\s?\[([\sXx]?)]\s$/,({match:e})=>({kind:`task`,checked:[`x`,`X`].includes(e[1]),collapsed:!1})),C(/^\s?\+\s$/,{kind:`task`,marker:`+`,checked:!1,collapsed:!1})];function gr(){return h(hr.map(Pe))}function _r(){return S({kind:`task`,marker:`+`})}function vr(){return S({kind:`task`,marker:null})}function yr(){return o({wrapInCircleTask:_r,wrapInSquareTask:vr})}function br(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 xr(){return(e,t,n)=>{let r=br(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},S(a)(e,t,n)}}function Sr(){return(e,t,n)=>{let r=br(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},S(a)(e,t,n)}}function Cr(){return c({"Mod-Enter":xr(),"Mod-Shift-Enter":Sr()})}function wr(){return h(Be(),Re(),Le(),Fe(),ze(),Ie(),gr(),Cr(),dr(),fr(),mr(),yr())}function Tr(){return f({name:`paragraph`,content:`inline*`,group:`block`,whitespace:`pre`,parseDOM:[{tag:`p`}],toDOM(){return[`p`,0]}})}function Er(){return h(g(Tr(),t.highest),Ve(),He())}const Dr=(e,t)=>{let{selection:n}=e;return!Ze(n)||!n.isColSelection()||!n.isRowSelection()?!1:Xe(e,t)};function Or(){return g(c({Backspace:Dr,Delete:Dr}),t.high)}function kr(){return h(Ye(),Je(),Ue(),qe(),Ke({allowTableNodeSelection:!0}),We(),Ge(),Or())}function Ar(){return h(Er(),de(),kt(),me(),ce(),wr(),Pt(),kr(),le(),It(),Jn(),Et(),Nn(),ur(),dn(),xt({marks:[{name:`mdImageSource`,modes:[`hide`]},{name:`mdWikilinkSource`,modes:[`hide`,`focus`,`show`]}],selectedClass:`md-atomic-selected`}),a(),i(),s(),fe(),he(),pe())}function jr(){return Ar()}function G(e){return p(new _({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 Mr=new v(`meowdown-wikilink-click`);function Nr(e,t){let n=w(e,t,`mdWikilinkSource`);if(!n)return;let{target:r}=n.mark.attrs;return{from:n.from,to:n.to,target:r}}function Pr(e){return G({key:Mr,selector:`.md-wikilink-label, .md-wikilink-source`,preventDefault:!1,findPayloadAt:(e,t)=>Nr(e,t)?.target,onClick:(t,n)=>e({target:t,event:n})})}const Fr=new v(`meowdown-link-click`);function Ir(e,t){let n=w(e,t,`mdLinkText`);if(n)return{from:n.from,to:n.to,href:n.mark.attrs.href}}function Lr(e){return G({key:Fr,selector:`.md-link`,preventDefault:!0,findPayloadAt:(e,t)=>Ir(e,t)?.href,onClick:(t,n)=>e({href:t,event:n})})}const Rr=new v(`meowdown-tag-click`);function zr(e,t){let n=w(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 Br(e){return G({key:Rr,selector:`.md-tag`,preventDefault:!1,findPayloadAt:(e,t)=>zr(e,t)?.tag,onClick:(t,n)=>e({tag:t,event:n})})}function Vr(){return typeof window>`u`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches}const Hr=/^(?:www\.|mobile\.)?(?:twitter\.com|x\.com)$/i,Ur=/\/status(?:es)?\/(\d+)/;function Wr(e){let t;try{t=new URL(e)}catch{return}if(Hr.test(t.hostname))return Ur.exec(t.pathname)?.[1]}const Gr=e=>{let t=Wr(e);if(!t)return;let n=Vr()?`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 Kr(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 qr=/^(?:www\.|m\.)?(?:youtube\.com|youtube-nocookie\.com)$/i,Jr=/^(?:www\.)?youtu\.be$/i,Yr=/^[\w-]{11}$/;function Xr(e){let t;try{t=new URL(e)}catch{return}let n=null;if(Jr.test(t.hostname))n=t.pathname.slice(1);else if(qr.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||!Yr.test(n))return;let r=t.searchParams.get(`start`)??t.searchParams.get(`t`),i=r?Zr(r):void 0;return{videoId:n,startSeconds:i}}function Zr(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 Qr=[e=>{let t=Xr(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}},Gr];function K(e){for(let t of Qr){let n=t(e);if(n)return n}}function $r(e){return/^https?:\/\//i.test(e)?e:void 0}function ei(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`&&Kr(t),t}function ti(e,t,n){let r=K(e);if(r){let e=document.createElement(`span`);return e.className=`md-image-preview md-image-preview-embed`,e.appendChild(ei(r)),e}let i=(n.resolveImageUrl??$r)(e);if(!i)return;let a=document.createElement(`span`);a.className=`md-image-preview md-image-preview-img`,a.dataset.testid=`image-preview`;let o=document.createElement(`img`);return o.src=i,o.alt=t,o.draggable=!1,a.appendChild(o),a}function ni(e){return t=>{let n=t.attrs,r=document.createElement(`span`);r.className=`md-image-view`;let i=document.createElement(`span`);i.className=`md-image-view-content`,r.appendChild(i);let a=ti(n.src,n.alt,e);return a&&(a.contentEditable=`false`,r.appendChild(a)),{dom:r,contentDOM:i,ignoreMutation:e=>!i.contains(e.target)}}}function ri(e){return e?Array.from(e.files).filter(e=>e.type.startsWith(`image/`)):[]}const ii=e=>{console.error(`[meowdown] failed to save pasted image:`,e)};async function ai(e,t,n,r=ii,i){let a=i;for(let i of t){let t;try{t=await n(i)}catch(e){r(e,i);continue}if(!t||e.isDestroyed)continue;let o=``,s=a==null?e.state.tr.insertText(o):e.state.tr.insertText(o,a);e.dispatch(s),a!=null&&(a+=o.length)}}function oi(e){return new _({key:new v(`image-input`),props:{handlePaste:(t,n)=>{let r=ri(n.clipboardData),{onImagePaste:i,onImageSaveError:a}=e;return r.length===0||!i?!1:(ai(t,r,i,a),!0)},handleDrop:(t,n)=>{let r=ri(n.dataTransfer),{onImagePaste:i,onImageSaveError:a}=e;return r.length===0||!i?!1:(ai(t,r,i,a,t.posAtCoords({left:n.clientX,top:n.clientY})?.pos),!0)}}})}function si(e={}){return h(u({name:`mdImageView`,constructor:ni(e)}),g(p(oi(e)),t.high))}const ci=new v(`meowdown-image-click`);function li(e,t){let n=w(e,t,`mdImageSource`);if(!n)return;let{src:r,alt:i}=n.mark.attrs;return{from:n.from,to:n.to,src:r,alt:i}}function ui(e){return p(new _({key:ci,props:{handleClick:(t,n,r)=>{let i=r.target?.closest?.(`.md-image-preview`);if(!i)return!1;let a=i.closest(`.md-image-view`)?.querySelector(`.md-image-view-content`);if(!a)return!1;let o=li(t.state,t.posAtDOM(a,0));return o?(e({src:o.src,alt:o.alt,event:r}),!0):!1}}}))}const di=new v(`meowdown-embed-paste`);function fi(e){let t=e.trim();if(!(!t||/\s/.test(t)))return K(t)?t:void 0}function pi(e,t){return e.clipboardData?.getData(`text/plain`)||t.content.textBetween(0,t.content.size,`
|
|
3
|
-
|
|
4
|
-
`,t-1)+1,r=0;for(let i=n;i<t;i++)r+=e.charCodeAt(i)===9?4-r%4:1;return r}function Ti(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 Ei(e,t){return t===0||!e.includes(`
|
|
1
|
+
import{Priority as e,Priority as t,createMarkBuilders as n,createNodeBuilders as r,defineBaseCommands as i,defineBaseKeymap as a,defineCommands as o,defineHistory as s,defineKeymap as c,defineMarkSpec as l,defineMarkView as u,defineNodeAttr as d,defineNodeSpec as f,definePlugin as p,getMarkRange as m,getMarkType as ee,getNodeType as te,isAllSelection as ne,isAtBlockStart as re,isTextSelection as h,toggleNode as ie,union as g,unsetBlockType as ae,withPriority as oe,withPriority as _,withSkipCodeBlock as se}from"@prosekit/core";import{definePlaceholder as ce}from"@prosekit/extensions/placeholder";import{defineReadonly as le}from"@prosekit/extensions/readonly";import{once as v}from"@ocavue/utils";import{defineBlockquote as ue}from"@prosekit/extensions/blockquote";import{defineCodeBlock as de,defineCodeBlockHighlight as fe}from"@prosekit/extensions/code-block";import{defineDoc as pe}from"@prosekit/extensions/doc";import{defineGapCursor as me}from"@prosekit/extensions/gap-cursor";import{defineModClickPrevention as he}from"@prosekit/extensions/mod-click-prevention";import{defineText as ge}from"@prosekit/extensions/text";import{defineVirtualSelection as _e}from"@prosekit/extensions/virtual-selection";import{Plugin as y,PluginKey as b,Selection as ve,TextSelection as x}from"@prosekit/pm/state";import{Decoration as ye,DecorationSet as S}from"@prosekit/pm/view";import{LanguageDescription as be}from"@codemirror/language";import{languages as xe}from"@codemirror/language-data";import{classHighlighter as Se,highlightTree as Ce}from"@lezer/highlight";import{createParser as we}from"prosemirror-highlight/lezer";import{defineHeadingCommands as Te,defineHeadingInputRule as Ee,defineHeadingSpec as De}from"@prosekit/extensions/heading";import{defineHorizontalRule as Oe}from"@prosekit/extensions/horizontal-rule";import{ReplaceStep as ke,Step as Ae,StepResult as je,Transform as Me}from"@prosekit/pm/transform";import{DOMSerializer as Ne,Mark as Pe}from"@prosekit/pm/model";import{GFM as Fe,parser as Ie}from"@lezer/markdown";import{defineInputRule as Le}from"@prosekit/extensions/input-rule";import{defineListCommands as Re,defineListDropIndicator as ze,defineListKeymap as Be,defineListPlugins as Ve,defineListSerializer as He,defineListSpec as Ue,wrapInList as C}from"@prosekit/extensions/list";import{wrappingListInputRule as w}from"prosemirror-flat-list";import{defineParagraphCommands as We,defineParagraphKeymap as Ge}from"@prosekit/extensions/paragraph";import{defineTableCellSpec as Ke,defineTableCommands as qe,defineTableDropIndicator as Je,defineTableEditingPlugin as Ye,defineTableHeaderCellSpec as Xe,defineTableRowSpec as Ze,defineTableSpec as Qe,deleteTable as $e,isCellSelection as et}from"@prosekit/extensions/table";import{closeHistory as tt}from"@prosekit/pm/history";import nt from"rehype-parse";import rt from"rehype-remark";import it from"remark-gfm";import at from"remark-stringify";import{unified as ot}from"unified";import{triggerAutocomplete as st}from"@prosekit/extensions/autocomplete";function T(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 m(i,n)}const ct=new Set([`mdMark`,`mdLinkUri`]),lt=new Set([`mdImageSource`,`mdWikilinkSource`]),ut=new b(`mark-mode`);function dt(e){return new y({key:ut,state:{init:()=>e,apply:(e,t)=>t},props:{attributes:{"data-mark-mode":e},decorations:e===`focus`?e=>ht(e):void 0,clipboardTextSerializer:e===`show`?void 0:mt}})}function ft(e){return p(dt(e))}function pt(e){return ut.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=>lt.has(e.type.name))&&e.marks.some(e=>ct.has(e.type.name))||n.push(e.text),!1)),t.push(n.join(``))}),t.join(`
|
|
2
|
+
`)}function ht(e){let{selection:t}=e;if(!t.empty)return S.empty;let n=t.$head,{parent:r}=n;if(!r.isTextblock||r.type.spec.code)return S.empty;let i=m(n,ee(e.schema,`mdPack`));return i?S.create(e.doc,[ye.inline(i.from,i.to,{class:`show`})]):S.empty}function E(e,t){let n=pt(t);return n?e.flatMap(e=>e.modes.includes(n)?[e.name]:[]):[]}function D(e,t,n){for(let r of n){let n=T(e,t,r);if(n)return n}}function O(e,t,n){let r=D(e,t,n);return r&&r.to===t?r:void 0}function k(e,t,n){let r=D(e,t,n);return r&&r.from===t?r:void 0}function A(e,t){let{from:n,to:r,empty:i}=e.selection;if(i)return;let a=D(e,n,t);return a&&a.from===n&&a.to===r?a:void 0}function gt(e,t){return x.create(e.doc,t.from,t.to)}function _t(e){return(t,n)=>{let r=E(e,t);if(r.length===0||!h(t.selection))return!1;let i=t.selection;if(i.empty){let e=k(t,i.from,r);if(e)return n?.(t.tr.setSelection(gt(t,e))),!0;if(O(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=A(t,r);return a?(n?.(t.tr.setSelection(x.create(t.doc,a.to))),!0):!1}}function vt(e){return(t,n)=>{let r=E(e,t);if(r.length===0||!h(t.selection))return!1;let i=t.selection;if(i.empty){let e=O(t,i.from,r);return e?(n?.(t.tr.setSelection(gt(t,e))),!0):!1}let a=A(t,r);return a?(n?.(t.tr.setSelection(x.create(t.doc,a.from))),!0):!1}}function yt(e){return(t,n)=>{let r=E(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=O(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!k(t,i,r)||i<=t.doc.resolve(i).start()?!1:(n?.(t.tr.delete(i-1,i)),!0)}}function bt(e){return(t,n)=>{let r=E(e,t);if(r.length===0||!t.selection.empty)return!1;let i=t.selection.from,a=k(t,i,r);return a?(n?.(t.tr.delete(a.from,a.to)),!0):!O(t,i,r)||i>=t.doc.resolve(i).end()?!1:(n?.(t.tr.delete(i,i+1)),!0)}}function xt(e,t){return new y({key:new b(`atomic-mark-selection-${t}`),props:{decorations:n=>{let r=E(e,n);if(r.length===0)return;let i=A(n,r);if(i)return S.create(n.doc,[ye.inline(i.from,i.to,{class:t})])}}})}function St({marks:e,selectedClass:n}){return g(_(c({ArrowRight:_t(e),ArrowLeft:vt(e),Backspace:yt(e),Delete:bt(e)}),t.high),p(xt(e,n)))}const j=new Map,Ct=new Map;async function wt(e){let t=j.get(e);if(t!==void 0)return t;let n=be.matchLanguageName(xe,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 Tt(e,t){let n=Ct.get(e);if(n)return n;let r=we({parse:e=>t.language.parser.parse(e.content),highlighter:Se});return Ct.set(e,r),r}const Et=e=>{let t=e.language?.trim();if(!t)return[];let n=j.get(t);return n===null?[]:n?Tt(t,n)(e):wt(t).then(()=>void 0)};function Dt(){return fe({parser:Et,nodeTypes:[`codeBlock`]})}function Ot(e,t){let n=t.language.parser.parse(e),r=[];return Ce(n,Se,(e,t,n)=>{r.push([e,t,n])}),r}function kt(e,t){let n=t.trim();if(!n)return[];let r=j.get(n);return r===null?[]:r?Ot(e,r):wt(n).then(t=>t?Ot(e,t):[])}function At(){return d({type:`doc`,attr:`frontmatter`,default:null})}function jt(){return f({name:`heading`,whitespace:`pre`})}function Mt(){return d({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 M(e){return se(ie({type:`heading`,attrs:{level:e}}))}const Nt=(e,t,n)=>re(e,n)?.parent.type.name===`heading`?ae()(e,t,n):!1;function Pt(){return c({"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:Nt})}function Ft(){return g(De(),jt(),Mt(),Ee(),Te(),Pt())}function It(){return d({type:`horizontalRule`,attr:`marker`,default:null,toDOM:e=>e?[`data-hr-marker`,e]:null,parseDOM:e=>e.getAttribute(`data-hr-marker`)})}function Lt(){return g(Oe(),It())}function Rt(){return f({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 zt(e){let[t,n,r]=e;return[t,n,r.map(e=>e.toJSON())]}function Bt(e,t){let[n,r,i]=t;return[n,r,i.map(t=>Pe.fromJSON(e,t))]}var N=class e extends Ae{constructor(e){super(),this.chunks=e}apply(e){if(this.chunks.length===0)return je.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 Me(e),n.removeMark(i,c,t));for(let t of a)t.isInSet(l)||(n??=new Me(e),n.addMark(i,c,t));return!1})}return je.ok(n?n.doc:e)}invert(e){if(this.chunks.length===0)return Vt;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 ke(i,a,e.slice(i,a),!1)}map(e){return null}toJSON(){return{stepType:`batchSetMark`,chunks:this.chunks.map(zt)}}static fromJSON(t,n){let r=n.chunks;return new e(r.map(e=>Bt(t,e)))}};Ae.jsonID(`batchSetMark`,N);const Vt=new N([]),Ht=new Set([`com`,`br`,`net`,`jp`,`org`,`in`,`de`,`ru`,`it`,`fr`]),Ut=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;function Wt(e){let t=e.indexOf(`/`);return t===-1?e:e.slice(0,t)}function Gt(e){let t=e.split(`.`);if(t.length<2)return!1;let n=t[t.length-1].toLowerCase();if(!Ht.has(n)||t[t.length-2].length<3)return!1;for(let e of t)if(e.length>63||!Ut.test(e))return!1;return!0}function P(e){return e===32||e===9||e===10||e===13}const Kt=/^[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:\/[^\s<]*)?/i,qt=/[\s(*_~]/;function Jt(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45}function Yt(e,t,n){let r=0;for(let i=0;i<t;i++)e[i]===n&&r++;return r}function Xt(e){let t=e.length;for(;;){let n=e[t-1];if(/[?!.,:*_~]/.test(n)||n===`)`&&Yt(e,t,`)`)>Yt(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 Zt={parseInline:[{name:`BareAutolink`,before:`Link`,parse(e,t,n){if(!Jt(t)||e.hasOpenLink)return-1;let r=e.slice(n-1,n);if(r!==``&&!qt.test(r))return-1;let i=Kt.exec(e.slice(n,e.end));if(!i)return-1;let a=Xt(i[0]);return a===0||!Gt(Wt(i[0].slice(0,a)))?-1:e.addElement(e.elt(`URL`,n,n+a))}}]};function Qt(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 $t(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(!Qt(t))break;i||=$t(t),r++}return i?e.addElement(e.elt(`Hashtag`,n,r)):-1}}]},tn={resolve:`Highlight`,mark:`HighlightMark`},nn=/[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~\u{A1}\u{2010}-\u{2027}]/u,rn={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=nn.test(r),c=nn.test(i);return e.addDelimiter(tn,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 on(e){return e.end}const F=Ie.configure([Fe,en,an,Zt,rn]),sn=F.configure({parseInline:[{name:`SkipInline`,before:`Escape`,parse:on}]});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 cn(e){let t={};for(let n of e.nodeSet.types)t[n.name]=n.id;return t}const R=cn(F);function ln(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 un(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 dn(){return e=>{let t=e.attrs,n=document.createElement(`span`);n.className=`md-wikilink-view`;let r=document.createElement(`span`);r.className=`md-wikilink-label`,r.contentEditable=`false`,r.dataset.testid=`wikilink`,r.textContent=t.display||t.target,n.appendChild(r);let i=document.createElement(`span`);return i.className=`md-wikilink-view-content`,n.appendChild(i),{dom:n,contentDOM:i,ignoreMutation:e=>!i.contains(e.target)}}}function fn(){return u({name:`mdWikilinkView`,constructor:dn()})}const z=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.Hashtag,`mdTag`],[R.WikilinkMark,`mdMark`]]);function pn(e,t){let n=I(t),r=[];return B(n,[],0,t.length,t,e,r),r}function mn(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)||Gt(Wt(e)))return`https://${e}`}function B(e,t,n,r,i,a,o){let s=n;for(let n of e){n.from>s&&V(o,s,n.from,t);let e=n.type;if(e===R.Link)hn(n,t,i,a,o);else if(e===R.Image)gn(n,t,i,a,o);else if(e===R.Wikilink)_n(n,t,i,a,o);else if(e===R.URL){let e=mn(i.slice(n.from,n.to)),r=e?a.mdLinkText.create({href:e}):a.mdLinkUri.create();V(o,n.from,n.to,[...t,r])}else{let r;e===R.Emphasis?r=`italic`:e===R.StrongEmphasis?r=`bold`:e===R.InlineCode?r=`code`:e===R.Strikethrough?r=`strike`:e===R.Highlight?r=`highlight`:e===R.Autolink&&(r=`autolink`);let s=r?[...t,a.mdPack.create({key:r})]:t,c=z.get(e),l=c?[...s,a[c].create()]:s;n.children.length===0?V(o,n.from,n.to,l):B(n.children,l,n.from,n.to,i,a,o)}s=n.to}s<r&&V(o,s,r,t)}function hn(e,t,n,r,i){let a=-1,o=null,s=0;for(let t of e.children)t.type===R.LinkMark?(s++,s===2&&(a=t.from)):t.type===R.URL&&o===null&&(o=t);let c=o?n.slice(o.from,o.to):``,l=c?r.mdLinkText.create({href:c}):null,u=e=>a>=0&&e<a&&l!==null,d=r.mdPack.create({key:`link_${c}`}),f=[...t,d],p=e.from;for(let t of e.children){if(t.from>p){let e=u(p)?[...f,l]:f;V(i,p,t.from,e)}let e=u(t.from)?[...f,l]:f;if(t.type===R.Wikilink){_n(t,e,n,r,i),p=t.to;continue}let a=z.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),p=t.to}p<e.to&&V(i,p,e.to,f)}function gn(e,t,n,r,i){let a=e.children.find(e=>e.type===R.URL);if(!a){hn(e,t,n,r,i);return}let o=e.children.filter(e=>e.type===R.LinkMark),s=n.slice(a.from,a.to),c=o.length>=2?n.slice(o[0].to,o[1].from):``,l=r.mdImageSource.create({src:s,alt:c}),u=r.mdImageView.create({src:s,alt:c}),d=r.mdPack.create({key:`image_${s}`}),f=e.to-1,p=e=>e>=f?[...t,d,l,u]:[...t,d,l],m=e.from;for(let t of e.children){t.from>m&&V(i,m,t.from,p(m));let e=z.get(t.type),a=e?[...p(t.from),r[e].create()]:p(t.from);t.children.length===0?V(i,t.from,t.to,a):B(t.children,a,t.from,t.to,n,r,i),m=t.to}m<e.to&&V(i,m,e.to,p(m))}function _n(e,t,n,r,i){let{target:a,display:o}=un(n.slice(e.from,e.to)),s=r.mdWikilinkSource.create({target:a}),c=r.mdWikilinkView.create({target:a,display:o}),l=e.to-1,u=e=>e>=l?[...t,s,c]:[...t,s],d=e.from;for(let t of e.children){t.from>d&&V(i,d,t.from,u(d));let e=r.mdMark.create();t.from<l&&t.to>l?(V(i,t.from,l,[...u(t.from),e]),V(i,l,t.to,[...u(l),e])):V(i,t.from,t.to,[...u(t.from),e]),d=t.to}d<e.to&&V(i,d,e.to,u(d))}function V(e,t,n,r){if(t>=n)return;let i=e.at(-1);if(i&&i[1]===t&&ln(i[2],r)){e[e.length-1]=[i[0],n,i[2]];return}e.push([t,n,r])}const vn=`inline-marks-applied`,yn=new WeakMap;let bn=0,xn=0;function Sn(e,t,n){let r=yn.get(e);if(r?xn++:(bn++,r=pn(Ar(n),e.textContent),yn.set(e,r)),t===0)return r;let i=[];for(let[e,n,a]of r)i.push([e+t,n+t,a]);return i}function Cn(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 wn(e,t){let n=[];return e.doc.nodesBetween(t.from,t.to,(t,r)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;if(t.childCount===0)return!1;let i=Sn(t,r+1,e.schema);return i.length>0&&n.push(...i),!1}),n}function Tn(){return new y({key:new b(`inline-mark`),appendTransaction(e,t,n){for(let t of e)if(t.getMeta(vn))return null;let r=wn(n,Cn(e,n));if(r.length===0)return null;let i=n.tr.step(new N(r));return i.setMeta(vn,!0),i.setMeta(`addToHistory`,!1),i},view(e){return e.dispatch(En(e.state)),{}}})}function En(e){return e.tr.setMeta(`inline-marks-trigger`,!0)}function Dn(){return p(Tn())}function On(){return l({name:`mdImageView`,inclusive:!1,attrs:{src:{default:``},alt:{default:``}},toDOM:()=>[`span`,{class:`md-image-anchor`},0],parseDOM:[{tag:`span.md-image-anchor`}]})}function kn(){return l({name:`mdImageSource`,inclusive:!1,attrs:{src:{default:``},alt:{default:``}},toDOM:()=>[`span`,{class:`md-image-source`},0],parseDOM:[{tag:`span.md-image-source`}]})}function An(){return l({name:`mdMark`,inclusive:!1,toDOM:()=>[`span`,{class:`md-mark`},0],parseDOM:[{tag:`span.md-mark`}]})}function jn(){return l({name:`mdEm`,toDOM:()=>[`em`,0],parseDOM:[{tag:`em`}]})}function Mn(){return l({name:`mdStrong`,toDOM:()=>[`strong`,0],parseDOM:[{tag:`strong`}]})}function Nn(){return l({name:`mdCode`,toDOM:()=>[`code`,0],parseDOM:[{tag:`code`}]})}function Pn(){return l({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 Fn(){return l({name:`mdLinkUri`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-uri`},0],parseDOM:[{tag:`span.md-link-uri`}]})}function In(){return l({name:`mdDel`,toDOM:()=>[`del`,0],parseDOM:[{tag:`del`}]})}function Ln(){return l({name:`mdHighlight`,toDOM:()=>[`mark`,0],parseDOM:[{tag:`mark`}]})}function Rn(){return l({name:`mdTag`,toDOM:()=>[`span`,{class:`md-tag`},0],parseDOM:[{tag:`span.md-tag`}]})}function zn(){return l({name:`mdWikilinkSource`,inclusive:!1,attrs:{target:{default:``}},toDOM:()=>[`span`,{class:`md-wikilink-source`},0],parseDOM:[{tag:`span.md-wikilink-source`}]})}function Bn(){return l({name:`mdWikilinkView`,inclusive:!1,attrs:{target:{default:``},display:{default:``}},toDOM:()=>[`span`,{class:`md-wikilink-anchor`},0],parseDOM:[{tag:`span.md-wikilink-anchor`}]})}function Vn(){return l({name:`mdPack`,excludes:``,inclusive:!1,attrs:{key:{default:``}},toDOM:e=>[`span`,{class:`md-pack`,"data-key":e.attrs.key},0],parseDOM:[{tag:`span.md-pack`}]})}function Hn(){return g(An(),jn(),Mn(),Nn(),Pn(),Fn(),In(),Ln(),Rn(),zn(),Bn(),kn(),On(),Vn())}function Un(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:`==`}},Wn=new Set([R.EmphasisMark,R.CodeMark,R.LinkMark,R.StrikethroughMark,R.HighlightMark]);function U(e){return[e.children[0],e.children.at(-1)]}function Gn(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=Gn(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 Kn(e,t,n){for(let r of e)if(!(r.to<=t||r.from>=n)&&(t>r.from||r.to>n))return Kn(e,Math.min(t,r.from),Math.max(n,r.to));return[t,n]}function qn(e,t,n){for(;t<n&&P(e.charCodeAt(t));)t++;for(;n>t&&P(e.charCodeAt(n-1));)n--;return[t,n]}function Jn(e,t,n,r){let i=L(I(e),e=>e.type===r.node||Wn.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 Yn(e,t,n,r,i){let a=I(e),o=L(a,e=>e.type===r.node);return i?Qn(e,o,t,n):Xn(e,a,o,t,n,r)}function Xn(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]=Zn(e,r,i,o,a);return o.push({from:r,to:r,insert:s},{from:i,to:i,insert:c}),o}function Zn(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(Un(a)+1),s=a.startsWith("`")||a.endsWith("`")?` `:``;return[o+s,s+o]}function Qn(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]=Kn(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 $n(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 er(a,t)||e[t-1]===r[0]||e[t]===r[0]?null:{kind:`insert`,pos:t}}function er(e,t){for(let n of e)if(n.from<t&&t<n.to){let e=Gn(n);return!e||t<e[0]||t>e[1]?!0:er(n.children,t)}return!1}function G(e){return(t,n)=>{if(t.selection.empty)return tr(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]=qn(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:Jn(a,c,l,e)}),!1});let c=s.length>0&&s.every(e=>e.active),l=s.filter(e=>c||!e.active).flatMap(t=>Yn(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 tr(e,t,n){let{$from:r}=t.selection,i=r.parent;if(!i.isTextblock||i.type.spec.code)return!1;let a=$n(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 nr(){return o({toggleEm:()=>G(H.em),toggleStrong:()=>G(H.strong),toggleCode:()=>G(H.code),toggleDel:()=>G(H.del),toggleHighlight:()=>G(H.highlight)})}function rr(){return c({"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 ir(){return g(nr(),rr())}function ar(){return d({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 or(){return d({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 sr(e){return e===2||e===3||e===4}function cr(){return d({type:`list`,attr:`markerGap`,default:1,splittable:!0,toDOM:e=>sr(e)?[`data-list-marker-gap`,String(e)]:null,parseDOM:e=>{let t=Number.parseInt(e.getAttribute(`data-list-marker-gap`)??``,10);return sr(t)?t:1}})}const lr=[w(/^\s?([*-])\s$/,{kind:`bullet`,collapsed:!1}),w(/^\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}}),w(/^\s?\[([\sXx]?)]\s$/,({match:e})=>({kind:`task`,checked:[`x`,`X`].includes(e[1]),collapsed:!1})),w(/^\s?\+\s$/,{kind:`task`,marker:`+`,checked:!1,collapsed:!1})];function ur(){return g(lr.map(Le))}function dr(){return C({kind:`task`,marker:`+`})}function fr(){return C({kind:`task`,marker:null})}function pr(){return o({wrapInCircleTask:dr,wrapInSquareTask:fr})}function mr(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 hr(){return(e,t,n)=>{let r=mr(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},C(a)(e,t,n)}}function gr(){return(e,t,n)=>{let r=mr(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},C(a)(e,t,n)}}function _r(){return c({"Mod-Enter":hr(),"Mod-Shift-Enter":gr()})}function vr(){return g(Ue(),Ve(),Be(),Re(),He(),ze(),ur(),_r(),ar(),or(),cr(),pr())}function yr(){return f({name:`paragraph`,content:`inline*`,group:`block`,whitespace:`pre`,parseDOM:[{tag:`p`}],toDOM(){return[`p`,0]}})}function br(){return g(_(yr(),t.highest),We(),Ge())}const xr=(e,t)=>{let{selection:n}=e;return!et(n)||!n.isColSelection()||!n.isRowSelection()?!1:$e(e,t)};function Sr(){return _(c({Backspace:xr,Delete:xr}),t.high)}function Cr(){return g(Qe(),Ze(),Ke(),Xe(),Ye({allowTableNodeSelection:!0}),qe(),Je(),Sr())}function wr(){return g(br(),pe(),At(),ge(),ue(),vr(),Ft(),Cr(),de(),Lt(),Rt(),Hn(),Dt(),Dn(),ir(),fn(),St({marks:[{name:`mdImageSource`,modes:[`hide`]},{name:`mdWikilinkSource`,modes:[`hide`,`focus`,`show`]}],selectedClass:`md-atomic-selected`}),a(),i(),s(),me(),_e(),he())}function Tr(){return wr()}const Er=v(()=>{let e=Tr().schema;if(e==null)throw Error(`Unexpected empty schema`);return e}),Dr=v(()=>r(Er())),Or=v(()=>n(Er())),kr=`meowdown_mark_builders`;function Ar(e){let t=e.cached[kr];if(t)return t;let r=n(e);return e.cached[kr]=r,r}const jr=`meowdown_node_builders`;function Mr(e){let t=e.cached[jr];if(t)return t;let n=r(e);return e.cached[jr]=n,n}function K(e,t={}){let{nodes:n=Dr(),frontmatter:r=!1}=t,i,a=e;if(r){let[t,n]=Pr(e);i=t,n&&(a=e.slice(n))}let o=Fr(n,sn.parse(a).cursor(),a);return n.doc(i===void 0?{}:{frontmatter:i},o)}const Nr=/^---[ \t]*\r?\n([\s\S]*?\n)?---[ \t]*(?:\r?\n|$)/;function Pr(e){let t=Nr.exec(e);return t?[(t[1]??``).replace(/\r?\n$/,``),t[0].length]:[]}function Fr(e,t,n){let r=[];if(!t.firstChild())return r;do r.push(...q(e,t,n));while(t.nextSibling());return t.parent(),r}function q(e,t,n){switch(t.type.id){case R.ATXHeading1:return[J(e,t,n,1,!1)];case R.ATXHeading2:return[J(e,t,n,2,!1)];case R.ATXHeading3:return[J(e,t,n,3,!1)];case R.ATXHeading4:return[J(e,t,n,4,!1)];case R.ATXHeading5:return[J(e,t,n,5,!1)];case R.ATXHeading6:return[J(e,t,n,6,!1)];case R.SetextHeading1:return[J(e,t,n,1,!0)];case R.SetextHeading2:return[J(e,t,n,2,!0)];case R.Paragraph:return[Q(e,t,n)];case R.CommentBlock:return[Rr(e,t,n)];case R.HTMLBlock:case R.ProcessingInstructionBlock:return[Q(e,t,n)];case R.Blockquote:return[zr(e,t,n)];case R.BulletList:return Br(e,t,n,`bullet`);case R.OrderedList:return Br(e,t,n,`ordered`);case R.FencedCode:case R.CodeBlock:return[Hr(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[Ur(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 J(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=X(n.slice(o,s),Y(n,o)).trim(),d=i?Ir(n,c,l)||1:null;return e.heading({level:r,setextUnderline:d},u)}function Ir(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 Y(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 Lr(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 X(e,t){return t===0||!e.includes(`
|
|
5
4
|
`)?e:e.split(`
|
|
6
|
-
`).map((e,n)=>n===0?e:
|
|
7
|
-
`)}function Z(e,t,n){return e.paragraph(
|
|
5
|
+
`).map((e,n)=>n===0?e:Lr(e,t)).join(`
|
|
6
|
+
`)}function Z(e,t,n){return e.paragraph(X(t,n))}function Q(e,t,n){let r=t.from,i=t.to,a=Y(n,r);if(t.firstChild()){let o=``,s=r;do t.type.id===R.QuoteMark&&(o+=n.slice(s,t.from),s=t.to,P(n.charCodeAt(s))&&(s+=1));while(t.nextSibling());return t.parent(),o+=n.slice(s,i),Z(e,o,a)}return Z(e,n.slice(r,i),a)}function Rr(e,t,n){let r=Y(n,t.from),i=X(n.slice(t.from,t.to),r);return e.htmlComment({content:i})}function zr(e,t,n){let r=[];if(t.firstChild()){do{if(t.type.id===R.QuoteMark)continue;r.push(...q(e,t,n))}while(t.nextSibling());t.parent()}return e.blockquote(r)}function Br(e,t,n,r){let i=[];if(t.firstChild()){do t.type.id===R.ListItem&&i.push(Vr(e,t,n,r));while(t.nextSibling());t.parent()}return i}function Vr(e,t,n,r){let i=[],a,o,s,c,l,u;if(t.firstChild()){do{if(t.type.id!==R.ListMark&&u==null&&(u=Y(n,t.from)),t.type.id===R.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=Y(n,t.to);continue}if(r===`bullet`&&t.type.id===R.Task){let r=t.from,s=t.to;if(a=!1,t.firstChild()){if(t.type.id===R.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()}P(n.charCodeAt(r))&&(r+=1);let c=n.slice(r,s);i.push(Z(e,c,Y(n,r)));continue}i.push(...q(e,t,n))}while(t.nextSibling());t.parent()}let d=u!=null&&l!=null?u-l:1;return e.list({kind:a==null?r:`task`,order:r===`ordered`?s??1:null,checked:a??!1,collapsed:!1,marker:c,taskMarker:o,markerGap:d>=2&&d<=4?d:1},i)}function Hr(e,t,n){let r=``,i=``;if(t.firstChild()){do switch(t.type.id){case R.CodeInfo:r=n.slice(t.from,t.to);break;case R.CodeText:i+=n.slice(t.from,t.to);break}while(t.nextSibling());t.parent()}return e.codeBlock({language:r},i)}function Ur(e,t,n){let r=0;if(t.firstChild()){do t.type.id===R.TableDelimiter&&(r=Wr(n.slice(t.from,t.to)));while(t.nextSibling());t.parent()}let i=[];if(t.firstChild()){do{let a=t.type.id;a===R.TableHeader?i.push(Gr(e,t,n,!0,r)):a===R.TableRow&&i.push(Gr(e,t,n,!1,r))}while(t.nextSibling());t.parent()}return e.table(i)}function Wr(e){return e.split(`|`).filter(e=>e.trim()!==``).length}function Gr(e,t,n,r,i){let a=Array(i).fill(``);if(t.firstChild()){let e=t.type.id===R.TableDelimiter,r=0;do if(t.type.id===R.TableDelimiter)r++;else if(t.type.id===R.TableCell){let o=r-+!!e;o>=0&&o<i&&(a[o]=n.slice(t.from,t.to).trim().replaceAll(String.raw`\|`,`|`))}while(t.nextSibling());t.parent()}let o=a.map(t=>{let n=e.paragraph(t);return r?e.tableHeaderCell(n):e.tableCell(n)});return e.tableRow(o)}function $(e,t={}){let n=new Yr;return t.frontmatter&&Kr(e.attrs.frontmatter,n),Xr(e,n),n.finish()}function Kr(e,t){e!==null&&(t.write(`---`),t.write(`
|
|
8
7
|
`),e!==``&&(t.write(e),t.write(`
|
|
9
|
-
`)),t.write(`---`),t.closeBlock())}const
|
|
10
|
-
`+i.repeat(Math.max(1,r))),t.closeBlock();return}t.write(
|
|
8
|
+
`)),t.write(`---`),t.closeBlock())}const qr=[``,`# `,`## `,`### `,`#### `,`##### `,`###### `];function Jr(e,t){let n=e.attrs,r=n.setextUnderline;if(r!=null&&e.content.size>0&&n.level<=2){ei(e,t);let i=n.level===1?`=`:`-`;t.write(`
|
|
9
|
+
`+i.repeat(Math.max(1,r))),t.closeBlock();return}t.write(qr[n.level]??`# `),ei(e,t),t.closeBlock()}var Yr=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(`
|
|
11
10
|
`)){this.parts.push(e);return}let t=e.split(`
|
|
12
11
|
`);for(let e=0;e<t.length;e++)e>0&&this.parts.push(`
|
|
13
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(`
|
|
14
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+$/,``)+`
|
|
15
14
|
`}emitDeferredBlankLine(){let e=this.deferredBlankPrefix;e!==null&&(this.parts.push(e.trimEnd(),`
|
|
16
|
-
`),this.deferredBlankPrefix=null)}};function
|
|
15
|
+
`),this.deferredBlankPrefix=null)}};function Xr(e,t){switch(e.type.name){case`doc`:Zr(e,t);return;case`paragraph`:ei(e,t),t.closeBlock();return;case`heading`:Jr(e,t);return;case`blockquote`:t.withPrefix(`> `,`> `,()=>Zr(e,t)),t.closeBlock();return;case`list`:ti(e,t,$r(e));return;case`codeBlock`:ni(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`:ri(e,t);return;case`text`:e.text&&t.write(e.text);return}}function Zr(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(),Xr(a,t),i++;continue}let o=i+1;for(;o<r&&e.child(o).type.name===`list`;)o++;let s=Qr(e,i,o);for(let r=i;r<o;r++)(r===i?n&&i>0:s)&&t.suppressBlank(),ti(e.child(r),t,s);i=o}}function Qr(e,t,n){for(let r=t;r<n;r++)if(!$r(e.child(r)))return!1;return!0}function $r(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 ei(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 ti(e,t,n){let r=e.attrs,i=r.marker===`*`||r.marker===`+`?r.marker:`-`,a=r.marker===`)`?`)`:`.`,o=r.taskMarker===`X`?`X`:`x`,s=Math.min(Math.max(r.markerGap??1,1),4),c=`${r.kind===`ordered`?`${r.order??1}${a}`:i}${` `.repeat(s)}`,l=r.kind===`task`?`${c}[${r.checked?o:` `}] `:c,u=` `.repeat(c.length);t.withPrefix(u,l,()=>Zr(e,t,n)),t.closeBlock()}function ni(e,t){let n=e.attrs.language||``,r=e.textContent,i="`".repeat(Un(r,2)+1);t.write(i),n&&t.write(n),t.write(`
|
|
17
16
|
`),r&&(t.write(r),t.write(`
|
|
18
|
-
`)),t.write(i),t.closeBlock()}function
|
|
17
|
+
`)),t.write(i),t.closeBlock()}function ri(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(ai(t))}s&&a<0&&(a=t),o.length>i&&(i=o.length),r.push(o)}if(i===0)return;let o=`| `+Array(i).fill(`---`).join(` | `)+` |`,s=a>=0?r[a]:Array(i).fill(``);t.write(ii(s,i)),t.write(`
|
|
19
18
|
`),t.write(o);for(let e=0;e<n;e++)e!==a&&(t.write(`
|
|
20
|
-
`),t.write(
|
|
19
|
+
`),t.write(ii(r[e],i)));t.closeBlock()}function ii(e,t){let n=`|`;for(let r=0;r<t;r++)n+=` `+(e[r]??``)+` |`;return n}function ai(e){let t=e.textContent.trim();return!t.includes(`|`)&&!t.includes(`
|
|
21
20
|
`)?t:t.replaceAll(`|`,String.raw`\|`).replaceAll(`
|
|
22
|
-
`,` `)}
|
|
21
|
+
`,` `)}function oi(e){return e.replace(/\n+$/u,``)}function si(e){return/^[\s>]*$/u.test(e)}function ci(e){return e.split(`
|
|
22
|
+
`).filter(e=>!si(e))}function li(e,t={}){let n=$(K(e,{frontmatter:t.frontmatter}),{frontmatter:t.frontmatter});if(oi(n)===oi(e))return`exact`;let r=ci(e),i=ci(n);return r.length===i.length&&r.every((e,t)=>e.trimEnd()===i[t].trimEnd())?`normalizing`:`lossy`}const ui=(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=te(e.schema,`list`),i=te(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 di(){return _(c({Enter:ui}),t.high)}const fi=new Set([`MscGen`,`Xù`,`MsGenny`,`Angular Template`,`Brainfuck`,`Esper`,`Oz`,`Factor`,`Squirrel`,`Yacas`,`mIRC`,`FCL`,`ECL`,`MUMPS`,`Pig`,`Asterisk`,`Z80`]),pi=xe.map(e=>e.name).filter(e=>!fi.has(e)).map(e=>({label:e,value:e.toLowerCase()})).concat({label:`Plain text`,value:``}).sort((e,t)=>e.label.localeCompare(t.label));function mi(){return typeof window>`u`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches}const hi=/^(?:www\.|mobile\.)?(?:twitter\.com|x\.com)$/i,gi=/\/status(?:es)?\/(\d+)/;function _i(e){let t;try{t=new URL(e)}catch{return}if(hi.test(t.hostname))return gi.exec(t.pathname)?.[1]}const vi=e=>{let t=_i(e);if(!t)return;let n=mi()?`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 yi(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 bi=/^(?:www\.|m\.)?(?:youtube\.com|youtube-nocookie\.com)$/i,xi=/^(?:www\.)?youtu\.be$/i,Si=/^[\w-]{11}$/;function Ci(e){let t;try{t=new URL(e)}catch{return}let n=null;if(xi.test(t.hostname))n=t.pathname.slice(1);else if(bi.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||!Si.test(n))return;let r=t.searchParams.get(`start`)??t.searchParams.get(`t`),i=r?wi(r):void 0;return{videoId:n,startSeconds:i}}function wi(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 Ti=[e=>{let t=Ci(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}},vi];function Ei(e){for(let t of Ti){let n=t(e);if(n)return n}}const Di=new b(`meowdown-embed-paste`);function Oi(e){let t=e.trim();if(!(!t||/\s/.test(t)))return Ei(t)?t:void 0}function ki(e,t){return e.clipboardData?.getData(`text/plain`)||t.content.textBetween(0,t.content.size,`
|
|
23
|
+
`)}function Ai(e,t){let{from:n,to:r}=e.state.selection;e.dispatch(tt(e.state.tr.insertText(t,n,r)));let i=e.state.tr.insertText(``,n,n+t.length);e.dispatch(tt(i))}function ji(){return p(new y({key:Di,props:{handlePaste:(e,t,n)=>{let r=e.state.selection.$from.parent;if(!r.inlineContent||r.type.spec.code)return!1;let i=ki(t,n);if(!i)return!1;let a=Oi(i);return a?(Ai(e,a),!0):!1}}}))}const Mi=new b(`meowdown-exit-boundary`);function Ni(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&&ve.findFrom(a,t))}function Pi(e,t){let{state:n}=e,{selection:r}=n;return h(r)&&!r.empty||ne(r)||r.$from.parent.inlineContent&&!e.endOfTextblock(t<0?`up`:`down`)?!0:Ni(n,t)}function Fi(e){return new y({key:Mi,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||Pi(t,r)||e({direction:r<0?`up`:`down`,event:n})===!1)}}})}function Ii(e){return _(p(Fi(e)),t.low)}const Li=(e,t)=>{let n={type:`highlight`,children:e.all(t)};return e.patch(t,n),n},Ri=(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 zi(){return ot().use(nt).use(rt,{handlers:{mark:Li}}).use(it).use(at,{bullet:`-`,emphasis:`*`,strong:`*`,fence:"`",fences:!0,rule:`-`,ruleRepetition:3,listItemIndent:`one`,handlers:{highlight:Ri}}).freeze()}const Bi=v(zi);function Vi(e){return String(Bi().processSync(e))}const Hi=new b(`meowdown-html-paste`);function Ui(){return p(new y({key:Hi,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=Vi(e);if(!r.trim())return e;let i=K(r,{nodes:Mr(t.state.schema)}),a=Ne.fromSchema(t.state.schema),o=document.createElement(`div`);return o.append(a.serializeFragment(i.content)),o.innerHTML}}}))}const Wi=new b(`meowdown-image-click`);function Gi(e,t){let n=T(e,t,`mdImageSource`);if(!n)return;let{src:r,alt:i}=n.mark.attrs;return{from:n.from,to:n.to,src:r,alt:i}}function Ki(e){return p(new y({key:Wi,props:{handleClick:(t,n,r)=>{let i=r.target?.closest?.(`.md-image-preview`);if(!i)return!1;let a=i.closest(`.md-image-view`)?.querySelector(`.md-image-view-content`);if(!a)return!1;let o=Gi(t.state,t.posAtDOM(a,0));return o?(e({src:o.src,alt:o.alt,event:r}),!0):!1}}}))}function qi(e){return/^https?:\/\//i.test(e)?e:void 0}function Ji(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`&&yi(t),t}function Yi(e,t,n){let r=Ei(e);if(r){let e=document.createElement(`span`);return e.className=`md-image-preview md-image-preview-embed`,e.appendChild(Ji(r)),e}let i=(n.resolveImageUrl??qi)(e);if(!i)return;let a=document.createElement(`span`);a.className=`md-image-preview md-image-preview-img`,a.dataset.testid=`image-preview`;let o=document.createElement(`img`);return o.src=i,o.alt=t,o.draggable=!1,a.appendChild(o),a}function Xi(e){return t=>{let n=t.attrs,r=document.createElement(`span`);r.className=`md-image-view`;let i=document.createElement(`span`);i.className=`md-image-view-content`,r.appendChild(i);let a=Yi(n.src,n.alt,e);return a&&(a.contentEditable=`false`,r.appendChild(a)),{dom:r,contentDOM:i,ignoreMutation:e=>!i.contains(e.target)}}}function Zi(e){return e?Array.from(e.files).filter(e=>e.type.startsWith(`image/`)):[]}const Qi=e=>{console.error(`[meowdown] failed to save pasted image:`,e)};async function $i(e,t,n,r=Qi,i){let a=i;for(let i of t){let t;try{t=await n(i)}catch(e){r(e,i);continue}if(!t||e.isDestroyed)continue;let o=``,s=a==null?e.state.tr.insertText(o):e.state.tr.insertText(o,a);e.dispatch(s),a!=null&&(a+=o.length)}}function ea(e){return new y({key:new b(`image-input`),props:{handlePaste:(t,n)=>{let r=Zi(n.clipboardData),{onImagePaste:i,onImageSaveError:a}=e;return r.length===0||!i?!1:($i(t,r,i,a),!0)},handleDrop:(t,n)=>{let r=Zi(n.dataTransfer),{onImagePaste:i,onImageSaveError:a}=e;return r.length===0||!i?!1:($i(t,r,i,a,t.posAtCoords({left:n.clientX,top:n.clientY})?.pos),!0)}}})}function ta(e={}){return g(u({name:`mdImageView`,constructor:Xi(e)}),_(p(ea(e)),t.high))}const na={"Mod-b":`Bold`,"Mod-i":`Italic`,"Mod-e":`Inline code`,"Mod-Shift-x":`Strikethrough`,"Mod-Shift-h":`Highlight`,"Mod-1":`Heading 1`,"Mod-2":`Heading 2`,"Mod-3":`Heading 3`,"Mod-4":`Heading 4`,"Mod-5":`Heading 5`,"Mod-6":`Heading 6`};function ra(e){return p(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 ia=new b(`meowdown-link-click`);function aa(e,t){let n=T(e,t,`mdLinkText`);if(n)return{from:n.from,to:n.to,href:n.mark.attrs.href}}function oa(e){return ra({key:ia,selector:`.md-link`,preventDefault:!0,findPayloadAt:(e,t)=>aa(e,t)?.href,onClick:(t,n)=>e({href:t,event:n})})}const sa=new b(`meowdown-markdown-copy`);function ca(){return p(new y({key:sa,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
24
|
`,`
|
|
24
|
-
`)}}}))}const
|
|
25
|
-
`).filter(e=>!oa(e))}function ca(e,t={}){let n=$(q(e,{frontmatter:t.frontmatter}),{frontmatter:t.frontmatter});if(aa(n)===aa(e))return`exact`;let r=sa(e),i=sa(n);return r.length===i.length&&r.every((e,t)=>e.trimEnd()===i[t].trimEnd())?`normalizing`:`lossy`}export{na as EDITOR_KEY_BINDINGS,e as Priority,ca as checkRoundTrip,ia as codeBlockLanguages,$r as defaultResolveImageUrl,$i as defineBulletAfterHeading,Et as defineCodeBlockSyntaxHighlight,jr as defineEditorExtension,hi as defineEmbedPaste,Fi as defineHTMLPaste,si as defineImage,ui as defineImageClickHandler,Lr as defineLinkClickHandler,dt as defineMarkMode,Zi as defineMarkdownCopy,at as definePlaceholder,ot as defineReadonly,Br as defineTagClickHandler,Pr as defineWikilinkClickHandler,ta as defineWikilinkTrigger,$ as docToMarkdown,Ot as getCodeTokens,yn as getMarkBuilders,fn as inlineTextToMarkChunks,Kr as listenForTweetHeight,q as markdownToDoc,K as matchEmbed,oe as withPriority};
|
|
25
|
+
`)}}}))}const la=new b(`meowdown-tag-click`);function ua(e,t){let n=T(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 da(e){return ra({key:la,selector:`.md-tag`,preventDefault:!1,findPayloadAt:(e,t)=>ua(e,t)?.tag,onClick:(t,n)=>e({tag:t,event:n})})}const fa=new b(`meowdown-wikilink-click`);function pa(e,t){let n=T(e,t,`mdWikilinkSource`);if(!n)return;let{target:r}=n.mark.attrs;return{from:n.from,to:n.to,target:r}}function ma(e){return ra({key:fa,selector:`.md-wikilink-label, .md-wikilink-source`,preventDefault:!1,findPayloadAt:(e,t)=>pa(e,t)?.target,onClick:(t,n)=>e({target:t,event:n})})}const ha=(e,t)=>{let{selection:n}=e;if(!n.empty&&!n.$head.sameParent(n.$anchor))return!1;let r=e.doc.textBetween(n.from,n.to);if(r.startsWith(`[[`))return!1;r.startsWith(`[`)&&(r=r.slice(1));let i=`[[`+r;if(t){let r=e.tr.insertText(i,n.from,n.to);r.setSelection(x.create(r.doc,n.from+i.length)),st(r),t(r.scrollIntoView())}return!0};function ga(){return c({"Mod-Shift-k":ha})}export{na as EDITOR_KEY_BINDINGS,e as Priority,li as checkRoundTrip,pi as codeBlockLanguages,qi as defaultResolveImageUrl,di as defineBulletAfterHeading,Dt as defineCodeBlockSyntaxHighlight,Tr as defineEditorExtension,ji as defineEmbedPaste,Ii as defineExitBoundaryHandler,Rt as defineHTMLComment,Ui as defineHTMLPaste,ta as defineImage,Ki as defineImageClickHandler,oa as defineLinkClickHandler,ft as defineMarkMode,ca as defineMarkdownCopy,ce as definePlaceholder,le as defineReadonly,da as defineTagClickHandler,ma as defineWikilinkClickHandler,ga as defineWikilinkTrigger,$ as docToMarkdown,kt as getCodeTokens,Or as getMarkBuilders,pn as inlineTextToMarkChunks,yi as listenForTweetHeight,K as markdownToDoc,Ei as matchEmbed,oe as withPriority};
|