@mp-lb/mdkit 0.3.0 → 0.3.1
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEditorState } from "@tiptap/react";
|
|
3
3
|
import { BubbleMenu } from "@tiptap/react/menus";
|
|
4
|
-
import { Bold, Code2, Heading1, Heading2, Italic, Link2, List, ListOrdered, Quote, Strikethrough, } from "lucide-react";
|
|
4
|
+
import { Bold, Code2, Heading1, Heading2, Heading3, Italic, Link2, List, ListOrdered, Quote, Strikethrough, } from "lucide-react";
|
|
5
5
|
import { joinClassNames } from "../ui/joinClassNames.js";
|
|
6
6
|
const toolbarActiveStateIsEqual = (left, right) => {
|
|
7
7
|
if (!right) {
|
|
@@ -13,6 +13,7 @@ const toolbarActiveStateIsEqual = (left, right) => {
|
|
|
13
13
|
left.codeBlock === right.codeBlock &&
|
|
14
14
|
left.heading1 === right.heading1 &&
|
|
15
15
|
left.heading2 === right.heading2 &&
|
|
16
|
+
left.heading3 === right.heading3 &&
|
|
16
17
|
left.italic === right.italic &&
|
|
17
18
|
left.link === right.link &&
|
|
18
19
|
left.orderedList === right.orderedList &&
|
|
@@ -27,6 +28,7 @@ const useToolbarActiveState = (editor) => useEditorState({
|
|
|
27
28
|
codeBlock: currentEditor.isActive("codeBlock"),
|
|
28
29
|
heading1: currentEditor.isActive("heading", { level: 1 }),
|
|
29
30
|
heading2: currentEditor.isActive("heading", { level: 2 }),
|
|
31
|
+
heading3: currentEditor.isActive("heading", { level: 3 }),
|
|
30
32
|
italic: currentEditor.isActive("italic"),
|
|
31
33
|
link: currentEditor.isActive("link"),
|
|
32
34
|
orderedList: currentEditor.isActive("orderedList"),
|
|
@@ -80,5 +82,5 @@ export const MarkdownBubbleMenu = ({ editor }) => {
|
|
|
80
82
|
const activeState = useToolbarActiveState(editor);
|
|
81
83
|
return (_jsxs(BubbleMenu, { className: "mp-lb-mdkit-toolbar", editor: editor, options: {
|
|
82
84
|
placement: "top",
|
|
83
|
-
}, shouldShow: shouldShowMarkdownBubbleMenu, children: [_jsx(ToolbarButton, { ariaLabel: "Bold", isActive: activeState.bold, onAction: () => editor.chain().focus().toggleBold().run(), children: _jsx(Bold, {}) }), _jsx(ToolbarButton, { ariaLabel: "Italic", isActive: activeState.italic, onAction: () => editor.chain().focus().toggleItalic().run(), children: _jsx(Italic, {}) }), _jsx(ToolbarButton, { ariaLabel: "Strikethrough", isActive: activeState.strike, onAction: () => editor.chain().focus().toggleStrike().run(), children: _jsx(Strikethrough, {}) }), _jsx(ToolbarButton, { ariaLabel: "Code block", isActive: activeState.codeBlock, onAction: () => editor.chain().focus().toggleCodeBlock().run(), children: _jsx(Code2, {}) }), _jsx("div", { className: "mp-lb-mdkit-toolbar-divider" }), _jsx(ToolbarButton, { ariaLabel: "Heading 1", isActive: activeState.heading1, onAction: () => editor.chain().focus().toggleHeading({ level: 1 }).run(), children: _jsx(Heading1, {}) }), _jsx(ToolbarButton, { ariaLabel: "Heading 2", isActive: activeState.heading2, onAction: () => editor.chain().focus().toggleHeading({ level: 2 }).run(), children: _jsx(Heading2, {}) }), _jsx("div", { className: "mp-lb-mdkit-toolbar-divider" }), _jsx(ToolbarButton, { ariaLabel: "Bullet list", isActive: activeState.bulletList, onAction: () => editor.chain().focus().toggleBulletList().run(), children: _jsx(List, {}) }), _jsx(ToolbarButton, { ariaLabel: "Ordered list", isActive: activeState.orderedList, onAction: () => editor.chain().focus().toggleOrderedList().run(), children: _jsx(ListOrdered, {}) }), _jsx(ToolbarButton, { ariaLabel: "Blockquote", isActive: activeState.blockquote, onAction: () => editor.chain().focus().toggleBlockquote().run(), children: _jsx(Quote, {}) }), _jsx("div", { className: "mp-lb-mdkit-toolbar-divider" }), _jsx(ToolbarButton, { ariaLabel: "Link", isActive: activeState.link, onAction: () => setLink(editor), children: _jsx(Link2, {}) })] }));
|
|
85
|
+
}, shouldShow: shouldShowMarkdownBubbleMenu, children: [_jsx(ToolbarButton, { ariaLabel: "Bold", isActive: activeState.bold, onAction: () => editor.chain().focus().toggleBold().run(), children: _jsx(Bold, {}) }), _jsx(ToolbarButton, { ariaLabel: "Italic", isActive: activeState.italic, onAction: () => editor.chain().focus().toggleItalic().run(), children: _jsx(Italic, {}) }), _jsx(ToolbarButton, { ariaLabel: "Strikethrough", isActive: activeState.strike, onAction: () => editor.chain().focus().toggleStrike().run(), children: _jsx(Strikethrough, {}) }), _jsx(ToolbarButton, { ariaLabel: "Code block", isActive: activeState.codeBlock, onAction: () => editor.chain().focus().toggleCodeBlock().run(), children: _jsx(Code2, {}) }), _jsx("div", { className: "mp-lb-mdkit-toolbar-divider" }), _jsx(ToolbarButton, { ariaLabel: "Heading 1", isActive: activeState.heading1, onAction: () => editor.chain().focus().toggleHeading({ level: 1 }).run(), children: _jsx(Heading1, {}) }), _jsx(ToolbarButton, { ariaLabel: "Heading 2", isActive: activeState.heading2, onAction: () => editor.chain().focus().toggleHeading({ level: 2 }).run(), children: _jsx(Heading2, {}) }), _jsx(ToolbarButton, { ariaLabel: "Heading 3", isActive: activeState.heading3, onAction: () => editor.chain().focus().toggleHeading({ level: 3 }).run(), children: _jsx(Heading3, {}) }), _jsx("div", { className: "mp-lb-mdkit-toolbar-divider" }), _jsx(ToolbarButton, { ariaLabel: "Bullet list", isActive: activeState.bulletList, onAction: () => editor.chain().focus().toggleBulletList().run(), children: _jsx(List, {}) }), _jsx(ToolbarButton, { ariaLabel: "Ordered list", isActive: activeState.orderedList, onAction: () => editor.chain().focus().toggleOrderedList().run(), children: _jsx(ListOrdered, {}) }), _jsx(ToolbarButton, { ariaLabel: "Blockquote", isActive: activeState.blockquote, onAction: () => editor.chain().focus().toggleBlockquote().run(), children: _jsx(Quote, {}) }), _jsx("div", { className: "mp-lb-mdkit-toolbar-divider" }), _jsx(ToolbarButton, { ariaLabel: "Link", isActive: activeState.link, onAction: () => setLink(editor), children: _jsx(Link2, {}) })] }));
|
|
84
86
|
};
|
|
@@ -6,7 +6,7 @@ import { MarkdownSearchExtension } from "./MarkdownSearchExtension.js";
|
|
|
6
6
|
export const defaultMdKitMarkdownPlaceholder = "Start writing...";
|
|
7
7
|
export const createMdKitTiptapExtensions = ({ placeholder = defaultMdKitMarkdownPlaceholder, undoRedo = true, } = {}) => [
|
|
8
8
|
StarterKit.configure({
|
|
9
|
-
heading: { levels: [1, 2] },
|
|
9
|
+
heading: { levels: [1, 2, 3, 4, 5, 6] },
|
|
10
10
|
link: {
|
|
11
11
|
HTMLAttributes: {
|
|
12
12
|
rel: "noopener noreferrer",
|