@meowdown/react 0.25.0 → 0.26.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 +10 -1
- package/dist/index.js +26 -4
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ import { ExitBoundaryHandler, ImageClickHandler, ImageOptions, LinkClickHandler,
|
|
|
3
3
|
import { SelectionJSON, SelectionJSON as SelectionJSON$1 } from "@prosekit/core";
|
|
4
4
|
import { useEditor, useExtension, useKeymap } from "@prosekit/react";
|
|
5
5
|
|
|
6
|
+
//#region src/utils/date-format.d.ts
|
|
7
|
+
type TimeFormat = '12' | '24';
|
|
8
|
+
//#endregion
|
|
6
9
|
//#region src/components/types.d.ts
|
|
7
10
|
/** A selection to restore: an exact JSON selection, or a document edge. */
|
|
8
11
|
type SelectionHint = SelectionJSON$1 | 'start' | 'end';
|
|
@@ -198,6 +201,11 @@ interface EditorProps {
|
|
|
198
201
|
* to the browser's behavior. Ignored in source mode.
|
|
199
202
|
*/
|
|
200
203
|
spellCheck?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Clock format the `/now` slash command inserts: '12' for "3:45pm" or '24'
|
|
206
|
+
* for "15:45". Defaults to '12'. Ignored in source mode.
|
|
207
|
+
*/
|
|
208
|
+
timeFormat?: TimeFormat;
|
|
201
209
|
/** Class on the editable root (the contenteditable). Rich modes only. */
|
|
202
210
|
editorClassName?: string;
|
|
203
211
|
/** Class on the outer `.meowdown` wrapper div. */
|
|
@@ -229,6 +237,7 @@ declare function MeowdownEditor({
|
|
|
229
237
|
placeholder,
|
|
230
238
|
readOnly,
|
|
231
239
|
spellCheck,
|
|
240
|
+
timeFormat,
|
|
232
241
|
editorClassName,
|
|
233
242
|
wrapperClassName,
|
|
234
243
|
handleRef,
|
|
@@ -276,4 +285,4 @@ declare function MarkdownView({
|
|
|
276
285
|
className
|
|
277
286
|
}: MarkdownViewProps): ReactElement;
|
|
278
287
|
//#endregion
|
|
279
|
-
export { type EditorHandle, type EditorMode, type EditorProps, type EditorStateSnapshot, MarkdownView, type MarkdownViewProps, MeowdownEditor, type SelectionHint, type SelectionJSON, type TagItem, type TagSearchHandler, type WikilinkItem, type WikilinkSearchHandler, useEditor, useExtension, useKeymap };
|
|
288
|
+
export { type EditorHandle, type EditorMode, type EditorProps, type EditorStateSnapshot, MarkdownView, type MarkdownViewProps, MeowdownEditor, type SelectionHint, type SelectionJSON, type TagItem, type TagSearchHandler, type TimeFormat, type WikilinkItem, type WikilinkSearchHandler, useEditor, useExtension, useKeymap };
|
package/dist/index.js
CHANGED
|
@@ -656,6 +656,23 @@ function LinkMenu({ onLinkClick, onLinkCopy }) {
|
|
|
656
656
|
return null;
|
|
657
657
|
}
|
|
658
658
|
|
|
659
|
+
//#endregion
|
|
660
|
+
//#region src/utils/date-format.ts
|
|
661
|
+
/** Formats the current wall-clock time for the `/now` slash command. */
|
|
662
|
+
function formatNowTime(timeFormat) {
|
|
663
|
+
return formatTime(/* @__PURE__ */ new Date(), timeFormat);
|
|
664
|
+
}
|
|
665
|
+
/** Formats a given time as `3:45pm` ('12') or `15:45` ('24'). */
|
|
666
|
+
function formatTime(date, timeFormat) {
|
|
667
|
+
return timeFormat === "12" ? formatTime12(date) : formatTime24(date);
|
|
668
|
+
}
|
|
669
|
+
function formatTime12(date) {
|
|
670
|
+
return `${date.getHours() % 12 || 12}:${date.getMinutes().toString().padStart(2, "0")}${date.getHours() >= 12 ? "pm" : "am"}`;
|
|
671
|
+
}
|
|
672
|
+
function formatTime24(date) {
|
|
673
|
+
return `${date.getHours().toString().padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")}`;
|
|
674
|
+
}
|
|
675
|
+
|
|
659
676
|
//#endregion
|
|
660
677
|
//#region src/components/autocomplete-menu.module.css
|
|
661
678
|
var autocomplete_menu_module_default = {
|
|
@@ -676,7 +693,7 @@ function SlashMenuItem({ label, kbd, onSelect }) {
|
|
|
676
693
|
children: [/* @__PURE__ */ jsx("span", { children: label }), kbd && /* @__PURE__ */ jsx("kbd", { children: kbd })]
|
|
677
694
|
});
|
|
678
695
|
}
|
|
679
|
-
function SlashMenu() {
|
|
696
|
+
function SlashMenu({ timeFormat = "12" }) {
|
|
680
697
|
const editor = useEditor$1();
|
|
681
698
|
return /* @__PURE__ */ jsx(AutocompleteRoot, {
|
|
682
699
|
regex: regex$2,
|
|
@@ -744,6 +761,10 @@ function SlashMenu() {
|
|
|
744
761
|
header: true
|
|
745
762
|
})
|
|
746
763
|
}),
|
|
764
|
+
/* @__PURE__ */ jsx(SlashMenuItem, {
|
|
765
|
+
label: "Now",
|
|
766
|
+
onSelect: () => editor.commands.insertText({ text: formatNowTime(timeFormat) })
|
|
767
|
+
}),
|
|
747
768
|
/* @__PURE__ */ jsx(AutocompleteEmpty, {
|
|
748
769
|
className: autocomplete_menu_module_default.Item,
|
|
749
770
|
children: "No results"
|
|
@@ -1060,7 +1081,7 @@ function resolveSelection(doc, selection) {
|
|
|
1060
1081
|
return TextSelection.between(doc.resolve(anchor), doc.resolve(head));
|
|
1061
1082
|
}
|
|
1062
1083
|
}
|
|
1063
|
-
function ProseKitEditor({ markMode = "focus", initialMarkdown, onDocChange, onTagSearch, onWikilinkSearch, onWikilinkClick, onLinkClick, onLinkCopy, onTagClick, onExitBoundary, resolveImageUrl, onImagePaste, onImageSaveError, onImageClick, embedPaste, bulletAfterHeading, frontmatter = false, blockHandle = true, placeholder, readOnly, spellCheck, editorClassName, ref, children }) {
|
|
1084
|
+
function ProseKitEditor({ markMode = "focus", initialMarkdown, onDocChange, onTagSearch, onWikilinkSearch, onWikilinkClick, onLinkClick, onLinkCopy, onTagClick, onExitBoundary, resolveImageUrl, onImagePaste, onImageSaveError, onImageClick, embedPaste, bulletAfterHeading, frontmatter = false, blockHandle = true, placeholder, readOnly, spellCheck, timeFormat, editorClassName, ref, children }) {
|
|
1064
1085
|
const [editor] = useState(() => {
|
|
1065
1086
|
const editor = createEditor({ extension: union(defineEditorExtension(), defineCodeBlockView()) });
|
|
1066
1087
|
if (initialMarkdown) editor.setContent(markdownToDoc(initialMarkdown, {
|
|
@@ -1157,7 +1178,7 @@ function ProseKitEditor({ markMode = "focus", initialMarkdown, onDocChange, onTa
|
|
|
1157
1178
|
blockHandle && !readOnly && /* @__PURE__ */ jsx(BlockHandle, {}),
|
|
1158
1179
|
!readOnly && /* @__PURE__ */ jsx(TableHandle, {}),
|
|
1159
1180
|
blockHandle && !readOnly && /* @__PURE__ */ jsx(DropIndicator$1, {}),
|
|
1160
|
-
/* @__PURE__ */ jsx(SlashMenu, {}),
|
|
1181
|
+
/* @__PURE__ */ jsx(SlashMenu, { timeFormat }),
|
|
1161
1182
|
!readOnly && /* @__PURE__ */ jsx(LinkMenu, {
|
|
1162
1183
|
onLinkClick,
|
|
1163
1184
|
onLinkCopy
|
|
@@ -1171,7 +1192,7 @@ function ProseKitEditor({ markMode = "focus", initialMarkdown, onDocChange, onTa
|
|
|
1171
1192
|
|
|
1172
1193
|
//#endregion
|
|
1173
1194
|
//#region src/components/editor.tsx
|
|
1174
|
-
function MeowdownEditor({ mode = "focus", initialMarkdown, onDocChange, onTagSearch, onWikilinkSearch, onWikilinkClick, onLinkClick, onLinkCopy, onTagClick, onExitBoundary, resolveImageUrl, onImagePaste, onImageSaveError, onImageClick, embedPaste = true, bulletAfterHeading = false, frontmatter = false, blockHandle = true, placeholder, readOnly, spellCheck, editorClassName, wrapperClassName, handleRef, children }) {
|
|
1195
|
+
function MeowdownEditor({ mode = "focus", initialMarkdown, onDocChange, onTagSearch, onWikilinkSearch, onWikilinkClick, onLinkClick, onLinkCopy, onTagClick, onExitBoundary, resolveImageUrl, onImagePaste, onImageSaveError, onImageClick, embedPaste = true, bulletAfterHeading = false, frontmatter = false, blockHandle = true, placeholder, readOnly, spellCheck, timeFormat, editorClassName, wrapperClassName, handleRef, children }) {
|
|
1175
1196
|
const childRef = useRef(null);
|
|
1176
1197
|
useImperativeHandle(handleRef, () => {
|
|
1177
1198
|
function getMarkdown() {
|
|
@@ -1251,6 +1272,7 @@ function MeowdownEditor({ mode = "focus", initialMarkdown, onDocChange, onTagSea
|
|
|
1251
1272
|
placeholder,
|
|
1252
1273
|
readOnly,
|
|
1253
1274
|
spellCheck,
|
|
1275
|
+
timeFormat,
|
|
1254
1276
|
editorClassName,
|
|
1255
1277
|
children
|
|
1256
1278
|
})
|
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.26.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@prosekit/react": "^0.8.0-beta.11",
|
|
31
31
|
"clsx": "^2.1.1",
|
|
32
32
|
"lucide-react": "^1.21.0",
|
|
33
|
-
"@meowdown/core": "0.
|
|
33
|
+
"@meowdown/core": "0.26.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"react": "^19.0.0",
|