notra-editor 0.8.1 → 0.8.2
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/components/blockquote-button/blockquote-button.cjs +5 -3
- package/dist/components/blockquote-button/blockquote-button.cjs.map +1 -1
- package/dist/components/blockquote-button/blockquote-button.mjs +5 -3
- package/dist/components/blockquote-button/blockquote-button.mjs.map +1 -1
- package/dist/components/code-block-button/code-block-button.cjs +5 -3
- package/dist/components/code-block-button/code-block-button.cjs.map +1 -1
- package/dist/components/code-block-button/code-block-button.mjs +5 -3
- package/dist/components/code-block-button/code-block-button.mjs.map +1 -1
- package/dist/components/code-block-view/code-block-shell.cjs +4 -2
- package/dist/components/code-block-view/code-block-shell.cjs.map +1 -1
- package/dist/components/code-block-view/code-block-shell.mjs +3 -2
- package/dist/components/code-block-view/code-block-shell.mjs.map +1 -1
- package/dist/components/code-block-view/code-block-view.cjs +6 -4
- package/dist/components/code-block-view/code-block-view.cjs.map +1 -1
- package/dist/components/code-block-view/code-block-view.mjs +6 -4
- package/dist/components/code-block-view/code-block-view.mjs.map +1 -1
- package/dist/components/code-block-view/language-select.cjs +9 -7
- package/dist/components/code-block-view/language-select.cjs.map +1 -1
- package/dist/components/code-block-view/language-select.mjs +9 -7
- package/dist/components/code-block-view/language-select.mjs.map +1 -1
- package/dist/components/copy-button.cjs +6 -4
- package/dist/components/copy-button.cjs.map +1 -1
- package/dist/components/copy-button.mjs +6 -4
- package/dist/components/copy-button.mjs.map +1 -1
- package/dist/components/heading-dropdown-menu/heading-dropdown-menu.cjs +8 -6
- package/dist/components/heading-dropdown-menu/heading-dropdown-menu.cjs.map +1 -1
- package/dist/components/heading-dropdown-menu/heading-dropdown-menu.mjs +8 -6
- package/dist/components/heading-dropdown-menu/heading-dropdown-menu.mjs.map +1 -1
- package/dist/components/heading-dropdown-menu/heading-menu-item.cjs +6 -4
- package/dist/components/heading-dropdown-menu/heading-menu-item.cjs.map +1 -1
- package/dist/components/heading-dropdown-menu/heading-menu-item.mjs +5 -4
- package/dist/components/heading-dropdown-menu/heading-menu-item.mjs.map +1 -1
- package/dist/components/heading-dropdown-menu/use-heading.cjs +4 -2
- package/dist/components/heading-dropdown-menu/use-heading.cjs.map +1 -1
- package/dist/components/heading-dropdown-menu/use-heading.mjs +3 -2
- package/dist/components/heading-dropdown-menu/use-heading.mjs.map +1 -1
- package/dist/components/image-popover/image-input-form.cjs +127 -0
- package/dist/components/image-popover/image-input-form.cjs.map +1 -0
- package/dist/components/image-popover/image-input-form.d.cts +16 -0
- package/dist/components/image-popover/image-input-form.d.ts +16 -0
- package/dist/components/image-popover/image-input-form.mjs +103 -0
- package/dist/components/image-popover/image-input-form.mjs.map +1 -0
- package/dist/components/image-popover/image-popover.cjs +35 -92
- package/dist/components/image-popover/image-popover.cjs.map +1 -1
- package/dist/components/image-popover/image-popover.mjs +36 -93
- package/dist/components/image-popover/image-popover.mjs.map +1 -1
- package/dist/components/image-popover/use-image-popover.cjs +2 -0
- package/dist/components/image-popover/use-image-popover.cjs.map +1 -1
- package/dist/components/image-popover/use-image-popover.mjs +1 -0
- package/dist/components/image-popover/use-image-popover.mjs.map +1 -1
- package/dist/components/link-popover/link-popover.cjs +9 -7
- package/dist/components/link-popover/link-popover.cjs.map +1 -1
- package/dist/components/link-popover/link-popover.mjs +9 -7
- package/dist/components/link-popover/link-popover.mjs.map +1 -1
- package/dist/components/link-popover/use-link-popover.cjs +2 -0
- package/dist/components/link-popover/use-link-popover.cjs.map +1 -1
- package/dist/components/link-popover/use-link-popover.mjs +1 -0
- package/dist/components/link-popover/use-link-popover.mjs.map +1 -1
- package/dist/components/list-dropdown-menu/list-dropdown-menu.cjs +8 -6
- package/dist/components/list-dropdown-menu/list-dropdown-menu.cjs.map +1 -1
- package/dist/components/list-dropdown-menu/list-dropdown-menu.mjs +8 -6
- package/dist/components/list-dropdown-menu/list-dropdown-menu.mjs.map +1 -1
- package/dist/components/list-dropdown-menu/list-menu-item.cjs +6 -4
- package/dist/components/list-dropdown-menu/list-menu-item.cjs.map +1 -1
- package/dist/components/list-dropdown-menu/list-menu-item.mjs +5 -4
- package/dist/components/list-dropdown-menu/list-menu-item.mjs.map +1 -1
- package/dist/components/list-dropdown-menu/use-list.cjs +5 -3
- package/dist/components/list-dropdown-menu/use-list.cjs.map +1 -1
- package/dist/components/list-dropdown-menu/use-list.mjs +4 -3
- package/dist/components/list-dropdown-menu/use-list.mjs.map +1 -1
- package/dist/components/mark-button/mark-button.cjs +6 -4
- package/dist/components/mark-button/mark-button.cjs.map +1 -1
- package/dist/components/mark-button/mark-button.mjs +6 -4
- package/dist/components/mark-button/mark-button.mjs.map +1 -1
- package/dist/components/mark-button/use-mark.cjs +4 -2
- package/dist/components/mark-button/use-mark.cjs.map +1 -1
- package/dist/components/mark-button/use-mark.mjs +3 -2
- package/dist/components/mark-button/use-mark.mjs.map +1 -1
- package/dist/components/slash-dropdown-menu/slash-dropdown-menu.cjs +151 -0
- package/dist/components/slash-dropdown-menu/slash-dropdown-menu.cjs.map +1 -0
- package/dist/components/slash-dropdown-menu/slash-dropdown-menu.d.cts +9 -0
- package/dist/components/slash-dropdown-menu/slash-dropdown-menu.d.ts +9 -0
- package/dist/components/slash-dropdown-menu/slash-dropdown-menu.mjs +127 -0
- package/dist/components/slash-dropdown-menu/slash-dropdown-menu.mjs.map +1 -0
- package/dist/components/slash-dropdown-menu/slash-image-popover.cjs +80 -0
- package/dist/components/slash-dropdown-menu/slash-image-popover.cjs.map +1 -0
- package/dist/components/slash-dropdown-menu/slash-image-popover.d.cts +11 -0
- package/dist/components/slash-dropdown-menu/slash-image-popover.d.ts +11 -0
- package/dist/components/slash-dropdown-menu/slash-image-popover.mjs +56 -0
- package/dist/components/slash-dropdown-menu/slash-image-popover.mjs.map +1 -0
- package/dist/components/slash-dropdown-menu/use-slash-items.cjs +138 -0
- package/dist/components/slash-dropdown-menu/use-slash-items.cjs.map +1 -0
- package/dist/components/slash-dropdown-menu/use-slash-items.d.cts +11 -0
- package/dist/components/slash-dropdown-menu/use-slash-items.d.ts +11 -0
- package/dist/components/slash-dropdown-menu/use-slash-items.mjs +125 -0
- package/dist/components/slash-dropdown-menu/use-slash-items.mjs.map +1 -0
- package/dist/components/suggestion-menu/filter-suggestion-items.cjs +57 -0
- package/dist/components/suggestion-menu/filter-suggestion-items.cjs.map +1 -0
- package/dist/components/suggestion-menu/filter-suggestion-items.d.cts +6 -0
- package/dist/components/suggestion-menu/filter-suggestion-items.d.ts +6 -0
- package/dist/components/suggestion-menu/filter-suggestion-items.mjs +32 -0
- package/dist/components/suggestion-menu/filter-suggestion-items.mjs.map +1 -0
- package/dist/components/suggestion-menu/suggestion-menu-types.cjs +19 -0
- package/dist/components/suggestion-menu/suggestion-menu-types.cjs.map +1 -0
- package/dist/components/suggestion-menu/suggestion-menu-types.d.cts +22 -0
- package/dist/components/suggestion-menu/suggestion-menu-types.d.ts +22 -0
- package/dist/components/suggestion-menu/suggestion-menu-types.mjs +1 -0
- package/dist/components/suggestion-menu/suggestion-menu-types.mjs.map +1 -0
- package/dist/components/suggestion-menu/suggestion-menu.cjs +205 -0
- package/dist/components/suggestion-menu/suggestion-menu.cjs.map +1 -0
- package/dist/components/suggestion-menu/suggestion-menu.d.cts +27 -0
- package/dist/components/suggestion-menu/suggestion-menu.d.ts +27 -0
- package/dist/components/suggestion-menu/suggestion-menu.mjs +181 -0
- package/dist/components/suggestion-menu/suggestion-menu.mjs.map +1 -0
- package/dist/components/toolbar/toolbar.cjs +4 -2
- package/dist/components/toolbar/toolbar.cjs.map +1 -1
- package/dist/components/toolbar/toolbar.mjs +3 -2
- package/dist/components/toolbar/toolbar.mjs.map +1 -1
- package/dist/components/ui/button.cjs +5 -3
- package/dist/components/ui/button.cjs.map +1 -1
- package/dist/components/ui/button.mjs +4 -3
- package/dist/components/ui/button.mjs.map +1 -1
- package/dist/components/ui/command.cjs +6 -5
- package/dist/components/ui/command.cjs.map +1 -1
- package/dist/components/ui/command.mjs +5 -5
- package/dist/components/ui/command.mjs.map +1 -1
- package/dist/components/ui/dialog.cjs +5 -4
- package/dist/components/ui/dialog.cjs.map +1 -1
- package/dist/components/ui/dialog.mjs +4 -4
- package/dist/components/ui/dialog.mjs.map +1 -1
- package/dist/components/ui/dropdown-menu.cjs +4 -3
- package/dist/components/ui/dropdown-menu.cjs.map +1 -1
- package/dist/components/ui/dropdown-menu.mjs +3 -3
- package/dist/components/ui/dropdown-menu.mjs.map +1 -1
- package/dist/components/ui/input-group.cjs +9 -7
- package/dist/components/ui/input-group.cjs.map +1 -1
- package/dist/components/ui/input-group.d.cts +1 -1
- package/dist/components/ui/input-group.d.ts +1 -1
- package/dist/components/ui/input-group.mjs +9 -7
- package/dist/components/ui/input-group.mjs.map +1 -1
- package/dist/components/ui/input.cjs +3 -1
- package/dist/components/ui/input.cjs.map +1 -1
- package/dist/components/ui/input.mjs +2 -1
- package/dist/components/ui/input.mjs.map +1 -1
- package/dist/components/ui/popover.cjs +4 -3
- package/dist/components/ui/popover.cjs.map +1 -1
- package/dist/components/ui/popover.mjs +3 -3
- package/dist/components/ui/popover.mjs.map +1 -1
- package/dist/components/ui/separator.cjs +4 -3
- package/dist/components/ui/separator.cjs.map +1 -1
- package/dist/components/ui/separator.mjs +3 -3
- package/dist/components/ui/separator.mjs.map +1 -1
- package/dist/components/ui/spacer.cjs +2 -0
- package/dist/components/ui/spacer.cjs.map +1 -1
- package/dist/components/ui/spacer.mjs +1 -0
- package/dist/components/ui/spacer.mjs.map +1 -1
- package/dist/components/ui/textarea.cjs +3 -1
- package/dist/components/ui/textarea.cjs.map +1 -1
- package/dist/components/ui/textarea.mjs +2 -1
- package/dist/components/ui/textarea.mjs.map +1 -1
- package/dist/components/undo-redo-button/undo-redo-button.cjs +6 -4
- package/dist/components/undo-redo-button/undo-redo-button.cjs.map +1 -1
- package/dist/components/undo-redo-button/undo-redo-button.mjs +6 -4
- package/dist/components/undo-redo-button/undo-redo-button.mjs.map +1 -1
- package/dist/components/undo-redo-button/use-undo-redo.cjs +4 -2
- package/dist/components/undo-redo-button/use-undo-redo.cjs.map +1 -1
- package/dist/components/undo-redo-button/use-undo-redo.mjs +3 -2
- package/dist/components/undo-redo-button/use-undo-redo.mjs.map +1 -1
- package/dist/extensions/code-block.cjs +8 -6
- package/dist/extensions/code-block.cjs.map +1 -1
- package/dist/extensions/code-block.mjs +7 -6
- package/dist/extensions/code-block.mjs.map +1 -1
- package/dist/extensions/editor.cjs +5 -3
- package/dist/extensions/editor.cjs.map +1 -1
- package/dist/extensions/editor.mjs +4 -3
- package/dist/extensions/editor.mjs.map +1 -1
- package/dist/extensions/index.cjs +4 -2
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.mjs +3 -2
- package/dist/extensions/index.mjs.map +1 -1
- package/dist/extensions/shared.cjs +5 -3
- package/dist/extensions/shared.cjs.map +1 -1
- package/dist/extensions/shared.mjs +4 -3
- package/dist/extensions/shared.mjs.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.cjs +3 -2
- package/dist/hooks/use-copy-to-clipboard.cjs.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.mjs +2 -2
- package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -1
- package/dist/hooks/use-floating-element.cjs +55 -0
- package/dist/hooks/use-floating-element.cjs.map +1 -0
- package/dist/hooks/use-floating-element.d.cts +21 -0
- package/dist/hooks/use-floating-element.d.ts +21 -0
- package/dist/hooks/use-floating-element.mjs +35 -0
- package/dist/hooks/use-floating-element.mjs.map +1 -0
- package/dist/hooks/use-markdown-editor.cjs +6 -1
- package/dist/hooks/use-markdown-editor.cjs.map +1 -1
- package/dist/hooks/use-markdown-editor.d.cts +1 -1
- package/dist/hooks/use-markdown-editor.d.ts +1 -1
- package/dist/hooks/use-markdown-editor.mjs +5 -1
- package/dist/hooks/use-markdown-editor.mjs.map +1 -1
- package/dist/index.cjs +18 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +17 -16
- package/dist/index.mjs.map +1 -1
- package/dist/lib/highlight-code-to-html.cjs +2 -0
- package/dist/lib/highlight-code-to-html.cjs.map +1 -1
- package/dist/lib/highlight-code-to-html.mjs +1 -0
- package/dist/lib/highlight-code-to-html.mjs.map +1 -1
- package/dist/lib/languages.cjs +4 -2
- package/dist/lib/languages.cjs.map +1 -1
- package/dist/lib/languages.mjs +3 -2
- package/dist/lib/languages.mjs.map +1 -1
- package/dist/lib/utils.cjs +2 -0
- package/dist/lib/utils.cjs.map +1 -1
- package/dist/lib/utils.mjs +1 -0
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/notra-editor.cjs +17 -13
- package/dist/notra-editor.cjs.map +1 -1
- package/dist/notra-editor.mjs +17 -13
- package/dist/notra-editor.mjs.map +1 -1
- package/dist/notra-reader.cjs +9 -7
- package/dist/notra-reader.cjs.map +1 -1
- package/dist/notra-reader.mjs +8 -7
- package/dist/notra-reader.mjs.map +1 -1
- package/dist/styles/globals.css +3 -0
- package/dist/themes/default/editor.css +50 -0
- package/dist/utils/markdown-to-json.cjs +5 -3
- package/dist/utils/markdown-to-json.cjs.map +1 -1
- package/dist/utils/markdown-to-json.mjs +4 -3
- package/dist/utils/markdown-to-json.mjs.map +1 -1
- package/package.json +4 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/components/slash-dropdown-menu/slash-image-popover.tsx
|
|
22
|
+
var slash_image_popover_exports = {};
|
|
23
|
+
__export(slash_image_popover_exports, {
|
|
24
|
+
SlashImagePopover: () => SlashImagePopover
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(slash_image_popover_exports);
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_image_input_form = require("../image-popover/image-input-form.cjs");
|
|
29
|
+
var import_popover = require("../ui/popover.cjs");
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
function SlashImagePopover({
|
|
32
|
+
editor,
|
|
33
|
+
anchorRect,
|
|
34
|
+
onClose
|
|
35
|
+
}) {
|
|
36
|
+
const handleSubmit = (0, import_react.useCallback)(
|
|
37
|
+
({ url, alt }) => {
|
|
38
|
+
if (!url) {
|
|
39
|
+
onClose();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
editor.chain().focus().setImage({ src: url, alt: alt || void 0 }).run();
|
|
43
|
+
onClose();
|
|
44
|
+
},
|
|
45
|
+
[editor, onClose]
|
|
46
|
+
);
|
|
47
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
48
|
+
import_popover.Popover,
|
|
49
|
+
{
|
|
50
|
+
open: true,
|
|
51
|
+
onOpenChange: (next) => {
|
|
52
|
+
if (!next) onClose();
|
|
53
|
+
},
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popover.PopoverAnchor, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
56
|
+
"span",
|
|
57
|
+
{
|
|
58
|
+
ref: (node) => {
|
|
59
|
+
if (!node) return;
|
|
60
|
+
const { top, left, width, height } = anchorRect;
|
|
61
|
+
node.style.position = "fixed";
|
|
62
|
+
node.style.top = `${top}px`;
|
|
63
|
+
node.style.left = `${left}px`;
|
|
64
|
+
node.style.width = `${width || 1}px`;
|
|
65
|
+
node.style.height = `${height || 1}px`;
|
|
66
|
+
node.style.pointerEvents = "none";
|
|
67
|
+
},
|
|
68
|
+
"aria-hidden": true
|
|
69
|
+
}
|
|
70
|
+
) }),
|
|
71
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popover.PopoverContent, { align: "start", className: "nt:w-auto nt:p-0", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_image_input_form.ImageInputForm, { onCancel: onClose, onSubmit: handleSubmit }) })
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
SlashImagePopover
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=slash-image-popover.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/slash-dropdown-menu/slash-image-popover.tsx"],"sourcesContent":["'use client';\n\nimport { useCallback } from 'react';\n\nimport { ImageInputForm } from '../image-popover/image-input-form.js';\nimport { Popover, PopoverAnchor, PopoverContent } from '../ui/popover.js';\n\nimport type { Editor } from '@tiptap/core';\nimport type {} from '@tiptap/extension-image';\n\nexport interface SlashImagePopoverProps {\n\teditor: Editor;\n\tanchorRect: DOMRect;\n\tonClose: () => void;\n}\n\nexport function SlashImagePopover({\n\teditor,\n\tanchorRect,\n\tonClose\n}: SlashImagePopoverProps) {\n\tconst handleSubmit = useCallback(\n\t\t({ url, alt }: { url: string; alt: string }) => {\n\t\t\tif (!url) {\n\t\t\t\tonClose();\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\teditor\n\t\t\t\t.chain()\n\t\t\t\t.focus()\n\t\t\t\t.setImage({ src: url, alt: alt || undefined })\n\t\t\t\t.run();\n\t\t\tonClose();\n\t\t},\n\t\t[editor, onClose]\n\t);\n\n\treturn (\n\t\t<Popover\n\t\t\topen\n\t\t\tonOpenChange={(next) => {\n\t\t\t\tif (!next) onClose();\n\t\t\t}}\n\t\t>\n\t\t\t<PopoverAnchor asChild>\n\t\t\t\t<span\n\t\t\t\t\tref={(node) => {\n\t\t\t\t\t\tif (!node) return;\n\n\t\t\t\t\t\t// Pin the anchor element at the captured rect.\n\t\t\t\t\t\tconst { top, left, width, height } = anchorRect;\n\n\t\t\t\t\t\tnode.style.position = 'fixed';\n\t\t\t\t\t\tnode.style.top = `${top}px`;\n\t\t\t\t\t\tnode.style.left = `${left}px`;\n\t\t\t\t\t\tnode.style.width = `${width || 1}px`;\n\t\t\t\t\t\tnode.style.height = `${height || 1}px`;\n\t\t\t\t\t\tnode.style.pointerEvents = 'none';\n\t\t\t\t\t}}\n\t\t\t\t\taria-hidden\n\t\t\t\t/>\n\t\t\t</PopoverAnchor>\n\t\t\t<PopoverContent align=\"start\" className=\"nt:w-auto nt:p-0\">\n\t\t\t\t<ImageInputForm onCancel={onClose} onSubmit={handleSubmit} />\n\t\t\t</PopoverContent>\n\t\t</Popover>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA4B;AAE5B,8BAA+B;AAC/B,qBAAuD;AAmCrD;AAxBK,SAAS,kBAAkB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AACD,GAA2B;AAC1B,QAAM,mBAAe;AAAA,IACpB,CAAC,EAAE,KAAK,IAAI,MAAoC;AAC/C,UAAI,CAAC,KAAK;AACT,gBAAQ;AAER;AAAA,MACD;AAEA,aACE,MAAM,EACN,MAAM,EACN,SAAS,EAAE,KAAK,KAAK,KAAK,OAAO,OAAU,CAAC,EAC5C,IAAI;AACN,cAAQ;AAAA,IACT;AAAA,IACA,CAAC,QAAQ,OAAO;AAAA,EACjB;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAI;AAAA,MACJ,cAAc,CAAC,SAAS;AACvB,YAAI,CAAC,KAAM,SAAQ;AAAA,MACpB;AAAA,MAEA;AAAA,oDAAC,gCAAc,SAAO,MACrB;AAAA,UAAC;AAAA;AAAA,YACA,KAAK,CAAC,SAAS;AACd,kBAAI,CAAC,KAAM;AAGX,oBAAM,EAAE,KAAK,MAAM,OAAO,OAAO,IAAI;AAErC,mBAAK,MAAM,WAAW;AACtB,mBAAK,MAAM,MAAM,GAAG,GAAG;AACvB,mBAAK,MAAM,OAAO,GAAG,IAAI;AACzB,mBAAK,MAAM,QAAQ,GAAG,SAAS,CAAC;AAChC,mBAAK,MAAM,SAAS,GAAG,UAAU,CAAC;AAClC,mBAAK,MAAM,gBAAgB;AAAA,YAC5B;AAAA,YACA,eAAW;AAAA;AAAA,QACZ,GACD;AAAA,QACA,4CAAC,iCAAe,OAAM,SAAQ,WAAU,oBACvC,sDAAC,0CAAe,UAAU,SAAS,UAAU,cAAc,GAC5D;AAAA;AAAA;AAAA,EACD;AAEF;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Editor } from '@tiptap/core';
|
|
3
|
+
|
|
4
|
+
interface SlashImagePopoverProps {
|
|
5
|
+
editor: Editor;
|
|
6
|
+
anchorRect: DOMRect;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
}
|
|
9
|
+
declare function SlashImagePopover({ editor, anchorRect, onClose }: SlashImagePopoverProps): react_jsx_runtime.JSX.Element;
|
|
10
|
+
|
|
11
|
+
export { SlashImagePopover, type SlashImagePopoverProps };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Editor } from '@tiptap/core';
|
|
3
|
+
|
|
4
|
+
interface SlashImagePopoverProps {
|
|
5
|
+
editor: Editor;
|
|
6
|
+
anchorRect: DOMRect;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
}
|
|
9
|
+
declare function SlashImagePopover({ editor, anchorRect, onClose }: SlashImagePopoverProps): react_jsx_runtime.JSX.Element;
|
|
10
|
+
|
|
11
|
+
export { SlashImagePopover, type SlashImagePopoverProps };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/slash-dropdown-menu/slash-image-popover.tsx
|
|
4
|
+
import { useCallback } from "react";
|
|
5
|
+
import { ImageInputForm } from "../image-popover/image-input-form.mjs";
|
|
6
|
+
import { Popover, PopoverAnchor, PopoverContent } from "../ui/popover.mjs";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
function SlashImagePopover({
|
|
9
|
+
editor,
|
|
10
|
+
anchorRect,
|
|
11
|
+
onClose
|
|
12
|
+
}) {
|
|
13
|
+
const handleSubmit = useCallback(
|
|
14
|
+
({ url, alt }) => {
|
|
15
|
+
if (!url) {
|
|
16
|
+
onClose();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
editor.chain().focus().setImage({ src: url, alt: alt || void 0 }).run();
|
|
20
|
+
onClose();
|
|
21
|
+
},
|
|
22
|
+
[editor, onClose]
|
|
23
|
+
);
|
|
24
|
+
return /* @__PURE__ */ jsxs(
|
|
25
|
+
Popover,
|
|
26
|
+
{
|
|
27
|
+
open: true,
|
|
28
|
+
onOpenChange: (next) => {
|
|
29
|
+
if (!next) onClose();
|
|
30
|
+
},
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ jsx(PopoverAnchor, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
33
|
+
"span",
|
|
34
|
+
{
|
|
35
|
+
ref: (node) => {
|
|
36
|
+
if (!node) return;
|
|
37
|
+
const { top, left, width, height } = anchorRect;
|
|
38
|
+
node.style.position = "fixed";
|
|
39
|
+
node.style.top = `${top}px`;
|
|
40
|
+
node.style.left = `${left}px`;
|
|
41
|
+
node.style.width = `${width || 1}px`;
|
|
42
|
+
node.style.height = `${height || 1}px`;
|
|
43
|
+
node.style.pointerEvents = "none";
|
|
44
|
+
},
|
|
45
|
+
"aria-hidden": true
|
|
46
|
+
}
|
|
47
|
+
) }),
|
|
48
|
+
/* @__PURE__ */ jsx(PopoverContent, { align: "start", className: "nt:w-auto nt:p-0", children: /* @__PURE__ */ jsx(ImageInputForm, { onCancel: onClose, onSubmit: handleSubmit }) })
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
SlashImagePopover
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=slash-image-popover.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/slash-dropdown-menu/slash-image-popover.tsx"],"sourcesContent":["'use client';\n\nimport { useCallback } from 'react';\n\nimport { ImageInputForm } from '../image-popover/image-input-form.js';\nimport { Popover, PopoverAnchor, PopoverContent } from '../ui/popover.js';\n\nimport type { Editor } from '@tiptap/core';\nimport type {} from '@tiptap/extension-image';\n\nexport interface SlashImagePopoverProps {\n\teditor: Editor;\n\tanchorRect: DOMRect;\n\tonClose: () => void;\n}\n\nexport function SlashImagePopover({\n\teditor,\n\tanchorRect,\n\tonClose\n}: SlashImagePopoverProps) {\n\tconst handleSubmit = useCallback(\n\t\t({ url, alt }: { url: string; alt: string }) => {\n\t\t\tif (!url) {\n\t\t\t\tonClose();\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\teditor\n\t\t\t\t.chain()\n\t\t\t\t.focus()\n\t\t\t\t.setImage({ src: url, alt: alt || undefined })\n\t\t\t\t.run();\n\t\t\tonClose();\n\t\t},\n\t\t[editor, onClose]\n\t);\n\n\treturn (\n\t\t<Popover\n\t\t\topen\n\t\t\tonOpenChange={(next) => {\n\t\t\t\tif (!next) onClose();\n\t\t\t}}\n\t\t>\n\t\t\t<PopoverAnchor asChild>\n\t\t\t\t<span\n\t\t\t\t\tref={(node) => {\n\t\t\t\t\t\tif (!node) return;\n\n\t\t\t\t\t\t// Pin the anchor element at the captured rect.\n\t\t\t\t\t\tconst { top, left, width, height } = anchorRect;\n\n\t\t\t\t\t\tnode.style.position = 'fixed';\n\t\t\t\t\t\tnode.style.top = `${top}px`;\n\t\t\t\t\t\tnode.style.left = `${left}px`;\n\t\t\t\t\t\tnode.style.width = `${width || 1}px`;\n\t\t\t\t\t\tnode.style.height = `${height || 1}px`;\n\t\t\t\t\t\tnode.style.pointerEvents = 'none';\n\t\t\t\t\t}}\n\t\t\t\t\taria-hidden\n\t\t\t\t/>\n\t\t\t</PopoverAnchor>\n\t\t\t<PopoverContent align=\"start\" className=\"nt:w-auto nt:p-0\">\n\t\t\t\t<ImageInputForm onCancel={onClose} onSubmit={handleSubmit} />\n\t\t\t</PopoverContent>\n\t\t</Popover>\n\t);\n}\n"],"mappings":";;;AAEA,SAAS,mBAAmB;AAE5B,SAAS,sBAAsB;AAC/B,SAAS,SAAS,eAAe,sBAAsB;AAmCrD,SAOE,KAPF;AAxBK,SAAS,kBAAkB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AACD,GAA2B;AAC1B,QAAM,eAAe;AAAA,IACpB,CAAC,EAAE,KAAK,IAAI,MAAoC;AAC/C,UAAI,CAAC,KAAK;AACT,gBAAQ;AAER;AAAA,MACD;AAEA,aACE,MAAM,EACN,MAAM,EACN,SAAS,EAAE,KAAK,KAAK,KAAK,OAAO,OAAU,CAAC,EAC5C,IAAI;AACN,cAAQ;AAAA,IACT;AAAA,IACA,CAAC,QAAQ,OAAO;AAAA,EACjB;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAI;AAAA,MACJ,cAAc,CAAC,SAAS;AACvB,YAAI,CAAC,KAAM,SAAQ;AAAA,MACpB;AAAA,MAEA;AAAA,4BAAC,iBAAc,SAAO,MACrB;AAAA,UAAC;AAAA;AAAA,YACA,KAAK,CAAC,SAAS;AACd,kBAAI,CAAC,KAAM;AAGX,oBAAM,EAAE,KAAK,MAAM,OAAO,OAAO,IAAI;AAErC,mBAAK,MAAM,WAAW;AACtB,mBAAK,MAAM,MAAM,GAAG,GAAG;AACvB,mBAAK,MAAM,OAAO,GAAG,IAAI;AACzB,mBAAK,MAAM,QAAQ,GAAG,SAAS,CAAC;AAChC,mBAAK,MAAM,SAAS,GAAG,UAAU,CAAC;AAClC,mBAAK,MAAM,gBAAgB;AAAA,YAC5B;AAAA,YACA,eAAW;AAAA;AAAA,QACZ,GACD;AAAA,QACA,oBAAC,kBAAe,OAAM,SAAQ,WAAU,oBACvC,8BAAC,kBAAe,UAAU,SAAS,UAAU,cAAc,GAC5D;AAAA;AAAA;AAAA,EACD;AAEF;","names":[]}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/slash-dropdown-menu/use-slash-items.ts
|
|
21
|
+
var use_slash_items_exports = {};
|
|
22
|
+
__export(use_slash_items_exports, {
|
|
23
|
+
useSlashItems: () => useSlashItems
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(use_slash_items_exports);
|
|
26
|
+
var import_lucide_react = require("lucide-react");
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
function useSlashItems({ onImageRequest }) {
|
|
29
|
+
return (0, import_react.useCallback)(
|
|
30
|
+
(editor) => [
|
|
31
|
+
{
|
|
32
|
+
title: "Text",
|
|
33
|
+
keywords: ["p", "paragraph", "text"],
|
|
34
|
+
badge: import_lucide_react.Type,
|
|
35
|
+
group: "Style",
|
|
36
|
+
onSelect: () => {
|
|
37
|
+
editor.chain().focus().setParagraph().run();
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
title: "Heading 1",
|
|
42
|
+
keywords: ["h1", "heading"],
|
|
43
|
+
badge: import_lucide_react.Heading1,
|
|
44
|
+
group: "Style",
|
|
45
|
+
onSelect: () => {
|
|
46
|
+
editor.chain().focus().toggleHeading({ level: 1 }).run();
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
title: "Heading 2",
|
|
51
|
+
keywords: ["h2", "heading"],
|
|
52
|
+
badge: import_lucide_react.Heading2,
|
|
53
|
+
group: "Style",
|
|
54
|
+
onSelect: () => {
|
|
55
|
+
editor.chain().focus().toggleHeading({ level: 2 }).run();
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
title: "Heading 3",
|
|
60
|
+
keywords: ["h3", "heading"],
|
|
61
|
+
badge: import_lucide_react.Heading3,
|
|
62
|
+
group: "Style",
|
|
63
|
+
onSelect: () => {
|
|
64
|
+
editor.chain().focus().toggleHeading({ level: 3 }).run();
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
title: "Heading 4",
|
|
69
|
+
keywords: ["h4", "heading"],
|
|
70
|
+
badge: import_lucide_react.Heading4,
|
|
71
|
+
group: "Style",
|
|
72
|
+
onSelect: () => {
|
|
73
|
+
editor.chain().focus().toggleHeading({ level: 4 }).run();
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
title: "Bullet List",
|
|
78
|
+
keywords: ["ul", "list", "bullet"],
|
|
79
|
+
badge: import_lucide_react.List,
|
|
80
|
+
group: "Style",
|
|
81
|
+
onSelect: () => {
|
|
82
|
+
editor.chain().focus().toggleBulletList().run();
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
title: "Numbered List",
|
|
87
|
+
keywords: ["ol", "list", "ordered", "numbered"],
|
|
88
|
+
badge: import_lucide_react.ListOrdered,
|
|
89
|
+
group: "Style",
|
|
90
|
+
onSelect: () => {
|
|
91
|
+
editor.chain().focus().toggleOrderedList().run();
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
title: "To-do List",
|
|
96
|
+
keywords: ["task", "todo", "checklist"],
|
|
97
|
+
badge: import_lucide_react.ListTodo,
|
|
98
|
+
group: "Style",
|
|
99
|
+
onSelect: () => {
|
|
100
|
+
editor.chain().focus().toggleTaskList().run();
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
title: "Blockquote",
|
|
105
|
+
keywords: ["quote"],
|
|
106
|
+
badge: import_lucide_react.Quote,
|
|
107
|
+
group: "Style",
|
|
108
|
+
onSelect: () => {
|
|
109
|
+
editor.chain().focus().toggleBlockquote().run();
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
title: "Code Block",
|
|
114
|
+
keywords: ["code", "pre"],
|
|
115
|
+
badge: import_lucide_react.SquareCode,
|
|
116
|
+
group: "Style",
|
|
117
|
+
onSelect: () => {
|
|
118
|
+
editor.chain().focus().toggleCodeBlock().run();
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
title: "Image",
|
|
123
|
+
keywords: ["image", "img", "picture", "media", "url"],
|
|
124
|
+
badge: import_lucide_react.Image,
|
|
125
|
+
group: "Insert",
|
|
126
|
+
onSelect: () => {
|
|
127
|
+
onImageRequest();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
[onImageRequest]
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
135
|
+
0 && (module.exports = {
|
|
136
|
+
useSlashItems
|
|
137
|
+
});
|
|
138
|
+
//# sourceMappingURL=use-slash-items.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/slash-dropdown-menu/use-slash-items.ts"],"sourcesContent":["import {\n\tHeading1,\n\tHeading2,\n\tHeading3,\n\tHeading4,\n\tImage as ImageIcon,\n\tList,\n\tListOrdered,\n\tListTodo,\n\tQuote,\n\tSquareCode,\n\tType\n} from 'lucide-react';\nimport { useCallback } from 'react';\n\nimport type { SuggestionItem } from '../suggestion-menu/suggestion-menu-types.js';\nimport type { Editor } from '@tiptap/core';\n// Module augmentations: pull in ChainedCommands extensions from these packages.\nimport type {} from '@tiptap/starter-kit';\nimport type {} from '@tiptap/extension-list';\n\nexport interface UseSlashItemsOptions {\n\t/** Called when the Image slash item is chosen. */\n\tonImageRequest: () => void;\n}\n\nexport function useSlashItems({ onImageRequest }: UseSlashItemsOptions) {\n\treturn useCallback(\n\t\t(editor: Editor): SuggestionItem[] => [\n\t\t\t{\n\t\t\t\ttitle: 'Text',\n\t\t\t\tkeywords: ['p', 'paragraph', 'text'],\n\t\t\t\tbadge: Type,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().setParagraph().run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'Heading 1',\n\t\t\t\tkeywords: ['h1', 'heading'],\n\t\t\t\tbadge: Heading1,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().toggleHeading({ level: 1 }).run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'Heading 2',\n\t\t\t\tkeywords: ['h2', 'heading'],\n\t\t\t\tbadge: Heading2,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().toggleHeading({ level: 2 }).run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'Heading 3',\n\t\t\t\tkeywords: ['h3', 'heading'],\n\t\t\t\tbadge: Heading3,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().toggleHeading({ level: 3 }).run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'Heading 4',\n\t\t\t\tkeywords: ['h4', 'heading'],\n\t\t\t\tbadge: Heading4,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().toggleHeading({ level: 4 }).run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'Bullet List',\n\t\t\t\tkeywords: ['ul', 'list', 'bullet'],\n\t\t\t\tbadge: List,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().toggleBulletList().run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'Numbered List',\n\t\t\t\tkeywords: ['ol', 'list', 'ordered', 'numbered'],\n\t\t\t\tbadge: ListOrdered,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().toggleOrderedList().run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'To-do List',\n\t\t\t\tkeywords: ['task', 'todo', 'checklist'],\n\t\t\t\tbadge: ListTodo,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().toggleTaskList().run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'Blockquote',\n\t\t\t\tkeywords: ['quote'],\n\t\t\t\tbadge: Quote,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().toggleBlockquote().run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'Code Block',\n\t\t\t\tkeywords: ['code', 'pre'],\n\t\t\t\tbadge: SquareCode,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().toggleCodeBlock().run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'Image',\n\t\t\t\tkeywords: ['image', 'img', 'picture', 'media', 'url'],\n\t\t\t\tbadge: ImageIcon,\n\t\t\t\tgroup: 'Insert',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\tonImageRequest();\n\t\t\t\t}\n\t\t\t}\n\t\t],\n\t\t[onImageRequest]\n\t);\n}\n"],"mappings":"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","names":["ImageIcon"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SuggestionItem } from '../suggestion-menu/suggestion-menu-types.cjs';
|
|
2
|
+
import { Editor } from '@tiptap/core';
|
|
3
|
+
import '@tiptap/react';
|
|
4
|
+
|
|
5
|
+
interface UseSlashItemsOptions {
|
|
6
|
+
/** Called when the Image slash item is chosen. */
|
|
7
|
+
onImageRequest: () => void;
|
|
8
|
+
}
|
|
9
|
+
declare function useSlashItems({ onImageRequest }: UseSlashItemsOptions): (editor: Editor) => SuggestionItem[];
|
|
10
|
+
|
|
11
|
+
export { type UseSlashItemsOptions, useSlashItems };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SuggestionItem } from '../suggestion-menu/suggestion-menu-types.js';
|
|
2
|
+
import { Editor } from '@tiptap/core';
|
|
3
|
+
import '@tiptap/react';
|
|
4
|
+
|
|
5
|
+
interface UseSlashItemsOptions {
|
|
6
|
+
/** Called when the Image slash item is chosen. */
|
|
7
|
+
onImageRequest: () => void;
|
|
8
|
+
}
|
|
9
|
+
declare function useSlashItems({ onImageRequest }: UseSlashItemsOptions): (editor: Editor) => SuggestionItem[];
|
|
10
|
+
|
|
11
|
+
export { type UseSlashItemsOptions, useSlashItems };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// src/components/slash-dropdown-menu/use-slash-items.ts
|
|
2
|
+
import {
|
|
3
|
+
Heading1,
|
|
4
|
+
Heading2,
|
|
5
|
+
Heading3,
|
|
6
|
+
Heading4,
|
|
7
|
+
Image as ImageIcon,
|
|
8
|
+
List,
|
|
9
|
+
ListOrdered,
|
|
10
|
+
ListTodo,
|
|
11
|
+
Quote,
|
|
12
|
+
SquareCode,
|
|
13
|
+
Type
|
|
14
|
+
} from "lucide-react";
|
|
15
|
+
import { useCallback } from "react";
|
|
16
|
+
function useSlashItems({ onImageRequest }) {
|
|
17
|
+
return useCallback(
|
|
18
|
+
(editor) => [
|
|
19
|
+
{
|
|
20
|
+
title: "Text",
|
|
21
|
+
keywords: ["p", "paragraph", "text"],
|
|
22
|
+
badge: Type,
|
|
23
|
+
group: "Style",
|
|
24
|
+
onSelect: () => {
|
|
25
|
+
editor.chain().focus().setParagraph().run();
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
title: "Heading 1",
|
|
30
|
+
keywords: ["h1", "heading"],
|
|
31
|
+
badge: Heading1,
|
|
32
|
+
group: "Style",
|
|
33
|
+
onSelect: () => {
|
|
34
|
+
editor.chain().focus().toggleHeading({ level: 1 }).run();
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
title: "Heading 2",
|
|
39
|
+
keywords: ["h2", "heading"],
|
|
40
|
+
badge: Heading2,
|
|
41
|
+
group: "Style",
|
|
42
|
+
onSelect: () => {
|
|
43
|
+
editor.chain().focus().toggleHeading({ level: 2 }).run();
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
title: "Heading 3",
|
|
48
|
+
keywords: ["h3", "heading"],
|
|
49
|
+
badge: Heading3,
|
|
50
|
+
group: "Style",
|
|
51
|
+
onSelect: () => {
|
|
52
|
+
editor.chain().focus().toggleHeading({ level: 3 }).run();
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
title: "Heading 4",
|
|
57
|
+
keywords: ["h4", "heading"],
|
|
58
|
+
badge: Heading4,
|
|
59
|
+
group: "Style",
|
|
60
|
+
onSelect: () => {
|
|
61
|
+
editor.chain().focus().toggleHeading({ level: 4 }).run();
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
title: "Bullet List",
|
|
66
|
+
keywords: ["ul", "list", "bullet"],
|
|
67
|
+
badge: List,
|
|
68
|
+
group: "Style",
|
|
69
|
+
onSelect: () => {
|
|
70
|
+
editor.chain().focus().toggleBulletList().run();
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
title: "Numbered List",
|
|
75
|
+
keywords: ["ol", "list", "ordered", "numbered"],
|
|
76
|
+
badge: ListOrdered,
|
|
77
|
+
group: "Style",
|
|
78
|
+
onSelect: () => {
|
|
79
|
+
editor.chain().focus().toggleOrderedList().run();
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
title: "To-do List",
|
|
84
|
+
keywords: ["task", "todo", "checklist"],
|
|
85
|
+
badge: ListTodo,
|
|
86
|
+
group: "Style",
|
|
87
|
+
onSelect: () => {
|
|
88
|
+
editor.chain().focus().toggleTaskList().run();
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
title: "Blockquote",
|
|
93
|
+
keywords: ["quote"],
|
|
94
|
+
badge: Quote,
|
|
95
|
+
group: "Style",
|
|
96
|
+
onSelect: () => {
|
|
97
|
+
editor.chain().focus().toggleBlockquote().run();
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
title: "Code Block",
|
|
102
|
+
keywords: ["code", "pre"],
|
|
103
|
+
badge: SquareCode,
|
|
104
|
+
group: "Style",
|
|
105
|
+
onSelect: () => {
|
|
106
|
+
editor.chain().focus().toggleCodeBlock().run();
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
title: "Image",
|
|
111
|
+
keywords: ["image", "img", "picture", "media", "url"],
|
|
112
|
+
badge: ImageIcon,
|
|
113
|
+
group: "Insert",
|
|
114
|
+
onSelect: () => {
|
|
115
|
+
onImageRequest();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
[onImageRequest]
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
export {
|
|
123
|
+
useSlashItems
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=use-slash-items.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/slash-dropdown-menu/use-slash-items.ts"],"sourcesContent":["import {\n\tHeading1,\n\tHeading2,\n\tHeading3,\n\tHeading4,\n\tImage as ImageIcon,\n\tList,\n\tListOrdered,\n\tListTodo,\n\tQuote,\n\tSquareCode,\n\tType\n} from 'lucide-react';\nimport { useCallback } from 'react';\n\nimport type { SuggestionItem } from '../suggestion-menu/suggestion-menu-types.js';\nimport type { Editor } from '@tiptap/core';\n// Module augmentations: pull in ChainedCommands extensions from these packages.\nimport type {} from '@tiptap/starter-kit';\nimport type {} from '@tiptap/extension-list';\n\nexport interface UseSlashItemsOptions {\n\t/** Called when the Image slash item is chosen. */\n\tonImageRequest: () => void;\n}\n\nexport function useSlashItems({ onImageRequest }: UseSlashItemsOptions) {\n\treturn useCallback(\n\t\t(editor: Editor): SuggestionItem[] => [\n\t\t\t{\n\t\t\t\ttitle: 'Text',\n\t\t\t\tkeywords: ['p', 'paragraph', 'text'],\n\t\t\t\tbadge: Type,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().setParagraph().run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'Heading 1',\n\t\t\t\tkeywords: ['h1', 'heading'],\n\t\t\t\tbadge: Heading1,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().toggleHeading({ level: 1 }).run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'Heading 2',\n\t\t\t\tkeywords: ['h2', 'heading'],\n\t\t\t\tbadge: Heading2,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().toggleHeading({ level: 2 }).run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'Heading 3',\n\t\t\t\tkeywords: ['h3', 'heading'],\n\t\t\t\tbadge: Heading3,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().toggleHeading({ level: 3 }).run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'Heading 4',\n\t\t\t\tkeywords: ['h4', 'heading'],\n\t\t\t\tbadge: Heading4,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().toggleHeading({ level: 4 }).run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'Bullet List',\n\t\t\t\tkeywords: ['ul', 'list', 'bullet'],\n\t\t\t\tbadge: List,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().toggleBulletList().run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'Numbered List',\n\t\t\t\tkeywords: ['ol', 'list', 'ordered', 'numbered'],\n\t\t\t\tbadge: ListOrdered,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().toggleOrderedList().run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'To-do List',\n\t\t\t\tkeywords: ['task', 'todo', 'checklist'],\n\t\t\t\tbadge: ListTodo,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().toggleTaskList().run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'Blockquote',\n\t\t\t\tkeywords: ['quote'],\n\t\t\t\tbadge: Quote,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().toggleBlockquote().run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'Code Block',\n\t\t\t\tkeywords: ['code', 'pre'],\n\t\t\t\tbadge: SquareCode,\n\t\t\t\tgroup: 'Style',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\teditor.chain().focus().toggleCodeBlock().run();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: 'Image',\n\t\t\t\tkeywords: ['image', 'img', 'picture', 'media', 'url'],\n\t\t\t\tbadge: ImageIcon,\n\t\t\t\tgroup: 'Insert',\n\t\t\t\tonSelect: () => {\n\t\t\t\t\tonImageRequest();\n\t\t\t\t}\n\t\t\t}\n\t\t],\n\t\t[onImageRequest]\n\t);\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/suggestion-menu/filter-suggestion-items.ts
|
|
21
|
+
var filter_suggestion_items_exports = {};
|
|
22
|
+
__export(filter_suggestion_items_exports, {
|
|
23
|
+
filterSuggestionItems: () => filterSuggestionItems
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(filter_suggestion_items_exports);
|
|
26
|
+
function filterSuggestionItems(items, query) {
|
|
27
|
+
const normalized = query.trim().toLowerCase();
|
|
28
|
+
if (!normalized) {
|
|
29
|
+
return items;
|
|
30
|
+
}
|
|
31
|
+
const matches = items.filter((item) => {
|
|
32
|
+
if (item.title.toLowerCase().includes(normalized)) return true;
|
|
33
|
+
if (item.subtext?.toLowerCase().includes(normalized)) return true;
|
|
34
|
+
if (item.keywords?.some((kw) => kw.toLowerCase().includes(normalized))) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
});
|
|
39
|
+
return matches.sort((a, b) => {
|
|
40
|
+
const aTitle = a.title.toLowerCase();
|
|
41
|
+
const bTitle = b.title.toLowerCase();
|
|
42
|
+
const aExact = aTitle === normalized;
|
|
43
|
+
const bExact = bTitle === normalized;
|
|
44
|
+
if (aExact && !bExact) return -1;
|
|
45
|
+
if (bExact && !aExact) return 1;
|
|
46
|
+
const aStarts = aTitle.startsWith(normalized);
|
|
47
|
+
const bStarts = bTitle.startsWith(normalized);
|
|
48
|
+
if (aStarts && !bStarts) return -1;
|
|
49
|
+
if (bStarts && !aStarts) return 1;
|
|
50
|
+
return 0;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
filterSuggestionItems
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=filter-suggestion-items.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/suggestion-menu/filter-suggestion-items.ts"],"sourcesContent":["import type { SuggestionItem } from './suggestion-menu-types.js';\n\nexport function filterSuggestionItems(\n\titems: SuggestionItem[],\n\tquery: string\n): SuggestionItem[] {\n\tconst normalized = query.trim().toLowerCase();\n\n\tif (!normalized) {\n\t\treturn items;\n\t}\n\n\tconst matches = items.filter((item) => {\n\t\tif (item.title.toLowerCase().includes(normalized)) return true;\n\n\t\tif (item.subtext?.toLowerCase().includes(normalized)) return true;\n\n\t\tif (item.keywords?.some((kw) => kw.toLowerCase().includes(normalized))) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t});\n\n\treturn matches.sort((a, b) => {\n\t\tconst aTitle = a.title.toLowerCase();\n\t\tconst bTitle = b.title.toLowerCase();\n\n\t\tconst aExact = aTitle === normalized;\n\t\tconst bExact = bTitle === normalized;\n\n\t\tif (aExact && !bExact) return -1;\n\n\t\tif (bExact && !aExact) return 1;\n\n\t\tconst aStarts = aTitle.startsWith(normalized);\n\t\tconst bStarts = bTitle.startsWith(normalized);\n\n\t\tif (aStarts && !bStarts) return -1;\n\n\t\tif (bStarts && !aStarts) return 1;\n\n\t\treturn 0;\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,SAAS,sBACf,OACA,OACmB;AACnB,QAAM,aAAa,MAAM,KAAK,EAAE,YAAY;AAE5C,MAAI,CAAC,YAAY;AAChB,WAAO;AAAA,EACR;AAEA,QAAM,UAAU,MAAM,OAAO,CAAC,SAAS;AACtC,QAAI,KAAK,MAAM,YAAY,EAAE,SAAS,UAAU,EAAG,QAAO;AAE1D,QAAI,KAAK,SAAS,YAAY,EAAE,SAAS,UAAU,EAAG,QAAO;AAE7D,QAAI,KAAK,UAAU,KAAK,CAAC,OAAO,GAAG,YAAY,EAAE,SAAS,UAAU,CAAC,GAAG;AACvE,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,EACR,CAAC;AAED,SAAO,QAAQ,KAAK,CAAC,GAAG,MAAM;AAC7B,UAAM,SAAS,EAAE,MAAM,YAAY;AACnC,UAAM,SAAS,EAAE,MAAM,YAAY;AAEnC,UAAM,SAAS,WAAW;AAC1B,UAAM,SAAS,WAAW;AAE1B,QAAI,UAAU,CAAC,OAAQ,QAAO;AAE9B,QAAI,UAAU,CAAC,OAAQ,QAAO;AAE9B,UAAM,UAAU,OAAO,WAAW,UAAU;AAC5C,UAAM,UAAU,OAAO,WAAW,UAAU;AAE5C,QAAI,WAAW,CAAC,QAAS,QAAO;AAEhC,QAAI,WAAW,CAAC,QAAS,QAAO;AAEhC,WAAO;AAAA,EACR,CAAC;AACF;","names":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/components/suggestion-menu/filter-suggestion-items.ts
|
|
2
|
+
function filterSuggestionItems(items, query) {
|
|
3
|
+
const normalized = query.trim().toLowerCase();
|
|
4
|
+
if (!normalized) {
|
|
5
|
+
return items;
|
|
6
|
+
}
|
|
7
|
+
const matches = items.filter((item) => {
|
|
8
|
+
if (item.title.toLowerCase().includes(normalized)) return true;
|
|
9
|
+
if (item.subtext?.toLowerCase().includes(normalized)) return true;
|
|
10
|
+
if (item.keywords?.some((kw) => kw.toLowerCase().includes(normalized))) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
});
|
|
15
|
+
return matches.sort((a, b) => {
|
|
16
|
+
const aTitle = a.title.toLowerCase();
|
|
17
|
+
const bTitle = b.title.toLowerCase();
|
|
18
|
+
const aExact = aTitle === normalized;
|
|
19
|
+
const bExact = bTitle === normalized;
|
|
20
|
+
if (aExact && !bExact) return -1;
|
|
21
|
+
if (bExact && !aExact) return 1;
|
|
22
|
+
const aStarts = aTitle.startsWith(normalized);
|
|
23
|
+
const bStarts = bTitle.startsWith(normalized);
|
|
24
|
+
if (aStarts && !bStarts) return -1;
|
|
25
|
+
if (bStarts && !aStarts) return 1;
|
|
26
|
+
return 0;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
filterSuggestionItems
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=filter-suggestion-items.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/suggestion-menu/filter-suggestion-items.ts"],"sourcesContent":["import type { SuggestionItem } from './suggestion-menu-types.js';\n\nexport function filterSuggestionItems(\n\titems: SuggestionItem[],\n\tquery: string\n): SuggestionItem[] {\n\tconst normalized = query.trim().toLowerCase();\n\n\tif (!normalized) {\n\t\treturn items;\n\t}\n\n\tconst matches = items.filter((item) => {\n\t\tif (item.title.toLowerCase().includes(normalized)) return true;\n\n\t\tif (item.subtext?.toLowerCase().includes(normalized)) return true;\n\n\t\tif (item.keywords?.some((kw) => kw.toLowerCase().includes(normalized))) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t});\n\n\treturn matches.sort((a, b) => {\n\t\tconst aTitle = a.title.toLowerCase();\n\t\tconst bTitle = b.title.toLowerCase();\n\n\t\tconst aExact = aTitle === normalized;\n\t\tconst bExact = bTitle === normalized;\n\n\t\tif (aExact && !bExact) return -1;\n\n\t\tif (bExact && !aExact) return 1;\n\n\t\tconst aStarts = aTitle.startsWith(normalized);\n\t\tconst bStarts = bTitle.startsWith(normalized);\n\n\t\tif (aStarts && !bStarts) return -1;\n\n\t\tif (bStarts && !aStarts) return 1;\n\n\t\treturn 0;\n\t});\n}\n"],"mappings":";AAEO,SAAS,sBACf,OACA,OACmB;AACnB,QAAM,aAAa,MAAM,KAAK,EAAE,YAAY;AAE5C,MAAI,CAAC,YAAY;AAChB,WAAO;AAAA,EACR;AAEA,QAAM,UAAU,MAAM,OAAO,CAAC,SAAS;AACtC,QAAI,KAAK,MAAM,YAAY,EAAE,SAAS,UAAU,EAAG,QAAO;AAE1D,QAAI,KAAK,SAAS,YAAY,EAAE,SAAS,UAAU,EAAG,QAAO;AAE7D,QAAI,KAAK,UAAU,KAAK,CAAC,OAAO,GAAG,YAAY,EAAE,SAAS,UAAU,CAAC,GAAG;AACvE,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,EACR,CAAC;AAED,SAAO,QAAQ,KAAK,CAAC,GAAG,MAAM;AAC7B,UAAM,SAAS,EAAE,MAAM,YAAY;AACnC,UAAM,SAAS,EAAE,MAAM,YAAY;AAEnC,UAAM,SAAS,WAAW;AAC1B,UAAM,SAAS,WAAW;AAE1B,QAAI,UAAU,CAAC,OAAQ,QAAO;AAE9B,QAAI,UAAU,CAAC,OAAQ,QAAO;AAE9B,UAAM,UAAU,OAAO,WAAW,UAAU;AAC5C,UAAM,UAAU,OAAO,WAAW,UAAU;AAE5C,QAAI,WAAW,CAAC,QAAS,QAAO;AAEhC,QAAI,WAAW,CAAC,QAAS,QAAO;AAEhC,WAAO;AAAA,EACR,CAAC;AACF;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/components/suggestion-menu/suggestion-menu-types.ts
|
|
17
|
+
var suggestion_menu_types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(suggestion_menu_types_exports);
|
|
19
|
+
//# sourceMappingURL=suggestion-menu-types.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/suggestion-menu/suggestion-menu-types.ts"],"sourcesContent":["import type { Editor, Range } from '@tiptap/react';\n\nexport type IconComponent = React.ComponentType<React.SVGProps<SVGSVGElement>>;\n\nexport interface SuggestionItem {\n\t/** Main label shown in the menu. */\n\ttitle: string;\n\t/** Secondary description shown under the title. */\n\tsubtext?: string;\n\t/** Icon component (lucide-react). */\n\tbadge?: IconComponent;\n\t/** Group label used by callers that render grouped lists. */\n\tgroup?: string;\n\t/** Extra search keywords. */\n\tkeywords?: string[];\n\t/** Invoked when the item is chosen. */\n\tonSelect: (props: { editor: Editor; range: Range }) => void;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|