@meowdown/react 0.28.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +39 -44
- package/dist/index.js +68 -189
- package/dist/style.css +0 -20
- package/package.json +2 -7
package/dist/index.d.ts
CHANGED
|
@@ -11,8 +11,7 @@ type TimeFormat = '12' | '24';
|
|
|
11
11
|
type SelectionHint = SelectionJSON$1 | 'start' | 'end';
|
|
12
12
|
/**
|
|
13
13
|
* The current Markdown and selection. Selection positions are in the mounted
|
|
14
|
-
* editor's coordinate space
|
|
15
|
-
* character offsets in source mode. Not portable across a mode switch.
|
|
14
|
+
* editor's coordinate space and are not portable across editors.
|
|
16
15
|
*/
|
|
17
16
|
type EditorStateSnapshot = [markdown: string, selection: SelectionJSON$1];
|
|
18
17
|
interface EditorHandle {
|
|
@@ -40,7 +39,10 @@ interface EditorHandle {
|
|
|
40
39
|
focus: () => void;
|
|
41
40
|
/** Scrolls the selection into view. */
|
|
42
41
|
scrollIntoView: () => void;
|
|
43
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Escape hatch: the underlying ProseKit editor, or `undefined` when the
|
|
44
|
+
* handle does not wrap one.
|
|
45
|
+
*/
|
|
44
46
|
readonly editor: TypedEditor | undefined;
|
|
45
47
|
}
|
|
46
48
|
/**
|
|
@@ -80,13 +82,11 @@ interface WikilinkItem {
|
|
|
80
82
|
type WikilinkSearchHandler = (query: string) => WikilinkItem[] | Promise<WikilinkItem[]>;
|
|
81
83
|
//#endregion
|
|
82
84
|
//#region src/components/editor.d.ts
|
|
83
|
-
type EditorMode = MarkMode
|
|
85
|
+
type EditorMode = MarkMode;
|
|
84
86
|
interface EditorProps {
|
|
85
87
|
/**
|
|
86
|
-
* The editor mode
|
|
87
|
-
*
|
|
88
|
-
* Content carries over when switching between the two editor families, but undo
|
|
89
|
-
* history and selection do not. Defaults to 'focus'.
|
|
88
|
+
* The editor mode ('focus', 'show', 'hide'), controlling how much Markdown
|
|
89
|
+
* syntax stays in view. Defaults to 'focus'.
|
|
90
90
|
*/
|
|
91
91
|
mode?: EditorMode;
|
|
92
92
|
/**
|
|
@@ -101,42 +101,37 @@ interface EditorProps {
|
|
|
101
101
|
onDocChange?: VoidFunction;
|
|
102
102
|
/**
|
|
103
103
|
* Searches tags for the tag menu, which opens when typing `#` followed by
|
|
104
|
-
* text
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* tag menu. Ignored in source mode.
|
|
104
|
+
* text. Receives the query (lowercased, punctuation stripped) and returns the
|
|
105
|
+
* tags to show, synchronously or as a promise. Pass a stable function (e.g.
|
|
106
|
+
* from `useCallback`). Omit to disable the tag menu.
|
|
108
107
|
*/
|
|
109
108
|
onTagSearch?: TagSearchHandler;
|
|
110
109
|
/**
|
|
111
110
|
* Searches notes for the wikilink menu, which opens as soon as `[[` or `@`
|
|
112
|
-
* is typed
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* mode.
|
|
111
|
+
* is typed. Receives the query (lowercased, punctuation stripped, may be
|
|
112
|
+
* empty) and returns the note names to show, synchronously or as a promise.
|
|
113
|
+
* Pass a stable function (e.g. from `useCallback`). Omit to disable the
|
|
114
|
+
* wikilink menu.
|
|
117
115
|
*/
|
|
118
116
|
onWikilinkSearch?: WikilinkSearchHandler;
|
|
119
117
|
/**
|
|
120
118
|
* Called with the link target on click of a rendered wiki link. Pass a stable
|
|
121
|
-
* function (e.g. from `useCallback`).
|
|
119
|
+
* function (e.g. from `useCallback`).
|
|
122
120
|
*/
|
|
123
121
|
onWikilinkClick?: WikilinkClickHandler;
|
|
124
122
|
/**
|
|
125
123
|
* Called with the link `href` on click of a rendered Markdown link
|
|
126
|
-
* (`[text](url)`). Pass a stable function (e.g. from `useCallback`).
|
|
127
|
-
* in source mode.
|
|
124
|
+
* (`[text](url)`). Pass a stable function (e.g. from `useCallback`).
|
|
128
125
|
*/
|
|
129
126
|
onLinkClick?: LinkClickHandler;
|
|
130
127
|
/**
|
|
131
128
|
* Called after a link is copied from the link menu, with its `href`. Useful
|
|
132
|
-
* for a toast. Pass a stable function (e.g. from `useCallback`).
|
|
133
|
-
* source mode.
|
|
129
|
+
* for a toast. Pass a stable function (e.g. from `useCallback`).
|
|
134
130
|
*/
|
|
135
131
|
onLinkCopy?: LinkCopyHandler;
|
|
136
132
|
/**
|
|
137
133
|
* Called with the tag name (without the leading `#`) on click of a rendered
|
|
138
|
-
* `#tag`. Pass a stable function (e.g. from `useCallback`).
|
|
139
|
-
* mode.
|
|
134
|
+
* `#tag`. Pass a stable function (e.g. from `useCallback`).
|
|
140
135
|
*/
|
|
141
136
|
onTagClick?: TagClickHandler;
|
|
142
137
|
/**
|
|
@@ -146,73 +141,73 @@ interface EditorProps {
|
|
|
146
141
|
* Use it to move focus to a previous/next note or page. Receives the
|
|
147
142
|
* `direction` and the original `KeyboardEvent`. Return `false` to let the
|
|
148
143
|
* editor handle the key normally; any other return value consumes it. Pass a
|
|
149
|
-
* stable function (e.g. from `useCallback`).
|
|
144
|
+
* stable function (e.g. from `useCallback`).
|
|
150
145
|
*/
|
|
151
146
|
onExitBoundary?: ExitBoundaryHandler;
|
|
152
147
|
/**
|
|
153
148
|
* Maps an image `src` to a displayable URL, or `undefined` to skip that image.
|
|
154
149
|
* Defaults to showing http(s) URLs as-is. Pass a stable function (e.g. from
|
|
155
|
-
* `useCallback`).
|
|
150
|
+
* `useCallback`).
|
|
156
151
|
*/
|
|
157
152
|
resolveImageUrl?: ImageOptions['resolveImageUrl'];
|
|
158
153
|
/**
|
|
159
154
|
* Persists a pasted/dropped image file and returns its markdown `src`. Pass a
|
|
160
|
-
* stable function.
|
|
155
|
+
* stable function.
|
|
161
156
|
*/
|
|
162
157
|
onImagePaste?: ImageOptions['onImagePaste'];
|
|
163
|
-
/** Called when persisting a pasted/dropped image throws.
|
|
158
|
+
/** Called when persisting a pasted/dropped image throws. */
|
|
164
159
|
onImageSaveError?: ImageOptions['onImageSaveError'];
|
|
165
160
|
/**
|
|
166
161
|
* Called when the user clicks a rendered image, with its markdown `src`,
|
|
167
162
|
* `alt`, and the originating `MouseEvent`. Pass a stable function (e.g. from
|
|
168
|
-
* `useCallback`).
|
|
163
|
+
* `useCallback`).
|
|
169
164
|
*/
|
|
170
165
|
onImageClick?: ImageClickHandler;
|
|
171
166
|
/**
|
|
172
167
|
* Auto-embeds a pasted tweet or YouTube link as a rich embed; one undo turns
|
|
173
|
-
* the embed back into the raw link. On by default.
|
|
168
|
+
* the embed back into the raw link. On by default.
|
|
174
169
|
*/
|
|
175
170
|
embedPaste?: boolean;
|
|
176
171
|
/**
|
|
177
172
|
* Pressing Enter at the end of the document's first heading (the title line)
|
|
178
173
|
* starts a fresh empty bullet on the next line instead of a plain paragraph.
|
|
179
|
-
* Off by default.
|
|
174
|
+
* Off by default.
|
|
180
175
|
*/
|
|
181
176
|
bulletAfterHeading?: boolean;
|
|
182
|
-
/** Handles a leading `---` frontmatter block
|
|
177
|
+
/** Handles a leading `---` frontmatter block (off by default). */
|
|
183
178
|
frontmatter?: boolean;
|
|
184
179
|
/**
|
|
185
|
-
* Shows the per-block gutter handle
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
180
|
+
* Shows the per-block gutter handle: a drag grip for reordering blocks and a
|
|
181
|
+
* "+" add button, plus the drop indicator that visualizes where a dragged
|
|
182
|
+
* block will land. On by default. Set to `false` to hide the gutter
|
|
183
|
+
* affordance entirely, e.g. when the host does not want block reordering.
|
|
184
|
+
* Ignored when `readOnly` is set.
|
|
190
185
|
*/
|
|
191
186
|
blockHandle?: boolean;
|
|
192
187
|
/**
|
|
193
188
|
* Placeholder text shown when the whole document is empty. A function
|
|
194
|
-
* receives the editor state. Pass a stable function.
|
|
189
|
+
* receives the editor state. Pass a stable function.
|
|
195
190
|
*/
|
|
196
191
|
placeholder?: PlaceholderOptions['placeholder'];
|
|
197
|
-
/** Makes the editor read-only
|
|
192
|
+
/** Makes the editor read-only. */
|
|
198
193
|
readOnly?: boolean;
|
|
199
194
|
/**
|
|
200
|
-
* Enables the browser's native spell checking
|
|
201
|
-
*
|
|
195
|
+
* Enables the browser's native spell checking. Defaults to the browser's
|
|
196
|
+
* behavior.
|
|
202
197
|
*/
|
|
203
198
|
spellCheck?: boolean;
|
|
204
199
|
/**
|
|
205
200
|
* Clock format the `/now` slash command inserts: '12' for "3:45pm" or '24'
|
|
206
|
-
* for "15:45". Defaults to '12'.
|
|
201
|
+
* for "15:45". Defaults to '12'.
|
|
207
202
|
*/
|
|
208
203
|
timeFormat?: TimeFormat;
|
|
209
|
-
/** Class on the editable root (the contenteditable).
|
|
204
|
+
/** Class on the editable root (the contenteditable). */
|
|
210
205
|
editorClassName?: string;
|
|
211
206
|
/** Class on the outer `.meowdown` wrapper div. */
|
|
212
207
|
wrapperClassName?: string;
|
|
213
208
|
/** Imperative handle for the editor. */
|
|
214
209
|
handleRef?: Ref<EditorHandle>;
|
|
215
|
-
/** Nodes rendered inside the editor's ProseKit context
|
|
210
|
+
/** Nodes rendered inside the editor's ProseKit context. */
|
|
216
211
|
children?: ReactNode;
|
|
217
212
|
}
|
|
218
213
|
declare function MeowdownEditor({
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { clsx } from "clsx/lite";
|
|
2
|
-
import { Fragment, createElement, useCallback, useEffect, useImperativeHandle,
|
|
3
|
-
import {
|
|
4
|
-
import { markdown, markdownLanguage } from "@codemirror/lang-markdown";
|
|
5
|
-
import { defaultHighlightStyle, syntaxHighlighting } from "@codemirror/language";
|
|
6
|
-
import { Compartment, EditorSelection, EditorState } from "@codemirror/state";
|
|
7
|
-
import { EditorView, keymap } from "@codemirror/view";
|
|
2
|
+
import { Fragment, createElement, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { codeBlockLanguages, defaultResolveImageUrl, defineBulletAfterHeading, defineEditorExtension, defineEmbedPaste, defineExitBoundaryHandler, defineHTMLPaste, defineImage, defineImageClickHandler, defineLinkClickHandler, defineLinkEditKeymap, defineLinkHoverHandler, defineMarkMode, defineMarkdownCopy, definePlaceholder, defineReadonly, defineTagClickHandler, defineWikilinkClickHandler, defineWikilinkTrigger, docToMarkdown, getCodeTokens, getMarkBuilders, getVirtualElementFromRange, inlineTextToMarkChunks, isSelectionInTableCell, listenForTweetHeight, markdownToDoc, matchEmbed } from "@meowdown/core";
|
|
8
4
|
import { clamp } from "@ocavue/utils";
|
|
9
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { codeBlockLanguages, defaultResolveImageUrl, defineBulletAfterHeading, defineEditorExtension, defineEmbedPaste, defineExitBoundaryHandler, defineHTMLPaste, defineImage, defineImageClickHandler, defineLinkClickHandler, defineLinkEditKeymap, defineLinkHoverHandler, defineMarkMode, defineMarkdownCopy, definePlaceholder, defineReadonly, defineTagClickHandler, defineWikilinkClickHandler, defineWikilinkTrigger, docToMarkdown, getCodeTokens, getMarkBuilders, getVirtualElementFromRange, inlineTextToMarkChunks, listenForTweetHeight, markdownToDoc, matchEmbed } from "@meowdown/core";
|
|
11
5
|
import { canUseRegexLookbehind, createEditor, defineDocChangeHandler, union } from "@prosekit/core";
|
|
12
6
|
import { Selection, TextSelection } from "@prosekit/pm/state";
|
|
13
7
|
import { ProseKit, defineReactNodeView, useEditor, useEditor as useEditor$1, useEditorDerivedValue, useExtension, useExtension as useExtension$1, useKeymap } from "@prosekit/react";
|
|
14
8
|
import { Combobox } from "@base-ui/react/combobox";
|
|
15
9
|
import { CheckIcon, ChevronsUpDownIcon, CopyIcon, GripHorizontalIcon, GripVerticalIcon, PencilIcon, UnlinkIcon } from "lucide-react";
|
|
10
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
16
11
|
import { BlockHandleDraggable, BlockHandlePopup, BlockHandlePositioner, BlockHandleRoot } from "@prosekit/react/block-handle";
|
|
17
12
|
import { DropIndicator } from "@prosekit/react/drop-indicator";
|
|
18
13
|
import { Popover } from "@base-ui/react/popover";
|
|
@@ -21,122 +16,6 @@ import { MenuItem, MenuPopup, MenuPositioner } from "@prosekit/react/menu";
|
|
|
21
16
|
import { TableHandleColumnMenuRoot, TableHandleColumnMenuTrigger, TableHandleColumnPopup, TableHandleColumnPositioner, TableHandleDragPreview, TableHandleDropIndicator, TableHandleRoot, TableHandleRowMenuRoot, TableHandleRowMenuTrigger, TableHandleRowPopup, TableHandleRowPositioner } from "@prosekit/react/table-handle";
|
|
22
17
|
import { Mark } from "@prosekit/pm/model";
|
|
23
18
|
|
|
24
|
-
//#region src/components/codemirror-editor.tsx
|
|
25
|
-
function resolveSelection$1(selection, docLength) {
|
|
26
|
-
if (selection === "start") return EditorSelection.single(0);
|
|
27
|
-
if (selection === "end") return EditorSelection.single(docLength);
|
|
28
|
-
return EditorSelection.single(clamp(selection.anchor, 0, docLength), clamp(selection.head, 0, docLength));
|
|
29
|
-
}
|
|
30
|
-
function CodeMirrorEditor({ initialMarkdown, onDocChange, readOnly, ref }) {
|
|
31
|
-
const containerRef = useRef(null);
|
|
32
|
-
const viewRef = useRef(null);
|
|
33
|
-
const readOnlyCompartmentRef = useRef(new Compartment());
|
|
34
|
-
const suppressDocChangeRef = useRef(false);
|
|
35
|
-
const onDocChangeRef = useRef(onDocChange);
|
|
36
|
-
useLayoutEffect(() => {
|
|
37
|
-
onDocChangeRef.current = onDocChange;
|
|
38
|
-
}, [onDocChange]);
|
|
39
|
-
const initialMarkdownRef = useRef(initialMarkdown ?? "");
|
|
40
|
-
const initialReadOnlyRef = useRef(readOnly ?? false);
|
|
41
|
-
useImperativeHandle(ref, () => {
|
|
42
|
-
function getMarkdown() {
|
|
43
|
-
return viewRef.current?.state.doc.toString() ?? initialMarkdownRef.current;
|
|
44
|
-
}
|
|
45
|
-
function getSelection() {
|
|
46
|
-
const main = viewRef.current?.state.selection.main;
|
|
47
|
-
return {
|
|
48
|
-
type: "text",
|
|
49
|
-
anchor: main?.anchor ?? 0,
|
|
50
|
-
head: main?.head ?? 0
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function getState() {
|
|
54
|
-
return [getMarkdown(), getSelection()];
|
|
55
|
-
}
|
|
56
|
-
function setState(markdown, selection) {
|
|
57
|
-
const view = viewRef.current;
|
|
58
|
-
if (!view) {
|
|
59
|
-
if (markdown != null) initialMarkdownRef.current = markdown;
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (markdown == null && !selection) return;
|
|
63
|
-
const docLength = markdown == null ? view.state.doc.length : markdown.length;
|
|
64
|
-
suppressDocChangeRef.current = true;
|
|
65
|
-
try {
|
|
66
|
-
view.dispatch({
|
|
67
|
-
changes: markdown == null ? void 0 : {
|
|
68
|
-
from: 0,
|
|
69
|
-
to: view.state.doc.length,
|
|
70
|
-
insert: markdown
|
|
71
|
-
},
|
|
72
|
-
selection: selection ? resolveSelection$1(selection, docLength) : void 0,
|
|
73
|
-
scrollIntoView: true
|
|
74
|
-
});
|
|
75
|
-
} finally {
|
|
76
|
-
suppressDocChangeRef.current = false;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function setMarkdown(markdown) {
|
|
80
|
-
setState(markdown);
|
|
81
|
-
}
|
|
82
|
-
function setSelection(selection) {
|
|
83
|
-
setState(void 0, selection);
|
|
84
|
-
}
|
|
85
|
-
function focus() {
|
|
86
|
-
viewRef.current?.focus();
|
|
87
|
-
}
|
|
88
|
-
function scrollIntoView() {
|
|
89
|
-
viewRef.current?.dispatch({ scrollIntoView: true });
|
|
90
|
-
}
|
|
91
|
-
return {
|
|
92
|
-
getMarkdown,
|
|
93
|
-
setMarkdown,
|
|
94
|
-
getState,
|
|
95
|
-
setState,
|
|
96
|
-
getSelection,
|
|
97
|
-
setSelection,
|
|
98
|
-
focus,
|
|
99
|
-
scrollIntoView,
|
|
100
|
-
editor: void 0
|
|
101
|
-
};
|
|
102
|
-
}, []);
|
|
103
|
-
useLayoutEffect(() => {
|
|
104
|
-
const container = containerRef.current;
|
|
105
|
-
if (!container) return;
|
|
106
|
-
const view = new EditorView({
|
|
107
|
-
parent: container,
|
|
108
|
-
state: EditorState.create({
|
|
109
|
-
doc: initialMarkdownRef.current,
|
|
110
|
-
extensions: [
|
|
111
|
-
history(),
|
|
112
|
-
keymap.of([...defaultKeymap, ...historyKeymap]),
|
|
113
|
-
markdown({ base: markdownLanguage }),
|
|
114
|
-
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
|
|
115
|
-
EditorView.lineWrapping,
|
|
116
|
-
readOnlyCompartmentRef.current.of(EditorState.readOnly.of(initialReadOnlyRef.current)),
|
|
117
|
-
EditorView.updateListener.of((update) => {
|
|
118
|
-
if (!update.docChanged || suppressDocChangeRef.current) return;
|
|
119
|
-
onDocChangeRef.current?.();
|
|
120
|
-
})
|
|
121
|
-
]
|
|
122
|
-
})
|
|
123
|
-
});
|
|
124
|
-
viewRef.current = view;
|
|
125
|
-
return () => {
|
|
126
|
-
view.destroy();
|
|
127
|
-
viewRef.current = null;
|
|
128
|
-
};
|
|
129
|
-
}, []);
|
|
130
|
-
useLayoutEffect(() => {
|
|
131
|
-
viewRef.current?.dispatch({ effects: readOnlyCompartmentRef.current.reconfigure(EditorState.readOnly.of(readOnly ?? false)) });
|
|
132
|
-
}, [readOnly]);
|
|
133
|
-
return /* @__PURE__ */ jsx("div", {
|
|
134
|
-
ref: containerRef,
|
|
135
|
-
"data-editor": "codemirror"
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
//#endregion
|
|
140
19
|
//#region src/components/code-block-view.module.css
|
|
141
20
|
var code_block_view_module_default = {
|
|
142
21
|
"CopyButton": "meow_CopyButton_D3j_9q",
|
|
@@ -693,8 +572,12 @@ function SlashMenuItem({ label, kbd, onSelect }) {
|
|
|
693
572
|
children: [/* @__PURE__ */ jsx("span", { children: label }), kbd && /* @__PURE__ */ jsx("kbd", { children: kbd })]
|
|
694
573
|
});
|
|
695
574
|
}
|
|
575
|
+
function selectionInTableCell(editor) {
|
|
576
|
+
return isSelectionInTableCell(editor.state);
|
|
577
|
+
}
|
|
696
578
|
function SlashMenu({ timeFormat = "12" }) {
|
|
697
579
|
const editor = useEditor$1();
|
|
580
|
+
const inTableCell = useEditorDerivedValue(selectionInTableCell);
|
|
698
581
|
return /* @__PURE__ */ jsx(AutocompleteRoot, {
|
|
699
582
|
regex: regex$2,
|
|
700
583
|
children: /* @__PURE__ */ jsx(AutocompletePositioner, {
|
|
@@ -703,64 +586,66 @@ function SlashMenu({ timeFormat = "12" }) {
|
|
|
703
586
|
className: autocomplete_menu_module_default.Popup,
|
|
704
587
|
"data-testid": "slash-menu",
|
|
705
588
|
children: [
|
|
706
|
-
/* @__PURE__ */
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
589
|
+
!inTableCell && /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
590
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
591
|
+
label: "Heading 1",
|
|
592
|
+
kbd: "#",
|
|
593
|
+
onSelect: () => editor.commands.setHeading({ level: 1 })
|
|
594
|
+
}),
|
|
595
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
596
|
+
label: "Heading 2",
|
|
597
|
+
kbd: "##",
|
|
598
|
+
onSelect: () => editor.commands.setHeading({ level: 2 })
|
|
599
|
+
}),
|
|
600
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
601
|
+
label: "Heading 3",
|
|
602
|
+
kbd: "###",
|
|
603
|
+
onSelect: () => editor.commands.setHeading({ level: 3 })
|
|
604
|
+
}),
|
|
605
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
606
|
+
label: "Heading 4",
|
|
607
|
+
kbd: "####",
|
|
608
|
+
onSelect: () => editor.commands.setHeading({ level: 4 })
|
|
609
|
+
}),
|
|
610
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
611
|
+
label: "Blockquote",
|
|
612
|
+
kbd: ">",
|
|
613
|
+
onSelect: () => editor.commands.setBlockquote()
|
|
614
|
+
}),
|
|
615
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
616
|
+
label: "Bullet list",
|
|
617
|
+
kbd: "-",
|
|
618
|
+
onSelect: () => editor.commands.wrapInList({ kind: "bullet" })
|
|
619
|
+
}),
|
|
620
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
621
|
+
label: "Ordered list",
|
|
622
|
+
kbd: "1.",
|
|
623
|
+
onSelect: () => editor.commands.wrapInList({ kind: "ordered" })
|
|
624
|
+
}),
|
|
625
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
626
|
+
label: "Task list",
|
|
627
|
+
kbd: "+ [ ] ",
|
|
628
|
+
onSelect: () => editor.commands.wrapInCircleTask()
|
|
629
|
+
}),
|
|
630
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
631
|
+
label: "Checkbox list",
|
|
632
|
+
kbd: "- [ ] ",
|
|
633
|
+
onSelect: () => editor.commands.wrapInSquareTask()
|
|
634
|
+
}),
|
|
635
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
636
|
+
label: "Code block",
|
|
637
|
+
kbd: "```",
|
|
638
|
+
onSelect: () => editor.commands.setCodeBlock()
|
|
639
|
+
}),
|
|
640
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
641
|
+
label: "Table",
|
|
642
|
+
onSelect: () => editor.commands.insertTable({
|
|
643
|
+
row: 3,
|
|
644
|
+
col: 3,
|
|
645
|
+
header: true
|
|
646
|
+
})
|
|
762
647
|
})
|
|
763
|
-
}),
|
|
648
|
+
] }),
|
|
764
649
|
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
765
650
|
label: "Now",
|
|
766
651
|
onSelect: () => editor.commands.insertText({ text: formatNowTime(timeFormat) })
|
|
@@ -1241,18 +1126,12 @@ function MeowdownEditor({ mode = "focus", initialMarkdown, onDocChange, onTagSea
|
|
|
1241
1126
|
}
|
|
1242
1127
|
};
|
|
1243
1128
|
}, []);
|
|
1244
|
-
const seedMarkdown = childRef.current?.getMarkdown() ?? initialMarkdown ?? "";
|
|
1245
1129
|
return /* @__PURE__ */ jsx("div", {
|
|
1246
1130
|
className: clsx("meowdown", wrapperClassName),
|
|
1247
|
-
children:
|
|
1248
|
-
ref: childRef,
|
|
1249
|
-
initialMarkdown: seedMarkdown,
|
|
1250
|
-
onDocChange,
|
|
1251
|
-
readOnly
|
|
1252
|
-
}) : /* @__PURE__ */ jsx(ProseKitEditor, {
|
|
1131
|
+
children: /* @__PURE__ */ jsx(ProseKitEditor, {
|
|
1253
1132
|
ref: childRef,
|
|
1254
1133
|
markMode: mode,
|
|
1255
|
-
initialMarkdown
|
|
1134
|
+
initialMarkdown,
|
|
1256
1135
|
onDocChange,
|
|
1257
1136
|
onTagSearch,
|
|
1258
1137
|
onWikilinkSearch,
|
package/dist/style.css
CHANGED
|
@@ -567,24 +567,4 @@
|
|
|
567
567
|
& .ProseMirror {
|
|
568
568
|
flex: 1 0 auto;
|
|
569
569
|
}
|
|
570
|
-
|
|
571
|
-
& [data-editor="codemirror"] {
|
|
572
|
-
flex: 1 0 auto;
|
|
573
|
-
display: flex;
|
|
574
|
-
|
|
575
|
-
& .cm-editor {
|
|
576
|
-
flex: 1;
|
|
577
|
-
font-size: .95rem;
|
|
578
|
-
|
|
579
|
-
&.cm-focused {
|
|
580
|
-
outline: none;
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
& .cm-content {
|
|
585
|
-
padding: 1.25rem var(--meowdown-gutter) 1.75rem;
|
|
586
|
-
font-family: var(--meowdown-font-mono);
|
|
587
|
-
caret-color: var(--meowdown-accent);
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
570
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meowdown/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.29.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -19,18 +19,13 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@base-ui/react": "^1.6.0",
|
|
22
|
-
"@codemirror/commands": "^6.10.4",
|
|
23
|
-
"@codemirror/lang-markdown": "^6.5.0",
|
|
24
|
-
"@codemirror/language": "^6.12.3",
|
|
25
|
-
"@codemirror/state": "^6.7.0",
|
|
26
|
-
"@codemirror/view": "^6.43.1",
|
|
27
22
|
"@ocavue/utils": "^1.7.0",
|
|
28
23
|
"@prosekit/core": "^0.13.0-beta.3",
|
|
29
24
|
"@prosekit/pm": "^0.1.19-beta.0",
|
|
30
25
|
"@prosekit/react": "^0.8.0-beta.11",
|
|
31
26
|
"clsx": "^2.1.1",
|
|
32
27
|
"lucide-react": "^1.21.0",
|
|
33
|
-
"@meowdown/core": "0.
|
|
28
|
+
"@meowdown/core": "0.29.0"
|
|
34
29
|
},
|
|
35
30
|
"peerDependencies": {
|
|
36
31
|
"react": "^19.0.0",
|