notra-editor 0.8.1 → 0.8.3
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/filter-slash-items.cjs +46 -0
- package/dist/components/slash-dropdown-menu/filter-slash-items.cjs.map +1 -0
- package/dist/components/slash-dropdown-menu/filter-slash-items.d.cts +15 -0
- package/dist/components/slash-dropdown-menu/filter-slash-items.d.ts +15 -0
- package/dist/components/slash-dropdown-menu/filter-slash-items.mjs +21 -0
- package/dist/components/slash-dropdown-menu/filter-slash-items.mjs.map +1 -0
- package/dist/components/slash-dropdown-menu/slash-dropdown-menu.cjs +294 -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 +292 -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/types.cjs +19 -0
- package/dist/components/slash-dropdown-menu/types.cjs.map +1 -0
- package/dist/components/slash-dropdown-menu/types.d.cts +22 -0
- package/dist/components/slash-dropdown-menu/types.d.ts +22 -0
- package/dist/components/slash-dropdown-menu/types.mjs +1 -0
- package/dist/components/slash-dropdown-menu/types.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/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 +7 -6
- package/dist/components/ui/command.cjs.map +1 -1
- package/dist/components/ui/command.mjs +6 -6
- 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.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-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 +4 -2
- package/dist/themes/default/editor.css +68 -6
- 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 +5 -1
|
@@ -16,6 +16,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/list-dropdown-menu/use-list.ts
|
|
19
21
|
var use_list_exports = {};
|
|
20
22
|
__export(use_list_exports, {
|
|
21
23
|
getListTriggerIcon: () => getListTriggerIcon,
|
|
@@ -25,17 +27,17 @@ __export(use_list_exports, {
|
|
|
25
27
|
module.exports = __toCommonJS(use_list_exports);
|
|
26
28
|
var import_lucide_react = require("lucide-react");
|
|
27
29
|
var import_react = require("react");
|
|
28
|
-
|
|
30
|
+
var listIcons = {
|
|
29
31
|
bulletList: import_lucide_react.List,
|
|
30
32
|
orderedList: import_lucide_react.ListOrdered,
|
|
31
33
|
taskList: import_lucide_react.ListTodo
|
|
32
34
|
};
|
|
33
|
-
|
|
35
|
+
var listLabels = {
|
|
34
36
|
bulletList: "Bullet List",
|
|
35
37
|
orderedList: "Ordered List",
|
|
36
38
|
taskList: "Task List"
|
|
37
39
|
};
|
|
38
|
-
|
|
40
|
+
var listItemTypes = {
|
|
39
41
|
bulletList: "listItem",
|
|
40
42
|
orderedList: "listItem",
|
|
41
43
|
taskList: "taskItem"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/list-dropdown-menu/use-list.ts"],"sourcesContent":["import { List, ListOrdered, ListTodo } from 'lucide-react';\nimport { useCallback, useEffect, useState } from 'react';\n\nimport type { Editor } from '@tiptap/core';\nimport type { LucideIcon } from 'lucide-react';\n\nexport type ListType = 'bulletList' | 'orderedList' | 'taskList';\n\ntype IconComponent = LucideIcon;\n\nconst listIcons: Record<ListType, IconComponent> = {\n\tbulletList: List,\n\torderedList: ListOrdered,\n\ttaskList: ListTodo\n};\n\nconst listLabels: Record<ListType, string> = {\n\tbulletList: 'Bullet List',\n\torderedList: 'Ordered List',\n\ttaskList: 'Task List'\n};\n\nconst listItemTypes: Record<ListType, string> = {\n\tbulletList: 'listItem',\n\torderedList: 'listItem',\n\ttaskList: 'taskItem'\n};\n\nfunction canToggleList(editor: Editor | null): boolean {\n\tif (!editor || !editor.isEditable) return false;\n\n\treturn (\n\t\teditor.can().toggleList('bulletList', 'listItem') ||\n\t\teditor.can().clearNodes()\n\t);\n}\n\nexport function useList({\n\teditor,\n\ttype\n}: {\n\teditor: Editor | null;\n\ttype: ListType;\n}) {\n\tconst [isActive, setIsActive] = useState(false);\n\tconst [canToggle, setCanToggle] = useState(false);\n\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\n\t\tconst handleUpdate = () => {\n\t\t\tsetIsActive(editor.isActive(type));\n\t\t\tsetCanToggle(canToggleList(editor));\n\t\t};\n\n\t\thandleUpdate();\n\n\t\teditor.on('selectionUpdate', handleUpdate);\n\t\teditor.on('transaction', handleUpdate);\n\n\t\treturn () => {\n\t\t\teditor.off('selectionUpdate', handleUpdate);\n\t\t\teditor.off('transaction', handleUpdate);\n\t\t};\n\t}, [editor, type]);\n\n\tconst handleToggle = useCallback(() => {\n\t\tif (!editor || !editor.isEditable) return false;\n\n\t\tconst itemType = listItemTypes[type];\n\n\t\tif (editor.isActive(type)) {\n\t\t\t// Currently this list type → convert back to paragraph\n\t\t\treturn editor.chain().focus().clearNodes().run();\n\t\t}\n\n\t\t// clearNodes first to convert any block type to paragraph,\n\t\t// then toggle list\n\t\treturn editor.chain().focus().clearNodes().toggleList(type, itemType).run();\n\t}, [editor, type]);\n\n\treturn {\n\t\tisActive,\n\t\tcanToggle,\n\t\thandleToggle,\n\t\tlabel: listLabels[type],\n\t\tIcon: listIcons[type]\n\t};\n}\n\nexport function useActiveListType(\n\teditor: Editor | null,\n\ttypes: ListType[]\n): ListType | null {\n\tconst [activeType, setActiveType] = useState<ListType | null>(null);\n\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\n\t\tconst handleUpdate = () => {\n\t\t\tconst found = types.find((type) => editor.isActive(type));\n\n\t\t\tsetActiveType(found ?? null);\n\t\t};\n\n\t\thandleUpdate();\n\n\t\teditor.on('selectionUpdate', handleUpdate);\n\t\teditor.on('transaction', handleUpdate);\n\n\t\treturn () => {\n\t\t\teditor.off('selectionUpdate', handleUpdate);\n\t\t\teditor.off('transaction', handleUpdate);\n\t\t};\n\t}, [editor, types]);\n\n\treturn activeType;\n}\n\nexport function getListTriggerIcon(activeType: ListType | null): IconComponent {\n\tif (activeType === null) return List;\n\n\treturn listIcons[activeType];\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/list-dropdown-menu/use-list.ts"],"sourcesContent":["import { List, ListOrdered, ListTodo } from 'lucide-react';\nimport { useCallback, useEffect, useState } from 'react';\n\nimport type { Editor } from '@tiptap/core';\nimport type { LucideIcon } from 'lucide-react';\n\nexport type ListType = 'bulletList' | 'orderedList' | 'taskList';\n\ntype IconComponent = LucideIcon;\n\nconst listIcons: Record<ListType, IconComponent> = {\n\tbulletList: List,\n\torderedList: ListOrdered,\n\ttaskList: ListTodo\n};\n\nconst listLabels: Record<ListType, string> = {\n\tbulletList: 'Bullet List',\n\torderedList: 'Ordered List',\n\ttaskList: 'Task List'\n};\n\nconst listItemTypes: Record<ListType, string> = {\n\tbulletList: 'listItem',\n\torderedList: 'listItem',\n\ttaskList: 'taskItem'\n};\n\nfunction canToggleList(editor: Editor | null): boolean {\n\tif (!editor || !editor.isEditable) return false;\n\n\treturn (\n\t\teditor.can().toggleList('bulletList', 'listItem') ||\n\t\teditor.can().clearNodes()\n\t);\n}\n\nexport function useList({\n\teditor,\n\ttype\n}: {\n\teditor: Editor | null;\n\ttype: ListType;\n}) {\n\tconst [isActive, setIsActive] = useState(false);\n\tconst [canToggle, setCanToggle] = useState(false);\n\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\n\t\tconst handleUpdate = () => {\n\t\t\tsetIsActive(editor.isActive(type));\n\t\t\tsetCanToggle(canToggleList(editor));\n\t\t};\n\n\t\thandleUpdate();\n\n\t\teditor.on('selectionUpdate', handleUpdate);\n\t\teditor.on('transaction', handleUpdate);\n\n\t\treturn () => {\n\t\t\teditor.off('selectionUpdate', handleUpdate);\n\t\t\teditor.off('transaction', handleUpdate);\n\t\t};\n\t}, [editor, type]);\n\n\tconst handleToggle = useCallback(() => {\n\t\tif (!editor || !editor.isEditable) return false;\n\n\t\tconst itemType = listItemTypes[type];\n\n\t\tif (editor.isActive(type)) {\n\t\t\t// Currently this list type → convert back to paragraph\n\t\t\treturn editor.chain().focus().clearNodes().run();\n\t\t}\n\n\t\t// clearNodes first to convert any block type to paragraph,\n\t\t// then toggle list\n\t\treturn editor.chain().focus().clearNodes().toggleList(type, itemType).run();\n\t}, [editor, type]);\n\n\treturn {\n\t\tisActive,\n\t\tcanToggle,\n\t\thandleToggle,\n\t\tlabel: listLabels[type],\n\t\tIcon: listIcons[type]\n\t};\n}\n\nexport function useActiveListType(\n\teditor: Editor | null,\n\ttypes: ListType[]\n): ListType | null {\n\tconst [activeType, setActiveType] = useState<ListType | null>(null);\n\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\n\t\tconst handleUpdate = () => {\n\t\t\tconst found = types.find((type) => editor.isActive(type));\n\n\t\t\tsetActiveType(found ?? null);\n\t\t};\n\n\t\thandleUpdate();\n\n\t\teditor.on('selectionUpdate', handleUpdate);\n\t\teditor.on('transaction', handleUpdate);\n\n\t\treturn () => {\n\t\t\teditor.off('selectionUpdate', handleUpdate);\n\t\t\teditor.off('transaction', handleUpdate);\n\t\t};\n\t}, [editor, types]);\n\n\treturn activeType;\n}\n\nexport function getListTriggerIcon(activeType: ListType | null): IconComponent {\n\tif (activeType === null) return List;\n\n\treturn listIcons[activeType];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA4C;AAC5C,mBAAiD;AASjD,IAAM,YAA6C;AAAA,EAClD,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,UAAU;AACX;AAEA,IAAM,aAAuC;AAAA,EAC5C,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,UAAU;AACX;AAEA,IAAM,gBAA0C;AAAA,EAC/C,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,UAAU;AACX;AAEA,SAAS,cAAc,QAAgC;AACtD,MAAI,CAAC,UAAU,CAAC,OAAO,WAAY,QAAO;AAE1C,SACC,OAAO,IAAI,EAAE,WAAW,cAAc,UAAU,KAChD,OAAO,IAAI,EAAE,WAAW;AAE1B;AAEO,SAAS,QAAQ;AAAA,EACvB;AAAA,EACA;AACD,GAGG;AACF,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAS,KAAK;AAC9C,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,KAAK;AAEhD,8BAAU,MAAM;AACf,QAAI,CAAC,OAAQ;AAEb,UAAM,eAAe,MAAM;AAC1B,kBAAY,OAAO,SAAS,IAAI,CAAC;AACjC,mBAAa,cAAc,MAAM,CAAC;AAAA,IACnC;AAEA,iBAAa;AAEb,WAAO,GAAG,mBAAmB,YAAY;AACzC,WAAO,GAAG,eAAe,YAAY;AAErC,WAAO,MAAM;AACZ,aAAO,IAAI,mBAAmB,YAAY;AAC1C,aAAO,IAAI,eAAe,YAAY;AAAA,IACvC;AAAA,EACD,GAAG,CAAC,QAAQ,IAAI,CAAC;AAEjB,QAAM,mBAAe,0BAAY,MAAM;AACtC,QAAI,CAAC,UAAU,CAAC,OAAO,WAAY,QAAO;AAE1C,UAAM,WAAW,cAAc,IAAI;AAEnC,QAAI,OAAO,SAAS,IAAI,GAAG;AAE1B,aAAO,OAAO,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI;AAAA,IAChD;AAIA,WAAO,OAAO,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,MAAM,QAAQ,EAAE,IAAI;AAAA,EAC3E,GAAG,CAAC,QAAQ,IAAI,CAAC;AAEjB,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,WAAW,IAAI;AAAA,IACtB,MAAM,UAAU,IAAI;AAAA,EACrB;AACD;AAEO,SAAS,kBACf,QACA,OACkB;AAClB,QAAM,CAAC,YAAY,aAAa,QAAI,uBAA0B,IAAI;AAElE,8BAAU,MAAM;AACf,QAAI,CAAC,OAAQ;AAEb,UAAM,eAAe,MAAM;AAC1B,YAAM,QAAQ,MAAM,KAAK,CAAC,SAAS,OAAO,SAAS,IAAI,CAAC;AAExD,oBAAc,SAAS,IAAI;AAAA,IAC5B;AAEA,iBAAa;AAEb,WAAO,GAAG,mBAAmB,YAAY;AACzC,WAAO,GAAG,eAAe,YAAY;AAErC,WAAO,MAAM;AACZ,aAAO,IAAI,mBAAmB,YAAY;AAC1C,aAAO,IAAI,eAAe,YAAY;AAAA,IACvC;AAAA,EACD,GAAG,CAAC,QAAQ,KAAK,CAAC;AAElB,SAAO;AACR;AAEO,SAAS,mBAAmB,YAA4C;AAC9E,MAAI,eAAe,KAAM,QAAO;AAEhC,SAAO,UAAU,UAAU;AAC5B;","names":[]}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
// src/components/list-dropdown-menu/use-list.ts
|
|
1
2
|
import { List, ListOrdered, ListTodo } from "lucide-react";
|
|
2
3
|
import { useCallback, useEffect, useState } from "react";
|
|
3
|
-
|
|
4
|
+
var listIcons = {
|
|
4
5
|
bulletList: List,
|
|
5
6
|
orderedList: ListOrdered,
|
|
6
7
|
taskList: ListTodo
|
|
7
8
|
};
|
|
8
|
-
|
|
9
|
+
var listLabels = {
|
|
9
10
|
bulletList: "Bullet List",
|
|
10
11
|
orderedList: "Ordered List",
|
|
11
12
|
taskList: "Task List"
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
+
var listItemTypes = {
|
|
14
15
|
bulletList: "listItem",
|
|
15
16
|
orderedList: "listItem",
|
|
16
17
|
taskList: "taskItem"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/list-dropdown-menu/use-list.ts"],"sourcesContent":["import { List, ListOrdered, ListTodo } from 'lucide-react';\nimport { useCallback, useEffect, useState } from 'react';\n\nimport type { Editor } from '@tiptap/core';\nimport type { LucideIcon } from 'lucide-react';\n\nexport type ListType = 'bulletList' | 'orderedList' | 'taskList';\n\ntype IconComponent = LucideIcon;\n\nconst listIcons: Record<ListType, IconComponent> = {\n\tbulletList: List,\n\torderedList: ListOrdered,\n\ttaskList: ListTodo\n};\n\nconst listLabels: Record<ListType, string> = {\n\tbulletList: 'Bullet List',\n\torderedList: 'Ordered List',\n\ttaskList: 'Task List'\n};\n\nconst listItemTypes: Record<ListType, string> = {\n\tbulletList: 'listItem',\n\torderedList: 'listItem',\n\ttaskList: 'taskItem'\n};\n\nfunction canToggleList(editor: Editor | null): boolean {\n\tif (!editor || !editor.isEditable) return false;\n\n\treturn (\n\t\teditor.can().toggleList('bulletList', 'listItem') ||\n\t\teditor.can().clearNodes()\n\t);\n}\n\nexport function useList({\n\teditor,\n\ttype\n}: {\n\teditor: Editor | null;\n\ttype: ListType;\n}) {\n\tconst [isActive, setIsActive] = useState(false);\n\tconst [canToggle, setCanToggle] = useState(false);\n\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\n\t\tconst handleUpdate = () => {\n\t\t\tsetIsActive(editor.isActive(type));\n\t\t\tsetCanToggle(canToggleList(editor));\n\t\t};\n\n\t\thandleUpdate();\n\n\t\teditor.on('selectionUpdate', handleUpdate);\n\t\teditor.on('transaction', handleUpdate);\n\n\t\treturn () => {\n\t\t\teditor.off('selectionUpdate', handleUpdate);\n\t\t\teditor.off('transaction', handleUpdate);\n\t\t};\n\t}, [editor, type]);\n\n\tconst handleToggle = useCallback(() => {\n\t\tif (!editor || !editor.isEditable) return false;\n\n\t\tconst itemType = listItemTypes[type];\n\n\t\tif (editor.isActive(type)) {\n\t\t\t// Currently this list type → convert back to paragraph\n\t\t\treturn editor.chain().focus().clearNodes().run();\n\t\t}\n\n\t\t// clearNodes first to convert any block type to paragraph,\n\t\t// then toggle list\n\t\treturn editor.chain().focus().clearNodes().toggleList(type, itemType).run();\n\t}, [editor, type]);\n\n\treturn {\n\t\tisActive,\n\t\tcanToggle,\n\t\thandleToggle,\n\t\tlabel: listLabels[type],\n\t\tIcon: listIcons[type]\n\t};\n}\n\nexport function useActiveListType(\n\teditor: Editor | null,\n\ttypes: ListType[]\n): ListType | null {\n\tconst [activeType, setActiveType] = useState<ListType | null>(null);\n\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\n\t\tconst handleUpdate = () => {\n\t\t\tconst found = types.find((type) => editor.isActive(type));\n\n\t\t\tsetActiveType(found ?? null);\n\t\t};\n\n\t\thandleUpdate();\n\n\t\teditor.on('selectionUpdate', handleUpdate);\n\t\teditor.on('transaction', handleUpdate);\n\n\t\treturn () => {\n\t\t\teditor.off('selectionUpdate', handleUpdate);\n\t\t\teditor.off('transaction', handleUpdate);\n\t\t};\n\t}, [editor, types]);\n\n\treturn activeType;\n}\n\nexport function getListTriggerIcon(activeType: ListType | null): IconComponent {\n\tif (activeType === null) return List;\n\n\treturn listIcons[activeType];\n}\n"],"mappings":"AAAA,SAAS,MAAM,aAAa,gBAAgB;AAC5C,SAAS,aAAa,WAAW,gBAAgB;AASjD,
|
|
1
|
+
{"version":3,"sources":["../../../src/components/list-dropdown-menu/use-list.ts"],"sourcesContent":["import { List, ListOrdered, ListTodo } from 'lucide-react';\nimport { useCallback, useEffect, useState } from 'react';\n\nimport type { Editor } from '@tiptap/core';\nimport type { LucideIcon } from 'lucide-react';\n\nexport type ListType = 'bulletList' | 'orderedList' | 'taskList';\n\ntype IconComponent = LucideIcon;\n\nconst listIcons: Record<ListType, IconComponent> = {\n\tbulletList: List,\n\torderedList: ListOrdered,\n\ttaskList: ListTodo\n};\n\nconst listLabels: Record<ListType, string> = {\n\tbulletList: 'Bullet List',\n\torderedList: 'Ordered List',\n\ttaskList: 'Task List'\n};\n\nconst listItemTypes: Record<ListType, string> = {\n\tbulletList: 'listItem',\n\torderedList: 'listItem',\n\ttaskList: 'taskItem'\n};\n\nfunction canToggleList(editor: Editor | null): boolean {\n\tif (!editor || !editor.isEditable) return false;\n\n\treturn (\n\t\teditor.can().toggleList('bulletList', 'listItem') ||\n\t\teditor.can().clearNodes()\n\t);\n}\n\nexport function useList({\n\teditor,\n\ttype\n}: {\n\teditor: Editor | null;\n\ttype: ListType;\n}) {\n\tconst [isActive, setIsActive] = useState(false);\n\tconst [canToggle, setCanToggle] = useState(false);\n\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\n\t\tconst handleUpdate = () => {\n\t\t\tsetIsActive(editor.isActive(type));\n\t\t\tsetCanToggle(canToggleList(editor));\n\t\t};\n\n\t\thandleUpdate();\n\n\t\teditor.on('selectionUpdate', handleUpdate);\n\t\teditor.on('transaction', handleUpdate);\n\n\t\treturn () => {\n\t\t\teditor.off('selectionUpdate', handleUpdate);\n\t\t\teditor.off('transaction', handleUpdate);\n\t\t};\n\t}, [editor, type]);\n\n\tconst handleToggle = useCallback(() => {\n\t\tif (!editor || !editor.isEditable) return false;\n\n\t\tconst itemType = listItemTypes[type];\n\n\t\tif (editor.isActive(type)) {\n\t\t\t// Currently this list type → convert back to paragraph\n\t\t\treturn editor.chain().focus().clearNodes().run();\n\t\t}\n\n\t\t// clearNodes first to convert any block type to paragraph,\n\t\t// then toggle list\n\t\treturn editor.chain().focus().clearNodes().toggleList(type, itemType).run();\n\t}, [editor, type]);\n\n\treturn {\n\t\tisActive,\n\t\tcanToggle,\n\t\thandleToggle,\n\t\tlabel: listLabels[type],\n\t\tIcon: listIcons[type]\n\t};\n}\n\nexport function useActiveListType(\n\teditor: Editor | null,\n\ttypes: ListType[]\n): ListType | null {\n\tconst [activeType, setActiveType] = useState<ListType | null>(null);\n\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\n\t\tconst handleUpdate = () => {\n\t\t\tconst found = types.find((type) => editor.isActive(type));\n\n\t\t\tsetActiveType(found ?? null);\n\t\t};\n\n\t\thandleUpdate();\n\n\t\teditor.on('selectionUpdate', handleUpdate);\n\t\teditor.on('transaction', handleUpdate);\n\n\t\treturn () => {\n\t\t\teditor.off('selectionUpdate', handleUpdate);\n\t\t\teditor.off('transaction', handleUpdate);\n\t\t};\n\t}, [editor, types]);\n\n\treturn activeType;\n}\n\nexport function getListTriggerIcon(activeType: ListType | null): IconComponent {\n\tif (activeType === null) return List;\n\n\treturn listIcons[activeType];\n}\n"],"mappings":";AAAA,SAAS,MAAM,aAAa,gBAAgB;AAC5C,SAAS,aAAa,WAAW,gBAAgB;AASjD,IAAM,YAA6C;AAAA,EAClD,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,UAAU;AACX;AAEA,IAAM,aAAuC;AAAA,EAC5C,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,UAAU;AACX;AAEA,IAAM,gBAA0C;AAAA,EAC/C,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,UAAU;AACX;AAEA,SAAS,cAAc,QAAgC;AACtD,MAAI,CAAC,UAAU,CAAC,OAAO,WAAY,QAAO;AAE1C,SACC,OAAO,IAAI,EAAE,WAAW,cAAc,UAAU,KAChD,OAAO,IAAI,EAAE,WAAW;AAE1B;AAEO,SAAS,QAAQ;AAAA,EACvB;AAAA,EACA;AACD,GAGG;AACF,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK;AAC9C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAEhD,YAAU,MAAM;AACf,QAAI,CAAC,OAAQ;AAEb,UAAM,eAAe,MAAM;AAC1B,kBAAY,OAAO,SAAS,IAAI,CAAC;AACjC,mBAAa,cAAc,MAAM,CAAC;AAAA,IACnC;AAEA,iBAAa;AAEb,WAAO,GAAG,mBAAmB,YAAY;AACzC,WAAO,GAAG,eAAe,YAAY;AAErC,WAAO,MAAM;AACZ,aAAO,IAAI,mBAAmB,YAAY;AAC1C,aAAO,IAAI,eAAe,YAAY;AAAA,IACvC;AAAA,EACD,GAAG,CAAC,QAAQ,IAAI,CAAC;AAEjB,QAAM,eAAe,YAAY,MAAM;AACtC,QAAI,CAAC,UAAU,CAAC,OAAO,WAAY,QAAO;AAE1C,UAAM,WAAW,cAAc,IAAI;AAEnC,QAAI,OAAO,SAAS,IAAI,GAAG;AAE1B,aAAO,OAAO,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI;AAAA,IAChD;AAIA,WAAO,OAAO,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,MAAM,QAAQ,EAAE,IAAI;AAAA,EAC3E,GAAG,CAAC,QAAQ,IAAI,CAAC;AAEjB,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,WAAW,IAAI;AAAA,IACtB,MAAM,UAAU,IAAI;AAAA,EACrB;AACD;AAEO,SAAS,kBACf,QACA,OACkB;AAClB,QAAM,CAAC,YAAY,aAAa,IAAI,SAA0B,IAAI;AAElE,YAAU,MAAM;AACf,QAAI,CAAC,OAAQ;AAEb,UAAM,eAAe,MAAM;AAC1B,YAAM,QAAQ,MAAM,KAAK,CAAC,SAAS,OAAO,SAAS,IAAI,CAAC;AAExD,oBAAc,SAAS,IAAI;AAAA,IAC5B;AAEA,iBAAa;AAEb,WAAO,GAAG,mBAAmB,YAAY;AACzC,WAAO,GAAG,eAAe,YAAY;AAErC,WAAO,MAAM;AACZ,aAAO,IAAI,mBAAmB,YAAY;AAC1C,aAAO,IAAI,eAAe,YAAY;AAAA,IACvC;AAAA,EACD,GAAG,CAAC,QAAQ,KAAK,CAAC;AAElB,SAAO;AACR;AAEO,SAAS,mBAAmB,YAA4C;AAC9E,MAAI,eAAe,KAAM,QAAO;AAEhC,SAAO,UAAU,UAAU;AAC5B;","names":[]}
|
|
@@ -17,16 +17,18 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/components/mark-button/mark-button.tsx
|
|
20
22
|
var mark_button_exports = {};
|
|
21
23
|
__export(mark_button_exports, {
|
|
22
24
|
MarkButton: () => MarkButton
|
|
23
25
|
});
|
|
24
26
|
module.exports = __toCommonJS(mark_button_exports);
|
|
25
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
27
|
var import_react = require("react");
|
|
27
|
-
var import_use_mark = require("./use-mark");
|
|
28
|
-
var import_button = require("../ui/button");
|
|
29
|
-
|
|
28
|
+
var import_use_mark = require("./use-mark.cjs");
|
|
29
|
+
var import_button = require("../ui/button.cjs");
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
var MarkButton = (0, import_react.forwardRef)(
|
|
30
32
|
({ editor, type, onClick, ...buttonProps }, ref) => {
|
|
31
33
|
const { isActive, canToggle, handleToggle, label, Icon } = (0, import_use_mark.useMark)({
|
|
32
34
|
editor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/mark-button/mark-button.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, useCallback } from 'react';\n\nimport { useMark } from './use-mark';\nimport { Button } from '../ui/button';\n\nimport type { MarkType } from './use-mark';\nimport type { Editor } from '@tiptap/core';\n\nexport interface MarkButtonProps extends Omit<\n\tReact.ButtonHTMLAttributes<HTMLButtonElement>,\n\t'type'\n> {\n\teditor: Editor | null;\n\ttype: MarkType;\n}\n\nexport const MarkButton = forwardRef<HTMLButtonElement, MarkButtonProps>(\n\t({ editor, type, onClick, ...buttonProps }, ref) => {\n\t\tconst { isActive, canToggle, handleToggle, label, Icon } = useMark({\n\t\t\teditor,\n\t\t\ttype\n\t\t});\n\n\t\tconst handleClick = useCallback(\n\t\t\t(event: React.MouseEvent<HTMLButtonElement>) => {\n\t\t\t\tonClick?.(event);\n\n\t\t\t\tif (event.defaultPrevented) return;\n\n\t\t\t\thandleToggle();\n\t\t\t},\n\t\t\t[handleToggle, onClick]\n\t\t);\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\tref={ref}\n\t\t\t\taria-label={label}\n\t\t\t\taria-pressed={isActive}\n\t\t\t\tdata-active-state={isActive ? 'on' : 'off'}\n\t\t\t\tdisabled={!canToggle}\n\t\t\t\tsize=\"icon\"\n\t\t\t\ttabIndex={-1}\n\t\t\t\ttype=\"button\"\n\t\t\t\tvariant=\"ghost\"\n\t\t\t\tonClick={handleClick}\n\t\t\t\t{...buttonProps}\n\t\t\t>\n\t\t\t\t<Icon\n\t\t\t\t\tclassName={\n\t\t\t\t\t\tisActive ? 'nt:text-[var(--tt-brand-color-500)]' : undefined\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</Button>\n\t\t);\n\t}\n);\n\nMarkButton.displayName = 'MarkButton';\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/mark-button/mark-button.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, useCallback } from 'react';\n\nimport { useMark } from './use-mark.js';\nimport { Button } from '../ui/button.js';\n\nimport type { MarkType } from './use-mark.js';\nimport type { Editor } from '@tiptap/core';\n\nexport interface MarkButtonProps extends Omit<\n\tReact.ButtonHTMLAttributes<HTMLButtonElement>,\n\t'type'\n> {\n\teditor: Editor | null;\n\ttype: MarkType;\n}\n\nexport const MarkButton = forwardRef<HTMLButtonElement, MarkButtonProps>(\n\t({ editor, type, onClick, ...buttonProps }, ref) => {\n\t\tconst { isActive, canToggle, handleToggle, label, Icon } = useMark({\n\t\t\teditor,\n\t\t\ttype\n\t\t});\n\n\t\tconst handleClick = useCallback(\n\t\t\t(event: React.MouseEvent<HTMLButtonElement>) => {\n\t\t\t\tonClick?.(event);\n\n\t\t\t\tif (event.defaultPrevented) return;\n\n\t\t\t\thandleToggle();\n\t\t\t},\n\t\t\t[handleToggle, onClick]\n\t\t);\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\tref={ref}\n\t\t\t\taria-label={label}\n\t\t\t\taria-pressed={isActive}\n\t\t\t\tdata-active-state={isActive ? 'on' : 'off'}\n\t\t\t\tdisabled={!canToggle}\n\t\t\t\tsize=\"icon\"\n\t\t\t\ttabIndex={-1}\n\t\t\t\ttype=\"button\"\n\t\t\t\tvariant=\"ghost\"\n\t\t\t\tonClick={handleClick}\n\t\t\t\t{...buttonProps}\n\t\t\t>\n\t\t\t\t<Icon\n\t\t\t\t\tclassName={\n\t\t\t\t\t\tisActive ? 'nt:text-[var(--tt-brand-color-500)]' : undefined\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</Button>\n\t\t);\n\t}\n);\n\nMarkButton.displayName = 'MarkButton';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAwC;AAExC,sBAAwB;AACxB,oBAAuB;AA6CnB;AAhCG,IAAM,iBAAa;AAAA,EACzB,CAAC,EAAE,QAAQ,MAAM,SAAS,GAAG,YAAY,GAAG,QAAQ;AACnD,UAAM,EAAE,UAAU,WAAW,cAAc,OAAO,KAAK,QAAI,yBAAQ;AAAA,MAClE;AAAA,MACA;AAAA,IACD,CAAC;AAED,UAAM,kBAAc;AAAA,MACnB,CAAC,UAA+C;AAC/C,kBAAU,KAAK;AAEf,YAAI,MAAM,iBAAkB;AAE5B,qBAAa;AAAA,MACd;AAAA,MACA,CAAC,cAAc,OAAO;AAAA,IACvB;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA,cAAY;AAAA,QACZ,gBAAc;AAAA,QACd,qBAAmB,WAAW,OAAO;AAAA,QACrC,UAAU,CAAC;AAAA,QACX,MAAK;AAAA,QACL,UAAU;AAAA,QACV,MAAK;AAAA,QACL,SAAQ;AAAA,QACR,SAAS;AAAA,QACR,GAAG;AAAA,QAEJ;AAAA,UAAC;AAAA;AAAA,YACA,WACC,WAAW,wCAAwC;AAAA;AAAA,QAErD;AAAA;AAAA,IACD;AAAA,EAEF;AACD;AAEA,WAAW,cAAc;","names":[]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
// src/components/mark-button/mark-button.tsx
|
|
3
4
|
import { forwardRef, useCallback } from "react";
|
|
4
|
-
import { useMark } from "./use-mark";
|
|
5
|
-
import { Button } from "../ui/button";
|
|
6
|
-
|
|
5
|
+
import { useMark } from "./use-mark.mjs";
|
|
6
|
+
import { Button } from "../ui/button.mjs";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
var MarkButton = forwardRef(
|
|
7
9
|
({ editor, type, onClick, ...buttonProps }, ref) => {
|
|
8
10
|
const { isActive, canToggle, handleToggle, label, Icon } = useMark({
|
|
9
11
|
editor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/mark-button/mark-button.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, useCallback } from 'react';\n\nimport { useMark } from './use-mark';\nimport { Button } from '../ui/button';\n\nimport type { MarkType } from './use-mark';\nimport type { Editor } from '@tiptap/core';\n\nexport interface MarkButtonProps extends Omit<\n\tReact.ButtonHTMLAttributes<HTMLButtonElement>,\n\t'type'\n> {\n\teditor: Editor | null;\n\ttype: MarkType;\n}\n\nexport const MarkButton = forwardRef<HTMLButtonElement, MarkButtonProps>(\n\t({ editor, type, onClick, ...buttonProps }, ref) => {\n\t\tconst { isActive, canToggle, handleToggle, label, Icon } = useMark({\n\t\t\teditor,\n\t\t\ttype\n\t\t});\n\n\t\tconst handleClick = useCallback(\n\t\t\t(event: React.MouseEvent<HTMLButtonElement>) => {\n\t\t\t\tonClick?.(event);\n\n\t\t\t\tif (event.defaultPrevented) return;\n\n\t\t\t\thandleToggle();\n\t\t\t},\n\t\t\t[handleToggle, onClick]\n\t\t);\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\tref={ref}\n\t\t\t\taria-label={label}\n\t\t\t\taria-pressed={isActive}\n\t\t\t\tdata-active-state={isActive ? 'on' : 'off'}\n\t\t\t\tdisabled={!canToggle}\n\t\t\t\tsize=\"icon\"\n\t\t\t\ttabIndex={-1}\n\t\t\t\ttype=\"button\"\n\t\t\t\tvariant=\"ghost\"\n\t\t\t\tonClick={handleClick}\n\t\t\t\t{...buttonProps}\n\t\t\t>\n\t\t\t\t<Icon\n\t\t\t\t\tclassName={\n\t\t\t\t\t\tisActive ? 'nt:text-[var(--tt-brand-color-500)]' : undefined\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</Button>\n\t\t);\n\t}\n);\n\nMarkButton.displayName = 'MarkButton';\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/mark-button/mark-button.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, useCallback } from 'react';\n\nimport { useMark } from './use-mark.js';\nimport { Button } from '../ui/button.js';\n\nimport type { MarkType } from './use-mark.js';\nimport type { Editor } from '@tiptap/core';\n\nexport interface MarkButtonProps extends Omit<\n\tReact.ButtonHTMLAttributes<HTMLButtonElement>,\n\t'type'\n> {\n\teditor: Editor | null;\n\ttype: MarkType;\n}\n\nexport const MarkButton = forwardRef<HTMLButtonElement, MarkButtonProps>(\n\t({ editor, type, onClick, ...buttonProps }, ref) => {\n\t\tconst { isActive, canToggle, handleToggle, label, Icon } = useMark({\n\t\t\teditor,\n\t\t\ttype\n\t\t});\n\n\t\tconst handleClick = useCallback(\n\t\t\t(event: React.MouseEvent<HTMLButtonElement>) => {\n\t\t\t\tonClick?.(event);\n\n\t\t\t\tif (event.defaultPrevented) return;\n\n\t\t\t\thandleToggle();\n\t\t\t},\n\t\t\t[handleToggle, onClick]\n\t\t);\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\tref={ref}\n\t\t\t\taria-label={label}\n\t\t\t\taria-pressed={isActive}\n\t\t\t\tdata-active-state={isActive ? 'on' : 'off'}\n\t\t\t\tdisabled={!canToggle}\n\t\t\t\tsize=\"icon\"\n\t\t\t\ttabIndex={-1}\n\t\t\t\ttype=\"button\"\n\t\t\t\tvariant=\"ghost\"\n\t\t\t\tonClick={handleClick}\n\t\t\t\t{...buttonProps}\n\t\t\t>\n\t\t\t\t<Icon\n\t\t\t\t\tclassName={\n\t\t\t\t\t\tisActive ? 'nt:text-[var(--tt-brand-color-500)]' : undefined\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</Button>\n\t\t);\n\t}\n);\n\nMarkButton.displayName = 'MarkButton';\n"],"mappings":";;;AAEA,SAAS,YAAY,mBAAmB;AAExC,SAAS,eAAe;AACxB,SAAS,cAAc;AA6CnB;AAhCG,IAAM,aAAa;AAAA,EACzB,CAAC,EAAE,QAAQ,MAAM,SAAS,GAAG,YAAY,GAAG,QAAQ;AACnD,UAAM,EAAE,UAAU,WAAW,cAAc,OAAO,KAAK,IAAI,QAAQ;AAAA,MAClE;AAAA,MACA;AAAA,IACD,CAAC;AAED,UAAM,cAAc;AAAA,MACnB,CAAC,UAA+C;AAC/C,kBAAU,KAAK;AAEf,YAAI,MAAM,iBAAkB;AAE5B,qBAAa;AAAA,MACd;AAAA,MACA,CAAC,cAAc,OAAO;AAAA,IACvB;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA,cAAY;AAAA,QACZ,gBAAc;AAAA,QACd,qBAAmB,WAAW,OAAO;AAAA,QACrC,UAAU,CAAC;AAAA,QACX,MAAK;AAAA,QACL,UAAU;AAAA,QACV,MAAK;AAAA,QACL,SAAQ;AAAA,QACR,SAAS;AAAA,QACR,GAAG;AAAA,QAEJ;AAAA,UAAC;AAAA;AAAA,YACA,WACC,WAAW,wCAAwC;AAAA;AAAA,QAErD;AAAA;AAAA,IACD;AAAA,EAEF;AACD;AAEA,WAAW,cAAc;","names":[]}
|
|
@@ -16,6 +16,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/mark-button/use-mark.ts
|
|
19
21
|
var use_mark_exports = {};
|
|
20
22
|
__export(use_mark_exports, {
|
|
21
23
|
useMark: () => useMark
|
|
@@ -23,13 +25,13 @@ __export(use_mark_exports, {
|
|
|
23
25
|
module.exports = __toCommonJS(use_mark_exports);
|
|
24
26
|
var import_lucide_react = require("lucide-react");
|
|
25
27
|
var import_react = require("react");
|
|
26
|
-
|
|
28
|
+
var markLabels = {
|
|
27
29
|
bold: "Bold",
|
|
28
30
|
italic: "Italic",
|
|
29
31
|
strike: "Strikethrough",
|
|
30
32
|
code: "Code"
|
|
31
33
|
};
|
|
32
|
-
|
|
34
|
+
var markIcons = {
|
|
33
35
|
bold: import_lucide_react.Bold,
|
|
34
36
|
italic: import_lucide_react.Italic,
|
|
35
37
|
strike: import_lucide_react.Strikethrough,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/mark-button/use-mark.ts"],"sourcesContent":["import { Bold, Code, Italic, Strikethrough } from 'lucide-react';\nimport { useCallback, useEffect, useState } from 'react';\n\nimport type { Editor } from '@tiptap/core';\nimport type { LucideIcon } from 'lucide-react';\n\nexport type MarkType = 'bold' | 'italic' | 'strike' | 'code';\n\nexport interface UseMarkConfig {\n\teditor: Editor | null;\n\ttype: MarkType;\n}\n\nconst markLabels: Record<MarkType, string> = {\n\tbold: 'Bold',\n\titalic: 'Italic',\n\tstrike: 'Strikethrough',\n\tcode: 'Code'\n};\n\nconst markIcons: Record<MarkType, LucideIcon> = {\n\tbold: Bold,\n\titalic: Italic,\n\tstrike: Strikethrough,\n\tcode: Code\n};\n\nexport function useMark({ editor, type }: UseMarkConfig) {\n\tconst [isActive, setIsActive] = useState(false);\n\tconst [canToggle, setCanToggle] = useState(false);\n\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\n\t\tconst handleUpdate = () => {\n\t\t\tsetIsActive(editor.isActive(type));\n\t\t\tsetCanToggle(editor.isEditable && editor.can().toggleMark(type));\n\t\t};\n\n\t\thandleUpdate();\n\n\t\teditor.on('selectionUpdate', handleUpdate);\n\t\teditor.on('transaction', handleUpdate);\n\n\t\treturn () => {\n\t\t\teditor.off('selectionUpdate', handleUpdate);\n\t\t\teditor.off('transaction', handleUpdate);\n\t\t};\n\t}, [editor, type]);\n\n\tconst handleToggle = useCallback(() => {\n\t\tif (!editor || !editor.isEditable) return false;\n\n\t\treturn editor.chain().focus().toggleMark(type).run();\n\t}, [editor, type]);\n\n\treturn {\n\t\tisActive,\n\t\tcanToggle,\n\t\thandleToggle,\n\t\tlabel: markLabels[type],\n\t\tIcon: markIcons[type]\n\t};\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/mark-button/use-mark.ts"],"sourcesContent":["import { Bold, Code, Italic, Strikethrough } from 'lucide-react';\nimport { useCallback, useEffect, useState } from 'react';\n\nimport type { Editor } from '@tiptap/core';\nimport type { LucideIcon } from 'lucide-react';\n\nexport type MarkType = 'bold' | 'italic' | 'strike' | 'code';\n\nexport interface UseMarkConfig {\n\teditor: Editor | null;\n\ttype: MarkType;\n}\n\nconst markLabels: Record<MarkType, string> = {\n\tbold: 'Bold',\n\titalic: 'Italic',\n\tstrike: 'Strikethrough',\n\tcode: 'Code'\n};\n\nconst markIcons: Record<MarkType, LucideIcon> = {\n\tbold: Bold,\n\titalic: Italic,\n\tstrike: Strikethrough,\n\tcode: Code\n};\n\nexport function useMark({ editor, type }: UseMarkConfig) {\n\tconst [isActive, setIsActive] = useState(false);\n\tconst [canToggle, setCanToggle] = useState(false);\n\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\n\t\tconst handleUpdate = () => {\n\t\t\tsetIsActive(editor.isActive(type));\n\t\t\tsetCanToggle(editor.isEditable && editor.can().toggleMark(type));\n\t\t};\n\n\t\thandleUpdate();\n\n\t\teditor.on('selectionUpdate', handleUpdate);\n\t\teditor.on('transaction', handleUpdate);\n\n\t\treturn () => {\n\t\t\teditor.off('selectionUpdate', handleUpdate);\n\t\t\teditor.off('transaction', handleUpdate);\n\t\t};\n\t}, [editor, type]);\n\n\tconst handleToggle = useCallback(() => {\n\t\tif (!editor || !editor.isEditable) return false;\n\n\t\treturn editor.chain().focus().toggleMark(type).run();\n\t}, [editor, type]);\n\n\treturn {\n\t\tisActive,\n\t\tcanToggle,\n\t\thandleToggle,\n\t\tlabel: markLabels[type],\n\t\tIcon: markIcons[type]\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAkD;AAClD,mBAAiD;AAYjD,IAAM,aAAuC;AAAA,EAC5C,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AACP;AAEA,IAAM,YAA0C;AAAA,EAC/C,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AACP;AAEO,SAAS,QAAQ,EAAE,QAAQ,KAAK,GAAkB;AACxD,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAS,KAAK;AAC9C,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,KAAK;AAEhD,8BAAU,MAAM;AACf,QAAI,CAAC,OAAQ;AAEb,UAAM,eAAe,MAAM;AAC1B,kBAAY,OAAO,SAAS,IAAI,CAAC;AACjC,mBAAa,OAAO,cAAc,OAAO,IAAI,EAAE,WAAW,IAAI,CAAC;AAAA,IAChE;AAEA,iBAAa;AAEb,WAAO,GAAG,mBAAmB,YAAY;AACzC,WAAO,GAAG,eAAe,YAAY;AAErC,WAAO,MAAM;AACZ,aAAO,IAAI,mBAAmB,YAAY;AAC1C,aAAO,IAAI,eAAe,YAAY;AAAA,IACvC;AAAA,EACD,GAAG,CAAC,QAAQ,IAAI,CAAC;AAEjB,QAAM,mBAAe,0BAAY,MAAM;AACtC,QAAI,CAAC,UAAU,CAAC,OAAO,WAAY,QAAO;AAE1C,WAAO,OAAO,MAAM,EAAE,MAAM,EAAE,WAAW,IAAI,EAAE,IAAI;AAAA,EACpD,GAAG,CAAC,QAAQ,IAAI,CAAC;AAEjB,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,WAAW,IAAI;AAAA,IACtB,MAAM,UAAU,IAAI;AAAA,EACrB;AACD;","names":[]}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
// src/components/mark-button/use-mark.ts
|
|
1
2
|
import { Bold, Code, Italic, Strikethrough } from "lucide-react";
|
|
2
3
|
import { useCallback, useEffect, useState } from "react";
|
|
3
|
-
|
|
4
|
+
var markLabels = {
|
|
4
5
|
bold: "Bold",
|
|
5
6
|
italic: "Italic",
|
|
6
7
|
strike: "Strikethrough",
|
|
7
8
|
code: "Code"
|
|
8
9
|
};
|
|
9
|
-
|
|
10
|
+
var markIcons = {
|
|
10
11
|
bold: Bold,
|
|
11
12
|
italic: Italic,
|
|
12
13
|
strike: Strikethrough,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/mark-button/use-mark.ts"],"sourcesContent":["import { Bold, Code, Italic, Strikethrough } from 'lucide-react';\nimport { useCallback, useEffect, useState } from 'react';\n\nimport type { Editor } from '@tiptap/core';\nimport type { LucideIcon } from 'lucide-react';\n\nexport type MarkType = 'bold' | 'italic' | 'strike' | 'code';\n\nexport interface UseMarkConfig {\n\teditor: Editor | null;\n\ttype: MarkType;\n}\n\nconst markLabels: Record<MarkType, string> = {\n\tbold: 'Bold',\n\titalic: 'Italic',\n\tstrike: 'Strikethrough',\n\tcode: 'Code'\n};\n\nconst markIcons: Record<MarkType, LucideIcon> = {\n\tbold: Bold,\n\titalic: Italic,\n\tstrike: Strikethrough,\n\tcode: Code\n};\n\nexport function useMark({ editor, type }: UseMarkConfig) {\n\tconst [isActive, setIsActive] = useState(false);\n\tconst [canToggle, setCanToggle] = useState(false);\n\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\n\t\tconst handleUpdate = () => {\n\t\t\tsetIsActive(editor.isActive(type));\n\t\t\tsetCanToggle(editor.isEditable && editor.can().toggleMark(type));\n\t\t};\n\n\t\thandleUpdate();\n\n\t\teditor.on('selectionUpdate', handleUpdate);\n\t\teditor.on('transaction', handleUpdate);\n\n\t\treturn () => {\n\t\t\teditor.off('selectionUpdate', handleUpdate);\n\t\t\teditor.off('transaction', handleUpdate);\n\t\t};\n\t}, [editor, type]);\n\n\tconst handleToggle = useCallback(() => {\n\t\tif (!editor || !editor.isEditable) return false;\n\n\t\treturn editor.chain().focus().toggleMark(type).run();\n\t}, [editor, type]);\n\n\treturn {\n\t\tisActive,\n\t\tcanToggle,\n\t\thandleToggle,\n\t\tlabel: markLabels[type],\n\t\tIcon: markIcons[type]\n\t};\n}\n"],"mappings":"AAAA,SAAS,MAAM,MAAM,QAAQ,qBAAqB;AAClD,SAAS,aAAa,WAAW,gBAAgB;AAYjD,
|
|
1
|
+
{"version":3,"sources":["../../../src/components/mark-button/use-mark.ts"],"sourcesContent":["import { Bold, Code, Italic, Strikethrough } from 'lucide-react';\nimport { useCallback, useEffect, useState } from 'react';\n\nimport type { Editor } from '@tiptap/core';\nimport type { LucideIcon } from 'lucide-react';\n\nexport type MarkType = 'bold' | 'italic' | 'strike' | 'code';\n\nexport interface UseMarkConfig {\n\teditor: Editor | null;\n\ttype: MarkType;\n}\n\nconst markLabels: Record<MarkType, string> = {\n\tbold: 'Bold',\n\titalic: 'Italic',\n\tstrike: 'Strikethrough',\n\tcode: 'Code'\n};\n\nconst markIcons: Record<MarkType, LucideIcon> = {\n\tbold: Bold,\n\titalic: Italic,\n\tstrike: Strikethrough,\n\tcode: Code\n};\n\nexport function useMark({ editor, type }: UseMarkConfig) {\n\tconst [isActive, setIsActive] = useState(false);\n\tconst [canToggle, setCanToggle] = useState(false);\n\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\n\t\tconst handleUpdate = () => {\n\t\t\tsetIsActive(editor.isActive(type));\n\t\t\tsetCanToggle(editor.isEditable && editor.can().toggleMark(type));\n\t\t};\n\n\t\thandleUpdate();\n\n\t\teditor.on('selectionUpdate', handleUpdate);\n\t\teditor.on('transaction', handleUpdate);\n\n\t\treturn () => {\n\t\t\teditor.off('selectionUpdate', handleUpdate);\n\t\t\teditor.off('transaction', handleUpdate);\n\t\t};\n\t}, [editor, type]);\n\n\tconst handleToggle = useCallback(() => {\n\t\tif (!editor || !editor.isEditable) return false;\n\n\t\treturn editor.chain().focus().toggleMark(type).run();\n\t}, [editor, type]);\n\n\treturn {\n\t\tisActive,\n\t\tcanToggle,\n\t\thandleToggle,\n\t\tlabel: markLabels[type],\n\t\tIcon: markIcons[type]\n\t};\n}\n"],"mappings":";AAAA,SAAS,MAAM,MAAM,QAAQ,qBAAqB;AAClD,SAAS,aAAa,WAAW,gBAAgB;AAYjD,IAAM,aAAuC;AAAA,EAC5C,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AACP;AAEA,IAAM,YAA0C;AAAA,EAC/C,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AACP;AAEO,SAAS,QAAQ,EAAE,QAAQ,KAAK,GAAkB;AACxD,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK;AAC9C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAEhD,YAAU,MAAM;AACf,QAAI,CAAC,OAAQ;AAEb,UAAM,eAAe,MAAM;AAC1B,kBAAY,OAAO,SAAS,IAAI,CAAC;AACjC,mBAAa,OAAO,cAAc,OAAO,IAAI,EAAE,WAAW,IAAI,CAAC;AAAA,IAChE;AAEA,iBAAa;AAEb,WAAO,GAAG,mBAAmB,YAAY;AACzC,WAAO,GAAG,eAAe,YAAY;AAErC,WAAO,MAAM;AACZ,aAAO,IAAI,mBAAmB,YAAY;AAC1C,aAAO,IAAI,eAAe,YAAY;AAAA,IACvC;AAAA,EACD,GAAG,CAAC,QAAQ,IAAI,CAAC;AAEjB,QAAM,eAAe,YAAY,MAAM;AACtC,QAAI,CAAC,UAAU,CAAC,OAAO,WAAY,QAAO;AAE1C,WAAO,OAAO,MAAM,EAAE,MAAM,EAAE,WAAW,IAAI,EAAE,IAAI;AAAA,EACpD,GAAG,CAAC,QAAQ,IAAI,CAAC;AAEjB,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,WAAW,IAAI;AAAA,IACtB,MAAM,UAAU,IAAI;AAAA,EACrB;AACD;","names":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
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/filter-slash-items.ts
|
|
21
|
+
var filter_slash_items_exports = {};
|
|
22
|
+
__export(filter_slash_items_exports, {
|
|
23
|
+
filterSlashItems: () => filterSlashItems
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(filter_slash_items_exports);
|
|
26
|
+
function filterSlashItems(items, query) {
|
|
27
|
+
const needle = query.trim().toLowerCase();
|
|
28
|
+
if (needle === "") return items;
|
|
29
|
+
const matches = items.filter((item) => {
|
|
30
|
+
if (item.title.toLowerCase().includes(needle)) return true;
|
|
31
|
+
if (item.subtext?.toLowerCase().includes(needle)) return true;
|
|
32
|
+
return item.keywords?.some((kw) => kw.toLowerCase().includes(needle)) ?? false;
|
|
33
|
+
});
|
|
34
|
+
const rankOf = (title) => {
|
|
35
|
+
const lower = title.toLowerCase();
|
|
36
|
+
if (lower === needle) return 0;
|
|
37
|
+
if (lower.startsWith(needle)) return 1;
|
|
38
|
+
return 2;
|
|
39
|
+
};
|
|
40
|
+
return matches.map((item, index) => ({ item, index, rank: rankOf(item.title) })).sort((a, b) => a.rank - b.rank || a.index - b.index).map(({ item }) => item);
|
|
41
|
+
}
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
filterSlashItems
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=filter-slash-items.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/slash-dropdown-menu/filter-slash-items.ts"],"sourcesContent":["import type { SlashItem } from './types.js';\n\n/**\n * Filter and rank slash-menu items against a user-typed query.\n *\n * Match rule: an item matches when the lowercased query is a substring of the\n * item's lowercased title, subtext, or any keyword.\n *\n * Ranking (stable): exact title match > title startsWith > everything else in\n * original order.\n */\nexport function filterSlashItems(\n\titems: SlashItem[],\n\tquery: string\n): SlashItem[] {\n\tconst needle = query.trim().toLowerCase();\n\n\tif (needle === '') return items;\n\n\tconst matches = items.filter((item) => {\n\t\tif (item.title.toLowerCase().includes(needle)) return true;\n\n\t\tif (item.subtext?.toLowerCase().includes(needle)) return true;\n\n\t\treturn (\n\t\t\titem.keywords?.some((kw) => kw.toLowerCase().includes(needle)) ?? false\n\t\t);\n\t});\n\n\tconst rankOf = (title: string) => {\n\t\tconst lower = title.toLowerCase();\n\n\t\tif (lower === needle) return 0;\n\n\t\tif (lower.startsWith(needle)) return 1;\n\n\t\treturn 2;\n\t};\n\n\treturn matches\n\t\t.map((item, index) => ({ item, index, rank: rankOf(item.title) }))\n\t\t.sort((a, b) => a.rank - b.rank || a.index - b.index)\n\t\t.map(({ item }) => item);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWO,SAAS,iBACf,OACA,OACc;AACd,QAAM,SAAS,MAAM,KAAK,EAAE,YAAY;AAExC,MAAI,WAAW,GAAI,QAAO;AAE1B,QAAM,UAAU,MAAM,OAAO,CAAC,SAAS;AACtC,QAAI,KAAK,MAAM,YAAY,EAAE,SAAS,MAAM,EAAG,QAAO;AAEtD,QAAI,KAAK,SAAS,YAAY,EAAE,SAAS,MAAM,EAAG,QAAO;AAEzD,WACC,KAAK,UAAU,KAAK,CAAC,OAAO,GAAG,YAAY,EAAE,SAAS,MAAM,CAAC,KAAK;AAAA,EAEpE,CAAC;AAED,QAAM,SAAS,CAAC,UAAkB;AACjC,UAAM,QAAQ,MAAM,YAAY;AAEhC,QAAI,UAAU,OAAQ,QAAO;AAE7B,QAAI,MAAM,WAAW,MAAM,EAAG,QAAO;AAErC,WAAO;AAAA,EACR;AAEA,SAAO,QACL,IAAI,CAAC,MAAM,WAAW,EAAE,MAAM,OAAO,MAAM,OAAO,KAAK,KAAK,EAAE,EAAE,EAChE,KAAK,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EACnD,IAAI,CAAC,EAAE,KAAK,MAAM,IAAI;AACzB;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SlashItem } from './types.cjs';
|
|
2
|
+
import '@tiptap/react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Filter and rank slash-menu items against a user-typed query.
|
|
6
|
+
*
|
|
7
|
+
* Match rule: an item matches when the lowercased query is a substring of the
|
|
8
|
+
* item's lowercased title, subtext, or any keyword.
|
|
9
|
+
*
|
|
10
|
+
* Ranking (stable): exact title match > title startsWith > everything else in
|
|
11
|
+
* original order.
|
|
12
|
+
*/
|
|
13
|
+
declare function filterSlashItems(items: SlashItem[], query: string): SlashItem[];
|
|
14
|
+
|
|
15
|
+
export { filterSlashItems };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SlashItem } from './types.js';
|
|
2
|
+
import '@tiptap/react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Filter and rank slash-menu items against a user-typed query.
|
|
6
|
+
*
|
|
7
|
+
* Match rule: an item matches when the lowercased query is a substring of the
|
|
8
|
+
* item's lowercased title, subtext, or any keyword.
|
|
9
|
+
*
|
|
10
|
+
* Ranking (stable): exact title match > title startsWith > everything else in
|
|
11
|
+
* original order.
|
|
12
|
+
*/
|
|
13
|
+
declare function filterSlashItems(items: SlashItem[], query: string): SlashItem[];
|
|
14
|
+
|
|
15
|
+
export { filterSlashItems };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/components/slash-dropdown-menu/filter-slash-items.ts
|
|
2
|
+
function filterSlashItems(items, query) {
|
|
3
|
+
const needle = query.trim().toLowerCase();
|
|
4
|
+
if (needle === "") return items;
|
|
5
|
+
const matches = items.filter((item) => {
|
|
6
|
+
if (item.title.toLowerCase().includes(needle)) return true;
|
|
7
|
+
if (item.subtext?.toLowerCase().includes(needle)) return true;
|
|
8
|
+
return item.keywords?.some((kw) => kw.toLowerCase().includes(needle)) ?? false;
|
|
9
|
+
});
|
|
10
|
+
const rankOf = (title) => {
|
|
11
|
+
const lower = title.toLowerCase();
|
|
12
|
+
if (lower === needle) return 0;
|
|
13
|
+
if (lower.startsWith(needle)) return 1;
|
|
14
|
+
return 2;
|
|
15
|
+
};
|
|
16
|
+
return matches.map((item, index) => ({ item, index, rank: rankOf(item.title) })).sort((a, b) => a.rank - b.rank || a.index - b.index).map(({ item }) => item);
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
filterSlashItems
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=filter-slash-items.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/slash-dropdown-menu/filter-slash-items.ts"],"sourcesContent":["import type { SlashItem } from './types.js';\n\n/**\n * Filter and rank slash-menu items against a user-typed query.\n *\n * Match rule: an item matches when the lowercased query is a substring of the\n * item's lowercased title, subtext, or any keyword.\n *\n * Ranking (stable): exact title match > title startsWith > everything else in\n * original order.\n */\nexport function filterSlashItems(\n\titems: SlashItem[],\n\tquery: string\n): SlashItem[] {\n\tconst needle = query.trim().toLowerCase();\n\n\tif (needle === '') return items;\n\n\tconst matches = items.filter((item) => {\n\t\tif (item.title.toLowerCase().includes(needle)) return true;\n\n\t\tif (item.subtext?.toLowerCase().includes(needle)) return true;\n\n\t\treturn (\n\t\t\titem.keywords?.some((kw) => kw.toLowerCase().includes(needle)) ?? false\n\t\t);\n\t});\n\n\tconst rankOf = (title: string) => {\n\t\tconst lower = title.toLowerCase();\n\n\t\tif (lower === needle) return 0;\n\n\t\tif (lower.startsWith(needle)) return 1;\n\n\t\treturn 2;\n\t};\n\n\treturn matches\n\t\t.map((item, index) => ({ item, index, rank: rankOf(item.title) }))\n\t\t.sort((a, b) => a.rank - b.rank || a.index - b.index)\n\t\t.map(({ item }) => item);\n}\n"],"mappings":";AAWO,SAAS,iBACf,OACA,OACc;AACd,QAAM,SAAS,MAAM,KAAK,EAAE,YAAY;AAExC,MAAI,WAAW,GAAI,QAAO;AAE1B,QAAM,UAAU,MAAM,OAAO,CAAC,SAAS;AACtC,QAAI,KAAK,MAAM,YAAY,EAAE,SAAS,MAAM,EAAG,QAAO;AAEtD,QAAI,KAAK,SAAS,YAAY,EAAE,SAAS,MAAM,EAAG,QAAO;AAEzD,WACC,KAAK,UAAU,KAAK,CAAC,OAAO,GAAG,YAAY,EAAE,SAAS,MAAM,CAAC,KAAK;AAAA,EAEpE,CAAC;AAED,QAAM,SAAS,CAAC,UAAkB;AACjC,UAAM,QAAQ,MAAM,YAAY;AAEhC,QAAI,UAAU,OAAQ,QAAO;AAE7B,QAAI,MAAM,WAAW,MAAM,EAAG,QAAO;AAErC,WAAO;AAAA,EACR;AAEA,SAAO,QACL,IAAI,CAAC,MAAM,WAAW,EAAE,MAAM,OAAO,MAAM,OAAO,KAAK,KAAK,EAAE,EAAE,EAChE,KAAK,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EACnD,IAAI,CAAC,EAAE,KAAK,MAAM,IAAI;AACzB;","names":[]}
|