@vkzstudio/muza-ui 1.0.9 → 1.0.11
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/Button/Button.d.ts +2 -1
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/Button.js +58 -55
- package/dist/components/Button/Button.stories.d.ts +2 -1
- package/dist/components/Button/Button.stories.d.ts.map +1 -1
- package/dist/components/Button/buttonVariants.d.ts +1 -1
- package/dist/components/Button/buttonVariants.d.ts.map +1 -1
- package/dist/components/Button/buttonVariants.js +6 -2
- package/dist/components/DataTable/DataTable.d.ts.map +1 -1
- package/dist/components/DataTable/DataTable.js +5 -4
- package/dist/components/DataTable/DataTable.stories.d.ts.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.stories.d.ts.map +1 -1
- package/dist/components/Icons/CustomIcons.d.ts +1 -0
- package/dist/components/Icons/CustomIcons.d.ts.map +1 -1
- package/dist/components/Icons/CustomIcons.js +38 -27
- package/dist/components/Reorderable/Reorderable.d.ts +2 -0
- package/dist/components/Reorderable/Reorderable.d.ts.map +1 -1
- package/dist/components/Reorderable/Reorderable.js +80 -78
- package/dist/components/ReorderableTable/ReorderableTable.d.ts.map +1 -1
- package/dist/components/ReorderableTable/ReorderableTable.stories.d.ts.map +1 -1
- package/dist/components/TextEditor/EditorToolbar.d.ts +18 -0
- package/dist/components/TextEditor/EditorToolbar.d.ts.map +1 -0
- package/dist/components/TextEditor/EditorToolbar.js +175 -0
- package/dist/components/TextEditor/LinkBubbleMenu.d.ts +52 -0
- package/dist/components/TextEditor/LinkBubbleMenu.d.ts.map +1 -0
- package/dist/components/TextEditor/LinkBubbleMenu.js +97 -0
- package/dist/components/TextEditor/TextEditor.d.ts +134 -0
- package/dist/components/TextEditor/TextEditor.d.ts.map +1 -0
- package/dist/components/TextEditor/TextEditor.js +240 -0
- package/dist/components/TextEditor/TextEditor.stories.d.ts +51 -0
- package/dist/components/TextEditor/TextEditor.stories.d.ts.map +1 -0
- package/dist/components/TextEditor/ToolbarButton.d.ts +38 -0
- package/dist/components/TextEditor/ToolbarButton.d.ts.map +1 -0
- package/dist/components/TextEditor/ToolbarButton.js +68 -0
- package/dist/components/TextEditor/ToolbarSeparator.d.ts +22 -0
- package/dist/components/TextEditor/ToolbarSeparator.d.ts.map +1 -0
- package/dist/components/TextEditor/ToolbarSeparator.js +23 -0
- package/dist/components/TextEditor/index.d.ts +4 -0
- package/dist/components/TextEditor/index.d.ts.map +1 -0
- package/dist/components/TextEditor/useLinkEditor.d.ts +37 -0
- package/dist/components/TextEditor/useLinkEditor.d.ts.map +1 -0
- package/dist/components/TextEditor/useLinkEditor.js +32 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.js +140 -132
- package/dist/muza-ui.css +1 -1
- package/dist/node_modules/@popperjs/core/lib/createPopper.js +122 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/contains.js +18 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getBoundingClientRect.js +23 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getClippingRect.js +37 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getCompositeRect.js +32 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getComputedStyle.js +7 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js +10 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getDocumentRect.js +17 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getHTMLElementScroll.js +9 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getLayoutRect.js +13 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getNodeName.js +6 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getNodeScroll.js +10 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getOffsetParent.js +35 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getParentNode.js +18 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getScrollParent.js +10 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getViewportRect.js +21 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getWindow.js +12 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getWindowScroll.js +11 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getWindowScrollBarX.js +9 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/instanceOf.js +20 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/isLayoutViewport.js +7 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/isScrollParent.js +8 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/isTableElement.js +7 -0
- package/dist/node_modules/@popperjs/core/lib/dom-utils/listScrollParents.js +16 -0
- package/dist/node_modules/@popperjs/core/lib/enums.js +31 -0
- package/dist/node_modules/@popperjs/core/lib/modifiers/applyStyles.js +47 -0
- package/dist/node_modules/@popperjs/core/lib/modifiers/arrow.js +37 -0
- package/dist/node_modules/@popperjs/core/lib/modifiers/computeStyles.js +99 -0
- package/dist/node_modules/@popperjs/core/lib/modifiers/eventListeners.js +26 -0
- package/dist/node_modules/@popperjs/core/lib/modifiers/flip.js +74 -0
- package/dist/node_modules/@popperjs/core/lib/modifiers/hide.js +44 -0
- package/dist/node_modules/@popperjs/core/lib/modifiers/offset.js +31 -0
- package/dist/node_modules/@popperjs/core/lib/modifiers/popperOffsets.js +19 -0
- package/dist/node_modules/@popperjs/core/lib/modifiers/preventOverflow.js +54 -0
- package/dist/node_modules/@popperjs/core/lib/popper.js +27 -0
- package/dist/node_modules/@popperjs/core/lib/utils/computeAutoPlacement.js +27 -0
- package/dist/node_modules/@popperjs/core/lib/utils/computeOffsets.js +54 -0
- package/dist/node_modules/@popperjs/core/lib/utils/debounce.js +13 -0
- package/dist/node_modules/@popperjs/core/lib/utils/detectOverflow.js +33 -0
- package/dist/node_modules/@popperjs/core/lib/utils/expandToHashMap.js +8 -0
- package/dist/node_modules/@popperjs/core/lib/utils/getAltAxis.js +6 -0
- package/dist/node_modules/@popperjs/core/lib/utils/getBasePlacement.js +6 -0
- package/dist/node_modules/@popperjs/core/lib/utils/getFreshSideObject.js +11 -0
- package/dist/node_modules/@popperjs/core/lib/utils/getMainAxisFromPlacement.js +6 -0
- package/dist/node_modules/@popperjs/core/lib/utils/getOppositePlacement.js +14 -0
- package/dist/node_modules/@popperjs/core/lib/utils/getOppositeVariationPlacement.js +12 -0
- package/dist/node_modules/@popperjs/core/lib/utils/getVariation.js +6 -0
- package/dist/node_modules/@popperjs/core/lib/utils/math.js +6 -0
- package/dist/node_modules/@popperjs/core/lib/utils/mergeByName.js +15 -0
- package/dist/node_modules/@popperjs/core/lib/utils/mergePaddingObject.js +7 -0
- package/dist/node_modules/@popperjs/core/lib/utils/orderModifiers.js +31 -0
- package/dist/node_modules/@popperjs/core/lib/utils/rectToClientRect.js +11 -0
- package/dist/node_modules/@popperjs/core/lib/utils/userAgent.js +9 -0
- package/dist/node_modules/@popperjs/core/lib/utils/within.js +12 -0
- package/dist/node_modules/@tiptap/core/dist/index.js +2857 -0
- package/dist/node_modules/@tiptap/extension-blockquote/dist/index.js +45 -0
- package/dist/node_modules/@tiptap/extension-bold/dist/index.js +76 -0
- package/dist/node_modules/@tiptap/extension-bubble-menu/dist/index.js +129 -0
- package/dist/node_modules/@tiptap/extension-bullet-list/dist/index.js +55 -0
- package/dist/node_modules/@tiptap/extension-code/dist/index.js +54 -0
- package/dist/node_modules/@tiptap/extension-code-block/dist/index.js +136 -0
- package/dist/node_modules/@tiptap/extension-document/dist/index.js +10 -0
- package/dist/node_modules/@tiptap/extension-dropcursor/dist/index.js +21 -0
- package/dist/node_modules/@tiptap/extension-gapcursor/dist/index.js +25 -0
- package/dist/node_modules/@tiptap/extension-hard-break/dist/index.js +56 -0
- package/dist/node_modules/@tiptap/extension-heading/dist/index.js +55 -0
- package/dist/node_modules/@tiptap/extension-history/dist/index.js +36 -0
- package/dist/node_modules/@tiptap/extension-horizontal-rule/dist/index.js +59 -0
- package/dist/node_modules/@tiptap/extension-italic/dist/index.js +75 -0
- package/dist/node_modules/@tiptap/extension-link/dist/index.js +272 -0
- package/dist/node_modules/@tiptap/extension-list-item/dist/index.js +34 -0
- package/dist/node_modules/@tiptap/extension-ordered-list/dist/index.js +73 -0
- package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js +34 -0
- package/dist/node_modules/@tiptap/extension-placeholder/dist/index.js +53 -0
- package/dist/node_modules/@tiptap/extension-strike/dist/index.js +64 -0
- package/dist/node_modules/@tiptap/extension-text/dist/index.js +9 -0
- package/dist/node_modules/@tiptap/react/dist/index.js +709 -0
- package/dist/node_modules/@tiptap/starter-kit/dist/index.js +30 -0
- package/dist/node_modules/linkifyjs/dist/linkify.js +707 -0
- package/dist/node_modules/orderedmap/dist/index.js +103 -0
- package/dist/node_modules/prosemirror-commands/dist/index.js +388 -0
- package/dist/node_modules/prosemirror-dropcursor/dist/index.js +86 -0
- package/dist/node_modules/prosemirror-gapcursor/dist/index.js +204 -0
- package/dist/node_modules/prosemirror-history/dist/index.js +248 -0
- package/dist/node_modules/prosemirror-keymap/dist/index.js +62 -0
- package/dist/node_modules/prosemirror-model/dist/index.js +2733 -0
- package/dist/node_modules/prosemirror-schema-list/dist/index.js +88 -0
- package/dist/node_modules/prosemirror-state/dist/index.js +822 -0
- package/dist/node_modules/prosemirror-transform/dist/index.js +1520 -0
- package/dist/node_modules/prosemirror-view/dist/index.js +3794 -0
- package/dist/node_modules/rope-sequence/dist/index.js +100 -0
- package/dist/node_modules/tippy.js/dist/tippy.esm.js +813 -0
- package/dist/node_modules/w3c-keyname/index.js +93 -0
- package/dist/translations/locales/cs.d.ts.map +1 -1
- package/dist/translations/locales/cs.js +18 -0
- package/dist/translations/locales/en.d.ts.map +1 -1
- package/dist/translations/locales/en.js +18 -0
- package/dist/translations/locales/sk.d.ts.map +1 -1
- package/dist/translations/locales/sk.js +18 -0
- package/dist/translations/types.d.ts +22 -0
- package/dist/translations/types.d.ts.map +1 -1
- package/package.json +17 -1
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AnyExtension } from '@tiptap/core';
|
|
3
|
+
import { Editor } from '@tiptap/react';
|
|
4
|
+
/** History toolbar item type */
|
|
5
|
+
type HistoryItem = 'undo' | 'redo';
|
|
6
|
+
/** Heading level type (1-3) */
|
|
7
|
+
type HeadingLevel = 1 | 2 | 3;
|
|
8
|
+
/** Text formatting toolbar item type */
|
|
9
|
+
type FormattingItem = 'bold' | 'italic' | 'strikethrough';
|
|
10
|
+
/** List toolbar item type */
|
|
11
|
+
type ListItem = 'bullet' | 'ordered';
|
|
12
|
+
/**
|
|
13
|
+
* Configuration for the TextEditor toolbar.
|
|
14
|
+
* Each property can be:
|
|
15
|
+
* - `true` to show all items in the group
|
|
16
|
+
* - `false` to hide the entire group
|
|
17
|
+
* - An array of specific items to show
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Show only undo (no redo), heading 2 and 3, and bold formatting
|
|
21
|
+
* const toolbar = {
|
|
22
|
+
* history: ['undo'],
|
|
23
|
+
* headings: [2, 3],
|
|
24
|
+
* formatting: ['bold'],
|
|
25
|
+
* lists: false,
|
|
26
|
+
* link: true,
|
|
27
|
+
* clearFormatting: false,
|
|
28
|
+
* }
|
|
29
|
+
*/
|
|
30
|
+
export interface TextEditorToolbarConfig {
|
|
31
|
+
/** Show history buttons (undo/redo). Default: true */
|
|
32
|
+
history?: boolean | HistoryItem[];
|
|
33
|
+
/** Show heading buttons (H1/H2/H3). Default: true */
|
|
34
|
+
headings?: boolean | HeadingLevel[];
|
|
35
|
+
/** Show formatting buttons (bold/italic/strikethrough). Default: true */
|
|
36
|
+
formatting?: boolean | FormattingItem[];
|
|
37
|
+
/** Show list buttons (bullet/ordered). Default: true */
|
|
38
|
+
lists?: boolean | ListItem[];
|
|
39
|
+
/** Show link button. When false, link pasting is also disabled. Default: true */
|
|
40
|
+
link?: boolean;
|
|
41
|
+
/** Show clear formatting button. Default: true */
|
|
42
|
+
clearFormatting?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Ref handle for imperative TextEditor control.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const editorRef = useRef<TextEditorRef>(null)
|
|
49
|
+
*
|
|
50
|
+
* // Focus the editor
|
|
51
|
+
* editorRef.current?.focus()
|
|
52
|
+
*
|
|
53
|
+
* // Get content
|
|
54
|
+
* const html = editorRef.current?.getHTML()
|
|
55
|
+
*/
|
|
56
|
+
export interface TextEditorRef {
|
|
57
|
+
/** The underlying TipTap editor instance */
|
|
58
|
+
editor: Editor | null;
|
|
59
|
+
/** Focuses the editor */
|
|
60
|
+
focus: () => void;
|
|
61
|
+
/** Removes focus from the editor */
|
|
62
|
+
blur: () => void;
|
|
63
|
+
/** Returns the current content as HTML */
|
|
64
|
+
getHTML: () => string;
|
|
65
|
+
/** Returns the current content as plain text */
|
|
66
|
+
getText: () => string;
|
|
67
|
+
/** Returns true if the editor has no content */
|
|
68
|
+
isEmpty: () => boolean;
|
|
69
|
+
/** Sets the editor content from HTML string */
|
|
70
|
+
setContent: (html: string) => void;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Props for the TextEditor component.
|
|
74
|
+
*/
|
|
75
|
+
export interface TextEditorProps {
|
|
76
|
+
/** Controlled value (HTML string). Use with onChange for controlled mode. */
|
|
77
|
+
value?: string;
|
|
78
|
+
/** Initial value for uncontrolled mode */
|
|
79
|
+
defaultValue?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Fires when content changes. Receives empty string when editor is empty,
|
|
82
|
+
* otherwise HTML content.
|
|
83
|
+
*/
|
|
84
|
+
onChange?: (html: string) => void;
|
|
85
|
+
/** Fires when the editor loses focus */
|
|
86
|
+
onBlur?: () => void;
|
|
87
|
+
/** Fires when the editor gains focus */
|
|
88
|
+
onFocus?: () => void;
|
|
89
|
+
/** Placeholder text shown when editor is empty */
|
|
90
|
+
placeholder?: string;
|
|
91
|
+
/** Label displayed above the editor */
|
|
92
|
+
label?: string;
|
|
93
|
+
/** Helper text displayed below the editor */
|
|
94
|
+
hint?: string;
|
|
95
|
+
/** Tooltip content shown next to the label */
|
|
96
|
+
infoTooltip?: string;
|
|
97
|
+
/** Disables editing and applies disabled styling */
|
|
98
|
+
disabled?: boolean;
|
|
99
|
+
/** Allows viewing but not editing content */
|
|
100
|
+
readOnly?: boolean;
|
|
101
|
+
/** Error state. String shows as error message, boolean only shows error styling. */
|
|
102
|
+
error?: string | boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Toolbar configuration. See TextEditorToolbarConfig for options.
|
|
105
|
+
* @see TextEditorToolbarConfig
|
|
106
|
+
*/
|
|
107
|
+
toolbar?: TextEditorToolbarConfig;
|
|
108
|
+
/** Additional content rendered at the end of the toolbar */
|
|
109
|
+
toolbarExtra?: ReactNode;
|
|
110
|
+
/**
|
|
111
|
+
* Additional TipTap extensions to add to the editor.
|
|
112
|
+
* @example
|
|
113
|
+
* import Mention from '@tiptap/extension-mention'
|
|
114
|
+
* <TextEditor extensions={[Mention.configure({ ... })]} />
|
|
115
|
+
*/
|
|
116
|
+
extensions?: AnyExtension[];
|
|
117
|
+
/** Minimum height of the content area. Default: 200 */
|
|
118
|
+
minHeight?: number | string;
|
|
119
|
+
/** Maximum height of the content area (enables scrolling) */
|
|
120
|
+
maxHeight?: number | string;
|
|
121
|
+
/** Enables vertical resizing. Default: true */
|
|
122
|
+
resizable?: boolean;
|
|
123
|
+
/** Additional class name for the root element */
|
|
124
|
+
className?: string;
|
|
125
|
+
/** Additional class name for the content area */
|
|
126
|
+
contentClassName?: string;
|
|
127
|
+
/** Disables built-in content formatting styles (headings, paragraphs, lists, links). Default: false */
|
|
128
|
+
unstyled?: boolean;
|
|
129
|
+
/** Additional class name for the TipTap editor element */
|
|
130
|
+
editorClassName?: string;
|
|
131
|
+
}
|
|
132
|
+
declare const TextEditor: import('react').ForwardRefExoticComponent<TextEditorProps & import('react').RefAttributes<TextEditorRef>>;
|
|
133
|
+
export { TextEditor };
|
|
134
|
+
//# sourceMappingURL=TextEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextEditor.d.ts","sourceRoot":"","sources":["../../../src/components/TextEditor/TextEditor.tsx"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { jsxs as l, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as R, useEffect as T, useImperativeHandle as I } from "react";
|
|
3
|
+
import { Link as O } from "../../node_modules/@tiptap/extension-link/dist/index.js";
|
|
4
|
+
import { Placeholder as $ } from "../../node_modules/@tiptap/extension-placeholder/dist/index.js";
|
|
5
|
+
import { useEditor as K, EditorContent as W } from "../../node_modules/@tiptap/react/dist/index.js";
|
|
6
|
+
import { StarterKit as Y } from "../../node_modules/@tiptap/starter-kit/dist/index.js";
|
|
7
|
+
import { cva as q } from "class-variance-authority";
|
|
8
|
+
import { EditorToolbar as D } from "./EditorToolbar.js";
|
|
9
|
+
import { LinkBubbleMenu as G } from "./LinkBubbleMenu.js";
|
|
10
|
+
import { useLinkEditor as J } from "./useLinkEditor.js";
|
|
11
|
+
import { useMuzaTranslations as Q } from "../../translations/TranslationContext.js";
|
|
12
|
+
import { Flex as L } from "../Flex/Flex.js";
|
|
13
|
+
import { Typography as E } from "../Typography/Typography.js";
|
|
14
|
+
import { cn as d } from "../../utils/cn.js";
|
|
15
|
+
import { TooltipProvider as X, Tooltip as Z, TooltipTrigger as tt, TooltipContent as et } from "../Tooltip/Tooltip.js";
|
|
16
|
+
import { InfoCircleBold as rt } from "@solar-icons/react-perf";
|
|
17
|
+
const ot = q(
|
|
18
|
+
[
|
|
19
|
+
"overflow-hidden rounded-xl border bg-surface-base-secondary transition-colors",
|
|
20
|
+
"focus-within:border-comp-texteditor-stroke-focused",
|
|
21
|
+
"pb-[calc(var(--spacing-xl)/2)]"
|
|
22
|
+
// Offset scrollbar to make resize handle visible
|
|
23
|
+
],
|
|
24
|
+
{
|
|
25
|
+
variants: {
|
|
26
|
+
state: {
|
|
27
|
+
default: "border-comp-texteditor-stroke-def hover:border-comp-texteditor-stroke-hover",
|
|
28
|
+
disabled: "cursor-not-allowed border-comp-texteditor-stroke-disabled opacity-60",
|
|
29
|
+
error: "border-comp-texteditor-stroke-error"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
defaultVariants: {
|
|
33
|
+
state: "default"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
), it = R(
|
|
37
|
+
({
|
|
38
|
+
value: s,
|
|
39
|
+
defaultValue: C,
|
|
40
|
+
onChange: p,
|
|
41
|
+
onBlur: w,
|
|
42
|
+
onFocus: M,
|
|
43
|
+
placeholder: z = "",
|
|
44
|
+
label: x,
|
|
45
|
+
hint: h,
|
|
46
|
+
infoTooltip: g,
|
|
47
|
+
disabled: i = !1,
|
|
48
|
+
readOnly: f = !1,
|
|
49
|
+
error: a,
|
|
50
|
+
toolbar: n = {},
|
|
51
|
+
toolbarExtra: k,
|
|
52
|
+
extensions: N = [],
|
|
53
|
+
minHeight: u = 200,
|
|
54
|
+
maxHeight: m,
|
|
55
|
+
resizable: H = !0,
|
|
56
|
+
className: U,
|
|
57
|
+
contentClassName: P,
|
|
58
|
+
unstyled: S = !1,
|
|
59
|
+
editorClassName: V
|
|
60
|
+
}, j) => {
|
|
61
|
+
const y = Q(), c = {
|
|
62
|
+
history: n.history ?? !0,
|
|
63
|
+
headings: n.headings ?? !0,
|
|
64
|
+
formatting: n.formatting ?? !0,
|
|
65
|
+
lists: n.lists ?? !0,
|
|
66
|
+
link: n.link ?? !0,
|
|
67
|
+
clearFormatting: n.clearFormatting ?? !0
|
|
68
|
+
}, A = !!k || Object.values(c).some((o) => o !== !1), t = K({
|
|
69
|
+
extensions: [
|
|
70
|
+
Y.configure({
|
|
71
|
+
heading: { levels: [1, 2, 3] },
|
|
72
|
+
bulletList: {
|
|
73
|
+
HTMLAttributes: { class: "list-disc ml-6" }
|
|
74
|
+
},
|
|
75
|
+
orderedList: {
|
|
76
|
+
HTMLAttributes: { class: "list-decimal ml-6" }
|
|
77
|
+
}
|
|
78
|
+
}),
|
|
79
|
+
...c.link ? [
|
|
80
|
+
O.configure({
|
|
81
|
+
openOnClick: !1,
|
|
82
|
+
autolink: !0,
|
|
83
|
+
linkOnPaste: !0,
|
|
84
|
+
HTMLAttributes: {
|
|
85
|
+
target: "_blank",
|
|
86
|
+
rel: "noopener noreferrer"
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
] : [],
|
|
90
|
+
$.configure({
|
|
91
|
+
placeholder: z
|
|
92
|
+
}),
|
|
93
|
+
...N
|
|
94
|
+
],
|
|
95
|
+
content: s ?? C ?? "",
|
|
96
|
+
editable: !i && !f,
|
|
97
|
+
onUpdate: ({ editor: o }) => {
|
|
98
|
+
const b = o.getText().trim(), v = o.getHTML();
|
|
99
|
+
p == null || p(b.length === 0 ? "" : v);
|
|
100
|
+
},
|
|
101
|
+
onBlur: w,
|
|
102
|
+
onFocus: M,
|
|
103
|
+
editorProps: {
|
|
104
|
+
attributes: {
|
|
105
|
+
class: d(
|
|
106
|
+
"outline-none text-sm",
|
|
107
|
+
!S && [
|
|
108
|
+
// Headings
|
|
109
|
+
"[&_h1]:text-3xl [&_h1]:font-semibold [&_h1]:text-text-dark-primary-def [&_h1]:my-3",
|
|
110
|
+
"[&_h2]:text-2xl [&_h2]:font-semibold [&_h2]:text-text-dark-primary-def [&_h2]:my-3",
|
|
111
|
+
"[&_h3]:text-xl [&_h3]:font-semibold [&_h3]:text-text-dark-primary-def [&_h3]:my-3",
|
|
112
|
+
// Paragraphs
|
|
113
|
+
"[&_p]:text-text-dark-primary-def [&_p]:my-2",
|
|
114
|
+
// Text formatting
|
|
115
|
+
"[&_strong]:text-text-dark-primary-def [&_strong]:font-semibold",
|
|
116
|
+
"[&_em]:text-text-dark-primary-def",
|
|
117
|
+
// Links
|
|
118
|
+
"[&_a]:text-text-brand-def [&_a]:underline",
|
|
119
|
+
// Lists
|
|
120
|
+
"[&_ul]:my-2 [&_ul]:ml-6 [&_ul]:list-disc",
|
|
121
|
+
"[&_ol]:my-2 [&_ol]:ml-6 [&_ol]:list-decimal",
|
|
122
|
+
"[&_li]:my-1",
|
|
123
|
+
"[&_hr]:my-3xl [&_hr]:border-stroke-base-secondary"
|
|
124
|
+
],
|
|
125
|
+
// Placeholder (always applied)
|
|
126
|
+
"[&_.is-empty]:before:content-[attr(data-placeholder)] [&_.is-empty]:before:text-comp-input-text-placeholder [&_.is-empty]:before:float-left [&_.is-empty]:before:h-0 [&_.is-empty]:before:pointer-events-none",
|
|
127
|
+
V
|
|
128
|
+
),
|
|
129
|
+
// Inline styles needed because Tailwind CSS 4 JIT doesn't apply to dynamically created elements
|
|
130
|
+
style: "width: 100%; min-height: 100%; max-width: none;",
|
|
131
|
+
role: "textbox",
|
|
132
|
+
"aria-multiline": "true"
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
T(() => {
|
|
137
|
+
if (t && s !== void 0) {
|
|
138
|
+
const o = t.getHTML();
|
|
139
|
+
(s || "<p></p>") !== (o || "<p></p>") && t.commands.setContent(s, !1);
|
|
140
|
+
}
|
|
141
|
+
}, [t, s]), T(() => {
|
|
142
|
+
t && t.setEditable(!i && !f);
|
|
143
|
+
}, [t, i, f]), I(
|
|
144
|
+
j,
|
|
145
|
+
() => ({
|
|
146
|
+
editor: t,
|
|
147
|
+
focus: () => t == null ? void 0 : t.commands.focus(),
|
|
148
|
+
blur: () => t == null ? void 0 : t.commands.blur(),
|
|
149
|
+
getHTML: () => (t == null ? void 0 : t.getHTML()) ?? "",
|
|
150
|
+
getText: () => (t == null ? void 0 : t.getText()) ?? "",
|
|
151
|
+
isEmpty: () => (t == null ? void 0 : t.isEmpty) ?? !0,
|
|
152
|
+
setContent: (o) => t == null ? void 0 : t.commands.setContent(o)
|
|
153
|
+
}),
|
|
154
|
+
[t]
|
|
155
|
+
);
|
|
156
|
+
const r = J(t), B = i ? "disabled" : a ? "error" : "default", _ = typeof a == "string" ? a : void 0, F = {
|
|
157
|
+
minHeight: typeof u == "number" ? `${u}px` : u,
|
|
158
|
+
maxHeight: m ? typeof m == "number" ? `${m}px` : m : void 0,
|
|
159
|
+
resize: H && !i ? "vertical" : "none"
|
|
160
|
+
};
|
|
161
|
+
return /* @__PURE__ */ l(L, { direction: "column", className: d("gap-comp-input-gap", U), children: [
|
|
162
|
+
x && /* @__PURE__ */ l(L, { align: "center", gap: "2xs", children: [
|
|
163
|
+
/* @__PURE__ */ e(
|
|
164
|
+
E,
|
|
165
|
+
{
|
|
166
|
+
component: "label",
|
|
167
|
+
weight: "regular",
|
|
168
|
+
size: "sm",
|
|
169
|
+
className: "text-comp-select-text-primary",
|
|
170
|
+
fixY: !0,
|
|
171
|
+
children: x
|
|
172
|
+
}
|
|
173
|
+
),
|
|
174
|
+
g && /* @__PURE__ */ e(X, { children: /* @__PURE__ */ l(Z, { children: [
|
|
175
|
+
/* @__PURE__ */ e(tt, { asChild: !0, children: /* @__PURE__ */ e(rt, { className: "cursor-help text-comp-info-ico-def hover:text-comp-info-ico-hover" }) }),
|
|
176
|
+
/* @__PURE__ */ e(et, { children: g })
|
|
177
|
+
] }) })
|
|
178
|
+
] }),
|
|
179
|
+
/* @__PURE__ */ l("div", { className: ot({ state: B }), children: [
|
|
180
|
+
A && /* @__PURE__ */ e(
|
|
181
|
+
D,
|
|
182
|
+
{
|
|
183
|
+
editor: t,
|
|
184
|
+
toolbarConfig: c,
|
|
185
|
+
disabled: i,
|
|
186
|
+
translations: y.textEditor,
|
|
187
|
+
onLinkClick: r.handleLinkToolbarClick,
|
|
188
|
+
toolbarExtra: k
|
|
189
|
+
}
|
|
190
|
+
),
|
|
191
|
+
/* @__PURE__ */ l(
|
|
192
|
+
"div",
|
|
193
|
+
{
|
|
194
|
+
className: d(
|
|
195
|
+
"relative overflow-auto px-2xl py-xl",
|
|
196
|
+
"mr-[calc(var(--spacing-xl)/2)]",
|
|
197
|
+
"pr-[calc(var(--spacing-2xl)-var(--spacing-xl)/2)]",
|
|
198
|
+
// Compensate for scrollbar offset
|
|
199
|
+
P
|
|
200
|
+
),
|
|
201
|
+
style: F,
|
|
202
|
+
children: [
|
|
203
|
+
/* @__PURE__ */ e(W, { editor: t, className: "h-full w-full" }),
|
|
204
|
+
t && c.link && /* @__PURE__ */ e(
|
|
205
|
+
G,
|
|
206
|
+
{
|
|
207
|
+
editor: t,
|
|
208
|
+
linkUrl: r.linkUrl,
|
|
209
|
+
isEditingLink: r.isEditingLink,
|
|
210
|
+
onUrlChange: r.setLinkUrl,
|
|
211
|
+
onEdit: r.handleOpenLinkEdit,
|
|
212
|
+
onSave: r.handleSaveLink,
|
|
213
|
+
onRemove: r.handleRemoveLink,
|
|
214
|
+
onCancel: r.handleCancelEdit,
|
|
215
|
+
translations: y.textEditor
|
|
216
|
+
}
|
|
217
|
+
)
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
)
|
|
221
|
+
] }),
|
|
222
|
+
(h || _) && /* @__PURE__ */ e(
|
|
223
|
+
E,
|
|
224
|
+
{
|
|
225
|
+
component: "span",
|
|
226
|
+
size: "sm",
|
|
227
|
+
weight: "regular",
|
|
228
|
+
className: d("text-comp-select-text-secondary", {
|
|
229
|
+
"text-comp-input-text-error": a
|
|
230
|
+
}),
|
|
231
|
+
children: _ || h
|
|
232
|
+
}
|
|
233
|
+
)
|
|
234
|
+
] });
|
|
235
|
+
}
|
|
236
|
+
);
|
|
237
|
+
it.displayName = "TextEditor";
|
|
238
|
+
export {
|
|
239
|
+
it as TextEditor
|
|
240
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { TextEditor } from './index';
|
|
3
|
+
declare const meta: Meta<typeof TextEditor>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof TextEditor>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Controlled: Story;
|
|
8
|
+
export declare const WithFormIntegration: Story;
|
|
9
|
+
export declare const AllStates: Story;
|
|
10
|
+
export declare const WithExampleContent: Story;
|
|
11
|
+
export declare const ReducedToolbar: Story;
|
|
12
|
+
export declare const WithToolbarExtra: Story;
|
|
13
|
+
export declare const CustomSizing: Story;
|
|
14
|
+
export declare const WithCustomHighlight: Story;
|
|
15
|
+
/**
|
|
16
|
+
* Demonstrates how to extend the TextEditor with TipTap extensions.
|
|
17
|
+
*
|
|
18
|
+
* This example uses the Mention extension to allow @-mentions in the editor.
|
|
19
|
+
* Type @ followed by a name to see the mention suggestions.
|
|
20
|
+
*
|
|
21
|
+
* **Note for consumers:** To use the Mention extension, install:
|
|
22
|
+
* ```bash
|
|
23
|
+
* npm install @tiptap/extension-mention @tiptap/suggestion tippy.js
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* The TextEditor accepts an `extensions` prop, allowing you to add
|
|
27
|
+
* any TipTap extension to extend its functionality.
|
|
28
|
+
*/
|
|
29
|
+
export declare const WithMentions: Story;
|
|
30
|
+
/**
|
|
31
|
+
* Demonstrates how to re-create the editor when extensions depend on async data.
|
|
32
|
+
*
|
|
33
|
+
* TipTap's `useEditor` creates the editor once on mount. If extensions are built
|
|
34
|
+
* from data fetched after mount (e.g. mention user lists from an API), the editor
|
|
35
|
+
* won't pick them up. Use React's `key` prop to force a clean unmount/remount
|
|
36
|
+
* when the data arrives.
|
|
37
|
+
*
|
|
38
|
+
* **Note:** TipTap's `useEditor` accepts a `deps` array, but using it causes a
|
|
39
|
+
* DOM conflict (`insertBefore` error) because TipTap imperatively removes DOM
|
|
40
|
+
* nodes that React still references during reconciliation. The `key` approach
|
|
41
|
+
* avoids this entirely — React does a clean teardown before mounting the new instance.
|
|
42
|
+
*
|
|
43
|
+
* **Steps to verify:**
|
|
44
|
+
* 1. Type some text in the editor
|
|
45
|
+
* 2. Click "Load mentions" — editor remounts cleanly without errors
|
|
46
|
+
* 3. Type @ to see the loaded mention suggestions
|
|
47
|
+
*/
|
|
48
|
+
export declare const WithAsyncExtensions: Story;
|
|
49
|
+
export declare const Unstyled: Story;
|
|
50
|
+
export declare const ToolbarButtonStates: Story;
|
|
51
|
+
//# sourceMappingURL=TextEditor.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextEditor.stories.d.ts","sourceRoot":"","sources":["../../../src/components/TextEditor/TextEditor.stories.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAO3D,OAAO,EACL,UAAU,EAIX,MAAM,SAAS,CAAA;AAEhB,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,UAAU,CAmKjC,CAAA;AAED,eAAe,IAAI,CAAA;AACnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,UAAU,CAAC,CAAA;AAGxC,eAAO,MAAM,OAAO,EAAE,KAOrB,CAAA;AAGD,eAAO,MAAM,UAAU,EAAE,KAsBxB,CAAA;AAGD,eAAO,MAAM,mBAAmB,EAAE,KA6BjC,CAAA;AAGD,eAAO,MAAM,SAAS,EAAE,KAqDvB,CAAA;AAGD,eAAO,MAAM,kBAAkB,EAAE,KAchC,CAAA;AAGD,eAAO,MAAM,cAAc,EAAE,KAgB5B,CAAA;AAGD,eAAO,MAAM,gBAAgB,EAAE,KAgC9B,CAAA;AAGD,eAAO,MAAM,YAAY,EAAE,KA8B1B,CAAA;AAGD,eAAO,MAAM,mBAAmB,EAAE,KAgCjC,CAAA;AAqKD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,EAAE,KAmD1B,CAAA;AAMD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,mBAAmB,EAAE,KAqDjC,CAAA;AAGD,eAAO,MAAM,QAAQ,EAAE,KA6CtB,CAAA;AAGD,eAAO,MAAM,mBAAmB,EAAE,KAkCjC,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { VariantProps } from 'class-variance-authority';
|
|
3
|
+
/** Style variants for the ToolbarButton component */
|
|
4
|
+
declare const toolbarButtonVariants: (props?: ({
|
|
5
|
+
state?: "default" | "disabled" | "active" | null | undefined;
|
|
6
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
7
|
+
/**
|
|
8
|
+
* Props for the ToolbarButton component.
|
|
9
|
+
*/
|
|
10
|
+
export interface ToolbarButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'>, VariantProps<typeof toolbarButtonVariants> {
|
|
11
|
+
/** Icon element to display in the button */
|
|
12
|
+
icon: ReactNode;
|
|
13
|
+
/** Whether the button is in active/pressed state */
|
|
14
|
+
active?: boolean;
|
|
15
|
+
/** Accessible label for the button (also used as default tooltip) */
|
|
16
|
+
label: string;
|
|
17
|
+
/** Custom tooltip content. Falls back to label if not provided. */
|
|
18
|
+
tooltip?: string;
|
|
19
|
+
/** Shows tooltip on hover. Default: true */
|
|
20
|
+
showTooltip?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Icon button for the TextEditor toolbar.
|
|
24
|
+
*
|
|
25
|
+
* Displays an icon with tooltip and supports active/disabled states.
|
|
26
|
+
* Can be used to extend the toolbar via the `toolbarExtra` prop.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* <ToolbarButton
|
|
30
|
+
* icon={<MyIcon />}
|
|
31
|
+
* label="Custom Action"
|
|
32
|
+
* onClick={handleClick}
|
|
33
|
+
* active={isActive}
|
|
34
|
+
* />
|
|
35
|
+
*/
|
|
36
|
+
declare const ToolbarButton: import('react').ForwardRefExoticComponent<ToolbarButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
37
|
+
export { ToolbarButton, toolbarButtonVariants };
|
|
38
|
+
//# sourceMappingURL=ToolbarButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarButton.d.ts","sourceRoot":"","sources":["../../../src/components/TextEditor/ToolbarButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,SAAS,EAAc,MAAM,OAAO,CAAA;AAC7E,OAAO,EAAE,KAAK,YAAY,EAAO,MAAM,0BAA0B,CAAA;AASjE,qDAAqD;AACrD,QAAA,MAAM,qBAAqB;;8EA2B1B,CAAA;AAED;;GAEG;AACH,MAAM,WAAW,kBACf,SAAQ,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,CAAC,EAC/D,YAAY,CAAC,OAAO,qBAAqB,CAAC;IAC5C,4CAA4C;IAC5C,IAAI,EAAE,SAAS,CAAA;IACf,oDAAoD;IACpD,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAA;IACb,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,4CAA4C;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,aAAa,kHA4ClB,CAAA;AAID,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,CAAA"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx as t, jsxs as m } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as p } from "react";
|
|
3
|
+
import { cva as u } from "class-variance-authority";
|
|
4
|
+
import { TooltipProvider as b, Tooltip as f, TooltipTrigger as x, TooltipContent as g } from "../Tooltip/Tooltip.js";
|
|
5
|
+
import { cn as h } from "../../utils/cn.js";
|
|
6
|
+
const v = u(
|
|
7
|
+
[
|
|
8
|
+
"flex shrink-0 items-center justify-center",
|
|
9
|
+
"size-comp-texteditor-ico-bg-size rounded-sm",
|
|
10
|
+
"[&>svg]:size-icon-xsmall",
|
|
11
|
+
"cursor-pointer transition-colors",
|
|
12
|
+
"disabled:cursor-not-allowed"
|
|
13
|
+
],
|
|
14
|
+
{
|
|
15
|
+
variants: {
|
|
16
|
+
state: {
|
|
17
|
+
default: [
|
|
18
|
+
"bg-comp-texteditor-bg-def text-comp-texteditor-ico-def",
|
|
19
|
+
"hover:bg-comp-texteditor-bg-hover hover:text-comp-texteditor-ico-hover"
|
|
20
|
+
],
|
|
21
|
+
active: [
|
|
22
|
+
"bg-comp-texteditor-bg-focused text-comp-texteditor-ico-focused"
|
|
23
|
+
],
|
|
24
|
+
disabled: [
|
|
25
|
+
"bg-comp-texteditor-bg-disabled text-comp-texteditor-ico-disabled"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
defaultVariants: {
|
|
30
|
+
state: "default"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
), T = p(
|
|
34
|
+
({
|
|
35
|
+
className: s,
|
|
36
|
+
icon: a,
|
|
37
|
+
active: e,
|
|
38
|
+
disabled: o,
|
|
39
|
+
label: r,
|
|
40
|
+
tooltip: d,
|
|
41
|
+
showTooltip: c = !0,
|
|
42
|
+
...n
|
|
43
|
+
}, l) => {
|
|
44
|
+
const i = /* @__PURE__ */ t(
|
|
45
|
+
"button",
|
|
46
|
+
{
|
|
47
|
+
type: "button",
|
|
48
|
+
ref: l,
|
|
49
|
+
className: h(v({ state: o ? "disabled" : e ? "active" : "default", className: s })),
|
|
50
|
+
disabled: o,
|
|
51
|
+
"aria-label": r,
|
|
52
|
+
"aria-pressed": e,
|
|
53
|
+
"aria-disabled": o,
|
|
54
|
+
...n,
|
|
55
|
+
children: a
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
return c ? /* @__PURE__ */ t(b, { children: /* @__PURE__ */ m(f, { children: [
|
|
59
|
+
/* @__PURE__ */ t(x, { asChild: !0, children: i }),
|
|
60
|
+
/* @__PURE__ */ t(g, { children: d ?? r })
|
|
61
|
+
] }) }) : i;
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
T.displayName = "ToolbarButton";
|
|
65
|
+
export {
|
|
66
|
+
T as ToolbarButton,
|
|
67
|
+
v as toolbarButtonVariants
|
|
68
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
/** Props for the ToolbarSeparator component */
|
|
3
|
+
export type ToolbarSeparatorProps = HTMLAttributes<HTMLDivElement>;
|
|
4
|
+
/**
|
|
5
|
+
* Vertical separator for the TextEditor toolbar.
|
|
6
|
+
*
|
|
7
|
+
* Use between toolbar button groups to visually separate different actions.
|
|
8
|
+
* Can be used in custom toolbar extensions via the `toolbarExtra` prop.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* <TextEditor
|
|
12
|
+
* toolbarExtra={
|
|
13
|
+
* <>
|
|
14
|
+
* <ToolbarSeparator />
|
|
15
|
+
* <ToolbarButton icon={<MyIcon />} label="Custom" />
|
|
16
|
+
* </>
|
|
17
|
+
* }
|
|
18
|
+
* />
|
|
19
|
+
*/
|
|
20
|
+
declare const ToolbarSeparator: import('react').ForwardRefExoticComponent<ToolbarSeparatorProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
21
|
+
export { ToolbarSeparator };
|
|
22
|
+
//# sourceMappingURL=ToolbarSeparator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarSeparator.d.ts","sourceRoot":"","sources":["../../../src/components/TextEditor/ToolbarSeparator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAc,MAAM,OAAO,CAAA;AAGvD,+CAA+C;AAC/C,MAAM,MAAM,qBAAqB,GAAG,cAAc,CAAC,cAAc,CAAC,CAAA;AAElE;;;;;;;;;;;;;;;GAeG;AACH,QAAA,MAAM,gBAAgB,kHAgBrB,CAAA;AAID,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as t } from "react";
|
|
3
|
+
import { cn as i } from "../../utils/cn.js";
|
|
4
|
+
const p = t(
|
|
5
|
+
({ className: r, ...o }, a) => /* @__PURE__ */ e(
|
|
6
|
+
"div",
|
|
7
|
+
{
|
|
8
|
+
ref: a,
|
|
9
|
+
className: i(
|
|
10
|
+
"w-px bg-stroke-base-secondary",
|
|
11
|
+
"h-comp-texteditor-ico-bg-size",
|
|
12
|
+
r
|
|
13
|
+
),
|
|
14
|
+
role: "separator",
|
|
15
|
+
"aria-orientation": "vertical",
|
|
16
|
+
...o
|
|
17
|
+
}
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
p.displayName = "ToolbarSeparator";
|
|
21
|
+
export {
|
|
22
|
+
p as ToolbarSeparator
|
|
23
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { TextEditor, type TextEditorProps, type TextEditorRef, type TextEditorToolbarConfig, } from './TextEditor';
|
|
2
|
+
export { ToolbarButton, toolbarButtonVariants, type ToolbarButtonProps, } from './ToolbarButton';
|
|
3
|
+
export { ToolbarSeparator, type ToolbarSeparatorProps, } from './ToolbarSeparator';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TextEditor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,uBAAuB,GAC7B,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,KAAK,kBAAkB,GACxB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
/**
|
|
3
|
+
* Return type for the useLinkEditor hook.
|
|
4
|
+
*/
|
|
5
|
+
export interface UseLinkEditorReturn {
|
|
6
|
+
/** Current URL being edited */
|
|
7
|
+
linkUrl: string;
|
|
8
|
+
/** Sets the URL value */
|
|
9
|
+
setLinkUrl: (url: string) => void;
|
|
10
|
+
/** Whether the link edit input is visible */
|
|
11
|
+
isEditingLink: boolean;
|
|
12
|
+
/** Sets the editing state */
|
|
13
|
+
setIsEditingLink: (editing: boolean) => void;
|
|
14
|
+
/** Opens the link edit input with the current link's URL */
|
|
15
|
+
handleOpenLinkEdit: () => void;
|
|
16
|
+
/** Saves the current URL to the selected text */
|
|
17
|
+
handleSaveLink: () => void;
|
|
18
|
+
/** Removes the link from the selected text */
|
|
19
|
+
handleRemoveLink: () => void;
|
|
20
|
+
/** Cancels editing — removes the link if it was newly created with an empty href */
|
|
21
|
+
handleCancelEdit: () => void;
|
|
22
|
+
/** Handles toolbar link button click - opens edit for existing links or creates new */
|
|
23
|
+
handleLinkToolbarClick: () => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Hook for managing link editing state and actions in the TextEditor.
|
|
27
|
+
*
|
|
28
|
+
* Handles the link bubble menu interactions including opening the edit input,
|
|
29
|
+
* saving links, and removing links from selected text.
|
|
30
|
+
*
|
|
31
|
+
* @param editor - The TipTap editor instance
|
|
32
|
+
* @returns Object containing link state and handler functions
|
|
33
|
+
*
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export declare const useLinkEditor: (editor: Editor | null) => UseLinkEditorReturn;
|
|
37
|
+
//# sourceMappingURL=useLinkEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLinkEditor.d.ts","sourceRoot":"","sources":["../../../src/components/TextEditor/useLinkEditor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE3C;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,yBAAyB;IACzB,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,6CAA6C;IAC7C,aAAa,EAAE,OAAO,CAAA;IACtB,6BAA6B;IAC7B,gBAAgB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IAC5C,4DAA4D;IAC5D,kBAAkB,EAAE,MAAM,IAAI,CAAA;IAC9B,iDAAiD;IACjD,cAAc,EAAE,MAAM,IAAI,CAAA;IAC1B,8CAA8C;IAC9C,gBAAgB,EAAE,MAAM,IAAI,CAAA;IAC5B,oFAAoF;IACpF,gBAAgB,EAAE,MAAM,IAAI,CAAA;IAC5B,uFAAuF;IACvF,sBAAsB,EAAE,MAAM,IAAI,CAAA;CACnC;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,MAAM,GAAG,IAAI,KAAG,mBAgErD,CAAA"}
|